Skip to content

Commit

Permalink
[IPV4]: Always set fl.proto in ip_route_newports
Browse files Browse the repository at this point in the history
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: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Patrick McHardy authored and David S. Miller committed Feb 1, 2006
1 parent 7fb76aa commit 5d39a79
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions include/net/route.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ static inline int ip_route_connect(struct rtable **rp, u32 dst,
return ip_route_output_flow(rp, &fl, sk, 0);
}

static inline int ip_route_newports(struct rtable **rp, u16 sport, u16 dport,
struct sock *sk)
static inline int ip_route_newports(struct rtable **rp, u8 protocol,
u16 sport, u16 dport, struct sock *sk)
{
if (sport != (*rp)->fl.fl_ip_sport ||
dport != (*rp)->fl.fl_ip_dport) {
Expand All @@ -180,6 +180,7 @@ static inline int ip_route_newports(struct rtable **rp, u16 sport, u16 dport,
memcpy(&fl, &(*rp)->fl, sizeof(fl));
fl.fl_ip_sport = sport;
fl.fl_ip_dport = dport;
fl.proto = protocol;
ip_rt_put(*rp);
*rp = NULL;
return ip_route_output_flow(rp, &fl, sk, 0);
Expand Down
3 changes: 2 additions & 1 deletion net/dccp/ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
if (err != 0)
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)
goto failure;

Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/tcp_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
if (err)
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)
goto failure;

Expand Down

0 comments on commit 5d39a79

Please sign in to comment.