]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
libnetlink: Convert GETROUTE dumps to use rtnl_routedump_req
authorDavid Ahern <dsahern@gmail.com>
Sat, 29 Sep 2018 15:46:31 +0000 (08:46 -0700)
committerDavid Ahern <dsahern@gmail.com>
Wed, 3 Oct 2018 01:38:27 +0000 (18:38 -0700)
Add rtnl_routedump_req for route dumps using the proper rtmsg
as the header. Convert existing RTM_GETROUTE dumps to use it.

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

index 2d9f6190230c10b3a1af5d0d82b376237f027e8e..a60af316b5051f37e6046b85ea34563a4e702530 100644 (file)
@@ -49,6 +49,8 @@ void rtnl_close(struct rtnl_handle *rth);
 
 int rtnl_addrdump_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_wilddump_request(struct rtnl_handle *rth, int fam, int type)
        __attribute__((warn_unused_result));
index bc23cfea7e8b52b747a9594bb9efde0ab7ca0e9d..c5dfa9cb1538c5171df6f5eca75b15f9ad73284d 100644 (file)
@@ -283,7 +283,7 @@ static int mroute_list(int argc, char **argv)
                filter.iif = idx;
        }
 
-       if (rtnl_wilddump_request(&rth, filter.af, RTM_GETROUTE) < 0) {
+       if (rtnl_routedump_req(&rth, filter.af) < 0) {
                perror("Cannot send dump request");
                return 1;
        }
index 398322fd1f4ff206f0b1f12c7c6cdf03d2cc60a8..699635923764c0ac7a38b9b3c49b49694e20d15e 100644 (file)
@@ -1645,7 +1645,7 @@ static int iproute_flush(int do_ipv6, rtnl_filter_t filter_fn)
        filter.flushe = sizeof(flushb);
 
        for (;;) {
-               if (rtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE) < 0) {
+               if (rtnl_routedump_req(&rth, do_ipv6) < 0) {
                        perror("Cannot send dump request");
                        return -2;
                }
@@ -1891,7 +1891,7 @@ static int iproute_list_flush_or_save(int argc, char **argv, int action)
                return iproute_flush(do_ipv6, filter_fn);
 
        if (!filter.cloned) {
-               if (rtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE) < 0) {
+               if (rtnl_routedump_req(&rth, do_ipv6) < 0) {
                        perror("Cannot send dump request");
                        return -2;
                }
index 749cf4fbb88e4f45c65e0b6f13462fd0040a9c31..fda5309ce44d77fa1ccf9d8a8697e2386e0a631b 100644 (file)
@@ -215,6 +215,22 @@ int rtnl_addrdump_req(struct rtnl_handle *rth, int family)
        return send(rth->fd, &req, sizeof(req), 0);
 }
 
+int rtnl_routedump_req(struct rtnl_handle *rth, int family)
+{
+       struct {
+               struct nlmsghdr nlh;
+               struct rtmsg rtm;
+       } req = {
+               .nlh.nlmsg_len = sizeof(req),
+               .nlh.nlmsg_type = RTM_GETROUTE,
+               .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+               .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+               .rtm.rtm_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);