]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
libnetlink: Convert GETMDB dumps to use rtnl_mdbdump_req
authorDavid Ahern <dsahern@gmail.com>
Sat, 29 Sep 2018 17:44:18 +0000 (10:44 -0700)
committerDavid Ahern <dsahern@gmail.com>
Wed, 3 Oct 2018 01:38:31 +0000 (18:38 -0700)
Add rtnl_mdbdump_req for mdb dumps using the proper br_port_msg as
the header. Convert existing RTM_GETMDB dumps to use it.

Signed-off-by: David Ahern <dsahern@gmail.com>
bridge/mdb.c
include/libnetlink.h
lib/libnetlink.c

index 841a36123050c82e805e0f70f7e8cc40ba68f291..03fcc91f0219f00ad6bdf10c2c66425664a67358 100644 (file)
@@ -293,7 +293,7 @@ static int mdb_show(int argc, char **argv)
        new_json_obj(json);
 
        /* get mdb entries*/
-       if (rtnl_wilddump_request(&rth, PF_BRIDGE, RTM_GETMDB) < 0) {
+       if (rtnl_mdbdump_req(&rth, PF_BRIDGE) < 0) {
                perror("Cannot send dump request");
                return -1;
        }
index bacaec8216f75c9bc92494866f418cbcfd9ecc53..8f2b2935074a3329d27d16c1f1d3acd0a49fafd4 100644 (file)
@@ -53,6 +53,8 @@ int rtnl_addrlbldump_req(struct rtnl_handle *rth, int family)
        __attribute__((warn_unused_result));
 int rtnl_routedump_req(struct rtnl_handle *rth, int family)
        __attribute__((warn_unused_result));
+int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
+       __attribute__((warn_unused_result));
 
 int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type)
        __attribute__((warn_unused_result));
index fb5f1714c2d89484fecb2b9ca82cdbf25f000e5c..51ea457cd31a28c6feb150353ca358ef039e5b1a 100644 (file)
@@ -23,6 +23,7 @@
 #include <time.h>
 #include <sys/uio.h>
 #include <linux/if_addrlabel.h>
+#include <linux/if_bridge.h>
 
 #include "libnetlink.h"
 
@@ -248,6 +249,22 @@ int rtnl_routedump_req(struct rtnl_handle *rth, int family)
        return send(rth->fd, &req, sizeof(req), 0);
 }
 
+int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
+{
+       struct {
+               struct nlmsghdr nlh;
+               struct br_port_msg bpm;
+       } req = {
+               .nlh.nlmsg_len = sizeof(req),
+               .nlh.nlmsg_type = RTM_GETMDB,
+               .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+               .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+               .bpm.family = family,
+       };
+
+       return send(rth->fd, &req, sizeof(req), 0);
+}
+
 int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
 {
        return rtnl_wilddump_req_filter(rth, family, type, RTEXT_FILTER_VF);