From patchwork Sun May 30 11:40:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Sukholitko X-Patchwork-Id: 450416 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCE9BC47089 for ; Sun, 30 May 2021 11:41:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 953AB60230 for ; Sun, 30 May 2021 11:41:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229580AbhE3LnZ (ORCPT ); Sun, 30 May 2021 07:43:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229800AbhE3LnZ (ORCPT ); Sun, 30 May 2021 07:43:25 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4713EC061574 for ; Sun, 30 May 2021 04:41:47 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id x10so2888989plg.3 for ; Sun, 30 May 2021 04:41:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version; bh=zovtuEpe5DU0SNDUMeu1JyK7ITPBpz0Dc3RCxQCL1KY=; b=R/ojG1I6KyJbkbHkxzmtfnPkIFQGBEhW47jECtBTn6gfRDOfozxFR4J10ajMzf/IcM ccEfZTaKX2Tv/XJbZ8e6GxYS/FTqZi27Q9v9IhuY8QXqOG6pkpWaFF5Xrn5C4UUpPP7x W97Xpht9CTtxcWhttQk9jU3QDWyxSim1KLWlg= 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:in-reply-to :references:mime-version; bh=zovtuEpe5DU0SNDUMeu1JyK7ITPBpz0Dc3RCxQCL1KY=; b=mFVae3AY4D9C44WkKiGCqIze23FiNJZJUqFBNpyRPVLWEbZ4rOWAjbaqakxA48wM+T RgGA38tUf2JA3M+43TuwEa7nW94UbKNllw1pgm7q2xdMH0RbFfe8ICGC9Y7/0EuHawnT yflqIvgLSHcK1a4DUkN+QnaEePaJmt9ZVT19F5Td4Gy8eEUERKDKW+2SFjodNzSflfIF 3Duddr+u12ha1mU4iJVaxHHmJ0j/gunfW0qrOGt3DxmtQiHt2xvnbvsWKi9sQ7jNxpQP k3zBzzzJx507xxl2s+o0OYBoRAePWxxMhaKM69kgyJfeMfZlzixmdnAt2XJjZEdwHmW9 zhbg== X-Gm-Message-State: AOAM532yRezo1syqMHARWnTCkP1qbi4BC6jHDzU4hZH61ys0n+BdfCRf bQmKCya5cLbAQRjqoNtyGWubYA== X-Google-Smtp-Source: ABdhPJwfEE/JdsLGRjkYlwdc4OtTscgN37CdPC+Rqws+UNJAHfIj3wB4y7QYKw667gfROrwtmo/TtA== X-Received: by 2002:a17:902:c3d5:b029:100:742f:fce9 with SMTP id j21-20020a170902c3d5b0290100742ffce9mr12363207plj.46.1622374906752; Sun, 30 May 2021 04:41:46 -0700 (PDT) Received: from localhost.localdomain ([192.19.250.250]) by smtp.gmail.com with ESMTPSA id o17sm8126093pjp.33.2021.05.30.04.41.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 May 2021 04:41:46 -0700 (PDT) From: Boris Sukholitko To: netdev@vger.kernel.org, Jamal Hadi Salim , Jiri Pirko , Cong Wang Cc: linux-kselftest@vger.kernel.org, shuah@kernel.org, Ilya Lifshits , Shmulik Ladkani , Jakub Kicinski , Davide Caratti , Boris Sukholitko Subject: [PATCH net-next v3 2/3] net/sched: act_vlan: No dump for unset priority Date: Sun, 30 May 2021 14:40:51 +0300 Message-Id: <20210530114052.16483-3-boris.sukholitko@broadcom.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210530114052.16483-1-boris.sukholitko@broadcom.com> References: <20210530114052.16483-1-boris.sukholitko@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Dump vlan priority only if it has been previously set. Fix the tests accordingly. Signed-off-by: Boris Sukholitko --- net/sched/act_vlan.c | 19 ++++++++++++++----- .../tc-testing/tc-tests/actions/vlan.json | 4 ++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c index a108469c664f..ccd1acfa4c55 100644 --- a/net/sched/act_vlan.c +++ b/net/sched/act_vlan.c @@ -307,8 +307,8 @@ static int tcf_vlan_dump(struct sk_buff *skb, struct tc_action *a, (nla_put_u16(skb, TCA_VLAN_PUSH_VLAN_ID, p->tcfv_push_vid) || nla_put_be16(skb, TCA_VLAN_PUSH_VLAN_PROTOCOL, p->tcfv_push_proto) || - (nla_put_u8(skb, TCA_VLAN_PUSH_VLAN_PRIORITY, - p->tcfv_push_prio)))) + (p->tcfv_push_prio_exists && + nla_put_u8(skb, TCA_VLAN_PUSH_VLAN_PRIORITY, p->tcfv_push_prio)))) goto nla_put_failure; if (p->tcfv_action == TCA_VLAN_ACT_PUSH_ETH) { @@ -362,10 +362,19 @@ static int tcf_vlan_search(struct net *net, struct tc_action **a, u32 index) static size_t tcf_vlan_get_fill_size(const struct tc_action *act) { - return nla_total_size(sizeof(struct tc_vlan)) + struct tcf_vlan *v = to_vlan(act); + struct tcf_vlan_params *p; + size_t ret = nla_total_size(sizeof(struct tc_vlan)) + nla_total_size(sizeof(u16)) /* TCA_VLAN_PUSH_VLAN_ID */ - + nla_total_size(sizeof(u16)) /* TCA_VLAN_PUSH_VLAN_PROTOCOL */ - + nla_total_size(sizeof(u8)); /* TCA_VLAN_PUSH_VLAN_PRIORITY */ + + nla_total_size(sizeof(u16)); /* TCA_VLAN_PUSH_VLAN_PROTOCOL */ + + spin_lock_bh(&v->tcf_lock); + p = rcu_dereference_protected(v->vlan_p, lockdep_is_held(&v->tcf_lock)); + if (p->tcfv_push_prio_exists) + ret += nla_total_size(sizeof(u8)); /* TCA_VLAN_PUSH_VLAN_PRIORITY */ + spin_unlock_bh(&v->tcf_lock); + + return ret; } static struct tc_action_ops act_vlan_ops = { diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/vlan.json b/tools/testing/selftests/tc-testing/tc-tests/actions/vlan.json index 527ce5410314..1d9d261aa0b3 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/vlan.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/vlan.json @@ -463,7 +463,7 @@ "cmdUnderTest": "$TC actions add action vlan modify protocol 802.1Q id 5 index 100", "expExitCode": "0", "verifyCmd": "$TC actions get action vlan index 100", - "matchPattern": "action order [0-9]+: vlan.*modify id 100 protocol 802.1Q priority 0 pipe.*index 100 ref", + "matchPattern": "action order [0-9]+: vlan.*modify id 100 protocol 802.1Q pipe.*index 100 ref", "matchCount": "0", "teardown": [ "$TC actions flush action vlan" @@ -487,7 +487,7 @@ "cmdUnderTest": "$TC actions add action vlan modify protocol 802.1ad id 500 reclassify index 12", "expExitCode": "0", "verifyCmd": "$TC actions get action vlan index 12", - "matchPattern": "action order [0-9]+: vlan.*modify id 500 protocol 802.1ad priority 0 reclassify.*index 12 ref", + "matchPattern": "action order [0-9]+: vlan.*modify id 500 protocol 802.1ad reclassify.*index 12 ref", "matchCount": "1", "teardown": [ "$TC actions flush action vlan"