PERFORCE change 45601 for review
Sam Leffler
sam at FreeBSD.org
Mon Jan 19 09:53:12 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=45601
Change 45601 by sam at sam_ebb on 2004/01/19 09:52:09
revert pfil_hooks changes unintentionally brought in during merge
Affected files ...
.. //depot/projects/netperf_socket/sys/net/if_ethersubr.c#3 edit
Differences ...
==== //depot/projects/netperf_socket/sys/net/if_ethersubr.c#3 (text+ko) ====
@@ -96,6 +96,9 @@
#endif /* NETATALK */
/* netgraph node hooks for ng_ether(4) */
+void (*ng_ether_input_p)(struct ifnet *ifp, struct mbuf **mp);
+void (*ng_ether_input_orphan_p)(struct ifnet *ifp, struct mbuf *m);
+int (*ng_ether_output_p)(struct ifnet *ifp, struct mbuf **mp);
void (*ng_ether_attach_p)(struct ifnet *ifp);
void (*ng_ether_detach_p)(struct ifnet *ifp);
@@ -108,10 +111,6 @@
bdgtakeifaces_t *bdgtakeifaces_ptr;
struct bdg_softc *ifp2sc;
-#ifdef PFIL_HOOKS
-struct pfil_head ether_pfil_hook;
-#endif
-
static u_char etherbroadcastaddr[ETHER_ADDR_LEN] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
@@ -298,20 +297,20 @@
return (0); /* XXX */
}
}
-#ifdef PFIL_HOOKS
- /*
- * Run through list of hooks for output packets.
- */
- error = pfil_run_hooks(ðer_pfil_hook, &m, ifp, PFIL_OUT);
- if (error != 0 || m == NULL)
- goto bad;
-#endif
+
+ /* Handle ng_ether(4) processing, if any */
+ if (ng_ether_output_p != NULL) {
+ if ((error = (*ng_ether_output_p)(ifp, &m)) != 0) {
+bad: if (m != NULL)
+ m_freem(m);
+ return (error);
+ }
+ if (m == NULL)
+ return (0);
+ }
+
/* Continue with link-layer output */
return ether_output_frame(ifp, m);
-bad:
- if (m != NULL)
- m_freem(m);
- return (error);
}
/*
@@ -531,15 +530,14 @@
}
ifp->if_ibytes += m->m_pkthdr.len;
-#ifdef PFIL_HOOKS
- /*
- * Run through list of hooks for input packets.
- */
- if (pfil_run_hooks(&inet_pfil_hook, &m, ifp, PFIL_IN) != 0)
- return;
- if (m == NULL) /* consumed by filter */
- return;
-#endif
+
+ /* Handle ng_ether(4) processing, if any */
+ if (ng_ether_input_p != NULL) {
+ (*ng_ether_input_p)(ifp, &m);
+ if (m == NULL)
+ return;
+ }
+
/* Check for bridging mode */
if (BDG_ACTIVE(ifp) ) {
struct ifnet *bif;
@@ -772,20 +770,20 @@
discard:
/*
- * Packet is to be discarded. If let hooks have a
- * last go at it before we reclaim storage.
+ * Packet is to be discarded. If netgraph is present,
+ * hand the packet to it for last chance processing;
+ * otherwise dispose of it.
*/
-#ifdef PFIL_HOOKS
- /*
- * Put back the ethernet header so hooks have a
- * consistent view of inbound packets.
- */
- M_PREPEND(m, ETHER_HDR_LEN, M_DONTWAIT);
- if (pfil_run_hooks(ðer_pfil_hook, &m, ifp, PFIL_IN_DISCARD) != 0)
- m = NULL; /* hook consumed packet, don't free */
-#endif
- if (m != NULL)
- m_freem(m);
+ if (ng_ether_input_orphan_p != NULL) {
+ /*
+ * Put back the ethernet header so netgraph has a
+ * consistent view of inbound packets.
+ */
+ M_PREPEND(m, ETHER_HDR_LEN, M_DONTWAIT);
+ (*ng_ether_input_orphan_p)(ifp, m);
+ return;
+ }
+ m_freem(m);
}
/*
@@ -1018,53 +1016,11 @@
}
}
-static int
-ether_modinit(void)
-{
-#ifdef PFIL_HOOKS
- int error;
-
- ether_pfil_hook.ph_type = PFIL_TYPE_AF;
- ether_pfil_hook.ph_af = AF_LINK; /* XXX */
- error = pfil_head_register(ðer_pfil_hook);
- if (error != 0)
- printf("%s: Unable to register hook, error %d\n",
- __func__, error);
- return error;
-#else
- return 0;
-#endif
-}
-
-static int
-ether_moddestroy(void)
-{
-#ifdef PFIL_HOOKS
- (void) pfil_head_unregister(ðer_pfil_hook);
-#endif
- return 0;
-}
-
-/*
- * Module glue.
- */
-static int
-ether_modevent(module_t mod, int type, void *unused)
-{
- switch (type) {
- case MOD_LOAD:
- return ether_modinit();
- case MOD_UNLOAD:
- return ether_moddestroy();
- }
- return EINVAL;
-}
-
static moduledata_t ether_mod = {
- "ether",
- ether_modevent,
- 0
+ "ether",
+ NULL,
+ 0
};
-
-DECLARE_MODULE(ether, ether_mod, SI_SUB_PSEUDO, SI_ORDER_FIRST);
+
+DECLARE_MODULE(ether, ether_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
MODULE_VERSION(ether, 1);
More information about the p4-projects
mailing list