xfrm: tunnel: add extack to ipip_init_state, xfrm6_tunnel_init_state
authorSabrina Dubroca <sd@queasysnail.net>
Tue, 27 Sep 2022 15:45:32 +0000 (17:45 +0200)
committerSteffen Klassert <steffen.klassert@secunet.com>
Thu, 29 Sep 2022 05:18:00 +0000 (07:18 +0200)
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/ipv4/xfrm4_tunnel.c
net/ipv6/xfrm6_tunnel.c

index 08826e0d79620e5842b18258da7a832c2edc4cf6..8489fa10658377eb0942943e537a453d781f4520 100644 (file)
@@ -24,11 +24,15 @@ static int ipip_xfrm_rcv(struct xfrm_state *x, struct sk_buff *skb)
 
 static int ipip_init_state(struct xfrm_state *x, struct netlink_ext_ack *extack)
 {
-       if (x->props.mode != XFRM_MODE_TUNNEL)
+       if (x->props.mode != XFRM_MODE_TUNNEL) {
+               NL_SET_ERR_MSG(extack, "IPv4 tunnel can only be used with tunnel mode");
                return -EINVAL;
+       }
 
-       if (x->encap)
+       if (x->encap) {
+               NL_SET_ERR_MSG(extack, "IPv4 tunnel is not compatible with encapsulation");
                return -EINVAL;
+       }
 
        x->props.header_len = sizeof(struct iphdr);
 
index dda44b0671ac8fb0d1703844e49b4a41c29863f1..1323f2f6928e2abf277e9ce7bd06025cd0049031 100644 (file)
@@ -272,11 +272,15 @@ static int xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 
 static int xfrm6_tunnel_init_state(struct xfrm_state *x, struct netlink_ext_ack *extack)
 {
-       if (x->props.mode != XFRM_MODE_TUNNEL)
+       if (x->props.mode != XFRM_MODE_TUNNEL) {
+               NL_SET_ERR_MSG(extack, "IPv6 tunnel can only be used with tunnel mode");
                return -EINVAL;
+       }
 
-       if (x->encap)
+       if (x->encap) {
+               NL_SET_ERR_MSG(extack, "IPv6 tunnel is not compatible with encapsulation");
                return -EINVAL;
+       }
 
        x->props.header_len = sizeof(struct ipv6hdr);