Commit 5d39a795 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[IPV4]: Always set fl.proto in ip_route_newports

ip_route_newports uses the struct flowi from the struct rtable returned
by ip_route_connect for the new route lookup and just replaces the port
numbers if they have changed. If an IPsec policy exists which doesn't match
port 0 the struct flowi won't have the proto field set and no xfrm lookup
is done for the changed ports.
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7fb76aa0
...@@ -170,8 +170,8 @@ static inline int ip_route_connect(struct rtable **rp, u32 dst, ...@@ -170,8 +170,8 @@ static inline int ip_route_connect(struct rtable **rp, u32 dst,
return ip_route_output_flow(rp, &fl, sk, 0); return ip_route_output_flow(rp, &fl, sk, 0);
} }
static inline int ip_route_newports(struct rtable **rp, u16 sport, u16 dport, static inline int ip_route_newports(struct rtable **rp, u8 protocol,
struct sock *sk) u16 sport, u16 dport, struct sock *sk)
{ {
if (sport != (*rp)->fl.fl_ip_sport || if (sport != (*rp)->fl.fl_ip_sport ||
dport != (*rp)->fl.fl_ip_dport) { dport != (*rp)->fl.fl_ip_dport) {
...@@ -180,6 +180,7 @@ static inline int ip_route_newports(struct rtable **rp, u16 sport, u16 dport, ...@@ -180,6 +180,7 @@ static inline int ip_route_newports(struct rtable **rp, u16 sport, u16 dport,
memcpy(&fl, &(*rp)->fl, sizeof(fl)); memcpy(&fl, &(*rp)->fl, sizeof(fl));
fl.fl_ip_sport = sport; fl.fl_ip_sport = sport;
fl.fl_ip_dport = dport; fl.fl_ip_dport = dport;
fl.proto = protocol;
ip_rt_put(*rp); ip_rt_put(*rp);
*rp = NULL; *rp = NULL;
return ip_route_output_flow(rp, &fl, sk, 0); return ip_route_output_flow(rp, &fl, sk, 0);
......
...@@ -119,7 +119,8 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) ...@@ -119,7 +119,8 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
if (err != 0) if (err != 0)
goto failure; goto failure;
err = ip_route_newports(&rt, inet->sport, inet->dport, sk); err = ip_route_newports(&rt, IPPROTO_DCCP, inet->sport, inet->dport,
sk);
if (err != 0) if (err != 0)
goto failure; goto failure;
......
...@@ -236,7 +236,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) ...@@ -236,7 +236,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
if (err) if (err)
goto failure; goto failure;
err = ip_route_newports(&rt, inet->sport, inet->dport, sk); err = ip_route_newports(&rt, IPPROTO_TCP, inet->sport, inet->dport, sk);
if (err) if (err)
goto failure; goto failure;
......
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