Skip to content

Commit a92df25

Browse files
Alexey Dobriyandavem330
authored andcommitted
netns xfrm: ipcomp support
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a166477 commit a92df25

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎net/ipv4/ipcomp.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
static void ipcomp4_err(struct sk_buff *skb, u32 info)
2727
{
28+
struct net *net = dev_net(skb->dev);
2829
__be32 spi;
2930
struct iphdr *iph = (struct iphdr *)skb->data;
3031
struct ip_comp_hdr *ipch = (struct ip_comp_hdr *)(skb->data+(iph->ihl<<2));
@@ -35,7 +36,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
3536
return;
3637

3738
spi = htonl(ntohs(ipch->cpi));
38-
x = xfrm_state_lookup(&init_net, (xfrm_address_t *)&iph->daddr,
39+
x = xfrm_state_lookup(net, (xfrm_address_t *)&iph->daddr,
3940
spi, IPPROTO_COMP, AF_INET);
4041
if (!x)
4142
return;
@@ -47,9 +48,10 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
4748
/* We always hold one tunnel user reference to indicate a tunnel */
4849
static struct xfrm_state *ipcomp_tunnel_create(struct xfrm_state *x)
4950
{
51+
struct net *net = xs_net(x);
5052
struct xfrm_state *t;
5153

52-
t = xfrm_state_alloc(&init_net);
54+
t = xfrm_state_alloc(net);
5355
if (t == NULL)
5456
goto out;
5557

@@ -82,10 +84,11 @@ static struct xfrm_state *ipcomp_tunnel_create(struct xfrm_state *x)
8284
*/
8385
static int ipcomp_tunnel_attach(struct xfrm_state *x)
8486
{
87+
struct net *net = xs_net(x);
8588
int err = 0;
8689
struct xfrm_state *t;
8790

88-
t = xfrm_state_lookup(&init_net, (xfrm_address_t *)&x->id.daddr.a4,
91+
t = xfrm_state_lookup(net, (xfrm_address_t *)&x->id.daddr.a4,
8992
x->props.saddr.a4, IPPROTO_IPIP, AF_INET);
9093
if (!t) {
9194
t = ipcomp_tunnel_create(x);

0 commit comments

Comments
 (0)