From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Abeni Subject: [PATCH net-next 1/4] tc/act: user space can't use TC_ACT_REDIRECT directly Date: Fri, 13 Jul 2018 11:54:59 +0200 Message-ID: References: Cc: Jamal Hadi Salim , Cong Wang , Jiri Pirko , Alexei Starovoitov , Daniel Borkmann , Marcelo Ricardo Leitner To: netdev@vger.kernel.org Return-path: Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34462 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726789AbeGMKJG (ORCPT ); Fri, 13 Jul 2018 06:09:06 -0400 In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: 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_LAST + 1 at action init time, making the kernel behavior more consistent. Signed-off-by: Paolo Abeni --- include/uapi/linux/pkt_cls.h | 1 + net/sched/act_api.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index c4262d911596..7cdd62b51106 100644 --- a/include/uapi/linux/pkt_cls.h +++ b/include/uapi/linux/pkt_cls.h @@ -45,6 +45,7 @@ enum { * the skb and act like everything * is alright. */ +#define TC_ACT_LAST TC_ACT_TRAP /* There is a special kind of actions called "extended actions", * which need a value parameter. These have a local opcode located in diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 148a89ab789b..f6438f246dab 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"); + a->tcfa_action = TC_ACT_LAST + 1; + } + return a; err_mod: -- 2.17.1