linux-cp: stop managing adjacencies for tunnels 90/32890/1
authorAlexander Chernavin <achernavin@netgate.com>
Thu, 24 Jun 2021 14:46:19 +0000 (10:46 -0400)
committerAlexander Chernavin <achernavin@netgate.com>
Thu, 24 Jun 2021 14:46:19 +0000 (10:46 -0400)
Type: fix

Outbound packets which arrive on tun/L3 interfaces use a default
adjacency for the interface & address family from the corresponding
interface pair. However, there are entries in the linux-cp adj table
that are created for them. Managing these entries might cause a
segfault because the rewrite data might exceed the reserved space for
it of 28 bytes in the linux-cp adj key (e.g. in case of GRE IPv6).

With this change, stop creating adjacencies for tun/L3 interfaces in
the linux-cp adj table and delegating them.

Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
Change-Id: I4bcd685860053ab87c65064c182e3ed53fd4fae9

src/plugins/linux-cp/lcp_adj.c

index cbeb91a..bfbc2fe 100644 (file)
@@ -14,6 +14,8 @@
  */
 
 #include <vnet/adj/adj_delegate.h>
+
+#include <linux-cp/lcp_interface.h>
 #include <linux-cp/lcp_adj.h>
 
 #include <vppinfra/bihash_32_8.h>
@@ -133,9 +135,19 @@ lcp_adj_delegate_adj_created (adj_index_t ai)
   lcp_adj_kv_t kv;
   index_t lai = INDEX_INVALID;
   lcp_adj_key_t *adj_key;
+  index_t lipi;
+  lcp_itf_pair_t *lip;
 
   adj = adj_get (ai);
 
+  lipi = lcp_itf_pair_find_by_phy (adj->rewrite_header.sw_if_index);
+  if (lipi == INDEX_INVALID)
+    return;
+
+  lip = lcp_itf_pair_get (lipi);
+  if (lip->lip_host_type == LCP_ITF_HOST_TUN)
+    return;
+
   if (IP_LOOKUP_NEXT_REWRITE == adj->lookup_next_index)
     {
       lcp_adj_mk_key_adj (adj, &kv.k);