From patchwork Mon Aug 12 10:17:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 1145621 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@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=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=idosch.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="Grdvk3xt"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 466WxS73nXz9sNC for ; Mon, 12 Aug 2019 20:17:32 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727823AbfHLKRb (ORCPT ); Mon, 12 Aug 2019 06:17:31 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:49111 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727564AbfHLKRb (ORCPT ); Mon, 12 Aug 2019 06:17:31 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 32E5E21F16; Mon, 12 Aug 2019 06:17:30 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 12 Aug 2019 06:17:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=zP+6oYsL0xPCrmAPh ZSWiKhgiLkwj7fMru3h03QugCQ=; b=Grdvk3xtKK2y1UAUP6z71CeFh/pBx0cxr +x3YJzPDR764kzMiEBua6tZ7EjCMhr13NEufYKb5G22O7Qdb+XWTXaAmiuZWj6XY 90md75rq16i4Fdip6ZDos7QcZvOQFgOXaH7Z6gyrpN1lO17tm1KAv/GUruOci7Iu YCeUJO7gm55wIkZcKJ06by469BjC/9PJwg2oQNQszkdUwBTVyplJ3Nk1LLheWdvm dd9UCCbKVhu0EA8es8ASkwXXb+jU5WrAvUlH9jxono2ZLfrSeAoxBPjmamGC1E99 SMQK0Eglmr2D6b50tBRoo7Ull9pkHJOYopHQSbCM94CLgCKJII5fA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddruddvgedgvdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomhepkfguohcuufgthhhimhhmvghluceoihguohhstghhsehiughoshgt hhdrohhrgheqnecukfhppeduleefrdegjedrudeihedrvdehudenucfrrghrrghmpehmrg hilhhfrhhomhepihguohhstghhsehiughoshgthhdrohhrghenucevlhhushhtvghrufhi iigvpedt X-ME-Proxy: Received: from splinter.mtl.com (unknown [193.47.165.251]) by mail.messagingengine.com (Postfix) with ESMTPA id 91A6380059; Mon, 12 Aug 2019 06:17:28 -0400 (EDT) From: Ido Schimmel To: netdev@vger.kernel.org Cc: stephen@networkplumber.org, dsahern@gmail.com, jiri@mellanox.com, mlxsw@mellanox.com, Ido Schimmel Subject: [PATCH iproute2] tc: Fix block-handle support for filter operations Date: Mon, 12 Aug 2019 13:17:06 +0300 Message-Id: <20190812101706.15778-1-idosch@idosch.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ido Schimmel Commit e991c04d64c0 ("Revert "tc: Add batchsize feature for filter and actions"") reverted more than it should and broke shared block functionality. Fix this by restoring the original functionality. To reproduce: # tc qdisc add dev swp1 ingress_block 10 ingress # tc filter add block 10 proto ip pref 1 flower \ dst_ip 192.0.2.0/24 action drop Unknown filter "block", hence option "10" is unparsable Fixes: e991c04d64c0 ("Revert "tc: Add batchsize feature for filter and actions"") Signed-off-by: Ido Schimmel Acked-by: Jiri Pirko --- tc/tc_filter.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tc/tc_filter.c b/tc/tc_filter.c index 53759a7a8876..23e21d89d7d1 100644 --- a/tc/tc_filter.c +++ b/tc/tc_filter.c @@ -74,6 +74,7 @@ static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv) __u32 prio = 0; __u32 protocol = 0; int protocol_set = 0; + __u32 block_index = 0; __u32 chain_index; int chain_index_set = 0; char *fhandle = NULL; @@ -89,7 +90,21 @@ static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv) NEXT_ARG(); if (d[0]) duparg("dev", *argv); + if (block_index) { + fprintf(stderr, "Error: \"dev\" and \"block\" are mutually exclusive\n"); + return -1; + } strncpy(d, *argv, sizeof(d)-1); + } else if (matches(*argv, "block") == 0) { + NEXT_ARG(); + if (block_index) + duparg("block", *argv); + if (d[0]) { + fprintf(stderr, "Error: \"dev\" and \"block\" are mutually exclusive\n"); + return -1; + } + if (get_u32(&block_index, *argv, 0) || !block_index) + invarg("invalid block index value", *argv); } else if (strcmp(*argv, "root") == 0) { if (req.t.tcm_parent) { fprintf(stderr, @@ -184,6 +199,9 @@ static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv) fprintf(stderr, "Cannot find device \"%s\"\n", d); return 1; } + } else if (block_index) { + req.t.tcm_ifindex = TCM_IFINDEX_MAGIC_BLOCK; + req.t.tcm_block_index = block_index; } if (q) {