[PATCH 50/53] netns xfrm: AH/ESP in netns!

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Alexey Dobriyan
Date: Tuesday, November 25, 2008 - 10:27 am

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 net/ipv4/ah4.c  |    4 +++-
 net/ipv4/esp4.c |    4 +++-
 net/ipv6/ah6.c  |    3 ++-
 net/ipv6/esp6.c |    3 ++-
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index 750426b..e878e49 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -201,6 +201,7 @@ out:
 
 static void ah4_err(struct sk_buff *skb, u32 info)
 {
+	struct net *net = dev_net(skb->dev);
 	struct iphdr *iph = (struct iphdr *)skb->data;
 	struct ip_auth_hdr *ah = (struct ip_auth_hdr *)(skb->data+(iph->ihl<<2));
 	struct xfrm_state *x;
@@ -209,7 +210,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
 	    icmp_hdr(skb)->code != ICMP_FRAG_NEEDED)
 		return;
 
-	x = xfrm_state_lookup(&init_net, (xfrm_address_t *)&iph->daddr, ah->spi, IPPROTO_AH, AF_INET);
+	x = xfrm_state_lookup(net, (xfrm_address_t *)&iph->daddr, ah->spi, IPPROTO_AH, AF_INET);
 	if (!x)
 		return;
 	printk(KERN_DEBUG "pmtu discovery on SA AH/%08x/%08x\n",
@@ -314,6 +315,7 @@ static struct net_protocol ah4_protocol = {
 	.handler	=	xfrm4_rcv,
 	.err_handler	=	ah4_err,
 	.no_policy	=	1,
+	.netns_ok	=	1,
 };
 
 static int __init ah4_init(void)
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 3595012..18bb383 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -413,6 +413,7 @@ static u32 esp4_get_mtu(struct xfrm_state *x, int mtu)
 
 static void esp4_err(struct sk_buff *skb, u32 info)
 {
+	struct net *net = dev_net(skb->dev);
 	struct iphdr *iph = (struct iphdr *)skb->data;
 	struct ip_esp_hdr *esph = (struct ip_esp_hdr *)(skb->data+(iph->ihl<<2));
 	struct xfrm_state *x;
@@ -421,7 +422,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
 	    icmp_hdr(skb)->code != ICMP_FRAG_NEEDED)
 		return;
 
-	x = xfrm_state_lookup(&init_net, (xfrm_address_t *)&iph->daddr, esph->spi, IPPROTO_ESP, AF_INET);
+	x = xfrm_state_lookup(net, (xfrm_address_t *)&iph->daddr, esph->spi, IPPROTO_ESP, AF_INET);
 	if (!x)
 		return;
 	NETDEBUG(KERN_DEBUG "pmtu discovery on SA ESP/%08x/%08x\n",
@@ -618,6 +619,7 @@ static struct net_protocol esp4_protocol = {
 	.handler	=	xfrm4_rcv,
 	.err_handler	=	esp4_err,
 	.no_policy	=	1,
+	.netns_ok	=	1,
 };
 
 static int __init esp4_init(void)
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index 6ae014b..52449f7 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -407,6 +407,7 @@ out:
 static void ah6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 		    int type, int code, int offset, __be32 info)
 {
+	struct net *net = dev_net(skb->dev);
 	struct ipv6hdr *iph = (struct ipv6hdr*)skb->data;
 	struct ip_auth_hdr *ah = (struct ip_auth_hdr*)(skb->data+offset);
 	struct xfrm_state *x;
@@ -415,7 +416,7 @@ static void ah6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 	    type != ICMPV6_PKT_TOOBIG)
 		return;
 
-	x = xfrm_state_lookup(&init_net, (xfrm_address_t *)&iph->daddr, ah->spi, IPPROTO_AH, AF_INET6);
+	x = xfrm_state_lookup(net, (xfrm_address_t *)&iph->daddr, ah->spi, IPPROTO_AH, AF_INET6);
 	if (!x)
 		return;
 
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 68f2af8..c2f2501 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -356,6 +356,7 @@ static u32 esp6_get_mtu(struct xfrm_state *x, int mtu)
 static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 		     int type, int code, int offset, __be32 info)
 {
+	struct net *net = dev_net(skb->dev);
 	struct ipv6hdr *iph = (struct ipv6hdr*)skb->data;
 	struct ip_esp_hdr *esph = (struct ip_esp_hdr *)(skb->data + offset);
 	struct xfrm_state *x;
@@ -364,7 +365,7 @@ static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 	    type != ICMPV6_PKT_TOOBIG)
 		return;
 
-	x = xfrm_state_lookup(&init_net, (xfrm_address_t *)&iph->daddr, esph->spi, IPPROTO_ESP, AF_INET6);
+	x = xfrm_state_lookup(net, (xfrm_address_t *)&iph->daddr, esph->spi, IPPROTO_ESP, AF_INET6);
 	if (!x)
 		return;
 	printk(KERN_DEBUG "pmtu discovery on SA ESP/%08x/%pI6\n",
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 01/53] xfrm: initialise xfrm_policy_gc_work statically, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 02/53] netns xfrm: add netns boilerplate, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 03/53] netns xfrm: add struct xfrm_state::xs_net, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 04/53] netns xfrm: per-netns xfrm_state_all list, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 05/53] netns xfrm: per-netns xfrm_state_bydst hash, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 06/53] netns xfrm: per-netns xfrm_state_bysrc hash, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 07/53] netns xfrm: per-netns xfrm_state_byspi hash, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 08/53] netns xfrm: per-netns xfrm_state_hmask, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 09/53] netns xfrm: per-netns xfrm_state counts, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 10/53] netns xfrm: per-netns xfrm_hash_work, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 11/53] netns xfrm: per-netns state GC list, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 12/53] netns xfrm: per-netns state GC work, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 13/53] netns xfrm: per-netns km_waitq, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 14/53] netns xfrm: add struct xfrm_policy::xp_net, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 15/53] netns xfrm: per-netns policy list, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 16/53] netns xfrm: per-netns xfrm_policy_byidx hash, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 18/53] netns xfrm: per-netns inexact policies, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 19/53] netns xfrm: per-netns xfrm_policy_bydst hash, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 20/53] netns xfrm: per-netns policy counts, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 21/53] netns xfrm: per-netns policy hash resizing work, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 23/53] netns xfrm: trivial netns propagations, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 24/53] netns xfrm: state flush in netns, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 25/53] netns xfrm: state lookup in netns, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 26/53] netns xfrm: fixup xfrm_alloc_spi(), Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 27/53] netns xfrm: finding states in netns, Alexey Dobriyan, (Tue Nov 25, 10:26 am)
[PATCH 28/53] netns xfrm: state walking in netns, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 30/53] netns xfrm: policy insertion in netns, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 31/53] netns xfrm: policy flushing in netns, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 32/53] netns xfrm: finding policy in netns, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 33/53] netns xfrm: policy walking in netns, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 34/53] netns xfrm: lookup in netns, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 35/53] netns xfrm: xfrm_policy_check in netns, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 36/53] netns xfrm: xfrm_route_forward() in netns, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 37/53] netns xfrm: flushing/pruning bundles in netns, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 38/53] netns xfrm: dst garbage-collecting in netns, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 39/53] netns xfrm: xfrm_input() fixup, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 40/53] netns xfrm: per-netns NETLINK_XFRM socket, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 41/53] netns xfrm: xfrm_user module in netns, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 42/53] netns xfrm: pass netns with KM notifications, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 43/53] netns xfrm: KM reporting in netns, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 44/53] netns xfrm: -&gt;dst_lookup in netns, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 45/53] netns xfrm: -&gt;get_saddr in netns, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 46/53] netns xfrm: flush SA/SPDs on netns stop, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 47/53] netns PF_KEY: part 1, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 48/53] netns PF_KEY: part 2, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 49/53] netns PF_KEY: per-netns /proc/pfkey, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 50/53] netns xfrm: AH/ESP in netns!, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 51/53] netns xfrm: per-netns MIBs, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 52/53] netns xfrm: /proc/net/xfrm_stat in netns, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
[PATCH 53/53] netns xfrm: per-netns sysctls, Alexey Dobriyan, (Tue Nov 25, 10:27 am)
Re: [PATCH 02/53] netns xfrm: add netns boilerplate, David Miller, (Tue Nov 25, 6:14 pm)
Re: [PATCH 10/53] netns xfrm: per-netns xfrm_hash_work, David Miller, (Tue Nov 25, 6:19 pm)
Re: [PATCH 11/53] netns xfrm: per-netns state GC list, David Miller, (Tue Nov 25, 6:20 pm)
Re: [PATCH 12/53] netns xfrm: per-netns state GC work, David Miller, (Tue Nov 25, 6:20 pm)
Re: [PATCH 13/53] netns xfrm: per-netns km_waitq, David Miller, (Tue Nov 25, 6:21 pm)
Re: [PATCH 15/53] netns xfrm: per-netns policy list, David Miller, (Tue Nov 25, 6:22 pm)
Re: [PATCH 20/53] netns xfrm: per-netns policy counts, David Miller, (Tue Nov 25, 6:24 pm)
Re: [PATCH 24/53] netns xfrm: state flush in netns, David Miller, (Tue Nov 25, 6:30 pm)
Re: [PATCH 25/53] netns xfrm: state lookup in netns, David Miller, (Tue Nov 25, 6:30 pm)
Re: [PATCH 26/53] netns xfrm: fixup xfrm_alloc_spi(), David Miller, (Tue Nov 25, 6:31 pm)
Re: [PATCH 27/53] netns xfrm: finding states in netns, David Miller, (Tue Nov 25, 6:31 pm)
Re: [PATCH 28/53] netns xfrm: state walking in netns, David Miller, (Tue Nov 25, 6:32 pm)
Re: [PATCH 30/53] netns xfrm: policy insertion in netns, David Miller, (Tue Nov 25, 6:33 pm)
Re: [PATCH 31/53] netns xfrm: policy flushing in netns, David Miller, (Tue Nov 25, 6:33 pm)
Re: [PATCH 32/53] netns xfrm: finding policy in netns, David Miller, (Tue Nov 25, 6:34 pm)
Re: [PATCH 33/53] netns xfrm: policy walking in netns, David Miller, (Tue Nov 25, 6:34 pm)
Re: [PATCH 34/53] netns xfrm: lookup in netns, David Miller, (Tue Nov 25, 6:35 pm)
Re: [PATCH 39/53] netns xfrm: xfrm_input() fixup, David Miller, (Tue Nov 25, 6:38 pm)
Re: [PATCH 41/53] netns xfrm: xfrm_user module in netns, David Miller, (Tue Nov 25, 6:50 pm)
Re: [PATCH 43/53] netns xfrm: KM reporting in netns, David Miller, (Tue Nov 25, 6:51 pm)
Re: [PATCH 44/53] netns xfrm: -&gt;dst_lookup in netns, David Miller, (Tue Nov 25, 6:51 pm)
Re: [PATCH 45/53] netns xfrm: -&gt;get_saddr in netns, David Miller, (Tue Nov 25, 6:56 pm)
Re: [PATCH 47/53] netns PF_KEY: part 1, David Miller, (Tue Nov 25, 6:58 pm)
Re: [PATCH 48/53] netns PF_KEY: part 2, David Miller, (Tue Nov 25, 6:58 pm)
Re: [PATCH 49/53] netns PF_KEY: per-netns /proc/pfkey, David Miller, (Tue Nov 25, 6:59 pm)
Re: [PATCH 50/53] netns xfrm: AH/ESP in netns!, David Miller, (Tue Nov 25, 6:59 pm)
Re: [PATCH 51/53] netns xfrm: per-netns MIBs, David Miller, (Tue Nov 25, 6:59 pm)
Re: [PATCH 53/53] netns xfrm: per-netns sysctls, David Miller, (Tue Nov 25, 7:00 pm)
Re: [PATCH 03/53] netns xfrm: add struct xfrm_state::xs_net, Alexey Dobriyan, (Tue Nov 25, 9:25 pm)