I'd like to be able to easily identify how deep are the tentacles of a
pseudo-driver in your network stack.  This diff takes the example of
gif(4) and move all the remaining blocks checking for "IFT_GIF" under
the appropriate #ifdef dance.

The #ifdef I'm adding below are not strictly needed to compile a kernel
without gif(4) but they act as markers to limit code chunks that do not
need to be executed without the corresponding interface.

Ok?

Index: net/if_bridge.c
===================================================================
RCS file: /cvs/src/sys/net/if_bridge.c,v
retrieving revision 1.232
diff -u -p -r1.232 if_bridge.c
--- net/if_bridge.c     6 Feb 2015 22:10:43 -0000       1.232
+++ net/if_bridge.c     1 Apr 2015 12:00:11 -0000
@@ -1377,6 +1377,7 @@ bridge_input(struct ifnet *ifp, struct e
                IF_ENQUEUE(&sc->sc_if.if_snd, mc);
                splx(s);
                schednetisr(NETISR_BRIDGE);
+#if NGIF > 0
                if (ifp->if_type == IFT_GIF) {
                        TAILQ_FOREACH(ifl, &sc->sc_iflist, next) {
                                if (ifl->ifp->if_type == IFT_ETHER)
@@ -1396,6 +1397,7 @@ bridge_input(struct ifnet *ifp, struct e
                                m = NULL;
                        }
                }
+#endif /* NGIF */
                return (m);
        }
 
@@ -1446,11 +1448,13 @@ bridge_input(struct ifnet *ifp, struct e
 
                        m->m_pkthdr.rcvif = ifl->ifp;
                        m->m_pkthdr.ph_rtableid = ifl->ifp->if_rdomain;
+#if NGIF > 0
                        if (ifp->if_type == IFT_GIF) {
                                m->m_flags |= M_PROTO1;
                                ether_input(ifl->ifp, eh, m);
                                m = NULL;
                        }
+#endif /* NGIF */
                        return (m);
                }
                if (bcmp(ac->ac_enaddr, eh->ether_shost, ETHER_ADDR_LEN) == 0
Index: netinet6/in6_ifattach.c
===================================================================
RCS file: /cvs/src/sys/netinet6/in6_ifattach.c,v
retrieving revision 1.86
diff -u -p -r1.86 in6_ifattach.c
--- netinet6/in6_ifattach.c     14 Mar 2015 03:38:52 -0000      1.86
+++ netinet6/in6_ifattach.c     1 Apr 2015 11:58:55 -0000
@@ -30,6 +30,8 @@
  * SUCH DAMAGE.
  */
 
+#include "gif.h"
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/socket.h>
@@ -198,6 +200,7 @@ get_hw_ifid(struct ifnet *ifp, struct in
                }
                break;
 
+#if NGIF > 0
        case IFT_GIF:
                /*
                 * RFC2893 says: "SHOULD use IPv4 address as ifid source".
@@ -206,6 +209,7 @@ get_hw_ifid(struct ifnet *ifp, struct in
                 * we don't do this.
                 */
                return -1;
+#endif /* NGIF */
 
        default:
                return -1;
Index: netinet6/nd6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6.c,v
retrieving revision 1.133
diff -u -p -r1.133 nd6.c
--- netinet6/nd6.c      25 Mar 2015 17:39:33 -0000      1.133
+++ netinet6/nd6.c      1 Apr 2015 12:02:14 -0000
@@ -30,6 +30,8 @@
  * SUCH DAMAGE.
  */
 
+#include "gif.h"
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/timeout.h>
@@ -1817,7 +1819,10 @@ nd6_need_cache(struct ifnet *ifp)
        case IFT_PROPVIRTUAL:
        case IFT_IEEE80211:
        case IFT_CARP:
-       case IFT_GIF:           /* XXX need more cases? */
+#if NGIF > 0
+       case IFT_GIF:
+#endif /* NGIF */
+               /* XXX need more cases? */
                return (1);
        default:
                return (0);

Reply via email to