From patchwork Sat Jan 20 10:00:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 863941 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@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; dkim=pass (2048-bit key; unprotected) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="omeaOvXd"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zNtVg3JDYz9s82 for ; Sat, 20 Jan 2018 21:00:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754637AbeATKAh (ORCPT ); Sat, 20 Jan 2018 05:00:37 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:44919 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751177AbeATKAc (ORCPT ); Sat, 20 Jan 2018 05:00:32 -0500 Received: by mail-wr0-f196.google.com with SMTP id w50so3704213wrc.11 for ; Sat, 20 Jan 2018 02:00:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=s2+assuDeisPL2WUmW5LY+IRb07T3J4urBFwO0SejFE=; b=omeaOvXdFwn8YmdcOEmeyQYX9exv5GTGrObuvvXpYtrbADwIq8tsPfAbNBtJX8SLB8 Rsm0zdOxAU4zwPHe146mrMcquwhnzBFSRBqUqBqLm9Q8D2zehoxA3iYK9/1QayBFQazl bhgnV4OsBlverSQtOU++PZMXlvgRhtWPBpiaj/gDNOAh2bvRt2774g2Bw45f0eoJxmvk nA34XLHjAy8GXiFoyfVuIKuN+IDOGyHuxoJAKeMaq9YcQu4WjMwMVydlXnorbUMkF3JA 82dTDYo8jO7EQGLSzt34jxCcyYq4OtYdemIbFBGf9qgVUCAdExAN5WM6Z9UZ9glryk6I EM1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=s2+assuDeisPL2WUmW5LY+IRb07T3J4urBFwO0SejFE=; b=TuQEu6PLiEs+tLkrraT5J+ENPZgyU9fSWDZQJRdcN61BYvOl8FeRKkFamDp+RJdjF9 u69BY75N7cRKJfFF9e5ah0QrYnvzdsp2KpXUXDiCWBz096cBzh4ygpgFEXx2/6eJPHGX DTMDOjOqy4p5EiGUrL4/U6AX2iiV/FIACorNxN7WjvUdZ76UbiZ7UlCH6V27PjcyK5K2 +ged+BKkPm2NF4GXdkqO3T8TIIUnz2HFxWh/AYLiivnJTfk2BzDzebE0rsTCYfvu3iXH 5Jag9qHuZ8+FVAAiZxDf5D5AcdnPCidz18h19qtmjN3dCf2sSd2s+wnn+o1manATMLl8 vlUg== X-Gm-Message-State: AKwxytfQ2za+5B69PDFw8G33RPZwbFxRKtR8tbI9m/1iZfgDjHz1q94a iczy6jnR/6YjPbK9uEqenHxftnzB X-Google-Smtp-Source: AH8x225XoA1eanxx9gKK+BQH0FpyYRjBXpyCveMHV7qK6BbsXAnT0+SpJ6ZL8ciJFFQRE83sWGfZCg== X-Received: by 10.223.153.103 with SMTP id x94mr1274437wrb.210.1516442431186; Sat, 20 Jan 2018 02:00:31 -0800 (PST) Received: from localhost (jirka.pirko.cz. [84.16.102.26]) by smtp.gmail.com with ESMTPSA id e128sm1526641wmg.1.2018.01.20.02.00.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Jan 2018 02:00:30 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: mlxsw@mellanox.com, dsahern@gmail.com Subject: [patch iproute2 net-next v12 0/3] tc: shared block support Date: Sat, 20 Jan 2018 11:00:26 +0100 Message-Id: <20180120100029.886-1-jiri@resnulli.us> X-Mailer: git-send-email 2.14.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko Kernel allows to share all filters between qdiscs with use of shared block. Example: block number 22. "22" is just an identification: $ tc qdisc add dev ens7 ingress_block 22 ingress ^^^^^^^^^^^^^^^^ $ tc qdisc add dev ens8 ingress_block 22 ingress ^^^^^^^^^^^^^^^^ If we don't specify "block" command line option, no shared block would be created: $ tc qdisc add dev ens9 ingress Now if we list the qdiscs, we will see the block index in the output: $ tc qdisc qdisc ingress ffff: dev ens7 parent ffff:fff1 ingress_block 22 qdisc ingress ffff: dev ens8 parent ffff:fff1 ingress_block 22 qdisc ingress ffff: dev ens9 parent ffff:fff1 To make is more visual, the situation looks like this: ens7 ingress qdisc ens7 ingress qdisc | | | | +----------> block 22 <----------+ Unlimited number of qdiscs may share the same block. Block sharing is also supported for clsact qdisc: $ tc qdisc add dev ens10 ingress_block 23 egress_block 24 clsact $ tc qdisc show dev ens10 qdisc clsact ffff: dev ens10 parent ffff:fff1 ingress_block 23 egress_block 24 We can add filter using the block index: $ tc filter add block 22 protocol ip pref 25 flower dst_ip 192.168.0.0/16 action drop Note we cannot use the qdisc for filter manipulations of shared blocks: $ tc filter add dev ens8 ingress protocol ip pref 1 flower dst_ip 192.168.100.2 action drop Error: This filter block is shared. Please use the block index to manipulate the filters. We will see the same output if we list filters for ingress qdisc of ens7 and ens8, also for the block 22: $ tc filter show block 22 filter protocol ip pref 25 flower chain 0 filter protocol ip pref 25 flower chain 0 handle 0x1 ... $ tc filter show dev ens7 ingress filter block 22 protocol ip pref 25 flower chain 0 filter block 22 protocol ip pref 25 flower chain 0 handle 0x1 ... $ tc filter show dev ens8 ingress filter block 22 protocol ip pref 25 flower chain 0 filter block 22 protocol ip pref 25 flower chain 0 handle 0x1 ... --- v11->v12: - separate iproute2 patchset, kernel part is merged - original patch 1 is removed as the header changes are already in iproute2 code - patch 1: - fixed return type of tc_qdisc_block_exists - removed 0 checks for block in tc_qdisc_block_exists - rever xmas tree variables in tc_qdisc_block_exists - patch 2 - fixes error message when both dev and block are on the command line --- Note that if you want me to change the ">=" vs "==" thing, I will do it. But I think that it is a global iproute2 thing and should be changed in a separate patch/patchset. Jiri Pirko (3): tc: introduce tc_qdisc_block_exists helper tc: introduce support for block-handle for filter operations tc: implement ingress/egress block index attributes for qdiscs man/man8/tc.8 | 24 ++++++++++++- tc/tc_filter.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++---------- tc/tc_qdisc.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tc/tc_util.h | 2 ++ 4 files changed, 210 insertions(+), 18 deletions(-)