netfilter: nf_tables: fix nft_meta_target module
Subsystems (2)
PATCH v2 1/1 netfilter: nf_tables: fix nft_meta_target module
This patch adds kernel support for the meta expression in target flavour. Indicates that a given packet has to be set with a property, currently one of mark, priority, nftrace or secmark.
In case of nftrace, the value is always 1. Such behaviour is copied from net/netfilter/xt_TRACE.c
In case of secmark, the intention is to make the translation between the security_ctx and security_id in userspace.
Otherwise, a string is needed to be passed from the userpsace to kernel as part of the attribute set, breaking the KEY,VALUE pair approach. This is different from net/netfilter/xt_SECMARK.c. There, the context is translated in kernel side.
NFTA_META_DREG and NFTA_META_VALUE attributes are mutually exclusives.
--- include/uapi/linux/netfilter/nf_tables.h | 2 net/netfilter/nft_meta.c | 156 +++++++++++++++++++++++++----- 2 files changed, 132 insertions(+), 26 deletions(-)
include/uapi/linux/netfilter/nf_tables.h +2 -0
@@ -552,11 +552,13 @@ enum nft_meta_keys {* enum nft_meta_attributes - nf_tables meta expression netlink attributes * * @NFTA_META_DREG: destination register (NLA_U32) +* @NFTA_META_VALUE: source data to load (NLA_U32) * @NFTA_META_KEY: meta data item to load (NLA_U32: nft_meta_keys) */ enum nft_meta_attributes {NFTA_META_UNSPEC ,NFTA_META_DREG , +NFTA_META_VALUE ,NFTA_META_KEY , __NFTA_META_MAX };
net/netfilter/nft_meta.c +130 -26
208 lines not on this page · raw message
Hi Arturo,
include/uapi/linux/netfilter/nf_tables.h enum nft_meta_keys { · line 562
Quoted 9 lines
* @NFTA_META_DREG: destination register (
NLA_U32)
+ * @NFTA_META_VALUE: source data to load (NLA_U32)
* @NFTA_META_KEY: meta data item to load (NLA_U32:nft_meta_keys) */
enumnft_meta_attributes{
NFTA_META_UNSPEC,
NFTA_META_DREG,include/uapi/linux/netfilter/nf_tables.h +1
-0+NFTA_META_VALUE , NFTA_META_KEY,
You have to move NFTA_META_VALUE after NFTA_META_KEY, or then it will break with 3.13 kernel API version. (your patch is going to be part of 3.14 I guess)
net/netfilter/nft_meta.c err: · line 168
Quoted 8 lines
__NFTA_META_MAX
};
(...)net/netfilter/nft_meta.c +2
-0+static const struct nla_policy nft_meta_policy[NFTA_META_MAX +1 ] = { [NFTA_META_DREG ] = { .type =NLA_U32 }, + [NFTA_META_VALUE ] = { .type =NLA_U32 }, [NFTA_META_KEY ] = { .type =NLA_U32 },
So switch these 2 last lines accordingly.
Besides that the _match/_target naming looks still awkward to me. But _get/_set would be more "semantically relevant" imho.
Of course it's purely subjective, as usual with naming ;)
Tomasz
Quoted 3 lines · Tomasz Bursztyka
You have to move
NFTA_META_VALUEafterNFTA_META_KEY, or then it will break with 3.13 kernel API version.
(your patch is going to be part of 3.14 I guess)
OK :(
Quoted 3 lines
Besides that the _match/_target naming looks still awkward to me. But _get/_set would be more "semantically relevant" imho.
Sounds good. @pablo, what do you think?
Thanks Tomasz for your time.
regards
Signature · 5 lines
Arturo Borrero González -- 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