]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospf6d: fix logging of border router routes
authorRenato Westphal <renato@opensourcerouting.org>
Thu, 19 Aug 2021 02:07:10 +0000 (23:07 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Tue, 24 Aug 2021 14:53:36 +0000 (11:53 -0300)
The prefix of routes to border routers consists of two pieces of
information embedded in a single struct (prefix.u.lp):

  struct prefix {
          uint8_t family;
          uint16_t prefixlen;
          union {
   [snip]
                  struct {
                          struct in_addr id;
                          struct in_addr adv_router;
                  } lp;
          } u __attribute__((aligned(8)));
  };

As such, using prefix2str() (or the %pFX format specifier) isn't
correct when logging such routes.

This commit adds a few special cases here and there to handle
OSPF6_DEST_TYPE_ROUTER routes differently. It'd probably be a good
idea to add a helper function to handle all cases in a single place,
but that can be left for a second moment.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ospf6d/ospf6_abr.c
ospf6d/ospf6_route.c

index 69be807c13d913b0345b281bfbd0c98cf2c3f3d2..650262f1aec851faf4788a4461a3c42afe606e3d 100644 (file)
@@ -172,9 +172,19 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
        uint16_t type;
        int is_debug = 0;
 
-       if (IS_OSPF6_DEBUG_ABR)
-               zlog_debug("%s : start area %s, route %pFX", __func__,
-                          area->name, &route->prefix);
+       if (IS_OSPF6_DEBUG_ABR) {
+               char buf[BUFSIZ];
+
+               if (route->type == OSPF6_DEST_TYPE_ROUTER)
+                       inet_ntop(AF_INET,
+                                 &ADV_ROUTER_IN_PREFIX(&route->prefix), buf,
+                                 sizeof(buf));
+               else
+                       prefix2str(&route->prefix, buf, sizeof(buf));
+
+               zlog_debug("%s : start area %s, route %s", __func__, area->name,
+                          buf);
+       }
 
        if (route->type == OSPF6_DEST_TYPE_ROUTER)
                summary_table = area->summary_router;
@@ -684,8 +694,18 @@ void ospf6_abr_originate_summary(struct ospf6_route *route, struct ospf6 *ospf6)
        struct ospf6_area *oa;
        struct ospf6_route *range = NULL;
 
-       if (IS_OSPF6_DEBUG_ABR)
-               zlog_debug("%s: route %pFX", __func__, &route->prefix);
+       if (IS_OSPF6_DEBUG_ABR) {
+               char buf[BUFSIZ];
+
+               if (route->type == OSPF6_DEST_TYPE_ROUTER)
+                       inet_ntop(AF_INET,
+                                 &ADV_ROUTER_IN_PREFIX(&route->prefix), buf,
+                                 sizeof(buf));
+               else
+                       prefix2str(&route->prefix, buf, sizeof(buf));
+
+               zlog_debug("%s: route %s", __func__, buf);
+       }
 
        if (route->type == OSPF6_DEST_TYPE_NETWORK) {
                oa = ospf6_area_lookup(route->path.area_id, ospf6);
index cd3139d28a54c650463a575f6b95a506a053bc7b..13003b4151802cc50e29130936068260b8140613 100644 (file)
@@ -667,6 +667,9 @@ struct ospf6_route *ospf6_route_add(struct ospf6_route *route,
 
        if (route->type == OSPF6_DEST_TYPE_LINKSTATE)
                ospf6_linkstate_prefix2str(&route->prefix, buf, sizeof(buf));
+       else if (route->type == OSPF6_DEST_TYPE_ROUTER)
+               inet_ntop(AF_INET, &ADV_ROUTER_IN_PREFIX(&route->prefix), buf,
+                         sizeof(buf));
        else
                prefix2str(&route->prefix, buf, sizeof(buf));
 
@@ -899,6 +902,9 @@ void ospf6_route_remove(struct ospf6_route *route,
 
        if (route->type == OSPF6_DEST_TYPE_LINKSTATE)
                ospf6_linkstate_prefix2str(&route->prefix, buf, sizeof(buf));
+       else if (route->type == OSPF6_DEST_TYPE_ROUTER)
+               inet_ntop(AF_INET, &ADV_ROUTER_IN_PREFIX(&route->prefix), buf,
+                         sizeof(buf));
        else
                prefix2str(&route->prefix, buf, sizeof(buf));