Skip to contentSkip to conversation

netfilter: nf_tables: Add meta expression key for bridge interface name

PATCH In review Tomasz Bursztyka 3 participants 6 messages Mar 25, 2014 – Mar 26, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index 83c985a..e3c98f9 100644
@@ -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
#1 lore raw

Forgot to mention this patch is provided more as an RFC actually, since it's not tested.

Tomasz

#2 lore raw
In reply to Tomasz Bursztyka

Hi Tomasz,

Thanks for looking into this, comments below.

Quoted 24 lines · Tomasz Bursztyka

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 +0 -0
index 83c985a..e3c98f9 100644

[...]

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.

#3 lore raw

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 in nft_meta.c that you can use from the new net/bridge/netfilter/nft_meta.c file. We should avoid these ifdef games.

I agree, looks ugly.

Will prepare a proper patch

Tomasz

#4 lore raw
In reply to Tomasz Bursztyka
Quoted 2 lines · Tomasz Bursztyka

NFT_META_IBRIFNAME to get packet input bridge interface name NFT_META_OBRIFNAME to get packet output bridge interface name

Minor request: NFT_META_BRI_IIFNAME and NFT_META_BRI_OIFNAME.

#5 lore raw

Hi Patrick,

Quoted 5 lines · Tomasz Bursztyka
Quoted 2 lines

NFT_META_IBRIFNAME to get packet input bridge interface name NFT_META_OBRIFNAME to get packet output bridge interface name

Minor request: NFT_META_BRI_IIFNAME and NFT_META_BRI_OIFNAME.

Will do

Thanks,

Tomasz