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

Function ether_input_internal

freebsd/net/if_ethersubr.c:518–711  ·  view source on GitHub ↗

* Process a received Ethernet packet; the packet is in the * mbuf chain m with the ethernet header at the front. */

Source from the content-addressed store, hash-verified

516 * mbuf chain m with the ethernet header at the front.
517 */
518static void
519ether_input_internal(struct ifnet *ifp, struct mbuf *m)
520{
521 struct ether_header *eh;
522 u_short etype;
523
524 if ((ifp->if_flags & IFF_UP) == 0) {
525 m_freem(m);
526 return;
527 }
528#ifdef DIAGNOSTIC
529 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
530 if_printf(ifp, "discard frame at !IFF_DRV_RUNNING\n");
531 m_freem(m);
532 return;
533 }
534#endif
535 if (m->m_len < ETHER_HDR_LEN) {
536 /* XXX maybe should pullup? */
537 if_printf(ifp, "discard frame w/o leading ethernet "
538 "header (len %u pkt len %u)\n",
539 m->m_len, m->m_pkthdr.len);
540 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
541 m_freem(m);
542 return;
543 }
544 eh = mtod(m, struct ether_header *);
545 etype = ntohs(eh->ether_type);
546 random_harvest_queue_ether(m, sizeof(*m));
547
548#ifdef EXPERIMENTAL
549#if defined(INET6) && defined(INET)
550 /* draft-ietf-6man-ipv6only-flag */
551 /* Catch ETHERTYPE_IP, and ETHERTYPE_[REV]ARP if we are v6-only. */
552 if ((ND_IFINFO(ifp)->flags & ND6_IFF_IPV6_ONLY_MASK) != 0) {
553 switch (etype) {
554 case ETHERTYPE_IP:
555 case ETHERTYPE_ARP:
556 case ETHERTYPE_REVARP:
557 m_freem(m);
558 return;
559 /* NOTREACHED */
560 break;
561 };
562 }
563#endif
564#endif
565
566 CURVNET_SET_QUIET(ifp->if_vnet);
567
568 if (ETHER_IS_MULTICAST(eh->ether_dhost)) {
569 if (ETHER_IS_BROADCAST(eh->ether_dhost))
570 m->m_flags |= M_BCAST;
571 else
572 m->m_flags |= M_MCAST;
573 if_inc_counter(ifp, IFCOUNTER_IMCASTS, 1);
574 }
575

Callers 1

ether_nh_inputFunction · 0.85

Calls 7

if_printfFunction · 0.85
if_inc_counterFunction · 0.85
mac_ifnet_create_mbufFunction · 0.85
m_adjFunction · 0.85
m_pullupFunction · 0.85
ether_demuxFunction · 0.85
m_freemFunction · 0.50

Tested by

no test coverage detected