Skip to content

Commit 26c97c5

Browse files
JoePerchesummakynes
authored andcommitted
netfilter: ipset: Use is_zero_ether_addr instead of static and memcmp
To make the test a bit clearer and to reduce object size a little. Miscellanea: o remove now unnecessary static const array $ size ip_set_hash_mac.o* text data bss dec hex filename 22822 4619 64 27505 6b71 ip_set_hash_mac.o.allyesconfig.new 22932 4683 64 27679 6c1f ip_set_hash_mac.o.allyesconfig.old 10443 1040 0 11483 2cdb ip_set_hash_mac.o.defconfig.new 10507 1040 0 11547 2d1b ip_set_hash_mac.o.defconfig.old Signed-off-by: Joe Perches <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent e3b5e1e commit 26c97c5

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

net/netfilter/ipset/ip_set_hash_mac.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ hash_mac4_data_next(struct hash_mac4_elem *next,
7272
#define IP_SET_PROTO_UNDEF
7373
#include "ip_set_hash_gen.h"
7474

75-
/* Zero valued element is not supported */
76-
static const unsigned char invalid_ether[ETH_ALEN] = { 0 };
77-
7875
static int
7976
hash_mac4_kadt(struct ip_set *set, const struct sk_buff *skb,
8077
const struct xt_action_param *par,
@@ -93,7 +90,7 @@ hash_mac4_kadt(struct ip_set *set, const struct sk_buff *skb,
9390
return -EINVAL;
9491

9592
ether_addr_copy(e.ether, eth_hdr(skb)->h_source);
96-
if (memcmp(e.ether, invalid_ether, ETH_ALEN) == 0)
93+
if (is_zero_ether_addr(e.ether))
9794
return -EINVAL;
9895
return adtfn(set, &e, &ext, &opt->ext, opt->cmdflags);
9996
}
@@ -118,7 +115,7 @@ hash_mac4_uadt(struct ip_set *set, struct nlattr *tb[],
118115
if (ret)
119116
return ret;
120117
ether_addr_copy(e.ether, nla_data(tb[IPSET_ATTR_ETHER]));
121-
if (memcmp(e.ether, invalid_ether, ETH_ALEN) == 0)
118+
if (is_zero_ether_addr(e.ether))
122119
return -IPSET_ERR_HASH_ELEM;
123120

124121
return adtfn(set, &e, &ext, &ext, flags);

0 commit comments

Comments
 (0)