[PATCH 6/6] basic: add action removal API
Cong Wang
xiyou.wangcong at gmail.com
Thu Dec 5 18:48:30 EST 2013
Signed-off-by: Cong Wang <xiyou.wangcong at gmail.com>
---
include/netlink/route/cls/basic.h | 1 +
lib/route/cls/basic.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/include/netlink/route/cls/basic.h b/include/netlink/route/cls/basic.h
index 2fbae64..f00793c 100644
--- a/include/netlink/route/cls/basic.h
+++ b/include/netlink/route/cls/basic.h
@@ -27,6 +27,7 @@ extern void rtnl_basic_set_ematch(struct rtnl_cls *,
struct rtnl_ematch_tree *);
extern struct rtnl_ematch_tree *rtnl_basic_get_ematch(struct rtnl_cls *);
extern int rtnl_basic_add_action(struct rtnl_cls *, struct rtnl_act *);
+extern int rtnl_basic_del_action(struct rtnl_cls *, struct rtnl_act *);
#ifdef __cplusplus
}
diff --git a/lib/route/cls/basic.c b/lib/route/cls/basic.c
index b7449c0..c5c5cb0 100644
--- a/lib/route/cls/basic.c
+++ b/lib/route/cls/basic.c
@@ -232,6 +232,25 @@ int rtnl_basic_add_action(struct rtnl_cls *cls, struct rtnl_act *act)
b->b_mask |= BASIC_ATTR_ACTION;
return rtnl_act_append(&b->b_act, act);
}
+
+int rtnl_basic_del_action(struct rtnl_cls *cls, struct rtnl_act *act)
+{
+ struct rtnl_basic *b;
+ int ret;
+
+ if (!act)
+ return 0;
+
+ if (!(b = rtnl_tc_data(TC_CAST(cls))))
+ return -NLE_NOMEM;
+
+ if (!(b->b_mask & BASIC_ATTR_ACTION))
+ return -NLE_INVAL;
+ ret = rtnl_act_remove(&b->b_act, act);
+ if (!b->b_act)
+ b->b_mask &= ~BASIC_ATTR_ACTION;
+ return ret;
+}
/** @} */
static struct rtnl_tc_ops basic_ops = {
--
1.8.3.1
More information about the libnl
mailing list