* [PATCH iproute2] ipxfrm: wrong nl msg sent on deleteall cmd
@ 2015-04-15 12:00 Nicolas Dichtel
2015-04-20 17:05 ` Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Dichtel @ 2015-04-15 12:00 UTC (permalink / raw)
To: shemminger; +Cc: netdev, gregory.hoggarth, Nicolas Dichtel
XFRM netlink family is independent from the route netlink family. It's wrong
to call rtnl_wilddump_request(), because it will add a 'struct ifinfomsg' into
the header and the kernel will complain (at least for xfrm state):
netlink: 24 bytes leftover after parsing attributes in process `ip'.
Reported-by: Gregory Hoggarth <Gregory.Hoggarth@alliedtelesis.co.nz>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
ip/xfrm_policy.c | 24 ++++++++++++++++++++++--
ip/xfrm_state.c | 12 +++++++++++-
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/ip/xfrm_policy.c b/ip/xfrm_policy.c
index 2337d35246fa..fd6d4890fa4e 100644
--- a/ip/xfrm_policy.c
+++ b/ip/xfrm_policy.c
@@ -847,13 +847,23 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall)
xb.rth = &rth;
for (i = 0; ; i++) {
+ struct {
+ struct nlmsghdr n;
+ char buf[NLMSG_BUF_SIZE];
+ } req = {
+ .n.nlmsg_len = NLMSG_HDRLEN,
+ .n.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+ .n.nlmsg_type = XFRM_MSG_GETPOLICY,
+ .n.nlmsg_seq = rth.dump = ++rth.seq,
+ };
+
xb.offset = 0;
xb.nlmsg_count = 0;
if (show_stats > 1)
fprintf(stderr, "Delete-all round = %d\n", i);
- if (rtnl_wilddump_request(&rth, preferred_family, XFRM_MSG_GETPOLICY) < 0) {
+ if (rtnl_send(&rth, (void *)&req, req.n.nlmsg_len) < 0) {
perror("Cannot send dump request");
exit(1);
}
@@ -879,7 +889,17 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall)
xb.nlmsg_count = 0;
}
} else {
- if (rtnl_wilddump_request(&rth, preferred_family, XFRM_MSG_GETPOLICY) < 0) {
+ struct {
+ struct nlmsghdr n;
+ char buf[NLMSG_BUF_SIZE];
+ } req = {
+ .n.nlmsg_len = NLMSG_HDRLEN,
+ .n.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+ .n.nlmsg_type = XFRM_MSG_GETPOLICY,
+ .n.nlmsg_seq = rth.dump = ++rth.seq,
+ };
+
+ if (rtnl_send(&rth, (void *)&req, req.n.nlmsg_len) < 0) {
perror("Cannot send dump request");
exit(1);
}
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
index 2ad3d8d37fbe..04af50b348e6 100644
--- a/ip/xfrm_state.c
+++ b/ip/xfrm_state.c
@@ -1148,13 +1148,23 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall)
xb.rth = &rth;
for (i = 0; ; i++) {
+ struct {
+ struct nlmsghdr n;
+ char buf[NLMSG_BUF_SIZE];
+ } req = {
+ .n.nlmsg_len = NLMSG_HDRLEN,
+ .n.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
+ .n.nlmsg_type = XFRM_MSG_GETSA,
+ .n.nlmsg_seq = rth.dump = ++rth.seq,
+ };
+
xb.offset = 0;
xb.nlmsg_count = 0;
if (show_stats > 1)
fprintf(stderr, "Delete-all round = %d\n", i);
- if (rtnl_wilddump_request(&rth, preferred_family, XFRM_MSG_GETSA) < 0) {
+ if (rtnl_send(&rth, (void *)&req, req.n.nlmsg_len) < 0) {
perror("Cannot send dump request");
exit(1);
}
--
2.2.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH iproute2] ipxfrm: wrong nl msg sent on deleteall cmd
2015-04-15 12:00 [PATCH iproute2] ipxfrm: wrong nl msg sent on deleteall cmd Nicolas Dichtel
@ 2015-04-20 17:05 ` Stephen Hemminger
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2015-04-20 17:05 UTC (permalink / raw)
To: Nicolas Dichtel; +Cc: shemminger, netdev, gregory.hoggarth
On Wed, 15 Apr 2015 14:00:53 +0200
Nicolas Dichtel <nicolas.dichtel@6wind.com> wrote:
> XFRM netlink family is independent from the route netlink family. It's wrong
> to call rtnl_wilddump_request(), because it will add a 'struct ifinfomsg' into
> the header and the kernel will complain (at least for xfrm state):
>
> netlink: 24 bytes leftover after parsing attributes in process `ip'.
>
> Reported-by: Gregory Hoggarth <Gregory.Hoggarth@alliedtelesis.co.nz>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Applied thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-04-20 17:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-15 12:00 [PATCH iproute2] ipxfrm: wrong nl msg sent on deleteall cmd Nicolas Dichtel
2015-04-20 17:05 ` Stephen Hemminger
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.