diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2008-11-25 20:15:16 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-11-25 20:15:16 -0500 |
commit | 673c09be457bb23aa0eaaa79804cbb342210d195 (patch) | |
tree | 9948d1859bbcd07316f5cea239b86845d6061570 /net/xfrm/xfrm_state.c | |
parent | d62ddc21b674b5ac1466091ff3fbf7baa53bc92c (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/xfrm/xfrm_state.c')
-rw-r--r-- | net/xfrm/xfrm_state.c | 9 |
1 files changed, 5 insertions, 4 deletions
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 | ||
505 | static void xfrm_replay_timer_handler(unsigned long data); | 505 | static void xfrm_replay_timer_handler(unsigned long data); |
506 | 506 | ||
507 | struct xfrm_state *xfrm_state_alloc(void) | 507 | struct 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); | |||
1125 | static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp) | 1126 | static 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 | ||