introduce rt expression
PATCH v2 1/1 introduce rt expression
From: Anders K. Pedersen <[email protected]>
Introduce support for rt expression for routing related data as implemented in kernel.
Signed-off-by Anders K. Pedersen <[email protected]>
---
v2
- fix comments for enum nft_rt_keys
include/libnftnl/expr.h | 12 ++ include/linux/netfilter/nf_tables.h | 27 ++++ src/Makefile.am | 1 + src/expr/rt.c | 268 ++++++++++++++++++++++++++++++++++++ src/expr_ops.c | 2 + 5 files changed, 310 insertions(+)
include/libnftnl/expr.h +12 -0
@@ -64,6 +64,12 @@ enum { };enum { +NFTNL_EXPR_RT_KEY =NFTNL_EXPR_BASE , +NFTNL_EXPR_RT_DREG , +NFTNL_EXPR_RT_FAMILY , +}; + +enum {NFTNL_EXPR_CMP_SREG =NFTNL_EXPR_BASE ,NFTNL_EXPR_CMP_OP ,NFTNL_EXPR_CMP_DATA ,
@@ -272,6 +278,12 @@ enum { };enum { +NFT_EXPR_RT_KEY =NFT_RULE_EXPR_ATTR_BASE , +NFT_EXPR_RT_DREG , +NFT_EXPR_RT_FAMILY , +}; + +enum {NFT_EXPR_CMP_SREG =NFT_RULE_EXPR_ATTR_BASE ,NFT_EXPR_CMP_OP ,NFT_EXPR_CMP_DATA ,
include/linux/netfilter/nf_tables.h +27 -0
@@ -753,6 +753,17 @@ enum nft_meta_keys { };/** +* enum nft_rt_keys - nf_tables routing expression keys +* +* @NFT_RT_CLASSID: realm value of packet's route (skb->dst->tclassid) +* @NFT_RT_NEXTHOP: routing nexthop +*/ +enum nft_rt_keys { +NFT_RT_CLASSID , +NFT_RT_NEXTHOP , +}; + +/** * enum nft_hash_attributes - nf_tables hash expression netlink attributes * * @NFTA_HASH_SREG: source register (NLA_U32)
@@ -791,6 +802,22 @@ enum nft_meta_attributes {#define NFTA_META_MAX (__NFTA_META_MAX - 1)/** +* enum nft_rt_attributes - nf_tables routing expression netlink attributes +* +* @NFTA_RT_DREG: destination register (NLA_U32) +* @NFTA_RT_KEY: meta data item to load (NLA_U32: nft_rt_keys) +* @NFTA_RT_FAMILY: Address family (NLA_U32) +*/ +enum nft_rt_attributes { +NFTA_RT_UNSPEC , +NFTA_RT_DREG , +NFTA_RT_KEY , +NFTA_RT_FAMILY , + __NFTA_RT_MAX +}; +#define NFTA_RT_MAX (__NFTA_RT_MAX - 1) + +/** * enum nft_ct_keys - nf_tables ct expression keys * * @NFT_CT_STATE: conntrack state (bitmask of enum ip_conntrack_info)
src/Makefile.am +1 -0
@@ -44,6 +44,7 @@ libnftnl_la_SOURCES = utils.c \ expr/queue.c \ expr/quota.c \ expr/reject.c \ + expr/rt.c \ expr/target.c \ expr/masq.c \ expr/redir.c \
src/expr/rt.c new file +268 -0
268 lines not on this page · raw message
src/expr_ops.c +2 -0
@@ -25,6 +25,7 @@ extern struct expr_ops expr_ops_payload;extern struct expr_ops expr_ops_range;extern struct expr_ops expr_ops_redir;extern struct expr_ops expr_ops_reject; +extern struct expr_ops expr_ops_rt;extern struct expr_ops expr_ops_queue;extern struct expr_ops expr_ops_quota;extern struct expr_ops expr_ops_target;
@@ -53,6 +54,7 @@ static struct expr_ops *expr_ops[] = { &expr_ops_range, &expr_ops_redir, &expr_ops_reject, + &expr_ops_rt, &expr_ops_queue, &expr_ops_quota, &expr_ops_target,