diff options
Diffstat (limited to 'net/l2tp/l2tp_ip.c')
-rw-r--r-- | net/l2tp/l2tp_ip.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c index 61d8b75d2686..7f41b7051269 100644 --- a/net/l2tp/l2tp_ip.c +++ b/net/l2tp/l2tp_ip.c | |||
@@ -49,10 +49,9 @@ static inline struct l2tp_ip_sock *l2tp_ip_sk(const struct sock *sk) | |||
49 | 49 | ||
50 | static struct sock *__l2tp_ip_bind_lookup(struct net *net, __be32 laddr, int dif, u32 tunnel_id) | 50 | static struct sock *__l2tp_ip_bind_lookup(struct net *net, __be32 laddr, int dif, u32 tunnel_id) |
51 | { | 51 | { |
52 | struct hlist_node *node; | ||
53 | struct sock *sk; | 52 | struct sock *sk; |
54 | 53 | ||
55 | sk_for_each_bound(sk, node, &l2tp_ip_bind_table) { | 54 | sk_for_each_bound(sk, &l2tp_ip_bind_table) { |
56 | struct inet_sock *inet = inet_sk(sk); | 55 | struct inet_sock *inet = inet_sk(sk); |
57 | struct l2tp_ip_sock *l2tp = l2tp_ip_sk(sk); | 56 | struct l2tp_ip_sock *l2tp = l2tp_ip_sk(sk); |
58 | 57 | ||
@@ -115,6 +114,7 @@ static inline struct sock *l2tp_ip_bind_lookup(struct net *net, __be32 laddr, in | |||
115 | */ | 114 | */ |
116 | static int l2tp_ip_recv(struct sk_buff *skb) | 115 | static int l2tp_ip_recv(struct sk_buff *skb) |
117 | { | 116 | { |
117 | struct net *net = dev_net(skb->dev); | ||
118 | struct sock *sk; | 118 | struct sock *sk; |
119 | u32 session_id; | 119 | u32 session_id; |
120 | u32 tunnel_id; | 120 | u32 tunnel_id; |
@@ -142,7 +142,7 @@ static int l2tp_ip_recv(struct sk_buff *skb) | |||
142 | } | 142 | } |
143 | 143 | ||
144 | /* Ok, this is a data packet. Lookup the session. */ | 144 | /* Ok, this is a data packet. Lookup the session. */ |
145 | session = l2tp_session_find(&init_net, NULL, session_id); | 145 | session = l2tp_session_find(net, NULL, session_id); |
146 | if (session == NULL) | 146 | if (session == NULL) |
147 | goto discard; | 147 | goto discard; |
148 | 148 | ||
@@ -173,14 +173,14 @@ pass_up: | |||
173 | goto discard; | 173 | goto discard; |
174 | 174 | ||
175 | tunnel_id = ntohl(*(__be32 *) &skb->data[4]); | 175 | tunnel_id = ntohl(*(__be32 *) &skb->data[4]); |
176 | tunnel = l2tp_tunnel_find(&init_net, tunnel_id); | 176 | tunnel = l2tp_tunnel_find(net, tunnel_id); |
177 | if (tunnel != NULL) | 177 | if (tunnel != NULL) |
178 | sk = tunnel->sock; | 178 | sk = tunnel->sock; |
179 | else { | 179 | else { |
180 | struct iphdr *iph = (struct iphdr *) skb_network_header(skb); | 180 | struct iphdr *iph = (struct iphdr *) skb_network_header(skb); |
181 | 181 | ||
182 | read_lock_bh(&l2tp_ip_lock); | 182 | read_lock_bh(&l2tp_ip_lock); |
183 | sk = __l2tp_ip_bind_lookup(&init_net, iph->daddr, 0, tunnel_id); | 183 | sk = __l2tp_ip_bind_lookup(net, iph->daddr, 0, tunnel_id); |
184 | read_unlock_bh(&l2tp_ip_lock); | 184 | read_unlock_bh(&l2tp_ip_lock); |
185 | } | 185 | } |
186 | 186 | ||
@@ -239,6 +239,7 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
239 | { | 239 | { |
240 | struct inet_sock *inet = inet_sk(sk); | 240 | struct inet_sock *inet = inet_sk(sk); |
241 | struct sockaddr_l2tpip *addr = (struct sockaddr_l2tpip *) uaddr; | 241 | struct sockaddr_l2tpip *addr = (struct sockaddr_l2tpip *) uaddr; |
242 | struct net *net = sock_net(sk); | ||
242 | int ret; | 243 | int ret; |
243 | int chk_addr_ret; | 244 | int chk_addr_ret; |
244 | 245 | ||
@@ -251,7 +252,8 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
251 | 252 | ||
252 | ret = -EADDRINUSE; | 253 | ret = -EADDRINUSE; |
253 | read_lock_bh(&l2tp_ip_lock); | 254 | read_lock_bh(&l2tp_ip_lock); |
254 | if (__l2tp_ip_bind_lookup(&init_net, addr->l2tp_addr.s_addr, sk->sk_bound_dev_if, addr->l2tp_conn_id)) | 255 | if (__l2tp_ip_bind_lookup(net, addr->l2tp_addr.s_addr, |
256 | sk->sk_bound_dev_if, addr->l2tp_conn_id)) | ||
255 | goto out_in_use; | 257 | goto out_in_use; |
256 | 258 | ||
257 | read_unlock_bh(&l2tp_ip_lock); | 259 | read_unlock_bh(&l2tp_ip_lock); |
@@ -260,7 +262,7 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
260 | if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_l2tpip)) | 262 | if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_l2tpip)) |
261 | goto out; | 263 | goto out; |
262 | 264 | ||
263 | chk_addr_ret = inet_addr_type(&init_net, addr->l2tp_addr.s_addr); | 265 | chk_addr_ret = inet_addr_type(net, addr->l2tp_addr.s_addr); |
264 | ret = -EADDRNOTAVAIL; | 266 | ret = -EADDRNOTAVAIL; |
265 | if (addr->l2tp_addr.s_addr && chk_addr_ret != RTN_LOCAL && | 267 | if (addr->l2tp_addr.s_addr && chk_addr_ret != RTN_LOCAL && |
266 | chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST) | 268 | chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST) |
@@ -369,7 +371,7 @@ static int l2tp_ip_backlog_recv(struct sock *sk, struct sk_buff *skb) | |||
369 | return 0; | 371 | return 0; |
370 | 372 | ||
371 | drop: | 373 | drop: |
372 | IP_INC_STATS(&init_net, IPSTATS_MIB_INDISCARDS); | 374 | IP_INC_STATS(sock_net(sk), IPSTATS_MIB_INDISCARDS); |
373 | kfree_skb(skb); | 375 | kfree_skb(skb); |
374 | return -1; | 376 | return -1; |
375 | } | 377 | } |
@@ -605,6 +607,7 @@ static struct inet_protosw l2tp_ip_protosw = { | |||
605 | 607 | ||
606 | static struct net_protocol l2tp_ip_protocol __read_mostly = { | 608 | static struct net_protocol l2tp_ip_protocol __read_mostly = { |
607 | .handler = l2tp_ip_recv, | 609 | .handler = l2tp_ip_recv, |
610 | .netns_ok = 1, | ||
608 | }; | 611 | }; |
609 | 612 | ||
610 | static int __init l2tp_ip_init(void) | 613 | static int __init l2tp_ip_init(void) |