ipv4: Sanitize and simplify ip_route_{connect,newports}()
authorDavid S. Miller <davem@davemloft.net>
Tue, 26 Apr 2011 20:28:44 +0000 (13:28 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 27 Apr 2011 20:59:04 +0000 (13:59 -0700)
commit2d7192d6cbab20e153c47fa1559ffd41ceef0e79
treeaac4c4132f5b4a173ad8f8d0bf24427e039bbc89
parent15ecd039b7182d725f4294e01f2fb12c3a88db17
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>
include/net/route.h
net/dccp/ipv4.c
net/ipv4/af_inet.c
net/ipv4/datagram.c
net/ipv4/tcp_ipv4.c
net/l2tp/l2tp_ip.c