]> git.proxmox.com Git - mirror_frr.git/blobdiff - babeld/xroute.c
Merge pull request #5793 from ton31337/fix/formatting_show_bgp_summary_failed
[mirror_frr.git] / babeld / xroute.c
index 2e123564ea267dcc13fe5940411a06591d2bd341..61ea5a1ac13b74a9489b923d90bbcffc1c12d3f8 100644 (file)
@@ -43,63 +43,54 @@ static int numxroutes = 0, maxxroutes = 0;
 
 /* Add redistributed route to Babel table. */
 int
-babel_ipv4_route_add (struct zapi_ipv4 *api, struct prefix_ipv4 *prefix,
-                      unsigned int ifindex, struct in_addr *nexthop)
+babel_route_add (struct zapi_route *api)
 {
     unsigned char uchar_prefix[16];
 
-    inaddr_to_uchar(uchar_prefix, &prefix->prefix);
-    debugf(BABEL_DEBUG_ROUTE, "Adding new ipv4 route coming from Zebra.");
-    xroute_add_new_route(uchar_prefix, prefix->prefixlen + 96,
-                         api->metric, ifindex, 0, 1);
-    return 0;
-}
-
-/* Remove redistributed route from Babel table. */
-int
-babel_ipv4_route_delete (struct zapi_ipv4 *api, struct prefix_ipv4 *prefix,
-                         unsigned int ifindex)
-{
-    unsigned char uchar_prefix[16];
-    struct xroute *xroute = NULL;
-
-    inaddr_to_uchar(uchar_prefix, &prefix->prefix);
-    xroute = find_xroute(uchar_prefix, prefix->prefixlen + 96);
-    if (xroute != NULL) {
-        debugf(BABEL_DEBUG_ROUTE, "Removing ipv4 route (from zebra).");
-        flush_xroute(xroute);
+    switch (api->prefix.family) {
+    case AF_INET:
+        inaddr_to_uchar(uchar_prefix, &api->prefix.u.prefix4);
+        debugf(BABEL_DEBUG_ROUTE, "Adding new ipv4 route coming from Zebra.");
+        xroute_add_new_route(uchar_prefix, api->prefix.prefixlen + 96,
+                             api->metric, api->nexthops[0].ifindex, 0, 1);
+        break;
+    case AF_INET6:
+        in6addr_to_uchar(uchar_prefix, &api->prefix.u.prefix6);
+        debugf(BABEL_DEBUG_ROUTE, "Adding new ipv6 route coming from Zebra.");
+        xroute_add_new_route(uchar_prefix, api->prefix.prefixlen,
+                             api->metric, api->nexthops[0].ifindex, 0, 1);
+        break;
     }
-    return 0;
-}
 
-/* Add redistributed route to Babel table. */
-int
-babel_ipv6_route_add (struct zapi_ipv6 *api, struct prefix_ipv6 *prefix,
-                      unsigned int ifindex, struct in6_addr *nexthop)
-{
-    unsigned char uchar_prefix[16];
-
-    in6addr_to_uchar(uchar_prefix, &prefix->prefix);
-    debugf(BABEL_DEBUG_ROUTE, "Adding new route coming from Zebra.");
-    xroute_add_new_route(uchar_prefix, prefix->prefixlen, api->metric, ifindex,
-                         0, 1);
     return 0;
 }
 
 /* Remove redistributed route from Babel table. */
 int
-babel_ipv6_route_delete (struct zapi_ipv6 *api, struct prefix_ipv6 *prefix,
-                         unsigned int ifindex)
+babel_route_delete (struct zapi_route *api)
 {
     unsigned char uchar_prefix[16];
     struct xroute *xroute = NULL;
 
-    in6addr_to_uchar(uchar_prefix, &prefix->prefix);
-    xroute = find_xroute(uchar_prefix, prefix->prefixlen);
-    if (xroute != NULL) {
-        debugf(BABEL_DEBUG_ROUTE, "Removing route (from zebra).");
-        flush_xroute(xroute);
+    switch (api->prefix.family) {
+    case AF_INET:
+        inaddr_to_uchar(uchar_prefix, &api->prefix.u.prefix4);
+        xroute = find_xroute(uchar_prefix, api->prefix.prefixlen + 96);
+        if (xroute != NULL) {
+            debugf(BABEL_DEBUG_ROUTE, "Removing ipv4 route (from zebra).");
+            flush_xroute(xroute);
+        }
+        break;
+    case AF_INET6:
+        in6addr_to_uchar(uchar_prefix, &api->prefix.u.prefix6);
+        xroute = find_xroute(uchar_prefix, api->prefix.prefixlen);
+        if (xroute != NULL) {
+            debugf(BABEL_DEBUG_ROUTE, "Removing ipv6 route (from zebra).");
+            flush_xroute(xroute);
+        }
+        break;
     }
+
     return 0;
 }
 
@@ -178,7 +169,7 @@ add_xroute(unsigned char prefix[16], unsigned char plen,
 
 /* Returns an overestimate of the number of xroutes. */
 int
-xroutes_estimate()
+xroutes_estimate(void)
 {
     return numxroutes;
 }