]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
xfrm: not try to delete ipcomp states when using deleteall
authorXin Long <lucien.xin@gmail.com>
Mon, 24 Feb 2020 14:57:01 +0000 (09:57 -0500)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 28 Feb 2020 21:50:58 +0000 (13:50 -0800)
In kernel space, ipcomp(sub) states used by main states are not
allowed to be deleted by users, they would be freed only when
all main states are destroyed and no one uses them.

In user space, ip xfrm sta deleteall doesn't filter these ipcomp
states out, and it causes errors:

  # ip xfrm state add src 192.168.0.1 dst 192.168.0.2 spi 0x1000 \
      proto comp comp deflate mode tunnel sel src 192.168.0.1 dst \
      192.168.0.2 proto gre
  # ip xfrm sta deleteall
  Failed to send delete-all request
  : Operation not permitted

This patch is to fix it by filtering ipcomp states with a check
xsinfo->id.proto == IPPROTO_IPIP.

Fixes: c7699875bee0 ("Import patch ipxfrm-20040707_2.diff")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/xfrm_state.c

index 16ff1931b156df0b86235eb8fad94f23a223eaba..d68f600ae700bc3aa123aa45a125de97c0799e88 100644 (file)
@@ -1131,6 +1131,9 @@ static int xfrm_state_keep(struct nlmsghdr *n, void *arg)
        if (!xfrm_state_filter_match(xsinfo))
                return 0;
 
+       if (xsinfo->id.proto == IPPROTO_IPIP)
+               return 0;
+
        if (xb->offset > xb->size) {
                fprintf(stderr, "State buffer overflow\n");
                return -1;