const int hash = inet6_ehashfn(daddr, inet->num, saddr, inet->dport, tcp_hashinfo.ehash_size); struct inet_ehash_bucket *head = &tcp_hashinfo.ehash[hash];
unsigned int hash = inet6_ehashfn(daddr, inet->num, saddr, inet->dport); struct inet_ehash_bucket *head = inet_ehash_bucket(&tcp_hashinfo, hash);
static int __tcp_v6_check_established(struct sock *sk, const __u16 lport,				      struct inet_timewait_sock **twp){	struct inet_sock *inet = inet_sk(sk);	const struct ipv6_pinfo *np = inet6_sk(sk);	const struct in6_addr *daddr = &np->rcv_saddr;	const struct in6_addr *saddr = &np->daddr;	const int dif = sk->sk_bound_dev_if;	const u32 ports = INET_COMBINED_PORTS(inet->dport, lport);	const int hash = inet6_ehashfn(daddr, inet->num, saddr, inet->dport,				       tcp_hashinfo.ehash_size);	struct inet_ehash_bucket *head = &tcp_hashinfo.ehash[hash];	struct sock *sk2;	const struct hlist_node *node;	struct inet_timewait_sock *tw;	write_lock(&head->lock);	/* Check TIME-WAIT sockets first. */	sk_for_each(sk2, node, &(head + tcp_hashinfo.ehash_size)->chain) {		const struct tcp6_timewait_sock *tcp6tw = tcp6_twsk(sk2);		tw = inet_twsk(sk2);		if(*((__u32 *)&(tw->tw_dport))	== ports	&&		   sk2->sk_family		== PF_INET6	&&		   ipv6_addr_equal(&tcp6tw->tw_v6_daddr, saddr)	&&		   ipv6_addr_equal(&tcp6tw->tw_v6_rcv_saddr, daddr)	&&		   sk2->sk_bound_dev_if == sk->sk_bound_dev_if) {			const struct tcp_timewait_sock *tcptw = tcp_twsk(sk2);			struct tcp_sock *tp = tcp_sk(sk);			if (tcptw->tw_ts_recent_stamp &&			    (!twp ||			     (sysctl_tcp_tw_reuse &&			      xtime.tv_sec - tcptw->tw_ts_recent_stamp > 1))) {				/* See comment in tcp_ipv4.c */				tp->write_seq = tcptw->tw_snd_nxt + 65535 + 2;				if (!tp->write_seq)					tp->write_seq = 1;				tp->rx_opt.ts_recent	   = tcptw->tw_ts_recent;				tp->rx_opt.ts_recent_stamp = tcptw->tw_ts_recent_stamp;				sock_hold(sk2);				goto unique;			} else				goto not_unique;		}	}	tw = NULL;	/* And established part... */	sk_for_each(sk2, node, &head->chain) {		if (INET6_MATCH(sk2, saddr, daddr, ports, dif))			goto not_unique;	}unique:	BUG_TRAP(sk_unhashed(sk));	__sk_add_node(sk, &head->chain);	sk->sk_hashent = hash;	sock_prot_inc_use(sk->sk_prot);	write_unlock(&head->lock);	if (twp) {		*twp = tw;		NET_INC_STATS_BH(LINUX_MIB_TIMEWAITRECYCLED);	} else if (tw) {		/* Silly. Should hash-dance instead... */		inet_twsk_deschedule(tw, &tcp_death_row);		NET_INC_STATS_BH(LINUX_MIB_TIMEWAITRECYCLED);		inet_twsk_put(tw);	}	return 0;not_unique:	write_unlock(&head->lock);	return -EADDRNOTAVAIL;}