Hi,
this diff makes more use of the goto dropanyway instead of repeating 
m_freem() and return.
Also change the sizeof(etherbroadcastaddr) with ETHER_ADDR_LEN for
consistency with the other memcmps.

Regards,
Michele


Index: sys/net/if_ethersubr.c
===================================================================
RCS file: /cvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.250
diff -u -p -r1.250 if_ethersubr.c
--- sys/net/if_ethersubr.c      10 Jan 2018 00:14:38 -0000      1.250
+++ sys/net/if_ethersubr.c      1 Feb 2018 22:20:08 -0000
@@ -333,14 +333,12 @@ ether_input(struct ifnet *ifp, struct mb
                 */
                if ((ifp->if_flags & IFF_SIMPLEX) == 0) {
                        if (memcmp(ac->ac_enaddr, eh->ether_shost,
-                           ETHER_ADDR_LEN) == 0) {
-                               m_freem(m);
-                               return (1);
-                       }
+                           ETHER_ADDR_LEN) == 0)
+                               goto dropanyway;
                }
 
                if (memcmp(etherbroadcastaddr, eh->ether_dhost,
-                   sizeof(etherbroadcastaddr)) == 0)
+                   ETHER_ADDR_LEN) == 0)
                        m->m_flags |= M_BCAST;
                else
                        m->m_flags |= M_MCAST;
@@ -351,10 +349,8 @@ ether_input(struct ifnet *ifp, struct mb
         * HW vlan tagged packets that were not collected by vlan(4) must
         * be dropped now.
         */
-       if (m->m_flags & M_VLANTAG) {
-               m_freem(m);
-               return (1);
-       }
+       if (m->m_flags & M_VLANTAG)
+               goto dropanyway;
 
        /*
         * If packet is unicast, make sure it is for us.  Drop otherwise.
@@ -362,10 +358,8 @@ ether_input(struct ifnet *ifp, struct mb
         * where the MAC filter is 'best effort' only.
         */
        if ((m->m_flags & (M_BCAST|M_MCAST)) == 0) {
-               if (memcmp(ac->ac_enaddr, eh->ether_dhost, ETHER_ADDR_LEN)) {
-                       m_freem(m);
-                       return (1);
-               }
+               if (memcmp(ac->ac_enaddr, eh->ether_dhost, ETHER_ADDR_LEN))
+                       goto dropanyway;
        }
 
        etype = ntohs(eh->ether_type);

Reply via email to