mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 01:21:58 +00:00
ipv4: Sanitize and simplify ip_route_{connect,newports}()
These functions are used together as a unit for route resolution during connect(). They address the chicken-and-egg problem that exists when ports need to be allocated during connect() processing, yet such port allocations require addressing information from the routing code. It's currently more heavy handed than it needs to be, and in particular we allocate and initialize a flow object twice. Let the callers provide the on-stack flow object. That way we only need to initialize it once in the ip_route_connect() call. Later, if ip_route_newports() needs to do anything, it re-uses that flow object as-is except for the ports which it updates before the route re-lookup. Also, describe why this set of facilities are needed and how it works in a big comment. Signed-off-by: David S. Miller <davem@davemloft.net> Reviewed-by: Eric Dumazet <eric.dumazet@gmail.com>
This commit is contained in:
parent
15ecd039b7
commit
2d7192d6cb
6 changed files with 81 additions and 55 deletions
|
@ -1103,6 +1103,7 @@ static int inet_sk_reselect_saddr(struct sock *sk)
|
|||
struct inet_sock *inet = inet_sk(sk);
|
||||
__be32 old_saddr = inet->inet_saddr;
|
||||
__be32 daddr = inet->inet_daddr;
|
||||
struct flowi4 fl4;
|
||||
struct rtable *rt;
|
||||
__be32 new_saddr;
|
||||
|
||||
|
@ -1110,7 +1111,7 @@ static int inet_sk_reselect_saddr(struct sock *sk)
|
|||
daddr = inet->opt->faddr;
|
||||
|
||||
/* Query new route. */
|
||||
rt = ip_route_connect(daddr, 0, RT_CONN_FLAGS(sk),
|
||||
rt = ip_route_connect(&fl4, daddr, 0, RT_CONN_FLAGS(sk),
|
||||
sk->sk_bound_dev_if, sk->sk_protocol,
|
||||
inet->inet_sport, inet->inet_dport, sk, false);
|
||||
if (IS_ERR(rt))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue