diff options
-rw-r--r-- | include/net/xfrm.h | 10 | ||||
-rw-r--r-- | net/ipv4/ipcomp.c | 2 | ||||
-rw-r--r-- | net/ipv6/ipcomp6.c | 2 | ||||
-rw-r--r-- | net/key/af_key.c | 2 | ||||
-rw-r--r-- | net/xfrm/xfrm_state.c | 9 | ||||
-rw-r--r-- | net/xfrm/xfrm_user.c | 4 |
6 files changed, 19 insertions, 10 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 9107d6f5c297..9da89039832c 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
@@ -130,6 +130,9 @@ struct xfrm_state_walk { | |||
130 | /* Full description of state of transformer. */ | 130 | /* Full description of state of transformer. */ |
131 | struct xfrm_state | 131 | struct xfrm_state |
132 | { | 132 | { |
133 | #ifdef CONFIG_NET_NS | ||
134 | struct net *xs_net; | ||
135 | #endif | ||
133 | union { | 136 | union { |
134 | struct hlist_node gclist; | 137 | struct hlist_node gclist; |
135 | struct hlist_node bydst; | 138 | struct hlist_node bydst; |
@@ -223,6 +226,11 @@ struct xfrm_state | |||
223 | void *data; | 226 | void *data; |
224 | }; | 227 | }; |
225 | 228 | ||
229 | static inline struct net *xs_net(struct xfrm_state *x) | ||
230 | { | ||
231 | return read_pnet(&x->xs_net); | ||
232 | } | ||
233 | |||
226 | /* xflags - make enum if more show up */ | 234 | /* xflags - make enum if more show up */ |
227 | #define XFRM_TIME_DEFER 1 | 235 | #define XFRM_TIME_DEFER 1 |
228 | 236 | ||
@@ -1296,7 +1304,7 @@ extern void xfrm_state_walk_init(struct xfrm_state_walk *walk, u8 proto); | |||
1296 | extern int xfrm_state_walk(struct xfrm_state_walk *walk, | 1304 | extern int xfrm_state_walk(struct xfrm_state_walk *walk, |
1297 | int (*func)(struct xfrm_state *, int, void*), void *); | 1305 | int (*func)(struct xfrm_state *, int, void*), void *); |
1298 | extern void xfrm_state_walk_done(struct xfrm_state_walk *walk); | 1306 | extern void xfrm_state_walk_done(struct xfrm_state_walk *walk); |
1299 | extern struct xfrm_state *xfrm_state_alloc(void); | 1307 | extern struct xfrm_state *xfrm_state_alloc(struct net *net); |
1300 | extern struct xfrm_state *xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, | 1308 | extern struct xfrm_state *xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, |
1301 | struct flowi *fl, struct xfrm_tmpl *tmpl, | 1309 | struct flowi *fl, struct xfrm_tmpl *tmpl, |
1302 | struct xfrm_policy *pol, int *err, | 1310 | struct xfrm_policy *pol, int *err, |
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 | ||
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 | ||
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) |