u32: add action removal API
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
This commit is contained in:
parent
ffbfe92d74
commit
507897a53e
4 changed files with 37 additions and 0 deletions
|
@ -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 *);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue