src: add support for nft_redir expression
PATCH v2 1/1 src: add support for nft_redir expression
This patch adds support for the new nft_redir expression.
Signed-off-by Arturo Borrero Gonzalez <[email protected]>
---
v2: redirect flags is uint 16.
I'm sorry, diffstat is missing :-(
0 files changed
include/libnftnl/expr.h +6 -0
@@ -161,6 +161,12 @@ enum { NFT_EXPR_MASQ_FLAGS = NFT_RULE_EXPR_ATTR_BASE, }; +enum { +NFT_EXPR_REDIR_REG_PROTO_MIN =NFT_RULE_EXPR_ATTR_BASE , +NFT_EXPR_REDIR_REG_PROTO_MAX , +NFT_EXPR_REDIR_FLAGS , +}; +#ifdef __cplusplus } /* extern "C" */#endif
include/linux/netfilter/nf_tables.h +37 -0
@@ -749,13 +749,34 @@ enum nft_queue_attributes {* * @NFT_REJECT_ICMP_UNREACH: reject using ICMP unreachable * @NFT_REJECT_TCP_RST: reject using TCP RST +* @NFT_REJECT_ICMPX_UNREACH: abstracted ICMP unreachable for bridge and inet */ enum nft_reject_types {NFT_REJECT_ICMP_UNREACH ,NFT_REJECT_TCP_RST , +NFT_REJECT_ICMPX_UNREACH , };/** +* enum nft_reject_code - Generic reject codes for IPv4/IPv6 +* +* @NFT_REJECT_ICMPX_NO_ROUTE: no route to host / network unreachable +* @NFT_REJECT_ICMPX_PORT_UNREACH: port unreachable +* @NFT_REJECT_ICMPX_HOST_UNREACH: host unreachable +* @NFT_REJECT_ICMPX_ADMIN_PROHIBITED: administratively prohibited +* +* These codes are mapped to real ICMP and ICMPv6 codes. +*/ +enum nft_reject_inet_code { +NFT_REJECT_ICMPX_NO_ROUTE =0 , +NFT_REJECT_ICMPX_PORT_UNREACH , +NFT_REJECT_ICMPX_HOST_UNREACH , +NFT_REJECT_ICMPX_ADMIN_PROHIBITED , + __NFT_REJECT_ICMPX_MAX +}; +#define NFT_REJECT_ICMPX_MAX (__NFT_REJECT_ICMPX_MAX + 1) + +/** * enum nft_reject_attributes - nf_tables reject expression netlink attributes * * @NFTA_REJECT_TYPE: packet type to use (NLA_U32: nft_reject_types)
@@ -817,6 +838,22 @@ enum nft_masq_attributes {#define NFTA_MASQ_MAX (__NFTA_MASQ_MAX - 1)/** +* enum nft_redir_attributes - nf_tables redirect expression netlink attributes +* +* @NFTA_REDIR_REG_PROTO_MIN: source register of proto range start (NLA_U32: nft_registers) +* @NFTA_REDIR_REG_PROTO_MAX: source register of proto range end (NLA_U32: nft_registers) +* @NFTA_REDIR_FLAGS: NAT flags (see NF_NAT_RANGE_* in linux/netfilter/nf_nat.h) (NLA_U16) +*/ +enum nft_redir_attributes { +NFTA_REDIR_UNSPEC , +NFTA_REDIR_REG_PROTO_MIN , +NFTA_REDIR_REG_PROTO_MAX , +NFTA_REDIR_FLAGS , + __NFTA_REDIR_MAX +}; +#define NFTA_REDIR_MAX (__NFTA_REDIR_MAX - 1) + +/** * enum nft_gen_attributes - nf_tables ruleset generation attributes * * @NFTA_GEN_ID: Ruleset generation ID (NLA_U32)
src/Makefile.am +1 -0
@@ -37,6 +37,7 @@ libnftnl_la_SOURCES = utils.c \ expr/reject.c \ expr/target.c \ expr/masq.c \ + expr/redir.c \ expr/data_reg.h \ libnftnl.map \ expr_ops.h \
src/expr/redir.c new file +308 -0
308 lines not on this page · raw message
Pablo Neira Ayuso
maintainerQuoted 5 lines · Arturo Borrero Gonzalez
This patch adds support for the new
nft_redirexpression.Signed-off-by Arturo Borrero Gonzalez <[email protected]>---
v2: redirect flags is uint 16.
Please, keep using u32 from the netlink interface. Only use u16 from internal kernel structure.
Quoted 1 line · Arturo Borrero Gonzalez
This patch adds support for the new
nft_redirexpression.
Applied, thanks.