Skip to contentSkip to conversation

ip xfrm: copy only the mark payload in deleteall

PATCH New Dave Seddon 1 participant 1 message Nov 24

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ip xfrm: copy only the mark payload in deleteall

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
---
 ip/xfrm_policy.c | 2 +-
 ip/xfrm_state.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
ip/xfrm_policy.c +1 -1
index 5261a292..1a41f2a9 100644
@@ -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);
ip/xfrm_state.c +1 -1
index dcd08d59..7e365b19 100644
@@ -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);
Signature · 1 line
2.56.0