summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/af_packet/af_packet.c
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2022-04-05 12:03:47 +0000
committerBeno�t Ganne <bganne@cisco.com>2022-04-06 11:42:08 +0000
commit2b6479c07ed67940e47a676f3386a2df21c16655 (patch)
tree7163e8b0930a2bcd1808c19ec88d919aef94be8a /src/vnet/devices/af_packet/af_packet.c
parenteecec8ceba7dcd572ff557726e7e253488b13656 (diff)
devices: add cli support to disable qdisc bypass
Type: improvement Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com> Change-Id: Ie5f2bdb8fb559680bab863a7c24a49360e005b58
Diffstat (limited to 'src/vnet/devices/af_packet/af_packet.c')
-rw-r--r--src/vnet/devices/af_packet/af_packet.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/vnet/devices/af_packet/af_packet.c b/src/vnet/devices/af_packet/af_packet.c
index c941d3763cf..a8ab944a513 100644
--- a/src/vnet/devices/af_packet/af_packet.c
+++ b/src/vnet/devices/af_packet/af_packet.c
@@ -191,7 +191,8 @@ af_packet_set_tx_queues (vlib_main_t *vm, af_packet_if_t *apif)
static int
create_packet_v3_sock (int host_if_index, tpacket_req3_t *rx_req,
tpacket_req3_t *tx_req, int *fd, af_packet_ring_t *ring,
- u8 *is_cksum_gso_enabled, u32 fanout_id, u8 is_fanout)
+ u8 *is_cksum_gso_enabled, u32 fanout_id, u8 is_fanout,
+ af_packet_if_flags_t *flags)
{
af_packet_main_t *apm = &af_packet_main;
struct sockaddr_ll sll;
@@ -261,15 +262,18 @@ create_packet_v3_sock (int host_if_index, tpacket_req3_t *rx_req,
*is_cksum_gso_enabled = 1;
#if defined(PACKET_QDISC_BYPASS)
- /* Introduced with Linux 3.14 so the ifdef should eventually be removed */
- if (setsockopt (*fd, SOL_PACKET, PACKET_QDISC_BYPASS, &opt, sizeof (opt)) <
- 0)
- {
- vlib_log_debug (apm->log_class,
- "Failed to set qdisc bypass error "
- "handling option: %s (errno %d)",
- strerror (errno), errno);
- }
+ if (*flags & AF_PACKET_IF_FLAGS_QDISC_BYPASS)
+ /* Introduced with Linux 3.14 so the ifdef should eventually be removed */
+ if (setsockopt (*fd, SOL_PACKET, PACKET_QDISC_BYPASS, &opt, sizeof (opt)) <
+ 0)
+ {
+ // remove the flag
+ *flags &= ~AF_PACKET_IF_FLAGS_QDISC_BYPASS;
+ vlib_log_debug (apm->log_class,
+ "Failed to set qdisc bypass error "
+ "handling option: %s (errno %d)",
+ strerror (errno), errno);
+ }
#endif
if (is_fanout)
@@ -389,7 +393,7 @@ af_packet_queue_init (vlib_main_t *vm, af_packet_if_t *apif,
{
ret = create_packet_v3_sock (apif->host_if_index, rx_req, tx_req, &fd,
&ring, &is_cksum_gso_enabled,
- apif->dev_instance, is_fanout);
+ apif->dev_instance, is_fanout, &arg->flags);
if (ret != 0)
goto error;
@@ -641,6 +645,9 @@ af_packet_create_if (af_packet_create_if_arg_t *arg)
af_packet_set_rx_queues (vm, apif);
af_packet_set_tx_queues (vm, apif);
+ apif->is_qdisc_bypass_enabled =
+ (arg->flags & AF_PACKET_IF_FLAGS_QDISC_BYPASS);
+
if (apif->is_cksum_gso_enabled)
caps |= VNET_HW_IF_CAP_TCP_GSO | VNET_HW_IF_CAP_TX_IP4_CKSUM |
VNET_HW_IF_CAP_TX_TCP_CKSUM | VNET_HW_IF_CAP_TX_UDP_CKSUM;