netfilter: add fib expression
Subsystems (2)
Florian Westphal
maintainercover netfilter: add fib expression
This adds the FIB expression to query fib for oif and route/address type.
This provides functionality of the xtables 'rpfilter' and 'addrtype' matches.
The '--local' option supported by the rpfilter match is not supported anymore, but it is possible to use extra rules (either checking for explicit saddr/daddr pairs) or the 'fib type' result to make packets coming from external source but with a locally configured address bypass 'fib oif' queries.
oif is supported in prerouting, type can be used in all hooks. The kernel validates that the combinations make sense (e.g., you cannot ask for iif in OUTPUT).
ipv4, ipv6 and inet families are supported at the moment.
Comments welcome.
Florian Westphal
maintainerPATCH 1/3 nf_tables: add fib expression
Add FIB expression, supported for ipv4, ipv6 and inet family (the latter just dispatches to ipv4 or ipv6 one based on nfproto).
Currently supports fetching output interface index/name and the rtm_type associated with an address.
This can be used for adding path filtering. rtm_type is useful to e.g. enforce a strong-end host model where packets are only accepted if daddr is configured on the interface the packet arrived on.
The fib expression is a native nftables alternative to the xtables addrtype and rp_filter matches.
FIB result order for oif/oifname retrieval is as follows:
- if packet is local (skb has rtable, RTF_LOCAL set, this will also catch looped-back multicast packets), set oif to the loopback interface.
- if fib lookup returns an error, or result points to local, store zero result. This means '--local' option of -m rpfilter is not supported. It is possible to use 'fib type local' or add explicit saddr/daddr matching rules to create exceptions if this is really needed.
- store result in the destination register.
In case of multiple routes, search set for desired oif in case strict matching is requested.
ipv4 and ipv6 behave fib expressions are supposed to behave the same.
---
NB: This conflicts with not-yet pushed patches from Pablo, one of us needs to rebase.
include/net/netfilter/nft_fib.h | 31 ++++ include/uapi/linux/netfilter/nf_tables.h | 36 ++++ net/ipv4/netfilter/Kconfig | 8 + net/ipv4/netfilter/Makefile | 1 + net/ipv4/netfilter/nft_fib_ipv4.c | 233 ++++++++++++++++++++++++++ net/ipv6/netfilter/Kconfig | 8 + net/ipv6/netfilter/Makefile | 1 + net/ipv6/netfilter/nft_fib_ipv6.c | 275 +++++++++++++++++++++++++++++++ net/netfilter/Kconfig | 13 ++ net/netfilter/Makefile | 2 + net/netfilter/nft_fib.c | 159 ++++++++++++++++++ net/netfilter/nft_fib_inet.c | 82 +++++++++ 12 files changed, 849 insertions(+) create mode 100644 include/net/netfilter/nft_fib.h create mode 100644 net/ipv4/netfilter/nft_fib_ipv4.c create mode 100644 net/ipv6/netfilter/nft_fib_ipv6.c create mode 100644 net/netfilter/nft_fib.c create mode 100644 net/netfilter/nft_fib_inet.c
include/net/netfilter/nft_fib.h new file +31 -0
@@ -0,0 +1,31 @@ +#ifndef _NFT_FIB_H_ +#define _NFT_FIB_H_ + +struct nft_fib { +enum nft_registers dreg:8 ; +u8 result; +u32 flags; +}; + +extern const struct nla_policy nft_fib_policy[]; + +int nft_fib_dump (struct sk_buff *skb,const struct nft_expr *expr); +int nft_fib_init (const struct nft_ctx *ctx,const struct nft_expr *expr, +const struct nlattr *const tb[]); +int nft_fib_validate (const struct nft_ctx *ctx,const struct nft_expr *expr, +const struct nft_data **data); + + +void nft_fib4_eval_type (const struct nft_expr *expr,struct nft_regs *regs, +const struct nft_pktinfo *pkt); +void nft_fib4_eval (const struct nft_expr *expr,struct nft_regs *regs, +const struct nft_pktinfo *pkt); + +void nft_fib6_eval_type (const struct nft_expr *expr,struct nft_regs *regs, +const struct nft_pktinfo *pkt); +void nft_fib6_eval (const struct nft_expr *expr,struct nft_regs *regs, +const struct nft_pktinfo *pkt); + +void nft_fib_store_result (void *reg,enum nft_fib_result r, +const struct nft_pktinfo *pkt,int index); +#endif
include/uapi/linux/netfilter/nf_tables.h +36 -0
@@ -1109,6 +1109,42 @@ enum nft_gen_attributes { };#define NFTA_GEN_MAX (__NFTA_GEN_MAX - 1) +/* +* enum nft_fib_attributes - nf_tables fib expression netlink attributes +* +* @NFTA_FIB_DREG: destination register (NLA_U32) +* @NFTA_FIB_RESULT: desired result (NLA_U32) +* @NFTA_FIB_FLAGS: flowi fields to initialize when querying the FIB (NLA_U32) +* +* The FIB expression performs a route lookup according +* to the packet data. +*/ +enum nft_fib_attributes { +NFTA_FIB_UNSPEC , +NFTA_FIB_DREG , +NFTA_FIB_RESULT , +NFTA_FIB_FLAGS , + __NFTA_FIB_MAX +}; +#define NFTA_FIB_MAX (__NFTA_FIB_MAX - 1) + +enum nft_fib_result { +NFT_FIB_RESULT_UNSPEC , +NFT_FIB_RESULT_OIF , +NFT_FIB_RESULT_OIFNAME , +NFT_FIB_RESULT_ADDRTYPE , + __NFT_FIB_RESULT_MAX +}; +#define NFT_FIB_RESULT_MAX (__NFT_FIB_RESULT_MAX - 1) + +enum nft_fib_flags { +NFTA_FIB_F_SADDR =1 <<0 ,/* look up src */ +NFTA_FIB_F_DADDR =1 <<1 ,/* look up dst */ +NFTA_FIB_F_MARK =1 <<2 ,/* use skb->mark */ +NFTA_FIB_F_IIF =1 <<3 ,/* restrict to iif */ +NFTA_FIB_F_OIF =1 <<4 ,/* restrict to oif */ +}; +/** * enum nft_trace_attributes - nf_tables trace netlink attributes *
net/ipv4/netfilter/Kconfig +8 -0
@@ -54,6 +54,14 @@ config NFT_DUP_IPV4 help This module enables IPv4 packet duplication support for nf_tables. +config NFT_FIB_IPV4 + select NFT_FIB + tristate "nf_tables fib / ip route lookup support" + help + This module enables IPv4 FIB lookups, e.g. for reverse path filtering. + It also allows query of the FIB for the route type, e.g. local, unicast, + multicast or blackhole. + endif # NF_TABLES_IPV4 config NF_TABLES_ARP
net/ipv4/netfilter/Makefile +1 -0
@@ -34,6 +34,7 @@ obj-$(CONFIG_NF_TABLES_IPV4) += nf_tables_ipv4.o obj-$(CONFIG_NFT_CHAIN_ROUTE_IPV4) += nft_chain_route_ipv4.o obj-$(CONFIG_NFT_CHAIN_NAT_IPV4) += nft_chain_nat_ipv4.o obj-$(CONFIG_NFT_REJECT_IPV4) += nft_reject_ipv4.o +obj-$(CONFIG_NFT_FIB_IPV4) += nft_fib_ipv4.o obj-$(CONFIG_NFT_MASQ_IPV4) += nft_masq_ipv4.o obj-$(CONFIG_NFT_REDIR_IPV4) += nft_redir_ipv4.o obj-$(CONFIG_NFT_DUP_IPV4) += nft_dup_ipv4.o
net/ipv4/netfilter/nft_fib_ipv4.c new file +233 -0
233 lines not on this page · raw message
net/ipv6/netfilter/Kconfig +8 -0
@@ -54,6 +54,14 @@ config NFT_DUP_IPV6 help This module enables IPv6 packet duplication support for nf_tables. +config NFT_FIB_IPV6 + tristate "nf_tables fib / ipv6 route lookup support" + select NFT_FIB + help + This module enables IPv6 FIB lookups, e.g. for reverse path filtering. + It also allows query of the FIB for the route type, e.g. local, unicast, + multicast or blackhole. + endif # NF_TABLES_IPV6 endif # NF_TABLES
net/ipv6/netfilter/Makefile +1 -0
@@ -40,6 +40,7 @@ obj-$(CONFIG_NFT_REJECT_IPV6) += nft_reject_ipv6.o obj-$(CONFIG_NFT_MASQ_IPV6) += nft_masq_ipv6.o obj-$(CONFIG_NFT_REDIR_IPV6) += nft_redir_ipv6.o obj-$(CONFIG_NFT_DUP_IPV6) += nft_dup_ipv6.o +obj-$(CONFIG_NFT_FIB_IPV6) += nft_fib_ipv6.o # matches obj-$(CONFIG_IP6_NF_MATCH_AH) += ip6t_ah.o
net/ipv6/netfilter/nft_fib_ipv6.c new file +275 -0
275 lines not on this page · raw message
net/netfilter/Kconfig +13 -0
@@ -581,6 +581,19 @@ config NFT_HASH This option adds the "hash" expression that you can use to perform a hash operation on registers. +config NFT_FIB + tristate + +config NFT_FIB_INET + depends on NF_TABLES_INET + depends on NFT_FIB_IPV4 + depends on NFT_FIB_IPV6 + tristate "Netfilter nf_tables fib inet support" + help + This option allows using the FIB expression from the inet table. + The lookup will be delegated to the IPv4 or IPv6 FIB depending + on the protocol of the packet. + if NF_TABLES_NETDEV config NF_DUP_NETDEV
net/netfilter/Makefile +2 -0
@@ -96,6 +96,8 @@ obj-$(CONFIG_NFT_LOG) += nft_log.o obj-$(CONFIG_NFT_MASQ) += nft_masq.o obj-$(CONFIG_NFT_REDIR) += nft_redir.o obj-$(CONFIG_NFT_HASH) += nft_hash.o +obj-$(CONFIG_NFT_FIB) += nft_fib.o +obj-$(CONFIG_NFT_FIB_INET) += nft_fib_inet.o # nf_tables netdev obj-$(CONFIG_NFT_DUP_NETDEV) += nft_dup_netdev.o
net/netfilter/nft_fib.c new file +159 -0
159 lines not on this page · raw message
net/netfilter/nft_fib_inet.c new file +82 -0
82 lines not on this page · raw message
Signature · 1 line
2.7.3
Pablo Neira Ayuso
maintainerRe: [PATCH 1/3 nf-next] nf_tables: add fib expression
Quoted 27 lines · Florian Westphal
Add FIB expression, supported for ipv4, ipv6 and inet family (the latter just dispatches to ipv4 or ipv6 one based on nfproto).
Currently supports fetching output interface index/name and the
rtm_typeassociated with an address.This can be used for adding path filtering.
rtm_typeis useful to e.g. enforce a strong-end host model where packets are only accepted if daddr is configured on the interface the packet arrived on.The fib expression is a native nftables alternative to the xtables addrtype and
rp_filtermatches.FIB result order for oif/oifname retrieval is as follows:
- if packet is local (skb has rtable,RTF_LOCALset, this will also catch looped-back multicast packets), set oif to the loopback interface.
- if fib lookup returns an error, or result points to local, store zero result. This means '--local' option of -m rpfilter is not supported. It is possible to use 'fib type local' or add explicit saddr/daddr matching rules to create exceptions if this is really needed.
- store result in the destination register.
In case of multiple routes, search set for desired oif in case strict matching is requested.
Quoted 1 line
ipv4 and ipv6 behave fib expressions are supposed to behave the same.
This looks great, applied, thanks Florian.
Florian Westphal
maintainerPATCH 2/3 expr: add fib expression
In reply to Florian Westphal--- include/libnftnl/expr.h | 6 + include/linux/netfilter/nf_tables.h | 36 +++++ src/Makefile.am | 1 + src/expr/fib.c | 273 ++++++++++++++++++++++++++++++++++++ src/expr_ops.c | 2 + 5 files changed, 318 insertions(+) create mode 100644 src/expr/fib.c
include/libnftnl/expr.h +6 -0
@@ -222,6 +222,12 @@ enum { NFTNL_EXPR_HASH_OFFSET, }; +enum { +NFTNL_EXPR_FIB_DREG =NFTNL_EXPR_BASE , +NFTNL_EXPR_FIB_RESULT , +NFTNL_EXPR_FIB_FLAGS , +}; +/* * Compat */
include/linux/netfilter/nf_tables.h +36 -0
@@ -1103,6 +1103,42 @@ enum nft_gen_attributes { };#define NFTA_GEN_MAX (__NFTA_GEN_MAX - 1) +/* +* enum nft_fib_attributes - nf_tables fib expression netlink attributes +* +* @NFTA_FIB_DREG: destination register (NLA_U32) +* @NFTA_FIB_RESULT: desired result (NLA_U32) +* @NFTA_FIB_FLAGS: flowi fields to initialize when querying the FIB (NLA_U32) +* +* The FIB expression performs a route lookup according +* to the packet data. +*/ +enum nft_fib_attributes { +NFTA_FIB_UNSPEC , +NFTA_FIB_DREG , +NFTA_FIB_RESULT , +NFTA_FIB_FLAGS , + __NFTA_FIB_MAX +}; +#define NFTA_FIB_MAX (__NFTA_FIB_MAX - 1) + +enum nft_fib_result { +NFT_FIB_RESULT_UNSPEC , +NFT_FIB_RESULT_OIF , +NFT_FIB_RESULT_OIFNAME , +NFT_FIB_RESULT_ADDRTYPE , + __NFT_FIB_RESULT_MAX +}; +#define NFT_FIB_RESULT_MAX (__NFT_FIB_RESULT_MAX - 1) + +enum nft_fib_flags { +NFTA_FIB_F_SADDR =1 <<0 ,/* look up src, not dst */ +NFTA_FIB_F_DADDR =1 <<1 ,/* look up dst (default) */ +NFTA_FIB_F_MARK =1 <<2 ,/* set fib mark */ +NFTA_FIB_F_IIF =1 <<3 ,/* restrict to iif */ +NFTA_FIB_F_OIF =1 <<4 ,/* restrict to oif */ +}; +/** * enum nft_trace_attributes - nf_tables trace netlink attributes *
src/Makefile.am +1 -0
@@ -30,6 +30,7 @@ libnftnl_la_SOURCES = utils.c \ expr/data_reg.c \ expr/dup.c \ expr/exthdr.c \ + expr/fib.c \ expr/fwd.c \ expr/limit.c \ expr/log.c \
src/expr/fib.c new file +273 -0
273 lines not on this page · raw message
src/expr_ops.c +2 -0
@@ -30,6 +30,7 @@ extern struct expr_ops expr_ops_quota;extern struct expr_ops expr_ops_target;extern struct expr_ops expr_ops_dynset;extern struct expr_ops expr_ops_hash; +extern struct expr_ops expr_ops_fib;static struct expr_ops expr_ops_notrack = { .name ="notrack" ,
@@ -63,6 +64,7 @@ static struct expr_ops *expr_ops[] = { &expr_ops_target, &expr_ops_dynset, &expr_ops_hash, + &expr_ops_fib, NULL, };
Signature · 1 line
2.7.3
Florian Westphal
maintainerPATCH 3/3 src: add fib expression
In reply to Florian WestphalThis adds the 'fib' expression which can be used to obtain the output interface from the route table based on either source or destination address of a packet.
This can be used to e.g. add reverse path filtering:
# drop if not coming from the same interface packet # arrived on # nft add rule x prerouting fib saddr . iif oif eq 0 drop
# accept only if from eth0 # nft add rule x prerouting fib saddr . iif oif eq "eth0" accept
# accept if from any valid interface # nft add rule x prerouting fib saddr oif accept
Querying of address type is also supported. This can be used to e.g. only accept packets to addresses configured in the same interface:
# fib daddr . iif type local
Its also possible to use mark and verdict map, e.g.:
blackhole : drop,
prohibit : drop,
unicast : accept
}
--- doc/nft.xml | 103 ++++++++++++++++++++++++++ include/datatype.h | 1 + include/expression.h | 7 ++ include/fib.h | 7 ++ include/linux/netfilter/nf_tables.h | 36 +++++++++ src/Makefile.am | 1 + src/evaluate.c | 1 + src/fib.c | 144 ++++++++++++++++++++++++++++++++++++ src/netlink_delinearize.c | 19 +++++ src/netlink_linearize.c | 16 ++++ src/parser_bison.y | 50 +++++++++++++ src/scanner.l | 2 + 12 files changed, 387 insertions(+) create mode 100644 include/fib.h create mode 100644 src/fib.c
doc/nft.xml +103 -0
@@ -1222,6 +1222,109 @@ filter output oif eth0 </example> </para> </refsect2> + + <refsect2> + <title>fib expressions</title> + <para> + <cmdsynopsis> + <command>fib</command> + <group choice="req"> + <arg>saddr</arg> + <arg>daddr</arg> + <group choice="opt"> + <arg>mark</arg> + <arg>iif</arg> + <arg>oif</arg> + </group> + </group> + <group choice="req"> + <arg>oif</arg> + <arg>oifname</arg> + <arg>type</arg> + </group> + </cmdsynopsis> + </para> + <para> + A fib expression queries the fib (forwarding information base) + to obtain information such as the output interface index a particular address would use. The input is a tuple of elements that is used as input to the fib lookup + functions. + </para> + <para> + fib expressions return or as qualified meta expressions. + </para> + <para> + <table frame="all"> + <title>Meta expression types</title> + <tgroup cols='3' align='left' colsep='1' rowsep='1'> + <colspec colname='c1'/> + <colspec colname='c2'/> + <colspec colname='c3'/> + <thead> + <row> + <entry>Keyword</entry> + <entry>Description</entry> + <entry>Type</entry> + </row> + </thead> + <tbody> + <row> + <entry>oif</entry> + <entry>Output interface index</entry> + <entry>integer (32 bit)</entry> + </row> + <row> + <entry>oifname</entry> + <entry>Output interface name</entry> + <entry>string</entry> + </row> + <row> + <entry>type</entry> + <entry>Address type</entry> + <entry>fib_addrtype</entry> + </row> + </tbody> + </tgroup> + </table> + </para> + <para> + <table frame="all"> + <title>fib expression specific types</title> + <tgroup cols='2' align='left' colsep='1' rowsep='1'> + <colspec colname='c1'/> + <colspec colname='c2'/> + <thead> + <row> + <entry>Type</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>fib_addrtype</entry> + <entry> + Address type stored in the fib. + </entry> + </row> + </tbody> + </tgroup> + </table> + </para> + <para> + <example> + <title>Using fib expressions</title> + <programlisting> +# drop packets without a reverse path +filter prerouting fib saddr . iif oif eq 0 drop + +# drop packets to address not configured on ininterface +filter input fib daddr . iif type not { local, broadcast, multicast } drop + +# perform lookup in a specific 'blackhole' table (0xdead, needs ip appropriate ip rule) +filter prerouting meta mark set 0xdead fib daddr . mark type vmap { backhole : drop, prohibit : jump prohibited, unreachable : drop } + </programlisting> + </example> + </para> + </refsect2> </refsect1> <refsect1>
include/datatype.h +1 -0
@@ -81,6 +81,7 @@ enum datatypes {TYPE_DEVGROUP ,TYPE_DSCP ,TYPE_ECN , +TYPE_FIB_ADDR , __TYPE_MAX };#define TYPE_MAX (__TYPE_MAX - 1)
include/expression.h +7 -0
@@ -59,6 +59,7 @@ enum expr_types {EXPR_RELATIONAL ,EXPR_NUMGEN ,EXPR_HASH , + EXPR_FIB, }; enum ops {
@@ -178,6 +179,7 @@ enum expr_flags {#include <payload.h> #include <exthdr.h> +#include <fib.h> #include <numgen.h> #include <meta.h> #include <hash.h>
@@ -298,6 +300,11 @@ struct expr {uint32_t mod;uint32_t seed; } hash; +struct { +/* EXPR_FIB */ +uint32_t flags; +uint32_t result; + } fib; }; };
include/fib.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef NFTABLES_FIB_H +#define NFTABLES_FIB_H + +extern struct expr *fib_expr_alloc (const struct location *loc, +unsigned int flags, +unsigned int result); +#endif /* NFTABLES_FIB_H */
include/linux/netfilter/nf_tables.h +36 -0
@@ -1099,6 +1099,42 @@ enum nft_gen_attributes { };#define NFTA_GEN_MAX (__NFTA_GEN_MAX - 1) +/* +* enum nft_fib_attributes - nf_tables fib expression netlink attributes +* +* @NFTA_FIB_DREG: destination register (NLA_U32) +* @NFTA_FIB_RESULT: desired result (NLA_U32) +* @NFTA_FIB_FLAGS: flowi fields to initialize when querying the FIB (NLA_U32) +* +* The FIB expression performs a route lookup according +* to the packet data. +*/ +enum nft_fib_attributes { +NFTA_FIB_UNSPEC , +NFTA_FIB_DREG , +NFTA_FIB_RESULT , +NFTA_FIB_FLAGS , + __NFTA_FIB_MAX +}; +#define NFTA_FIB_MAX (__NFTA_FIB_MAX - 1) + +enum nft_fib_result { +NFT_FIB_RESULT_UNSPEC , +NFT_FIB_RESULT_OIF , +NFT_FIB_RESULT_OIFNAME , +NFT_FIB_RESULT_ADDRTYPE , + __NFT_FIB_RESULT_MAX +}; +#define NFT_FIB_RESULT_MAX (__NFT_FIB_RESULT_MAX - 1) + +enum nft_fib_flags { +NFTA_FIB_F_SADDR =1 <<0 ,/* look up src */ +NFTA_FIB_F_DADDR =1 <<1 ,/* look up dst */ +NFTA_FIB_F_MARK =1 <<2 ,/* use skb->mark */ +NFTA_FIB_F_IIF =1 <<3 ,/* restrict to iif */ +NFTA_FIB_F_OIF =1 <<4 ,/* restrict to oif */ +}; +/** * enum nft_trace_attributes - nf_tables trace netlink attributes *
src/Makefile.am +1 -0
@@ -36,6 +36,7 @@ nft_SOURCES = main.c \ proto.c \ payload.c \ exthdr.c \ + fib.c \ hash.c \ meta.c \ numgen.c \
src/evaluate.c +1 -0
@@ -1606,6 +1606,7 @@ static int expr_evaluate(struct eval_ctx *ctx, struct expr **expr)return expr_evaluate_exthdr (ctx, expr);case EXPR_VERDICT :case EXPR_META : +case EXPR_FIB :return expr_evaluate_primary (ctx, expr);case EXPR_PAYLOAD :return expr_evaluate_payload (ctx, expr);
src/fib.c new file +144 -0
144 lines not on this page · raw message
src/netlink_delinearize.c +19 -0
@@ -538,6 +538,23 @@ static void netlink_parse_hash(struct netlink_parse_ctx *ctx,netlink_set_register (ctx, dreg, expr); } +static void netlink_parse_fib (struct netlink_parse_ctx *ctx, +const struct location *loc, +const struct nftnl_expr *nle) +{ +enum nft_registers dreg; +struct expr *expr; +uint32_t flags, result; + + flags =nftnl_expr_get_u32 (nle,NFTNL_EXPR_FIB_FLAGS ); + result =nftnl_expr_get_u32 (nle,NFTNL_EXPR_FIB_RESULT ); + + expr =fib_expr_alloc (loc, flags, result); + + dreg =netlink_parse_register (nle,NFTNL_EXPR_FIB_DREG ); +netlink_set_register (ctx, dreg, expr); +} +static void netlink_parse_meta_expr (struct netlink_parse_ctx *ctx,const struct location *loc,const struct nftnl_expr *nle)
@@ -1103,6 +1120,7 @@ static const struct { { .name = "quota", .parse = netlink_parse_quota }, { .name = "numgen", .parse = netlink_parse_numgen }, { .name = "hash", .parse = netlink_parse_hash }, + { .name = "fib", .parse = netlink_parse_fib }, }; static int netlink_parse_expr(const struct nftnl_expr *nle,
@@ -1725,6 +1743,7 @@ static void expr_postprocess(struct rule_pp_ctx *ctx, struct expr **exprp)case EXPR_META :case EXPR_VERDICT :case EXPR_NUMGEN : +case EXPR_FIB :break ;case EXPR_HASH :expr_postprocess (ctx, &expr->hash.expr);
src/netlink_linearize.c +16 -0
@@ -104,6 +104,20 @@ static void netlink_gen_concat(struct netlink_linearize_ctx *ctx, } } +static void netlink_gen_fib (struct netlink_linearize_ctx *ctx, +const struct expr *expr, +enum nft_registers dreg) +{ +struct nftnl_expr *nle; + + nle =alloc_nft_expr ("fib" ); +netlink_put_register (nle,NFTNL_EXPR_FIB_DREG , dreg); +nftnl_expr_set_u32 (nle,NFTNL_EXPR_FIB_RESULT , expr->fib.result); +nftnl_expr_set_u32 (nle,NFTNL_EXPR_FIB_FLAGS , expr->fib.flags); + +nftnl_rule_add_expr (ctx->nlr, nle); +} +static void netlink_gen_hash (struct netlink_linearize_ctx *ctx,const struct expr *expr,enum nft_registers dreg)
@@ -648,6 +662,8 @@ static void netlink_gen_expr(struct netlink_linearize_ctx *ctx,return netlink_gen_numgen (ctx, expr, dreg);case EXPR_HASH :return netlink_gen_hash (ctx, expr, dreg); +case EXPR_FIB : +return netlink_gen_fib (ctx, expr, dreg);default :BUG ("unknown expression type %s\n" , expr->ops->name); }
src/parser_bison.y +50 -0
75 lines not on this page · raw message
src/scanner.l +2 -0
@@ -477,6 +477,8 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr}) "dup" { return DUP; } "fwd" { return FWD; } +"fib" { return FIB; } + "xml" { return XML; } "json" { return JSON; }
Signature · 1 line
2.7.3