@@ -70,6 +70,7 @@ struct nf_flowtable_type {
enum nf_flowtable_flags {
NF_FLOWTABLE_HW_OFFLOAD = 0x1, /* NFT_FLOWTABLE_HW_OFFLOAD */
NF_FLOWTABLE_COUNTER = 0x2, /* NFT_FLOWTABLE_COUNTER */
+ NF_FLOWTABLE_XDP_OFFLOAD = 0x4, /* NFT_FLOWTABLE_XDP_OFFLOAD */
};
struct nf_flowtable {
@@ -1675,12 +1675,15 @@ enum nft_object_attributes {
*
* @NFT_FLOWTABLE_HW_OFFLOAD: flowtable hardware offload is enabled
* @NFT_FLOWTABLE_COUNTER: enable flow counters
+ * @NFT_FLOWTABLE_XDP_OFFLOAD: flowtable xdp offload is enabled
*/
enum nft_flowtable_flags {
NFT_FLOWTABLE_HW_OFFLOAD = 0x1,
NFT_FLOWTABLE_COUNTER = 0x2,
+ NFT_FLOWTABLE_XDP_OFFLOAD = 0x4,
NFT_FLOWTABLE_MASK = (NFT_FLOWTABLE_HW_OFFLOAD |
- NFT_FLOWTABLE_COUNTER)
+ NFT_FLOWTABLE_COUNTER |
+ NFT_FLOWTABLE_XDP_OFFLOAD),
};
/**
@@ -8288,6 +8288,15 @@ static void nft_hooks_destroy(struct list_head *hook_list)
}
}
+static bool nft_flowtable_flag_changes(const struct nf_flowtable *ft,
+ unsigned int new_flags, enum nft_flowtable_flags flag)
+{
+ if ((ft->flags & flag) ^ (new_flags & flag))
+ return true;
+
+ return false;
+}
+
static int nft_flowtable_update(struct nft_ctx *ctx, const struct nlmsghdr *nlh,
struct nft_flowtable *flowtable,
struct netlink_ext_ack *extack)
@@ -8318,8 +8327,9 @@ static int nft_flowtable_update(struct nft_ctx *ctx, const struct nlmsghdr *nlh,
err = -EOPNOTSUPP;
goto err_flowtable_update_hook;
}
- if ((flowtable->ft->flags & NFT_FLOWTABLE_HW_OFFLOAD) ^
- (flags & NFT_FLOWTABLE_HW_OFFLOAD)) {
+
+ if (nft_flowtable_flag_changes(flowtable->ft, flags, NFT_FLOWTABLE_HW_OFFLOAD) ||
+ nft_flowtable_flag_changes(flowtable->ft, flags, NFT_FLOWTABLE_XDP_OFFLOAD)) {
err = -EOPNOTSUPP;
goto err_flowtable_update_hook;
}
Also make sure this flag cannot be set or cleared, just like with the regular hw offload flag. Otherwise we'd have to add more complexity and explicitly withdraw or add the device to the netdev -> flowtable mapping. Signed-off-by: Florian Westphal <fw@strlen.de> --- include/net/netfilter/nf_flow_table.h | 1 + include/uapi/linux/netfilter/nf_tables.h | 5 ++++- net/netfilter/nf_tables_api.c | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-)