summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorThomas Graf <tgr@lsx.localdomain>2009-09-02 16:31:14 (GMT)
committerThomas Graf <tgr@lsx.localdomain>2009-09-02 16:31:14 (GMT)
commitef858fb492dfe98e3ae194264fbc73649cf8493a (patch)
tree86e6c7adc5f4ba2294cb31a386c3f8d90c8b88be /include
parent7d249fc2e1d0cb06cd4a4dfcc0a3c425ce63def7 (diff)
downloadlibnl-ef858fb492dfe98e3ae194264fbc73649cf8493a.zip
libnl-ef858fb492dfe98e3ae194264fbc73649cf8493a.tar.gz
libnl-ef858fb492dfe98e3ae194264fbc73649cf8493a.tar.bz2
- Reworked the classifier interface.
- Added initial ematch support - Added support for the basic classifier - Added support for the cgroup classifier
Diffstat (limited to 'include')
-rw-r--r--include/linux/pkt_cls.h78
-rw-r--r--include/netlink-types.h32
-rw-r--r--include/netlink/attr.h10
-rw-r--r--include/netlink/list.h5
-rw-r--r--include/netlink/route/classifier-modules.h12
-rw-r--r--include/netlink/route/classifier.h6
-rw-r--r--include/netlink/route/cls/basic.h33
-rw-r--r--include/netlink/route/cls/cgroup.h31
-rw-r--r--include/netlink/route/cls/ematch.h73
-rw-r--r--include/netlink/route/cls/ematch/cmp.h31
10 files changed, 299 insertions, 12 deletions
diff --git a/include/linux/pkt_cls.h b/include/linux/pkt_cls.h
index 30b8571..3c842ed 100644
--- a/include/linux/pkt_cls.h
+++ b/include/linux/pkt_cls.h
@@ -1,6 +1,7 @@
#ifndef __LINUX_PKT_CLS_H
#define __LINUX_PKT_CLS_H
+#include <linux/types.h>
#include <linux/pkt_sched.h>
/* I think i could have done better macros ; for now this is stolen from
@@ -201,8 +202,8 @@ enum
struct tc_u32_key
{
- __u32 mask;
- __u32 val;
+ __be32 mask;
+ __be32 val;
int off;
int offmask;
};
@@ -213,12 +214,12 @@ struct tc_u32_sel
unsigned char offshift;
unsigned char nkeys;
- __u16 offmask;
+ __be16 offmask;
__u16 off;
short offoff;
short hoff;
- __u32 hmask;
+ __be32 hmask;
struct tc_u32_key keys[0];
};
@@ -328,6 +329,58 @@ enum
#define TCA_TCINDEX_MAX (__TCA_TCINDEX_MAX - 1)
+/* Flow filter */
+
+enum
+{
+ FLOW_KEY_SRC,
+ FLOW_KEY_DST,
+ FLOW_KEY_PROTO,
+ FLOW_KEY_PROTO_SRC,
+ FLOW_KEY_PROTO_DST,
+ FLOW_KEY_IIF,
+ FLOW_KEY_PRIORITY,
+ FLOW_KEY_MARK,
+ FLOW_KEY_NFCT,
+ FLOW_KEY_NFCT_SRC,
+ FLOW_KEY_NFCT_DST,
+ FLOW_KEY_NFCT_PROTO_SRC,
+ FLOW_KEY_NFCT_PROTO_DST,
+ FLOW_KEY_RTCLASSID,
+ FLOW_KEY_SKUID,
+ FLOW_KEY_SKGID,
+ FLOW_KEY_VLAN_TAG,
+ __FLOW_KEY_MAX,
+};
+
+#define FLOW_KEY_MAX (__FLOW_KEY_MAX - 1)
+
+enum
+{
+ FLOW_MODE_MAP,
+ FLOW_MODE_HASH,
+};
+
+enum
+{
+ TCA_FLOW_UNSPEC,
+ TCA_FLOW_KEYS,
+ TCA_FLOW_MODE,
+ TCA_FLOW_BASECLASS,
+ TCA_FLOW_RSHIFT,
+ TCA_FLOW_ADDEND,
+ TCA_FLOW_MASK,
+ TCA_FLOW_XOR,
+ TCA_FLOW_DIVISOR,
+ TCA_FLOW_ACT,
+ TCA_FLOW_POLICE,
+ TCA_FLOW_EMATCHES,
+ TCA_FLOW_PERTURB,
+ __TCA_FLOW_MAX
+};
+
+#define TCA_FLOW_MAX (__TCA_FLOW_MAX - 1)
+
/* Basic filter */
enum
@@ -342,6 +395,20 @@ enum
#define TCA_BASIC_MAX (__TCA_BASIC_MAX - 1)
+
+/* Cgroup classifier */
+
+enum
+{
+ TCA_CGROUP_UNSPEC,
+ TCA_CGROUP_ACT,
+ TCA_CGROUP_POLICE,
+ TCA_CGROUP_EMATCHES,
+ __TCA_CGROUP_MAX,
+};
+
+#define TCA_CGROUP_MAX (__TCA_CGROUP_MAX - 1)
+
/* Extended Matches */
struct tcf_ematch_tree_hdr
@@ -409,7 +476,8 @@ enum
#define TCF_EM_U32 3
#define TCF_EM_META 4
#define TCF_EM_TEXT 5
-#define TCF_EM_MAX 5
+#define TCF_EM_VLAN 6
+#define TCF_EM_MAX 6
enum
{
diff --git a/include/netlink-types.h b/include/netlink-types.h
index 263e5d7..ace5dde 100644
--- a/include/netlink-types.h
+++ b/include/netlink-types.h
@@ -453,7 +453,7 @@ struct rtnl_tstats
struct nl_data * pre ##_opts; \
uint64_t pre ##_stats[RTNL_TC_STATS_MAX+1]; \
struct nl_data * pre ##_xstats; \
- void * pre ##_subdata; \
+ struct nl_data * pre ##_subdata; \
struct rtnl_tca
@@ -476,8 +476,8 @@ struct rtnl_class
struct rtnl_cls
{
NL_TCA_GENERIC(c);
- uint16_t c_prio;
- uint16_t c_protocol;
+ uint16_t c_prio;
+ uint16_t c_protocol;
struct rtnl_cls_ops *c_ops;
};
@@ -495,6 +495,12 @@ struct rtnl_u32
int cu_mask;
};
+struct rtnl_cgroup
+{
+ struct rtnl_ematch_tree *cg_ematch;
+ int cg_mask;
+};
+
struct rtnl_fw
{
uint32_t cf_classid;
@@ -504,6 +510,26 @@ struct rtnl_fw
int cf_mask;
};
+struct rtnl_ematch
+{
+ uint16_t e_id;
+ uint16_t e_kind;
+ uint16_t e_flags;
+
+ struct nl_list_head e_childs;
+ struct nl_list_head e_list;
+ struct rtnl_ematch_ops *e_ops;
+
+ char e_data[0];
+};
+
+struct rtnl_ematch_tree
+{
+ uint16_t et_progid;
+ struct nl_list_head et_list;
+
+};
+
struct rtnl_dsmark_qdisc
{
uint16_t qdm_indices;
diff --git a/include/netlink/attr.h b/include/netlink/attr.h
index b3a350b..8479c23 100644
--- a/include/netlink/attr.h
+++ b/include/netlink/attr.h
@@ -232,6 +232,16 @@ extern int nla_parse_nested(struct nlattr **, int, struct nlattr *,
NLA_PUT(msg, attrtype, nl_addr_get_len(addr), \
nl_addr_get_binary_addr(addr))
+/**
+ * Add abstract data attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg data Abstract data object.
+ */
+#define NLA_PUT_DATA(msg, attrtype, data) \
+ NLA_PUT(msg, attrtype, nl_data_get_size(data), \
+ nl_data_get(data))
+
/** @} */
/**
diff --git a/include/netlink/list.h b/include/netlink/list.h
index c6876a7..28712ed 100644
--- a/include/netlink/list.h
+++ b/include/netlink/list.h
@@ -18,6 +18,11 @@ struct nl_list_head
struct nl_list_head * prev;
};
+static inline void NL_INIT_LIST_HEAD(struct nl_list_head *list)
+{
+ list->next = list;
+ list->prev = list;
+}
static inline void __nl_list_add(struct nl_list_head *obj,
struct nl_list_head *prev,
diff --git a/include/netlink/route/classifier-modules.h b/include/netlink/route/classifier-modules.h
index 02715ed..35cb06e 100644
--- a/include/netlink/route/classifier-modules.h
+++ b/include/netlink/route/classifier-modules.h
@@ -6,7 +6,7 @@
* License as published by the Free Software Foundation version 2.1
* of the License.
*
- * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ * Copyright (c) 2003-2009 Thomas Graf <tgraf@suug.ch>
*/
#ifndef NETLINK_CLASS_MODULES_H_
@@ -25,10 +25,16 @@ extern "C" {
struct rtnl_cls_ops
{
/**
- * Kind/Name of classifier
+ * Name of classifier module
*/
char co_kind[32];
+
+ /**
+ * Size of private classifier data
+ */
+ size_t co_size;
+
/**
* Dump callbacks
*/
@@ -37,7 +43,7 @@ struct rtnl_cls_ops
/**
* Must return the contents supposed to be in TCA_OPTIONS
*/
- struct nl_msg *(*co_get_opts)(struct rtnl_cls *);
+ int (*co_get_opts)(struct rtnl_cls *, struct nl_msg *);
/**
* TCA_OPTIONS message parser
diff --git a/include/netlink/route/classifier.h b/include/netlink/route/classifier.h
index b434000..d9c3d21 100644
--- a/include/netlink/route/classifier.h
+++ b/include/netlink/route/classifier.h
@@ -6,7 +6,7 @@
* License as published by the Free Software Foundation version 2.1
* of the License.
*
- * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ * Copyright (c) 2003-2009 Thomas Graf <tgraf@suug.ch>
*/
#ifndef NETLINK_CLASSIFIER_H_
@@ -40,8 +40,10 @@ extern int rtnl_cls_build_delete_request(struct rtnl_cls *, int,
extern int rtnl_cls_delete(struct nl_sock *, struct rtnl_cls *, int);
extern void rtnl_cls_set_ifindex(struct rtnl_cls *, int);
+extern int rtnl_cls_get_ifindex(struct rtnl_cls *);
extern void rtnl_cls_set_handle(struct rtnl_cls *, uint32_t);
extern void rtnl_cls_set_parent(struct rtnl_cls *, uint32_t);
+extern uint32_t rtnl_cls_get_parent(struct rtnl_cls *);
extern int rtnl_cls_set_kind(struct rtnl_cls *, const char *);
extern struct rtnl_cls_ops *rtnl_cls_get_ops(struct rtnl_cls *);
@@ -51,6 +53,8 @@ extern uint16_t rtnl_cls_get_prio(struct rtnl_cls *);
extern void rtnl_cls_set_protocol(struct rtnl_cls *, uint16_t);
extern uint16_t rtnl_cls_get_protocol(struct rtnl_cls *);
+extern void *rtnl_cls_data(struct rtnl_cls *);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/netlink/route/cls/basic.h b/include/netlink/route/cls/basic.h
new file mode 100644
index 0000000..7003124
--- /dev/null
+++ b/include/netlink/route/cls/basic.h
@@ -0,0 +1,33 @@
+/*
+ * netlink/route/cls/basic.h Basic Classifier
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2008-2009 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_BASIC_H_
+#define NETLINK_BASIC_H_
+
+#include <netlink/netlink.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern struct rtnl_cls_ops *rtnl_basic_get_ops(void);
+extern int rtnl_basic_set_classid(struct rtnl_cls *, uint32_t);
+extern uint32_t rtnl_basic_get_classid(struct rtnl_cls *);
+extern int rtnl_basic_set_ematch(struct rtnl_cls *,
+ struct rtnl_ematch_tree *);
+extern struct rtnl_ematch_tree *
+ rtnl_basic_get_ematch(struct rtnl_cls *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/netlink/route/cls/cgroup.h b/include/netlink/route/cls/cgroup.h
new file mode 100644
index 0000000..7b0e3d3
--- /dev/null
+++ b/include/netlink/route/cls/cgroup.h
@@ -0,0 +1,31 @@
+/*
+ * netlink/route/cls/cgroup.h Control Groups Classifier
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2009 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_CLS_CGROUP_H_
+#define NETLINK_CLS_CGROUP_H_
+
+#include <netlink/netlink.h>
+#include <netlink/cache.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int rtnl_cgroup_set_ematch(struct rtnl_cls *,
+ struct rtnl_ematch_tree *);
+extern struct rtnl_ematch_tree *
+ rtnl_cgroup_get_ematch(struct rtnl_cls *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/netlink/route/cls/ematch.h b/include/netlink/route/cls/ematch.h
new file mode 100644
index 0000000..c4292bf
--- /dev/null
+++ b/include/netlink/route/cls/ematch.h
@@ -0,0 +1,73 @@
+/*
+ * netlink/route/cls/ematch.h Extended Matches
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_CLS_EMATCH_H_
+#define NETLINK_CLS_EMATCH_H_
+
+#include <netlink/netlink.h>
+#include <netlink/route/classifier.h>
+#include <linux/pkt_cls.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct rtnl_ematch;
+struct rtnl_ematch_tree;
+
+struct rtnl_ematch_ops
+{
+ int eo_kind;
+ const char * eo_name;
+ size_t eo_datalen;
+
+ int (*eo_parse)(struct rtnl_ematch *,
+ void *, size_t);
+ void (*eo_dump)(struct rtnl_ematch *,
+ struct nl_dump_params *);
+ struct nl_list_head eo_list;
+};
+
+extern int rtnl_ematch_register(struct rtnl_ematch_ops *);
+extern int rtnl_ematch_unregister(struct rtnl_ematch_ops *);
+
+extern struct rtnl_ematch_ops *
+ rtnl_ematch_lookup_ops(int);
+extern struct rtnl_ematch_ops *
+ rtnl_ematch_lookup_ops_name(const char *);
+
+extern struct rtnl_ematch *
+ rtnl_ematch_alloc(struct rtnl_ematch_ops *);
+extern void rtnl_ematch_add_child(struct rtnl_ematch *,
+ struct rtnl_ematch *);
+extern void rtnl_ematch_unlink(struct rtnl_ematch *);
+extern void rtnl_ematch_free(struct rtnl_ematch *);
+
+extern void * rtnl_ematch_data(struct rtnl_ematch *);
+extern void rtnl_ematch_set_flags(struct rtnl_ematch *, uint16_t);
+extern void rtnl_ematch_unset_flags(struct rtnl_ematch *, uint16_t);
+extern uint16_t rtnl_ematch_get_flags(struct rtnl_ematch *);
+
+extern struct rtnl_ematch_tree *
+ rtnl_ematch_tree_alloc(uint16_t);
+extern void rtnl_ematch_tree_free(struct rtnl_ematch_tree *);
+
+extern int rtnl_ematch_parse(struct nlattr *, struct rtnl_ematch_tree **);
+extern void rtnl_ematch_tree_add_tail(struct rtnl_ematch_tree *,
+ struct rtnl_ematch *);
+extern void rtnl_ematch_tree_dump(struct rtnl_ematch_tree *,
+ struct nl_dump_params *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/netlink/route/cls/ematch/cmp.h b/include/netlink/route/cls/ematch/cmp.h
new file mode 100644
index 0000000..b4ad03a
--- /dev/null
+++ b/include/netlink/route/cls/ematch/cmp.h
@@ -0,0 +1,31 @@
+/*
+ * netlink/route/cls/ematch/cmp.h Simple Comparison
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation version 2.1
+ * of the License.
+ *
+ * Copyright (c) 2008 Thomas Graf <tgraf@suug.ch>
+ */
+
+#ifndef NETLINK_CLS_EMATCH_CMP_H_
+#define NETLINK_CLS_EMATCH_CMP_H_
+
+#include <netlink/netlink.h>
+#include <netlink/route/cls/ematch.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void rtnl_ematch_cmp_set(struct rtnl_ematch *,
+ struct tcf_em_cmp *);
+extern struct tcf_em_cmp *
+ rtnl_ematch_cmp_get(struct rtnl_ematch *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif