From 831c1b709c8834a47419a0f77fd8636145ed05be Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Thu, 30 Aug 2018 10:46:18 +0200 Subject: Add compatibility to support is_zero_ether_addr() --- configure.ac | 10 ++++++++++ kernel/include/linux/netfilter/ipset/ip_set_compat.h.in | 14 +++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 3f51720..73a2f8c 100644 --- a/configure.ac +++ b/configure.ac @@ -230,6 +230,16 @@ else AC_SUBST(HAVE_ETHER_ADDR_EQUAL, undef) fi +AC_MSG_CHECKING([kernel source for is_zero_ether_addr]) +if test -f $ksourcedir/include/linux/etherdevice.h && \ + $GREP -q 'is_zero_ether_addr' $ksourcedir/include/linux/etherdevice.h; then + AC_MSG_RESULT(yes) + AC_SUBST(HAVE_IS_ZERO_ETHER_ADDR, define) +else + AC_MSG_RESULT(no) + AC_SUBST(HAVE_IS_ZERO_ETHER_ADDR, undef) +fi + AC_MSG_CHECKING([kernel source for nla_put_be16]) if test -f $ksourcedir/include/net/netlink.h && \ $GREP -q 'nla_put_be16' $ksourcedir/include/net/netlink.h; then diff --git a/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in b/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in index c78867d..72b77b3 100644 --- a/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in +++ b/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in @@ -8,6 +8,7 @@ #@HAVE_STRUCT_XT_ACTION_PARAM@ HAVE_STRUCT_XT_ACTION_PARAM #@HAVE_VZALLOC@ HAVE_VZALLOC #@HAVE_ETHER_ADDR_EQUAL@ HAVE_ETHER_ADDR_EQUAL +#@HAVE_IS_ZERO_ETHER_ADDR@ HAVE_IS_ZERO_ETHER_ADDR #@HAVE_NLA_PUT_BE16@ HAVE_NLA_PUT_BE16 #@HAVE_NLA_PUT_BE64@ HAVE_NLA_PUT_BE64 #@HAVE_NLA_PUT_64BIT@ HAVE_NLA_PUT_64BIT @@ -152,15 +153,26 @@ do { \ PAGE_KERNEL) #endif -#ifndef HAVE_ETHER_ADDR_EQUAL +#if !defined(HAVE_ETHER_ADDR_EQUAL) || !defined(HAVE_IS_ZERO_ETHER_ADDR) #include +#ifndef HAVE_ETHER_ADDR_EQUAL static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2) { return !compare_ether_addr(addr1, addr2); } #endif +#ifndef HAVE_IS_ZERO_ETHER_ADDR +static inline bool is_zero_ether_addr(const u8 *addr) +{ + return (*(const u16 *)(addr + 0) | + *(const u16 *)(addr + 2) | + *(const u16 *)(addr + 4)) == 0; +} +#endif +#endif + #ifndef HAVE_NLA_PUT_BE64 static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value) { -- cgit v1.2.3