Skip to content

Passing net through the netfilter hooks

Eric W. Biederman lvs-devel netdev netfilter-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest30 patches 10 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/30netfilter: Remove !CONFIG_NETFITLER definition of nf_hook_threshinclude/linux/netfilter.h+0 -90 replies
2/30netfilter: Store net in nf_hook_stateinclude/linux/netfilter.h include/linux/netfilter_ingress.h+5 -20 replies
3/30netfilter: Pass net to nf_hook_threshinclude/linux/netfilter.h+7 -40 replies
4/30xfrm: Remove unused afinfo method init_dstinclude/net/xfrm.h net/xfrm/xfrm_policy.c+0 -40 replies
5/30net: Merge dst_output and dst_output_skinclude/net/dst.h net/decnet/dn_nsp_out.c net/ipv4/ip_forward.c +16 more+26 -300 replies
6/30ipv4: Compute net once in ip_forwardnet/ipv4/ip_forward.c+4 -20 replies
7/30ipv4: Compute net once in ip_forward_finishnet/ipv4/ip_forward.c+3 -20 replies
8/30ipv4: Compute net once in ip_rcvnet/ipv4/ip_input.c+9 -70 replies
9/30ipv4: Remember the net in ip_output and ip_mc_outputnet/ipv4/ip_output.c+4 -20 replies
10/30ipv4: Don't recompute net in ipmr_queue_xmitnet/ipv4/ipmr.c+1 -10 replies
11/30ipv4: Only compute net once in ip_do_fragmentnet/ipv4/ip_output.c+8 -60 replies
12/30ipv4: Explicitly compute net in ip_fragmentnet/ipv4/ip_output.c+2 -30 replies
13/30ipv4: Only compute net once in ip_finish_output2net/ipv4/ip_output.c+3 -20 replies
14/30ipv4: Only compute net once in ip_rcv_finishnet/ipv4/ip_input.c+4 -60 replies
15/30ipv4: Only compute net once in ipmr_forward_finishnet/ipv4/ipmr.c+3 -20 replies
16/30ipv6: Only compute net once in ip6mr_forward2_finishnet/ipv6/ip6mr.c+3 -21 reply
17/30arp: Introduce arp_xmit_finishnet/ipv4/arp.c+6 -10 replies
18/30bridge: Introduce br_send_bpdu_finishnet/bridge/br_stp_bpdu.c+6 -10 replies
19/30net: Remove dev_queue_xmit_skinclude/linux/netdevice.h net/core/dev.c+3 -70 replies
20/30ipv6: Don't recompute net in ip6_rcvnet/ipv6/ip6_input.c+1 -10 replies
21/30ipv6: Only compute net once in ip6_finish_output2net/ipv6/ip6_output.c+5 -60 replies
22/30ipv6: Cache net in ip6_outputnet/ipv6/ip6_output.c+2 -21 reply
23/30ipv6: Compute net once in raw6_send_hdrincnet/ipv6/raw.c+3 -20 replies
24/30bridge: Pass net into br_nf_ip_fragmentnet/bridge/br_netfilter_hooks.c+6 -60 replies
25/30bridge: Pass net into br_nf_push_frag_xmitnet/bridge/br_netfilter_hooks.c+8 -30 replies
26/30bridge: Cache net in br_nf_pre_routing_finishnet/bridge/br_netfilter_hooks.c+2 -10 replies
27/30bridge: Add br_netif_receive_skb remove netif_receive_skb_skinclude/linux/netdevice.h net/bridge/br_input.c net/core/dev.c+9 -80 replies
28/30netfilter: Pass struct net into the netfilter hooksdrivers/net/vrf.c include/linux/netfilter.h net/bridge/br_forward.c +28 more+142 -1201 reply
29/30netfilter: Use nf_hook_state.netnet/bridge/netfilter/ebtable_filter.c net/bridge/netfilter/ebtable_nat.c net/ipv4/netfilter/arptable_filter.c +18 more+41 -580 replies
30/30netfilter: Pass net into okfndrivers/net/vrf.c include/linux/netdevice.h include/linux/netfilter.h +34 more+95 -940 replies

Reviews trailers per patch

None of the 30 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchNicolas DichtelJulian AnastasovPablo Neira Ayuso
SeriesA-b A-b A-b A-b A-b A-b A-b A-b A-b
1/30
2/30
3/30
4/30
5/30
6/30
7/30
8/30
9/30
10/30
11/30
12/30
13/30
14/30
15/30
16/30
17/30
18/30
19/30
20/30
21/30
22/30
23/30
24/30
25/30
26/30
27/30
28/30
29/30
30/30

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH next 0/30] Passing net through the netfilter hooks

My primary goal with this patchset and it's follow ups is to cleanup the network routing paths so that we do not look at the output device to derive the network namespace. My plan is to pass the network namespace of the transmitting socket through the output path, to replace code that looks at the output network device today. Once that is done we can have routes with output devices outside of the current network namespace. Which should allow reception and transmission of packets in network namespaces to be as fast as normal packet reception and transmission with early demux disabled, because it will same code path.

Once skb_dst(skb)->dev is a little better under control I think it will also be possible to use rcu to cleanup the ancient hack that sets dst->dev to loopback_dev when a network device is removed.

The work to get there is a series of code cleanups. I am starting with passing net into the netfilter hooks and into the functions that are called after the netfilter hooks. This removes from netfilter the need to guess which network namespace it is working on.

To get there I perform a series of minor prep patches so the big changes at the end are possible to audit without getting lost in the noise. In particular I have a lot of patches computing net into a local variable and then using it through out the function.

So this patchset encompases removing dead code, sorting out the _sk functions that were added last time someone pushed a prototype change through the post netfilter functions. Cleaning up individual functions use of the network namespace. Passing net into the netfilter hooks. Passing net into the post netfilter functions. Using state->net in the netfilter code where it is available and trivially usable.

Pablo, Dave I don't know whose tree this makes more sense to go through. I am assuming at least initially Pablos as netfilter is involved. From what I have seen there will be a lot of back and forth between the netfilter code paths and the routing code paths.

The patches are also available (against 4.3-rc1) at:
git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/net-next.git master

Eric W. Biederman (30):
netfilter: Remove !CONFIG_NETFITLER definition of nf_hook_thresh
netfilter: Store net in nf_hook_state
netfilter: Pass net to nf_hook_thresh
xfrm: Remove unused afinfo method init_dst
net: Merge dst_output and dst_output_sk
ipv4: Compute net once in ip_forward
ipv4: Compute net once in ip_forward_finish
ipv4: Compute net once in ip_rcv
ipv4: Remember the net in ip_output and ip_mc_output
ipv4: Don't recompute net in ipmr_queue_xmit
ipv4: Only compute net once in ip_do_fragment
ipv4: Explicitly compute net in ip_fragment
ipv4: Only compute net once in ip_finish_output2
ipv4: Only compute net once in ip_rcv_finish
ipv4: Only compute net once in ipmr_forward_finish
ipv6: Only compute net once in ip6mr_forward2_finish
arp: Introduce arp_xmit_finish
bridge: Introduce br_send_bpdu_finish
net: Remove dev_queue_xmit_sk
ipv6: Don't recompute net in ip6_rcv
ipv6: Only compute net once in ip6_finish_output2
ipv6: Cache net in ip6_output
ipv6: Compute net once in raw6_send_hdrinc
bridge: Pass net into br_nf_ip_fragment
bridge: Pass net into br_nf_push_frag_xmit
bridge: Cache net in br_nf_pre_routing_finish
bridge: Add br_netif_receive_skb remove netif_receive_skb_sk
netfilter: Pass struct net into the netfilter hooks
netfilter: Use nf_hook_state.net
netfilter: Pass net into okfn

 drivers/net/vrf.c                              |  9 ++--
 include/linux/netdevice.h                      | 14 ++----
 include/linux/netfilter.h                      | 68 ++++++++++++--------------
 include/linux/netfilter_bridge.h               |  2 +-
 include/linux/netfilter_ingress.h              |  2 +-
 include/net/dn_neigh.h                         |  6 +--
 include/net/dst.h                              |  6 +--
 include/net/ipv6.h                             |  2 +-
 include/net/netfilter/br_netfilter.h           |  2 +-
 include/net/xfrm.h                             |  2 -
 net/bridge/br_forward.c                        | 16 +++---
 net/bridge/br_input.c                          | 25 ++++++----
 net/bridge/br_multicast.c                      |  4 +-
 net/bridge/br_netfilter_hooks.c                | 54 ++++++++++----------
 net/bridge/br_netfilter_ipv6.c                 |  8 +--
 net/bridge/br_private.h                        |  6 +--
 net/bridge/br_stp_bpdu.c                       | 12 +++--
 net/bridge/netfilter/ebtable_filter.c          |  4 +-
 net/bridge/netfilter/ebtable_nat.c             |  4 +-
 net/core/dev.c                                 | 12 +++--
 net/decnet/dn_neigh.c                          | 23 +++++----
 net/decnet/dn_nsp_in.c                         |  7 +--
 net/decnet/dn_nsp_out.c                        |  4 +-
 net/decnet/dn_route.c                          | 30 ++++++------
 net/ipv4/arp.c                                 | 20 +++++---
 net/ipv4/ip_forward.c                          | 19 ++++---
 net/ipv4/ip_input.c                            | 39 +++++++--------
 net/ipv4/ip_output.c                           | 58 ++++++++++++----------
 net/ipv4/ip_vti.c                              |  2 +-
 net/ipv4/ipmr.c                                | 15 +++---
 net/ipv4/netfilter/arptable_filter.c           |  4 +-
 net/ipv4/netfilter/ip_tables.c                 |  8 +--
 net/ipv4/netfilter/ipt_CLUSTERIP.c             |  2 +-
 net/ipv4/netfilter/ipt_SYNPROXY.c              |  2 +-
 net/ipv4/netfilter/iptable_filter.c            |  6 +--
 net/ipv4/netfilter/iptable_mangle.c            |  7 ++-
 net/ipv4/netfilter/iptable_nat.c               |  5 +-
 net/ipv4/netfilter/iptable_raw.c               |  6 +--
 net/ipv4/netfilter/iptable_security.c          |  5 +-
 net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c |  4 +-
 net/ipv4/raw.c                                 |  5 +-
 net/ipv4/xfrm4_input.c                         |  7 +--
 net/ipv4/xfrm4_output.c                        | 10 ++--
 net/ipv6/ip6_input.c                           | 15 +++---
 net/ipv6/ip6_output.c                          | 37 +++++++-------
 net/ipv6/ip6_vti.c                             |  2 +-
 net/ipv6/ip6mr.c                               | 12 ++---
 net/ipv6/mcast.c                               |  9 ++--
 net/ipv6/ndisc.c                               |  6 +--
 net/ipv6/netfilter/ip6_tables.c                |  8 +--
 net/ipv6/netfilter/ip6t_SYNPROXY.c             |  2 +-
 net/ipv6/netfilter/ip6table_filter.c           |  5 +-
 net/ipv6/netfilter/ip6table_mangle.c           |  6 +--
 net/ipv6/netfilter/ip6table_nat.c              |  5 +-
 net/ipv6/netfilter/ip6table_raw.c              |  5 +-
 net/ipv6/netfilter/ip6table_security.c         |  4 +-
 net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c |  4 +-
 net/ipv6/netfilter/nf_defrag_ipv6_hooks.c      |  2 +-
 net/ipv6/output_core.c                         |  8 +--
 net/ipv6/raw.c                                 |  9 ++--
 net/ipv6/xfrm6_input.c                         |  4 +-
 net/ipv6/xfrm6_output.c                        | 10 ++--
 net/netfilter/ipvs/ip_vs_xmit.c                |  8 +--
 net/netfilter/nf_queue.c                       |  2 +-
 net/netfilter/nfnetlink_queue_core.c           |  3 +-
 net/xfrm/xfrm_output.c                         | 17 ++++---
 net/xfrm/xfrm_policy.c                         |  4 +-
 67 files changed, 375 insertions(+), 358 deletions(-)