]> git.puffer.fish Git - mirror/frr.git/commitdiff
rib: default distance value for new protocols (v2)
authorDavid Lamparter <equinox@diac24.net>
Wed, 26 Aug 2009 22:28:28 +0000 (00:28 +0200)
committerDenis Ovsienko <infrastation@yandex.ru>
Mon, 21 Nov 2011 14:24:28 +0000 (18:24 +0400)
adding protocols and forgetting to update zebra_rib.c currently causes
a beyond end of array access for the default distance value. fix by
making 150 the default distance for unknown routing protocols.

150 is higher than all other IGPs but lower than iBGP (200)

zebra/zebra_rib.c

index 12f3fa5a5b912c32a8a658c27d714e7c545da8b7..8228350f0953538d8d540765e70525adb5601057 100644 (file)
@@ -67,6 +67,7 @@ static const struct
   {ZEBRA_ROUTE_OSPF6,   110},
   {ZEBRA_ROUTE_ISIS,    115},
   {ZEBRA_ROUTE_BGP,      20  /* IBGP is 200. */}
+  /* no entry/default: 150 */
 };
 \f
 /* Vector for routing table.  */
@@ -1511,7 +1512,10 @@ rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p,
   /* Set default distance by route type. */
   if (distance == 0)
     {
-      distance = route_info[type].distance;
+      if ((unsigned)type >= sizeof(route_info) / sizeof(route_info[0]))
+       distance = 150;
+      else
+        distance = route_info[type].distance;
 
       /* iBGP distance is 200. */
       if (type == ZEBRA_ROUTE_BGP && CHECK_FLAG (flags, ZEBRA_FLAG_IBGP))