aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@redhat.com>2015-05-27 10:16:49 -0400
committerSteffen Klassert <steffen.klassert@secunet.com>2015-05-28 00:23:31 -0400
commit049f8e2e28d9c3dac0744cc2f19d3157c7fb5646 (patch)
tree85ef9a4d2dfab318d7c09ec8953b4ba7951cbe39 /net/xfrm
parentcd5279c194f89c9b97c294af4aaf4ea8c5e3c704 (diff)
xfrm: Override skb->mark with tunnel->parm.i_key in xfrm_input
This change makes it so that if a tunnel is defined we just use the mark from the tunnel instead of the mark from the skb header. By doing this we can avoid the need to set skb->mark inside of the tunnel receive functions. Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/xfrm')
-rw-r--r--net/xfrm/xfrm_input.c17
1 files changed, 16 insertions, 1 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
17static struct kmem_cache *secpath_cachep __read_mostly; 19static 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);