Netfilter updates for net-next
Subsystems (3)
Pablo Neira Ayuso
maintainercover Netfilter updates for net-next
Hi David,
The following patchset contains Netfilter updates for net-next, they are:
1) default CONFIG_NETFILTER_INGRESS to y for easier compile-testing of all options.
2) Allow to bind a table to net_device. This introduces the internal NFT_AF_NEEDS_DEV flag to perform a mandatory check for this binding. This is required by the next patch.
3) Add the 'netdev' table family, this new table allows you to create ingress filter basechains. This provides access to the existing nf_tables features from ingress.
4) Kill unused argument from compat_find_calc_{match,target} in ip_tables and ip6_tables, from Florian Westphal.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git
Thanks!
----------------------------------------------------------------
The following changes since commit 76d7c457659dfc05d5a23cd0b21fea333d1788cd:
Merge branch 'icmp_frag' (2015-05-19 00:15:50 -0400)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git master
for you to fetch changes up to ed6c4136f1571bd6ab362afc3410905a8a69ca42:
netfilter: nf_tables: add netdev table to filter from ingress (2015-05-26 18:41:23 +0200)
----------------------------------------------------------------
Florian Westphal (1):
netfilter: remove unused comefrom hookmask argument
Pablo Neira Ayuso (3):
netfilter: default CONFIG_NETFILTER_INGRESS to y
netfilter: nf_tables: allow to bind table to net_device
netfilter: nf_tables: add netdev table to filter from ingress
include/net/netfilter/nf_tables.h | 8 ++ include/net/netns/nftables.h | 1 + include/uapi/linux/netfilter/nf_tables.h | 2 + net/ipv4/netfilter/ip_tables.c | 4 +- net/ipv6/netfilter/ip6_tables.c | 4 +- net/netfilter/Kconfig | 6 + net/netfilter/Makefile | 1 + net/netfilter/nf_tables_api.c | 46 +++++++- net/netfilter/nf_tables_netdev.c | 183 ++++++++++++++++++++++++++++++ 9 files changed, 244 insertions(+), 11 deletions(-) create mode 100644 net/netfilter/nf_tables_netdev.c
Pablo Neira Ayuso
maintainerPATCH 1/4 netfilter: remove unused comefrom hookmask argument
From: Florian Westphal <[email protected]>
--- net/ipv4/netfilter/ip_tables.c | 4 +--- net/ipv6/netfilter/ip6_tables.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-)
net/ipv4/netfilter/ip_tables.c +1 -3
@@ -1441,7 +1441,6 @@ static int compat_find_calc_match(struct xt_entry_match *m, const char *name, const struct ipt_ip *ip, - unsigned int hookmask, int *size) { struct xt_match *match;
@@ -1510,8 +1509,7 @@ check_compat_entry_size_and_hooks(struct compat_ipt_entry *e, entry_offset = (void *)e - (void *)base; j =0 ; xt_ematch_foreach(ematch, e) { - ret =compat_find_calc_match (ematch, name, - &e->ip, e->comefrom, &off); + ret =compat_find_calc_match (ematch, name, &e->ip, &off);if (ret !=0 ) goto release_matches; ++j;
net/ipv6/netfilter/ip6_tables.c +1 -3
@@ -1456,7 +1456,6 @@ static int compat_find_calc_match(struct xt_entry_match *m, const char *name, const struct ip6t_ip6 *ipv6, - unsigned int hookmask, int *size) { struct xt_match *match;
@@ -1525,8 +1524,7 @@ check_compat_entry_size_and_hooks(struct compat_ip6t_entry *e, entry_offset = (void *)e - (void *)base; j =0 ; xt_ematch_foreach(ematch, e) { - ret =compat_find_calc_match (ematch, name, - &e->ipv6, e->comefrom, &off); + ret =compat_find_calc_match (ematch, name, &e->ipv6, &off);if (ret !=0 ) goto release_matches; ++j;
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 2/4 netfilter: default CONFIG_NETFILTER_INGRESS to y
In reply to Pablo Neira AyusoUseful to compile-test all options.
--- net/netfilter/Kconfig | 1 + 1 file changed, 1 insertion(+)
net/netfilter/Kconfig +1 -0
@@ -3,6 +3,7 @@ menu "Core Netfilter Configuration" config NETFILTER_INGRESS bool "Netfilter ingress support" + default y select NET_INGRESS help This allows you to classify packets from ingress using the Netfilter
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 3/4 netfilter: nf_tables: allow to bind table to net_device
In reply to Pablo Neira AyusoThis patch adds the internal NFT_AF_NEEDS_DEV flag to indicate that you must attach this table to a net_device.
This change is required by the follow up patch that introduces the new netdev table.
--- include/net/netfilter/nf_tables.h | 8 ++++++ include/uapi/linux/netfilter/nf_tables.h | 2 ++ net/netfilter/nf_tables_api.c | 46 ++++++++++++++++++++++++++---- 3 files changed, 51 insertions(+), 5 deletions(-)
include/net/netfilter/nf_tables.h +8 -0
@@ -819,6 +819,7 @@ unsigned int nft_do_chain(struct nft_pktinfo *pkt,* @use: number of chain references to this table * @flags: table flag (see enum nft_table_flags) * @name: name of the table +* @dev: this table is bound to this device (if any) */ struct nft_table {struct list_head list;
@@ -828,6 +829,11 @@ struct nft_table {u32 use;u16 flags;char name[NFT_TABLE_MAXNAMELEN ]; +struct net_device *dev; +}; + +enum nft_af_flags { +NFT_AF_NEEDS_DEV = (1 <<0 ), };/**
@@ -838,6 +844,7 @@ struct nft_table {* @nhooks: number of hooks in this family * @owner: module owner * @tables: used internally +* @flags: family flags * @nops: number of hook ops in this family * @hook_ops_init: initialization function for chain hook ops * @hooks: hookfn overrides for packet validation
@@ -848,6 +855,7 @@ struct nft_af_info {unsigned int nhooks;struct module *owner;struct list_head tables; +u32 flags;unsigned int nops;void (*hook_ops_init)(struct nf_hook_ops *,unsigned int );
include/uapi/linux/netfilter/nf_tables.h +2 -0
@@ -146,12 +146,14 @@ enum nft_table_flags {* @NFTA_TABLE_NAME: name of the table (NLA_STRING) * @NFTA_TABLE_FLAGS: bitmask of enum nft_table_flags (NLA_U32) * @NFTA_TABLE_USE: number of chains in this table (NLA_U32) +* @NFTA_TABLE_DEV: net device name (NLA_STRING) */ enum nft_table_attributes {NFTA_TABLE_UNSPEC ,NFTA_TABLE_NAME ,NFTA_TABLE_FLAGS ,NFTA_TABLE_USE , +NFTA_TABLE_DEV , __NFTA_TABLE_MAX };#define NFTA_TABLE_MAX (__NFTA_TABLE_MAX - 1)
net/netfilter/nf_tables_api.c +41 -5
107 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 4/4 netfilter: nf_tables: add netdev table to filter from ingress
In reply to Pablo Neira AyusoThis allows us to create netdev tables that contain ingress chains. Use skb_header_pointer() as we may see shared sk_buffs at this stage.
This change provides access to the existing nf_tables features from the ingress hook.
--- include/net/netns/nftables.h | 1 + net/netfilter/Kconfig | 5 ++ net/netfilter/Makefile | 1 + net/netfilter/nf_tables_netdev.c | 183 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 190 insertions(+) create mode 100644 net/netfilter/nf_tables_netdev.c
include/net/netns/nftables.h +1 -0
@@ -13,6 +13,7 @@ struct netns_nftables {struct nft_af_info *inet;struct nft_af_info *arp;struct nft_af_info *bridge; +struct nft_af_info *netdev;unsigned int base_seq;u8 gencursor; };
net/netfilter/Kconfig +5 -0
@@ -456,6 +456,11 @@ config NF_TABLES_INET help This option enables support for a mixed IPv4/IPv6 "inet" table. +config NF_TABLES_NETDEV + tristate "Netfilter nf_tables netdev tables support" + help + This option enables support for the "netdev" table. + config NFT_EXTHDR tristate "Netfilter nf_tables IPv6 exthdr module" help
net/netfilter/Makefile +1 -0
@@ -75,6 +75,7 @@ nf_tables-objs += nft_bitwise.o nft_byteorder.o nft_payload.o obj-$(CONFIG_NF_TABLES) += nf_tables.o obj-$(CONFIG_NF_TABLES_INET) += nf_tables_inet.o +obj-$(CONFIG_NF_TABLES_NETDEV) += nf_tables_netdev.o obj-$(CONFIG_NFT_COMPAT) += nft_compat.o obj-$(CONFIG_NFT_EXTHDR) += nft_exthdr.o obj-$(CONFIG_NFT_META) += nft_meta.o
net/netfilter/nf_tables_netdev.c new file +183 -0
183 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Re: [PATCH 2/4] netfilter: default CONFIG_NETFILTER_INGRESS to y
In reply to Pablo Neira AyusoQuoted 9 lines · Pablo Neira Ayuso
Useful to compile-test all options.
net/netfilter/Kconfig +0
-0@@ -3,6 +3,7 @@ menu "Core Netfilter Configuration"config
NETFILTER_INGRESS
bool "Netfilter ingress support"net/netfilter/Kconfig +1
-0+ default y
Quoted 3 lines
select
NET_INGRESS
help
This allows you to classify packets from ingress using the Netfilter
Careful with default y. I seem to remember that someone higher up (perhaps Linus himself) was against "default y" for features deemed not essential (especially hardware drivers), as no driver is any more important than another. If "compile-test" is your reason for the patch, it might fall into the same category.
Pablo Neira Ayuso
maintainerRe: [PATCH 2/4] netfilter: default CONFIG_NETFILTER_INGRESS to y
Quoted 8 lines · Jan Engelhardt
Quoted 6 lines · Pablo Neira Ayuso
Useful to compile-test all options.
net/netfilter/Kconfig +0
-0@@ -3,6 +3,7 @@ menu "Core Netfilter Configuration"
Quoted 12 lines
Quoted 6 lines
config
NETFILTER_INGRESS
bool "Netfilter ingress support"net/netfilter/Kconfig +1
-0+ default yselect
NET_INGRESS
help
This allows you to classify packets from ingress using the NetfilterCareful with default y. I seem to remember that someone higher up (perhaps Linus himself) was against "default y" for features deemed not essential (especially hardware drivers), as no driver is any more important than another. If "compile-test" is your reason for the patch, it might fall into the same category.
This config option is hiding behind the global CONFIG_NETFILTER switch that, if enabled, gets the very basic hook infrastructure, and this ingress hook falls into that category.
I agree this makes sense for hardware drivers, but this is not the case.
David Miller
maintainerFrom: Pablo Neira Ayuso <[email protected]>
Date: Fri, 29 May 2015 01:44:51 +0200
Quoted 13 lines
The following patchset contains Netfilter updates for net-next, they are:
1) default
CONFIG_NETFILTER_INGRESSto y for easier compile-testing of all options.2) Allow to bind a table to
net_device. This introduces the internalNFT_AF_NEEDS_DEVflag to perform a mandatory check for this binding. This is required by the next patch.3) Add the 'netdev' table family, this new table allows you to create ingress filter basechains. This provides access to the existing
nf_tablesfeatures from ingress.
Quoted 6 lines
4) Kill unused argument from compat_find_calc_{match,target} in
ip_tablesandip6_tables, from Florian Westphal.You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git
Pulled, thanks Pablo.