mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-21 22:21:21 +00:00
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:
parent
05dbc7b594
commit
efe4208f47
35 changed files with 213 additions and 288 deletions
|
@ -77,20 +77,19 @@ static struct sock *__raw_v6_lookup(struct net *net, struct sock *sk,
|
|||
|
||||
sk_for_each_from(sk)
|
||||
if (inet_sk(sk)->inet_num == num) {
|
||||
struct ipv6_pinfo *np = inet6_sk(sk);
|
||||
|
||||
if (!net_eq(sock_net(sk), net))
|
||||
continue;
|
||||
|
||||
if (!ipv6_addr_any(&np->daddr) &&
|
||||
!ipv6_addr_equal(&np->daddr, rmt_addr))
|
||||
if (!ipv6_addr_any(&sk->sk_v6_daddr) &&
|
||||
!ipv6_addr_equal(&sk->sk_v6_daddr, rmt_addr))
|
||||
continue;
|
||||
|
||||
if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif)
|
||||
continue;
|
||||
|
||||
if (!ipv6_addr_any(&np->rcv_saddr)) {
|
||||
if (ipv6_addr_equal(&np->rcv_saddr, loc_addr))
|
||||
if (!ipv6_addr_any(&sk->sk_v6_rcv_saddr)) {
|
||||
if (ipv6_addr_equal(&sk->sk_v6_rcv_saddr, loc_addr))
|
||||
goto found;
|
||||
if (is_multicast &&
|
||||
inet6_mc_check(sk, loc_addr, rmt_addr))
|
||||
|
@ -302,7 +301,7 @@ static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
|
|||
}
|
||||
|
||||
inet->inet_rcv_saddr = inet->inet_saddr = v4addr;
|
||||
np->rcv_saddr = addr->sin6_addr;
|
||||
sk->sk_v6_rcv_saddr = addr->sin6_addr;
|
||||
if (!(addr_type & IPV6_ADDR_MULTICAST))
|
||||
np->saddr = addr->sin6_addr;
|
||||
err = 0;
|
||||
|
@ -804,8 +803,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
|
|||
* sk->sk_dst_cache.
|
||||
*/
|
||||
if (sk->sk_state == TCP_ESTABLISHED &&
|
||||
ipv6_addr_equal(daddr, &np->daddr))
|
||||
daddr = &np->daddr;
|
||||
ipv6_addr_equal(daddr, &sk->sk_v6_daddr))
|
||||
daddr = &sk->sk_v6_daddr;
|
||||
|
||||
if (addr_len >= sizeof(struct sockaddr_in6) &&
|
||||
sin6->sin6_scope_id &&
|
||||
|
@ -816,7 +815,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
|
|||
return -EDESTADDRREQ;
|
||||
|
||||
proto = inet->inet_num;
|
||||
daddr = &np->daddr;
|
||||
daddr = &sk->sk_v6_daddr;
|
||||
fl6.flowlabel = np->flow_label;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue