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 <dsahern@gmail.com>
This commit is contained in:
David Ahern 2018-09-29 09:34:57 -07:00
parent ddee16bc96
commit b05d9a3d58
3 changed files with 20 additions and 1 deletions

View File

@ -53,6 +53,8 @@ int rtnl_addrlbldump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result)); __attribute__((warn_unused_result));
int rtnl_routedump_req(struct rtnl_handle *rth, int family) int rtnl_routedump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result)); __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) int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result)); __attribute__((warn_unused_result));
int rtnl_netconfdump_req(struct rtnl_handle *rth, int family) int rtnl_netconfdump_req(struct rtnl_handle *rth, int family)

View File

@ -615,7 +615,7 @@ static int iprule_list_flush_or_save(int argc, char **argv, int action)
argc--; argv++; argc--; argv++;
} }
if (rtnl_wilddump_request(&rth, af, RTM_GETRULE) < 0) { if (rtnl_ruledump_req(&rth, af) < 0) {
perror("Cannot send dump request"); perror("Cannot send dump request");
return 1; return 1;
} }

View File

@ -22,6 +22,7 @@
#include <errno.h> #include <errno.h>
#include <time.h> #include <time.h>
#include <sys/uio.h> #include <sys/uio.h>
#include <linux/fib_rules.h>
#include <linux/if_addrlabel.h> #include <linux/if_addrlabel.h>
#include <linux/if_bridge.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); 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) int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
{ {
struct { struct {