13#include <netlink-private/netlink.h> 
   14#include <netlink-private/tc.h> 
   15#include <netlink/netlink.h> 
   16#include <netlink/attr.h> 
   17#include <netlink/utils.h> 
   18#include <netlink-private/route/tc-api.h> 
   19#include <netlink/route/classifier.h> 
   20#include <netlink/route/cls/cgroup.h> 
   21#include <netlink/route/cls/ematch.h> 
   24#define CGROUP_ATTR_EMATCH      0x001 
   27static struct nla_policy cgroup_policy[TCA_CGROUP_MAX+1] = {
 
   31static int cgroup_clone(
void *_dst, 
void *_src)
 
   33        struct rtnl_cgroup *dst = _dst, *src = _src;
 
   35        dst->cg_ematch = NULL;
 
   46static void cgroup_free_data(
struct rtnl_tc *tc, 
void *data)
 
   48        struct rtnl_cgroup *c = data;
 
   56static int cgroup_msg_parser(
struct rtnl_tc *tc, 
void *data)
 
   58        struct nlattr *tb[TCA_CGROUP_MAX + 1];
 
   59        struct rtnl_cgroup *c = data;
 
   62        err = tca_parse(tb, TCA_CGROUP_MAX, tc, cgroup_policy);
 
   66        if (tb[TCA_CGROUP_EMATCHES]) {
 
   70                c->cg_mask |= CGROUP_ATTR_EMATCH;
 
   82static void cgroup_dump_line(
struct rtnl_tc *tc, 
void *data,
 
   85        struct rtnl_cgroup *c = data;
 
   90        if (c->cg_mask & CGROUP_ATTR_EMATCH)
 
   96static void cgroup_dump_details(
struct rtnl_tc *tc, 
void *data,
 
   99        struct rtnl_cgroup *c = data;
 
  104        if (c->cg_mask & CGROUP_ATTR_EMATCH) {
 
  105                nl_dump_line(p, 
"    ematch ");
 
  108                        rtnl_ematch_tree_dump(c->cg_ematch, p);
 
  115static int cgroup_fill_msg(
struct rtnl_tc *tc, 
void *data,
 
  118        struct rtnl_cgroup *c = data;
 
  123        if (!(tc->ce_mask & TCA_ATTR_HANDLE))
 
  124                return -NLE_MISSING_ATTR;
 
  126        if (c->cg_mask & CGROUP_ATTR_EMATCH)
 
  127                return rtnl_ematch_fill_attr(msg, TCA_CGROUP_EMATCHES,
 
  139void rtnl_cgroup_set_ematch(
struct rtnl_cls *cls, 
struct rtnl_ematch_tree *tree)
 
  141        struct rtnl_cgroup *c;
 
  148                c->cg_mask &= ~CGROUP_ATTR_EMATCH;
 
  154                c->cg_mask |= CGROUP_ATTR_EMATCH;
 
  157struct rtnl_ematch_tree *rtnl_cgroup_get_ematch(
struct rtnl_cls *cls)
 
  159        struct rtnl_cgroup *c;
 
  169static struct rtnl_tc_ops cgroup_ops = {
 
  171        .to_type                = RTNL_TC_TYPE_CLS,
 
  172        .to_size                = 
sizeof(
struct rtnl_cgroup),
 
  173        .to_clone               = cgroup_clone,
 
  174        .to_msg_parser          = cgroup_msg_parser,
 
  175        .to_free_data           = cgroup_free_data,
 
  176        .to_msg_fill            = cgroup_fill_msg,
 
  183static void __init cgroup_init(
void)
 
  188static void __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 *tc)
Return pointer to private data of traffic control object.
 
int rtnl_tc_register(struct rtnl_tc_ops *ops)
Register a traffic control module.
 
void rtnl_tc_unregister(struct rtnl_tc_ops *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.