linux-cp: handle AF_BRIDGE neighbors 61/36961/2
authorMatthew Smith <mgsmith@netgate.com>
Fri, 19 Aug 2022 19:54:40 +0000 (19:54 +0000)
committerNeale Ranns <neale@graphiant.com>
Tue, 23 Aug 2022 22:12:58 +0000 (22:12 +0000)
Type: improvement

VPP crashes when a linux-cp tap is added to a bridge on the host system
because rtnl_neigh_get_dst() returns NULL for the neighbor message that
is sent by the kernel.

Check for NULL before trying to use the address from a neighbor in a
netlink message.

Signed-off-by: Matthew Smith <mgsmith@netgate.com>
Change-Id: I8a683d815a09620df9c0cc76e18df39828428e2c
Signed-off-by: Matthew Smith <mgsmith@netgate.com>
src/plugins/linux-cp/lcp_router.c

index acf0a03..04a6ba0 100644 (file)
@@ -710,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)))
        {
@@ -759,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)))
        {