Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Mar 2009 16:09:05 +0000 (UTC)
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r189966 - in stable/7/sys: . contrib/pf dev/cxgb dev/cxgb/ulp/tom netinet netinet6
Message-ID:  <200903181609.n2IG95Jf030784@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bz
Date: Wed Mar 18 16:09:05 2009
New Revision: 189966
URL: http://svn.freebsd.org/changeset/base/189966

Log:
  MFC r186222:
  
    Use inc_flags instead of the inc_isipv6 alias which so far
    had been the only flag with random usage patterns.
    Switch inc_flags to be used as a real bit field by using
    INC_ISIPV6 with bitops to check for the 'isipv6' condition.
  
    While here fix a place or two where in case of v4 inc_flags
    were not properly initialized before.[1]
  
    Found by:     rwatson during review [1]

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
  stable/7/sys/netinet/in_pcb.c
  stable/7/sys/netinet/in_pcb.h
  stable/7/sys/netinet/tcp_hostcache.c
  stable/7/sys/netinet/tcp_input.c
  stable/7/sys/netinet/tcp_subr.c
  stable/7/sys/netinet/tcp_syncache.c
  stable/7/sys/netinet/tcp_timewait.c
  stable/7/sys/netinet/tcp_usrreq.c
  stable/7/sys/netinet6/icmp6.c
  stable/7/sys/netinet6/ip6_output.c

Modified: stable/7/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
==============================================================================
--- stable/7/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c	Wed Mar 18 14:43:56 2009	(r189965)
+++ stable/7/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c	Wed Mar 18 16:09:05 2009	(r189966)
@@ -3270,8 +3270,6 @@ syncache_add_accept_req(struct cpl_pass_
 
 	toep->tp_iss = toep->tp_delack_seq = toep->tp_rcv_wup = toep->tp_copied_seq = rcv_isn + 1;
 
-	
-	inc.inc_isipv6 = 0;
 	inc.inc_len = 0;
 	inc.inc_faddr.s_addr = req->peer_ip;
 	inc.inc_laddr.s_addr = req->local_ip;
@@ -3611,7 +3609,6 @@ syncache_expand_establish_req(struct cpl
 	th.th_seq = req->rcv_isn;
 	th.th_flags = TH_ACK;
 	
-	inc.inc_isipv6 = 0;
 	inc.inc_len = 0;
 	inc.inc_faddr.s_addr = req->peer_ip;
 	inc.inc_laddr.s_addr = req->local_ip;

Modified: stable/7/sys/netinet/in_pcb.c
==============================================================================
--- stable/7/sys/netinet/in_pcb.c	Wed Mar 18 14:43:56 2009	(r189965)
+++ stable/7/sys/netinet/in_pcb.c	Wed Mar 18 16:09:05 2009	(r189966)
@@ -1622,7 +1622,7 @@ db_print_inconninfo(struct in_conninfo *
 	indent += 2;
 
 #ifdef INET6
-	if (inc->inc_flags == 1) {
+	if (inc->inc_flags & INC_ISIPV6) {
 		/* IPv6. */
 		ip6_sprintf(laddr_str, &inc->inc6_laddr);
 		ip6_sprintf(faddr_str, &inc->inc6_faddr);

Modified: stable/7/sys/netinet/in_pcb.h
==============================================================================
--- stable/7/sys/netinet/in_pcb.h	Wed Mar 18 14:43:56 2009	(r189965)
+++ stable/7/sys/netinet/in_pcb.h	Wed Mar 18 16:09:05 2009	(r189966)
@@ -106,6 +106,12 @@ struct in_conninfo {
 	/* protocol dependent part */
 	struct	in_endpoints inc_ie;
 };
+
+/*
+ * Flags for inc_flags.
+ */
+#define	INC_ISIPV6	0x01
+
 #define inc_isipv6	inc_flags	/* temp compatability */
 #define	inc_fport	inc_ie.ie_fport
 #define	inc_lport	inc_ie.ie_lport

Modified: stable/7/sys/netinet/tcp_hostcache.c
==============================================================================
--- stable/7/sys/netinet/tcp_hostcache.c	Wed Mar 18 14:43:56 2009	(r189965)
+++ stable/7/sys/netinet/tcp_hostcache.c	Wed Mar 18 16:09:05 2009	(r189966)
@@ -276,7 +276,7 @@ tcp_hc_lookup(struct in_conninfo *inc)
 	/*
 	 * Hash the foreign ip address.
 	 */
-	if (inc->inc_isipv6)
+	if (inc->inc_flags & INC_ISIPV6)
 		hash = HOSTCACHE_HASH6(&inc->inc6_faddr);
 	else
 		hash = HOSTCACHE_HASH(&inc->inc_faddr);
@@ -294,7 +294,7 @@ tcp_hc_lookup(struct in_conninfo *inc)
 	 * Iterate through entries in bucket row looking for a match.
 	 */
 	TAILQ_FOREACH(hc_entry, &hc_head->hch_bucket, rmx_q) {
-		if (inc->inc_isipv6) {
+		if (inc->inc_flags & INC_ISIPV6) {
 			if (memcmp(&inc->inc6_faddr, &hc_entry->ip6,
 			    sizeof(inc->inc6_faddr)) == 0)
 				return hc_entry;
@@ -331,7 +331,7 @@ tcp_hc_insert(struct in_conninfo *inc)
 	/*
 	 * Hash the foreign ip address.
 	 */
-	if (inc->inc_isipv6)
+	if (inc->inc_flags & INC_ISIPV6)
 		hash = HOSTCACHE_HASH6(&inc->inc6_faddr);
 	else
 		hash = HOSTCACHE_HASH(&inc->inc_faddr);
@@ -386,7 +386,7 @@ tcp_hc_insert(struct in_conninfo *inc)
 	 * Initialize basic information of hostcache entry.
 	 */
 	bzero(hc_entry, sizeof(*hc_entry));
-	if (inc->inc_isipv6)
+	if (inc->inc_flags & INC_ISIPV6)
 		bcopy(&inc->inc6_faddr, &hc_entry->ip6, sizeof(hc_entry->ip6));
 	else
 		hc_entry->ip4 = inc->inc_faddr;

Modified: stable/7/sys/netinet/tcp_input.c
==============================================================================
--- stable/7/sys/netinet/tcp_input.c	Wed Mar 18 14:43:56 2009	(r189965)
+++ stable/7/sys/netinet/tcp_input.c	Wed Mar 18 16:09:05 2009	(r189966)
@@ -564,9 +564,9 @@ findpcb:
 		    "tp not listening", __func__));
 
 		bzero(&inc, sizeof(inc));
-		inc.inc_isipv6 = isipv6;
 #ifdef INET6
 		if (isipv6) {
+			inc.inc_flags |= INC_ISIPV6;
 			inc.inc6_faddr = ip6->ip6_src;
 			inc.inc6_laddr = ip6->ip6_dst;
 		} else
@@ -2974,14 +2974,11 @@ tcp_mssopt(struct in_conninfo *inc)
 	u_long maxmtu = 0;
 	u_long thcmtu = 0;
 	size_t min_protoh;
-#ifdef INET6
-	int isipv6 = inc->inc_isipv6 ? 1 : 0;
-#endif
 
 	KASSERT(inc != NULL, ("tcp_mssopt with NULL in_conninfo pointer"));
 
 #ifdef INET6
-	if (isipv6) {
+	if (inc->inc_flags & INC_ISIPV6) {
 		mss = tcp_v6mssdflt;
 		maxmtu = tcp_maxmtu6(inc, NULL);
 		thcmtu = tcp_hc_getmtu(inc); /* IPv4 and IPv6 */

Modified: stable/7/sys/netinet/tcp_subr.c
==============================================================================
--- stable/7/sys/netinet/tcp_subr.c	Wed Mar 18 14:43:56 2009	(r189965)
+++ stable/7/sys/netinet/tcp_subr.c	Wed Mar 18 16:09:05 2009	(r189966)
@@ -1191,7 +1191,6 @@ tcp_ctlinput(int cmd, struct sockaddr *s
 					     * value (if given) and then notify.
 					     */
 					    bzero(&inc, sizeof(inc));
-					    inc.inc_flags = 0;	/* IPv4 */
 					    inc.inc_faddr = faddr;
 					    inc.inc_fibnum =
 						inp->inp_inc.inc_fibnum;
@@ -1228,13 +1227,11 @@ tcp_ctlinput(int cmd, struct sockaddr *s
 			if (inp != NULL)
 				INP_WUNLOCK(inp);
 		} else {
+			bzero(&inc, sizeof(inc));
 			inc.inc_fport = th->th_dport;
 			inc.inc_lport = th->th_sport;
 			inc.inc_faddr = faddr;
 			inc.inc_laddr = ip->ip_src;
-#ifdef INET6
-			inc.inc_isipv6 = 0;
-#endif
 			syncache_unreach(&inc, th);
 		}
 		INP_INFO_WUNLOCK(&tcbinfo);
@@ -1303,11 +1300,12 @@ tcp6_ctlinput(int cmd, struct sockaddr *
 		    (struct sockaddr *)ip6cp->ip6c_src,
 		    th.th_sport, cmd, NULL, notify);
 
+		bzero(&inc, sizeof(inc));
 		inc.inc_fport = th.th_dport;
 		inc.inc_lport = th.th_sport;
 		inc.inc6_faddr = ((struct sockaddr_in6 *)sa)->sin6_addr;
 		inc.inc6_laddr = ip6cp->ip6c_src->sin6_addr;
-		inc.inc_isipv6 = 1;
+		inc.inc_flags |= INC_ISIPV6;
 		INP_INFO_WLOCK(&tcbinfo);
 		syncache_unreach(&inc, &th);
 		INP_INFO_WUNLOCK(&tcbinfo);
@@ -2188,7 +2186,7 @@ tcp_log_addrs(struct in_conninfo *inc, s
 	strcat(s, "TCP: [");
 	sp = s + strlen(s);
 
-	if (inc && inc->inc_isipv6 == 0) {
+	if (inc && ((inc->inc_flags & INC_ISIPV6) == 0)) {
 		inet_ntoa_r(inc->inc_faddr, sp);
 		sp = s + strlen(s);
 		sprintf(sp, "]:%i to [", ntohs(inc->inc_fport));

Modified: stable/7/sys/netinet/tcp_syncache.c
==============================================================================
--- stable/7/sys/netinet/tcp_syncache.c	Wed Mar 18 14:43:56 2009	(r189965)
+++ stable/7/sys/netinet/tcp_syncache.c	Wed Mar 18 16:09:05 2009	(r189966)
@@ -474,7 +474,7 @@ syncache_lookup(struct in_conninfo *inc,
 	struct syncache_head *sch;
 
 #ifdef INET6
-	if (inc->inc_isipv6) {
+	if (inc->inc_flags & INC_ISIPV6) {
 		sch = &tcp_syncache.hashbase[
 		    SYNCACHE_HASH6(inc, tcp_syncache.hashmask)];
 		*schp = sch;
@@ -498,7 +498,7 @@ syncache_lookup(struct in_conninfo *inc,
 		/* Circle through bucket row to find matching entry. */
 		TAILQ_FOREACH(sc, &sch->sch_bucket, sc_hash) {
 #ifdef INET6
-			if (sc->sc_inc.inc_isipv6)
+			if (sc->sc_inc.inc_flags & INC_ISIPV6)
 				continue;
 #endif
 			if (ENDPTS_EQ(&inc->inc_ie, &sc->sc_inc.inc_ie))
@@ -683,9 +683,9 @@ syncache_socket(struct syncache *sc, str
 	INP_WLOCK(inp);
 
 	/* Insert new socket into PCB hash list. */
-	inp->inp_inc.inc_isipv6 = sc->sc_inc.inc_isipv6;
+	inp->inp_inc.inc_flags = sc->sc_inc.inc_flags;
 #ifdef INET6
-	if (sc->sc_inc.inc_isipv6) {
+	if (sc->sc_inc.inc_flags & INC_ISIPV6) {
 		inp->in6p_laddr = sc->sc_inc.inc6_laddr;
 	} else {
 		inp->inp_vflag &= ~INP_IPV6;
@@ -702,7 +702,7 @@ syncache_socket(struct syncache *sc, str
 		 * put the PCB on the hash lists.
 		 */
 #ifdef INET6
-		if (sc->sc_inc.inc_isipv6)
+		if (sc->sc_inc.inc_flags & INC_ISIPV6)
 			inp->in6p_laddr = in6addr_any;
 		else
 #endif
@@ -716,7 +716,7 @@ syncache_socket(struct syncache *sc, str
 		printf("syncache_socket: could not copy policy\n");
 #endif
 #ifdef INET6
-	if (sc->sc_inc.inc_isipv6) {
+	if (sc->sc_inc.inc_flags & INC_ISIPV6) {
 		struct inpcb *oinp = sotoinpcb(lso);
 		struct in6_addr laddr6;
 		struct sockaddr_in6 sin6;
@@ -1043,7 +1043,7 @@ _syncache_add(struct in_conninfo *inc, s
 	cred = crhold(so->so_cred);
 
 #ifdef INET6
-	if (inc->inc_isipv6 &&
+	if ((inc->inc_flags & INC_ISIPV6) &&
 	    (inp->in6p_flags & IN6P_AUTOFLOWLABEL))
 		autoflowlabel = 1;
 #endif
@@ -1072,7 +1072,7 @@ _syncache_add(struct in_conninfo *inc, s
 	 * Remember the IP options, if any.
 	 */
 #ifdef INET6
-	if (!inc->inc_isipv6)
+	if (!(inc->inc_flags & INC_ISIPV6))
 #endif
 		ipopts = (m) ? ip_srcroute(m) : NULL;
 
@@ -1173,10 +1173,11 @@ _syncache_add(struct in_conninfo *inc, s
 	sc->sc_cred = cred;
 	cred = NULL;
 	sc->sc_ipopts = ipopts;
+	/* XXX-BZ this fib assignment is just useless. */
 	sc->sc_inc.inc_fibnum = inp->inp_inc.inc_fibnum;
 	bcopy(inc, &sc->sc_inc, sizeof(struct in_conninfo));
 #ifdef INET6
-	if (!inc->inc_isipv6)
+	if (!(inc->inc_flags & INC_ISIPV6))
 #endif
 	{
 		sc->sc_ip_tos = ip_tos;
@@ -1316,7 +1317,7 @@ syncache_respond(struct syncache *sc)
 
 	hlen =
 #ifdef INET6
-	       (sc->sc_inc.inc_isipv6) ? sizeof(struct ip6_hdr) :
+	       (sc->sc_inc.inc_flags & INC_ISIPV6) ? sizeof(struct ip6_hdr) :
 #endif
 		sizeof(struct ip);
 	tlen = hlen + sizeof(struct tcphdr);
@@ -1343,7 +1344,7 @@ syncache_respond(struct syncache *sc)
 	m->m_pkthdr.rcvif = NULL;
 
 #ifdef INET6
-	if (sc->sc_inc.inc_isipv6) {
+	if (sc->sc_inc.inc_flags & INC_ISIPV6) {
 		ip6 = mtod(m, struct ip6_hdr *);
 		ip6->ip6_vfc = IPV6_VERSION;
 		ip6->ip6_nxt = IPPROTO_TCP;
@@ -1429,7 +1430,7 @@ syncache_respond(struct syncache *sc)
 			    to.to_signature, IPSEC_DIR_OUTBOUND);
 #endif
 #ifdef INET6
-		if (sc->sc_inc.inc_isipv6)
+		if (sc->sc_inc.inc_flags & INC_ISIPV6)
 			ip6->ip6_plen = htons(ntohs(ip6->ip6_plen) + optlen);
 		else
 #endif
@@ -1438,7 +1439,7 @@ syncache_respond(struct syncache *sc)
 		optlen = 0;
 
 #ifdef INET6
-	if (sc->sc_inc.inc_isipv6) {
+	if (sc->sc_inc.inc_flags & INC_ISIPV6) {
 		th->th_sum = 0;
 		th->th_sum = in6_cksum(m, IPPROTO_TCP, hlen,
 				       tlen + optlen - hlen);
@@ -1691,7 +1692,7 @@ syncookie_lookup(struct in_conninfo *inc
 	sc->sc_iss = ack;
 
 #ifdef INET6
-	if (inc->inc_isipv6) {
+	if (inc->inc_flags & INC_ISIPV6) {
 		if (sotoinpcb(so)->in6p_flags & IN6P_AUTOFLOWLABEL)
 			sc->sc_flowlabel = md5_buffer[1] & IPV6_FLOWLABEL_MASK;
 	} else
@@ -1779,7 +1780,7 @@ syncache_pcblist(struct sysctl_req *req,
 				continue;
 			bzero(&xt, sizeof(xt));
 			xt.xt_len = sizeof(xt);
-			if (sc->sc_inc.inc_isipv6)
+			if (sc->sc_inc.inc_flags & INC_ISIPV6)
 				xt.xt_inp.inp_vflag = INP_IPV6;
 			else
 				xt.xt_inp.inp_vflag = INP_IPV4;

Modified: stable/7/sys/netinet/tcp_timewait.c
==============================================================================
--- stable/7/sys/netinet/tcp_timewait.c	Wed Mar 18 14:43:56 2009	(r189965)
+++ stable/7/sys/netinet/tcp_timewait.c	Wed Mar 18 16:09:05 2009	(r189966)
@@ -529,7 +529,7 @@ tcp_twrespond(struct tcptw *tw, int flag
 	struct tcpopt to;
 #ifdef INET6
 	struct ip6_hdr *ip6 = NULL;
-	int isipv6 = inp->inp_inc.inc_isipv6;
+	int isipv6 = inp->inp_inc.inc_flags & INC_ISIPV6;
 #endif
 
 	INP_WLOCK_ASSERT(inp);

Modified: stable/7/sys/netinet/tcp_usrreq.c
==============================================================================
--- stable/7/sys/netinet/tcp_usrreq.c	Wed Mar 18 14:43:56 2009	(r189965)
+++ stable/7/sys/netinet/tcp_usrreq.c	Wed Mar 18 16:09:05 2009	(r189966)
@@ -538,7 +538,7 @@ tcp6_usr_connect(struct socket *so, stru
 	}
 	inp->inp_vflag &= ~INP_IPV4;
 	inp->inp_vflag |= INP_IPV6;
-	inp->inp_inc.inc_isipv6 = 1;
+	inp->inp_inc.inc_flags |= INC_ISIPV6;
 	if ((error = prison_remote_ip6(td->td_ucred, &sin6p->sin6_addr)) != 0)
 		goto out;
 	if ((error = tcp6_connect(tp, nam, td)) != 0)

Modified: stable/7/sys/netinet6/icmp6.c
==============================================================================
--- stable/7/sys/netinet6/icmp6.c	Wed Mar 18 14:43:56 2009	(r189965)
+++ stable/7/sys/netinet6/icmp6.c	Wed Mar 18 16:09:05 2009	(r189966)
@@ -1129,7 +1129,7 @@ icmp6_mtudisc_update(struct ip6ctlparam 
 		mtu = IPV6_MMTU - 8;
 
 	bzero(&inc, sizeof(inc));
-	inc.inc_flags = 1; /* IPv6 */
+	inc.inc_flags |= INC_ISIPV6;
 	inc.inc6_faddr = *dst;
 	if (in6_setscope(&inc.inc6_faddr, m->m_pkthdr.rcvif, NULL))
 		return;

Modified: stable/7/sys/netinet6/ip6_output.c
==============================================================================
--- stable/7/sys/netinet6/ip6_output.c	Wed Mar 18 14:43:56 2009	(r189965)
+++ stable/7/sys/netinet6/ip6_output.c	Wed Mar 18 16:09:05 2009	(r189966)
@@ -1314,7 +1314,7 @@ ip6_getpmtu(struct route_in6 *ro_pmtu, s
 		struct in_conninfo inc;
 
 		bzero(&inc, sizeof(inc));
-		inc.inc_flags = 1; /* IPv6 */
+		inc.inc_flags |= INC_ISIPV6;
 		inc.inc6_faddr = *dst;
 
 		if (ifp == NULL)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903181609.n2IG95Jf030784>