]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
bridge: mdb: print protocol when available
authorNikolay Aleksandrov <nikolay@nvidia.com>
Thu, 8 Oct 2020 13:50:24 +0000 (16:50 +0300)
committerDavid Ahern <dsahern@gmail.com>
Mon, 12 Oct 2020 02:07:50 +0000 (20:07 -0600)
Print the mdb entry's protocol (i.e. who added it)  when it's available if
the user requested to show details (-d). Currently the only possible
values are RTPROT_STATIC (user-space added) or RTPROT_KERNEL
(automatically added by kernel). The value is kernel controlled.

Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
bridge/mdb.c

index b3b58a2385ca69a80c14d82193d4613b3b3d88e1..4cd7ca762b78c8cb70dd92fe2742ee4321d9e8d3 100644 (file)
@@ -203,6 +203,13 @@ static void print_mdb_entry(FILE *f, int ifindex, const struct br_mdb_entry *e,
                        }
                        close_json_array(PRINT_JSON, NULL);
                }
+               if (tb[MDBA_MDB_EATTR_RTPROT]) {
+                       __u8 rtprot = rta_getattr_u8(tb[MDBA_MDB_EATTR_RTPROT]);
+                       SPRINT_BUF(rtb);
+
+                       print_string(PRINT_ANY, "protocol", " proto %s ",
+                                    rtnl_rtprot_n2a(rtprot, rtb, sizeof(rtb)));
+               }
        }
 
        open_json_array(PRINT_JSON, "flags");