Commit cd70f3f5 authored by Stephen Hemminger's avatar Stephen Hemminger

libnetlink: remove unused junk callback

Both rtnl_talk and rtnl_dump had a callback for handling portions
of netlink message that do not match the correct pid or seq.
But this callback was never used by any part of iproute2 so remove
it.
parent d060de7f
...@@ -67,7 +67,7 @@ int genl_ctrl_resolve_family(const char *family) ...@@ -67,7 +67,7 @@ int genl_ctrl_resolve_family(const char *family)
addattr_l(nlh, 128, CTRL_ATTR_FAMILY_NAME, family, strlen(family) + 1); addattr_l(nlh, 128, CTRL_ATTR_FAMILY_NAME, family, strlen(family) + 1);
if (rtnl_talk(&rth, nlh, 0, 0, nlh, NULL, NULL) < 0) { if (rtnl_talk(&rth, nlh, 0, 0, nlh) < 0) {
fprintf(stderr, "Error talking to the kernel\n"); fprintf(stderr, "Error talking to the kernel\n");
goto errout; goto errout;
} }
...@@ -334,7 +334,7 @@ static int ctrl_list(int cmd, int argc, char **argv) ...@@ -334,7 +334,7 @@ static int ctrl_list(int cmd, int argc, char **argv)
goto ctrl_done; goto ctrl_done;
} }
if (rtnl_talk(&rth, nlh, 0, 0, nlh, NULL, NULL) < 0) { if (rtnl_talk(&rth, nlh, 0, 0, nlh) < 0) {
fprintf(stderr, "Error talking to the kernel\n"); fprintf(stderr, "Error talking to the kernel\n");
goto ctrl_done; goto ctrl_done;
} }
...@@ -355,7 +355,7 @@ static int ctrl_list(int cmd, int argc, char **argv) ...@@ -355,7 +355,7 @@ static int ctrl_list(int cmd, int argc, char **argv)
goto ctrl_done; goto ctrl_done;
} }
rtnl_dump_filter(&rth, print_ctrl, stdout, NULL, NULL); rtnl_dump_filter(&rth, print_ctrl, stdout);
} }
......
...@@ -32,21 +32,14 @@ struct rtnl_dump_filter_arg ...@@ -32,21 +32,14 @@ struct rtnl_dump_filter_arg
{ {
rtnl_filter_t filter; rtnl_filter_t filter;
void *arg1; void *arg1;
rtnl_filter_t junk;
void *arg2;
}; };
extern int rtnl_dump_filter_l(struct rtnl_handle *rth, extern int rtnl_dump_filter_l(struct rtnl_handle *rth,
const struct rtnl_dump_filter_arg *arg); const struct rtnl_dump_filter_arg *arg);
extern int rtnl_dump_filter(struct rtnl_handle *rth, rtnl_filter_t filter, extern int rtnl_dump_filter(struct rtnl_handle *rth, rtnl_filter_t filter,
void *arg1, void *arg);
rtnl_filter_t junk,
void *arg2);
extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
unsigned groups, struct nlmsghdr *answer, unsigned groups, struct nlmsghdr *answer);
rtnl_filter_t junk,
void *jarg);
extern int rtnl_send(struct rtnl_handle *rth, const void *buf, int); extern int rtnl_send(struct rtnl_handle *rth, const void *buf, int);
extern int rtnl_send_check(struct rtnl_handle *rth, const void *buf, int); extern int rtnl_send_check(struct rtnl_handle *rth, const void *buf, int);
...@@ -74,7 +67,7 @@ extern int __parse_rtattr_nested_compat(struct rtattr *tb[], int max, struct rta ...@@ -74,7 +67,7 @@ extern int __parse_rtattr_nested_compat(struct rtattr *tb[], int max, struct rta
(parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta))) (parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta)))
#define parse_rtattr_nested_compat(tb, max, rta, data, len) \ #define parse_rtattr_nested_compat(tb, max, rta, data, len) \
({ data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL; \ ({ data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL; \
__parse_rtattr_nested_compat(tb, max, rta, len); }) __parse_rtattr_nested_compat(tb, max, rta, len); })
extern int rtnl_listen(struct rtnl_handle *, rtnl_filter_t handler, extern int rtnl_listen(struct rtnl_handle *, rtnl_filter_t handler,
......
...@@ -833,7 +833,7 @@ static int ipaddr_list_or_flush(int argc, char **argv, int flush) ...@@ -833,7 +833,7 @@ static int ipaddr_list_or_flush(int argc, char **argv, int flush)
exit(1); exit(1);
} }
if (rtnl_dump_filter(&rth, store_nlmsg, &linfo, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, store_nlmsg, &linfo) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
exit(1); exit(1);
} }
...@@ -859,20 +859,14 @@ static int ipaddr_list_or_flush(int argc, char **argv, int flush) ...@@ -859,20 +859,14 @@ static int ipaddr_list_or_flush(int argc, char **argv, int flush)
{ {
.filter = print_addrinfo_secondary, .filter = print_addrinfo_secondary,
.arg1 = stdout, .arg1 = stdout,
.junk = NULL,
.arg2 = NULL
}, },
{ {
.filter = print_addrinfo_primary, .filter = print_addrinfo_primary,
.arg1 = stdout, .arg1 = stdout,
.junk = NULL,
.arg2 = NULL
}, },
{ {
.filter = NULL, .filter = NULL,
.arg1 = NULL, .arg1 = NULL,
.junk = NULL,
.arg2 = NULL
}, },
}; };
if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) { if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) {
...@@ -923,7 +917,7 @@ flush_done: ...@@ -923,7 +917,7 @@ flush_done:
exit(1); exit(1);
} }
if (rtnl_dump_filter(&rth, store_nlmsg, &ainfo, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, store_nlmsg, &ainfo) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
exit(1); exit(1);
} }
...@@ -1214,7 +1208,7 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv) ...@@ -1214,7 +1208,7 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
sizeof(cinfo)); sizeof(cinfo));
} }
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
return -2; return -2;
return 0; return 0;
......
...@@ -114,7 +114,7 @@ static int ipaddrlabel_list(int argc, char **argv) ...@@ -114,7 +114,7 @@ static int ipaddrlabel_list(int argc, char **argv)
return 1; return 1;
} }
if (rtnl_dump_filter(&rth, print_addrlabel, stdout, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, print_addrlabel, stdout) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
return 1; return 1;
} }
...@@ -183,7 +183,7 @@ static int ipaddrlabel_modify(int cmd, int argc, char **argv) ...@@ -183,7 +183,7 @@ static int ipaddrlabel_modify(int cmd, int argc, char **argv)
if (req.ifal.ifal_family == AF_UNSPEC) if (req.ifal.ifal_family == AF_UNSPEC)
req.ifal.ifal_family = AF_INET6; req.ifal.ifal_family = AF_INET6;
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
return 2; return 2;
return 0; return 0;
...@@ -210,7 +210,7 @@ static int flush_addrlabel(const struct sockaddr_nl *who, struct nlmsghdr *n, vo ...@@ -210,7 +210,7 @@ static int flush_addrlabel(const struct sockaddr_nl *who, struct nlmsghdr *n, vo
if (rtnl_open(&rth2, 0) < 0) if (rtnl_open(&rth2, 0) < 0)
return -1; return -1;
if (rtnl_talk(&rth2, n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth2, n, 0, 0, NULL) < 0)
return -2; return -2;
rtnl_close(&rth2); rtnl_close(&rth2);
...@@ -236,7 +236,7 @@ static int ipaddrlabel_flush(int argc, char **argv) ...@@ -236,7 +236,7 @@ static int ipaddrlabel_flush(int argc, char **argv)
return 1; return 1;
} }
if (rtnl_dump_filter(&rth, flush_addrlabel, NULL, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, flush_addrlabel, NULL) < 0) {
fprintf(stderr, "Flush terminated\n"); fprintf(stderr, "Flush terminated\n");
return 1; return 1;
} }
......
...@@ -482,7 +482,7 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv) ...@@ -482,7 +482,7 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
req.i.ifi_index = 0; req.i.ifi_index = 0;
addattr32(&req.n, sizeof(req), IFLA_GROUP, group); addattr32(&req.n, sizeof(req), IFLA_GROUP, group);
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2); exit(2);
return 0; return 0;
} }
...@@ -559,7 +559,7 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv) ...@@ -559,7 +559,7 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
addattr_l(&req.n, sizeof(req), IFLA_IFNAME, name, len); addattr_l(&req.n, sizeof(req), IFLA_IFNAME, name, len);
} }
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2); exit(2);
return 0; return 0;
......
...@@ -174,7 +174,7 @@ static int ipneigh_modify(int cmd, int flags, int argc, char **argv) ...@@ -174,7 +174,7 @@ static int ipneigh_modify(int cmd, int flags, int argc, char **argv)
return -1; return -1;
} }
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2); exit(2);
return 0; return 0;
...@@ -391,7 +391,7 @@ int do_show_or_flush(int argc, char **argv, int flush) ...@@ -391,7 +391,7 @@ int do_show_or_flush(int argc, char **argv, int flush)
exit(1); exit(1);
} }
filter.flushed = 0; filter.flushed = 0;
if (rtnl_dump_filter(&rth, print_neigh, stdout, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, print_neigh, stdout) < 0) {
fprintf(stderr, "Flush terminated\n"); fprintf(stderr, "Flush terminated\n");
exit(1); exit(1);
} }
...@@ -423,7 +423,7 @@ int do_show_or_flush(int argc, char **argv, int flush) ...@@ -423,7 +423,7 @@ int do_show_or_flush(int argc, char **argv, int flush)
exit(1); exit(1);
} }
if (rtnl_dump_filter(&rth, print_neigh, stdout, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, print_neigh, stdout) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
exit(1); exit(1);
} }
......
...@@ -313,7 +313,7 @@ static int ipntable_modify(int cmd, int flags, int argc, char **argv) ...@@ -313,7 +313,7 @@ static int ipntable_modify(int cmd, int flags, int argc, char **argv)
RTA_PAYLOAD(parms_rta)); RTA_PAYLOAD(parms_rta));
} }
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2); exit(2);
return 0; return 0;
...@@ -625,7 +625,7 @@ static int ipntable_show(int argc, char **argv) ...@@ -625,7 +625,7 @@ static int ipntable_show(int argc, char **argv)
exit(1); exit(1);
} }
if (rtnl_dump_filter(&rth, print_ntable, stdout, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, print_ntable, stdout) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
exit(1); exit(1);
} }
......
...@@ -1011,7 +1011,7 @@ int iproute_modify(int cmd, unsigned flags, int argc, char **argv) ...@@ -1011,7 +1011,7 @@ int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
if (req.r.rtm_family == AF_UNSPEC) if (req.r.rtm_family == AF_UNSPEC)
req.r.rtm_family = AF_INET; req.r.rtm_family = AF_INET;
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2); exit(2);
return 0; return 0;
...@@ -1289,7 +1289,7 @@ static int iproute_list_flush_or_save(int argc, char **argv, int action) ...@@ -1289,7 +1289,7 @@ static int iproute_list_flush_or_save(int argc, char **argv, int action)
exit(1); exit(1);
} }
filter.flushed = 0; filter.flushed = 0;
if (rtnl_dump_filter(&rth, filter_fn, stdout, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, filter_fn, stdout) < 0) {
fprintf(stderr, "Flush terminated\n"); fprintf(stderr, "Flush terminated\n");
exit(1); exit(1);
} }
...@@ -1332,7 +1332,7 @@ static int iproute_list_flush_or_save(int argc, char **argv, int action) ...@@ -1332,7 +1332,7 @@ static int iproute_list_flush_or_save(int argc, char **argv, int action)
} }
} }
if (rtnl_dump_filter(&rth, filter_fn, stdout, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, filter_fn, stdout) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
exit(1); exit(1);
} }
...@@ -1453,7 +1453,7 @@ int iproute_get(int argc, char **argv) ...@@ -1453,7 +1453,7 @@ int iproute_get(int argc, char **argv)
if (req.r.rtm_family == AF_UNSPEC) if (req.r.rtm_family == AF_UNSPEC)
req.r.rtm_family = AF_INET; req.r.rtm_family = AF_INET;
if (rtnl_talk(&rth, &req.n, 0, 0, &req.n, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, &req.n) < 0)
exit(2); exit(2);
if (connected && !from_ok) { if (connected && !from_ok) {
...@@ -1494,7 +1494,7 @@ int iproute_get(int argc, char **argv) ...@@ -1494,7 +1494,7 @@ int iproute_get(int argc, char **argv)
req.n.nlmsg_flags = NLM_F_REQUEST; req.n.nlmsg_flags = NLM_F_REQUEST;
req.n.nlmsg_type = RTM_GETROUTE; req.n.nlmsg_type = RTM_GETROUTE;
if (rtnl_talk(&rth, &req.n, 0, 0, &req.n, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, &req.n) < 0)
exit(2); exit(2);
} }
...@@ -1514,7 +1514,7 @@ int restore_handler(const struct sockaddr_nl *nl, struct nlmsghdr *n, void *arg) ...@@ -1514,7 +1514,7 @@ int restore_handler(const struct sockaddr_nl *nl, struct nlmsghdr *n, void *arg)
ll_init_map(&rth); ll_init_map(&rth);
ret = rtnl_talk(&rth, n, 0, 0, n, NULL, NULL); ret = rtnl_talk(&rth, n, 0, 0, n);
if ((ret < 0) && (errno == EEXIST)) if ((ret < 0) && (errno == EEXIST))
ret = 0; ret = 0;
......
...@@ -212,7 +212,7 @@ static int iprule_list(int argc, char **argv) ...@@ -212,7 +212,7 @@ static int iprule_list(int argc, char **argv)
return 1; return 1;
} }
if (rtnl_dump_filter(&rth, print_rule, stdout, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, print_rule, stdout) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
return 1; return 1;
} }
...@@ -355,7 +355,7 @@ static int iprule_modify(int cmd, int argc, char **argv) ...@@ -355,7 +355,7 @@ static int iprule_modify(int cmd, int argc, char **argv)
if (!table_ok && cmd == RTM_NEWRULE) if (!table_ok && cmd == RTM_NEWRULE)
req.r.rtm_table = RT_TABLE_MAIN; req.r.rtm_table = RT_TABLE_MAIN;
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
return 2; return 2;
return 0; return 0;
...@@ -382,7 +382,7 @@ static int flush_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *a ...@@ -382,7 +382,7 @@ static int flush_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *a
if (rtnl_open(&rth2, 0) < 0) if (rtnl_open(&rth2, 0) < 0)
return -1; return -1;
if (rtnl_talk(&rth2, n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth2, n, 0, 0, NULL) < 0)
return -2; return -2;
rtnl_close(&rth2); rtnl_close(&rth2);
...@@ -408,7 +408,7 @@ static int iprule_flush(int argc, char **argv) ...@@ -408,7 +408,7 @@ static int iprule_flush(int argc, char **argv)
return 1; return 1;
} }
if (rtnl_dump_filter(&rth, flush_rule, NULL, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, flush_rule, NULL) < 0) {
fprintf(stderr, "Flush terminated\n"); fprintf(stderr, "Flush terminated\n");
return 1; return 1;
} }
......
...@@ -72,7 +72,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv, ...@@ -72,7 +72,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
req.i.ifi_family = preferred_family; req.i.ifi_family = preferred_family;
req.i.ifi_index = ifi->ifi_index; req.i.ifi_index = ifi->ifi_index;
if (rtnl_talk(&rth, &req.n, 0, 0, &req.n, NULL, NULL) < 0) { if (rtnl_talk(&rth, &req.n, 0, 0, &req.n) < 0) {
get_failed: get_failed:
fprintf(stderr, fprintf(stderr,
"Failed to get existing tunnel info.\n"); "Failed to get existing tunnel info.\n");
......
...@@ -163,7 +163,7 @@ main(int argc, char **argv) ...@@ -163,7 +163,7 @@ main(int argc, char **argv)
write_stamp(fp); write_stamp(fp);
if (rtnl_dump_filter(&rth, dump_msg, fp, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, dump_msg, fp) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
return 1; return 1;
} }
......
...@@ -393,7 +393,7 @@ static int xfrm_policy_modify(int cmd, unsigned flags, int argc, char **argv) ...@@ -393,7 +393,7 @@ static int xfrm_policy_modify(int cmd, unsigned flags, int argc, char **argv)
if (req.xpinfo.sel.family == AF_UNSPEC) if (req.xpinfo.sel.family == AF_UNSPEC)
req.xpinfo.sel.family = AF_INET; req.xpinfo.sel.family = AF_INET;
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2); exit(2);
rtnl_close(&rth); rtnl_close(&rth);
...@@ -670,7 +670,7 @@ static int xfrm_policy_get_or_delete(int argc, char **argv, int delete, ...@@ -670,7 +670,7 @@ static int xfrm_policy_get_or_delete(int argc, char **argv, int delete,
(void *)&ctx, ctx.sctx.len); (void *)&ctx, ctx.sctx.len);
} }
if (rtnl_talk(&rth, &req.n, 0, 0, res_nlbuf, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, res_nlbuf) < 0)
exit(2); exit(2);
rtnl_close(&rth); rtnl_close(&rth);
...@@ -859,7 +859,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall) ...@@ -859,7 +859,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall)
exit(1); exit(1);
} }
if (rtnl_dump_filter(&rth, xfrm_policy_keep, &xb, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, xfrm_policy_keep, &xb) < 0) {
fprintf(stderr, "Delete-all terminated\n"); fprintf(stderr, "Delete-all terminated\n");
exit(1); exit(1);
} }
...@@ -885,7 +885,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall) ...@@ -885,7 +885,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall)
exit(1); exit(1);
} }
if (rtnl_dump_filter(&rth, xfrm_policy_print, stdout, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, xfrm_policy_print, stdout) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
exit(1); exit(1);
} }
...@@ -975,7 +975,7 @@ static int xfrm_spd_getinfo(int argc, char **argv) ...@@ -975,7 +975,7 @@ static int xfrm_spd_getinfo(int argc, char **argv)
if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
exit(1); exit(1);
if (rtnl_talk(&rth, &req.n, 0, 0, &req.n, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, &req.n) < 0)
exit(2); exit(2);
print_spdinfo(&req.n, (void*)stdout); print_spdinfo(&req.n, (void*)stdout);
...@@ -1027,7 +1027,7 @@ static int xfrm_policy_flush(int argc, char **argv) ...@@ -1027,7 +1027,7 @@ static int xfrm_policy_flush(int argc, char **argv)
if (show_stats > 1) if (show_stats > 1)
fprintf(stderr, "Flush policy\n"); fprintf(stderr, "Flush policy\n");
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2); exit(2);
rtnl_close(&rth); rtnl_close(&rth);
......
...@@ -544,7 +544,7 @@ static int xfrm_state_modify(int cmd, unsigned flags, int argc, char **argv) ...@@ -544,7 +544,7 @@ static int xfrm_state_modify(int cmd, unsigned flags, int argc, char **argv)
if (req.xsinfo.family == AF_UNSPEC) if (req.xsinfo.family == AF_UNSPEC)
req.xsinfo.family = AF_INET; req.xsinfo.family = AF_INET;
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2); exit(2);
rtnl_close(&rth); rtnl_close(&rth);
...@@ -681,7 +681,7 @@ static int xfrm_state_allocspi(int argc, char **argv) ...@@ -681,7 +681,7 @@ static int xfrm_state_allocspi(int argc, char **argv)
req.xspi.info.family = AF_INET; req.xspi.info.family = AF_INET;
if (rtnl_talk(&rth, &req.n, 0, 0, res_n, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, res_n) < 0)
exit(2); exit(2);
if (xfrm_state_print(NULL, res_n, (void*)stdout) < 0) { if (xfrm_state_print(NULL, res_n, (void*)stdout) < 0) {
...@@ -871,7 +871,7 @@ static int xfrm_state_get_or_delete(int argc, char **argv, int delete) ...@@ -871,7 +871,7 @@ static int xfrm_state_get_or_delete(int argc, char **argv, int delete)
req.xsid.family = AF_INET; req.xsid.family = AF_INET;
if (delete) { if (delete) {
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2); exit(2);
} else { } else {
char buf[NLMSG_BUF_SIZE]; char buf[NLMSG_BUF_SIZE];
...@@ -879,7 +879,7 @@ static int xfrm_state_get_or_delete(int argc, char **argv, int delete) ...@@ -879,7 +879,7 @@ static int xfrm_state_get_or_delete(int argc, char **argv, int delete)
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
if (rtnl_talk(&rth, &req.n, 0, 0, res_n, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, res_n) < 0)
exit(2); exit(2);
if (xfrm_state_print(NULL, res_n, (void*)stdout) < 0) { if (xfrm_state_print(NULL, res_n, (void*)stdout) < 0) {
...@@ -1015,7 +1015,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall) ...@@ -1015,7 +1015,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall)
exit(1); exit(1);
} }
if (rtnl_dump_filter(&rth, xfrm_state_keep, &xb, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, xfrm_state_keep, &xb) < 0) {
fprintf(stderr, "Delete-all terminated\n"); fprintf(stderr, "Delete-all terminated\n");
exit(1); exit(1);
} }
...@@ -1042,7 +1042,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall) ...@@ -1042,7 +1042,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall)
exit(1); exit(1);
} }
if (rtnl_dump_filter(&rth, xfrm_state_print, stdout, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, xfrm_state_print, stdout) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
exit(1); exit(1);
} }
...@@ -1120,7 +1120,7 @@ static int xfrm_sad_getinfo(int argc, char **argv) ...@@ -1120,7 +1120,7 @@ static int xfrm_sad_getinfo(int argc, char **argv)
if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0)
exit(1); exit(1);
if (rtnl_talk(&rth, &req.n, 0, 0, &req.n, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, &req.n) < 0)
exit(2); exit(2);
print_sadinfo(&req.n, (void*)stdout); print_sadinfo(&req.n, (void*)stdout);
...@@ -1174,7 +1174,7 @@ static int xfrm_state_flush(int argc, char **argv) ...@@ -1174,7 +1174,7 @@ static int xfrm_state_flush(int argc, char **argv)
fprintf(stderr, "Flush state proto=%s\n", fprintf(stderr, "Flush state proto=%s\n",
strxf_xfrmproto(req.xsf.proto)); strxf_xfrmproto(req.xsf.proto));
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
exit(2); exit(2);
rtnl_close(&rth); rtnl_close(&rth);
......
...@@ -214,15 +214,8 @@ int rtnl_dump_filter_l(struct rtnl_handle *rth, ...@@ -214,15 +214,8 @@ int rtnl_dump_filter_l(struct rtnl_handle *rth,
if (nladdr.nl_pid != 0 || if (nladdr.nl_pid != 0 ||
h->nlmsg_pid != rth->local.nl_pid || h->nlmsg_pid != rth->local.nl_pid ||
h->nlmsg_seq != rth->dump) { h->nlmsg_seq != rth->dump)
if (a->junk) {
err = a->junk(&nladdr, h,
a->arg2);
if (err < 0)
return err;
}
goto skip_it; goto skip_it;
}
if (h->nlmsg_type == NLMSG_DONE) { if (h->nlmsg_type == NLMSG_DONE) {
found_done = 1; found_done = 1;
...@@ -264,22 +257,18 @@ skip_it: ...@@ -264,22 +257,18 @@ skip_it:
int rtnl_dump_filter(struct rtnl_handle *rth, int rtnl_dump_filter(struct rtnl_handle *rth,
rtnl_filter_t filter, rtnl_filter_t filter,
void *arg1, void *arg1)
rtnl_filter_t junk,
void *arg2)
{ {
const struct rtnl_dump_filter_arg a[2] = { const struct rtnl_dump_filter_arg a[2] = {
{ .filter = filter, .arg1 = arg1, .junk = junk, .arg2 = arg2 }, { .filter = filter, .arg1 = arg1, },
{ .filter = NULL, .arg1 = NULL, .junk = NULL, .arg2 = NULL } { .filter = NULL, .arg1 = NULL, },
}; };
return rtnl_dump_filter_l(rth, a); return rtnl_dump_filter_l(rth, a);
} }
int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
unsigned groups, struct nlmsghdr *answer, unsigned groups, struct nlmsghdr *answer)
rtnl_filter_t junk,
void *jarg)
{ {
int status; int status;
unsigned seq; unsigned seq;
...@@ -338,11 +327,10 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, ...@@ -338,11 +327,10 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
exit(1); exit(1);
} }
for (h = (struct nlmsghdr*)buf; status >= sizeof(*h); ) { for (h = (struct nlmsghdr*)buf; status >= sizeof(*h); ) {
int err;
int len = h->nlmsg_len; int len = h->nlmsg_len;
int l = len - sizeof(*h); int l = len - sizeof(*h);
if (l<0 || len>status) { if (l < 0 || len>status) {
if (msg.msg_flags & MSG_TRUNC) { if (msg.msg_flags & MSG_TRUNC) {
fprintf(stderr, "Truncated message\n"); fprintf(stderr, "Truncated message\n");
return -1; return -1;
...@@ -354,11 +342,6 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, ...@@ -354,11 +342,6 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
if (nladdr.nl_pid != peer || if (nladdr.nl_pid != peer ||
h->nlmsg_pid != rtnl->local.nl_pid || h->nlmsg_pid != rtnl->local.nl_pid ||
h->nlmsg_seq != seq) { h->nlmsg_seq != seq) {
if (junk) {
err = junk(&nladdr, h, jarg);
if (err < 0)
return err;
}
/* Don't forget to skip that message. */ /* Don't forget to skip that message. */
status -= NLMSG_ALIGN(len); status -= NLMSG_ALIGN(len);
h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len)); h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len));
......
...@@ -204,7 +204,7 @@ int ll_init_map(struct rtnl_handle *rth) ...@@ -204,7 +204,7 @@ int ll_init_map(struct rtnl_handle *rth)
exit(1); exit(1);
} }
if (rtnl_dump_filter(rth, ll_remember_index, NULL, NULL, NULL) < 0) { if (rtnl_dump_filter(rth, ll_remember_index, NULL) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
exit(1); exit(1);
} }
......
...@@ -128,7 +128,7 @@ void load_info(void) ...@@ -128,7 +128,7 @@ void load_info(void)
exit(1); exit(1);
} }
if (rtnl_dump_filter(&rth, get_nlmsg, NULL, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, get_nlmsg, NULL) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
exit(1); exit(1);
} }
......
...@@ -451,7 +451,7 @@ int tc_action_gd(int cmd, unsigned flags, int *argc_p, char ***argv_p) ...@@ -451,7 +451,7 @@ int tc_action_gd(int cmd, unsigned flags, int *argc_p, char ***argv_p)
if (cmd == RTM_GETACTION) if (cmd == RTM_GETACTION)
ans = &req.n; ans = &req.n;
if (rtnl_talk(&rth, &req.n, 0, 0, ans, NULL, NULL) < 0) { if (rtnl_talk(&rth, &req.n, 0, 0, ans) < 0) {
fprintf(stderr, "We have an error talking to the kernel\n"); fprintf(stderr, "We have an error talking to the kernel\n");
return 1; return 1;
} }
...@@ -496,7 +496,7 @@ int tc_action_modify(int cmd, unsigned flags, int *argc_p, char ***argv_p) ...@@ -496,7 +496,7 @@ int tc_action_modify(int cmd, unsigned flags, int *argc_p, char ***argv_p)
} }
tail->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail; tail->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail;
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) { if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0) {
fprintf(stderr, "We have an error talking to the kernel\n"); fprintf(stderr, "We have an error talking to the kernel\n");
ret = -1; ret = -1;
} }
...@@ -558,7 +558,7 @@ int tc_act_list_or_flush(int argc, char **argv, int event) ...@@ -558,7 +558,7 @@ int tc_act_list_or_flush(int argc, char **argv, int event)
perror("Cannot send dump request"); perror("Cannot send dump request");
return 1; return 1;
} }
ret = rtnl_dump_filter(&rth, print_action, stdout, NULL, NULL); ret = rtnl_dump_filter(&rth, print_action, stdout);
} }
if (event == RTM_DELACTION) { if (event == RTM_DELACTION) {
...@@ -566,7 +566,7 @@ int tc_act_list_or_flush(int argc, char **argv, int event) ...@@ -566,7 +566,7 @@ int tc_act_list_or_flush(int argc, char **argv, int event)
req.n.nlmsg_type = RTM_DELACTION; req.n.nlmsg_type = RTM_DELACTION;
req.n.nlmsg_flags |= NLM_F_ROOT; req.n.nlmsg_flags |= NLM_F_ROOT;
req.n.nlmsg_flags |= NLM_F_REQUEST; req.n.nlmsg_flags |= NLM_F_REQUEST;
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) { if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0) {
fprintf(stderr, "We have an error flushing\n"); fprintf(stderr, "We have an error flushing\n");
return 1; return 1;
} }
......
...@@ -138,7 +138,7 @@ int tc_class_modify(int cmd, unsigned flags, int argc, char **argv) ...@@ -138,7 +138,7 @@ int tc_class_modify(int cmd, unsigned flags, int argc, char **argv)
} }
} }
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
return 2; return 2;
return 0; return 0;
...@@ -298,7 +298,7 @@ int tc_class_list(int argc, char **argv) ...@@ -298,7 +298,7 @@ int tc_class_list(int argc, char **argv)
return 1; return 1;
} }
if (rtnl_dump_filter(&rth, print_class, stdout, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, print_class, stdout) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
return 1; return 1;
} }
......
...@@ -167,7 +167,7 @@ int tc_filter_modify(int cmd, unsigned flags, int argc, char **argv) ...@@ -167,7 +167,7 @@ int tc_filter_modify(int cmd, unsigned flags, int argc, char **argv)
} }
} }
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) { if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0) {
fprintf(stderr, "We have an error talking to the kernel\n"); fprintf(stderr, "We have an error talking to the kernel\n");
return 2; return 2;
} }
...@@ -341,7 +341,7 @@ int tc_filter_list(int argc, char **argv) ...@@ -341,7 +341,7 @@ int tc_filter_list(int argc, char **argv)
return 1; return 1;
} }
if (rtnl_dump_filter(&rth, print_filter, stdout, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, print_filter, stdout) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
return 1; return 1;
} }
......
...@@ -186,7 +186,7 @@ int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv) ...@@ -186,7 +186,7 @@ int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv)
req.t.tcm_ifindex = idx; req.t.tcm_ifindex = idx;
} }
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
return 2; return 2;
return 0; return 0;
...@@ -323,7 +323,7 @@ int tc_qdisc_list(int argc, char **argv) ...@@ -323,7 +323,7 @@ int tc_qdisc_list(int argc, char **argv)
return 1; return 1;
} }
if (rtnl_dump_filter(&rth, print_qdisc, stdout, NULL, NULL) < 0) { if (rtnl_dump_filter(&rth, print_qdisc, stdout) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
return 1; return 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment