Netdev List
 help / color / mirror / Atom feed
* [PATCH iproute2] ip xfrm: copy only the mark payload in deleteall
@ 2026-11-24  6:01 Dave Seddon
  2026-11-25  0:53 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Seddon @ 2026-11-24  6:01 UTC (permalink / raw)
  To: netdev; +Cc: Dave Seddon, Stephen Hemminger, David Ahern

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH iproute2] ip xfrm: copy only the mark payload in deleteall
  2026-11-24  6:01 [PATCH iproute2] ip xfrm: copy only the mark payload in deleteall Dave Seddon
@ 2026-11-25  0:53 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2026-11-25  0:53 UTC (permalink / raw)
  To: Dave Seddon; +Cc: netdev, David Ahern

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-25  0:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24  6:01 [PATCH iproute2] ip xfrm: copy only the mark payload in deleteall Dave Seddon
2026-11-25  0:53 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox