From owner-svn-src-all@freebsd.org Fri Aug 3 22:55:59 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8552610544FC; Fri, 3 Aug 2018 22:55:59 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2BB3679B1C; Fri, 3 Aug 2018 22:55:59 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0A1DF26C9B; Fri, 3 Aug 2018 22:55:59 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w73MtwJ0041056; Fri, 3 Aug 2018 22:55:58 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w73MtwWb041054; Fri, 3 Aug 2018 22:55:58 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201808032255.w73MtwWb041054@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Fri, 3 Aug 2018 22:55:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337278 - head/sys/netgraph X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: head/sys/netgraph X-SVN-Commit-Revision: 337278 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Aug 2018 22:55:59 -0000 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_ */