* [ipsec PATCH 0/3] Preserve skb->mark through VTI tunnels
@ 2015-05-27 14:16 Alexander Duyck
2015-05-27 14:16 ` [ipsec PATCH 1/3] ip_vti/ip6_vti: Do not touch skb->mark on xmit Alexander Duyck
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Alexander Duyck @ 2015-05-27 14:16 UTC (permalink / raw)
To: steffen.klassert, netdev; +Cc: linux-crypto, davem, herbert
These patches are meant to try and address the fact the VTI tunnels are
currently overwriting the skb->mark value. I am generally happy with the
first two patches, however the third patch still modifies the skb->mark,
though it undoes after the fact.
The main problem I am trying to address is the fact that currently if I use
an v6 over v6 VTI tunnel I cannot receive any traffic on the interface as
the skb->mark is bleeding through and causing the traffic to be dropped.
---
Alexander Duyck (3):
ip_vti/ip6_vti: Do not touch skb->mark on xmit
xfrm: Override skb->mark with tunnel->parm.i_key in xfrm_input
ip_vti/ip6_vti: Preserve skb->mark after rcv_cb call
net/ipv4/ip_vti.c | 14 ++++++++++----
net/ipv6/ip6_vti.c | 13 ++++++++++---
net/xfrm/xfrm_input.c | 17 ++++++++++++++++-
3 files changed, 36 insertions(+), 8 deletions(-)
--
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ipsec PATCH 1/3] ip_vti/ip6_vti: Do not touch skb->mark on xmit
2015-05-27 14:16 [ipsec PATCH 0/3] Preserve skb->mark through VTI tunnels Alexander Duyck
@ 2015-05-27 14:16 ` Alexander Duyck
2015-05-27 14:16 ` [ipsec PATCH 2/3] xfrm: Override skb->mark with tunnel->parm.i_key in xfrm_input Alexander Duyck
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Alexander Duyck @ 2015-05-27 14:16 UTC (permalink / raw)
To: steffen.klassert, netdev; +Cc: linux-crypto, davem, herbert
Instead of modifying skb->mark we can simply modify the flowi_mark that is
generated as a result of the xfrm_decode_session. By doing this we don't
need to actually touch the skb->mark and it can be preserved as it passes
out through the tunnel.
Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
---
net/ipv4/ip_vti.c | 5 +++--
net/ipv6/ip6_vti.c | 4 +++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
index 9f7269f3c54a..4c318e1c13c8 100644
--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -216,8 +216,6 @@ static netdev_tx_t vti_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
memset(&fl, 0, sizeof(fl));
- skb->mark = be32_to_cpu(tunnel->parms.o_key);
-
switch (skb->protocol) {
case htons(ETH_P_IP):
xfrm_decode_session(skb, &fl, AF_INET);
@@ -233,6 +231,9 @@ static netdev_tx_t vti_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK;
}
+ /* override mark with tunnel output key */
+ fl.flowi_mark = be32_to_cpu(tunnel->parms.o_key);
+
return vti_xmit(skb, dev, &fl);
}
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index ed9d681207fa..104de4da3ff3 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -495,7 +495,6 @@ vti6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
int ret;
memset(&fl, 0, sizeof(fl));
- skb->mark = be32_to_cpu(t->parms.o_key);
switch (skb->protocol) {
case htons(ETH_P_IPV6):
@@ -516,6 +515,9 @@ vti6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
goto tx_err;
}
+ /* override mark with tunnel output key */
+ fl.flowi_mark = be32_to_cpu(t->parms.o_key);
+
ret = vti6_xmit(skb, dev, &fl);
if (ret < 0)
goto tx_err;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [ipsec PATCH 2/3] xfrm: Override skb->mark with tunnel->parm.i_key in xfrm_input
2015-05-27 14:16 [ipsec PATCH 0/3] Preserve skb->mark through VTI tunnels Alexander Duyck
2015-05-27 14:16 ` [ipsec PATCH 1/3] ip_vti/ip6_vti: Do not touch skb->mark on xmit Alexander Duyck
@ 2015-05-27 14:16 ` Alexander Duyck
2015-05-27 14:16 ` [ipsec PATCH 3/3] ip_vti/ip6_vti: Preserve skb->mark after rcv_cb call Alexander Duyck
2015-05-28 5:58 ` [ipsec PATCH 0/3] Preserve skb->mark through VTI tunnels Steffen Klassert
3 siblings, 0 replies; 5+ messages in thread
From: Alexander Duyck @ 2015-05-27 14:16 UTC (permalink / raw)
To: steffen.klassert, netdev; +Cc: linux-crypto, davem, herbert
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>
---
net/xfrm/xfrm_input.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
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 @@
#include <net/dst.h>
#include <net/ip.h>
#include <net/xfrm.h>
+#include <net/ip_tunnels.h>
+#include <net/ip6_tunnel.h>
static struct kmem_cache *secpath_cachep __read_mostly;
@@ -186,6 +188,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
struct xfrm_state *x = NULL;
xfrm_address_t *daddr;
struct xfrm_mode *inner_mode;
+ u32 mark = skb->mark;
unsigned int family;
int decaps = 0;
int async = 0;
@@ -203,6 +206,18 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
XFRM_SPI_SKB_CB(skb)->daddroff);
family = XFRM_SPI_SKB_CB(skb)->family;
+ /* if tunnel is present override skb->mark value with tunnel i_key */
+ if (XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4) {
+ switch (family) {
+ case AF_INET:
+ mark = be32_to_cpu(XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4->parms.i_key);
+ break;
+ case AF_INET6:
+ mark = be32_to_cpu(XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6->parms.i_key);
+ break;
+ }
+ }
+
/* Allocate new secpath or COW existing one. */
if (!skb->sp || atomic_read(&skb->sp->refcnt) != 1) {
struct sec_path *sp;
@@ -229,7 +244,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
goto drop;
}
- x = xfrm_state_lookup(net, skb->mark, daddr, spi, nexthdr, family);
+ x = xfrm_state_lookup(net, mark, daddr, spi, nexthdr, family);
if (x == NULL) {
XFRM_INC_STATS(net, LINUX_MIB_XFRMINNOSTATES);
xfrm_audit_state_notfound(skb, family, spi, seq);
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [ipsec PATCH 3/3] ip_vti/ip6_vti: Preserve skb->mark after rcv_cb call
2015-05-27 14:16 [ipsec PATCH 0/3] Preserve skb->mark through VTI tunnels Alexander Duyck
2015-05-27 14:16 ` [ipsec PATCH 1/3] ip_vti/ip6_vti: Do not touch skb->mark on xmit Alexander Duyck
2015-05-27 14:16 ` [ipsec PATCH 2/3] xfrm: Override skb->mark with tunnel->parm.i_key in xfrm_input Alexander Duyck
@ 2015-05-27 14:16 ` Alexander Duyck
2015-05-28 5:58 ` [ipsec PATCH 0/3] Preserve skb->mark through VTI tunnels Steffen Klassert
3 siblings, 0 replies; 5+ messages in thread
From: Alexander Duyck @ 2015-05-27 14:16 UTC (permalink / raw)
To: steffen.klassert, netdev; +Cc: linux-crypto, davem, herbert
The vti6_rcv_cb and vti_rcv_cb calls were leaving the skb->mark modified
after completing the function. This resulted in the original skb->mark
value being lost. Since we only need skb->mark to be set for
xfrm_policy_check we can pull the assignment into the rcv_cb calls and then
just restore the original mark after xfrm_policy_check has been completed.
Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
---
net/ipv4/ip_vti.c | 9 +++++++--
net/ipv6/ip6_vti.c | 9 +++++++--
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
index 4c318e1c13c8..0c152087ca15 100644
--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -65,7 +65,6 @@ static int vti_input(struct sk_buff *skb, int nexthdr, __be32 spi,
goto drop;
XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4 = tunnel;
- skb->mark = be32_to_cpu(tunnel->parms.i_key);
return xfrm_input(skb, nexthdr, spi, encap_type);
}
@@ -91,6 +90,8 @@ static int vti_rcv_cb(struct sk_buff *skb, int err)
struct pcpu_sw_netstats *tstats;
struct xfrm_state *x;
struct ip_tunnel *tunnel = XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4;
+ u32 orig_mark = skb->mark;
+ int ret;
if (!tunnel)
return 1;
@@ -107,7 +108,11 @@ static int vti_rcv_cb(struct sk_buff *skb, int err)
x = xfrm_input_state(skb);
family = x->inner_mode->afinfo->family;
- if (!xfrm_policy_check(NULL, XFRM_POLICY_IN, skb, family))
+ skb->mark = be32_to_cpu(tunnel->parms.i_key);
+ ret = xfrm_policy_check(NULL, XFRM_POLICY_IN, skb, family);
+ skb->mark = orig_mark;
+
+ if (!ret)
return -EPERM;
skb_scrub_packet(skb, !net_eq(tunnel->net, dev_net(skb->dev)));
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index 104de4da3ff3..ff3bd863fa03 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -322,7 +322,6 @@ static int vti6_rcv(struct sk_buff *skb)
}
XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6 = t;
- skb->mark = be32_to_cpu(t->parms.i_key);
rcu_read_unlock();
@@ -342,6 +341,8 @@ static int vti6_rcv_cb(struct sk_buff *skb, int err)
struct pcpu_sw_netstats *tstats;
struct xfrm_state *x;
struct ip6_tnl *t = XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6;
+ u32 orig_mark = skb->mark;
+ int ret;
if (!t)
return 1;
@@ -358,7 +359,11 @@ static int vti6_rcv_cb(struct sk_buff *skb, int err)
x = xfrm_input_state(skb);
family = x->inner_mode->afinfo->family;
- if (!xfrm_policy_check(NULL, XFRM_POLICY_IN, skb, family))
+ skb->mark = be32_to_cpu(t->parms.i_key);
+ ret = xfrm_policy_check(NULL, XFRM_POLICY_IN, skb, family);
+ skb->mark = orig_mark;
+
+ if (!ret)
return -EPERM;
skb_scrub_packet(skb, !net_eq(t->net, dev_net(skb->dev)));
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [ipsec PATCH 0/3] Preserve skb->mark through VTI tunnels
2015-05-27 14:16 [ipsec PATCH 0/3] Preserve skb->mark through VTI tunnels Alexander Duyck
` (2 preceding siblings ...)
2015-05-27 14:16 ` [ipsec PATCH 3/3] ip_vti/ip6_vti: Preserve skb->mark after rcv_cb call Alexander Duyck
@ 2015-05-28 5:58 ` Steffen Klassert
3 siblings, 0 replies; 5+ messages in thread
From: Steffen Klassert @ 2015-05-28 5:58 UTC (permalink / raw)
To: Alexander Duyck; +Cc: netdev, linux-crypto, davem, herbert
On Wed, May 27, 2015 at 07:16:37AM -0700, Alexander Duyck wrote:
> These patches are meant to try and address the fact the VTI tunnels are
> currently overwriting the skb->mark value. I am generally happy with the
> first two patches, however the third patch still modifies the skb->mark,
> though it undoes after the fact.
>
> The main problem I am trying to address is the fact that currently if I use
> an v6 over v6 VTI tunnel I cannot receive any traffic on the interface as
> the skb->mark is bleeding through and causing the traffic to be dropped.
>
> ---
>
> Alexander Duyck (3):
> ip_vti/ip6_vti: Do not touch skb->mark on xmit
> xfrm: Override skb->mark with tunnel->parm.i_key in xfrm_input
> ip_vti/ip6_vti: Preserve skb->mark after rcv_cb call
All applied to the ipsec tree, thanks a lot Alexander!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-05-28 5:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-27 14:16 [ipsec PATCH 0/3] Preserve skb->mark through VTI tunnels Alexander Duyck
2015-05-27 14:16 ` [ipsec PATCH 1/3] ip_vti/ip6_vti: Do not touch skb->mark on xmit Alexander Duyck
2015-05-27 14:16 ` [ipsec PATCH 2/3] xfrm: Override skb->mark with tunnel->parm.i_key in xfrm_input Alexander Duyck
2015-05-27 14:16 ` [ipsec PATCH 3/3] ip_vti/ip6_vti: Preserve skb->mark after rcv_cb call Alexander Duyck
2015-05-28 5:58 ` [ipsec PATCH 0/3] Preserve skb->mark through VTI tunnels Steffen Klassert
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.