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_ */
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to