diff options
Diffstat (limited to 'net/xfrm')
| -rw-r--r-- | net/xfrm/xfrm_input.c | 17 | ||||
| -rw-r--r-- | net/xfrm/xfrm_replay.c | 2 | ||||
| -rw-r--r-- | net/xfrm/xfrm_state.c | 2 |
3 files changed, 19 insertions, 2 deletions
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c index 526c4feb3b50..b58286ecd156 100644 --- a/net/xfrm/xfrm_input.c +++ b/net/xfrm/xfrm_input.c | |||
| @@ -13,6 +13,8 @@ | |||
| 13 | #include <net/dst.h> | 13 | #include <net/dst.h> |
| 14 | #include <net/ip.h> | 14 | #include <net/ip.h> |
| 15 | #include <net/xfrm.h> | 15 | #include <net/xfrm.h> |
| 16 | #include <net/ip_tunnels.h> | ||
| 17 | #include <net/ip6_tunnel.h> | ||
| 16 | 18 | ||
| 17 | static struct kmem_cache *secpath_cachep __read_mostly; | 19 | static struct kmem_cache *secpath_cachep __read_mostly; |
| 18 | 20 | ||
| @@ -186,6 +188,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) | |||
| 186 | struct xfrm_state *x = NULL; | 188 | struct xfrm_state *x = NULL; |
| 187 | xfrm_address_t *daddr; | 189 | xfrm_address_t *daddr; |
| 188 | struct xfrm_mode *inner_mode; | 190 | struct xfrm_mode *inner_mode; |
| 191 | u32 mark = skb->mark; | ||
| 189 | unsigned int family; | 192 | unsigned int family; |
| 190 | int decaps = 0; | 193 | int decaps = 0; |
| 191 | int async = 0; | 194 | int async = 0; |
| @@ -203,6 +206,18 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) | |||
| 203 | XFRM_SPI_SKB_CB(skb)->daddroff); | 206 | XFRM_SPI_SKB_CB(skb)->daddroff); |
| 204 | family = XFRM_SPI_SKB_CB(skb)->family; | 207 | family = XFRM_SPI_SKB_CB(skb)->family; |
| 205 | 208 | ||
| 209 | /* if tunnel is present override skb->mark value with tunnel i_key */ | ||
| 210 | if (XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4) { | ||
| 211 | switch (family) { | ||
| 212 | case AF_INET: | ||
| 213 | mark = be32_to_cpu(XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4->parms.i_key); | ||
| 214 | break; | ||
| 215 | case AF_INET6: | ||
| 216 | mark = be32_to_cpu(XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6->parms.i_key); | ||
| 217 | break; | ||
| 218 | } | ||
| 219 | } | ||
| 220 | |||
| 206 | /* Allocate new secpath or COW existing one. */ | 221 | /* Allocate new secpath or COW existing one. */ |
| 207 | if (!skb->sp || atomic_read(&skb->sp->refcnt) != 1) { | 222 | if (!skb->sp || atomic_read(&skb->sp->refcnt) != 1) { |
| 208 | struct sec_path *sp; | 223 | struct sec_path *sp; |
| @@ -229,7 +244,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) | |||
| 229 | goto drop; | 244 | goto drop; |
| 230 | } | 245 | } |
| 231 | 246 | ||
| 232 | x = xfrm_state_lookup(net, skb->mark, daddr, spi, nexthdr, family); | 247 | x = xfrm_state_lookup(net, mark, daddr, spi, nexthdr, family); |
| 233 | if (x == NULL) { | 248 | if (x == NULL) { |
| 234 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINNOSTATES); | 249 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINNOSTATES); |
| 235 | xfrm_audit_state_notfound(skb, family, spi, seq); | 250 | xfrm_audit_state_notfound(skb, family, spi, seq); |
diff --git a/net/xfrm/xfrm_replay.c b/net/xfrm/xfrm_replay.c index dab57daae408..4fd725a0c500 100644 --- a/net/xfrm/xfrm_replay.c +++ b/net/xfrm/xfrm_replay.c | |||
| @@ -99,6 +99,7 @@ static int xfrm_replay_overflow(struct xfrm_state *x, struct sk_buff *skb) | |||
| 99 | 99 | ||
| 100 | if (x->type->flags & XFRM_TYPE_REPLAY_PROT) { | 100 | if (x->type->flags & XFRM_TYPE_REPLAY_PROT) { |
| 101 | XFRM_SKB_CB(skb)->seq.output.low = ++x->replay.oseq; | 101 | XFRM_SKB_CB(skb)->seq.output.low = ++x->replay.oseq; |
| 102 | XFRM_SKB_CB(skb)->seq.output.hi = 0; | ||
| 102 | if (unlikely(x->replay.oseq == 0)) { | 103 | if (unlikely(x->replay.oseq == 0)) { |
| 103 | x->replay.oseq--; | 104 | x->replay.oseq--; |
| 104 | xfrm_audit_state_replay_overflow(x, skb); | 105 | xfrm_audit_state_replay_overflow(x, skb); |
| @@ -177,6 +178,7 @@ static int xfrm_replay_overflow_bmp(struct xfrm_state *x, struct sk_buff *skb) | |||
| 177 | 178 | ||
| 178 | if (x->type->flags & XFRM_TYPE_REPLAY_PROT) { | 179 | if (x->type->flags & XFRM_TYPE_REPLAY_PROT) { |
| 179 | XFRM_SKB_CB(skb)->seq.output.low = ++replay_esn->oseq; | 180 | XFRM_SKB_CB(skb)->seq.output.low = ++replay_esn->oseq; |
| 181 | XFRM_SKB_CB(skb)->seq.output.hi = 0; | ||
| 180 | if (unlikely(replay_esn->oseq == 0)) { | 182 | if (unlikely(replay_esn->oseq == 0)) { |
| 181 | replay_esn->oseq--; | 183 | replay_esn->oseq--; |
| 182 | xfrm_audit_state_replay_overflow(x, skb); | 184 | xfrm_audit_state_replay_overflow(x, skb); |
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index f5e39e35d73a..96688cd0f6f1 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
| @@ -927,8 +927,8 @@ struct xfrm_state *xfrm_state_lookup_byspi(struct net *net, __be32 spi, | |||
| 927 | x->id.spi != spi) | 927 | x->id.spi != spi) |
| 928 | continue; | 928 | continue; |
| 929 | 929 | ||
| 930 | spin_unlock_bh(&net->xfrm.xfrm_state_lock); | ||
| 931 | xfrm_state_hold(x); | 930 | xfrm_state_hold(x); |
| 931 | spin_unlock_bh(&net->xfrm.xfrm_state_lock); | ||
| 932 | return x; | 932 | return x; |
| 933 | } | 933 | } |
| 934 | spin_unlock_bh(&net->xfrm.xfrm_state_lock); | 934 | spin_unlock_bh(&net->xfrm.xfrm_state_lock); |
