MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ether_demux

Function ether_demux

freebsd/net/if_ethersubr.c:841–944  ·  view source on GitHub ↗

* Upper layer processing for a received Ethernet packet. */

Source from the content-addressed store, hash-verified

839 * Upper layer processing for a received Ethernet packet.
840 */
841void
842ether_demux(struct ifnet *ifp, struct mbuf *m)
843{
844 struct ether_header *eh;
845 int i, isr;
846 u_short ether_type;
847
848 NET_EPOCH_ASSERT();
849 KASSERT(ifp != NULL, ("%s: NULL interface pointer", __func__));
850
851 /* Do not grab PROMISC frames in case we are re-entered. */
852 if (PFIL_HOOKED_IN(V_link_pfil_head) && !(m->m_flags & M_PROMISC)) {
853 i = pfil_run_hooks(V_link_pfil_head, &m, ifp, PFIL_IN, NULL);
854 if (i != 0 || m == NULL)
855 return;
856 }
857
858 eh = mtod(m, struct ether_header *);
859 ether_type = ntohs(eh->ether_type);
860
861 /*
862 * If this frame has a VLAN tag other than 0, call vlan_input()
863 * if its module is loaded. Otherwise, drop.
864 */
865 if ((m->m_flags & M_VLANTAG) &&
866 EVL_VLANOFTAG(m->m_pkthdr.ether_vtag) != 0) {
867 if (ifp->if_vlantrunk == NULL) {
868 if_inc_counter(ifp, IFCOUNTER_NOPROTO, 1);
869 m_freem(m);
870 return;
871 }
872 KASSERT(vlan_input_p != NULL,("%s: VLAN not loaded!",
873 __func__));
874 /* Clear before possibly re-entering ether_input(). */
875 m->m_flags &= ~M_PROMISC;
876 (*vlan_input_p)(ifp, m);
877 return;
878 }
879
880 /*
881 * Pass promiscuously received frames to the upper layer if the user
882 * requested this by setting IFF_PPROMISC. Otherwise, drop them.
883 */
884 if ((ifp->if_flags & IFF_PPROMISC) == 0 && (m->m_flags & M_PROMISC)) {
885 m_freem(m);
886 return;
887 }
888
889 /*
890 * Reset layer specific mbuf flags to avoid confusing upper layers.
891 * Strip off Ethernet header.
892 */
893 m->m_flags &= ~M_VLANTAG;
894 m_clrprotoflags(m);
895 m_adj(m, ETHER_HDR_LEN);
896
897 /*
898 * Dispatch frame to upper layer.

Callers 4

dummynet_sendFunction · 0.85
ether_input_internalFunction · 0.85
gif_inputFunction · 0.85
ng_ether_rcv_upperFunction · 0.85

Calls 6

pfil_run_hooksFunction · 0.85
if_inc_counterFunction · 0.85
m_adjFunction · 0.85
netisr_dispatchFunction · 0.85
m_freemFunction · 0.50
m_clrprotoflagsFunction · 0.50

Tested by

no test coverage detected