net/af_packet: run on kernels without qdisc bypass support

Message ID 1626254891-65085-1-git-send-email-tudor.cornea@keysight.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series net/af_packet: run on kernels without qdisc bypass support |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/github-robot success github build: passed
ci/Intel-compilation success Compilation OK
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-testing fail Testing issues
ci/iol-intel-Performance fail Performance Testing issues

Commit Message

Tudor Cornea July 14, 2021, 9:28 a.m. UTC
  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 <tudor.cornea@keysight.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
  

Comments

Thomas Monjalon July 23, 2021, 8:21 a.m. UTC | #1
14/07/2021 11:28, Tudor Cornea:
> 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 <tudor.cornea@keysight.com>

Applied, thanks.
  
Thomas Monjalon July 23, 2021, 8:29 a.m. UTC | #2
I did a change in the patch while applying. See below:

14/07/2021 11:28, Tudor Cornea:
> 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 <tudor.cornea@keysight.com>
> ---
> --- a/drivers/net/af_packet/rte_eth_af_packet.c
> +++ b/drivers/net/af_packet/rte_eth_af_packet.c
> @@ -749,13 +749,15 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
>  		}
>  
>  #if defined(PACKET_QDISC_BYPASS)

I move this #if below...

> -		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;
> +		if (qdisc_bypass) {

... here so we can...

> +			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);

... drop this #else
  

Patch

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 2e90e29..60b485a 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -749,13 +749,15 @@  rte_pmd_init_internals(struct rte_vdev_device *dev,
 		}
 
 #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;
+		if (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);