Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Aug 2018 22:55:58 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r337278 - head/sys/netgraph
Message-ID:  <201808032255.w73MtwWb041054@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Fri Aug  3 22:55:58 2018
New Revision: 337278
URL: https://svnweb.freebsd.org/changeset/base/337278

Log:
  Use if_tunnel_check_nesting() for ng_iface(4).

Modified:
  head/sys/netgraph/ng_iface.c
  head/sys/netgraph/ng_iface.h

Modified: head/sys/netgraph/ng_iface.c
==============================================================================
--- head/sys/netgraph/ng_iface.c	Fri Aug  3 22:15:58 2018	(r337277)
+++ head/sys/netgraph/ng_iface.c	Fri Aug  3 22:55:58 2018	(r337278)
@@ -344,7 +344,6 @@ static int
 ng_iface_output(struct ifnet *ifp, struct mbuf *m,
 	const struct sockaddr *dst, struct route *ro)
 {
-	struct m_tag *mtag;
 	uint32_t af;
 	int error;
 
@@ -356,22 +355,11 @@ ng_iface_output(struct ifnet *ifp, struct mbuf *m,
 	}
 
 	/* Protect from deadly infinite recursion. */
-	mtag = NULL;
-	while ((mtag = m_tag_locate(m, MTAG_NGIF, MTAG_NGIF_CALLED, mtag))) {
-		if (*(struct ifnet **)(mtag + 1) == ifp) {
-			log(LOG_NOTICE, "Loop detected on %s\n", ifp->if_xname);
-			m_freem(m);
-			return (EDEADLK);
-		}
-	}
-	mtag = m_tag_alloc(MTAG_NGIF, MTAG_NGIF_CALLED, sizeof(struct ifnet *),
-	    M_NOWAIT);
-	if (mtag == NULL) {
+	error = if_tunnel_check_nesting(ifp, m, NGM_IFACE_COOKIE, 1);
+	if (error) {
 		m_freem(m);
-		return (ENOMEM);
+		return (error);
 	}
-	*(struct ifnet **)(mtag + 1) = ifp;
-	m_tag_prepend(m, mtag);
 
 	/* BPF writes need to be handled specially. */
 	if (dst->sa_family == AF_UNSPEC)

Modified: head/sys/netgraph/ng_iface.h
==============================================================================
--- head/sys/netgraph/ng_iface.h	Fri Aug  3 22:15:58 2018	(r337277)
+++ head/sys/netgraph/ng_iface.h	Fri Aug  3 22:55:58 2018	(r337278)
@@ -70,7 +70,4 @@ enum {
 	NGM_IFACE_GET_IFINDEX,
 };
 
-#define	MTAG_NGIF			NGM_IFACE_COOKIE
-#define	MTAG_NGIF_CALLED		0 | MTAG_PERSISTENT
-
 #endif /* _NETGRAPH_NG_IFACE_H_ */



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