From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15EB6CA9EC0 for ; Mon, 28 Oct 2019 15:48:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9D1D20830 for ; Mon, 28 Oct 2019 15:48:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727797AbfJ1Psd (ORCPT ); Mon, 28 Oct 2019 11:48:33 -0400 Received: from orbyte.nwl.cc ([151.80.46.58]:40104 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726097AbfJ1Psd (ORCPT ); Mon, 28 Oct 2019 11:48:33 -0400 Received: from localhost ([::1]:53194 helo=tatos) by orbyte.nwl.cc with esmtp (Exim 4.91) (envelope-from ) id 1iP7Fv-00025C-VO; Mon, 28 Oct 2019 16:48:32 +0100 From: Phil Sutter To: Pablo Neira Ayuso Cc: netfilter-devel@vger.kernel.org Subject: [iptables PATCH v2 10/10] nft-arp: Use xtables_print_mac_and_mask() Date: Mon, 28 Oct 2019 16:48:18 +0100 Message-Id: <20191028154818.31257-11-phil@nwl.cc> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191028154818.31257-1-phil@nwl.cc> References: <20191028154818.31257-1-phil@nwl.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org This libxtables function does exactly what the local implementation did. The only noteworthy difference is that it assumes MAC/mask lengths, but the local implementation was passed ETH_ALEN in each invocation, so no practical difference. Signed-off-by: Phil Sutter --- iptables/nft-arp.c | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/iptables/nft-arp.c b/iptables/nft-arp.c index 9805bbe0de87b..7068f82c5495a 100644 --- a/iptables/nft-arp.c +++ b/iptables/nft-arp.c @@ -114,29 +114,6 @@ mask_to_dotted(const struct in_addr *mask) return buf; } -static void print_mac(const unsigned char *mac, int l) -{ - int j; - - for (j = 0; j < l; j++) - printf("%02x%s", mac[j], - (j==l-1) ? "" : ":"); -} - -static void print_mac_and_mask(const unsigned char *mac, const unsigned char *mask, int l) -{ - int i; - - print_mac(mac, l); - for (i = 0; i < l ; i++) - if (mask[i] != 255) - break; - if (i == l) - return; - printf("/"); - print_mac(mask, l); -} - static bool need_devaddr(struct arpt_devaddr_info *info) { int i; @@ -506,8 +483,8 @@ static void nft_arp_print_rule_details(const struct iptables_command_state *cs, printf("%s%s", sep, fw->arp.invflags & ARPT_INV_SRCDEVADDR ? "! " : ""); printf("--src-mac "); - print_mac_and_mask((unsigned char *)fw->arp.src_devaddr.addr, - (unsigned char *)fw->arp.src_devaddr.mask, ETH_ALEN); + xtables_print_mac_and_mask((unsigned char *)fw->arp.src_devaddr.addr, + (unsigned char *)fw->arp.src_devaddr.mask); sep = " "; after_devsrc: @@ -532,8 +509,8 @@ after_devsrc: printf("%s%s", sep, fw->arp.invflags & ARPT_INV_TGTDEVADDR ? "! " : ""); printf("--dst-mac "); - print_mac_and_mask((unsigned char *)fw->arp.tgt_devaddr.addr, - (unsigned char *)fw->arp.tgt_devaddr.mask, ETH_ALEN); + xtables_print_mac_and_mask((unsigned char *)fw->arp.tgt_devaddr.addr, + (unsigned char *)fw->arp.tgt_devaddr.mask); sep = " "; after_devdst: -- 2.23.0