diff options
Diffstat (limited to 'net/ipv4/tcp_ipv4.c')
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index ef5a90beb9b0..27a0cc8cc888 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -149,6 +149,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
149 | struct inet_sock *inet = inet_sk(sk); | 149 | struct inet_sock *inet = inet_sk(sk); |
150 | struct tcp_sock *tp = tcp_sk(sk); | 150 | struct tcp_sock *tp = tcp_sk(sk); |
151 | struct sockaddr_in *usin = (struct sockaddr_in *)uaddr; | 151 | struct sockaddr_in *usin = (struct sockaddr_in *)uaddr; |
152 | __be16 orig_sport, orig_dport; | ||
152 | struct rtable *rt; | 153 | struct rtable *rt; |
153 | __be32 daddr, nexthop; | 154 | __be32 daddr, nexthop; |
154 | int tmp; | 155 | int tmp; |
@@ -167,10 +168,12 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
167 | nexthop = inet->opt->faddr; | 168 | nexthop = inet->opt->faddr; |
168 | } | 169 | } |
169 | 170 | ||
171 | orig_sport = inet->inet_sport; | ||
172 | orig_dport = usin->sin_port; | ||
170 | tmp = ip_route_connect(&rt, nexthop, inet->inet_saddr, | 173 | tmp = ip_route_connect(&rt, nexthop, inet->inet_saddr, |
171 | RT_CONN_FLAGS(sk), sk->sk_bound_dev_if, | 174 | RT_CONN_FLAGS(sk), sk->sk_bound_dev_if, |
172 | IPPROTO_TCP, | 175 | IPPROTO_TCP, |
173 | inet->inet_sport, usin->sin_port, sk, 1); | 176 | orig_sport, orig_dport, sk, 1); |
174 | if (tmp < 0) { | 177 | if (tmp < 0) { |
175 | if (tmp == -ENETUNREACH) | 178 | if (tmp == -ENETUNREACH) |
176 | IP_INC_STATS_BH(sock_net(sk), IPSTATS_MIB_OUTNOROUTES); | 179 | IP_INC_STATS_BH(sock_net(sk), IPSTATS_MIB_OUTNOROUTES); |
@@ -234,6 +237,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
234 | goto failure; | 237 | goto failure; |
235 | 238 | ||
236 | err = ip_route_newports(&rt, IPPROTO_TCP, | 239 | err = ip_route_newports(&rt, IPPROTO_TCP, |
240 | orig_sport, orig_dport, | ||
237 | inet->inet_sport, inet->inet_dport, sk); | 241 | inet->inet_sport, inet->inet_dport, sk); |
238 | if (err) | 242 | if (err) |
239 | goto failure; | 243 | goto failure; |