[PATCH] rtnl_mirred_set_policy: allow TC_POLICE_STOLEN

Alban Crequy alban.crequy at collabora.co.uk
Wed Jan 22 08:15:20 EST 2014


TC_POLICE_STOLEN is used when setting up a redirection with:

$ tc qdisc add dev eth0 handle ffff: ingress
$ tc filter add dev eth0 parent ffff: protocol ip u32 match u32 0 0 \
                         action mirred egress redirect dev ifb0

The equivalent code is in iproute2/tc/m_mirred.c:parse_egress():
                } else if (!redir && matches(*argv, "redirect") == 0) {
                        ...
                        p.eaction = TCA_EGRESS_REDIR;
                        p.action = TC_ACT_STOLEN;

In order to do the same with libnl, rtnl_mirred_set_policy() needs to allow
TC_POLICE_STOLEN.

Signed-off-by: Alban Crequy <alban.crequy at collabora.co.uk>
---
 include/linux/pkt_cls.h | 1 +
 lib/route/act/mirred.c  | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/pkt_cls.h b/include/linux/pkt_cls.h
index defbde2..2d4614f 100644
--- a/include/linux/pkt_cls.h
+++ b/include/linux/pkt_cls.h
@@ -124,6 +124,7 @@ struct tc_police {
 #define TC_POLICE_RECLASSIFY	TC_ACT_RECLASSIFY
 #define TC_POLICE_SHOT		TC_ACT_SHOT
 #define TC_POLICE_PIPE		TC_ACT_PIPE
+#define TC_POLICE_STOLEN	TC_ACT_STOLEN
 
 	__u32			limit;
 	__u32			burst;
diff --git a/lib/route/act/mirred.c b/lib/route/act/mirred.c
index 2668048..0e0ec8d 100644
--- a/lib/route/act/mirred.c
+++ b/lib/route/act/mirred.c
@@ -187,7 +187,7 @@ int rtnl_mirred_set_policy(struct rtnl_act *act, int policy)
 	if (!(u = (struct rtnl_mirred *) rtnl_tc_data(TC_CAST(act))))
 		return -NLE_NOMEM;
 
-	if (policy > TC_POLICE_PIPE || policy < TC_POLICE_OK)
+	if (policy > TC_POLICE_STOLEN || policy < TC_POLICE_OK)
 		return -NLE_INVAL;
 
 	switch (u->m_parm.eaction) {
-- 
1.8.5.3




More information about the libnl mailing list