summaryrefslogtreecommitdiffstats
path: root/VNFs/DPPD-PROX/prox_port_cfg.c
diff options
context:
space:
mode:
authorXavier Simonart <xavier.simonart@intel.com>2020-05-29 00:06:45 +0200
committerXavier Simonart <xavier.simonart@intel.com>2020-05-29 23:51:04 +0200
commit33d5f47e781c6986232378b7f8cadd17ac8894fe (patch)
tree3d120cd0d22dfae25dd01a372b1ecfb49ee970e8 /VNFs/DPPD-PROX/prox_port_cfg.c
parent51fd77bfea70da57af93390e1992b16022e2c88f (diff)
VLAN support with vdev devices + few other changes
- vdev devices now support VLAN. - kernel tap device can be configured with a netmask (/24 was always used in previous version). - when sending a (fake) packet to the kernel, this packet will now not be routed by the kernel (i.e. it will leave through the interface configured by PROX). This might change in the futture when PROX supports multiple VLANs per port. But today it prevents ARP being sent on management interfaces. - Log error in case kernel unable to send packet. - Added support for comments (';') in lua sections. - Prevent duplication of local_ipv4 - should now be configured in port section local_ipv4 in core section still supported Change-Id: I8f9a40fe6ad6f3013ff91b58b44627c7f34081e6 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.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/VNFs/DPPD-PROX/prox_port_cfg.c b/VNFs/DPPD-PROX/prox_port_cfg.c
index 2e19d25d..89824d69 100644
--- a/VNFs/DPPD-PROX/prox_port_cfg.c
+++ b/VNFs/DPPD-PROX/prox_port_cfg.c
@@ -165,24 +165,39 @@ void prox_pktmbuf_reinit(void *arg, void *start, __attribute__((unused)) void *e
plog_info("\t\t%s disabled\n", #flag);\
}\
+static inline uint32_t get_netmask(uint8_t prefix)
+{
+ if (prefix == 0)
+ return(~((uint32_t) -1));
+ else
+ return rte_cpu_to_be_32(~((1 << (32 - prefix)) - 1));
+}
-static void set_ip_address (char *devname, uint32_t *ip)
+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);
+
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
memset(&ifreq, 0, sizeof(struct ifreq));
memset(&in_addr, 0, sizeof(struct sockaddr_in));
in_addr.sin_family = AF_INET;
in_addr.sin_addr = *(struct in_addr *)ip;
- fd = socket(in_addr.sin_family, SOCK_DGRAM, 0);
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 %d on device %s: error = %d\n", *ip, devname, errno);
+ PROX_PANIC(rc < 0, "Failed to set IP address %x on device %s: error = %d (%s)\n", *ip, devname, errno, strerror(errno));
+
+ in_addr.sin_addr = *(struct in_addr *)&netmask;
+ ifreq.ifr_netmask = *(struct sockaddr *)&in_addr;
+ rc = ioctl(fd, SIOCSIFNETMASK, &ifreq);
+ PROX_PANIC(rc < 0, "Failed to set netmask %x (prefix %d) on device %s: error = %d (%s)\n", netmask, prefix, devname, errno, strerror(errno));
close(fd);
}
@@ -212,6 +227,7 @@ void init_rte_dev(int use_dummy_devices)
int vdev_port_id = prox_rte_eth_dev_count_avail() - 1;
PROX_PANIC(vdev_port_id >= PROX_MAX_PORTS, "Too many port defined %d >= %d\n", vdev_port_id, PROX_MAX_PORTS);
plog_info("\tCreating device %s, port %d\n", port_cfg->vdev, vdev_port_id);
+ prox_port_cfg[vdev_port_id].is_vdev = 1;
prox_port_cfg[vdev_port_id].active = 1;
prox_port_cfg[vdev_port_id].dpdk_mapping = port_id;
prox_port_cfg[vdev_port_id].n_txq = 1;
@@ -228,7 +244,7 @@ void init_rte_dev(int use_dummy_devices)
prox_port_cfg[port_id].dpdk_mapping = vdev_port_id;
prox_port_cfg[vdev_port_id].ip = rte_be_to_cpu_32(prox_port_cfg[port_id].ip);
- prox_port_cfg[port_id].ip = 0; // So only vdev has an IP associated
+ prox_port_cfg[vdev_port_id].prefix = prox_port_cfg[port_id].prefix;
prox_port_cfg[vdev_port_id].type = prox_port_cfg[port_id].type;
if (prox_port_cfg[vdev_port_id].type == PROX_PORT_MAC_HW) {
// If DPDK port MAC set to HW, then make sure the vdev has the same MAC as DPDK port
@@ -768,8 +784,8 @@ static void init_port(struct prox_port_cfg *port_cfg)
PROX_PANIC(ret < 0, "\n\t\t\trte_eth_dev_start() failed on port %u: error %d\n", port_id, ret);
plog_info(" done: ");
- if (prox_port_cfg[port_id].ip) {
- set_ip_address(prox_port_cfg[port_id].name, &prox_port_cfg[port_id].ip);
+ if ((prox_port_cfg[port_id].ip) && (prox_port_cfg[port_id].is_vdev)) {
+ set_ip_address(prox_port_cfg[port_id].name, &prox_port_cfg[port_id].ip, prox_port_cfg[port_id].prefix);
}
/* Getting link status can be done without waiting if Link
State Interrupt is enabled since in that case, if the link