]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
libnetlink: Convert GETRULE dumps to use rtnl_ruledump_req
authorDavid Ahern <dsahern@gmail.com>
Sat, 29 Sep 2018 16:34:57 +0000 (09:34 -0700)
committerDavid Ahern <dsahern@gmail.com>
Wed, 3 Oct 2018 01:38:56 +0000 (18:38 -0700)
Add rtnl_ruledump_req for fib fule dumps using the proper fib_rule_hdr
as the header. Convert existing RTM_GETRULE dumps to use it.

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

index 7e9ef640c704b00aa89f7e04d6d2e7a73e37b72e..5f6bbe55fe4a9988ec4c7eb58fd0fd7e28432b79 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_ruledump_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)
index 744d6d88e3433525b7a739ee5fcfbfc09979a64e..60fd4c7e9f935166b046636275faa7d1733891cd 100644 (file)
@@ -615,7 +615,7 @@ static int iprule_list_flush_or_save(int argc, char **argv, int action)
                argc--; argv++;
        }
 
-       if (rtnl_wilddump_request(&rth, af, RTM_GETRULE) < 0) {
+       if (rtnl_ruledump_req(&rth, af) < 0) {
                perror("Cannot send dump request");
                return 1;
        }
index e5cb275faf0941b2d619d337abfa605dd30754d7..89e4d6a2a6620558bee97b66dfc5586d219e7594 100644 (file)
@@ -22,6 +22,7 @@
 #include <errno.h>
 #include <time.h>
 #include <sys/uio.h>
+#include <linux/fib_rules.h>
 #include <linux/if_addrlabel.h>
 #include <linux/if_bridge.h>
 
@@ -249,6 +250,22 @@ int rtnl_routedump_req(struct rtnl_handle *rth, int family)
        return send(rth->fd, &req, sizeof(req), 0);
 }
 
+int rtnl_ruledump_req(struct rtnl_handle *rth, int family)
+{
+       struct {
+               struct nlmsghdr nlh;
+               struct fib_rule_hdr frh;
+       } req = {
+               .nlh.nlmsg_len = sizeof(req),
+               .nlh.nlmsg_type = RTM_GETRULE,
+               .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+               .nlh.nlmsg_seq = rth->dump = ++rth->seq,
+               .frh.family = family
+       };
+
+       return send(rth->fd, &req, sizeof(req), 0);
+}
+
 int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
 {
        struct {