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 08826e0..8489fa1 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 dda44b0..1323f2f 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);