Simplify netfilter and network namespaces (take 2)
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest43 patches 4 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/43 | netfilter: Kill unused copies of RCV_SKB_FAILnet/ net/ | +0 | 0 replies | |
| 2/43 | netfilter: Pass struct net into the netfilter hooksinclude/ include/ net/ +27 more | +190 | 0 replies | |
| 3/43 | netfilter: Use nf_hook_state.netnet/ net/ net/ +18 more | +41 | 0 replies | |
| 4/43 | ebtables: Simplify the arguments to ebt_do_tableinclude/ net/ net/ +2 more | +20 | 0 replies | |
| 5/43 | inet netfilter: Remove hook from ip6t_do_table, arp_do_table, ipt_do_tableinclude/ include/ include/ +14 more | +25 | 0 replies | |
| 6/43 | inet netfilter: Prefer state->hook to ops->hooknumnet/ net/ net/ +3 more | +21 | 0 replies | |
| 7/43 | nftables: kill nft_pktinfo.opsinclude/ include/ include/ +20 more | +52 | 0 replies | |
| 8/43 | tc: Simplify em_ipset_matchnet/ | +2 | 0 replies | |
| 9/43 | x_tables: Pass struct net in xt_action_paraminclude/ include/ net/ +5 more | +9 | 0 replies | |
| 10/43 | x_tables: Use par->net instead of computing from the passed net devicesnet/ net/ net/ +15 more | +45 | 0 replies | |
| 11/43 | nftables: Pass struct net in nft_pktinfoinclude/ | +2 | 0 replies | |
| 12/43 | nf_tables: Use pkt->net instead of computing net from the passed net_devicesnet/ net/ net/ +2 more | +14 | 0 replies | |
| 13/43 | nf_conntrack: Add a struct net parameter to l4_pkt_to_tupleinclude/ include/ include/ +12 more | +23 | 0 replies | |
| 14/43 | ipv4: Pass struct net into ip_defrag and ip_check_defragdrivers/ include/ net/ +4 more | +20 | 0 replies | |
| 15/43 | ipv6: Pass struct net into nf_ct_frag6_gatherinclude/ net/ net/ | +4 | 0 replies | |
| 16/43 | net: include missing headers in net/net_namespace.hinclude/ | +2 | 0 replies | |
| 17/43 | netfilter: use forward declaration instead of including linux/proc_fs.hinclude/ net/ | +2 | 0 replies | |
| 18/43 | netfilter: don't pull include/linux/netfilter.h from netns headersinclude/ include/ include/ +3 more | +16 | 0 replies | |
| 19/43 | ipvs: Read hooknum from state rather than ops->hooknumnet/ | +8 | 0 replies | |
| 20/43 | netfilter: Pass priv instead of nf_hook_ops to netfilter hooksinclude/ include/ include/ +38 more | +155 | 0 replies | |
| 21/43 | netfilter: Add a network namespace Kconfig conflictinit/ | +1 | 0 replies | |
| 22/43 | netfilter: Add a struct net parameter to nf_register_hook[s]include/ net/ net/ +18 more | +32 | 0 replies | |
| 23/43 | netfilter: Add a struct net parameter to nf_unregister_hook[s]include/ net/ net/ +16 more | +30 | 0 replies | |
| 24/43 | netfilter: Make the netfilter hooks per network namespaceinclude/ include/ net/ | +17 | 0 replies | |
| 25/43 | netfilter: Make nf_hook_ops just a parameter structureinclude/ include/ net/ +2 more | +80 | 0 replies | |
| 26/43 | netfitler: Remove spurios included of netfilter.hdrivers/ drivers/ drivers/ +9 more | +0 | 0 replies | |
| 27/43 | x_tables: Add magical hook registration in the common caseinclude/ net/ net/ | +75 | 0 replies | |
| 28/43 | x_tables: Where possible convert to the new hook registration methodnet/ net/ net/ +6 more | +27 | 0 replies | |
| 29/43 | x_tables: Kill xt_[un]hook_linkinclude/ net/ | +0 | 0 replies | |
| 30/43 | x_tables: Update ip?table_nat to register their hooks in all network namespacesnet/ net/ | +24 | 0 replies | |
| 31/43 | netfilter: nf_tables: adapt it to pernet hooksnet/ | +6 | 0 replies | |
| 32/43 | netfilter: ipt_CLUSTERIP: adapt it to support pernet hooksnet/ | +7 | 0 replies | |
| 33/43 | netfilter: ebtables: adapt the filter and nat table to pernet hooksnet/ net/ | +25 | 0 replies | |
| 34/43 | netfilter: bridge: adapt it to pernet hooksnet/ | +16 | 0 replies | |
| 35/43 | ipvs: Register netfilter hooks in all network namespacesnet/ | +8 | 0 replies | |
| 36/43 | netfilter: nf_conntract: Register netfilter hooks in all network namespacesnet/ net/ | +23 | 0 replies | |
| 37/43 | netfilter: nf_defrag: Register netfilter hooks in all network namespacesnet/ net/ | +36 | 0 replies | |
| 38/43 | netfilter: synproxy: Register netfilter hooks in all network namespacesnet/ net/ | +40 | 0 replies | |
| 39/43 | selinux: adapt it to pernet hookssecurity/ | +18 | 0 replies | |
| 40/43 | smack: adapt it to pernet hookssecurity/ | +16 | 0 replies | |
| 41/43 | netfilter: Remove the network namespace Kconfig conflictinit/ | +0 | 0 replies | |
| 42/43 | netfilter bridge: Make the sysctl knobs per network namespaceinclude/ net/ | +103 | 0 replies | |
| 43/43 | netfilter: Skip unnecessary calls to synchronize_netnet/ | +3 | 2 replies |
Reviews trailers per patch
None of the 43 patches has a Reviewed-by or Acked-by.
| Patch | Pablo Neira Ayuso |
|---|---|
| 1/43 | |
| 2/43 | |
| 3/43 | |
| 4/43 | |
| 5/43 | |
| 6/43 | |
| 7/43 | |
| 8/43 | |
| 9/43 | |
| 10/43 | |
| 11/43 | |
| 12/43 | |
| 13/43 | |
| 14/43 | |
| 15/43 | |
| 16/43 | |
| 17/43 | |
| 18/43 | |
| 19/43 | |
| 20/43 | |
| 21/43 | |
| 22/43 | |
| 23/43 | |
| 24/43 | Inspired-by |
| 25/43 | |
| 26/43 | |
| 27/43 | |
| 28/43 | |
| 29/43 | |
| 30/43 | |
| 31/43 | |
| 32/43 | |
| 33/43 | |
| 34/43 | |
| 35/43 | |
| 36/43 | |
| 37/43 | |
| 38/43 | Inspired-by |
| 39/43 | |
| 40/43 | |
| 41/43 | |
| 42/43 | |
| 43/43 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH net-next 00/43] Simplify netfilter and network namespaces (take 2)
While looking into what it would take to route packets out to network devices in other network namespaces I started looking at the netfilter hooks, and there is a lot of nasty code to figure out which network namespace to filter the packets in.
Passing the network namespace into the netfilter hooks is a significant simplication in the code, and worth it as the first thing most netfilter hooks do is compute the network namespace.
I collided with Pablos work on per network namespace netfilter hooks the first time I submitted his changes, so now this patchset includes a per network namespace nftable hooks. Inspired by Pablos work but largely rewritten to fix and avoid the bugs I was finding in Pablos work to register the netfilter hooks per network namespace.
These per network namespace netfilter hooks fix a long standing bug in nftables, where packets passing through nftables would be run against the nftables configuration of every network namespace.
I have noticed what appears to be one more bug in nftables. Today the nf_queue code takes a module reference count to prevent the netfilter hook that it stops at from being unregistered. As it is the module initialization and module cleanup code that call nf_unregister_hook[s] in everything but nftables this works. Unfortunately it appears that someone can cause a packet to be queued, delete the nftable chain that caused the queueing and then cause the packet to be reinjected. So it looks like nfqnl_rcv_dev_event is needed for netfilter hook unregistration.
The first group of changes roots out all of the very weird network namespace computation logic (except for the code in ipvs) and fixes it. I really don't like how the code has been essentially guessing which network namespace to use.
Probably the worst guessing is in ipvs in the function skb_net. I have some preliminary changes to fix ipvs but they are not quite ready yet. Cleaning up ipvs enough that I can kill skb_net is on my short list.
There are a few extra cleanups in the first group of changes sprinkled in as I noticed a few other things as I was sorting out the network namespace computation logic.
There rest of the changes are based on Pablos per network namespace netfilter hook work and include related cleanups and simplifications. The most non-obvious detail were the necessary header file cleanups.
The changes where I started with Pablos patches in some cases the credits get a little weird and the descriptions are a little weaker than I would like but overall I think it is all close enough.
Eric W. Biederman (36):
ipvs: Read hooknum from state rather than ops->hooknum
netfilter: Pass priv instead of nf_hook_ops to netfilter hooks
netfilter: Add a network namespace Kconfig conflict
netfilter: Add a struct net parameter to nf_register_hook[s]
netfilter: Add a struct net parameter to nf_unregister_hook[s]
netfilter: Make the netfilter hooks per network namespace
netfilter: Make nf_hook_ops just a parameter structure
netfitler: Remove spurios included of netfilter.h
x_tables: Add magical hook registration in the common case
x_tables: Where possible convert to the new hook registration method
x_tables: Kill xt_[un]hook_link
x_tables: Update ip?table_nat to register their hooks in all network namespaces
netfilter: bridge: adapt it to pernet hooks
ipvs: Register netfilter hooks in all network namespaces
netfilter: nf_conntract: Register netfilter hooks in all network namespaces
netfilter: nf_defrag: Register netfilter hooks in all network namespaces
netfilter: synproxy: Register netfilter hooks in all network namespaces
smack: adapt it to pernet hooks
netfilter bridge: Make the sysctl knobs per network namespace
netfilter: Skip unnecessary calls to synchronize_net
netfilter: Kill unused copies of RCV_SKB_FAIL
netfilter: Pass struct net into the netfilter hooks
netfilter: Use nf_hook_state.net
ebtables: Simplify the arguments to ebt_do_table
inet netfilter: Remove hook from ip6t_do_table, arp_do_table, ipt_do_table inet netfilter: Prefer state->hook to ops->hooknum
nftables: kill nft_pktinfo.ops
tc: Simplify em_ipset_match
x_tables: Pass struct net in xt_action_param
x_tables: Use par->net instead of computing from the passed net devices
nftables: Pass struct net in nft_pktinfo
nf_tables: Use pkt->net instead of computing net from the passed net_devices
nf_conntrack: Add a struct net parameter to l4_pkt_to_tuple
ipv4: Pass struct net into ip_defrag and ip_check_defrag
ipv6: Pass struct net into nf_ct_frag6_gather
netfilter: Remove the network namespace Kconfig conflict
Pablo Neira Ayuso (7):
net: include missing headers in net/net_namespace.h
netfilter: use forward declaration instead of including linux/proc_fs.h
netfilter: don't pull include/linux/netfilter.h from netns headers
netfilter: nf_tables: adapt it to pernet hooks
netfilter: ipt_CLUSTERIP: adapt it to support pernet hooks
netfilter: ebtables: adapt the filter and nat table to pernet hooks
selinux: adapt it to pernet hooks
Eric