From patchwork Tue Jan 16 17:20:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 861785 X-Patchwork-Delegate: davem@davemloft.net 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=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="JCSnt1/N"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zLcSV0KNmz9t6N for ; Wed, 17 Jan 2018 04:20:58 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751112AbeAPRUx (ORCPT ); Tue, 16 Jan 2018 12:20:53 -0500 Received: from mail-it0-f66.google.com ([209.85.214.66]:43356 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750876AbeAPRUv (ORCPT ); Tue, 16 Jan 2018 12:20:51 -0500 Received: by mail-it0-f66.google.com with SMTP id u62so5753186ita.2 for ; Tue, 16 Jan 2018 09:20:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=d3qLS/5oik2rvOo53xyrW0DlATNQt5y9Yi7hIBVfhsw=; b=JCSnt1/N2XQpGFJZOy0ieuoIn2KAPCwIZyO/KzKH1Lx7yMCwCNzsRoB1q0o4fgH7zG lR2i9LWQWcAZcCEUiPDKaLHsfZ0xzufbKqh3TWHqRtgvUb/vc5oQh51uYmK455Uin4fj laTRP1lsTjps4H662rCRiqruZ8zSLhcoIu4Ub4mUhAkGAKjDBiMTgKqpb/TZ3sRTqKIj Of2ZhjS7AM3u8PnGFg4TVsq42yu9dIidZ0b2OYrmvMtoTIh1Qk+rY6McNh0gkiq9haOv tZ96jIMmzMfnV8fQuLRhCd2EOb9H8UAtmpl/MfYa5qizYS0iH2lEgSBNKsU81+vvB8Ow K6aA== 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; bh=d3qLS/5oik2rvOo53xyrW0DlATNQt5y9Yi7hIBVfhsw=; b=ZD0MbfBuYiIxcCMP77qc+2cfQGlufR2CwlSWJBzgRaddWO7mQC37iuqfg9Sf8QSzI3 IvujPg9m3Rn2qygg+/n1K1Ioa55q7GHgFksrLtb7maGYsXUAAbbed+IIyX/xrh9+hQUp tXzQoe4KP/Him6mlSKTBWOu/5DL+yzP06HB6l/2e9TrutnX13Skq3oy3UyX9KILo+Gda ptfdnPSVXPyxE38kDo55jFnBFqmeZTxnfB4QmrdJ0rOPHmwVfJ63+pUBQHbP7MvTmSBF 6yu6LwytTe/S+U/JGRn8oNy6IdZzay+sGrXPVnK3bplsh8mU1iLMraX3Pf1swiUMltVH qYow== X-Gm-Message-State: AKwxytev0mjOoQELSZY+5emQrPfbC/7IKdx/o+aeqgbWalqd8AyHCRUp kiWsqpZCHF2QEzsCoQdjIQxLpw== X-Google-Smtp-Source: ACJfBoseVMRwQzmXOXfzdCar2BPVNnl6PTgI4xIKZr4timYjN/eiBpGV/C3yXhId3PdU38CLRixKGA== X-Received: by 10.36.142.70 with SMTP id h67mr15320725ite.6.1516123250726; Tue, 16 Jan 2018 09:20:50 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id a13sm1353124itj.33.2018.01.16.09.20.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2018 09:20:50 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring Subject: [PATCH net-next 1/8] net: sched: cls: fix code style issues Date: Tue, 16 Jan 2018 12:20:20 -0500 Message-Id: <20180116172027.22128-2-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180116172027.22128-1-aring@mojatatu.com> References: <20180116172027.22128-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch changes some code style issues pointed out by checkpatch inside the TC cls subsystem. Signed-off-by: Alexander Aring --- include/net/sch_generic.h | 3 ++- net/sched/cls_api.c | 2 +- net/sched/cls_matchall.c | 2 +- net/sched/cls_u32.c | 8 ++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index ac029d5d88e4..b6ca86a8caeb 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -233,7 +233,8 @@ struct tcf_proto_ops { struct tcf_proto*, unsigned long, u32 handle, struct nlattr **, void **, bool); - int (*delete)(struct tcf_proto*, void *, bool*); + int (*delete)(struct tcf_proto *tp, void *arg, + bool *last); void (*walk)(struct tcf_proto*, struct tcf_walker *arg); void (*bind_class)(void *, u32, unsigned long); diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 6708b6953bfa..01d09055707d 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -780,7 +780,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, parent = q->handle; } else { q = qdisc_lookup(dev, TC_H_MAJ(t->tcm_parent)); - if (q == NULL) + if (!q) return -EINVAL; } diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c index 66d4e0099158..634114111adf 100644 --- a/net/sched/cls_matchall.c +++ b/net/sched/cls_matchall.c @@ -202,7 +202,7 @@ static int mall_change(struct net *net, struct sk_buff *in_skb, goto err_set_parms; if (!tc_skip_hw(new->flags)) { - err = mall_replace_hw_filter(tp, new, (unsigned long) new); + err = mall_replace_hw_filter(tp, new, (unsigned long)new); if (err) goto err_replace_hw_filter; } diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 507859cdd1cb..2e1b4580f798 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -782,7 +782,7 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp, if (handle) { ht_down = u32_lookup_ht(ht->tp_c, handle); - if (ht_down == NULL) + if (!ht_down) return -EINVAL; ht_down->refcnt++; } @@ -906,7 +906,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, size_t size; #endif - if (opt == NULL) + if (!opt) return handle ? -EINVAL : 0; err = nla_parse_nested(tb, TCA_U32_MAX, opt, u32_policy, NULL); @@ -1010,7 +1010,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, htid = ht->handle; } else { ht = u32_lookup_ht(tp->data, TC_U32_HTID(htid)); - if (ht == NULL) + if (!ht) return -EINVAL; } } else { @@ -1022,7 +1022,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, return -EINVAL; if (handle) { - if (TC_U32_HTID(handle) && TC_U32_HTID(handle^htid)) + if (TC_U32_HTID(handle) && TC_U32_HTID(handle ^ htid)) return -EINVAL; handle = htid | TC_U32_NODE(handle); err = idr_alloc_ext(&ht->handle_idr, NULL, NULL, From patchwork Tue Jan 16 17:20:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 861794 X-Patchwork-Delegate: davem@davemloft.net 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=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="TX6Lt+qb"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zLcTR19zKz9sBW for ; Wed, 17 Jan 2018 04:21:47 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751050AbeAPRVp (ORCPT ); Tue, 16 Jan 2018 12:21:45 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:35525 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751002AbeAPRUw (ORCPT ); Tue, 16 Jan 2018 12:20:52 -0500 Received: by mail-io0-f196.google.com with SMTP id m11so8213527iob.2 for ; Tue, 16 Jan 2018 09:20:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VNfmSHPHWMxouPDfB1YU0ujPFGAuDWICB6SnonsJBkk=; b=TX6Lt+qbJC4h0EyaLo0Qn199ZUWp9NMvGe6RwHfg5IA8/lSD0pl5PQJSDvWevhAxq7 2VdPxRrBZ8TT+x1nF8O81fbywk4AlF8NfJ4f3rYz14FK+vrMl8WPO73nKMQuVd+roZwy 86SwtyQzydJ8oKkaP1rqJufodrBpuaOm8fiV0N66YKvQpZ6zyFYhOv56upEMO/oErLHN CJ6OIWv8K+AYVxFeEuFNYx+LuMzntIERLi0WWC7LKuAg1J2Y9LW4VdosUgETZvdYBeJa rMp5NiYqqochLTd3rz0ZL3IP3VUIMTQ4mHDagsjpGG5vebbCDR6rcTZOka1KKzUJdWFI wCqw== 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; bh=VNfmSHPHWMxouPDfB1YU0ujPFGAuDWICB6SnonsJBkk=; b=RYkwODMAVQbsv0sCaJQJ5BHjJmwRJRKE2Nr0erj3eCnwBFFFY/7HjHC4dp4DAO3al9 LzSNWtPg/IjH6dtDmbYPNnEyxCzT3ZA7UdgOUwF+N7JgVBkfiT9hWlazgd8IKRbLEiDM QRzoI0z7nPE9mUiTsrRpIBTSjabqRILtWQr5qY3oRQw60T4XJk0AMf1ZDU4S6EzxWqGQ c6eL5Q8Bx9agAvDWtrtV4bm2Zz39SAXq+r4KKUiMiVC8BJrgGFHTa6cMFQyut+6r/cqj AXVsDEWqgaqGPQU/aLbHhqzoxGq+Iv+OcL4nuDsunHxxSV0QFXXbLSKgYKr3j/mX0kcJ 0U/Q== X-Gm-Message-State: AKwxytcqTfzzErrkTY9RmmRmyEzpnDIJlPgBYSpetsVdokAgODii/B4F Ct60WkmesdX03D9p6X1mKWMC1w== X-Google-Smtp-Source: ACJfBotAplDNumFCI4ajq1qX9WmIgSwZINhfmu67N6CAU0ZPWO/txzYWIcZPg+wp+zhTQNWkhDHaug== X-Received: by 10.107.142.68 with SMTP id q65mr6816685iod.133.1516123251844; Tue, 16 Jan 2018 09:20:51 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id a13sm1353124itj.33.2018.01.16.09.20.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2018 09:20:51 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCH net-next 2/8] net: sched: cls_api: handle generic cls errors Date: Tue, 16 Jan 2018 12:20:21 -0500 Message-Id: <20180116172027.22128-3-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180116172027.22128-1-aring@mojatatu.com> References: <20180116172027.22128-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack support for generic cls handling. The extack will be set deeper to each called function which is not part of netdev core api. Cc: David Ahern Signed-off-by: Alexander Aring --- net/sched/cls_api.c | 55 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 01d09055707d..c25a9b4bcb4b 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -122,7 +122,8 @@ static inline u32 tcf_auto_prio(struct tcf_proto *tp) static struct tcf_proto *tcf_proto_create(const char *kind, u32 protocol, u32 prio, u32 parent, struct Qdisc *q, - struct tcf_chain *chain) + struct tcf_chain *chain, + struct netlink_ext_ack *extack) { struct tcf_proto *tp; int err; @@ -148,6 +149,7 @@ static struct tcf_proto *tcf_proto_create(const char *kind, u32 protocol, module_put(tp->ops->owner); err = -EAGAIN; } else { + NL_SET_ERR_MSG(extack, "TC classifier not found"); err = -ENOENT; } goto errout; @@ -662,7 +664,8 @@ static int tfilter_notify(struct net *net, struct sk_buff *oskb, static int tfilter_del_notify(struct net *net, struct sk_buff *oskb, struct nlmsghdr *n, struct tcf_proto *tp, struct Qdisc *q, u32 parent, - void *fh, bool unicast, bool *last) + void *fh, bool unicast, bool *last, + struct netlink_ext_ack *extack) { struct sk_buff *skb; u32 portid = oskb ? NETLINK_CB(oskb).portid : 0; @@ -674,6 +677,7 @@ static int tfilter_del_notify(struct net *net, struct sk_buff *oskb, if (tcf_fill_node(net, skb, tp, q, parent, fh, portid, n->nlmsg_seq, n->nlmsg_flags, RTM_DELTFILTER) <= 0) { + NL_SET_ERR_MSG(extack, "Failed to build del event notification"); kfree_skb(skb); return -EINVAL; } @@ -687,8 +691,11 @@ static int tfilter_del_notify(struct net *net, struct sk_buff *oskb, if (unicast) return netlink_unicast(net->rtnl, skb, portid, MSG_DONTWAIT); - return rtnetlink_send(skb, net, portid, RTNLGRP_TC, - n->nlmsg_flags & NLM_F_ECHO); + err = rtnetlink_send(skb, net, portid, RTNLGRP_TC, + n->nlmsg_flags & NLM_F_ECHO); + if (err < 0) + NL_SET_ERR_MSG(extack, "Failed to send filter delete notification"); + return err; } static void tfilter_notify_chain(struct net *net, struct sk_buff *oskb, @@ -749,8 +756,10 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, if (prio == 0) { switch (n->nlmsg_type) { case RTM_DELTFILTER: - if (protocol || t->tcm_handle || tca[TCA_KIND]) + if (protocol || t->tcm_handle || tca[TCA_KIND]) { + NL_SET_ERR_MSG(extack, "Cannot flush filters with protocol, handle or kind set"); return -ENOENT; + } break; case RTM_NEWTFILTER: /* If no priority is provided by the user, @@ -763,6 +772,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, } /* fall-through */ default: + NL_SET_ERR_MSG(extack, "Invalid filter command with priority of zero"); return -ENOENT; } } @@ -780,23 +790,31 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, parent = q->handle; } else { q = qdisc_lookup(dev, TC_H_MAJ(t->tcm_parent)); - if (!q) + if (!q) { + NL_SET_ERR_MSG(extack, "Parent Qdisc doesn't exists"); return -EINVAL; + } } /* Is it classful? */ cops = q->ops->cl_ops; - if (!cops) + if (!cops) { + NL_SET_ERR_MSG(extack, "Qdisc not classful"); return -EINVAL; + } - if (!cops->tcf_block) + if (!cops->tcf_block) { + NL_SET_ERR_MSG(extack, "Class doesn't support blocks"); return -EOPNOTSUPP; + } /* Do we search for filter, attached to class? */ if (TC_H_MIN(parent)) { cl = cops->find(q, parent); - if (cl == 0) + if (cl == 0) { + NL_SET_ERR_MSG(extack, "Specified Class doesn't exist"); return -ENOENT; + } } /* And the last stroke */ @@ -808,12 +826,14 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, chain_index = tca[TCA_CHAIN] ? nla_get_u32(tca[TCA_CHAIN]) : 0; if (chain_index > TC_ACT_EXT_VAL_MASK) { + NL_SET_ERR_MSG(extack, "Specified chain index exceeds upper limit"); err = -EINVAL; goto errout; } chain = tcf_chain_get(block, chain_index, n->nlmsg_type == RTM_NEWTFILTER); if (!chain) { + NL_SET_ERR_MSG(extack, "Cannot find specified filter chain"); err = n->nlmsg_type == RTM_NEWTFILTER ? -ENOMEM : -EINVAL; goto errout; } @@ -829,6 +849,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, tp = tcf_chain_tp_find(chain, &chain_info, protocol, prio, prio_allocate); if (IS_ERR(tp)) { + NL_SET_ERR_MSG(extack, "Filter with specified priority/protocol not found"); err = PTR_ERR(tp); goto errout; } @@ -837,12 +858,14 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, /* Proto-tcf does not exist, create new one */ if (tca[TCA_KIND] == NULL || !protocol) { + NL_SET_ERR_MSG(extack, "Filter kind and protocol must be specified"); err = -EINVAL; goto errout; } if (n->nlmsg_type != RTM_NEWTFILTER || !(n->nlmsg_flags & NLM_F_CREATE)) { + NL_SET_ERR_MSG(extack, "Need both RTM_NEWTFILTER and NLM_F_CREATE to create a new filter"); err = -ENOENT; goto errout; } @@ -851,13 +874,14 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, prio = tcf_auto_prio(tcf_chain_tp_prev(&chain_info)); tp = tcf_proto_create(nla_data(tca[TCA_KIND]), - protocol, prio, parent, q, chain); + protocol, prio, parent, q, chain, extack); if (IS_ERR(tp)) { err = PTR_ERR(tp); goto errout; } tp_created = 1; } else if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], tp->ops->kind)) { + NL_SET_ERR_MSG(extack, "Specified filter kind does not match existing one"); err = -EINVAL; goto errout; } @@ -876,6 +900,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, if (n->nlmsg_type != RTM_NEWTFILTER || !(n->nlmsg_flags & NLM_F_CREATE)) { + NL_SET_ERR_MSG(extack, "Need both RTM_NEWTFILTER and NLM_F_CREATE to create a new filter"); err = -ENOENT; goto errout; } @@ -887,13 +912,14 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, if (n->nlmsg_flags & NLM_F_EXCL) { if (tp_created) tcf_proto_destroy(tp); + NL_SET_ERR_MSG(extack, "Exclusivity check success. Filter already exists"); err = -EEXIST; goto errout; } break; case RTM_DELTFILTER: err = tfilter_del_notify(net, skb, n, tp, q, parent, - fh, false, &last); + fh, false, &last, extack); if (err) goto errout; if (last) { @@ -904,8 +930,11 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, case RTM_GETTFILTER: err = tfilter_notify(net, skb, n, tp, q, parent, fh, RTM_NEWTFILTER, true); + if (err < 0) + NL_SET_ERR_MSG(extack, "Failed to send filter notify message"); goto errout; default: + NL_SET_ERR_MSG(extack, "Invalid netlink message type"); err = -EINVAL; goto errout; } @@ -1117,8 +1146,10 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, } #else if ((exts->action && tb[exts->action]) || - (exts->police && tb[exts->police])) + (exts->police && tb[exts->police])) { + NL_SET_ERR_MSG(extack, "Actions are not supported. Check compile options"); return -EOPNOTSUPP; + } #endif return 0; From patchwork Tue Jan 16 17:20:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 861787 X-Patchwork-Delegate: davem@davemloft.net 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=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="CLkjVhtd"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zLcSW4cDVz9t6N for ; Wed, 17 Jan 2018 04:20:59 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751201AbeAPRU5 (ORCPT ); Tue, 16 Jan 2018 12:20:57 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:35530 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751097AbeAPRUx (ORCPT ); Tue, 16 Jan 2018 12:20:53 -0500 Received: by mail-io0-f196.google.com with SMTP id m11so8213607iob.2 for ; Tue, 16 Jan 2018 09:20:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j3fAS2EFhAZdtbqCxRynDxzE4eVsV5tX5QPnL8Np7p8=; b=CLkjVhtdlCEaO4umlaO/ehCwNVG0BrSLfpAyZMLXftMvpHZ5gK+iAD6FTJvO58A+Q5 lZp9hMM5UEuqxVOUY5QDbwFuR4u8rAcAxUEknZxGy8BYeJWzISRtsvBhCs/JKTALUJIV 9P0XD/oHIrESlo3EbUpgy2wCX3oQjJC+5T1g46hSoIEhBW78gV0PN0pwgGnAxJ4eDuc8 GDlNKw1yuk0tvgmDy+xVBPcEqJeo7Q9GlFyWgfqM+j0J6rXbzkcg/+sm7OLGrkM/nDc3 LqMw/KJwC/+R136tqe4IrgIKioiPeGDeYbg9zyAMpRJDv51nNgezaluW0s7YGdQjGWq4 NfkA== 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; bh=j3fAS2EFhAZdtbqCxRynDxzE4eVsV5tX5QPnL8Np7p8=; b=iXVDeInn798aJrYw7FrfQsTb9J+d8Ps5GN73NETjyav6Sr9B4kl66Qw7pRpMvNiaBK 8z9C5jQKfJemHXQuKRNGNFV0ESoju/VF9/Z/eGl4GoWyyMu4Bgkqy7bLyUA8jUOTJfqH OVPdTBHtWOh3P1JvUQP4suVSGcTSJ3JBe5GuXzqDSQgdcVHYkuXNHzScAKz38JJKa0k4 ufXVmUc/xjADzZLftU+RkPf4kmC/0ckdthV+XNKP63pmA6qpqKejhYItNSJHfNm0Z7jO 7/OCo9r9w8IwQerQp0x0s/+8P0A5+yZNcGNGCSoN0DxI4EbdD6NSUBcLh4Vv9elaSSSy oFaQ== X-Gm-Message-State: AKGB3mIn6VhZU5dzKc2xo94JxAjT95c79ypDBqy23DslPpHNGgrMd7xC mzN/fKPO8ZM+qlAOGMiebsyrEA== X-Google-Smtp-Source: ACJfBos1ch/4oJdWXpVBd7nmX337DDz1/KtlGOpBnVm2o9RfGFIj/m+m425OeDo566pI96VtYl3IWw== X-Received: by 10.107.160.196 with SMTP id j187mr41036702ioe.186.1516123253097; Tue, 16 Jan 2018 09:20:53 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id a13sm1353124itj.33.2018.01.16.09.20.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2018 09:20:52 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCH net-next 3/8] net: sched: cls: add extack support for change callback Date: Tue, 16 Jan 2018 12:20:22 -0500 Message-Id: <20180116172027.22128-4-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180116172027.22128-1-aring@mojatatu.com> References: <20180116172027.22128-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack support for classifier change callback api. This prepares to handle extack support inside each specific classifier implementation. Cc: David Ahern Signed-off-by: Alexander Aring --- include/net/sch_generic.h | 3 ++- net/sched/cls_api.c | 3 ++- net/sched/cls_basic.c | 3 ++- net/sched/cls_bpf.c | 2 +- net/sched/cls_cgroup.c | 3 ++- net/sched/cls_flow.c | 2 +- net/sched/cls_flower.c | 2 +- net/sched/cls_fw.c | 2 +- net/sched/cls_matchall.c | 2 +- net/sched/cls_route.c | 3 ++- net/sched/cls_rsvp.h | 2 +- net/sched/cls_tcindex.c | 3 ++- net/sched/cls_u32.c | 3 ++- 13 files changed, 20 insertions(+), 13 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index b6ca86a8caeb..f999ee6bac2e 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -232,7 +232,8 @@ struct tcf_proto_ops { int (*change)(struct net *net, struct sk_buff *, struct tcf_proto*, unsigned long, u32 handle, struct nlattr **, - void **, bool); + void **, bool, + struct netlink_ext_ack *); int (*delete)(struct tcf_proto *tp, void *arg, bool *last); void (*walk)(struct tcf_proto*, struct tcf_walker *arg); diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index c25a9b4bcb4b..520b5deec7af 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -941,7 +941,8 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, } err = tp->ops->change(net, skb, tp, cl, t->tcm_handle, tca, &fh, - n->nlmsg_flags & NLM_F_CREATE ? TCA_ACT_NOREPLACE : TCA_ACT_REPLACE); + n->nlmsg_flags & NLM_F_CREATE ? TCA_ACT_NOREPLACE : TCA_ACT_REPLACE, + extack); if (err == 0) { if (tp_created) tcf_chain_tp_insert(chain, &chain_info, tp); diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c index 5f169ded347e..2cc38cd71938 100644 --- a/net/sched/cls_basic.c +++ b/net/sched/cls_basic.c @@ -175,7 +175,8 @@ static int basic_set_parms(struct net *net, struct tcf_proto *tp, static int basic_change(struct net *net, struct sk_buff *in_skb, struct tcf_proto *tp, unsigned long base, u32 handle, - struct nlattr **tca, void **arg, bool ovr) + struct nlattr **tca, void **arg, bool ovr, + struct netlink_ext_ack *extack) { int err; struct basic_head *head = rtnl_dereference(tp->root); diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c index 8d78e7f4ecc3..fcb831b3917e 100644 --- a/net/sched/cls_bpf.c +++ b/net/sched/cls_bpf.c @@ -449,7 +449,7 @@ static int cls_bpf_set_parms(struct net *net, struct tcf_proto *tp, static int cls_bpf_change(struct net *net, struct sk_buff *in_skb, struct tcf_proto *tp, unsigned long base, u32 handle, struct nlattr **tca, - void **arg, bool ovr) + void **arg, bool ovr, struct netlink_ext_ack *extack) { struct cls_bpf_head *head = rtnl_dereference(tp->root); struct cls_bpf_prog *oldprog = *arg; diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c index 309d5899265f..b74af0b55820 100644 --- a/net/sched/cls_cgroup.c +++ b/net/sched/cls_cgroup.c @@ -91,7 +91,8 @@ static void cls_cgroup_destroy_rcu(struct rcu_head *root) static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb, struct tcf_proto *tp, unsigned long base, u32 handle, struct nlattr **tca, - void **arg, bool ovr) + void **arg, bool ovr, + struct netlink_ext_ack *extack) { struct nlattr *tb[TCA_CGROUP_MAX + 1]; struct cls_cgroup_head *head = rtnl_dereference(tp->root); diff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c index 25c2a888e1f0..e944f01d5394 100644 --- a/net/sched/cls_flow.c +++ b/net/sched/cls_flow.c @@ -401,7 +401,7 @@ static void flow_destroy_filter(struct rcu_head *head) static int flow_change(struct net *net, struct sk_buff *in_skb, struct tcf_proto *tp, unsigned long base, u32 handle, struct nlattr **tca, - void **arg, bool ovr) + void **arg, bool ovr, struct netlink_ext_ack *extack) { struct flow_head *head = rtnl_dereference(tp->root); struct flow_filter *fold, *fnew; diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 6132a7317efa..998ee4faf934 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -852,7 +852,7 @@ static int fl_set_parms(struct net *net, struct tcf_proto *tp, static int fl_change(struct net *net, struct sk_buff *in_skb, struct tcf_proto *tp, unsigned long base, u32 handle, struct nlattr **tca, - void **arg, bool ovr) + void **arg, bool ovr, struct netlink_ext_ack *extack) { struct cls_fl_head *head = rtnl_dereference(tp->root); struct cls_fl_filter *fold = *arg; diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c index 20f0de1a960a..72784491ce20 100644 --- a/net/sched/cls_fw.c +++ b/net/sched/cls_fw.c @@ -257,7 +257,7 @@ static int fw_set_parms(struct net *net, struct tcf_proto *tp, static int fw_change(struct net *net, struct sk_buff *in_skb, struct tcf_proto *tp, unsigned long base, u32 handle, struct nlattr **tca, void **arg, - bool ovr) + bool ovr, struct netlink_ext_ack *extack) { struct fw_head *head = rtnl_dereference(tp->root); struct fw_filter *f = *arg; diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c index 634114111adf..4cfd293dbbd0 100644 --- a/net/sched/cls_matchall.c +++ b/net/sched/cls_matchall.c @@ -159,7 +159,7 @@ static int mall_set_parms(struct net *net, struct tcf_proto *tp, static int mall_change(struct net *net, struct sk_buff *in_skb, struct tcf_proto *tp, unsigned long base, u32 handle, struct nlattr **tca, - void **arg, bool ovr) + void **arg, bool ovr, struct netlink_ext_ack *extack) { struct cls_mall_head *head = rtnl_dereference(tp->root); struct nlattr *tb[TCA_MATCHALL_MAX + 1]; diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c index ac9a5b8825b9..bf305db65de0 100644 --- a/net/sched/cls_route.c +++ b/net/sched/cls_route.c @@ -471,7 +471,8 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp, static int route4_change(struct net *net, struct sk_buff *in_skb, struct tcf_proto *tp, unsigned long base, u32 handle, - struct nlattr **tca, void **arg, bool ovr) + struct nlattr **tca, void **arg, bool ovr, + struct netlink_ext_ack *extack) { struct route4_head *head = rtnl_dereference(tp->root); struct route4_filter __rcu **fp; diff --git a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h index cf325625c99d..d1f67529c01d 100644 --- a/net/sched/cls_rsvp.h +++ b/net/sched/cls_rsvp.h @@ -486,7 +486,7 @@ static int rsvp_change(struct net *net, struct sk_buff *in_skb, struct tcf_proto *tp, unsigned long base, u32 handle, struct nlattr **tca, - void **arg, bool ovr) + void **arg, bool ovr, struct netlink_ext_ack *extack) { struct rsvp_head *data = rtnl_dereference(tp->root); struct rsvp_filter *f, *nfp; diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c index 67467ae24c97..0ec84cf2d6b7 100644 --- a/net/sched/cls_tcindex.c +++ b/net/sched/cls_tcindex.c @@ -520,7 +520,8 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, static int tcindex_change(struct net *net, struct sk_buff *in_skb, struct tcf_proto *tp, unsigned long base, u32 handle, - struct nlattr **tca, void **arg, bool ovr) + struct nlattr **tca, void **arg, bool ovr, + struct netlink_ext_ack *extack) { struct nlattr *opt = tca[TCA_OPTIONS]; struct nlattr *tb[TCA_TCINDEX_MAX + 1]; diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 2e1b4580f798..25a014499afe 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -892,7 +892,8 @@ static struct tc_u_knode *u32_init_knode(struct tcf_proto *tp, static int u32_change(struct net *net, struct sk_buff *in_skb, struct tcf_proto *tp, unsigned long base, u32 handle, - struct nlattr **tca, void **arg, bool ovr) + struct nlattr **tca, void **arg, bool ovr, + struct netlink_ext_ack *extack) { struct tc_u_common *tp_c = tp->data; struct tc_u_hnode *ht; From patchwork Tue Jan 16 17:20:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 861793 X-Patchwork-Delegate: davem@davemloft.net 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=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="sPKdu2/R"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zLcTJ2jlpz9sCZ for ; Wed, 17 Jan 2018 04:21:40 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751415AbeAPRVY (ORCPT ); Tue, 16 Jan 2018 12:21:24 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:46831 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751131AbeAPRUz (ORCPT ); Tue, 16 Jan 2018 12:20:55 -0500 Received: by mail-io0-f196.google.com with SMTP id f34so12347598ioi.13 for ; Tue, 16 Jan 2018 09:20:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tcGmRoOdvEufVuQ6ygY+AAuiDY3GnAJchrrpo4gHpOM=; b=sPKdu2/R38rFJjx0p3YH+2bUrPnNURdEh/dTQm2Li2iy5XPcISjHIaQhlGgWTWwAjp iVlilrWW4edNOwnuOMT4EkMvmRT7plNbJJ137wiUCVxgBuJuZ+Mnf79j+d3+ZqCs4qPs KTFKj0UX265taWYdMtVUFH8RE2kfD3fixPtVAUvXYZeVZB6o0B06/kaB31tHU+ateBFM hNU+1CrlNf51ZbINQvgoRuvqP0B2TDcWdZC9elVR+iKzmPgDCPT6ISOwGeQPNIcZ9H5R BjhjqXsITDo8e8Zd89B8UtQXCXstE/6yHuvH4mKTXzMxyGawt6XJvFLM/tERUhkPlTyH u+3g== 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; bh=tcGmRoOdvEufVuQ6ygY+AAuiDY3GnAJchrrpo4gHpOM=; b=QCgRQBdWGFMdgtEGBP2IoZuBlZyutKXjg8/DIIyFDFxXsvkrFyQk4vRLsclx9e5TQE LvsgdkxEhaOqZhcYRBV16yd+bv0/7+IXRy7+MTQJ3MbgpXpHvmsFmCe5TPFCcYQvbQsX N45B/oIOO2+RjbDcTBHEzUdOQ/1DSyO3zYuArWVzim8DaWCngXgLy1x0kgnpcewZA6Xb 6lKbcC1NK6wkzTTJ59LDvxZ7cp5tCoFQL++t2Hd1rJ69KfH7ACNiGXbzR1atcucVE1bY iMV8nyL7ZEwCRkGOOMUS0HhRmmXDePh4cIpzOdIZhdI9BKRP7oDZayYxbql7aJhMh51u tndw== X-Gm-Message-State: AKwxyteEF1DXsNg9K3AJ6EhG6OdIGfLnojn9zg0R2CMaWhA3XTz1c2Mw dwKhPx6F1mSjzNP62Sz4Bcf9Tw== X-Google-Smtp-Source: ACJfBovl7LfgDn4V4zAvmlavp4vqiedmRVLw0p678zVbNDvJYxWGEmriCPT7MpY5WS+tjloj9bGE4A== X-Received: by 10.107.150.10 with SMTP id y10mr10453037iod.246.1516123254290; Tue, 16 Jan 2018 09:20:54 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id a13sm1353124itj.33.2018.01.16.09.20.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2018 09:20:53 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCH net-next 4/8] net: sched: cls: add extack support for tcf_exts_validate Date: Tue, 16 Jan 2018 12:20:23 -0500 Message-Id: <20180116172027.22128-5-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180116172027.22128-1-aring@mojatatu.com> References: <20180116172027.22128-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The tcf_exts_validate function calls the act api change callback. For preparing extack support for act api, this patch adds the extack as parameter for this function which is common used in cls implementations. Furthermore the tcf_exts_validate will call action init callback which prepares the TC action subsystem for extack support. Cc: David Ahern Signed-off-by: Alexander Aring --- include/net/pkt_cls.h | 3 ++- net/sched/cls_api.c | 3 ++- net/sched/cls_basic.c | 8 +++++--- net/sched/cls_bpf.c | 8 +++++--- net/sched/cls_cgroup.c | 3 ++- net/sched/cls_flow.c | 3 ++- net/sched/cls_flower.c | 8 +++++--- net/sched/cls_fw.c | 10 ++++++---- net/sched/cls_matchall.c | 8 +++++--- net/sched/cls_route.c | 6 +++--- net/sched/cls_rsvp.h | 2 +- net/sched/cls_tcindex.c | 6 +++--- net/sched/cls_u32.c | 10 ++++++---- 13 files changed, 47 insertions(+), 31 deletions(-) diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 9c341f003091..0286d42d08ef 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -368,7 +368,8 @@ tcf_exts_exec(struct sk_buff *skb, struct tcf_exts *exts, int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, struct nlattr *rate_tlv, - struct tcf_exts *exts, bool ovr); + struct tcf_exts *exts, bool ovr, + struct netlink_ext_ack *extack); void tcf_exts_destroy(struct tcf_exts *exts); void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src); int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts); diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 520b5deec7af..011fe66c82b5 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -1114,7 +1114,8 @@ void tcf_exts_destroy(struct tcf_exts *exts) EXPORT_SYMBOL(tcf_exts_destroy); int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, - struct nlattr *rate_tlv, struct tcf_exts *exts, bool ovr) + struct nlattr *rate_tlv, struct tcf_exts *exts, bool ovr, + struct netlink_ext_ack *extack) { #ifdef CONFIG_NET_CLS_ACT { diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c index 2cc38cd71938..b7bcf67641bf 100644 --- a/net/sched/cls_basic.c +++ b/net/sched/cls_basic.c @@ -152,11 +152,12 @@ static const struct nla_policy basic_policy[TCA_BASIC_MAX + 1] = { static int basic_set_parms(struct net *net, struct tcf_proto *tp, struct basic_filter *f, unsigned long base, struct nlattr **tb, - struct nlattr *est, bool ovr) + struct nlattr *est, bool ovr, + struct netlink_ext_ack *extack) { int err; - err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr); + err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, extack); if (err < 0) return err; @@ -222,7 +223,8 @@ static int basic_change(struct net *net, struct sk_buff *in_skb, fnew->handle = idr_index; } - err = basic_set_parms(net, tp, fnew, base, tb, tca[TCA_RATE], ovr); + err = basic_set_parms(net, tp, fnew, base, tb, tca[TCA_RATE], ovr, + extack); if (err < 0) { if (!fold) idr_remove_ext(&head->handle_idr, fnew->handle); diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c index fcb831b3917e..50abd71f99ed 100644 --- a/net/sched/cls_bpf.c +++ b/net/sched/cls_bpf.c @@ -400,7 +400,8 @@ static int cls_bpf_prog_from_efd(struct nlattr **tb, struct cls_bpf_prog *prog, static int cls_bpf_set_parms(struct net *net, struct tcf_proto *tp, struct cls_bpf_prog *prog, unsigned long base, - struct nlattr **tb, struct nlattr *est, bool ovr) + struct nlattr **tb, struct nlattr *est, bool ovr, + struct netlink_ext_ack *extack) { bool is_bpf, is_ebpf, have_exts = false; u32 gen_flags = 0; @@ -411,7 +412,7 @@ static int cls_bpf_set_parms(struct net *net, struct tcf_proto *tp, if ((!is_bpf && !is_ebpf) || (is_bpf && is_ebpf)) return -EINVAL; - ret = tcf_exts_validate(net, tp, tb, est, &prog->exts, ovr); + ret = tcf_exts_validate(net, tp, tb, est, &prog->exts, ovr, extack); if (ret < 0) return ret; @@ -497,7 +498,8 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb, prog->handle = handle; } - ret = cls_bpf_set_parms(net, tp, prog, base, tb, tca[TCA_RATE], ovr); + ret = cls_bpf_set_parms(net, tp, prog, base, tb, tca[TCA_RATE], ovr, + extack); if (ret < 0) goto errout_idr; diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c index b74af0b55820..aaafcf6965f7 100644 --- a/net/sched/cls_cgroup.c +++ b/net/sched/cls_cgroup.c @@ -122,7 +122,8 @@ static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb, if (err < 0) goto errout; - err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &new->exts, ovr); + err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &new->exts, ovr, + extack); if (err < 0) goto errout; diff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c index e944f01d5394..5bc702f66bb5 100644 --- a/net/sched/cls_flow.c +++ b/net/sched/cls_flow.c @@ -454,7 +454,8 @@ static int flow_change(struct net *net, struct sk_buff *in_skb, if (err < 0) goto err2; - err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &fnew->exts, ovr); + err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &fnew->exts, ovr, + extack); if (err < 0) goto err2; diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 998ee4faf934..b9664e1df8f0 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -826,11 +826,12 @@ static int fl_check_assign_mask(struct cls_fl_head *head, static int fl_set_parms(struct net *net, struct tcf_proto *tp, struct cls_fl_filter *f, struct fl_flow_mask *mask, unsigned long base, struct nlattr **tb, - struct nlattr *est, bool ovr) + struct nlattr *est, bool ovr, + struct netlink_ext_ack *extack) { int err; - err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr); + err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, extack); if (err < 0) return err; @@ -915,7 +916,8 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, } } - err = fl_set_parms(net, tp, fnew, &mask, base, tb, tca[TCA_RATE], ovr); + err = fl_set_parms(net, tp, fnew, &mask, base, tb, tca[TCA_RATE], ovr, + extack); if (err) goto errout_idr; diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c index 72784491ce20..72a924a38753 100644 --- a/net/sched/cls_fw.c +++ b/net/sched/cls_fw.c @@ -218,13 +218,15 @@ static const struct nla_policy fw_policy[TCA_FW_MAX + 1] = { static int fw_set_parms(struct net *net, struct tcf_proto *tp, struct fw_filter *f, struct nlattr **tb, - struct nlattr **tca, unsigned long base, bool ovr) + struct nlattr **tca, unsigned long base, bool ovr, + struct netlink_ext_ack *extack) { struct fw_head *head = rtnl_dereference(tp->root); u32 mask; int err; - err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &f->exts, ovr); + err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &f->exts, ovr, + extack); if (err < 0) return err; @@ -296,7 +298,7 @@ static int fw_change(struct net *net, struct sk_buff *in_skb, return err; } - err = fw_set_parms(net, tp, fnew, tb, tca, base, ovr); + err = fw_set_parms(net, tp, fnew, tb, tca, base, ovr, extack); if (err < 0) { tcf_exts_destroy(&fnew->exts); kfree(fnew); @@ -345,7 +347,7 @@ static int fw_change(struct net *net, struct sk_buff *in_skb, f->id = handle; f->tp = tp; - err = fw_set_parms(net, tp, f, tb, tca, base, ovr); + err = fw_set_parms(net, tp, f, tb, tca, base, ovr, extack); if (err < 0) goto errout; diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c index 4cfd293dbbd0..cd15f05d170e 100644 --- a/net/sched/cls_matchall.c +++ b/net/sched/cls_matchall.c @@ -141,11 +141,12 @@ static const struct nla_policy mall_policy[TCA_MATCHALL_MAX + 1] = { static int mall_set_parms(struct net *net, struct tcf_proto *tp, struct cls_mall_head *head, unsigned long base, struct nlattr **tb, - struct nlattr *est, bool ovr) + struct nlattr *est, bool ovr, + struct netlink_ext_ack *extack) { int err; - err = tcf_exts_validate(net, tp, tb, est, &head->exts, ovr); + err = tcf_exts_validate(net, tp, tb, est, &head->exts, ovr, extack); if (err < 0) return err; @@ -197,7 +198,8 @@ static int mall_change(struct net *net, struct sk_buff *in_skb, new->handle = handle; new->flags = flags; - err = mall_set_parms(net, tp, new, base, tb, tca[TCA_RATE], ovr); + err = mall_set_parms(net, tp, new, base, tb, tca[TCA_RATE], ovr, + extack); if (err) goto err_set_parms; diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c index bf305db65de0..d5a5e0bff136 100644 --- a/net/sched/cls_route.c +++ b/net/sched/cls_route.c @@ -389,7 +389,7 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, struct route4_filter *f, u32 handle, struct route4_head *head, struct nlattr **tb, struct nlattr *est, int new, - bool ovr) + bool ovr, struct netlink_ext_ack *extack) { u32 id = 0, to = 0, nhandle = 0x8000; struct route4_filter *fp; @@ -397,7 +397,7 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp, struct route4_bucket *b; int err; - err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr); + err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, extack); if (err < 0) return err; @@ -516,7 +516,7 @@ static int route4_change(struct net *net, struct sk_buff *in_skb, } err = route4_set_parms(net, tp, base, f, handle, head, tb, - tca[TCA_RATE], new, ovr); + tca[TCA_RATE], new, ovr, extack); if (err < 0) goto errout; diff --git a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h index d1f67529c01d..c27d23694002 100644 --- a/net/sched/cls_rsvp.h +++ b/net/sched/cls_rsvp.h @@ -511,7 +511,7 @@ static int rsvp_change(struct net *net, struct sk_buff *in_skb, err = tcf_exts_init(&e, TCA_RSVP_ACT, TCA_RSVP_POLICE); if (err < 0) return err; - err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e, ovr); + err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e, ovr, extack); if (err < 0) goto errout2; diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c index 0ec84cf2d6b7..9d6621caa92f 100644 --- a/net/sched/cls_tcindex.c +++ b/net/sched/cls_tcindex.c @@ -322,7 +322,7 @@ static int tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, u32 handle, struct tcindex_data *p, struct tcindex_filter_result *r, struct nlattr **tb, - struct nlattr *est, bool ovr) + struct nlattr *est, bool ovr, struct netlink_ext_ack *extack) { struct tcindex_filter_result new_filter_result, *old_r = r; struct tcindex_filter_result cr; @@ -334,7 +334,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, err = tcf_exts_init(&e, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE); if (err < 0) return err; - err = tcf_exts_validate(net, tp, tb, est, &e, ovr); + err = tcf_exts_validate(net, tp, tb, est, &e, ovr, extack); if (err < 0) goto errout; @@ -541,7 +541,7 @@ tcindex_change(struct net *net, struct sk_buff *in_skb, return err; return tcindex_set_parms(net, tp, base, handle, p, r, tb, - tca[TCA_RATE], ovr); + tca[TCA_RATE], ovr, extack); } static void tcindex_walk(struct tcf_proto *tp, struct tcf_walker *walker) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 25a014499afe..6b25bc741daf 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -764,11 +764,12 @@ static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = { static int u32_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, struct tc_u_hnode *ht, struct tc_u_knode *n, struct nlattr **tb, - struct nlattr *est, bool ovr) + struct nlattr *est, bool ovr, + struct netlink_ext_ack *extack) { int err; - err = tcf_exts_validate(net, tp, tb, est, &n->exts, ovr); + err = tcf_exts_validate(net, tp, tb, est, &n->exts, ovr, extack); if (err < 0) return err; @@ -936,7 +937,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, err = u32_set_parms(net, tp, base, rtnl_dereference(n->ht_up), new, tb, - tca[TCA_RATE], ovr); + tca[TCA_RATE], ovr, extack); if (err) { u32_destroy_key(tp, new, false); @@ -1083,7 +1084,8 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, } #endif - err = u32_set_parms(net, tp, base, ht, n, tb, tca[TCA_RATE], ovr); + err = u32_set_parms(net, tp, base, ht, n, tb, tca[TCA_RATE], ovr, + extack); if (err == 0) { struct tc_u_knode __rcu **ins; struct tc_u_knode *pins; From patchwork Tue Jan 16 17:20:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 861791 X-Patchwork-Delegate: davem@davemloft.net 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=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="GKWUF5gJ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zLcSv3Dpqz9sBW for ; Wed, 17 Jan 2018 04:21:19 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751390AbeAPRVQ (ORCPT ); Tue, 16 Jan 2018 12:21:16 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:34179 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751142AbeAPRU4 (ORCPT ); Tue, 16 Jan 2018 12:20:56 -0500 Received: by mail-io0-f193.google.com with SMTP id c17so17632384iod.1 for ; Tue, 16 Jan 2018 09:20:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vBgTlYKyr3jUmIW2wXxLyFxvs4M2LYVKdenvhXWgMVc=; b=GKWUF5gJ74cvUdROxsfgQbAR288PBMArzhRTwb1cFVbr3Na8cax6UtWA/2IKwGv4jw N4dbQNy6apUPxpl1wny877m9rk3qCLYY+SEzhXxwM3ceq3aJGQ9RCsbNfbN6fJXbtcFy Mgb2LoM4HIgxk+R7JAt15ZiuElMsFES95F8oad9gRUgU5U/ayzTwc73Wevqh0OrjXNCc QArHw4OLtHCNi+x5i/+nM9htJSv0ivRjI2Qcu9ZeKHFU29QL+05hhY+mgOiFc7Qe9Ijh Jt3KrYs0713yApqHXaynNXaH1PditgKcALtaKctXkkdsLEs7bxeREN5nDVFn5yJzhatn df3Q== 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; bh=vBgTlYKyr3jUmIW2wXxLyFxvs4M2LYVKdenvhXWgMVc=; b=N7+GaE0EZz7KBuSle2Er9rc0MlhWzYUpY1rLJixXSzH6/qiUncn7DMoEZqBsJFG5Cd V8RX3JhoDl5eYqdj1QcvXjQBSTJw4UYsuv+UXbJ2zyaG/ACZJn0Fq/tbEHcVVxy+JYCH /fLnD2ciAOVU6ERpj733d0ylz8uqVJMi6bpvyyrg8okUlNH5RqwSoi/zE4shUfvEAlQb d71tASieJbhQYj4//cOEL3Y9Gtc90kLkfQwnZ1FsCjpDtUma51VGE3uPw65riOl3x6gl XcphFYq74FkgQndSsYQazZiuYRRr3GGhGNhRQ4BswTPzEr6Vp9onklsnOngNOd3Kaclo sYGQ== X-Gm-Message-State: AKwxyte4dXUocneIag/bE5F7vYA9zyVEDIApb765tcj7UUsYr8uTxnDQ VxSkSbufX+iMg6uLCIDAgt6WMA== X-Google-Smtp-Source: ACJfBotxo8YS98cbvs3WUHTP5UxE0K5vJtSpvzGjSgzbbWSsPr5ZcROecrRaAI29w2SGZ5reTuscNQ== X-Received: by 10.107.35.85 with SMTP id j82mr38091769ioj.253.1516123255440; Tue, 16 Jan 2018 09:20:55 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id a13sm1353124itj.33.2018.01.16.09.20.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2018 09:20:55 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCH net-next 5/8] net: sched: cls: add extack support for delete callback Date: Tue, 16 Jan 2018 12:20:24 -0500 Message-Id: <20180116172027.22128-6-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180116172027.22128-1-aring@mojatatu.com> References: <20180116172027.22128-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack support for classifier delete callback api. This prepares to handle extack support inside each specific classifier implementation. Cc: David Ahern Signed-off-by: Alexander Aring --- include/net/sch_generic.h | 3 ++- net/sched/cls_api.c | 2 +- net/sched/cls_basic.c | 3 ++- net/sched/cls_bpf.c | 3 ++- net/sched/cls_cgroup.c | 3 ++- net/sched/cls_flow.c | 3 ++- net/sched/cls_flower.c | 3 ++- net/sched/cls_fw.c | 3 ++- net/sched/cls_matchall.c | 3 ++- net/sched/cls_route.c | 3 ++- net/sched/cls_rsvp.h | 3 ++- net/sched/cls_tcindex.c | 5 +++-- net/sched/cls_u32.c | 3 ++- 13 files changed, 26 insertions(+), 14 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index f999ee6bac2e..01227fcaa09a 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -235,7 +235,8 @@ struct tcf_proto_ops { void **, bool, struct netlink_ext_ack *); int (*delete)(struct tcf_proto *tp, void *arg, - bool *last); + bool *last, + struct netlink_ext_ack *); void (*walk)(struct tcf_proto*, struct tcf_walker *arg); void (*bind_class)(void *, u32, unsigned long); diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 011fe66c82b5..6f9fe99ebe2b 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -682,7 +682,7 @@ static int tfilter_del_notify(struct net *net, struct sk_buff *oskb, return -EINVAL; } - err = tp->ops->delete(tp, fh, last); + err = tp->ops->delete(tp, fh, last, extack); if (err) { kfree_skb(skb); return err; diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c index b7bcf67641bf..6088be65d167 100644 --- a/net/sched/cls_basic.c +++ b/net/sched/cls_basic.c @@ -130,7 +130,8 @@ static void basic_destroy(struct tcf_proto *tp) kfree_rcu(head, rcu); } -static int basic_delete(struct tcf_proto *tp, void *arg, bool *last) +static int basic_delete(struct tcf_proto *tp, void *arg, bool *last, + struct netlink_ext_ack *extack) { struct basic_head *head = rtnl_dereference(tp->root); struct basic_filter *f = arg; diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c index 50abd71f99ed..4e30863723d9 100644 --- a/net/sched/cls_bpf.c +++ b/net/sched/cls_bpf.c @@ -292,7 +292,8 @@ static void __cls_bpf_delete(struct tcf_proto *tp, struct cls_bpf_prog *prog) __cls_bpf_delete_prog(prog); } -static int cls_bpf_delete(struct tcf_proto *tp, void *arg, bool *last) +static int cls_bpf_delete(struct tcf_proto *tp, void *arg, bool *last, + struct netlink_ext_ack *extack) { struct cls_bpf_head *head = rtnl_dereference(tp->root); diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c index aaafcf6965f7..1b54fbfca414 100644 --- a/net/sched/cls_cgroup.c +++ b/net/sched/cls_cgroup.c @@ -156,7 +156,8 @@ static void cls_cgroup_destroy(struct tcf_proto *tp) } } -static int cls_cgroup_delete(struct tcf_proto *tp, void *arg, bool *last) +static int cls_cgroup_delete(struct tcf_proto *tp, void *arg, bool *last, + struct netlink_ext_ack *extack) { return -EOPNOTSUPP; } diff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c index 5bc702f66bb5..c37c0415c40c 100644 --- a/net/sched/cls_flow.c +++ b/net/sched/cls_flow.c @@ -575,7 +575,8 @@ static int flow_change(struct net *net, struct sk_buff *in_skb, return err; } -static int flow_delete(struct tcf_proto *tp, void *arg, bool *last) +static int flow_delete(struct tcf_proto *tp, void *arg, bool *last, + struct netlink_ext_ack *extack) { struct flow_head *head = rtnl_dereference(tp->root); struct flow_filter *f = arg; diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index b9664e1df8f0..a3ad5d24b0b9 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -984,7 +984,8 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, return err; } -static int fl_delete(struct tcf_proto *tp, void *arg, bool *last) +static int fl_delete(struct tcf_proto *tp, void *arg, bool *last, + struct netlink_ext_ack *extack) { struct cls_fl_head *head = rtnl_dereference(tp->root); struct cls_fl_filter *f = arg; diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c index 72a924a38753..bd21ed83eb07 100644 --- a/net/sched/cls_fw.c +++ b/net/sched/cls_fw.c @@ -172,7 +172,8 @@ static void fw_destroy(struct tcf_proto *tp) kfree_rcu(head, rcu); } -static int fw_delete(struct tcf_proto *tp, void *arg, bool *last) +static int fw_delete(struct tcf_proto *tp, void *arg, bool *last, + struct netlink_ext_ack *extack) { struct fw_head *head = rtnl_dereference(tp->root); struct fw_filter *f = arg; diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c index cd15f05d170e..375b6252f29b 100644 --- a/net/sched/cls_matchall.c +++ b/net/sched/cls_matchall.c @@ -224,7 +224,8 @@ static int mall_change(struct net *net, struct sk_buff *in_skb, return err; } -static int mall_delete(struct tcf_proto *tp, void *arg, bool *last) +static int mall_delete(struct tcf_proto *tp, void *arg, bool *last, + struct netlink_ext_ack *extack) { return -EOPNOTSUPP; } diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c index d5a5e0bff136..a7836eb613c0 100644 --- a/net/sched/cls_route.c +++ b/net/sched/cls_route.c @@ -316,7 +316,8 @@ static void route4_destroy(struct tcf_proto *tp) kfree_rcu(head, rcu); } -static int route4_delete(struct tcf_proto *tp, void *arg, bool *last) +static int route4_delete(struct tcf_proto *tp, void *arg, bool *last, + struct netlink_ext_ack *extack) { struct route4_head *head = rtnl_dereference(tp->root); struct route4_filter *f = arg; diff --git a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h index c27d23694002..5cc0df690cff 100644 --- a/net/sched/cls_rsvp.h +++ b/net/sched/cls_rsvp.h @@ -350,7 +350,8 @@ static void rsvp_destroy(struct tcf_proto *tp) kfree_rcu(data, rcu); } -static int rsvp_delete(struct tcf_proto *tp, void *arg, bool *last) +static int rsvp_delete(struct tcf_proto *tp, void *arg, bool *last, + struct netlink_ext_ack *extack) { struct rsvp_head *head = rtnl_dereference(tp->root); struct rsvp_filter *nfp, *f = arg; diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c index 9d6621caa92f..01a163e0b6aa 100644 --- a/net/sched/cls_tcindex.c +++ b/net/sched/cls_tcindex.c @@ -193,7 +193,8 @@ static void tcindex_destroy_fexts(struct rcu_head *head) tcf_queue_work(&f->work); } -static int tcindex_delete(struct tcf_proto *tp, void *arg, bool *last) +static int tcindex_delete(struct tcf_proto *tp, void *arg, bool *last, + struct netlink_ext_ack *extack) { struct tcindex_data *p = rtnl_dereference(tp->root); struct tcindex_filter_result *r = arg; @@ -246,7 +247,7 @@ static int tcindex_destroy_element(struct tcf_proto *tp, { bool last; - return tcindex_delete(tp, arg, &last); + return tcindex_delete(tp, arg, &last, NULL); } static void __tcindex_destroy(struct rcu_head *head) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 6b25bc741daf..b2c83490cc73 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -671,7 +671,8 @@ static void u32_destroy(struct tcf_proto *tp) tp->data = NULL; } -static int u32_delete(struct tcf_proto *tp, void *arg, bool *last) +static int u32_delete(struct tcf_proto *tp, void *arg, bool *last, + struct netlink_ext_ack *extack) { struct tc_u_hnode *ht = arg; struct tc_u_hnode *root_ht = rtnl_dereference(tp->root); From patchwork Tue Jan 16 17:20:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 861788 X-Patchwork-Delegate: davem@davemloft.net 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=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="EhbpTHe+"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zLcSZ4ffzz9t5b for ; Wed, 17 Jan 2018 04:21:02 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751254AbeAPRU7 (ORCPT ); Tue, 16 Jan 2018 12:20:59 -0500 Received: from mail-it0-f68.google.com ([209.85.214.68]:43373 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751118AbeAPRU5 (ORCPT ); Tue, 16 Jan 2018 12:20:57 -0500 Received: by mail-it0-f68.google.com with SMTP id u62so5753635ita.2 for ; Tue, 16 Jan 2018 09:20:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xwcgGhf6mNNwpAPlIpbEpG55ceh0WOROuktV+eBxFRs=; b=EhbpTHe+9uIR6rJ8PjRMeRz3j8+xHbtwTkITG3hg1AQAkbg1E/G9WX6hdu8tTCD1XW xgcNOc8HdjzdODC5IcCr8IsdD25zBAphRJxBXAc8fvq6LzqONCUzp+OvaQufRyH+R/4n N0WVgcN47jXeM4fvUUxnGrkEA0NlpcjWYynrO5UkQJ/AiV6iWwrG7SHmNJfp9Pazkvla lC1cxl7HwueLsmGPwFSicnrct4mFmluo7Qx82Gb2LXB4dAiZlsuoJJ7M7jLTAf4bdl6N 5XX6UN5NyXT/uYpFmAiDtYtrX+LgLQqxqsepzvB7quc5Bp+8zDkpSkAYtdWUfja/3xvZ j5Fg== 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; bh=xwcgGhf6mNNwpAPlIpbEpG55ceh0WOROuktV+eBxFRs=; b=VPUECtdoSW7OR+/24po0dJZdawo3/343BxrfOYzvSvLWb4vZY5tSn2d6VntBV59QSg OHiCMSxm1D3rNqByl/YdqP9RLUwqjKQ35JezgI7vuA/CLkOBwBdZAzcsS8zqL0d8Y93F i+opN3OHAgU2mxTZyTdfE2RC8qP9XhZGk3YYmIh2DsNtxiaj1Og1bzO/bNDcpXOPw41i 3ss2NvAuqVRaKa98zomfNzjuDjSz4+q9Mxvku55FnRMno6wr/iu5zZvBQKHAUEOwqzO0 owVQZ97LD9kUCO9HlvFTEDL9J+OrKuE5FTDXxfaiAroebqZx3nAfwnu7u1iNjsIXbhHG zGmQ== X-Gm-Message-State: AKwxytfWuLEKHlqtoxMUmW9wv44f2qq8mBsuhNLkCFD8ZRh3PPhXOY8d /81UZR/fVNL7GHNa93LvRJt8vQ== X-Google-Smtp-Source: ACJfBoux11EOwuRqVfV+/JEFtvi/kMhficzNvSs/y4LQGklMvpgeuda6T981hGPLfTQdN7vumne8cA== X-Received: by 10.36.85.206 with SMTP id e197mr12324723itb.124.1516123256649; Tue, 16 Jan 2018 09:20:56 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id a13sm1353124itj.33.2018.01.16.09.20.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2018 09:20:56 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCH net-next 6/8] net: sched: cls: add extack support for tcf_change_indev Date: Tue, 16 Jan 2018 12:20:25 -0500 Message-Id: <20180116172027.22128-7-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180116172027.22128-1-aring@mojatatu.com> References: <20180116172027.22128-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack handling for the tcf_change_indev function which is common used by TC classifier implementations. Cc: David Ahern Signed-off-by: Alexander Aring --- include/net/pkt_cls.h | 7 +++++-- net/sched/cls_flower.c | 7 ++++--- net/sched/cls_fw.c | 2 +- net/sched/cls_u32.c | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 0286d42d08ef..03f62be4e57e 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -549,13 +549,16 @@ static inline int tcf_valid_offset(const struct sk_buff *skb, #include static inline int -tcf_change_indev(struct net *net, struct nlattr *indev_tlv) +tcf_change_indev(struct net *net, struct nlattr *indev_tlv, + struct netlink_ext_ack *extack) { char indev[IFNAMSIZ]; struct net_device *dev; - if (nla_strlcpy(indev, indev_tlv, IFNAMSIZ) >= IFNAMSIZ) + if (nla_strlcpy(indev, indev_tlv, IFNAMSIZ) >= IFNAMSIZ) { + NL_SET_ERR_MSG(extack, "Interface name too long"); return -EINVAL; + } dev = __dev_get_by_name(net, indev); if (!dev) return -ENODEV; diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index a3ad5d24b0b9..9eb552257890 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -525,13 +525,14 @@ static void fl_set_key_ip(struct nlattr **tb, } static int fl_set_key(struct net *net, struct nlattr **tb, - struct fl_flow_key *key, struct fl_flow_key *mask) + struct fl_flow_key *key, struct fl_flow_key *mask, + struct netlink_ext_ack *extack) { __be16 ethertype; int ret = 0; #ifdef CONFIG_NET_CLS_IND if (tb[TCA_FLOWER_INDEV]) { - int err = tcf_change_indev(net, tb[TCA_FLOWER_INDEV]); + int err = tcf_change_indev(net, tb[TCA_FLOWER_INDEV], extack); if (err < 0) return err; key->indev_ifindex = err; @@ -840,7 +841,7 @@ static int fl_set_parms(struct net *net, struct tcf_proto *tp, tcf_bind_filter(tp, &f->res, base); } - err = fl_set_key(net, tb, &f->key, &mask->key); + err = fl_set_key(net, tb, &f->key, &mask->key, extack); if (err) return err; diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c index bd21ed83eb07..94d159a8869a 100644 --- a/net/sched/cls_fw.c +++ b/net/sched/cls_fw.c @@ -239,7 +239,7 @@ static int fw_set_parms(struct net *net, struct tcf_proto *tp, #ifdef CONFIG_NET_CLS_IND if (tb[TCA_FW_INDEV]) { int ret; - ret = tcf_change_indev(net, tb[TCA_FW_INDEV]); + ret = tcf_change_indev(net, tb[TCA_FW_INDEV], extack); if (ret < 0) return ret; f->ifindex = ret; diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index b2c83490cc73..78d0a320e7fa 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -803,7 +803,7 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp, #ifdef CONFIG_NET_CLS_IND if (tb[TCA_U32_INDEV]) { int ret; - ret = tcf_change_indev(net, tb[TCA_U32_INDEV]); + ret = tcf_change_indev(net, tb[TCA_U32_INDEV], extack); if (ret < 0) return -EINVAL; n->ifindex = ret; From patchwork Tue Jan 16 17:20:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 861790 X-Patchwork-Delegate: davem@davemloft.net 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=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="GrE6A221"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zLcSm6VZ9z9sBW for ; Wed, 17 Jan 2018 04:21:12 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751349AbeAPRVL (ORCPT ); Tue, 16 Jan 2018 12:21:11 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:43379 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751097AbeAPRU6 (ORCPT ); Tue, 16 Jan 2018 12:20:58 -0500 Received: by mail-it0-f67.google.com with SMTP id u62so5753747ita.2 for ; Tue, 16 Jan 2018 09:20:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Xf9RLBt6ExfqUjwpFRHEu3xWnFAX93OivfUEskyx6T8=; b=GrE6A221vL6lXPu16501sSCblWsTs4YdNZ/pqsKb4f7j63oi5zG+M1dR5L6CgGOfKs y8Izu4GLBCUdQw9s5fWFuBiWGge1M71Xbk78J040zombkcmoR1gFMjGnTwb+vvKVyseb OE09S9Wqahxvh9zqREzIg4cpPzB2g7iaRtx9KOntRhmK+bZF7JmPTFHqxy/YMBmbP8i2 AffAksdF5uJrdNlibHcLKZ+n4yokM4HCrj1YHxcuf67kjDe5Gg49pbkKACESqwQjiBhF pdP1d7Y6NzxyscMp42rbuUf9OeWCPigMeIXRz+uFVU6mVYH/rOODNgg9tq57RZ3iN7iB wQ3A== 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; bh=Xf9RLBt6ExfqUjwpFRHEu3xWnFAX93OivfUEskyx6T8=; b=FnuLkx91vz1d59nztyb6Tf3X0pHO3lryS963m6bnXXoY9WjcKiWLWmZn/phC09PT/J 4UW2aFexPciGkfsv3Q79LwLXZq1CJU4SqQyNgZ/jP2SOazRuoTGzM3kP+YHmcQBSi6Zt j1Z4ZZqB0SQMFGWLmtHySh/908VSSzNITB6EVdP2D5J+2JcU76msEjQnFuesx2E2sXGG 4hw4l7kcoDTBiVEJB6g1t49FrWehvFDKJAOMW5XPku2WsL1SKyGSp/QhQ8o8Y9bbh7HF hlWeZ0ZsU424pN4TSNzHASjfbqj4FKLz2KU59Wkg+ad2E7zjL2W0uoAqMGfYJnZT4Qwk 9wHQ== X-Gm-Message-State: AKwxytfb6QPfqAh+jxh59/tBLnYMBxfgLg2ZX4je9NwYC/B+fnjZGCOX y5MC3rQU4ykxFjXKLh3jgCNf4A== X-Google-Smtp-Source: ACJfBou9hHqU1zrs6f/SpMrpyM0x5aoD6TdTEEgHkmaRX/efeIU79OdeIAGDhrfCHtCepj9Ts/4I1g== X-Received: by 10.36.179.2 with SMTP id e2mr18338642itf.9.1516123257808; Tue, 16 Jan 2018 09:20:57 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id a13sm1353124itj.33.2018.01.16.09.20.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2018 09:20:57 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCH net-next 7/8] net: sched: cls: add extack support for tc_setup_cb_call Date: Tue, 16 Jan 2018 12:20:26 -0500 Message-Id: <20180116172027.22128-8-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180116172027.22128-1-aring@mojatatu.com> References: <20180116172027.22128-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack handling for the tc_setup_cb_call function which is common used by TC classifier implementations. Cc: David Ahern Signed-off-by: Alexander Aring --- include/net/pkt_cls.h | 3 ++- net/sched/cls_api.c | 11 ++++++++--- net/sched/cls_bpf.c | 19 +++++++++++-------- net/sched/cls_flower.c | 11 ++++++----- net/sched/cls_matchall.c | 11 +++++++---- net/sched/cls_u32.c | 20 +++++++++++--------- 6 files changed, 45 insertions(+), 30 deletions(-) diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 03f62be4e57e..991f5011510b 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -577,7 +577,8 @@ tcf_match_indev(struct sk_buff *skb, int ifindex) #endif /* CONFIG_NET_CLS_IND */ int tc_setup_cb_call(struct tcf_block *block, struct tcf_exts *exts, - enum tc_setup_type type, void *type_data, bool err_stop); + enum tc_setup_type type, void *type_data, bool err_stop, + struct netlink_ext_ack *extack); enum tc_block_command { TC_BLOCK_BIND, diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 6f9fe99ebe2b..c4484a8341cd 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -1264,21 +1264,26 @@ static int tc_exts_setup_cb_egdev_call(struct tcf_exts *exts, } int tc_setup_cb_call(struct tcf_block *block, struct tcf_exts *exts, - enum tc_setup_type type, void *type_data, bool err_stop) + enum tc_setup_type type, void *type_data, bool err_stop, + struct netlink_ext_ack *extack) { int ok_count; int ret; ret = tcf_block_cb_call(block, type, type_data, err_stop); - if (ret < 0) + if (ret < 0) { + NL_SET_ERR_MSG(extack, "Failed to inialize tcf block"); return ret; + } ok_count = ret; if (!exts) return ok_count; ret = tc_exts_setup_cb_egdev_call(exts, type, type_data, err_stop); - if (ret < 0) + if (ret < 0) { + NL_SET_ERR_MSG(extack, "Failed to inialize tcf block extensions"); return ret; + } ok_count += ret; return ok_count; diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c index 4e30863723d9..79a07ae405f7 100644 --- a/net/sched/cls_bpf.c +++ b/net/sched/cls_bpf.c @@ -147,7 +147,8 @@ static bool cls_bpf_is_ebpf(const struct cls_bpf_prog *prog) } static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog, - struct cls_bpf_prog *oldprog) + struct cls_bpf_prog *oldprog, + struct netlink_ext_ack *extack) { struct tcf_block *block = tp->chain->block; struct tc_cls_bpf_offload cls_bpf = {}; @@ -167,10 +168,11 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog, cls_bpf.exts_integrated = obj->exts_integrated; cls_bpf.gen_flags = obj->gen_flags; - err = tc_setup_cb_call(block, NULL, TC_SETUP_CLSBPF, &cls_bpf, skip_sw); + err = tc_setup_cb_call(block, NULL, TC_SETUP_CLSBPF, &cls_bpf, skip_sw, + extack); if (prog) { if (err < 0) { - cls_bpf_offload_cmd(tp, oldprog, prog); + cls_bpf_offload_cmd(tp, oldprog, prog, NULL); return err; } else if (err > 0) { prog->gen_flags |= TCA_CLS_FLAGS_IN_HW; @@ -184,7 +186,8 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog, } static int cls_bpf_offload(struct tcf_proto *tp, struct cls_bpf_prog *prog, - struct cls_bpf_prog *oldprog) + struct cls_bpf_prog *oldprog, + struct netlink_ext_ack *extack) { if (prog && oldprog && prog->gen_flags != oldprog->gen_flags) return -EINVAL; @@ -196,7 +199,7 @@ static int cls_bpf_offload(struct tcf_proto *tp, struct cls_bpf_prog *prog, if (!prog && !oldprog) return 0; - return cls_bpf_offload_cmd(tp, prog, oldprog); + return cls_bpf_offload_cmd(tp, prog, oldprog, extack); } static void cls_bpf_stop_offload(struct tcf_proto *tp, @@ -204,7 +207,7 @@ static void cls_bpf_stop_offload(struct tcf_proto *tp, { int err; - err = cls_bpf_offload_cmd(tp, NULL, prog); + err = cls_bpf_offload_cmd(tp, NULL, prog, NULL); if (err) pr_err("Stopping hardware offload failed: %d\n", err); } @@ -223,7 +226,7 @@ static void cls_bpf_offload_update_stats(struct tcf_proto *tp, cls_bpf.exts_integrated = prog->exts_integrated; cls_bpf.gen_flags = prog->gen_flags; - tc_setup_cb_call(block, NULL, TC_SETUP_CLSBPF, &cls_bpf, false); + tc_setup_cb_call(block, NULL, TC_SETUP_CLSBPF, &cls_bpf, false, NULL); } static int cls_bpf_init(struct tcf_proto *tp) @@ -504,7 +507,7 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb, if (ret < 0) goto errout_idr; - ret = cls_bpf_offload(tp, prog, oldprog); + ret = cls_bpf_offload(tp, prog, oldprog, extack); if (ret) goto errout_parms; diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 9eb552257890..a06a1156b07c 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -228,13 +228,14 @@ static void fl_hw_destroy_filter(struct tcf_proto *tp, struct cls_fl_filter *f) cls_flower.cookie = (unsigned long) f; tc_setup_cb_call(block, &f->exts, TC_SETUP_CLSFLOWER, - &cls_flower, false); + &cls_flower, false, NULL); } static int fl_hw_replace_filter(struct tcf_proto *tp, struct flow_dissector *dissector, struct fl_flow_key *mask, - struct cls_fl_filter *f) + struct cls_fl_filter *f, + struct netlink_ext_ack *extack) { struct tc_cls_flower_offload cls_flower = {}; struct tcf_block *block = tp->chain->block; @@ -251,7 +252,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp, cls_flower.classid = f->res.classid; err = tc_setup_cb_call(block, &f->exts, TC_SETUP_CLSFLOWER, - &cls_flower, skip_sw); + &cls_flower, skip_sw, extack); if (err < 0) { fl_hw_destroy_filter(tp, f); return err; @@ -277,7 +278,7 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f) cls_flower.classid = f->res.classid; tc_setup_cb_call(block, &f->exts, TC_SETUP_CLSFLOWER, - &cls_flower, false); + &cls_flower, false, NULL); } static void __fl_delete(struct tcf_proto *tp, struct cls_fl_filter *f) @@ -942,7 +943,7 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, err = fl_hw_replace_filter(tp, &head->dissector, &mask.key, - fnew); + fnew, extack); if (err) goto errout_idr; } diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c index 375b6252f29b..2b3e407cc2c7 100644 --- a/net/sched/cls_matchall.c +++ b/net/sched/cls_matchall.c @@ -80,12 +80,14 @@ static void mall_destroy_hw_filter(struct tcf_proto *tp, cls_mall.command = TC_CLSMATCHALL_DESTROY; cls_mall.cookie = cookie; - tc_setup_cb_call(block, NULL, TC_SETUP_CLSMATCHALL, &cls_mall, false); + tc_setup_cb_call(block, NULL, TC_SETUP_CLSMATCHALL, &cls_mall, false, + NULL); } static int mall_replace_hw_filter(struct tcf_proto *tp, struct cls_mall_head *head, - unsigned long cookie) + unsigned long cookie, + struct netlink_ext_ack *extack) { struct tc_cls_matchall_offload cls_mall = {}; struct tcf_block *block = tp->chain->block; @@ -98,7 +100,7 @@ static int mall_replace_hw_filter(struct tcf_proto *tp, cls_mall.cookie = cookie; err = tc_setup_cb_call(block, NULL, TC_SETUP_CLSMATCHALL, - &cls_mall, skip_sw); + &cls_mall, skip_sw, extack); if (err < 0) { mall_destroy_hw_filter(tp, head, cookie); return err; @@ -204,7 +206,8 @@ static int mall_change(struct net *net, struct sk_buff *in_skb, goto err_set_parms; if (!tc_skip_hw(new->flags)) { - err = mall_replace_hw_filter(tp, new, (unsigned long)new); + err = mall_replace_hw_filter(tp, new, (unsigned long)new, + extack); if (err) goto err_replace_hw_filter; } diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 78d0a320e7fa..03dc08ab3cf1 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -497,11 +497,11 @@ static void u32_clear_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h) cls_u32.hnode.handle = h->handle; cls_u32.hnode.prio = h->prio; - tc_setup_cb_call(block, NULL, TC_SETUP_CLSU32, &cls_u32, false); + tc_setup_cb_call(block, NULL, TC_SETUP_CLSU32, &cls_u32, false, NULL); } static int u32_replace_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h, - u32 flags) + u32 flags, struct netlink_ext_ack *extack) { struct tcf_block *block = tp->chain->block; struct tc_cls_u32_offload cls_u32 = {}; @@ -515,7 +515,8 @@ static int u32_replace_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h, cls_u32.hnode.handle = h->handle; cls_u32.hnode.prio = h->prio; - err = tc_setup_cb_call(block, NULL, TC_SETUP_CLSU32, &cls_u32, skip_sw); + err = tc_setup_cb_call(block, NULL, TC_SETUP_CLSU32, &cls_u32, skip_sw, + extack); if (err < 0) { u32_clear_hw_hnode(tp, h); return err; @@ -538,11 +539,11 @@ static void u32_remove_hw_knode(struct tcf_proto *tp, u32 handle) cls_u32.command = TC_CLSU32_DELETE_KNODE; cls_u32.knode.handle = handle; - tc_setup_cb_call(block, NULL, TC_SETUP_CLSU32, &cls_u32, false); + tc_setup_cb_call(block, NULL, TC_SETUP_CLSU32, &cls_u32, false, NULL); } static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n, - u32 flags) + u32 flags, struct netlink_ext_ack *extack) { struct tcf_block *block = tp->chain->block; struct tc_cls_u32_offload cls_u32 = {}; @@ -565,7 +566,8 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n, if (n->ht_down) cls_u32.knode.link_handle = n->ht_down->handle; - err = tc_setup_cb_call(block, NULL, TC_SETUP_CLSU32, &cls_u32, skip_sw); + err = tc_setup_cb_call(block, NULL, TC_SETUP_CLSU32, &cls_u32, skip_sw, + extack); if (err < 0) { u32_remove_hw_knode(tp, n->handle); return err; @@ -945,7 +947,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, return err; } - err = u32_replace_hw_knode(tp, new, flags); + err = u32_replace_hw_knode(tp, new, flags, extack); if (err) { u32_destroy_key(tp, new, false); return err; @@ -992,7 +994,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, ht->prio = tp->prio; idr_init(&ht->handle_idr); - err = u32_replace_hw_hnode(tp, ht, flags); + err = u32_replace_hw_hnode(tp, ht, flags, extack); if (err) { idr_remove_ext(&tp_c->handle_idr, handle); kfree(ht); @@ -1091,7 +1093,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, struct tc_u_knode __rcu **ins; struct tc_u_knode *pins; - err = u32_replace_hw_knode(tp, n, flags); + err = u32_replace_hw_knode(tp, n, flags, extack); if (err) goto errhw; From patchwork Tue Jan 16 17:20:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 861789 X-Patchwork-Delegate: davem@davemloft.net 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=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="v5r9mvxV"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zLcSf2rhMz9sCZ for ; Wed, 17 Jan 2018 04:21:06 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751346AbeAPRVC (ORCPT ); Tue, 16 Jan 2018 12:21:02 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:33195 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751118AbeAPRU7 (ORCPT ); Tue, 16 Jan 2018 12:20:59 -0500 Received: by mail-it0-f67.google.com with SMTP id c102so12112645itd.0 for ; Tue, 16 Jan 2018 09:20:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vniAsGxrfEj8KDcs+qmlGGIKBaeeAAiqWQumFccAYao=; b=v5r9mvxVC8HpiE5N+sRVQ5gKWztA4l4iuIWTTX9AkYgE4BF1mS+bV7qtEQobByi0ni HZhTa9u+VOfo40cmJDdfTZ5n/Nil9XLar/nt8/wcPCjZEpX/9kFoHuXGDdihDcZkgx0B 9TgQ40zVr6wayvRKYBKSuSdueN0zcWr1Nrsl/b+mHSfqlUYf0Sj4D+oZQQTqrPpXt8F2 1obiGOP+jn6TBvykxa0bQDc1ZBrX00gnqfKWl68lus0TM+6hnfI5ATZkf52cwbcj4PI7 17Hm4Xhx5VMrDg2bQYptKlFDtJFYUdi56leKyCtveu/6Uj6ZMylDMUMF/n5oH6C8R+X8 fCpQ== 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; bh=vniAsGxrfEj8KDcs+qmlGGIKBaeeAAiqWQumFccAYao=; b=DT2EPL0hlW6XPozpQhbbo+d/sqk/2O04KW+bgARAzreG0DDgtIry1QGt2CVq9T7S1v BVh+CICgFkiNlFQks31m4hoRdweWMIgoSvjp5ScgblQcZ1RV8ilmJfHV++yb4Y0ZwFbt /R5EGcKh0G1sTqXN6N4RYdPYBaDFtL6F0CcOO655I3YQntSCH/ghseSsEJ6x6tlfbnyI 5+pSV54sy7pQneC+uKL73ScCKNzOsZZJLkMOU6uq9Y/vCK+bMCQCLOx1Y1XH9FkD2/9m 5CQyeoF1EoLMncqqlA3goda3Ruu9jqnO3W+G4vh8oGqgQ4y9DzYim0bZ3DUm1Z7cYZgN hgnw== X-Gm-Message-State: AKwxyteekq8dDmOf8qKum/Pk8LKW2RrtbLr3sFzm6G0JbZquhnlO7h6O RtQtXy1yZMAl6MMGRs/A5yIqrw== X-Google-Smtp-Source: ACJfBotODYSIy/iVRXUGOA4YHsa6Zwjj6p/LbXwHA0mUX+6dP8kFjJPni6wwVn5VzRV/ZoLGvdA9dg== X-Received: by 10.36.254.4 with SMTP id w4mr20041937ith.65.1516123258932; Tue, 16 Jan 2018 09:20:58 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id a13sm1353124itj.33.2018.01.16.09.20.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2018 09:20:58 -0800 (PST) From: Alexander Aring To: jhs@mojatatu.com Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern Subject: [PATCH net-next 8/8] net: sched: cls_u32: add extack support Date: Tue, 16 Jan 2018 12:20:27 -0500 Message-Id: <20180116172027.22128-9-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180116172027.22128-1-aring@mojatatu.com> References: <20180116172027.22128-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds extack support for the u32 classifier as example for delete and init callback. Cc: David Ahern Signed-off-by: Alexander Aring --- net/sched/cls_u32.c | 66 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 03dc08ab3cf1..69c2fbafd0a3 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -524,8 +524,10 @@ static int u32_replace_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h, offloaded = true; } - if (skip_sw && !offloaded) + if (skip_sw && !offloaded) { + NL_SET_ERR_MSG(extack, "Failed to offload filter requested with skip sw"); return -EINVAL; + } return 0; } @@ -575,8 +577,10 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n, n->flags |= TCA_CLS_FLAGS_IN_HW; } - if (skip_sw && !(n->flags & TCA_CLS_FLAGS_IN_HW)) + if (skip_sw && !(n->flags & TCA_CLS_FLAGS_IN_HW)) { + NL_SET_ERR_MSG(extack, "Failed to offload filter requested with skip sw"); return -EINVAL; + } return 0; } @@ -690,13 +694,16 @@ static int u32_delete(struct tcf_proto *tp, void *arg, bool *last, goto out; } - if (root_ht == ht) + if (root_ht == ht) { + NL_SET_ERR_MSG(extack, "Not allowd to delete root node"); return -EINVAL; + } if (ht->refcnt == 1) { ht->refcnt--; u32_destroy_hnode(tp, ht); } else { + NL_SET_ERR_MSG(extack, "Can not delete in-use filter"); return -EBUSY; } @@ -780,14 +787,18 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp, u32 handle = nla_get_u32(tb[TCA_U32_LINK]); struct tc_u_hnode *ht_down = NULL, *ht_old; - if (TC_U32_KEY(handle)) + if (TC_U32_KEY(handle)) { + NL_SET_ERR_MSG(extack, "u32 Link handle must be a hash table"); return -EINVAL; + } if (handle) { ht_down = u32_lookup_ht(ht->tp_c, handle); - if (!ht_down) + if (!ht_down) { + NL_SET_ERR_MSG(extack, "Link hash table not found"); return -EINVAL; + } ht_down->refcnt++; } @@ -911,28 +922,40 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, size_t size; #endif - if (!opt) - return handle ? -EINVAL : 0; + if (!opt) { + if (handle) { + NL_SET_ERR_MSG(extack, "Filter handle requires options"); + return -EINVAL; + } else { + return 0; + } + } - err = nla_parse_nested(tb, TCA_U32_MAX, opt, u32_policy, NULL); + err = nla_parse_nested(tb, TCA_U32_MAX, opt, u32_policy, extack); if (err < 0) return err; if (tb[TCA_U32_FLAGS]) { flags = nla_get_u32(tb[TCA_U32_FLAGS]); - if (!tc_flags_valid(flags)) + if (!tc_flags_valid(flags)) { + NL_SET_ERR_MSG(extack, "Invalid filter flags"); return -EINVAL; + } } n = *arg; if (n) { struct tc_u_knode *new; - if (TC_U32_KEY(n->handle) == 0) + if (TC_U32_KEY(n->handle) == 0) { + NL_SET_ERR_MSG(extack, "Key node id cannot be zero"); return -EINVAL; + } - if (n->flags != flags) + if (n->flags != flags) { + NL_SET_ERR_MSG(extack, "Key node flags do not match passed flags"); return -EINVAL; + } new = u32_init_knode(tp, n); if (!new) @@ -966,10 +989,14 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, if (tb[TCA_U32_DIVISOR]) { unsigned int divisor = nla_get_u32(tb[TCA_U32_DIVISOR]); - if (--divisor > 0x100) + if (--divisor > 0x100) { + NL_SET_ERR_MSG(extack, "Exceeded maximum 256 hash buckets"); return -EINVAL; - if (TC_U32_KEY(handle)) + } + if (TC_U32_KEY(handle)) { + NL_SET_ERR_MSG(extack, "Divisor can only be used on a hash table"); return -EINVAL; + } ht = kzalloc(sizeof(*ht) + divisor*sizeof(void *), GFP_KERNEL); if (ht == NULL) return -ENOBUFS; @@ -1015,20 +1042,26 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, htid = ht->handle; } else { ht = u32_lookup_ht(tp->data, TC_U32_HTID(htid)); - if (!ht) + if (!ht) { + NL_SET_ERR_MSG(extack, "Specified hash table not found"); return -EINVAL; + } } } else { ht = rtnl_dereference(tp->root); htid = ht->handle; } - if (ht->divisor < TC_U32_HASH(htid)) + if (ht->divisor < TC_U32_HASH(htid)) { + NL_SET_ERR_MSG(extack, "Specified hash table buckets exceed configured value"); return -EINVAL; + } if (handle) { - if (TC_U32_HTID(handle) && TC_U32_HTID(handle ^ htid)) + if (TC_U32_HTID(handle) && TC_U32_HTID(handle ^ htid)) { + NL_SET_ERR_MSG(extack, "Handle specified hash table address mismatch"); return -EINVAL; + } handle = htid | TC_U32_NODE(handle); err = idr_alloc_ext(&ht->handle_idr, NULL, NULL, handle, handle + 1, @@ -1039,6 +1072,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, handle = gen_new_kid(ht, htid); if (tb[TCA_U32_SEL] == NULL) { + NL_SET_ERR_MSG(extack, "Selector not specified"); err = -EINVAL; goto erridr; }