From 7bd9febf65e98eb1f4b4d51afa2479c442066235 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Sat, 3 Nov 2018 23:43:49 +0100 Subject: libxtables: add and use mac print helpers This changes ebtables-nft to consistently print mac address with two characters, i.e. 00:01:02:03:04:0a, not 0:1:2:3:4:a. Will require another bump of vcurrent/vage. Suggested-by: Pablo Neira Ayuso Signed-off-by: Florian Westphal --- iptables/nft-bridge.c | 17 ++++------------- .../testcases/ebtables/0002-ebtables-save-restore_0 | 4 ++-- 2 files changed, 6 insertions(+), 15 deletions(-) (limited to 'iptables') diff --git a/iptables/nft-bridge.c b/iptables/nft-bridge.c index a616f845..92e3f3b6 100644 --- a/iptables/nft-bridge.c +++ b/iptables/nft-bridge.c @@ -45,21 +45,12 @@ void ebt_cs_clean(struct iptables_command_state *cs) } } -/* 0: default, print only 2 digits if necessary - * 2: always print 2 digits, a printed mac address - * then always has the same length - */ -int ebt_printstyle_mac; - static void ebt_print_mac(const unsigned char *mac) { - if (ebt_printstyle_mac == 2) { - int j; - for (j = 0; j < ETH_ALEN; j++) - printf("%02x%s", mac[j], - (j==ETH_ALEN-1) ? "" : ":"); - } else - printf("%s", ether_ntoa((struct ether_addr *) mac)); + int j; + + for (j = 0; j < ETH_ALEN; j++) + printf("%02x%s", mac[j], (j==ETH_ALEN-1) ? "" : ":"); } static bool mac_all_ones(const unsigned char *mac) diff --git a/iptables/tests/shell/testcases/ebtables/0002-ebtables-save-restore_0 b/iptables/tests/shell/testcases/ebtables/0002-ebtables-save-restore_0 index eeb7d835..b23c1ee1 100755 --- a/iptables/tests/shell/testcases/ebtables/0002-ebtables-save-restore_0 +++ b/iptables/tests/shell/testcases/ebtables/0002-ebtables-save-restore_0 @@ -75,8 +75,8 @@ DUMP='*filter -A foo -p ARP --arp-op Request -j ACCEPT -A foo -p ARP --arp-ip-src 10.0.0.1 -j ACCEPT -A foo -p ARP --arp-ip-dst 10.0.0.0/8 -j ACCEPT --A foo -p ARP --arp-mac-src fe:ed:ba:be:0:1 -j ACCEPT --A foo -p ARP --arp-mac-dst fe:ed:ba:0:0:0/ff:ff:ff:0:0:0 -j ACCEPT +-A foo -p ARP --arp-mac-src fe:ed:ba:be:00:01 -j ACCEPT +-A foo -p ARP --arp-mac-dst fe:ed:ba:00:00:00/ff:ff:ff:00:00:00 -j ACCEPT -A foo -p IPv4 --ip-src 10.0.0.1 -j ACCEPT -A foo -p IPv4 --ip-dst 10.0.0.0/8 -j ACCEPT -A foo -p IPv4 --ip-tos 0x10 -j ACCEPT -- cgit v1.2.3