Browse Source

zebra: make fpm netlink_route_info_fill more robust

Having an RTM_ADDROUTE with a rib == NULL would lead
to a crash due to a NULL pointer dereference.

Since an RTM_ADDROUTE without a rib object doesn't make
much sense, print a warning and remove the concerned
route instead.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Tested-by: NetDEF CI System <cisystem@netdef.org>
Christian Franke 2 years ago
parent
commit
51b45a52ad
1 changed files with 8 additions and 3 deletions
  1. 8 3
      zebra/zebra_fpm_netlink.c

+ 8 - 3
zebra/zebra_fpm_netlink.c

@@ -252,11 +252,16 @@ netlink_route_info_fill (netlink_route_info_t *ri, int cmd,
    * An RTM_DELROUTE need not be accompanied by any nexthops,
    * particularly in our communication with the FPM.
    */
-  if (cmd == RTM_DELROUTE && !rib)
+  if (cmd == RTM_DELROUTE)
     goto skip;
 
-  if (rib)
-    ri->rtm_protocol = netlink_proto_from_route_type (rib->type);
+  if (!rib)
+    {
+      zlog_err("netlink_route_info_fill RTM_ADDROUTE called without rib info");
+      return 0;
+    }
+
+  ri->rtm_protocol = netlink_proto_from_route_type (rib->type);
 
   if ((rib->flags & ZEBRA_FLAG_BLACKHOLE) || (rib->flags & ZEBRA_FLAG_REJECT))
     discard = 1;