diff options
Diffstat (limited to 'net/ipv4/tcp_ipv4.c')
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 05bc6d9455fc..f7e6c2c2d2bb 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -152,7 +152,6 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
152 | __be16 orig_sport, orig_dport; | 152 | __be16 orig_sport, orig_dport; |
153 | struct rtable *rt; | 153 | struct rtable *rt; |
154 | __be32 daddr, nexthop; | 154 | __be32 daddr, nexthop; |
155 | int tmp; | ||
156 | int err; | 155 | int err; |
157 | 156 | ||
158 | if (addr_len < sizeof(struct sockaddr_in)) | 157 | if (addr_len < sizeof(struct sockaddr_in)) |
@@ -170,14 +169,15 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
170 | 169 | ||
171 | orig_sport = inet->inet_sport; | 170 | orig_sport = inet->inet_sport; |
172 | orig_dport = usin->sin_port; | 171 | orig_dport = usin->sin_port; |
173 | tmp = ip_route_connect(&rt, nexthop, inet->inet_saddr, | 172 | rt = ip_route_connect(nexthop, inet->inet_saddr, |
174 | RT_CONN_FLAGS(sk), sk->sk_bound_dev_if, | 173 | RT_CONN_FLAGS(sk), sk->sk_bound_dev_if, |
175 | IPPROTO_TCP, | 174 | IPPROTO_TCP, |
176 | orig_sport, orig_dport, sk, true); | 175 | orig_sport, orig_dport, sk, true); |
177 | if (tmp < 0) { | 176 | if (IS_ERR(rt)) { |
178 | if (tmp == -ENETUNREACH) | 177 | err = PTR_ERR(rt); |
178 | if (err == -ENETUNREACH) | ||
179 | IP_INC_STATS_BH(sock_net(sk), IPSTATS_MIB_OUTNOROUTES); | 179 | IP_INC_STATS_BH(sock_net(sk), IPSTATS_MIB_OUTNOROUTES); |
180 | return tmp; | 180 | return err; |
181 | } | 181 | } |
182 | 182 | ||
183 | if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) { | 183 | if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) { |
@@ -236,12 +236,14 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
236 | if (err) | 236 | if (err) |
237 | goto failure; | 237 | goto failure; |
238 | 238 | ||
239 | err = ip_route_newports(&rt, IPPROTO_TCP, | 239 | rt = ip_route_newports(rt, IPPROTO_TCP, |
240 | orig_sport, orig_dport, | 240 | orig_sport, orig_dport, |
241 | inet->inet_sport, inet->inet_dport, sk); | 241 | inet->inet_sport, inet->inet_dport, sk); |
242 | if (err) | 242 | if (IS_ERR(rt)) { |
243 | err = PTR_ERR(rt); | ||
244 | rt = NULL; | ||
243 | goto failure; | 245 | goto failure; |
244 | 246 | } | |
245 | /* OK, now commit destination to socket. */ | 247 | /* OK, now commit destination to socket. */ |
246 | sk->sk_gso_type = SKB_GSO_TCPV4; | 248 | sk->sk_gso_type = SKB_GSO_TCPV4; |
247 | sk_setup_caps(sk, &rt->dst); | 249 | sk_setup_caps(sk, &rt->dst); |