[PATCH] Provide accessors for actions (rtnl_act)
Santhosh Kumar Shanmugham
sshanmugham at twitter.com
Tue Mar 21 00:16:26 PDT 2017
Provide accessors for actions (rtnl_act).
Add accessor functions to retrieve actions on a tc object
and provide additional function to navigate the collection
of actions.
diff --git a/include/netlink/route/action.h b/include/netlink/route/action.h
index 5db92ab..7d4c185 100644
--- a/include/netlink/route/action.h
+++ b/include/netlink/route/action.h
@@ -22,6 +22,7 @@ extern "C" {
#endif
extern struct rtnl_act *rtnl_act_alloc(void);
+extern struct rtnl_act *rtnl_act_next(struct rtnl_act *);
extern void rtnl_act_get(struct rtnl_act *);
extern void rtnl_act_put(struct rtnl_act *);
extern int rtnl_act_build_add_request(struct rtnl_act *, int,
diff --git a/include/netlink/route/cls/basic.h
b/include/netlink/route/cls/basic.h
index f00793c..51232ae 100644
--- a/include/netlink/route/cls/basic.h
+++ b/include/netlink/route/cls/basic.h
@@ -28,6 +28,7 @@ extern void rtnl_basic_set_ematch(struct rtnl_cls *,
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 *);
+extern struct rtnl_act* rtnl_basic_get_action(struct rtnl_cls *);
#ifdef __cplusplus
}
diff --git a/include/netlink/route/cls/u32.h b/include/netlink/route/cls/u32.h
index 7475443..2443f51 100644
--- a/include/netlink/route/cls/u32.h
+++ b/include/netlink/route/cls/u32.h
@@ -50,6 +50,7 @@ extern int rtnl_u32_add_key_in6_addr(struct rtnl_cls
*, const struct in6_addr *,
uint8_t, int, int);
extern int rtnl_u32_add_action(struct rtnl_cls *, struct rtnl_act *);
extern int rtnl_u32_del_action(struct rtnl_cls *, struct rtnl_act *);
+extern struct rtnl_act* rtnl_u32_get_action(struct rtnl_cls *);
#ifdef __cplusplus
}
diff --git a/lib/route/act.c b/lib/route/act.c
index e429e00..836219d 100644
--- a/lib/route/act.c
+++ b/lib/route/act.c
@@ -27,6 +27,15 @@
static struct nl_object_ops act_obj_ops;
static struct nl_cache_ops rtnl_act_ops;
+struct rtnl_act * rtnl_act_next(struct rtnl_act *act)
+{
+ if (act == NULL) {
+ return NULL;
+ }
+
+ return act->a_next;
+}
+
int rtnl_act_append(struct rtnl_act **head, struct rtnl_act *new)
{
struct rtnl_act *p_act;
diff --git a/lib/route/cls/basic.c b/lib/route/cls/basic.c
index 6af3844..d330a19 100644
--- a/lib/route/cls/basic.c
+++ b/lib/route/cls/basic.c
@@ -233,6 +233,21 @@ int rtnl_basic_add_action(struct rtnl_cls *cls,
struct rtnl_act *act)
return rtnl_act_append(&b->b_act, act);
}
+struct rtnl_act* rtnl_basic_get_action(struct rtnl_cls *cls)
+{
+ struct rtnl_basic *b;
+
+ if (!(b = rtnl_tc_data_peek(TC_CAST(cls))))
+ return NULL;
+
+ if (!(b->b_mask & BASIC_ATTR_ACTION))
+ return NULL;
+
+ struct rtnl_act* act = b->b_act;
+ rtnl_act_get(act);
+ return act;
+}
+
int rtnl_basic_del_action(struct rtnl_cls *cls, struct rtnl_act *act)
{
struct rtnl_basic *b;
diff --git a/lib/route/cls/u32.c b/lib/route/cls/u32.c
index e8561c1..a6047b4 100644
--- a/lib/route/cls/u32.c
+++ b/lib/route/cls/u32.c
@@ -560,6 +560,21 @@ int rtnl_u32_add_action(struct rtnl_cls *cls,
struct rtnl_act *act)
return rtnl_act_append(&u->cu_act, act);
}
+struct rtnl_act* rtnl_u32_get_action(struct rtnl_cls *cls)
+{
+ struct rtnl_u32 *u;
+
+ if (!(u = rtnl_tc_data_peek(TC_CAST(cls))))
+ return NULL;
+
+ if (!(u->cu_mask & U32_ATTR_ACTION))
+ return NULL;
+
+ struct rtnl_act* act = u->cu_act;
+ rtnl_act_get(act);
+ return act;
+}
+
int rtnl_u32_del_action(struct rtnl_cls *cls, struct rtnl_act *act)
{
struct rtnl_u32 *u;
diff --git a/libnl-route-3.sym b/libnl-route-3.sym
index af1ed2d..94343a9 100644
--- a/libnl-route-3.sym
+++ b/libnl-route-3.sym
@@ -82,6 +82,7 @@ global:
rtnl_act_parse;
rtnl_act_put;
rtnl_act_put_all;
+ rtnl_act_next;
rtnl_act_remove;
rtnl_addr_add;
rtnl_addr_alloc;
@@ -126,6 +127,7 @@ global:
rtnl_addr_unset_flags;
rtnl_basic_add_action;
rtnl_basic_del_action;
+ rtnl_basic_get_action;
rtnl_basic_get_ematch;
rtnl_basic_get_target;
rtnl_basic_set_ematch;
@@ -822,6 +824,7 @@ global:
rtnl_u32_add_key_uint16;
rtnl_u32_add_key_uint32;
rtnl_u32_add_key_uint8;
+ rtnl_u32_get_action;
rtnl_u32_del_action;
rtnl_u32_get_key;
rtnl_u32_set_classid;
More information about the libnl
mailing list