From patchwork Thu Sep 13 07:57:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pieter Jansen van Vuuren X-Patchwork-Id: 969276 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="Yp/Wvrbg"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429rcJ2rsVz9s4V for ; Thu, 13 Sep 2018 17:58:07 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 5629DC22; Thu, 13 Sep 2018 07:58:01 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 7E83ABE6 for ; Thu, 13 Sep 2018 07:57:59 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-qt0-f179.google.com (mail-qt0-f179.google.com [209.85.216.179]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id ECD6213A for ; Thu, 13 Sep 2018 07:57:58 +0000 (UTC) Received: by mail-qt0-f179.google.com with SMTP id t39-v6so4515114qtc.8 for ; Thu, 13 Sep 2018 00:57:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=Vy0MUhHiSuKIbFkRMr4ZBeDSGVSUqbjPo7KAag4OH1A=; b=Yp/WvrbgtQX1XDneTI+TaMyWwSk5+Glua1OC5AsooC7JD91eMIr1kmUiVPQm5zb4Nz /qZICkuMGvuk5cJ/paKG/46E66WZ83t1Jd48EE5pMlnW2TIcwTwYb0gxfLQLP2toYEQJ Plso0eQWT3UlR3Mm1IfnikDA91588ZWCG8KHBFLmGOsbVMLIH3dWSu9JlgkV426eKkto zVTZXlnM1RCczzhbXGPRMiTu3Q/PDN4HdU17scMGlVkwjGUZRqzCDO96H7gvsZLfBW1H qdmjw9loyibQ+Fw1EE1P9didmoFfVFZ+wPiDzDbOau3hmk0xfjPsDwfSTCTRuOgtjq94 POQQ== 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=Vy0MUhHiSuKIbFkRMr4ZBeDSGVSUqbjPo7KAag4OH1A=; b=cNOdlgeRewYiucC0mvr0iFDxjFG+IHDSP//Bz5QPeVsHOhpIaeBunSEjyk4SS1AZFe FNdg0qzqrjWLqtXNBc8fmGt38rA4lUrkgZCSGo6PBSPze1jtezJzAMbRAM2jFlOKvkxm Tv2/TBxs/CacrPrOi0KliTFoX6wtueVNHKyUr0+ai7Yjt9OXHndEm6w7WUv2XOZz3wYd GG4rIXPRc3ZPluFBPbeXNG9w1Y9K7p123xehD/t5CyxLkprbbvCGxmhuG2WWWsCcqoYZ P7cYbHqUL1lk5VjQXTyeSMxK4Z1mhWcl+QgSf1E2EqLQ0P5tFvTzyFUSmL7vcJDWAk9v VSTQ== X-Gm-Message-State: APzg51C2S7TU5FO0iE+VXLGnvhWfze7+jYQ+YYR16SLo1trnFutiT8xA DSB2UUkZI5ZJ+bXA5S4bo9ZOcOxqUEw= X-Google-Smtp-Source: ANB0VdbiqKs5gFS8IzR3116/UvJjgxMtyrpTvoD0FKhq1ftEG+TizDQ52aQJPVeusAH8CZrP2iIg3w== X-Received: by 2002:a0c:ec47:: with SMTP id n7-v6mr4258791qvq.56.1536825477781; Thu, 13 Sep 2018 00:57:57 -0700 (PDT) Received: from pieter-Netronome.netronome.com (host81-150-168-85.in-addr.btopenworld.com. [81.150.168.85]) by smtp.gmail.com with ESMTPSA id m95-v6sm1920864qte.69.2018.09.13.00.57.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Sep 2018 00:57:57 -0700 (PDT) From: Pieter Jansen van Vuuren To: dev@openvswitch.org Date: Thu, 13 Sep 2018 08:57:48 +0100 Message-Id: <1536825468-20974-1-git-send-email-pieter.jansenvanvuuren@netronome.com> X-Mailer: git-send-email 1.9.1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: horms+renesas@verge.net.au, Pieter Jansen van Vuuren Subject: [ovs-dev] [PATCH branch-2.10] lib/tc: treat vlan id and prio as independent fields X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Previously the key was used to check the presence of vlan id and prio fields instead of using the mask. Additionally the vlan id field was considered to be present if only the prio field was set, and vice versa. f.e. setting the following: ovs-ofctl -OOpenFlow13,OpenFlow15 add-flow br0 \ priority=10,cookie=1,table=0,ip,dl_vlan_pcp=2,actions=output:2 Resulted in (instead of wildcarding vlan_id, filter matches 0): filter protocol 802.1Q pref 1 flower chain 0 filter protocol 802.1Q pref 1 flower chain 0 handle 0x1 vlan_id 0 vlan_prio 2 vlan_ethtype ip eth_type ipv4 ip_flags nofrag in_hw action order 1: mirred (Egress Redirect to device eth1) stolen index 2 ref 1 bind 1 installed 5 sec used 5 sec Action statistics: Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 cookie 47040ae7a94fff6afd7ed8aa04b11ba4 Signed-off-by: Pieter Jansen van Vuuren Reviewed-by: Simon Horman --- lib/netdev-tc-offloads.c | 2 ++ lib/tc.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c index 64f431c8d..f998ddfe1 100644 --- a/lib/netdev-tc-offloads.c +++ b/lib/netdev-tc-offloads.c @@ -960,10 +960,12 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, && (vid_mask || pcp_mask)) { if (vid_mask) { flower.key.vlan_id = vlan_tci_to_vid(key->vlans[0].tci); + flower.mask.vlan_id = vlan_tci_to_vid(mask->vlans[0].tci); VLOG_DBG_RL(&rl, "vlan_id: %d\n", flower.key.vlan_id); } if (pcp_mask) { flower.key.vlan_prio = vlan_tci_to_pcp(key->vlans[0].tci); + flower.mask.vlan_prio = vlan_tci_to_pcp(mask->vlans[0].tci); VLOG_DBG_RL(&rl, "vlan_prio: %d\n", flower.key.vlan_prio); } flower.key.encap_eth_type = flower.key.eth_type; diff --git a/lib/tc.c b/lib/tc.c index d5123bd69..b385ff365 100644 --- a/lib/tc.c +++ b/lib/tc.c @@ -346,10 +346,12 @@ nl_parse_flower_vlan(struct nlattr **attrs, struct tc_flower *flower) if (attrs[TCA_FLOWER_KEY_VLAN_ID]) { flower->key.vlan_id = nl_attr_get_u16(attrs[TCA_FLOWER_KEY_VLAN_ID]); + flower->mask.vlan_id = 0xffff; } if (attrs[TCA_FLOWER_KEY_VLAN_PRIO]) { flower->key.vlan_prio = nl_attr_get_u8(attrs[TCA_FLOWER_KEY_VLAN_PRIO]); + flower->mask.vlan_prio = 0xff; } } @@ -1637,9 +1639,11 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct tc_flower *flower) nl_msg_put_be16(request, TCA_FLOWER_KEY_ETH_TYPE, flower->key.eth_type); if (is_vlan) { - if (flower->key.vlan_id || flower->key.vlan_prio) { + if (flower->key.vlan_id) { nl_msg_put_u16(request, TCA_FLOWER_KEY_VLAN_ID, flower->key.vlan_id); + } + if (flower->key.vlan_prio) { nl_msg_put_u8(request, TCA_FLOWER_KEY_VLAN_PRIO, flower->key.vlan_prio); }