Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Oct 2019 08:15:40 +0000 (UTC)
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r354017 - head/sys/netinet6
Message-ID:  <201910240815.x9O8FeiG090474@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bz
Date: Thu Oct 24 08:15:40 2019
New Revision: 354017
URL: https://svnweb.freebsd.org/changeset/base/354017

Log:
  frag6: small improvements
  
  Rather than walking the mbuf chain manually use m_last() which doing
  exactly that for us.
  Defer initializing srcifp for longer as there are multiple exit paths
  out of the function which do not need it set.  Initialize before taking
  the lock though.
  Rename the mtx lock to match the type better.
  
  MFC after:	3 weeks
  Sponsored by:	Netflix

Modified:
  head/sys/netinet6/frag6.c

Modified: head/sys/netinet6/frag6.c
==============================================================================
--- head/sys/netinet6/frag6.c	Thu Oct 24 07:53:10 2019	(r354016)
+++ head/sys/netinet6/frag6.c	Thu Oct 24 08:15:40 2019	(r354017)
@@ -399,9 +399,6 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
 		return (IPPROTO_DONE);
 #endif
 
-	/* Store receive network interface pointer for later. */
-	srcifp = m->m_pkthdr.rcvif;
-
 	dstifp = NULL;
 	/* Find the destination interface of the packet. */
 	ia6 = in6ifa_ifwithaddr(&ip6->ip6_dst, 0 /* XXX */);
@@ -461,6 +458,9 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
 		return (IPPROTO_DONE);
 	}
 
+	/* Store receive network interface pointer for later. */
+	srcifp = m->m_pkthdr.rcvif;
+
 	/* Generate a hash value for fragment bucket selection. */
 	hashkeyp = hashkey;
 	memcpy(hashkeyp, &ip6->ip6_src, sizeof(struct in6_addr));
@@ -739,8 +739,7 @@ postinsert:
 		    af6->ip6af_m->m_pkthdr.csum_data;
 
 		TAILQ_REMOVE(&q6->ip6q_frags, af6, ip6af_tq);
-		while (t->m_next)
-			t = t->m_next;
+		t = m_last(t);
 		m_adj(af6->ip6af_m, af6->ip6af_offset);
 		m_demote_pkthdr(af6->ip6af_m);
 		m_cat(t, af6->ip6af_m);
@@ -930,7 +929,7 @@ frag6_init(void)
 	frag6_set_bucketsize();
 	for (bucket = 0; bucket < IP6REASS_NHASH; bucket++) {
 		TAILQ_INIT(IP6QB_HEAD(bucket));
-		mtx_init(&V_ip6qb[bucket].lock, "ip6qlock", NULL, MTX_DEF);
+		mtx_init(&V_ip6qb[bucket].lock, "ip6qb", NULL, MTX_DEF);
 		V_ip6qb[bucket].count = 0;
 	}
 	V_ip6qb_hashseed = arc4random();



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