From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Aring 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> References: <20180116172027.22128-1-aring@mojatatu.com> Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , David Ahern To: jhs@mojatatu.com Return-path: 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) In-Reply-To: <20180116172027.22128-1-aring@mojatatu.com> Sender: netdev-owner@vger.kernel.org List-ID: 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; -- 2.11.0