🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
4 messages
4 total messages Started by Dave Seddon Tue, 24 Nov 2026 06:01
[PATCH iproute2] ip xfrm: copy only the mark payload in deleteall
#21537
Author: Dave Seddon
Date: Tue, 24 Nov 2026 06:01
41 lines
11898 bytes
deleteall copies XFRMA_MARK with rta_len, which includes the attribute
header, so each delete request carries four extra bytes. Use
RTA_PAYLOAD().

Fixes: 0c7d651b38d6 ("xfrm_{state, policy}: Allow to deleteall polices/states with marks")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Dave Seddon <dave.seddon.ca@gmail.com>
---
 ip/xfrm_policy.c | 2 +-
 ip/xfrm_state.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ip/xfrm_policy.c b/ip/xfrm_policy.c
index 5261a292..1a41f2a9 100644
--- a/ip/xfrm_policy.c
+++ b/ip/xfrm_policy.c
@@ -783,7 +783,7 @@ static int xfrm_policy_keep(struct nlmsghdr *n, void *arg)
 
 	if (tb[XFRMA_MARK]) {
 		int r = addattr_l(new_n, xb->size, XFRMA_MARK,
-				(void *)RTA_DATA(tb[XFRMA_MARK]), tb[XFRMA_MARK]->rta_len);
+				(void *)RTA_DATA(tb[XFRMA_MARK]), RTA_PAYLOAD(tb[XFRMA_MARK]));
 		if (r < 0) {
 			fprintf(stderr, "%s: XFRMA_MARK failed\n", __func__);
 			exit(1);
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
index dcd08d59..7e365b19 100644
--- a/ip/xfrm_state.c
+++ b/ip/xfrm_state.c
@@ -1203,7 +1203,7 @@ static int xfrm_state_keep(struct nlmsghdr *n, void *arg)
 
 	if (tb[XFRMA_MARK]) {
 		int r = addattr_l(new_n, xb->size, XFRMA_MARK,
-				(void *)RTA_DATA(tb[XFRMA_MARK]), tb[XFRMA_MARK]->rta_len);
+				(void *)RTA_DATA(tb[XFRMA_MARK]), RTA_PAYLOAD(tb[XFRMA_MARK]));
 		if (r < 0) {
 			fprintf(stderr, "%s: XFRMA_MARK failed\n", __func__);
 			exit(1);
-- 
2.56.0
Re: [PATCH iproute2] ip xfrm: copy only the mark payload in deleteall
#22219
Author: Stephen Hemminger
Date: Wed, 25 Nov 2026 00:53
17 lines
11575 bytes
On Mon, 23 Nov 2026 22:01:39 -0800
Dave Seddon <dave.seddon.ca@gmail.com> wrote:

> diff --git a/ip/xfrm_policy.c b/ip/xfrm_policy.c
> index 5261a292..1a41f2a9 100644
> --- a/ip/xfrm_policy.c
> +++ b/ip/xfrm_policy.c
> @@ -783,7 +783,7 @@ static int xfrm_policy_keep(struct nlmsghdr *n, void *arg)
>  
>  	if (tb[XFRMA_MARK]) {
>  		int r = addattr_l(new_n, xb->size, XFRMA_MARK,
> -				(void *)RTA_DATA(tb[XFRMA_MARK]), tb[XFRMA_MARK]->rta_len);
> +				(void *)RTA_DATA(tb[XFRMA_MARK]), RTA_PAYLOAD(tb[XFRMA_MARK]));

Why the cast to void * here?  RTA_DATA() already is macro that returns void *
and if it was a similar pointer (like char *) then C would do implicit conversion.
Re: [PATCH iproute2] ip xfrm: copy only the mark payload in deleteall
#22247
Author: dave seddon
Date: Wed, 25 Nov 2026 02:15
52 lines
13234 bytes
Thanks Stephen

The cast came in via 0c7d651b38d6 ("xfrm_{state, policy}: Allow to
deleteall polices/states
with marks") from 2017

I didn't touch the cast, and only fixed the one incorrect argument.

I've been trying to keep these patches as small as possible, but I'm
happy to tidy the surrounding code as well where that's preferred.

Would you prefer a new v2 version, or a follow up removing the cast?

I'll also drop the LLM lines going forward.

... I have quite a few more issues to submit

Thanks,
Dave

On Tue, Nov 24, 2026 at 4:53 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Mon, 23 Nov 2026 22:01:39 -0800
> Dave Seddon <dave.seddon.ca@gmail.com> wrote:
>
> > diff --git a/ip/xfrm_policy.c b/ip/xfrm_policy.c
> > index 5261a292..1a41f2a9 100644
> > --- a/ip/xfrm_policy.c
> > +++ b/ip/xfrm_policy.c
> > @@ -783,7 +783,7 @@ static int xfrm_policy_keep(struct nlmsghdr *n, void *arg)
> >
> >       if (tb[XFRMA_MARK]) {
> >               int r = addattr_l(new_n, xb->size, XFRMA_MARK,
> > -                             (void *)RTA_DATA(tb[XFRMA_MARK]), tb[XFRMA_MARK]->rta_len);
> > +                             (void *)RTA_DATA(tb[XFRMA_MARK]), RTA_PAYLOAD(tb[XFRMA_MARK]));
>
> Why the cast to void * here?  RTA_DATA() already is macro that returns void *
> and if it was a similar pointer (like char *) then C would do implicit conversion.



-- 
Regards,
Dave Seddon
+1 415 857 5102
Re: [PATCH iproute2] ip xfrm: copy only the mark payload in deleteall
#22276
Author: dave seddon
Date: Wed, 25 Nov 2026 03:07
28 lines
12796 bytes
G'day Stephen,

A bit more context on "quite a few more", so it doesn't come as a
surprise.

I've been porting parts of ip and tc to Go. To check the port, I run
iproute2 commands in a namespace and capture the netlink traffic with
nlmon, so I now have a fairly large set of pcaps covering many
iproute2/kernel interactions. Comparing the port against those
captures, request by request and output line by output line, is what
shakes out the small differences, and some of them turn out to be nits
in iproute2 rather than in my port.

Roughly, I have a few dozen more like the ones already posted. Most are
small parsing and printing issues, each a line or two to fix, with a
few crashes on unusual input among them. Nothing I'd call urgent.

How would you like to receive them? I can keep sending single small
patches a few at a time, or group them into short series per area (tc,
xfrm, tipc, ...), whichever is easier for you to review. I'm also happy
to go at whatever pace suits.

If the captures would be useful to anyone else, for testing or
otherwise, I'm glad to share them.

Thanks,
Dave
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads