netfilter: nf_tables: Add meta expression key for bridge interface name
Subsystems (2)
PATCH 1/1 netfilter: nf_tables: Add meta expression key for bridge interface name
NFT_META_IBRIFNAME to get packet input bridge interface name NFT_META_OBRIFNAME to get packet output bridge interface name
---
Hi Pablo,
Does that design sounds proper?
I added the nft type right away in nft_meta.c
to reuse as much as possible, only the evaluation is a bit specific.
I haven't tested yet, I will do the support of this meta key for nft tool accordingly.
Tomasz
include/uapi/linux/netfilter/nf_tables.h | 4 ++ net/netfilter/nft_meta.c | 79 +++++++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 2 deletions(-)
include/uapi/linux/netfilter/nf_tables.h +4 -0
@@ -533,6 +533,8 @@ enum nft_exthdr_attributes {* @NFT_META_SECMARK: packet secmark (skb->secmark) * @NFT_META_NFPROTO: netfilter protocol * @NFT_META_L4PROTO: layer 4 protocol number +* @NFT_META_IBRIFNAME: packet input bridge interface name +* @NFT_META_OBRIFNAME: packet output bridge interface name */ enum nft_meta_keys {NFT_META_LEN ,
@@ -552,6 +554,8 @@ enum nft_meta_keys {NFT_META_SECMARK ,NFT_META_NFPROTO ,NFT_META_L4PROTO , +NFT_META_IBRIFNAME , + NFT_META_OBRIFNAME, };/**
net/netfilter/nft_meta.c +77 -2
118 lines not on this page · raw message
Signature · 6 lines
1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Forgot to mention this patch is provided more as an RFC actually, since it's not tested.
Tomasz
Pablo Neira Ayuso
maintainerHi Tomasz,
Thanks for looking into this, comments below.
Quoted 24 lines · Tomasz Bursztyka
NFT_META_IBRIFNAMEto get packet input bridge interface nameNFT_META_OBRIFNAMEto get packet output bridge interface nameSuggested-by Pablo Neira Ayuso <[email protected]>Signed-off-by Tomasz Bursztyka <[email protected]>---
Hi Pablo,
Does that design sounds proper?
I added the nft type right away innft_meta.c
to reuse as much as possible, only the evaluation is a bit specific.I haven't tested yet, I will do the support of this meta key for nft tool accordingly.
Tomasz
include/uapi/linux/netfilter/nf_tables.h | 4 ++ net/netfilter/nft_meta.c | 79 +++++++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 2 deletions(-)include/uapi/linux/netfilter/nf_tables.h +0
-0
[...]
include/uapi/linux/netfilter/nf_tables.h nft_meta_select_ops(const struct nft_ctx *ctx, · line 363
Quoted 10 lines
include/uapi/linux/netfilter/nf_tables.h +5
-1@@ -304,8 +356,13 @@ nft_meta_select_ops(const struct nft_ctx *ctx,if (tb[NFTA_META_DREG ] && tb[NFTA_META_SREG ])return ERR_PTR (-EINVAL ); -if (tb[NFTA_META_DREG ]) +if (tb[NFTA_META_DREG ]) { +#ifdef CONFIG_NF_TABLES_BRIDGE +if (ctx->aif->family ==NFPROTO_BRIDGE ) +return &nft_meta_bridge_get_ops; +#endif
I really think we have to use Patrick's new infrastructure that allows us to add new expression flavours per family. It should just need a couple of exported symbols in nft_meta.c that you can use from the new net/bridge/netfilter/nft_meta.c file. We should avoid these ifdef games.
Hi Pablo,
Quoted 2 lines
I really think we have to use Patrick's new infrastructure that allows us to add new expression flavours per family.
I actually used this, look at the end of the patch.
However, since I did not wanted to rewrite a specific nft_meta_select_ops, I used this trick. Makes it messy anyway yes, I will change that.
Quoted 4 lines
It should just need a
couple of exported symbols innft_meta.cthat you can use from the newnet/bridge/netfilter/nft_meta.cfile. We should avoid these ifdef games.
I agree, looks ugly.
Will prepare a proper patch
Tomasz
Quoted 2 lines · Tomasz Bursztyka
NFT_META_IBRIFNAMEto get packet input bridge interface nameNFT_META_OBRIFNAMEto get packet output bridge interface name
Minor request: NFT_META_BRI_IIFNAME and NFT_META_BRI_OIFNAME.
Hi Patrick,
Quoted 5 lines · Tomasz Bursztyka
Quoted 2 lines
NFT_META_IBRIFNAMEto get packet input bridge interface nameNFT_META_OBRIFNAMEto get packet output bridge interface nameMinor request:
NFT_META_BRI_IIFNAMEandNFT_META_BRI_OIFNAME.
Will do
Thanks,
Tomasz