aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-05-06 19:18:04 -0400
committerDavid S. Miller <davem@davemloft.net>2011-05-08 17:05:13 -0400
commit6e869138101bc607e4780187210b79d531f9b2ce (patch)
treefe85b2fb73b2658684d27f7d90188f8d735ad9c1 /net/ipv4
parent3038eeac027d8ec62e4936143498f2b37baf4cb5 (diff)
ipv4: Use cork flow in inet_sk_{reselect_saddr,rebuild_header}()
These two functions must be invoked only when the socket is locked (because socket identity modifications are made non-atomically). Therefore we can use the cork flow for output route lookups. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/af_inet.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 7b91fa8bf83c..851aa056854b 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1103,7 +1103,7 @@ static int inet_sk_reselect_saddr(struct sock *sk)
1103 struct inet_sock *inet = inet_sk(sk); 1103 struct inet_sock *inet = inet_sk(sk);
1104 __be32 old_saddr = inet->inet_saddr; 1104 __be32 old_saddr = inet->inet_saddr;
1105 __be32 daddr = inet->inet_daddr; 1105 __be32 daddr = inet->inet_daddr;
1106 struct flowi4 fl4; 1106 struct flowi4 *fl4;
1107 struct rtable *rt; 1107 struct rtable *rt;
1108 __be32 new_saddr; 1108 __be32 new_saddr;
1109 struct ip_options_rcu *inet_opt; 1109 struct ip_options_rcu *inet_opt;
@@ -1114,7 +1114,8 @@ static int inet_sk_reselect_saddr(struct sock *sk)
1114 daddr = inet_opt->opt.faddr; 1114 daddr = inet_opt->opt.faddr;
1115 1115
1116 /* Query new route. */ 1116 /* Query new route. */
1117 rt = ip_route_connect(&fl4, daddr, 0, RT_CONN_FLAGS(sk), 1117 fl4 = &inet->cork.fl.u.ip4;
1118 rt = ip_route_connect(fl4, daddr, 0, RT_CONN_FLAGS(sk),
1118 sk->sk_bound_dev_if, sk->sk_protocol, 1119 sk->sk_bound_dev_if, sk->sk_protocol,
1119 inet->inet_sport, inet->inet_dport, sk, false); 1120 inet->inet_sport, inet->inet_dport, sk, false);
1120 if (IS_ERR(rt)) 1121 if (IS_ERR(rt))
@@ -1122,7 +1123,7 @@ static int inet_sk_reselect_saddr(struct sock *sk)
1122 1123
1123 sk_setup_caps(sk, &rt->dst); 1124 sk_setup_caps(sk, &rt->dst);
1124 1125
1125 new_saddr = fl4.saddr; 1126 new_saddr = fl4->saddr;
1126 1127
1127 if (new_saddr == old_saddr) 1128 if (new_saddr == old_saddr)
1128 return 0; 1129 return 0;
@@ -1152,7 +1153,7 @@ int inet_sk_rebuild_header(struct sock *sk)
1152 struct rtable *rt = (struct rtable *)__sk_dst_check(sk, 0); 1153 struct rtable *rt = (struct rtable *)__sk_dst_check(sk, 0);
1153 __be32 daddr; 1154 __be32 daddr;
1154 struct ip_options_rcu *inet_opt; 1155 struct ip_options_rcu *inet_opt;
1155 struct flowi4 fl4; 1156 struct flowi4 *fl4;
1156 int err; 1157 int err;
1157 1158
1158 /* Route is OK, nothing to do. */ 1159 /* Route is OK, nothing to do. */
@@ -1166,7 +1167,8 @@ int inet_sk_rebuild_header(struct sock *sk)
1166 if (inet_opt && inet_opt->opt.srr) 1167 if (inet_opt && inet_opt->opt.srr)
1167 daddr = inet_opt->opt.faddr; 1168 daddr = inet_opt->opt.faddr;
1168 rcu_read_unlock(); 1169 rcu_read_unlock();
1169 rt = ip_route_output_ports(sock_net(sk), &fl4, sk, daddr, inet->inet_saddr, 1170 fl4 = &inet->cork.fl.u.ip4;
1171 rt = ip_route_output_ports(sock_net(sk), fl4, sk, daddr, inet->inet_saddr,
1170 inet->inet_dport, inet->inet_sport, 1172 inet->inet_dport, inet->inet_sport,
1171 sk->sk_protocol, RT_CONN_FLAGS(sk), 1173 sk->sk_protocol, RT_CONN_FLAGS(sk),
1172 sk->sk_bound_dev_if); 1174 sk->sk_bound_dev_if);