#include <netlink/netlink.h>
#include <netlink/cache.h>
#include <netlink/route/classifier.h>
+#include <netlink/route/action.h>
#ifdef __cplusplus
extern "C" {
uint8_t, int, int);
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 *);
#ifdef __cplusplus
}
#include <netlink-private/route/tc-api.h>
#include <netlink/route/classifier.h>
#include <netlink/route/cls/u32.h>
+#include <netlink/route/action.h>
/** @cond SKIP */
#define U32_ATTR_DIVISOR 0x001
}
if (tb[TCA_U32_ACT]) {
- u->cu_act = nl_data_alloc_attr(tb[TCA_U32_ACT]);
- if (!u->cu_act)
- goto errout_nomem;
u->cu_mask |= U32_ATTR_ACTION;
+ err = rtnl_act_parse(&u->cu_act, tb[TCA_U32_ACT]);
+ if (err)
+ return err;
}
if (tb[TCA_U32_POLICE]) {
{
struct rtnl_u32 *u = data;
+ if (u->cu_act)
+ rtnl_act_put_all(&u->cu_act);
nl_data_free(u->cu_selector);
- nl_data_free(u->cu_act);
nl_data_free(u->cu_police);
nl_data_free(u->cu_pcnt);
}
!(dst->cu_selector = nl_data_clone(src->cu_selector)))
return -NLE_NOMEM;
- if (src->cu_act && !(dst->cu_act = nl_data_clone(src->cu_act)))
+ if (src->cu_act && !(dst->cu_act = rtnl_act_alloc()))
return -NLE_NOMEM;
+ memcpy(dst->cu_act, src->cu_act, sizeof(struct rtnl_act));
if (src->cu_police && !(dst->cu_police = nl_data_clone(src->cu_police)))
return -NLE_NOMEM;
if (u->cu_mask & U32_ATTR_SELECTOR)
NLA_PUT_DATA(msg, TCA_U32_SEL, u->cu_selector);
- if (u->cu_mask & U32_ATTR_ACTION)
- NLA_PUT_DATA(msg, TCA_U32_ACT, u->cu_act);
+ if (u->cu_mask & U32_ATTR_ACTION) {
+ int err;
+
+ err = rtnl_act_fill(msg, TCA_U32_ACT, u->cu_act);
+ if (err)
+ return err;
+ }
if (u->cu_mask & U32_ATTR_POLICE)
NLA_PUT_DATA(msg, TCA_U32_POLICE, u->cu_police);
return 0;
}
+int rtnl_u32_add_action(struct rtnl_cls *cls, struct rtnl_act *act)
+{
+ struct rtnl_u32 *u;
+
+ if (!act)
+ return 0;
+
+ if (!(u = rtnl_tc_data(TC_CAST(cls))))
+ return -NLE_NOMEM;
+
+ u->cu_mask |= U32_ATTR_ACTION;
+ return rtnl_act_append(&u->cu_act, act);
+}
+
/** @} */
/**