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
This commit is contained in:
Bjoern A. Zeeb 2008-11-27 13:19:42 +00:00
parent 6aee2fc550
commit 5cd54324ee
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=185371
3 changed files with 4 additions and 8 deletions

View File

@ -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

View File

@ -1172,7 +1172,7 @@ tcp_output(struct tcpcb *tp)
{
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 */
/*

View File

@ -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 */
}