From patchwork Mon Sep 10 10:08:25 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: 967958 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="l8YcCZyo"; 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 4283fJ11dfz9s1x for ; Mon, 10 Sep 2018 20:08:39 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 9D5A7BC8; Mon, 10 Sep 2018 10:08:37 +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 7691F707 for ; Mon, 10 Sep 2018 10:08:36 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C3F5F71C for ; Mon, 10 Sep 2018 10:08:35 +0000 (UTC) Received: by mail-qk1-f196.google.com with SMTP id 130-v6so13934581qkd.10 for ; Mon, 10 Sep 2018 03:08:35 -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=O+xYJtEXTMqqeWPasyUu0Wq19XRixLj3sFBY1lwULFY=; b=l8YcCZyoXSn2ocWVBtz9i3TZOfQUcfYpb23LvhcI04ovIPsG2uhXVy3sYgYucKD97l 3fYZMFMP1LuxtfLVgA8cW1Fi580q8rAHYvZgUWTIaNleh3DlbLFm2CfTWlbaHUDlCUHT YKVQh7BXfHUkYeup61UgUb7KdV4T7BKzs4cJwQh9B1pTpB9AgysJQwjdEwSf8y8JT+g4 SUqW1Z/YqeVsckPicxqRA2CfcwYb8wsRahbhzC6IRG/AxVC2ZvI/ysLo35s0eNRoqJjk KkBHn8qVFqswequlFcEXE4ASq2yt8I9ptwDi1WzKRawYMKc+NUDbne4eCh1Q+s+yTUEW Vmaw== 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=O+xYJtEXTMqqeWPasyUu0Wq19XRixLj3sFBY1lwULFY=; b=JXgbjxxrC0agHT0TkvLA9ldvHDEthcbtCEWjLvlegP/2MnnmM9QOH7OFfBX2Q8sQVl Ygsx9JObpBDVdYsgc/l3/ik2fBxjdqWjkhl4ITuT/ckoGvRBuEhcDWGAdTjVrvGD+oL7 C0Z3uYgR+EX6EtbVdvrz+2u0O8IFm8rbYjlf67LcyeDgZ+o3minVNoyLcec2/6PRgP2A 4aoDWr1rE7oBBEp8yXtVfWeEsr8u1dDbB7yeTC0Y9IuuDJ4GtogxWSIpKrFM8bjw4a0G KDTBmFMzhvCdemH1RVJJEavW2H8m2qdwtyYqnEd/xJmpW2hJKFgeE2WexppiKIfxtHZg INEA== X-Gm-Message-State: APzg51Cn551IgVCiIWWVio4YTscZk/tulWvQvjj2iVbJJT/aORdWfOnv lxV7w/Mf5kfesvL8Wj82nfzqMVJKbZ8= X-Google-Smtp-Source: ANB0VdYF1RvCENzKf6WMvEVvnx99sQca9lewi5sPu7tozj+Z16hAAdBOQUzrQU56MZaCBAbdiJ9Bqw== X-Received: by 2002:a37:1f69:: with SMTP id f102-v6mr14756041qkf.9.1536574114679; Mon, 10 Sep 2018 03:08:34 -0700 (PDT) Received: from pieter-Netronome.netronome.com (host-79-78-33-110.static.as9105.net. [79.78.33.110]) by smtp.gmail.com with ESMTPSA id i85-v6sm11903677qkh.3.2018.09.10.03.08.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Sep 2018 03:08:34 -0700 (PDT) From: Pieter Jansen van Vuuren To: dev@openvswitch.org Date: Mon, 10 Sep 2018 11:08:25 +0100 Message-Id: <1536574105-5987-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: simon.horman@netronome.com, Pieter Jansen van Vuuren Subject: [ovs-dev] [PATCH] 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 | 4 ++++ lib/tc.c | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c index f7a175484..090662d54 100644 --- a/lib/netdev-tc-offloads.c +++ b/lib/netdev-tc-offloads.c @@ -1006,10 +1006,12 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, && (vid_mask || pcp_mask)) { if (vid_mask) { flower.key.vlan_id[0] = vlan_tci_to_vid(key->vlans[0].tci); + flower.mask.vlan_id[0] = vlan_tci_to_vid(mask->vlans[0].tci); VLOG_DBG_RL(&rl, "vlan_id[0]: %d\n", flower.key.vlan_id[0]); } if (pcp_mask) { flower.key.vlan_prio[0] = vlan_tci_to_pcp(key->vlans[0].tci); + flower.mask.vlan_prio[0] = vlan_tci_to_pcp(mask->vlans[0].tci); VLOG_DBG_RL(&rl, "vlan_prio[0]: %d\n", flower.key.vlan_prio[0]); } @@ -1035,10 +1037,12 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, && (vid_mask || pcp_mask)) { if (vid_mask) { flower.key.vlan_id[1] = vlan_tci_to_vid(key->vlans[1].tci); + flower.mask.vlan_id[1] = vlan_tci_to_vid(mask->vlans[1].tci); VLOG_DBG_RL(&rl, "vlan_id[1]: %d", flower.key.vlan_id[1]); } if (pcp_mask) { flower.key.vlan_prio[1] = vlan_tci_to_pcp(key->vlans[1].tci); + flower.mask.vlan_prio[1] = vlan_tci_to_pcp(mask->vlans[1].tci); VLOG_DBG_RL(&rl, "vlan_prio[1]: %d", flower.key.vlan_prio[1]); } flower.key.encap_eth_type[1] = flower.key.encap_eth_type[0]; diff --git a/lib/tc.c b/lib/tc.c index adcf31604..ac8db6159 100644 --- a/lib/tc.c +++ b/lib/tc.c @@ -403,10 +403,12 @@ nl_parse_flower_vlan(struct nlattr **attrs, struct tc_flower *flower) if (attrs[TCA_FLOWER_KEY_VLAN_ID]) { flower->key.vlan_id[0] = nl_attr_get_u16(attrs[TCA_FLOWER_KEY_VLAN_ID]); + flower->mask.vlan_id[0] = 0xffff; } if (attrs[TCA_FLOWER_KEY_VLAN_PRIO]) { flower->key.vlan_prio[0] = nl_attr_get_u8(attrs[TCA_FLOWER_KEY_VLAN_PRIO]); + flower->mask.vlan_prio[0] = 0xff; } if (!attrs[TCA_FLOWER_KEY_VLAN_ETH_TYPE]) { @@ -424,10 +426,12 @@ nl_parse_flower_vlan(struct nlattr **attrs, struct tc_flower *flower) if (attrs[TCA_FLOWER_KEY_CVLAN_ID]) { flower->key.vlan_id[1] = nl_attr_get_u16(attrs[TCA_FLOWER_KEY_CVLAN_ID]); + flower->mask.vlan_id[1] = 0xffff; } if (attrs[TCA_FLOWER_KEY_CVLAN_PRIO]) { flower->key.vlan_prio[1] = nl_attr_get_u8(attrs[TCA_FLOWER_KEY_CVLAN_PRIO]); + flower->mask.vlan_prio[1] = 0xff; } } @@ -1789,9 +1793,11 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct tc_flower *flower) } if (is_vlan) { - if (flower->key.vlan_id[0] || flower->key.vlan_prio[0]) { + if (flower->mask.vlan_id[0]) { nl_msg_put_u16(request, TCA_FLOWER_KEY_VLAN_ID, flower->key.vlan_id[0]); + } + if (flower->mask.vlan_prio[0]) { nl_msg_put_u8(request, TCA_FLOWER_KEY_VLAN_PRIO, flower->key.vlan_prio[0]); } @@ -1801,9 +1807,11 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct tc_flower *flower) } if (is_qinq) { - if (flower->key.vlan_id[1] || flower->key.vlan_prio[1]) { + if (flower->mask.vlan_id[1]) { nl_msg_put_u16(request, TCA_FLOWER_KEY_CVLAN_ID, flower->key.vlan_id[1]); + } + if (flower->mask.vlan_prio[1]) { nl_msg_put_u8(request, TCA_FLOWER_KEY_CVLAN_PRIO, flower->key.vlan_prio[1]); }