diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2020-05-20 20:23:35 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2020-06-02 14:05:38 +0200 |
commit | d47f1652088769a9dedb1fc5762c2d9d2e5d500b (patch) | |
tree | 14d195e031bed83c4b8f1c7add18e53579830ad7 /src/mnl.c | |
parent | 45f98f7451c7c3c3deb00de18683dba1970bee0c (diff) |
src: add devices to an existing flowtable
This patch allows you to add new devices to an existing flowtables.
# nft add flowtable x y { devices = { eth0 } \; }
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/mnl.c')
-rw-r--r-- | src/mnl.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -1640,11 +1640,17 @@ int mnl_nft_flowtable_add(struct netlink_ctx *ctx, struct cmd *cmd, nftnl_flowtable_set_u32(flo, NFTNL_FLOWTABLE_FAMILY, cmd->handle.family); - nftnl_flowtable_set_u32(flo, NFTNL_FLOWTABLE_HOOKNUM, - cmd->flowtable->hook.num); - mpz_export_data(&priority, cmd->flowtable->priority.expr->value, - BYTEORDER_HOST_ENDIAN, sizeof(int)); - nftnl_flowtable_set_u32(flo, NFTNL_FLOWTABLE_PRIO, priority); + + if (cmd->flowtable->hook.name) { + nftnl_flowtable_set_u32(flo, NFTNL_FLOWTABLE_HOOKNUM, + cmd->flowtable->hook.num); + mpz_export_data(&priority, cmd->flowtable->priority.expr->value, + BYTEORDER_HOST_ENDIAN, sizeof(int)); + nftnl_flowtable_set_u32(flo, NFTNL_FLOWTABLE_PRIO, priority); + } else { + nftnl_flowtable_set_u32(flo, NFTNL_FLOWTABLE_HOOKNUM, 0); + nftnl_flowtable_set_u32(flo, NFTNL_FLOWTABLE_PRIO, 0); + } dev_array = nft_flowtable_dev_array(cmd); nftnl_flowtable_set_data(flo, NFTNL_FLOWTABLE_DEVICES, |