]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[IPSEC]: Use the correct family for input state lookup
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 4 Dec 2007 06:54:12 +0000 (22:54 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 22:55:49 +0000 (14:55 -0800)
When merging the input paths of IPsec I accidentally left a hard-coded
AF_INET for the state lookup call.  This broke IPv6 obviously.  This
patch fixes by getting the input callers to specify the family through
skb->cb.

Credit goes to Kazunori Miyazawa for diagnosing this and providing an
initial patch.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/xfrm.h
net/ipv4/xfrm4_input.c
net/ipv6/xfrm6_input.c
net/xfrm/xfrm_input.c

index ecc02e9bde326ec3fb33102a8ff47fbe3e6a4637..182f10b29d88111ffb3ab60495b1323fe43408c5 100644 (file)
@@ -534,6 +534,7 @@ struct xfrm_spi_skb_cb {
        } header;
 
        unsigned int daddroff;
+       unsigned int family;
 };
 
 #define XFRM_SPI_SKB_CB(__skb) ((struct xfrm_spi_skb_cb *)&((__skb)->cb[0]))
index 0c377a66b8b5b1982f7467c807a9dd6aa0ae00d5..33f990d56c917baf22e55144dd17707df8e533c3 100644 (file)
@@ -39,6 +39,7 @@ drop:
 int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi,
                    int encap_type)
 {
+       XFRM_SPI_SKB_CB(skb)->family = AF_INET;
        XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct iphdr, daddr);
        return xfrm_input(skb, nexthdr, spi, encap_type);
 }
index e2c3efd2579d65a9a2cfc75fba5545286a7e733b..74f3aacebb5e695430bfb05ba0f13ed105af9e57 100644 (file)
@@ -23,6 +23,7 @@ int xfrm6_extract_input(struct xfrm_state *x, struct sk_buff *skb)
 
 int xfrm6_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi)
 {
+       XFRM_SPI_SKB_CB(skb)->family = AF_INET6;
        XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct ipv6hdr, daddr);
        return xfrm_input(skb, nexthdr, spi, 0);
 }
index 96f42c1d2e8eb56542c3fc743179bf90f2be8d2a..8b2b1b59133ec20e28e96dc83f1499aca6eafe31 100644 (file)
@@ -102,6 +102,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
        __be32 seq;
        struct xfrm_state *x;
        xfrm_address_t *daddr;
+       unsigned int family;
        int decaps = 0;
        int async = 0;
 
@@ -127,6 +128,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
 
        daddr = (xfrm_address_t *)(skb_network_header(skb) +
                                   XFRM_SPI_SKB_CB(skb)->daddroff);
+       family = XFRM_SPI_SKB_CB(skb)->family;
 
        seq = 0;
        if (!spi && (err = xfrm_parse_spi(skb, nexthdr, &spi, &seq)) != 0)
@@ -136,7 +138,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
                if (skb->sp->len == XFRM_MAX_DEPTH)
                        goto drop;
 
-               x = xfrm_state_lookup(daddr, spi, nexthdr, AF_INET);
+               x = xfrm_state_lookup(daddr, spi, nexthdr, family);
                if (x == NULL)
                        goto drop;
 
@@ -198,6 +200,7 @@ resume:
                 * transport mode so the outer address is identical.
                 */
                daddr = &x->id.daddr;
+               family = x->outer_mode->afinfo->family;
 
                err = xfrm_parse_spi(skb, nexthdr, &spi, &seq);
                if (err < 0)