From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jiri Pirko Subject: Re: [PATCH net-next v3 1/5] tc/act: user space can't use TC_ACT_REDIRECT directly Date: Wed, 25 Jul 2018 13:56:52 +0200 Message-ID: <20180725115652.GD2164@nanopsycho> References: <82c5852909788fef3c7b5c29d6ad8c90b60c7170.1532437050.git.pabeni@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: netdev@vger.kernel.org, Jamal Hadi Salim , Cong Wang , Daniel Borkmann , Marcelo Ricardo Leitner , Eyal Birger , "David S. Miller" To: Paolo Abeni Return-path: Received: from mail-wr1-f42.google.com ([209.85.221.42]:43093 "EHLO mail-wr1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728684AbeGYNKl (ORCPT ); Wed, 25 Jul 2018 09:10:41 -0400 Received: by mail-wr1-f42.google.com with SMTP id b15-v6so7129795wrv.10 for ; Wed, 25 Jul 2018 04:59:19 -0700 (PDT) Content-Disposition: inline In-Reply-To: <82c5852909788fef3c7b5c29d6ad8c90b60c7170.1532437050.git.pabeni@redhat.com> Sender: netdev-owner@vger.kernel.org List-ID: Tue, Jul 24, 2018 at 10:06:39PM CEST, pabeni@redhat.com wrote: >Only cls_bpf and act_bpf can safely use such value. If a generic >action is configured by user space to return TC_ACT_REDIRECT, >the usually visible behavior is passing the skb up the stack - as >for unknown action, but, with complex configuration, more random >results can be obtained. > >This patch forcefully converts TC_ACT_REDIRECT to TC_ACT_UNSPEC >at action init time, making the kernel behavior more consistent. > >v1 -> v3: use TC_ACT_UNSPEC instead of a newly definied act value > >Signed-off-by: Paolo Abeni >--- > net/sched/act_api.c | 5 +++++ > 1 file changed, 5 insertions(+) > >diff --git a/net/sched/act_api.c b/net/sched/act_api.c >index 148a89ab789b..24b5534967fe 100644 >--- a/net/sched/act_api.c >+++ b/net/sched/act_api.c >@@ -895,6 +895,11 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, > } > } > >+ if (a->tcfa_action == TC_ACT_REDIRECT) { >+ net_warn_ratelimited("TC_ACT_REDIRECT can't be used directly"); Can't you push this warning through extack? But, wouldn't it be more appropriate to fail here? User is passing invalid configuration.... >+ a->tcfa_action = TC_ACT_UNSPEC; >+ } >+ > return a; > > err_mod: >-- >2.17.1 >