Date: Tue, 5 Nov 2019 00:12:21 +0000 (UTC) From: Eric Joyner <erj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r354345 - in head/sys: dev/usb/net net Message-ID: <201911050012.xA50CLst063394@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: erj Date: Tue Nov 5 00:12:21 2019 New Revision: 354345 URL: https://svnweb.freebsd.org/changeset/base/354345 Log: net: add ETHER_IS_ZERO macro similar to ETHER_IS_BROADCAST Some places in network code may need to verify that an ethernet address is not the 'zero' address. Provide a standard macro ETHER_IS_ZERO for this purpose, similar to the ETHER_IS_BROADCAST macro already available. This patch also removes previous ETHER_IS_ZERO definitions in several USB ethernet drivers, in favor of this centrally-located macro. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Submitted by: Jacob Keller <jacob.e.keller@intel.com> Reviewed by: erj@ Sponsored by: Intel Corporation Differential Revision: https://reviews.freebsd.org/D21240 Modified: head/sys/dev/usb/net/if_muge.c head/sys/dev/usb/net/if_smsc.c head/sys/dev/usb/net/if_ure.c head/sys/net/ethernet.h Modified: head/sys/dev/usb/net/if_muge.c ============================================================================== --- head/sys/dev/usb/net/if_muge.c Mon Nov 4 23:06:57 2019 (r354344) +++ head/sys/dev/usb/net/if_muge.c Tue Nov 5 00:12:21 2019 (r354345) @@ -157,9 +157,6 @@ do { \ #define muge_err_printf(sc, fmt, args...) \ device_printf((sc)->sc_ue.ue_dev, "error: " fmt, ##args) -#define ETHER_IS_ZERO(addr) \ - (!(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5])) - #define ETHER_IS_VALID(addr) \ (!ETHER_IS_MULTICAST(addr) && !ETHER_IS_ZERO(addr)) Modified: head/sys/dev/usb/net/if_smsc.c ============================================================================== --- head/sys/dev/usb/net/if_smsc.c Mon Nov 4 23:06:57 2019 (r354344) +++ head/sys/dev/usb/net/if_smsc.c Tue Nov 5 00:12:21 2019 (r354345) @@ -171,9 +171,6 @@ static const struct usb_device_id smsc_devs[] = { device_printf((sc)->sc_ue.ue_dev, "error: " fmt, ##args) -#define ETHER_IS_ZERO(addr) \ - (!(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5])) - #define ETHER_IS_VALID(addr) \ (!ETHER_IS_MULTICAST(addr) && !ETHER_IS_ZERO(addr)) Modified: head/sys/dev/usb/net/if_ure.c ============================================================================== --- head/sys/dev/usb/net/if_ure.c Mon Nov 4 23:06:57 2019 (r354344) +++ head/sys/dev/usb/net/if_ure.c Tue Nov 5 00:12:21 2019 (r354345) @@ -68,9 +68,6 @@ SYSCTL_INT(_hw_usb_ure, OID_AUTO, debug, CTLFLAG_RWTUN "Debug level"); #endif -#define ETHER_IS_ZERO(addr) \ - (!(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5])) - /* * Various supported device vendors/products. */ Modified: head/sys/net/ethernet.h ============================================================================== --- head/sys/net/ethernet.h Mon Nov 4 23:06:57 2019 (r354344) +++ head/sys/net/ethernet.h Tue Nov 5 00:12:21 2019 (r354345) @@ -74,6 +74,9 @@ struct ether_addr { #define ETHER_IS_BROADCAST(addr) \ (((addr)[0] & (addr)[1] & (addr)[2] & \ (addr)[3] & (addr)[4] & (addr)[5]) == 0xff) +#define ETHER_IS_ZERO(addr) \ + (((addr)[0] | (addr)[1] | (addr)[2] | \ + (addr)[3] | (addr)[4] | (addr)[5]) == 0x00) /* * 802.1q Virtual LAN header.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201911050012.xA50CLst063394>