13#include "nl-default.h"
15#include <netlink/netlink.h>
16#include <netlink/attr.h>
17#include <netlink/utils.h>
18#include <netlink/route/classifier.h>
19#include <netlink/route/cls/cgroup.h>
20#include <netlink/route/cls/ematch.h>
26 struct rtnl_ematch_tree *cg_ematch;
30#define CGROUP_ATTR_EMATCH 0x001
37static int cgroup_clone(
void *
_dst,
void *
_src)
39 struct rtnl_cgroup *dst = _dst, *src = _src;
41 dst->cg_ematch = NULL;
52static void cgroup_free_data(
struct rtnl_tc *tc,
void *data)
54 struct rtnl_cgroup *c = data;
62static int cgroup_msg_parser(
struct rtnl_tc *tc,
void *data)
64 struct nlattr *tb[TCA_CGROUP_MAX + 1];
65 struct rtnl_cgroup *c = data;
68 err = tca_parse(tb, TCA_CGROUP_MAX, tc, cgroup_policy);
72 if (tb[TCA_CGROUP_EMATCHES]) {
76 c->cg_mask |= CGROUP_ATTR_EMATCH;
88static void cgroup_dump_line(
struct rtnl_tc *tc,
void *data,
91 struct rtnl_cgroup *c = data;
96 if (c->cg_mask & CGROUP_ATTR_EMATCH)
102static void cgroup_dump_details(
struct rtnl_tc *tc,
void *data,
105 struct rtnl_cgroup *c = data;
110 if (c->cg_mask & CGROUP_ATTR_EMATCH) {
111 nl_dump_line(p,
" ematch ");
114 rtnl_ematch_tree_dump(c->cg_ematch, p);
121static int cgroup_fill_msg(
struct rtnl_tc *tc,
void *data,
124 struct rtnl_cgroup *c = data;
129 if (!(tc->ce_mask & TCA_ATTR_HANDLE))
130 return -NLE_MISSING_ATTR;
132 if (c->cg_mask & CGROUP_ATTR_EMATCH)
133 return rtnl_ematch_fill_attr(msg, TCA_CGROUP_EMATCHES,
145void rtnl_cgroup_set_ematch(
struct rtnl_cls *cls,
struct rtnl_ematch_tree *tree)
147 struct rtnl_cgroup *c;
154 c->cg_mask &= ~CGROUP_ATTR_EMATCH;
160 c->cg_mask |= CGROUP_ATTR_EMATCH;
163struct rtnl_ematch_tree *rtnl_cgroup_get_ematch(
struct rtnl_cls *cls)
165 struct rtnl_cgroup *c;
175static struct rtnl_tc_ops cgroup_ops = {
177 .to_type = RTNL_TC_TYPE_CLS,
178 .to_size =
sizeof(
struct rtnl_cgroup),
179 .to_clone = cgroup_clone,
180 .to_msg_parser = cgroup_msg_parser,
181 .to_free_data = cgroup_free_data,
182 .to_msg_fill = cgroup_fill_msg,
189static void _nl_init cgroup_init(
void)
194static void _nl_exit cgroup_exit(
void)
@ NLA_NESTED
Nested attributes.
void rtnl_ematch_tree_free(struct rtnl_ematch_tree *tree)
Free ematch tree object.
int rtnl_ematch_parse_attr(struct nlattr *attr, struct rtnl_ematch_tree **result)
Parse ematch netlink attributes.
struct rtnl_ematch_tree * rtnl_ematch_tree_clone(struct rtnl_ematch_tree *src)
Clone ematch tree object.
#define TC_CAST(ptr)
Macro to cast qdisc/class/classifier to tc object.
void * rtnl_tc_data(struct rtnl_tc *)
Return pointer to private data of traffic control object.
int rtnl_tc_register(struct rtnl_tc_ops *)
Register a traffic control module.
void rtnl_tc_unregister(struct rtnl_tc_ops *)
Unregister a traffic control module.
void nl_dump(struct nl_dump_params *params, const char *fmt,...)
Dump a formatted character string.
@ NL_DUMP_LINE
Dump object briefly on one line.
@ NL_DUMP_DETAILS
Dump all attributes but no statistics.
Attribute validation policy.
uint16_t type
Type of attribute or NLA_UNSPEC.