From 038bfe209eeb1f951b217069a584edbcc92d0f2c Mon Sep 17 00:00:00 2001 From: rwatson Date: Sun, 15 Mar 2009 09:58:31 +0000 Subject: Correct a number of evolved problems with inp_vflag and inp_flags: certain flags that should have been in inp_flags ended up in inp_vflag, meaning that they were inconsistently locked, and in one case, interpreted. Move the following flags from inp_vflag to gaps in the inp_flags space (and clean up the inp_flags constants to make gaps more obvious to future takers): INP_TIMEWAIT INP_SOCKREF INP_ONESBCAST INP_DROPPED Some aspects of this change have no effect on kernel ABI at all, as these are UDP/TCP/IP-internal uses; however, netstat and sockstat detect INP_TIMEWAIT when listing TCP sockets, so any MFC will need to take this into account. MFC after: 1 week (or after dependencies are MFC'd) Reviewed by: bz --- sys/netinet/tcp_subr.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'sys/netinet/tcp_subr.c') diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 11f4a81..cabdbad 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -881,10 +881,10 @@ tcp_close(struct tcpcb *tp) KASSERT(inp->inp_socket != NULL, ("tcp_close: inp_socket NULL")); so = inp->inp_socket; soisdisconnected(so); - if (inp->inp_vflag & INP_SOCKREF) { + if (inp->inp_flags & INP_SOCKREF) { KASSERT(so->so_state & SS_PROTOREF, ("tcp_close: !SS_PROTOREF")); - inp->inp_vflag &= ~INP_SOCKREF; + inp->inp_flags &= ~INP_SOCKREF; INP_WUNLOCK(inp); ACCEPT_LOCK(); SOCK_LOCK(so); @@ -921,7 +921,7 @@ tcp_drain(void) */ INP_INFO_RLOCK(&V_tcbinfo); LIST_FOREACH(inpb, V_tcbinfo.ipi_listhead, inp_list) { - if (inpb->inp_vflag & INP_TIMEWAIT) + if (inpb->inp_flags & INP_TIMEWAIT) continue; INP_WLOCK(inpb); if ((tcpb = intotcpcb(inpb)) != NULL) { @@ -962,8 +962,8 @@ tcp_notify(struct inpcb *inp, int error) INP_INFO_WLOCK_ASSERT(&V_tcbinfo); INP_WLOCK_ASSERT(inp); - if ((inp->inp_vflag & INP_TIMEWAIT) || - (inp->inp_vflag & INP_DROPPED)) + if ((inp->inp_flags & INP_TIMEWAIT) || + (inp->inp_flags & INP_DROPPED)) return (inp); tp = intotcpcb(inp); @@ -1063,7 +1063,7 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS) * TCP state changes, is not quite right, but for * now, better than nothing. */ - if (inp->inp_vflag & INP_TIMEWAIT) { + if (inp->inp_flags & INP_TIMEWAIT) { if (intotw(inp) != NULL) error = cr_cansee(req->td->td_ucred, intotw(inp)->tw_cred); @@ -1094,7 +1094,7 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS) inp_ppcb = inp->inp_ppcb; if (inp_ppcb == NULL) bzero((char *) &xt.xt_tp, sizeof xt.xt_tp); - else if (inp->inp_vflag & INP_TIMEWAIT) { + else if (inp->inp_flags & INP_TIMEWAIT) { bzero((char *) &xt.xt_tp, sizeof xt.xt_tp); xt.xt_tp.t_state = TCPS_TIME_WAIT; } else @@ -1293,8 +1293,8 @@ tcp_ctlinput(int cmd, struct sockaddr *sa, void *vip) ip->ip_src, th->th_sport, 0, NULL); if (inp != NULL) { INP_WLOCK(inp); - if (!(inp->inp_vflag & INP_TIMEWAIT) && - !(inp->inp_vflag & INP_DROPPED) && + if (!(inp->inp_flags & INP_TIMEWAIT) && + !(inp->inp_flags & INP_DROPPED) && !(inp->inp_socket == NULL)) { icmp_tcp_seq = htonl(th->th_seq); tp = intotcpcb(inp); @@ -1581,8 +1581,8 @@ tcp_drop_syn_sent(struct inpcb *inp, int errno) INP_INFO_WLOCK_ASSERT(&V_tcbinfo); INP_WLOCK_ASSERT(inp); - if ((inp->inp_vflag & INP_TIMEWAIT) || - (inp->inp_vflag & INP_DROPPED)) + if ((inp->inp_flags & INP_TIMEWAIT) || + (inp->inp_flags & INP_DROPPED)) return (inp); tp = intotcpcb(inp); @@ -1610,8 +1610,8 @@ tcp_mtudisc(struct inpcb *inp, int errno) struct socket *so; INP_WLOCK_ASSERT(inp); - if ((inp->inp_vflag & INP_TIMEWAIT) || - (inp->inp_vflag & INP_DROPPED)) + if ((inp->inp_flags & INP_TIMEWAIT) || + (inp->inp_flags & INP_DROPPED)) return (inp); tp = intotcpcb(inp); @@ -2185,7 +2185,7 @@ sysctl_drop(SYSCTL_HANDLER_ARGS) } if (inp != NULL) { INP_WLOCK(inp); - if (inp->inp_vflag & INP_TIMEWAIT) { + if (inp->inp_flags & INP_TIMEWAIT) { /* * XXXRW: There currently exists a state where an * inpcb is present, but its timewait state has been @@ -2197,7 +2197,7 @@ sysctl_drop(SYSCTL_HANDLER_ARGS) tcp_twclose(tw, 0); else INP_WUNLOCK(inp); - } else if (!(inp->inp_vflag & INP_DROPPED) && + } else if (!(inp->inp_flags & INP_DROPPED) && !(inp->inp_socket->so_options & SO_ACCEPTCONN)) { tp = intotcpcb(inp); tp = tcp_drop(tp, ECONNABORTED); -- cgit v1.1