From patchwork Wed Jan 9 22:26:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Westphal X-Patchwork-Id: 1022633 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=strlen.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43ZkMW0lQHz9sN4 for ; Thu, 10 Jan 2019 09:29:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726731AbfAIW3m (ORCPT ); Wed, 9 Jan 2019 17:29:42 -0500 Received: from Chamillionaire.breakpoint.cc ([146.0.238.67]:50010 "EHLO Chamillionaire.breakpoint.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726221AbfAIW3m (ORCPT ); Wed, 9 Jan 2019 17:29:42 -0500 Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.89) (envelope-from ) id 1ghMM0-0001K6-EO; Wed, 09 Jan 2019 23:29:40 +0100 From: Florian Westphal To: Cc: Florian Westphal Subject: [PATCH nft] src: fix netdev family device name parsing Date: Wed, 9 Jan 2019 23:26:05 +0100 Message-Id: <20190109222605.10941-1-fw@strlen.de> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Should use accept/use quotes, else you can't use this with a device name that is shared with a key word, e.g. 'device vm'. Signed-off-by: Florian Westphal Acked-by: Pablo Neira Ayuso --- src/parser_bison.y | 2 +- src/rule.c | 2 +- tests/shell/testcases/chains/dumps/0021prio_0.nft | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/parser_bison.y b/src/parser_bison.y index 01f5be9563eb..f43d695688cd 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -1966,7 +1966,7 @@ int_num : NUM { $$ = $1; } | DASH NUM { $$ = -$2; } ; -dev_spec : DEVICE STRING { $$ = $2; } +dev_spec : DEVICE string { $$ = $2; } | /* empty */ { $$ = NULL; } ; diff --git a/src/rule.c b/src/rule.c index e15a20b30bbd..73b78c75a267 100644 --- a/src/rule.c +++ b/src/rule.c @@ -1070,7 +1070,7 @@ static void chain_print_declaration(const struct chain *chain, nft_print(octx, "\t\ttype %s hook %s", chain->type, hooknum2str(chain->handle.family, chain->hooknum)); if (chain->dev != NULL) - nft_print(octx, " device %s", chain->dev); + nft_print(octx, " device \"%s\"", chain->dev); nft_print(octx, " priority %s; policy %s;\n", prio2str(octx, priobuf, sizeof(priobuf), chain->handle.family, chain->hooknum, diff --git a/tests/shell/testcases/chains/dumps/0021prio_0.nft b/tests/shell/testcases/chains/dumps/0021prio_0.nft index 20125ba01186..ca94d4417bae 100644 --- a/tests/shell/testcases/chains/dumps/0021prio_0.nft +++ b/tests/shell/testcases/chains/dumps/0021prio_0.nft @@ -1364,23 +1364,23 @@ table arp x { } table netdev x { chain ingressfilterm11 { - type filter hook ingress device lo priority -11; policy accept; + type filter hook ingress device "lo" priority -11; policy accept; } chain ingressfilterm10 { - type filter hook ingress device lo priority filter - 10; policy accept; + type filter hook ingress device "lo" priority filter - 10; policy accept; } chain ingressfilter { - type filter hook ingress device lo priority filter; policy accept; + type filter hook ingress device "lo" priority filter; policy accept; } chain ingressfilterp10 { - type filter hook ingress device lo priority filter + 10; policy accept; + type filter hook ingress device "lo" priority filter + 10; policy accept; } chain ingressfilterp11 { - type filter hook ingress device lo priority 11; policy accept; + type filter hook ingress device "lo" priority 11; policy accept; } } table bridge x {