]> granicus.if.org Git - libnl/commitdiff
Improved printing of route cache entries
authorThomas Graf <tgr@lsx.localdomain>
Mon, 16 Jun 2008 21:59:09 +0000 (23:59 +0200)
committerThomas Graf <tgr@lsx.localdomain>
Mon, 16 Jun 2008 21:59:09 +0000 (23:59 +0200)
lib/route/route_obj.c

index 6fd68c3f0cce59b5c7163328e2c8fed5d40e1a6a..4e14d6d75b122a31485866aee2b2541b00ec1f5d 100644 (file)
@@ -126,19 +126,26 @@ static void route_dump_line(struct nl_object *a, struct nl_dump_params *p)
 {
        struct rtnl_route *r = (struct rtnl_route *) a;
        struct nl_cache *link_cache;
+       int cache = 0, flags;
        char buf[64];
 
        link_cache = nl_cache_mngt_require("route/link");
 
+       if (r->rt_flags & RTM_F_CLONED)
+               cache = 1;
+
        nl_dump_line(p, "%s ", nl_af2str(r->rt_family, buf, sizeof(buf)));
 
+       if (cache)
+               nl_dump(p, "cache ");
+
        if (!(r->ce_mask & ROUTE_ATTR_DST) ||
            nl_addr_get_len(r->rt_dst) == 0)
                nl_dump(p, "default ");
        else
                nl_dump(p, "%s ", nl_addr2str(r->rt_dst, buf, sizeof(buf)));
 
-       if (r->ce_mask & ROUTE_ATTR_TABLE)
+       if (r->ce_mask & ROUTE_ATTR_TABLE && !cache)
                nl_dump(p, "table %s ",
                        rtnl_route_table2str(r->rt_table, buf, sizeof(buf)));
 
@@ -158,11 +165,11 @@ static void route_dump_line(struct nl_object *a, struct nl_dump_params *p)
                }
        }
 
-       if (r->ce_mask & ROUTE_ATTR_FLAGS && r->rt_flags) {
-               int flags = r->rt_flags;
+       flags = r->rt_flags & ~(RTM_F_CLONED);
+       if (r->ce_mask & ROUTE_ATTR_FLAGS && flags) {
 
                nl_dump(p, "<");
-               
+
 #define PRINT_FLAG(f) if (flags & RTNH_F_##f) { \
                flags &= ~RTNH_F_##f; nl_dump(p, #f "%s", flags ? "," : ""); }
                PRINT_FLAG(DEAD);
@@ -173,11 +180,22 @@ static void route_dump_line(struct nl_object *a, struct nl_dump_params *p)
 #define PRINT_FLAG(f) if (flags & RTM_F_##f) { \
                flags &= ~RTM_F_##f; nl_dump(p, #f "%s", flags ? "," : ""); }
                PRINT_FLAG(NOTIFY);
-               PRINT_FLAG(CLONED);
                PRINT_FLAG(EQUALIZE);
                PRINT_FLAG(PREFIX);
 #undef PRINT_FLAG
 
+#define PRINT_FLAG(f) if (flags & RTCF_##f) { \
+               flags &= ~RTCF_##f; nl_dump(p, #f "%s", flags ? "," : ""); }
+               PRINT_FLAG(NOTIFY);
+               PRINT_FLAG(REDIRECTED);
+               PRINT_FLAG(DOREDIRECT);
+               PRINT_FLAG(DIRECTSRC);
+               PRINT_FLAG(DNAT);
+               PRINT_FLAG(BROADCAST);
+               PRINT_FLAG(MULTICAST);
+               PRINT_FLAG(LOCAL);
+#undef PRINT_FLAG
+
                nl_dump(p, ">");
        }