tests: refactor quic tests to use app-socket-api
[vpp.git] / src / plugins / linux-cp / lcp_router.c
index 4aab148..ab8ab16 100644 (file)
@@ -265,7 +265,7 @@ lcp_router_link_mtu (struct rtnl_link *rl, u32 sw_if_index)
   hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
 
   /* If HW interface, try to change hw link */
-  if ((sw->type == sw->sup_sw_if_index) &&
+  if ((sw->sw_if_index == sw->sup_sw_if_index) &&
       (hw->hw_class_index == ethernet_hw_interface_class.index))
     vnet_hw_interface_set_mtu (vnm, hw->hw_if_index, mtu);
   else
@@ -512,33 +512,59 @@ lcp_router_link_up_down (vnet_main_t *vnm, u32 hw_if_index, u32 flags)
        lcp_get_del_dynamic_on_link_down ()))
     {
       u32 fib_index;
+      u32 **fib_index_to_sw_if_index_to_bool = NULL;
+      u32 id, sw_if_index;
       lcp_router_table_t *nlt;
 
       fib_index = fib_table_get_index_for_sw_if_index (FIB_PROTOCOL_IP4,
                                                       hi->sw_if_index);
 
-      pool_foreach (nlt, lcp_router_table_pool)
+      vec_validate_init_empty (fib_index_to_sw_if_index_to_bool, fib_index,
+                              NULL);
+      vec_validate_init_empty (fib_index_to_sw_if_index_to_bool[fib_index],
+                              hi->sw_if_index, false);
+      fib_index_to_sw_if_index_to_bool[fib_index][hi->sw_if_index] = true;
+
+      /* clang-format off */
+      hash_foreach (id, sw_if_index, hi->sub_interface_sw_if_index_by_id,
+      ({
+       fib_index = fib_table_get_index_for_sw_if_index (FIB_PROTOCOL_IP4,
+                                                        sw_if_index);
+       vec_validate_init_empty (fib_index_to_sw_if_index_to_bool, fib_index,
+                                NULL);
+       vec_validate_init_empty (fib_index_to_sw_if_index_to_bool[fib_index],
+                                sw_if_index, false);
+       fib_index_to_sw_if_index_to_bool[fib_index][sw_if_index] = true;
+      }));
+      /* clang-format on */
+
+      vec_foreach_index (fib_index, fib_index_to_sw_if_index_to_bool)
        {
-         if (fib_index == nlt->nlt_fib_index &&
-             FIB_PROTOCOL_IP4 == nlt->nlt_proto)
-           {
-             u32 *sw_if_index_to_bool = NULL;
-
-             vec_validate_init_empty (sw_if_index_to_bool, hi->sw_if_index,
-                                      false);
-             sw_if_index_to_bool[hi->sw_if_index] = true;
+         u32 *sw_if_index_to_bool;
 
-             if (lcp_get_del_static_on_link_down ())
-               lcp_router_table_flush (nlt, sw_if_index_to_bool,
-                                       lcp_rt_fib_src);
-             if (lcp_get_del_dynamic_on_link_down ())
-               lcp_router_table_flush (nlt, sw_if_index_to_bool,
-                                       lcp_rt_fib_src_dynamic);
+         sw_if_index_to_bool = fib_index_to_sw_if_index_to_bool[fib_index];
+         if (NULL == sw_if_index_to_bool)
+           continue;
 
-             vec_free (sw_if_index_to_bool);
-             break;
+         pool_foreach (nlt, lcp_router_table_pool)
+           {
+             if (fib_index == nlt->nlt_fib_index &&
+                 FIB_PROTOCOL_IP4 == nlt->nlt_proto)
+               {
+                 if (lcp_get_del_static_on_link_down ())
+                   lcp_router_table_flush (nlt, sw_if_index_to_bool,
+                                           lcp_rt_fib_src);
+                 if (lcp_get_del_dynamic_on_link_down ())
+                   lcp_router_table_flush (nlt, sw_if_index_to_bool,
+                                           lcp_rt_fib_src_dynamic);
+                 break;
+               }
            }
+
+         vec_free (sw_if_index_to_bool);
        }
+
+      vec_free (fib_index_to_sw_if_index_to_bool);
     }
 
   return 0;
@@ -636,10 +662,25 @@ lcp_router_link_addr_add (struct rtnl_addr *la)
   lcp_router_link_addr_add_del (la, 0);
 }
 
+static walk_rc_t
+lcp_router_address_mark (index_t index, void *ctx)
+{
+  vnet_main_t *vnm = vnet_get_main ();
+
+  lcp_itf_pair_t *lip = lcp_itf_pair_get (index);
+  if (!lip)
+    return WALK_CONTINUE;
+
+  ip_interface_address_mark_one_interface (
+    vnm, vnet_get_sw_interface (vnm, lip->lip_phy_sw_if_index), 0);
+
+  return WALK_CONTINUE;
+}
+
 static void
 lcp_router_link_addr_sync_begin (void)
 {
-  ip_interface_address_mark ();
+  lcp_itf_pair_walk (lcp_router_address_mark, 0);
 
   LCP_ROUTER_INFO ("Begin synchronization of interface addresses");
 }
@@ -669,8 +710,11 @@ lcp_router_neigh_del (struct rtnl_neigh *rn)
     {
       ip_address_t nh;
       int rv;
+      struct nl_addr *rna;
 
-      lcp_router_mk_addr (rtnl_neigh_get_dst (rn), &nh);
+      if ((rna = rtnl_neigh_get_dst (rn)) == NULL)
+       return;
+      lcp_router_mk_addr (rna, &nh);
 
       if (ip46_address_is_multicast (&ip_addr_46 (&nh)))
        {
@@ -718,8 +762,11 @@ lcp_router_neigh_add (struct rtnl_neigh *rn)
       struct nl_addr *ll;
       ip_address_t nh;
       int state;
+      struct nl_addr *rna;
 
-      lcp_router_mk_addr (rtnl_neigh_get_dst (rn), &nh);
+      if ((rna = rtnl_neigh_get_dst (rn)) == NULL)
+       return;
+      lcp_router_mk_addr (rna, &nh);
 
       if (ip46_address_is_multicast (&ip_addr_46 (&nh)))
        {
@@ -769,11 +816,23 @@ lcp_router_neigh_add (struct rtnl_neigh *rn)
                     rtnl_neigh_get_ifindex (rn));
 }
 
+static walk_rc_t
+lcp_router_neighbor_mark (index_t index, void *ctx)
+{
+  lcp_itf_pair_t *lip = lcp_itf_pair_get (index);
+  if (!lip)
+    return WALK_CONTINUE;
+
+  ip_neighbor_walk (AF_IP4, lip->lip_phy_sw_if_index, ip_neighbor_mark_one, 0);
+  ip_neighbor_walk (AF_IP6, lip->lip_phy_sw_if_index, ip_neighbor_mark_one, 0);
+
+  return WALK_CONTINUE;
+}
+
 static void
 lcp_router_neigh_sync_begin (void)
 {
-  ip_neighbor_mark (AF_IP4);
-  ip_neighbor_mark (AF_IP6);
+  lcp_itf_pair_walk (lcp_router_neighbor_mark, 0);
 
   LCP_ROUTER_INFO ("Begin synchronization of neighbors");
 }
@@ -1170,6 +1229,16 @@ lcp_router_route_add (struct rtnl_route *rr)
          else
            {
              fib_source_t fib_src;
+             const fib_route_path_t *rpath;
+
+             vec_foreach (rpath, np.paths)
+               {
+                 if (fib_route_path_is_attached (rpath))
+                   {
+                     entry_flags |= FIB_ENTRY_FLAG_ATTACHED;
+                     break;
+                   }
+               }
 
              fib_src = lcp_router_proto_fib_source (rproto);