From 5cd54324eeeb8ad40870bae3627758b0e7848c3e Mon Sep 17 00:00:00 2001 From: "Bjoern A. Zeeb" Date: Thu, 27 Nov 2008 13:19:42 +0000 Subject: [PATCH] Replace most INP_CHECK_SOCKAF() uses checking if it is an IPv6 socket by comparing a constant inp vflag. This is expected to help to reduce extra locking. Suggested by: rwatson Reviewed by: rwatson MFC after: 6 weeks --- sys/netinet/in_pcb.c | 3 +-- sys/netinet/tcp_output.c | 2 +- sys/netinet/tcp_usrreq.c | 7 ++----- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index f611e73aa478..9ca1edc8cb13 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1254,8 +1254,7 @@ in_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in_addr faddr, return (inp); else if (inp->inp_laddr.s_addr == INADDR_ANY) { #ifdef INET6 - if (INP_CHECK_SOCKAF(inp->inp_socket, - AF_INET6)) + if (inp->inp_vflag & INP_IPV6PROTO) local_wild_mapped = inp; else #endif diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index ab92905a1c29..d93592b439c5 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1172,7 +1172,7 @@ timer: { ip->ip_len = m->m_pkthdr.len; #ifdef INET6 - if (INP_CHECK_SOCKAF(so, AF_INET6)) + if (tp->t_inpcb->inp_vflag & INP_IPV6PROTO) ip->ip_ttl = in6_selecthlim(tp->t_inpcb, NULL); #endif /* INET6 */ /* diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 9661a977b9ab..2ee8aa491e63 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1256,7 +1256,7 @@ tcp_ctloutput(struct socket *so, struct sockopt *sopt) INP_WLOCK(inp); if (sopt->sopt_level != IPPROTO_TCP) { #ifdef INET6 - if (INP_CHECK_SOCKAF(so, AF_INET6)) { + if (inp->inp_vflag & INP_IPV6PROTO) { INP_WUNLOCK(inp); error = ip6_ctloutput(so, sopt); } else { @@ -1436,9 +1436,6 @@ tcp_attach(struct socket *so) struct tcpcb *tp; struct inpcb *inp; int error; -#ifdef INET6 - int isipv6 = INP_CHECK_SOCKAF(so, AF_INET6) != 0; -#endif if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { error = soreserve(so, tcp_sendspace, tcp_recvspace); @@ -1455,7 +1452,7 @@ tcp_attach(struct socket *so) } inp = sotoinpcb(so); #ifdef INET6 - if (isipv6) { + if (inp->inp_vflag & INP_IPV6PROTO) { inp->inp_vflag |= INP_IPV6; inp->in6p_hops = -1; /* use kernel default */ }