diff options
author | David S. Miller <davem@davemloft.net> | 2011-03-02 17:31:35 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-03-02 17:31:35 -0500 |
commit | b23dd4fe42b455af5c6e20966b7d6959fa8352ea (patch) | |
tree | bf97323eae9a8d084170e573ff2c0c40bc72c3cd /net/ipv4/af_inet.c | |
parent | 452edd598f60522c11f7f88fdbab27eb36509d1a (diff) |
ipv4: Make output route lookup return rtable directly.
Instead of on the stack.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/af_inet.c')
-rw-r--r-- | net/ipv4/af_inet.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 44513bb8ac2e..35a502055018 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -1101,23 +1101,20 @@ int sysctl_ip_dynaddr __read_mostly; | |||
1101 | static int inet_sk_reselect_saddr(struct sock *sk) | 1101 | static int inet_sk_reselect_saddr(struct sock *sk) |
1102 | { | 1102 | { |
1103 | struct inet_sock *inet = inet_sk(sk); | 1103 | struct inet_sock *inet = inet_sk(sk); |
1104 | int err; | ||
1105 | struct rtable *rt; | ||
1106 | __be32 old_saddr = inet->inet_saddr; | 1104 | __be32 old_saddr = inet->inet_saddr; |
1107 | __be32 new_saddr; | ||
1108 | __be32 daddr = inet->inet_daddr; | 1105 | __be32 daddr = inet->inet_daddr; |
1106 | struct rtable *rt; | ||
1107 | __be32 new_saddr; | ||
1109 | 1108 | ||
1110 | if (inet->opt && inet->opt->srr) | 1109 | if (inet->opt && inet->opt->srr) |
1111 | daddr = inet->opt->faddr; | 1110 | daddr = inet->opt->faddr; |
1112 | 1111 | ||
1113 | /* Query new route. */ | 1112 | /* Query new route. */ |
1114 | err = ip_route_connect(&rt, daddr, 0, | 1113 | rt = ip_route_connect(daddr, 0, RT_CONN_FLAGS(sk), |
1115 | RT_CONN_FLAGS(sk), | 1114 | sk->sk_bound_dev_if, sk->sk_protocol, |
1116 | sk->sk_bound_dev_if, | 1115 | inet->inet_sport, inet->inet_dport, sk, false); |
1117 | sk->sk_protocol, | 1116 | if (IS_ERR(rt)) |
1118 | inet->inet_sport, inet->inet_dport, sk, false); | 1117 | return PTR_ERR(rt); |
1119 | if (err) | ||
1120 | return err; | ||
1121 | 1118 | ||
1122 | sk_setup_caps(sk, &rt->dst); | 1119 | sk_setup_caps(sk, &rt->dst); |
1123 | 1120 | ||
@@ -1160,7 +1157,7 @@ int inet_sk_rebuild_header(struct sock *sk) | |||
1160 | daddr = inet->inet_daddr; | 1157 | daddr = inet->inet_daddr; |
1161 | if (inet->opt && inet->opt->srr) | 1158 | if (inet->opt && inet->opt->srr) |
1162 | daddr = inet->opt->faddr; | 1159 | daddr = inet->opt->faddr; |
1163 | { | 1160 | { |
1164 | struct flowi fl = { | 1161 | struct flowi fl = { |
1165 | .oif = sk->sk_bound_dev_if, | 1162 | .oif = sk->sk_bound_dev_if, |
1166 | .mark = sk->sk_mark, | 1163 | .mark = sk->sk_mark, |
@@ -1174,11 +1171,14 @@ int inet_sk_rebuild_header(struct sock *sk) | |||
1174 | }; | 1171 | }; |
1175 | 1172 | ||
1176 | security_sk_classify_flow(sk, &fl); | 1173 | security_sk_classify_flow(sk, &fl); |
1177 | err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk); | 1174 | rt = ip_route_output_flow(sock_net(sk), &fl, sk); |
1178 | } | 1175 | } |
1179 | if (!err) | 1176 | if (!IS_ERR(rt)) { |
1177 | err = 0; | ||
1180 | sk_setup_caps(sk, &rt->dst); | 1178 | sk_setup_caps(sk, &rt->dst); |
1181 | else { | 1179 | } else { |
1180 | err = PTR_ERR(rt); | ||
1181 | |||
1182 | /* Routing failed... */ | 1182 | /* Routing failed... */ |
1183 | sk->sk_route_caps = 0; | 1183 | sk->sk_route_caps = 0; |
1184 | /* | 1184 | /* |