Commit fdbb0f07 authored by David S. Miller's avatar David S. Miller

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: default avatarDavid S. Miller <davem@davemloft.net>
parent 6af88da1
...@@ -298,7 +298,7 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len ...@@ -298,7 +298,7 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
{ {
struct sockaddr_l2tpip *lsa = (struct sockaddr_l2tpip *) uaddr; struct sockaddr_l2tpip *lsa = (struct sockaddr_l2tpip *) uaddr;
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct flowi4 fl4; struct flowi4 *fl4;
struct rtable *rt; struct rtable *rt;
__be32 saddr; __be32 saddr;
int oif, rc; int oif, rc;
...@@ -322,7 +322,8 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len ...@@ -322,7 +322,8 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
if (ipv4_is_multicast(lsa->l2tp_addr.s_addr)) if (ipv4_is_multicast(lsa->l2tp_addr.s_addr))
goto out; goto out;
rt = ip_route_connect(&fl4, lsa->l2tp_addr.s_addr, saddr, fl4 = &inet->cork.fl.u.ip4;
rt = ip_route_connect(fl4, lsa->l2tp_addr.s_addr, saddr,
RT_CONN_FLAGS(sk), oif, RT_CONN_FLAGS(sk), oif,
IPPROTO_L2TP, IPPROTO_L2TP,
0, 0, sk, true); 0, 0, sk, true);
...@@ -342,10 +343,10 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len ...@@ -342,10 +343,10 @@ static int l2tp_ip_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
l2tp_ip_sk(sk)->peer_conn_id = lsa->l2tp_conn_id; l2tp_ip_sk(sk)->peer_conn_id = lsa->l2tp_conn_id;
if (!inet->inet_saddr) if (!inet->inet_saddr)
inet->inet_saddr = fl4.saddr; inet->inet_saddr = fl4->saddr;
if (!inet->inet_rcv_saddr) if (!inet->inet_rcv_saddr)
inet->inet_rcv_saddr = fl4.saddr; inet->inet_rcv_saddr = fl4->saddr;
inet->inet_daddr = fl4.daddr; inet->inet_daddr = fl4->daddr;
sk->sk_state = TCP_ESTABLISHED; sk->sk_state = TCP_ESTABLISHED;
inet->inet_id = jiffies; inet->inet_id = jiffies;
...@@ -420,6 +421,7 @@ static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m ...@@ -420,6 +421,7 @@ static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m
struct l2tp_ip_sock *lsa = l2tp_ip_sk(sk); struct l2tp_ip_sock *lsa = l2tp_ip_sk(sk);
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct rtable *rt = NULL; struct rtable *rt = NULL;
struct flowi4 *fl4;
int connected = 0; int connected = 0;
__be32 daddr; __be32 daddr;
...@@ -474,12 +476,12 @@ static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m ...@@ -474,12 +476,12 @@ static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m
goto error; goto error;
} }
fl4 = &inet->cork.fl.u.ip4;
if (connected) if (connected)
rt = (struct rtable *) __sk_dst_check(sk, 0); rt = (struct rtable *) __sk_dst_check(sk, 0);
if (rt == NULL) { if (rt == NULL) {
struct ip_options_rcu *inet_opt; struct ip_options_rcu *inet_opt;
struct flowi4 fl4;
rcu_read_lock(); rcu_read_lock();
inet_opt = rcu_dereference(inet->inet_opt); 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,7 +496,7 @@ static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m
* keep trying until route appears or the connection times * keep trying until route appears or the connection times
* itself out. * itself out.
*/ */
rt = ip_route_output_ports(sock_net(sk), &fl4, sk, rt = ip_route_output_ports(sock_net(sk), fl4, sk,
daddr, inet->inet_saddr, daddr, inet->inet_saddr,
inet->inet_dport, inet->inet_sport, inet->inet_dport, inet->inet_sport,
sk->sk_protocol, RT_CONN_FLAGS(sk), sk->sk_protocol, RT_CONN_FLAGS(sk),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment