]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
libnetlink: Convert GETNETCONF dumps to use rtnl_netconfdump_req
authorDavid Ahern <dsahern@gmail.com>
Sat, 29 Sep 2018 16:29:29 +0000 (09:29 -0700)
committerDavid Ahern <dsahern@gmail.com>
Wed, 3 Oct 2018 01:38:34 +0000 (18:38 -0700)
Add rtnl_netconfdump_req for netconf dumps using the proper netconfmsg
as the header. Convert existing RTM_GETNETCONF dumps to use it.

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

index 8f2b2935074a3329d27d16c1f1d3acd0a49fafd4..7e9ef640c704b00aa89f7e04d6d2e7a73e37b72e 100644 (file)
@@ -55,6 +55,8 @@ 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_netconfdump_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 04c4d60807b15301b896679ac90881c89f1499dd..21822e367e112129f8aade7d5b7534479dd78b23 100644 (file)
@@ -210,8 +210,7 @@ static int do_show(int argc, char **argv)
        } else {
                rth.flags = RTNL_HANDLE_F_SUPPRESS_NLERR;
 dump:
-               if (rtnl_wilddump_request(&rth, filter.family,
-                                         RTM_GETNETCONF) < 0) {
+               if (rtnl_netconfdump_req(&rth, filter.family) < 0) {
                        perror("Cannot send dump request");
                        exit(1);
                }
index 51ea457cd31a28c6feb150353ca358ef039e5b1a..e5cb275faf0941b2d619d337abfa605dd30754d7 100644 (file)
@@ -265,6 +265,22 @@ int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
        return send(rth->fd, &req, sizeof(req), 0);
 }
 
+int rtnl_netconfdump_req(struct rtnl_handle *rth, int family)
+{
+       struct {
+               struct nlmsghdr nlh;
+               struct netconfmsg ncm;
+       } req = {
+               .nlh.nlmsg_len = sizeof(req),
+               .nlh.nlmsg_type = RTM_GETNETCONF,
+               .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+               .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+               .ncm.ncm_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);