ip: always set ip rx_sw_if_index 48/34448/3
authorFlorin Coras <fcoras@cisco.com>
Wed, 10 Nov 2021 15:39:51 +0000 (07:39 -0800)
committerFlorin Coras <florin.coras@gmail.com>
Wed, 10 Nov 2021 15:33:02 +0000 (15:33 +0000)
Type: improvement

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I43f6bfa028ee37227f27a2fe0303662bf2631b10

src/vnet/ip/ip4_forward.c
src/vnet/ip/ip6_forward.c
src/vnet/tcp/tcp_inlines.h

index 900a1b4..58af706 100644 (file)
@@ -1534,7 +1534,7 @@ ip4_local_check_src (vlib_buffer_t *b, ip4_header_t *ip0,
       vnet_buffer (b)->ip.rx_sw_if_index = rd->rd_sw_if_index;
     }
   else
-    vnet_buffer (b)->ip.rx_sw_if_index = ~0;
+    vnet_buffer (b)->ip.rx_sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX];
 
   /*
    * vnet_buffer()->ip.adj_index[VLIB_RX] will be set to the index of the
@@ -1622,8 +1622,10 @@ ip4_local_check_src_x2 (vlib_buffer_t **b, ip4_header_t **ip,
     }
   else
     {
-      vnet_buffer (b[0])->ip.rx_sw_if_index = ~0;
-      vnet_buffer (b[1])->ip.rx_sw_if_index = ~0;
+      vnet_buffer (b[0])->ip.rx_sw_if_index =
+       vnet_buffer (b[0])->sw_if_index[VLIB_RX];
+      vnet_buffer (b[1])->ip.rx_sw_if_index =
+       vnet_buffer (b[1])->sw_if_index[VLIB_RX];
     }
 
   /*
index b9f9892..833ce14 100644 (file)
@@ -1481,8 +1481,10 @@ ip6_local_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
            }
          else
            {
-             vnet_buffer (b[0])->ip.rx_sw_if_index = ~0;
-             vnet_buffer (b[1])->ip.rx_sw_if_index = ~0;
+             vnet_buffer (b[0])->ip.rx_sw_if_index =
+               vnet_buffer (b[0])->ip.adj_index[VLIB_RX];
+             vnet_buffer (b[1])->ip.rx_sw_if_index =
+               vnet_buffer (b[1])->ip.adj_index[VLIB_RX];
            }
        }                       /* head_of_feature_arc */
 
@@ -1618,7 +1620,8 @@ ip6_local_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
              vnet_buffer (b[0])->ip.rx_sw_if_index = rd->rd_sw_if_index;
            }
          else
-           vnet_buffer (b[0])->ip.rx_sw_if_index = ~0;
+           vnet_buffer (b[0])->ip.rx_sw_if_index =
+             vnet_buffer (b[0])->ip.adj_index[VLIB_RX];
        }                       /* head_of_feature_arc */
 
       next[0] = lm->local_next_by_ip_protocol[ip->protocol];
index e82f308..d57b305 100644 (file)
@@ -239,10 +239,7 @@ tcp_input_lookup_buffer (vlib_buffer_t * b, u8 thread_index, u32 * error,
 
   /* Set the sw_if_index[VLIB_RX] to the interface we received
    * the connection on (the local interface) */
-  vnet_buffer (b)->sw_if_index[VLIB_RX] =
-    vnet_buffer (b)->ip.rx_sw_if_index != ~0 ?
-      vnet_buffer (b)->ip.rx_sw_if_index :
-      vnet_buffer (b)->sw_if_index[VLIB_RX];
+  vnet_buffer (b)->sw_if_index[VLIB_RX] = vnet_buffer (b)->ip.rx_sw_if_index;
 
   if (is_ip4)
     {