diff options
author | Xavier Simonart <xavier.simonart@intel.com> | 2020-09-22 12:42:06 +0200 |
---|---|---|
committer | Xavier Simonart <xavier.simonart@intel.com> | 2020-10-16 14:32:53 +0200 |
commit | f9b0da859a9f2a6556f0437d5cff42a0648dcab2 (patch) | |
tree | 3b48c310d87547912a2f0fa3e17c34b0e9a594df /VNFs/DPPD-PROX/prox_port_cfg.c | |
parent | 0d1b97e647224d3d977186523d45555bc819f42a (diff) |
Report failure when tap port is not mapped to real dpdk port.
When using "vdev=" in port section, a tap device and an additional dpdk
port are created. In most cases, we still want to use a real DPDK device
(i.e. bound to an interface such as virtio or a PF or a VF).
PROX will now report by default an error when the used [port] is not a
DPDK bound device.
An additional parameter "virtual=yes" can be added in the port section
in case one want to disable this error checking (e.g. specify additional
parameter for the vdev device).
This patch also fixes a potential endianess issue when configuring IP
addresses.
Change-Id: Iffdd9552308be3b77cfe2067630647acac2c01fe
Signed-off-by: Xavier Simonart <xavier.simonart@intel.com>
Diffstat (limited to 'VNFs/DPPD-PROX/prox_port_cfg.c')
-rw-r--r-- | VNFs/DPPD-PROX/prox_port_cfg.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/VNFs/DPPD-PROX/prox_port_cfg.c b/VNFs/DPPD-PROX/prox_port_cfg.c index 859c4372..60809f1d 100644 --- a/VNFs/DPPD-PROX/prox_port_cfg.c +++ b/VNFs/DPPD-PROX/prox_port_cfg.c @@ -173,13 +173,14 @@ static inline uint32_t get_netmask(uint8_t prefix) return rte_cpu_to_be_32(~((1 << (32 - prefix)) - 1)); } -static void set_ip_address(char *devname, uint32_t *ip, uint8_t prefix) +static void set_ip_address(char *devname, uint32_t ip, uint8_t prefix) { struct ifreq ifreq; struct sockaddr_in in_addr; int fd, rc; uint32_t netmask = get_netmask(prefix); plog_info("Setting netmask to %x\n", netmask); + uint32_t ip_cpu = rte_be_to_cpu_32(ip); fd = socket(AF_INET, SOCK_DGRAM, 0); @@ -187,12 +188,12 @@ static void set_ip_address(char *devname, uint32_t *ip, uint8_t prefix) memset(&in_addr, 0, sizeof(struct sockaddr_in)); in_addr.sin_family = AF_INET; - in_addr.sin_addr = *(struct in_addr *)ip; + in_addr.sin_addr = *(struct in_addr *)&ip_cpu; strncpy(ifreq.ifr_name, devname, IFNAMSIZ); ifreq.ifr_addr = *(struct sockaddr *)&in_addr; rc = ioctl(fd, SIOCSIFADDR, &ifreq); - PROX_PANIC(rc < 0, "Failed to set IP address %x on device %s: error = %d (%s)\n", *ip, devname, errno, strerror(errno)); + PROX_PANIC(rc < 0, "Failed to set IP address %x on device %s: error = %d (%s)\n", ip_cpu, devname, errno, strerror(errno)); in_addr.sin_addr = *(struct in_addr *)&netmask; ifreq.ifr_netmask = *(struct sockaddr *)&in_addr; @@ -210,6 +211,11 @@ void init_rte_dev(int use_dummy_devices) const struct rte_pci_device *pci_dev; for (uint8_t port_id = 0; port_id < PROX_MAX_PORTS; ++port_id) { + if (prox_port_cfg[port_id].active && (prox_port_cfg[port_id].virtual == 0) && (port_id >= prox_rte_eth_dev_count_avail())) { + PROX_PANIC(1, "port %u used but only %u available\n", port_id, prox_rte_eth_dev_count_avail()); + } + } + for (uint8_t port_id = 0; port_id < PROX_MAX_PORTS; ++port_id) { if (!prox_port_cfg[port_id].active) { continue; } @@ -257,7 +263,7 @@ void init_rte_dev(int use_dummy_devices) prox_port_cfg[port_id].dpdk_mapping = vdev_port_id; uint32_t i = 0; while ((i < PROX_MAX_VLAN_TAGS) && (prox_port_cfg[port_id].ip_addr[i].ip)) { - prox_port_cfg[vdev_port_id].ip_addr[i].ip = rte_be_to_cpu_32(prox_port_cfg[port_id].ip_addr[i].ip); + prox_port_cfg[vdev_port_id].ip_addr[i].ip = prox_port_cfg[port_id].ip_addr[i].ip; prox_port_cfg[vdev_port_id].ip_addr[i].prefix = prox_port_cfg[port_id].ip_addr[i].prefix; i++; } @@ -824,7 +830,7 @@ static void init_port(struct prox_port_cfg *port_cfg) if (prox_port_cfg[port_id].is_vdev) { for (int vlan_id = 0; vlan_id < prox_port_cfg[port_id].n_vlans; vlan_id++) { - set_ip_address(prox_port_cfg[port_id].names[vlan_id], &prox_port_cfg[port_id].ip_addr[vlan_id].ip, prox_port_cfg[port_id].ip_addr[vlan_id].prefix); + set_ip_address(prox_port_cfg[port_id].names[vlan_id], prox_port_cfg[port_id].ip_addr[vlan_id].ip, prox_port_cfg[port_id].ip_addr[vlan_id].prefix); } } /* Getting link status can be done without waiting if Link |