aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2008-11-25 20:15:16 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-25 20:15:16 -0500
commit673c09be457bb23aa0eaaa79804cbb342210d195 (patch)
tree9948d1859bbcd07316f5cea239b86845d6061570 /net
parentd62ddc21b674b5ac1466091ff3fbf7baa53bc92c (diff)
netns xfrm: add struct xfrm_state::xs_net
To avoid unnecessary complications with passing netns around. * set once, very early after allocating * once set, never changes For a while create every xfrm_state in init_net. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/ipcomp.c2
-rw-r--r--net/ipv6/ipcomp6.c2
-rw-r--r--net/key/af_key.c2
-rw-r--r--net/xfrm/xfrm_state.c9
-rw-r--r--net/xfrm/xfrm_user.c4
5 files changed, 10 insertions, 9 deletions
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index ec8264ae45c2..0a35f1b6f22c 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -49,7 +49,7 @@ static struct xfrm_state *ipcomp_tunnel_create(struct xfrm_state *x)
49{ 49{
50 struct xfrm_state *t; 50 struct xfrm_state *t;
51 51
52 t = xfrm_state_alloc(); 52 t = xfrm_state_alloc(&init_net);
53 if (t == NULL) 53 if (t == NULL)
54 goto out; 54 goto out;
55 55
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index d4576a9c154f..c369638e208a 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -76,7 +76,7 @@ static struct xfrm_state *ipcomp6_tunnel_create(struct xfrm_state *x)
76{ 76{
77 struct xfrm_state *t = NULL; 77 struct xfrm_state *t = NULL;
78 78
79 t = xfrm_state_alloc(); 79 t = xfrm_state_alloc(&init_net);
80 if (!t) 80 if (!t)
81 goto out; 81 goto out;
82 82
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 5b22e011653b..bde8aad4cc93 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -1122,7 +1122,7 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct sadb_msg *hdr,
1122 (key->sadb_key_bits+7) / 8 > key->sadb_key_len * sizeof(uint64_t))) 1122 (key->sadb_key_bits+7) / 8 > key->sadb_key_len * sizeof(uint64_t)))
1123 return ERR_PTR(-EINVAL); 1123 return ERR_PTR(-EINVAL);
1124 1124
1125 x = xfrm_state_alloc(); 1125 x = xfrm_state_alloc(&init_net);
1126 if (x == NULL) 1126 if (x == NULL)
1127 return ERR_PTR(-ENOBUFS); 1127 return ERR_PTR(-ENOBUFS);
1128 1128
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 268fe3f9e498..81bde76d049c 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -504,13 +504,14 @@ out:
504 504
505static void xfrm_replay_timer_handler(unsigned long data); 505static void xfrm_replay_timer_handler(unsigned long data);
506 506
507struct xfrm_state *xfrm_state_alloc(void) 507struct xfrm_state *xfrm_state_alloc(struct net *net)
508{ 508{
509 struct xfrm_state *x; 509 struct xfrm_state *x;
510 510
511 x = kzalloc(sizeof(struct xfrm_state), GFP_ATOMIC); 511 x = kzalloc(sizeof(struct xfrm_state), GFP_ATOMIC);
512 512
513 if (x) { 513 if (x) {
514 write_pnet(&x->xs_net, net);
514 atomic_set(&x->refcnt, 1); 515 atomic_set(&x->refcnt, 1);
515 atomic_set(&x->tunnel_users, 0); 516 atomic_set(&x->tunnel_users, 0);
516 INIT_LIST_HEAD(&x->km.all); 517 INIT_LIST_HEAD(&x->km.all);
@@ -835,7 +836,7 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
835 error = -EEXIST; 836 error = -EEXIST;
836 goto out; 837 goto out;
837 } 838 }
838 x = xfrm_state_alloc(); 839 x = xfrm_state_alloc(&init_net);
839 if (x == NULL) { 840 if (x == NULL) {
840 error = -ENOMEM; 841 error = -ENOMEM;
841 goto out; 842 goto out;
@@ -1017,7 +1018,7 @@ static struct xfrm_state *__find_acq_core(unsigned short family, u8 mode, u32 re
1017 if (!create) 1018 if (!create)
1018 return NULL; 1019 return NULL;
1019 1020
1020 x = xfrm_state_alloc(); 1021 x = xfrm_state_alloc(&init_net);
1021 if (likely(x)) { 1022 if (likely(x)) {
1022 switch (family) { 1023 switch (family) {
1023 case AF_INET: 1024 case AF_INET:
@@ -1125,7 +1126,7 @@ EXPORT_SYMBOL(xfrm_state_add);
1125static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp) 1126static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp)
1126{ 1127{
1127 int err = -ENOMEM; 1128 int err = -ENOMEM;
1128 struct xfrm_state *x = xfrm_state_alloc(); 1129 struct xfrm_state *x = xfrm_state_alloc(&init_net);
1129 if (!x) 1130 if (!x)
1130 goto error; 1131 goto error;
1131 1132
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index ee15d5dd6544..65cdaa5c2280 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -320,7 +320,7 @@ static struct xfrm_state *xfrm_state_construct(struct xfrm_usersa_info *p,
320 struct nlattr **attrs, 320 struct nlattr **attrs,
321 int *errp) 321 int *errp)
322{ 322{
323 struct xfrm_state *x = xfrm_state_alloc(); 323 struct xfrm_state *x = xfrm_state_alloc(&init_net);
324 int err = -ENOMEM; 324 int err = -ENOMEM;
325 325
326 if (!x) 326 if (!x)
@@ -1663,7 +1663,7 @@ static int xfrm_add_acquire(struct sk_buff *skb, struct nlmsghdr *nlh,
1663 struct nlattr *rt = attrs[XFRMA_TMPL]; 1663 struct nlattr *rt = attrs[XFRMA_TMPL];
1664 1664
1665 struct xfrm_user_acquire *ua = nlmsg_data(nlh); 1665 struct xfrm_user_acquire *ua = nlmsg_data(nlh);
1666 struct xfrm_state *x = xfrm_state_alloc(); 1666 struct xfrm_state *x = xfrm_state_alloc(&init_net);
1667 int err = -ENOMEM; 1667 int err = -ENOMEM;
1668 1668
1669 if (!x) 1669 if (!x)