mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-24 09:50:04 +00:00
netfilter: nft_meta_bridge: add NFT_META_BRI_IIFPVID support
This patch allows you to match on the bridge port pvid, eg. nft add rule bridge firewall zones counter meta ibrpvid 10 Signed-off-by: wenxu <wenxu@ucloud.cn> Reviewed-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
7582f5b70f
commit
c54c7c6854
2 changed files with 17 additions and 0 deletions
|
@ -795,6 +795,7 @@ enum nft_exthdr_attributes {
|
||||||
* @NFT_META_SECPATH: boolean, secpath_exists (!!skb->sp)
|
* @NFT_META_SECPATH: boolean, secpath_exists (!!skb->sp)
|
||||||
* @NFT_META_IIFKIND: packet input interface kind name (dev->rtnl_link_ops->kind)
|
* @NFT_META_IIFKIND: packet input interface kind name (dev->rtnl_link_ops->kind)
|
||||||
* @NFT_META_OIFKIND: packet output interface kind name (dev->rtnl_link_ops->kind)
|
* @NFT_META_OIFKIND: packet output interface kind name (dev->rtnl_link_ops->kind)
|
||||||
|
* @NFT_META_BRI_IIFPVID: packet input bridge port pvid
|
||||||
*/
|
*/
|
||||||
enum nft_meta_keys {
|
enum nft_meta_keys {
|
||||||
NFT_META_LEN,
|
NFT_META_LEN,
|
||||||
|
@ -825,6 +826,7 @@ enum nft_meta_keys {
|
||||||
NFT_META_SECPATH,
|
NFT_META_SECPATH,
|
||||||
NFT_META_IIFKIND,
|
NFT_META_IIFKIND,
|
||||||
NFT_META_OIFKIND,
|
NFT_META_OIFKIND,
|
||||||
|
NFT_META_BRI_IIFPVID,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <linux/netfilter/nf_tables.h>
|
#include <linux/netfilter/nf_tables.h>
|
||||||
#include <net/netfilter/nf_tables.h>
|
#include <net/netfilter/nf_tables.h>
|
||||||
#include <net/netfilter/nft_meta.h>
|
#include <net/netfilter/nft_meta.h>
|
||||||
|
#include <linux/if_bridge.h>
|
||||||
|
|
||||||
static const struct net_device *
|
static const struct net_device *
|
||||||
nft_meta_get_bridge(const struct net_device *dev)
|
nft_meta_get_bridge(const struct net_device *dev)
|
||||||
|
@ -37,6 +38,17 @@ static void nft_meta_bridge_get_eval(const struct nft_expr *expr,
|
||||||
if (!br_dev)
|
if (!br_dev)
|
||||||
goto err;
|
goto err;
|
||||||
break;
|
break;
|
||||||
|
case NFT_META_BRI_IIFPVID: {
|
||||||
|
u16 p_pvid;
|
||||||
|
|
||||||
|
br_dev = nft_meta_get_bridge(in);
|
||||||
|
if (!br_dev || !br_vlan_enabled(br_dev))
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
br_vlan_get_pvid_rcu(in, &p_pvid);
|
||||||
|
nft_reg_store16(dest, p_pvid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +74,9 @@ static int nft_meta_bridge_get_init(const struct nft_ctx *ctx,
|
||||||
case NFT_META_BRI_OIFNAME:
|
case NFT_META_BRI_OIFNAME:
|
||||||
len = IFNAMSIZ;
|
len = IFNAMSIZ;
|
||||||
break;
|
break;
|
||||||
|
case NFT_META_BRI_IIFPVID:
|
||||||
|
len = sizeof(u16);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return nft_meta_get_init(ctx, expr, tb);
|
return nft_meta_get_init(ctx, expr, tb);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue