aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-05-08 16:48:37 -0400
committerDavid S. Miller <davem@davemloft.net>2011-05-08 16:48:37 -0400
commitfdbb0f076b065a0c753ba26925f10357505f1d42 (patch)
tree7b868c7216c2e5f29af9e06f58eec2ced201bb6f /net
parent6af88da14ee284aaad6e4326da09a89191ab6165 (diff)
l2tp: Use cork flow in l2tp_ip_connect() and l2tp_ip_sendmsg()
Now that the socket is consistently locked in these two routines, this transformation is legal. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/l2tp/l2tp_ip.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
index bd0cc0b8f32f..1ca74892ff09 100644
--- a/net/l2tp/l2tp_ip.c
+++ b/net/l2tp/l2tp_ip.c
@@ -298,7 +298,7 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
298{ 298{
299 struct sockaddr_l2tpip *lsa = (struct sockaddr_l2tpip *) uaddr; 299 struct sockaddr_l2tpip *lsa = (struct sockaddr_l2tpip *) uaddr;
300 struct inet_sock *inet = inet_sk(sk); 300 struct inet_sock *inet = inet_sk(sk);
301 struct flowi4 fl4; 301 struct flowi4 *fl4;
302 struct rtable *rt; 302 struct rtable *rt;
303 __be32 saddr; 303 __be32 saddr;
304 int oif, rc; 304 int oif, rc;
@@ -322,7 +322,8 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
322 if (ipv4_is_multicast(lsa->l2tp_addr.s_addr)) 322 if (ipv4_is_multicast(lsa->l2tp_addr.s_addr))
323 goto out; 323 goto out;
324 324
325 rt = ip_route_connect(&fl4, lsa->l2tp_addr.s_addr, saddr, 325 fl4 = &inet->cork.fl.u.ip4;
326 rt = ip_route_connect(fl4, lsa->l2tp_addr.s_addr, saddr,
326 RT_CONN_FLAGS(sk), oif, 327 RT_CONN_FLAGS(sk), oif,
327 IPPROTO_L2TP, 328 IPPROTO_L2TP,
328 0, 0, sk, true); 329 0, 0, sk, true);
@@ -342,10 +343,10 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
342 l2tp_ip_sk(sk)->peer_conn_id = lsa->l2tp_conn_id; 343 l2tp_ip_sk(sk)->peer_conn_id = lsa->l2tp_conn_id;
343 344
344 if (!inet->inet_saddr) 345 if (!inet->inet_saddr)
345 inet->inet_saddr = fl4.saddr; 346 inet->inet_saddr = fl4->saddr;
346 if (!inet->inet_rcv_saddr) 347 if (!inet->inet_rcv_saddr)
347 inet->inet_rcv_saddr = fl4.saddr; 348 inet->inet_rcv_saddr = fl4->saddr;
348 inet->inet_daddr = fl4.daddr; 349 inet->inet_daddr = fl4->daddr;
349 sk->sk_state = TCP_ESTABLISHED; 350 sk->sk_state = TCP_ESTABLISHED;
350 inet->inet_id = jiffies; 351 inet->inet_id = jiffies;
351 352
@@ -420,6 +421,7 @@ static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m
420 struct l2tp_ip_sock *lsa = l2tp_ip_sk(sk); 421 struct l2tp_ip_sock *lsa = l2tp_ip_sk(sk);
421 struct inet_sock *inet = inet_sk(sk); 422 struct inet_sock *inet = inet_sk(sk);
422 struct rtable *rt = NULL; 423 struct rtable *rt = NULL;
424 struct flowi4 *fl4;
423 int connected = 0; 425 int connected = 0;
424 __be32 daddr; 426 __be32 daddr;
425 427
@@ -474,12 +476,12 @@ static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m
474 goto error; 476 goto error;
475 } 477 }
476 478
479 fl4 = &inet->cork.fl.u.ip4;
477 if (connected) 480 if (connected)
478 rt = (struct rtable *) __sk_dst_check(sk, 0); 481 rt = (struct rtable *) __sk_dst_check(sk, 0);
479 482
480 if (rt == NULL) { 483 if (rt == NULL) {
481 struct ip_options_rcu *inet_opt; 484 struct ip_options_rcu *inet_opt;
482 struct flowi4 fl4;
483 485
484 rcu_read_lock(); 486 rcu_read_lock();
485 inet_opt = rcu_dereference(inet->inet_opt); 487 inet_opt = rcu_dereference(inet->inet_opt);
@@ -494,7 +496,7 @@ static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m
494 * keep trying until route appears or the connection times 496 * keep trying until route appears or the connection times
495 * itself out. 497 * itself out.
496 */ 498 */
497 rt = ip_route_output_ports(sock_net(sk), &fl4, sk, 499 rt = ip_route_output_ports(sock_net(sk), fl4, sk,
498 daddr, inet->inet_saddr, 500 daddr, inet->inet_saddr,
499 inet->inet_dport, inet->inet_sport, 501 inet->inet_dport, inet->inet_sport,
500 sk->sk_protocol, RT_CONN_FLAGS(sk), 502 sk->sk_protocol, RT_CONN_FLAGS(sk),