From patchwork Thu Feb 21 19:09:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 1046394 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=nwl.cc Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4453tr03Lwz9s7h for ; Fri, 22 Feb 2019 06:09:40 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727071AbfBUTJi (ORCPT ); Thu, 21 Feb 2019 14:09:38 -0500 Received: from orbyte.nwl.cc ([151.80.46.58]:60392 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726591AbfBUTJh (ORCPT ); Thu, 21 Feb 2019 14:09:37 -0500 Received: from localhost ([::1]:45250 helo=tatos) by orbyte.nwl.cc with esmtp (Exim 4.91) (envelope-from ) id 1gwtix-0007oe-Om; Thu, 21 Feb 2019 20:09:35 +0100 From: Phil Sutter To: Pablo Neira Ayuso Cc: netfilter-devel@vger.kernel.org Subject: [iptables PATCH 1/3] extensions: Fix ipvs vproto parsing Date: Thu, 21 Feb 2019 20:09:30 +0100 Message-Id: <20190221190932.16281-1-phil@nwl.cc> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org This was broken by integration into guided option parser: * Make 'vproto' option XTTYPE_PROTOCOL, otherwise its arguments are parsed as garbage only. * Drop O_VPROTO case from ipvs_mt_parse(), due to XTOPT_POINTER() and above change there is nothing to do for it in there. Fixes: 372203af4c70f ("libxt_ipvs: use guided option parser") Signed-off-by: Phil Sutter Reviewed-by: Julian Anastasov --- extensions/libxt_ipvs.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/extensions/libxt_ipvs.c b/extensions/libxt_ipvs.c index a6c57a030d2c6..fe98fef951686 100644 --- a/extensions/libxt_ipvs.c +++ b/extensions/libxt_ipvs.c @@ -27,7 +27,7 @@ enum { static const struct xt_option_entry ipvs_mt_opts[] = { {.name = "ipvs", .id = O_IPVS, .type = XTTYPE_NONE, .flags = XTOPT_INVERT}, - {.name = "vproto", .id = O_VPROTO, .type = XTTYPE_STRING, + {.name = "vproto", .id = O_VPROTO, .type = XTTYPE_PROTOCOL, .flags = XTOPT_INVERT | XTOPT_PUT, XTOPT_POINTER(s, l4proto)}, {.name = "vaddr", .id = O_VADDR, .type = XTTYPE_HOSTMASK, .flags = XTOPT_INVERT}, @@ -69,9 +69,6 @@ static void ipvs_mt_parse(struct xt_option_call *cb) xtables_option_parse(cb); switch (cb->entry->id) { - case O_VPROTO: - data->l4proto = cb->val.protocol; - break; case O_VADDR: memcpy(&data->vaddr, &cb->val.haddr, sizeof(cb->val.haddr)); memcpy(&data->vmask, &cb->val.hmask, sizeof(cb->val.hmask)); From patchwork Thu Feb 21 19:09:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 1046392 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=nwl.cc Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4453tc4NvCz9sDr for ; Fri, 22 Feb 2019 06:09:28 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727008AbfBUTJ1 (ORCPT ); Thu, 21 Feb 2019 14:09:27 -0500 Received: from orbyte.nwl.cc ([151.80.46.58]:60382 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726990AbfBUTJ0 (ORCPT ); Thu, 21 Feb 2019 14:09:26 -0500 Received: from localhost ([::1]:45240 helo=tatos) by orbyte.nwl.cc with esmtp (Exim 4.91) (envelope-from ) id 1gwtin-0007oM-2u; Thu, 21 Feb 2019 20:09:25 +0100 From: Phil Sutter To: Pablo Neira Ayuso Cc: netfilter-devel@vger.kernel.org Subject: [iptables PATCH 2/3] extensions: Fix ipvs vproto option printing Date: Thu, 21 Feb 2019 20:09:31 +0100 Message-Id: <20190221190932.16281-2-phil@nwl.cc> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190221190932.16281-1-phil@nwl.cc> References: <20190221190932.16281-1-phil@nwl.cc> MIME-Version: 1.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org This was broken since day 1: vproto option was printed as 'proto' which in turn iptables wouldn't accept anymore. Fixes: c36d05e424069 ("libxt_ipvs: user-space lib for netfilter matcher xt_ipvs") Signed-off-by: Phil Sutter --- extensions/libxt_ipvs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/libxt_ipvs.c b/extensions/libxt_ipvs.c index fe98fef951686..51952be4245b3 100644 --- a/extensions/libxt_ipvs.c +++ b/extensions/libxt_ipvs.c @@ -165,7 +165,7 @@ static void ipvs_mt_dump(const void *ip, const struct xt_ipvs_mtinfo *data, if (data->bitmask & XT_IPVS_PROTO) { if (data->invert & XT_IPVS_PROTO) printf(" !"); - printf(" %sproto %u", prefix, data->l4proto); + printf(" %svproto %u", prefix, data->l4proto); } if (data->bitmask & XT_IPVS_VADDR) { From patchwork Thu Feb 21 19:09:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 1046393 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=nwl.cc Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4453tj4kcqz9sBp for ; Fri, 22 Feb 2019 06:09:33 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727021AbfBUTJc (ORCPT ); Thu, 21 Feb 2019 14:09:32 -0500 Received: from orbyte.nwl.cc ([151.80.46.58]:60386 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727014AbfBUTJb (ORCPT ); Thu, 21 Feb 2019 14:09:31 -0500 Received: from localhost ([::1]:45244 helo=tatos) by orbyte.nwl.cc with esmtp (Exim 4.91) (envelope-from ) id 1gwtis-0007oU-Dl; Thu, 21 Feb 2019 20:09:30 +0100 From: Phil Sutter To: Pablo Neira Ayuso Cc: netfilter-devel@vger.kernel.org Subject: [iptables PATCH 3/3] extensions: Add testcase for libxt_ipvs Date: Thu, 21 Feb 2019 20:09:32 +0100 Message-Id: <20190221190932.16281-3-phil@nwl.cc> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190221190932.16281-1-phil@nwl.cc> References: <20190221190932.16281-1-phil@nwl.cc> MIME-Version: 1.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Given that it is fixed now, make it stay. Signed-off-by: Phil Sutter --- extensions/libxt_ipvs.t | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 extensions/libxt_ipvs.t diff --git a/extensions/libxt_ipvs.t b/extensions/libxt_ipvs.t new file mode 100644 index 0000000000000..c2acc6668d1b2 --- /dev/null +++ b/extensions/libxt_ipvs.t @@ -0,0 +1,20 @@ +:INPUT,FORWARD,OUTPUT +-m ipvs --ipvs;=;OK +-m ipvs ! --ipvs;=;OK +-m ipvs --vproto tcp;-m ipvs --vproto 6;OK +-m ipvs ! --vproto TCP;-m ipvs ! --vproto 6;OK +-m ipvs --vproto 23;=;OK +-m ipvs --vaddr 1.2.3.4;=;OK +-m ipvs ! --vaddr 1.2.3.4/255.255.255.0;-m ipvs ! --vaddr 1.2.3.4/24;OK +-m ipvs --vport http;-m ipvs --vport 80;OK +-m ipvs ! --vport ssh;-m ipvs ! --vport 22;OK +-m ipvs --vport 22;=;OK +-m ipvs ! --vport 443;=;OK +-m ipvs --vdir ORIGINAL;=;OK +-m ipvs --vdir REPLY;=;OK +-m ipvs --vmethod GATE;=;OK +-m ipvs ! --vmethod IPIP;=;OK +-m ipvs --vmethod MASQ;=;OK +-m ipvs --vportctl 21;=;OK +-m ipvs ! --vportctl 21;=;OK +-m ipvs --vproto 6 --vaddr 1.2.3.4/16 --vport 22 --vdir ORIGINAL --vmethod GATE;=;OK