RFC: removing redundant checks in ether_input_internal()

Andre Oppermann andre at freebsd.org
Wed May 22 14:53:43 UTC 2013


On 22.05.2013 14:58, Luigi Rizzo wrote:
> if_ethersubr.c :: ether_input_internal() is only called as follows:
>
>      static void
>      ether_nh_input(struct mbuf *m)
>      {
>
>          ether_input_internal(m->m_pkthdr.rcvif, m);
>      }
>
> hence the following checks in the body are unnecessary:
>
>          if (m->m_pkthdr.rcvif == NULL) {
>                  if_printf(ifp, "discard frame w/o interface pointer\n");
>                  ifp->if_ierrors++;
>                  m_freem(m);
>                  return;
>          }
>      #ifdef DIAGNOSTIC
>          if (m->m_pkthdr.rcvif != ifp) {
>                  if_printf(ifp, "Warning, frame marked as received on %s\n",
>                          m->m_pkthdr.rcvif->if_xname);
>          }
>      #endif
>
> Any objection if i remove them ?

No, but they should remain as KASSERTs.  None of these should trigger in
production and all of them are an indication that something is very wrong
with the packet or the caller.

-- 
Andre



More information about the freebsd-net mailing list