svn commit: r367148 - head/sys/netinet

John Baldwin jhb at FreeBSD.org
Thu Oct 29 22:18:57 UTC 2020


Author: jhb
Date: Thu Oct 29 22:18:56 2020
New Revision: 367148
URL: https://svnweb.freebsd.org/changeset/base/367148

Log:
  Call m_snd_tag_rele() to free send tags.
  
  Send tags are refcounted and if_snd_tag_free() is called by
  m_snd_tag_rele() when the last reference is dropped on a send tag.
  
  Reviewed by:	gallatin, hselasky
  Sponsored by:	Netflix
  Differential Revision:	https://reviews.freebsd.org/D26995

Modified:
  head/sys/netinet/in_pcb.c
  head/sys/netinet/in_pcb.h
  head/sys/netinet/tcp_ratelimit.c

Modified: head/sys/netinet/in_pcb.c
==============================================================================
--- head/sys/netinet/in_pcb.c	Thu Oct 29 22:16:59 2020	(r367147)
+++ head/sys/netinet/in_pcb.c	Thu Oct 29 22:18:56 2020	(r367148)
@@ -3347,20 +3347,10 @@ in_pcbattach_txrtlmt(struct inpcb *inp, struct ifnet *
 }
 
 void
-in_pcbdetach_tag(struct ifnet *ifp, struct m_snd_tag *mst)
+in_pcbdetach_tag(struct m_snd_tag *mst)
 {
-	if (ifp == NULL)
-		return;
 
-	/*
-	 * If the device was detached while we still had reference(s)
-	 * on the ifp, we assume if_snd_tag_free() was replaced with
-	 * stubs.
-	 */
-	ifp->if_snd_tag_free(mst);
-
-	/* release reference count on network interface */
-	if_rele(ifp);
+	m_snd_tag_rele(mst);
 #ifdef INET
 	counter_u64_add(rate_limit_active, -1);
 #endif

Modified: head/sys/netinet/in_pcb.h
==============================================================================
--- head/sys/netinet/in_pcb.h	Thu Oct 29 22:16:59 2020	(r367147)
+++ head/sys/netinet/in_pcb.h	Thu Oct 29 22:18:56 2020	(r367148)
@@ -884,7 +884,7 @@ in_pcboutput_txrtlmt_locked(struct inpcb *, struct ifn
 int	in_pcbattach_txrtlmt(struct inpcb *, struct ifnet *, uint32_t, uint32_t,
 	    uint32_t, struct m_snd_tag **);
 void	in_pcbdetach_txrtlmt(struct inpcb *);
-void    in_pcbdetach_tag(struct ifnet *ifp, struct m_snd_tag *mst);
+void    in_pcbdetach_tag(struct m_snd_tag *);
 int	in_pcbmodify_txrtlmt(struct inpcb *, uint32_t);
 int	in_pcbquery_txrtlmt(struct inpcb *, uint32_t *);
 int	in_pcbquery_txrlevel(struct inpcb *, uint32_t *);

Modified: head/sys/netinet/tcp_ratelimit.c
==============================================================================
--- head/sys/netinet/tcp_ratelimit.c	Thu Oct 29 22:16:59 2020	(r367147)
+++ head/sys/netinet/tcp_ratelimit.c	Thu Oct 29 22:18:56 2020	(r367148)
@@ -1028,7 +1028,7 @@ rt_find_real_interface(struct ifnet *ifp, struct inpcb
 		return (NULL);
 	}
 	tifp = tag->ifp;
-	tifp->if_snd_tag_free(tag);
+	m_snd_tag_rele(tag);
 	return (tifp);
 }
 
@@ -1161,7 +1161,6 @@ static void
 tcp_rl_ifnet_departure(void *arg __unused, struct ifnet *ifp)
 {
 	struct tcp_rate_set *rs, *nrs;
-	struct ifnet *tifp;
 	int i;
 
 	mtx_lock(&rs_mtx);
@@ -1173,8 +1172,7 @@ tcp_rl_ifnet_departure(void *arg __unused, struct ifne
 			rs->rs_flags |= RS_IS_DEAD;
 			for (i = 0; i < rs->rs_rate_cnt; i++) {
 				if (rs->rs_rlt[i].flags & HDWRPACE_TAGPRESENT) {
-					tifp = rs->rs_rlt[i].tag->ifp;
-					in_pcbdetach_tag(tifp, rs->rs_rlt[i].tag);
+					in_pcbdetach_tag(rs->rs_rlt[i].tag);
 					rs->rs_rlt[i].tag = NULL;
 				}
 				rs->rs_rlt[i].flags = HDWRPACE_IFPDEPARTED;
@@ -1191,7 +1189,6 @@ static void
 tcp_rl_shutdown(void *arg __unused, int howto __unused)
 {
 	struct tcp_rate_set *rs, *nrs;
-	struct ifnet *tifp;
 	int i;
 
 	mtx_lock(&rs_mtx);
@@ -1201,8 +1198,7 @@ tcp_rl_shutdown(void *arg __unused, int howto __unused
 		rs->rs_flags |= RS_IS_DEAD;
 		for (i = 0; i < rs->rs_rate_cnt; i++) {
 			if (rs->rs_rlt[i].flags & HDWRPACE_TAGPRESENT) {
-				tifp = rs->rs_rlt[i].tag->ifp;
-				in_pcbdetach_tag(tifp, rs->rs_rlt[i].tag);
+				in_pcbdetach_tag(rs->rs_rlt[i].tag);
 				rs->rs_rlt[i].tag = NULL;
 			}
 			rs->rs_rlt[i].flags = HDWRPACE_IFPDEPARTED;


More information about the svn-src-all mailing list