From: Tudor Cornea Date: Wed, 14 Jul 2021 09:28:11 +0000 (+0300) Subject: net/af_packet: run on kernel without qdisc bypass support X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=8089aa75c513e76a0afc029389a52e545786a9d1;p=dpdk.git net/af_packet: run on kernel without qdisc bypass support Some older kernels do not support the PACKET_QDISC_BYPASS socket option. Such an example is the CentOS 7 kernel (3.10). If we only check for the definition of PACKET_QDISC_BYPASS, it might mean that we will not be able to compile the PMD driver on a newer platform, and run in on a machine with an older kernel. Setting the socket option only if it is specifically requested from the EAL arguments, allows us to have a way to run the PMD compiled against newer kernel headers, on platforms having older kernels. Signed-off-by: Tudor Cornea Signed-off-by: Thomas Monjalon --- diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 2e90e2985c..b73b211fd2 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -748,18 +748,18 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, goto error; } + if (qdisc_bypass) { #if defined(PACKET_QDISC_BYPASS) - rc = setsockopt(qsockfd, SOL_PACKET, PACKET_QDISC_BYPASS, - &qdisc_bypass, sizeof(qdisc_bypass)); - if (rc == -1) { - PMD_LOG_ERRNO(ERR, - "%s: could not set PACKET_QDISC_BYPASS on AF_PACKET socket for %s", - name, pair->value); - goto error; - } -#else - RTE_SET_USED(qdisc_bypass); + rc = setsockopt(qsockfd, SOL_PACKET, PACKET_QDISC_BYPASS, + &qdisc_bypass, sizeof(qdisc_bypass)); + if (rc == -1) { + PMD_LOG_ERRNO(ERR, + "%s: could not set PACKET_QDISC_BYPASS on AF_PACKET socket for %s", + name, pair->value); + goto error; + } #endif + } rc = setsockopt(qsockfd, SOL_PACKET, PACKET_RX_RING, req, sizeof(*req)); if (rc == -1) {