xfrm: place xfrm6_local_dontfrag in xfrm.h
authorFlorian Westphal <fw@strlen.de>
Mon, 4 May 2020 08:06:07 +0000 (10:06 +0200)
committerSteffen Klassert <steffen.klassert@secunet.com>
Wed, 6 May 2020 07:40:08 +0000 (09:40 +0200)
so next patch can re-use it from net/xfrm/xfrm_output.c without
causing a linker error when IPV6 is a module.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
include/net/xfrm.h
net/ipv6/xfrm6_output.c

index 10295ab4cdfbfe7a35edb184c56c508a191b39ac..8f7fb033d5576b7a12f725b26f9cfff94698c4a4 100644 (file)
@@ -1993,4 +1993,20 @@ static inline int xfrm_tunnel_check(struct sk_buff *skb, struct xfrm_state *x,
 
        return 0;
 }
+
+#if IS_ENABLED(CONFIG_IPV6)
+static inline bool xfrm6_local_dontfrag(const struct sock *sk)
+{
+       int proto;
+
+       if (!sk || sk->sk_family != AF_INET6)
+               return false;
+
+       proto = sk->sk_protocol;
+       if (proto == IPPROTO_UDP || proto == IPPROTO_RAW)
+               return inet6_sk(sk)->dontfrag;
+
+       return false;
+}
+#endif
 #endif /* _NET_XFRM_H */
index 23e2b52cfba6510ab90b7d181dc9abad1f132de1..be64f280510c95b8a53a1899a1bb294d8bc1ff72 100644 (file)
@@ -23,23 +23,6 @@ int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb,
 }
 EXPORT_SYMBOL(xfrm6_find_1stfragopt);
 
-static int xfrm6_local_dontfrag(struct sk_buff *skb)
-{
-       int proto;
-       struct sock *sk = skb->sk;
-
-       if (sk) {
-               if (sk->sk_family != AF_INET6)
-                       return 0;
-
-               proto = sk->sk_protocol;
-               if (proto == IPPROTO_UDP || proto == IPPROTO_RAW)
-                       return inet6_sk(sk)->dontfrag;
-       }
-
-       return 0;
-}
-
 void xfrm6_local_rxpmtu(struct sk_buff *skb, u32 mtu)
 {
        struct flowi6 fl6;
@@ -82,7 +65,7 @@ static int xfrm6_tunnel_check_size(struct sk_buff *skb)
                skb->dev = dst->dev;
                skb->protocol = htons(ETH_P_IPV6);
 
-               if (xfrm6_local_dontfrag(skb))
+               if (xfrm6_local_dontfrag(skb->sk))
                        xfrm6_local_rxpmtu(skb, mtu);
                else if (skb->sk)
                        xfrm_local_error(skb, mtu);
@@ -181,7 +164,7 @@ static int __xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 
        toobig = skb->len > mtu && !skb_is_gso(skb);
 
-       if (toobig && xfrm6_local_dontfrag(skb)) {
+       if (toobig && xfrm6_local_dontfrag(skb->sk)) {
                xfrm6_local_rxpmtu(skb, mtu);
                kfree_skb(skb);
                return -EMSGSIZE;