From: David Ahern Date: Sat, 29 Sep 2018 16:34:57 +0000 (-0700) Subject: libnetlink: Convert GETRULE dumps to use rtnl_ruledump_req X-Git-Tag: v4.20.0~101^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b05d9a3d5866219b3c772256dc215bb04e65baa5;p=thirdparty%2Fiproute2.git libnetlink: Convert GETRULE dumps to use rtnl_ruledump_req 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 --- diff --git a/include/libnetlink.h b/include/libnetlink.h index 7e9ef640c..5f6bbe55f 100644 --- a/include/libnetlink.h +++ b/include/libnetlink.h @@ -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) diff --git a/ip/iprule.c b/ip/iprule.c index 744d6d88e..60fd4c7e9 100644 --- a/ip/iprule.c +++ b/ip/iprule.c @@ -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; } diff --git a/lib/libnetlink.c b/lib/libnetlink.c index e5cb275fa..89e4d6a2a 100644 --- a/lib/libnetlink.c +++ b/lib/libnetlink.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -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 {