Skip to content
Browse files

u32: add action removal API

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
  • Loading branch information...
1 parent ffbfe92 commit 507897a53ee033b3cc9375582a5b790c39b65271 @congwang congwang committed with tgraf Dec 5, 2013
Showing with 37 additions and 0 deletions.
  1. +1 −0 include/netlink/route/action.h
  2. +1 −0 include/netlink/route/cls/u32.h
  3. +16 −0 lib/route/act.c
  4. +19 −0 lib/route/cls/u32.c
View
1 include/netlink/route/action.h
@@ -38,6 +38,7 @@ extern int rtnl_act_build_delete_request(struct rtnl_act *, int,
extern int rtnl_act_delete(struct nl_sock *, struct rtnl_act *,
int);
extern int rtnl_act_append(struct rtnl_act **, struct rtnl_act *);
+extern int rtnl_act_remove(struct rtnl_act **, struct rtnl_act *);
extern int rtnl_act_fill(struct nl_msg *, int, struct rtnl_act *);
extern void rtnl_act_put_all(struct rtnl_act **);
extern int rtnl_act_parse(struct rtnl_act **, struct nlattr *);
View
1 include/netlink/route/cls/u32.h
@@ -43,6 +43,7 @@ extern int rtnl_u32_add_key_in_addr(struct rtnl_cls *, struct in_addr *,
extern int rtnl_u32_add_key_in6_addr(struct rtnl_cls *, 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 *);
#ifdef __cplusplus
}
View
16 lib/route/act.c
@@ -49,6 +49,22 @@ int rtnl_act_append(struct rtnl_act **head, struct rtnl_act *new)
return 0;
}
+int rtnl_act_remove(struct rtnl_act **head, struct rtnl_act *act)
+{
+ struct rtnl_act *a, **ap;
+
+ for (ap = head; (a = *ap) != NULL; ap = &a->a_next)
+ if (a == act)
+ break;
+ if (a) {
+ *ap = a->a_next;
+ a->a_next = NULL;
+ return 0;
+ }
+
+ return -NLE_OBJ_NOTFOUND;
+}
+
static int rtnl_act_fill_one(struct nl_msg *msg, struct rtnl_act *act, int order)
{
struct rtnl_tc *tc = TC_CAST(act);
View
19 lib/route/cls/u32.c
@@ -481,6 +481,25 @@ int rtnl_u32_add_action(struct rtnl_cls *cls, struct rtnl_act *act)
return rtnl_act_append(&u->cu_act, act);
}
+int rtnl_u32_del_action(struct rtnl_cls *cls, struct rtnl_act *act)
+{
+ struct rtnl_u32 *u;
+ int ret;
+
+ if (!act)
+ return 0;
+
+ if (!(u = rtnl_tc_data(TC_CAST(cls))))
+ return -NLE_NOMEM;
+
+ if (!(u->cu_mask & U32_ATTR_ACTION))
+ return -NLE_INVAL;
+
+ ret = rtnl_act_remove(&u->cu_act, act);
+ if (!u->cu_act)
+ u->cu_mask &= ~U32_ATTR_ACTION;
+ return ret;
+}
/** @} */
/**

0 comments on commit 507897a

Please sign in to comment.
Something went wrong with that request. Please try again.