summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorVolodymyr Bendiuga <volodymyr.bendiuga@westermo.se>2018-05-03 09:20:53 (GMT)
committerThomas Haller <thaller@redhat.com>2022-03-15 09:33:42 (GMT)
commitef46de143206d118ff777e29f4b2d5fe78c62ada (patch)
treef5f2e6626180277d97360c02aade9a1daedeaf0a /include
parentf0aad20815bf1a671071e17a227ec1a532376f11 (diff)
downloadlibnl-ef46de143206d118ff777e29f4b2d5fe78c62ada.zip
libnl-ef46de143206d118ff777e29f4b2d5fe78c62ada.tar.gz
libnl-ef46de143206d118ff777e29f4b2d5fe78c62ada.tar.bz2
route/cls: add flower classifier
This patch adds a subset of functions. Implemented api: rtnl_flower_set_proto; rtnl_flower_get_proto; rtnl_flower_set_vlan_id; rtnl_flower_get_vlan_id; rtnl_flower_set_vlan_prio; rtnl_flower_get_vlan_prio; rtnl_flower_set_vlan_ethtype; rtnl_flower_set_dst_mac; rtnl_flower_get_dst_mac; rtnl_flower_set_src_mac; rtnl_flower_get_src_mac; rtnl_flower_set_ip_dscp; rtnl_flower_get_ip_dscp; rtnl_flower_set_flags; rtnl_flower_append_action; rtnl_flower_del_action; rtnl_flower_get_action; [thaller@redhat.com: squashed commit "route:cls:flower: use parentheses in macro definitions"] [thaller@redhat.com: squashed commit "cls:flower: add TCA_FLOWER_FLAGS to flower_policy"] [thaller@redhat.com: squashed commit "cls:flower: vlan priority is uint8_t, not uint16_t"] [thaller@redhat.com: squashed commit "route:cls:flower: substitute nl_data* with uint8_t mac[ETH_ALEN]"] [thaller@redhat.com: drop non-existing TCA_FLOWER_POLICE. That was never merged to upstream kernel. While at it, use decimal numbers for the bitshift.] [thaller@redhat.com: fix build by including <linux/if_ether.h> in "types.h".] Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
Diffstat (limited to 'include')
-rw-r--r--include/netlink-private/types.h18
-rw-r--r--include/netlink/route/cls/flower.h58
2 files changed, 76 insertions, 0 deletions
diff --git a/include/netlink-private/types.h b/include/netlink-private/types.h
index 8e13222..be10d7a 100644
--- a/include/netlink-private/types.h
+++ b/include/netlink-private/types.h
@@ -27,6 +27,7 @@
#include <linux/tc_act/tc_vlan.h>
#include <linux/sock_diag.h>
#include <linux/fib_rules.h>
+#include <linux/if_ether.h>
#define NL_SOCK_PASSCRED (1<<1)
#define NL_OWN_PORT (1<<2)
@@ -610,6 +611,23 @@ struct rtnl_mall
int m_mask;
};
+struct rtnl_flower
+{
+ uint16_t cf_proto;
+ uint16_t cf_vlan_id;
+ uint8_t cf_vlan_prio;
+ uint16_t cf_vlan_ethtype;
+ uint8_t cf_src_mac[ETH_ALEN];
+ uint8_t cf_src_mac_mask[ETH_ALEN];
+ uint8_t cf_dst_mac[ETH_ALEN];
+ uint8_t cf_dst_mac_mask[ETH_ALEN];
+ uint8_t cf_ip_dscp;
+ uint8_t cf_ip_dscp_mask;
+ uint32_t cf_flags;
+ struct rtnl_act * cf_act;
+ int cf_mask;
+};
+
struct rtnl_cgroup
{
struct rtnl_ematch_tree *cg_ematch;
diff --git a/include/netlink/route/cls/flower.h b/include/netlink/route/cls/flower.h
new file mode 100644
index 0000000..f39ce1c
--- /dev/null
+++ b/include/netlink/route/cls/flower.h
@@ -0,0 +1,58 @@
+/*
+ * netlink/route/cls/flower.h flower 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) 2018 Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
+ */
+
+#ifndef NETLINK_FLOWER_H_
+#define NETLINK_FLOWER_H_
+
+#include <netlink/netlink.h>
+#include <netlink/cache.h>
+#include <netlink/route/classifier.h>
+#include <netlink/route/action.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int rtnl_flower_set_proto(struct rtnl_cls *cls, uint16_t);
+extern int rtnl_flower_get_proto(struct rtnl_cls *cls, uint16_t *);
+
+extern int rtnl_flower_set_vlan_id(struct rtnl_cls *, uint16_t);
+extern int rtnl_flower_get_vlan_id(struct rtnl_cls *, uint16_t *);
+
+extern int rtnl_flower_set_vlan_prio(struct rtnl_cls *, uint8_t);
+extern int rtnl_flower_get_vlan_prio(struct rtnl_cls *, uint8_t *);
+
+extern int rtnl_flower_set_vlan_ethtype(struct rtnl_cls *, uint16_t);
+
+extern int rtnl_flower_set_dst_mac(struct rtnl_cls *, unsigned char *,
+ unsigned char *);
+extern int rtnl_flower_get_dst_mac(struct rtnl_cls *, unsigned char *,
+ unsigned char *);
+
+extern int rtnl_flower_set_src_mac(struct rtnl_cls *, unsigned char *,
+ unsigned char *);
+extern int rtnl_flower_get_src_mac(struct rtnl_cls *, unsigned char *,
+ unsigned char *);
+
+extern int rtnl_flower_set_ip_dscp(struct rtnl_cls *, uint8_t, uint8_t);
+extern int rtnl_flower_get_ip_dscp(struct rtnl_cls *, uint8_t *, uint8_t *);
+
+extern int rtnl_flower_set_flags(struct rtnl_cls *, int);
+
+extern int rtnl_flower_append_action(struct rtnl_cls *, struct rtnl_act *);
+extern int rtnl_flower_del_action(struct rtnl_cls *, struct rtnl_act *);
+extern struct rtnl_act* rtnl_flower_get_action(struct rtnl_cls *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif