ipv6: make lookups simpler and faster
TCP listener refactoring, part 4 : To speed up inet lookups, we moved IPv4 addresses from inet to struct sock_common Now is time to do the same for IPv6, because it permits us to have fast lookups for all kind of sockets, including upcoming SYN_RECV. Getting IPv6 addresses in TCP lookups currently requires two extra cache lines, plus a dereference (and memory stall). inet6_sk(sk) does the dereference of inet_sk(__sk)->pinet6 This patch is way bigger than its IPv4 counter part, because for IPv4, we could add aliases (inet_daddr, inet_rcv_saddr), while on IPv6, it's not doable easily. inet6_sk(sk)->daddr becomes sk->sk_v6_daddr inet6_sk(sk)->rcv_saddr becomes sk->sk_v6_rcv_saddr And timewait socket also have tw->tw_v6_daddr & tw->tw_v6_rcv_saddr at the same offset. We get rid of INET6_TW_MATCH() as INET6_MATCH() is now the generic macro. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
05dbc7b594
commit
efe4208f47
@@ -165,11 +165,10 @@ EXPORT_SYMBOL_GPL(inet6_csk_reqsk_queue_hash_add);
|
||||
|
||||
void inet6_csk_addr2sockaddr(struct sock *sk, struct sockaddr * uaddr)
|
||||
{
|
||||
struct ipv6_pinfo *np = inet6_sk(sk);
|
||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) uaddr;
|
||||
|
||||
sin6->sin6_family = AF_INET6;
|
||||
sin6->sin6_addr = np->daddr;
|
||||
sin6->sin6_addr = sk->sk_v6_daddr;
|
||||
sin6->sin6_port = inet_sk(sk)->inet_dport;
|
||||
/* We do not store received flowlabel for TCP */
|
||||
sin6->sin6_flowinfo = 0;
|
||||
@@ -203,7 +202,7 @@ static struct dst_entry *inet6_csk_route_socket(struct sock *sk,
|
||||
|
||||
memset(fl6, 0, sizeof(*fl6));
|
||||
fl6->flowi6_proto = sk->sk_protocol;
|
||||
fl6->daddr = np->daddr;
|
||||
fl6->daddr = sk->sk_v6_daddr;
|
||||
fl6->saddr = np->saddr;
|
||||
fl6->flowlabel = np->flow_label;
|
||||
IP6_ECN_flow_xmit(sk, fl6->flowlabel);
|
||||
@@ -245,7 +244,7 @@ int inet6_csk_xmit(struct sk_buff *skb, struct flowi *fl_unused)
|
||||
skb_dst_set_noref(skb, dst);
|
||||
|
||||
/* Restore final destination back after routing done */
|
||||
fl6.daddr = np->daddr;
|
||||
fl6.daddr = sk->sk_v6_daddr;
|
||||
|
||||
res = ip6_xmit(sk, skb, &fl6, np->opt, np->tclass);
|
||||
rcu_read_unlock();
|
||||
|
Reference in New Issue
Block a user