]> Pileus Git - ~andy/linux/commitdiff
xfrm: choose protocol family by skb protocol
authorHannes Frederic Sowa <hannes@stressinduktion.org>
Sun, 18 Aug 2013 11:47:01 +0000 (13:47 +0200)
committerSteffen Klassert <steffen.klassert@secunet.com>
Mon, 19 Aug 2013 07:39:04 +0000 (09:39 +0200)
We need to choose the protocol family by skb->protocol. Otherwise we
call the wrong xfrm{4,6}_local_error handler in case an ipv6 sockets is
used in ipv4 mode, in which case we should call down to xfrm4_local_error
(ip6 sockets are a superset of ip4 ones).

We are called before before ip_output functions, so skb->protocol is
not reset.

Cc: Steffen Klassert <steffen.klassert@secunet.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
include/net/xfrm.h
net/xfrm/xfrm_output.c

index b41d2d10ff0e2088b14ba3513b5483bb3df6786c..ac5b02515355eb172b01c378eece62012e008b93 100644 (file)
@@ -1728,9 +1728,9 @@ static inline int xfrm_skb_dst_mtu(struct sk_buff *skb)
 {
        struct sock *sk = skb->sk;
 
-       if (sk && sk->sk_family == AF_INET6)
+       if (sk && skb->protocol == htons(ETH_P_IPV6))
                return ip6_skb_dst_mtu(skb);
-       else if (sk && sk->sk_family == AF_INET)
+       else if (sk && skb->protocol == htons(ETH_P_IP))
                return ip_skb_dst_mtu(skb);
        return dst_mtu(skb_dst(skb));
 }
index 6f5fc612b162f699069a85bab552b14b29744aa8..3bb2cdc13b46e1468743e1130d6c4c25e08921e0 100644 (file)
@@ -216,9 +216,17 @@ int xfrm_inner_extract_output(struct xfrm_state *x, struct sk_buff *skb)
 
 void xfrm_local_error(struct sk_buff *skb, int mtu)
 {
+       unsigned int proto;
        struct xfrm_state_afinfo *afinfo;
 
-       afinfo = xfrm_state_get_afinfo(skb->sk->sk_family);
+       if (skb->protocol == htons(ETH_P_IP))
+               proto = AF_INET;
+       else if (skb->protocol == htons(ETH_P_IPV6))
+               proto = AF_INET6;
+       else
+               return;
+
+       afinfo = xfrm_state_get_afinfo(proto);
        if (!afinfo)
                return;