From patchwork Mon Mar 23 20:48:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 222027 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=-6.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS 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 B03BCC4332B for ; Mon, 23 Mar 2020 20:48:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 87D1E20753 for ; Mon, 23 Mar 2020 20:48:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XHi30JCR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727111AbgCWUs4 (ORCPT ); Mon, 23 Mar 2020 16:48:56 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:60942 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727101AbgCWUsz (ORCPT ); Mon, 23 Mar 2020 16:48:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584996534; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=J8GBJrmynL3sFQZ6PZZq1e3DQg4qaD9hya+bPOkskNo=; b=XHi30JCR1olo3wRB6heWUkO4bLqSQl2cgnOnZR4LsyxWJe2+UpSbmtSAWDKLkXzXjnoR/Y U+6WlIlzGvx3RC+OO2wr/SvzLt30BLqkkbIprsz7LhGlPxuMHm8aquXjk9zvlw6oGyqF8S 781AcvTt+L0JI33O80PorghYL5JJ10M= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-375-VMwzAXnUNjKyU8a0S2ppoA-1; Mon, 23 Mar 2020 16:48:53 -0400 X-MC-Unique: VMwzAXnUNjKyU8a0S2ppoA-1 Received: by mail-wm1-f72.google.com with SMTP id m4so504037wme.0 for ; Mon, 23 Mar 2020 13:48:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=J8GBJrmynL3sFQZ6PZZq1e3DQg4qaD9hya+bPOkskNo=; b=rm9irV4/7AmBzCeXxm8LWKQvDzbr1mGAjkO9moNGly7TUeT1lpowNl5QbzlJtNDPCi pubYp7HPqVFBhk6cRXu52SgyILIuekcllfDnRQNRw/6it+6DiBzLpcAD9Twn7falcYk5 72SYM7k6mKu0UYewVZEBcLcKVKTQechd/Xj+Rkve4IIAlcPGMHtAFGIsQpN2JLcccrSJ JtpfIE/wTrs+PWPSJNakH2ldNWwn1ivKLDsfZZRaHM4Pvq+0Fb+aMU7Z/a6fH5PNzKyn lRm5jLlR5UnBwm2d2FCOrFcwntMwpLz+hAFHV0QXgBMgX5NZ1U00LWQQnM+9hdUMQBcp YkPQ== X-Gm-Message-State: ANhLgQ0+nr66bToM3bmf/ZFmc8er0yNIfVFan0N/omjbZsbFS+WCwMzZ 8qoC7Pio28z9NRz1ZloG3y9CMNhvGv2Ep8BnAed4Jp64eTtV87aC5Fcphl6h5Av++qKeCG5PL8R JDT9xJVDb9VW+p7iw X-Received: by 2002:adf:8b1b:: with SMTP id n27mr31840002wra.349.1584996531928; Mon, 23 Mar 2020 13:48:51 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuFi2m1LfcaXUrU/gldwuT2pBbK8k4lrH0v3ay125V26Ga92TUppZgLp5VtX5U2EDCmObrT1g== X-Received: by 2002:adf:8b1b:: with SMTP id n27mr31839991wra.349.1584996531771; Mon, 23 Mar 2020 13:48:51 -0700 (PDT) Received: from pc-3.home (2a01cb0585138800b113760e11343d15.ipv6.abo.wanadoo.fr. [2a01:cb05:8513:8800:b113:760e:1134:3d15]) by smtp.gmail.com with ESMTPSA id g127sm1100342wmf.10.2020.03.23.13.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2020 13:48:51 -0700 (PDT) Date: Mon, 23 Mar 2020 21:48:49 +0100 From: Guillaume Nault To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, Jamal Hadi Salim , Cong Wang , Jiri Pirko Subject: [PATCH net-next 2/4] cls_flower: Add extack support for mpls options Message-ID: <6a3a85b072832c1f8d83f3a4aba759f5f3a8777d.1584995986.git.gnault@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Pass extack down to fl_set_key_mpls() and set message on error. Signed-off-by: Guillaume Nault --- net/sched/cls_flower.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 258dc45ab7e3..544cc7b490a3 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -766,7 +766,8 @@ static int fl_set_key_port_range(struct nlattr **tb, struct fl_flow_key *key, static int fl_set_key_mpls(struct nlattr **tb, struct flow_dissector_key_mpls *key_val, - struct flow_dissector_key_mpls *key_mask) + struct flow_dissector_key_mpls *key_mask, + struct netlink_ext_ack *extack) { if (tb[TCA_FLOWER_KEY_MPLS_TTL]) { key_val->mpls_ttl = nla_get_u8(tb[TCA_FLOWER_KEY_MPLS_TTL]); @@ -775,24 +776,36 @@ static int fl_set_key_mpls(struct nlattr **tb, if (tb[TCA_FLOWER_KEY_MPLS_BOS]) { u8 bos = nla_get_u8(tb[TCA_FLOWER_KEY_MPLS_BOS]); - if (bos & ~MPLS_BOS_MASK) + if (bos & ~MPLS_BOS_MASK) { + NL_SET_ERR_MSG_ATTR(extack, + tb[TCA_FLOWER_KEY_MPLS_BOS], + "Bottom Of Stack (BOS) must be 0 or 1"); return -EINVAL; + } key_val->mpls_bos = bos; key_mask->mpls_bos = MPLS_BOS_MASK; } if (tb[TCA_FLOWER_KEY_MPLS_TC]) { u8 tc = nla_get_u8(tb[TCA_FLOWER_KEY_MPLS_TC]); - if (tc & ~MPLS_TC_MASK) + if (tc & ~MPLS_TC_MASK) { + NL_SET_ERR_MSG_ATTR(extack, + tb[TCA_FLOWER_KEY_MPLS_TC], + "Traffic Class (TC) must be between 0 and 7"); return -EINVAL; + } key_val->mpls_tc = tc; key_mask->mpls_tc = MPLS_TC_MASK; } if (tb[TCA_FLOWER_KEY_MPLS_LABEL]) { u32 label = nla_get_u32(tb[TCA_FLOWER_KEY_MPLS_LABEL]); - if (label & ~MPLS_LABEL_MASK) + if (label & ~MPLS_LABEL_MASK) { + NL_SET_ERR_MSG_ATTR(extack, + tb[TCA_FLOWER_KEY_MPLS_LABEL], + "Label must be between 0 and 1048575"); return -EINVAL; + } key_val->mpls_label = label; key_mask->mpls_label = MPLS_LABEL_MASK; } @@ -1364,7 +1377,7 @@ static int fl_set_key(struct net *net, struct nlattr **tb, sizeof(key->icmp.code)); } else if (key->basic.n_proto == htons(ETH_P_MPLS_UC) || key->basic.n_proto == htons(ETH_P_MPLS_MC)) { - ret = fl_set_key_mpls(tb, &key->mpls, &mask->mpls); + ret = fl_set_key_mpls(tb, &key->mpls, &mask->mpls, extack); if (ret) return ret; } else if (key->basic.n_proto == htons(ETH_P_ARP) || From patchwork Mon Mar 23 20:48:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 222026 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=-6.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS 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 356DDC54FCF for ; Mon, 23 Mar 2020 20:49:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0C27D20719 for ; Mon, 23 Mar 2020 20:49:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ac33ep1L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727121AbgCWUtC (ORCPT ); Mon, 23 Mar 2020 16:49:02 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:27507 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726173AbgCWUtA (ORCPT ); Mon, 23 Mar 2020 16:49:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584996539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YusDrJHgpQYBMdm47W+/18/y89tRNu/kM9vUiAgJIuU=; b=ac33ep1LK+DSU811Ub9slodt07ci/N9o2qzmepVPFMEWZzaiiQEUbjOddGnFAfQv45b6s1 /46yUtlLX21YCGDMdHfV/93bQCiyCXrM8qnZL/KXsW5zosODWvEMTiEmsrSzevJivY50cm EifoBHvmxcICP8KrPYsB3o39+ZHmE84= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-261-Vkk_CHQWOLK1Agm8DHgnxg-1; Mon, 23 Mar 2020 16:48:57 -0400 X-MC-Unique: Vkk_CHQWOLK1Agm8DHgnxg-1 Received: by mail-wr1-f70.google.com with SMTP id d17so7980687wrs.7 for ; Mon, 23 Mar 2020 13:48:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=YusDrJHgpQYBMdm47W+/18/y89tRNu/kM9vUiAgJIuU=; b=PXuoXk4sLyba15bRS0qXoEJfX/lo5eOiqXHhP/9vlkfLeabLZey9+c/Dqf7+HxahL9 LOJlj2Xn37ypBYUKoJ5L+zfB3Q8jAow3wq115LVM8le3hIIVfnJHqTQkPV2uMhzOSa1L HOQyIhx7JZP1Xz1ozQONpL+70XKk9Pf7q4SWwdlf99WCR+i+PPVNjdksqvMfr1ruvD4z 69PNK9pp1V65BAPWx0KkpxwDszSmTjMXgr4KY3dvYDre+28617M+wYc2MqarAQ4BU3TB pcErzECTMH7INCl6VqOFFPpjHnEfjNAcx+V9oacrebngP2YakS4v3Lrw84wzhGjdZKZq DC4Q== X-Gm-Message-State: ANhLgQ0x13ALv4nhag83t3cDOIvyHjQP6Dq4YhZjBHKDM4tlOwueRfcw ydCsBoT0D8XWjvVhFAVb0NUQWfoj6RR1WOkKXMKtOBITdbsbOg1+B1EQDl9i0PqMU5BlSpfJO+1 Hw9RqUt8hxsVerF44 X-Received: by 2002:adf:fa85:: with SMTP id h5mr6806679wrr.63.1584996536431; Mon, 23 Mar 2020 13:48:56 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuF399OftZU7Uwj9+P3HzHWVNXViaK3rhvjWVCMVM83ODrG9kdEcufqo62hvpKTTcDu+d5vFA== X-Received: by 2002:adf:fa85:: with SMTP id h5mr6806659wrr.63.1584996536185; Mon, 23 Mar 2020 13:48:56 -0700 (PDT) Received: from pc-3.home (2a01cb0585138800b113760e11343d15.ipv6.abo.wanadoo.fr. [2a01:cb05:8513:8800:b113:760e:1134:3d15]) by smtp.gmail.com with ESMTPSA id i12sm25873362wro.46.2020.03.23.13.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2020 13:48:55 -0700 (PDT) Date: Mon, 23 Mar 2020 21:48:53 +0100 From: Guillaume Nault To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, Jamal Hadi Salim , Cong Wang , Jiri Pirko Subject: [PATCH net-next 4/4] cls_flower: Add extack support for flags key Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Pass extack down to fl_set_key_flags() and set message on error. Signed-off-by: Guillaume Nault --- net/sched/cls_flower.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 5811dd971ee5..9b6acd736dc8 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -856,14 +856,16 @@ static void fl_set_key_flag(u32 flower_key, u32 flower_mask, } } -static int fl_set_key_flags(struct nlattr **tb, - u32 *flags_key, u32 *flags_mask) +static int fl_set_key_flags(struct nlattr **tb, u32 *flags_key, + u32 *flags_mask, struct netlink_ext_ack *extack) { u32 key, mask; /* mask is mandatory for flags */ - if (!tb[TCA_FLOWER_KEY_FLAGS_MASK]) + if (!tb[TCA_FLOWER_KEY_FLAGS_MASK]) { + NL_SET_ERR_MSG(extack, "Missing flags mask"); return -EINVAL; + } key = be32_to_cpu(nla_get_u32(tb[TCA_FLOWER_KEY_FLAGS])); mask = be32_to_cpu(nla_get_u32(tb[TCA_FLOWER_KEY_FLAGS_MASK])); @@ -1474,7 +1476,8 @@ static int fl_set_key(struct net *net, struct nlattr **tb, return ret; if (tb[TCA_FLOWER_KEY_FLAGS]) - ret = fl_set_key_flags(tb, &key->control.flags, &mask->control.flags); + ret = fl_set_key_flags(tb, &key->control.flags, + &mask->control.flags, extack); return ret; }