Skip to content

Commit d54725c

Browse files
committed
netfilter: nf_tables: support for multiple devices per netdev hook
This patch allows you to register one netdev basechain to multiple devices. This adds a new NFTA_HOOK_DEVS netlink attribute to specify the list of netdevices. Basechains store a list of hooks. Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent bbaef95 commit d54725c

File tree

5 files changed

+293
-98
lines changed

5 files changed

+293
-98
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,21 +973,21 @@ struct nft_hook {
973973
* struct nft_base_chain - nf_tables base chain
974974
*
975975
* @ops: netfilter hook ops
976+
* @hook_list: list of netfilter hooks (for NFPROTO_NETDEV family)
976977
* @type: chain type
977978
* @policy: default policy
978979
* @stats: per-cpu chain stats
979980
* @chain: the chain
980-
* @dev_name: device name that this base chain is attached to (if any)
981981
* @flow_block: flow block (for hardware offload)
982982
*/
983983
struct nft_base_chain {
984984
struct nf_hook_ops ops;
985+
struct list_head hook_list;
985986
const struct nft_chain_type *type;
986987
u8 policy;
987988
u8 flags;
988989
struct nft_stats __percpu *stats;
989990
struct nft_chain chain;
990-
char dev_name[IFNAMSIZ];
991991
struct flow_block flow_block;
992992
};
993993

include/uapi/linux/netfilter/nf_tables.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,14 @@ enum nft_list_attributes {
144144
* @NFTA_HOOK_HOOKNUM: netfilter hook number (NLA_U32)
145145
* @NFTA_HOOK_PRIORITY: netfilter hook priority (NLA_U32)
146146
* @NFTA_HOOK_DEV: netdevice name (NLA_STRING)
147+
* @NFTA_HOOK_DEVS: list of netdevices (NLA_NESTED)
147148
*/
148149
enum nft_hook_attributes {
149150
NFTA_HOOK_UNSPEC,
150151
NFTA_HOOK_HOOKNUM,
151152
NFTA_HOOK_PRIORITY,
152153
NFTA_HOOK_DEV,
154+
NFTA_HOOK_DEVS,
153155
__NFTA_HOOK_MAX
154156
};
155157
#define NFTA_HOOK_MAX (__NFTA_HOOK_MAX - 1)

0 commit comments

Comments
 (0)