Skip to content

netfilter: Stop guessing net (take 2)

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 Latest15 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/15ebtables: Simplify the arguments to ebt_do_tableinclude/linux/netfilter_bridge/ebtables.h net/bridge/netfilter/ebtable_broute.c net/bridge/netfilter/ebtable_filter.c +2 more+20 -190 replies
1/15ipv4: Fix ip_local_out_sk by passing the sk into __ip_local_out_sknet/ipv4/ip_output.c+1 -12 replies
2/15inet netfilter: Remove hook from ip6t_do_table, arp_do_table, ipt_do_tableinclude/linux/netfilter_arp/arp_tables.h include/linux/netfilter_ipv4/ip_tables.h include/linux/netfilter_ipv6/ip6_tables.h +14 more+25 -410 replies
2/15xfrm: Only compute net once in xfrm_policy_queue_processnet/xfrm/xfrm_policy.c+3 -40 replies
3/15inet netfilter: Prefer state->hook to ops->hooknumnet/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c net/ipv4/netfilter/nf_defrag_ipv4.c net/ipv4/netfilter/nf_nat_l3proto_ipv4.c +3 more+21 -210 replies
3/15net: Pass net into dst_output and remove dst_output_okfninclude/net/dst.h net/decnet/dn_nsp_out.c net/ipv4/ip_forward.c +16 more+28 -300 replies
4/15nftables: kill nft_pktinfo.opsinclude/net/netfilter/nf_tables.h include/net/netfilter/nf_tables_ipv4.h include/net/netfilter/nf_tables_ipv6.h +22 more+54 -640 replies
4/15dst: Pass a sk into .local_outdrivers/net/vrf.c include/net/dst_ops.h include/net/ip.h +8 more+12 -100 replies
5/15x_tables: Pass struct net in xt_action_paraminclude/linux/netfilter/x_tables.h include/net/netfilter/nf_tables.h net/bridge/netfilter/ebtables.c +5 more+9 -10 replies
5/15ipv4: Merge __ip_local_out and __ip_local_out_skinclude/net/ip.h net/ipv4/ip_output.c net/ipv4/route.c +1 more+5 -110 replies
6/15x_tables: Use par->net instead of computing from the passed net devicesnet/bridge/netfilter/ebt_log.c net/bridge/netfilter/ebt_nflog.c net/ipv4/netfilter/ipt_SYNPROXY.c +14 more+41 -430 replies
6/15ipv4: Merge ip_local_out and ip_local_out_skdrivers/net/ipvlan/ipvlan_core.c drivers/net/ppp/pptp.c drivers/net/vrf.c +8 more+17 -213 replies
7/15nftables: Pass struct net in nft_pktinfoinclude/net/netfilter/nf_tables.h+2 -10 replies
7/15ipv6: Merge __ip6_local_out and __ip6_local_out_skinclude/net/ipv6.h net/ipv6/output_core.c net/ipv6/route.c +1 more+5 -110 replies
8/15nftables: Use pkt->net instead of computing net from the passed net_devicesnet/bridge/netfilter/nft_reject_bridge.c net/ipv6/netfilter/nft_reject_ipv6.c net/netfilter/nf_tables_core.c +2 more+15 -200 replies
8/15ipv6: Merge ip6_local_out and ip6_local_out_skdrivers/net/ipvlan/ipvlan_core.c include/net/ip6_tunnel.h include/net/ipv6.h +6 more+9 -160 replies
9/15net: Pass net to nf_dup_ipv4 and nf_dup_ipv6include/net/netfilter/ipv4/nf_dup_ipv4.h include/net/netfilter/ipv6/nf_dup_ipv6.h net/ipv4/netfilter/nf_dup_ipv4.c +4 more+14 -440 replies
9/15ipv4: Cache net in iptunnel_xmitnet/ipv4/ip_tunnel_core.c+2 -20 replies
10/15act_connmark: Remember the struct net instead of guessing it.include/net/tc_act/tc_connmark.h net/sched/act_connmark.c+3 -10 replies
10/15ipv4: Cache net in ip_build_and_send_pkt and ip_queue_xmitnet/ipv4/ip_output.c+6 -43 replies
11/15nf_conntrack: Add a struct net parameter to l4_pkt_to_tupleinclude/net/netfilter/nf_conntrack.h include/net/netfilter/nf_conntrack_core.h include/net/netfilter/nf_conntrack_l4proto.h +13 more+24 -180 replies
11/15ppp: Cache net in pptp_xmitdrivers/net/ppp/pptp.c+3 -20 replies
12/15ipvs: Read hooknum from state rather than ops->hooknumnet/netfilter/ipvs/ip_vs_core.c+8 -80 replies
12/15ipvlan: Cache net in ipvlan_process_v4_outbound and ipvlan_process_v6_outbounddrivers/net/ipvlan/ipvlan_core.c+4 -22 replies
13/15netfilter: Pass priv instead of nf_hook_ops to netfilter hooksinclude/linux/netfilter.h include/net/netfilter/br_netfilter.h include/net/netfilter/nf_nat_l3proto.h +40 more+156 -1570 replies
13/15ipv4,ipv6: Pass net into __ip_local_out and __ip6_local_outdrivers/net/vrf.c include/net/dst_ops.h include/net/ip.h +4 more+10 -110 replies
14/15netfilter: Pass net into nf_xfrm_me_harderinclude/net/netfilter/nf_nat_core.h net/ipv4/netfilter/nf_nat_l3proto_ipv4.c net/ipv6/netfilter/nf_nat_l3proto_ipv6.c +1 more+7 -70 replies
14/15ipv4,ipv6: Pass net into ip_local_out and ip6_local_outdrivers/net/ipvlan/ipvlan_core.c drivers/net/ppp/pptp.c drivers/net/vrf.c +15 more+25 -270 replies
15/15netfilter: Use nf_ct_net instead of dev_net(out) in nf_nat_masquerade_ipv6net/ipv6/netfilter/nf_nat_masquerade_ipv6.c+1 -10 replies
15/15dst: Pass net into dst->outputdrivers/net/vrf.c include/net/dst.h include/net/ip.h +15 more+45 -530 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.

PatchJulian AnastasovNicolas DichtelPablo Neira Ayuso
SeriesA-b A-b A-b A-b A-b A-b A-b
1/15
1/15
2/15
2/15
3/15
3/15
4/15
4/15
5/15
5/15
6/15
6/15
7/15
7/15
8/15
8/15
9/15
9/15
10/15
10/15
11/15
11/15
12/15
12/15
13/15
13/15
14/15
14/15
15/15
15/15

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/15] netfilter: Stop guessing net (take 2)

This is the next installment of my work to pass struct net through the output path so the code does not need to guess how to figure out which network namespace it is in, and ultimately routes can have output devices in another network namespace.

This round the changes focus on using nf_hook_state->net in the netfilter functions, and not passing nf_hook_ops to the functions on the netfilter chains.

Given the way per network namespace operations are implemented callers can not rely on addresses or games with container_of. None of the netfilter hooks do but we should remove the temptation. Plus removing the extra parameter and the extra jump to get at values should reduce the number of cache line misses.

At a practical matter this is the bulk of the work that other pieces of code in the netfilter stack will depend on.

Since the last round I have fixed my test config to build act_connmark and added the patch that modifies act_connmark to track which network namespace it was it.

The changes are also available against net-next at:
git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/net-next.git master

My entire pending set of changes for those who want to look ahead is at:
git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/net-next.git for-testing

Eric

Eric W. Biederman (15):
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
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
nftables: Use pkt->net instead of computing net from the passed net_devices
net: Pass net to nf_dup_ipv4 and nf_dup_ipv6
act_connmark: Remember the struct net instead of guessing it.
nf_conntrack: Add a struct net parameter to l4_pkt_to_tuple
ipvs: Read hooknum from state rather than ops->hooknum
netfilter: Pass priv instead of nf_hook_ops to netfilter hooks
netfilter: Pass net into nf_xfrm_me_harder
netfilter: Use nf_ct_net instead of dev_net(out) in nf_nat_masquerade_ipv6

 include/linux/netfilter.h                      |  2 +-
 include/linux/netfilter/x_tables.h             |  3 +-
 include/linux/netfilter_arp/arp_tables.h       |  1 -
 include/linux/netfilter_bridge/ebtables.h      |  6 ++--
 include/linux/netfilter_ipv4/ip_tables.h       |  1 -
 include/linux/netfilter_ipv6/ip6_tables.h      |  1 -
 include/net/netfilter/br_netfilter.h           |  2 +-
 include/net/netfilter/ipv4/nf_dup_ipv4.h       |  2 +-
 include/net/netfilter/ipv6/nf_dup_ipv6.h       |  2 +-
 include/net/netfilter/nf_conntrack.h           |  3 +-
 include/net/netfilter/nf_conntrack_core.h      |  1 +
 include/net/netfilter/nf_conntrack_l4proto.h   |  2 +-
 include/net/netfilter/nf_nat_core.h            |  2 +-
 include/net/netfilter/nf_nat_l3proto.h         | 32 ++++++++++----------
 include/net/netfilter/nf_tables.h              | 14 ++++-----
 include/net/netfilter/nf_tables_ipv4.h         |  3 +-
 include/net/netfilter/nf_tables_ipv6.h         |  3 +-
 include/net/tc_act/tc_connmark.h               |  1 +
 net/bridge/br_netfilter_hooks.c                | 14 ++++-----
 net/bridge/br_netfilter_ipv6.c                 |  2 +-
 net/bridge/netfilter/ebt_log.c                 |  2 +-
 net/bridge/netfilter/ebt_nflog.c               |  2 +-
 net/bridge/netfilter/ebtable_broute.c          |  8 +++--
 net/bridge/netfilter/ebtable_filter.c          | 10 +++---
 net/bridge/netfilter/ebtable_nat.c             | 10 +++---
 net/bridge/netfilter/ebtables.c                | 14 +++++----
 net/bridge/netfilter/nf_tables_bridge.c        | 20 ++++++------
 net/bridge/netfilter/nft_reject_bridge.c       | 19 ++++++------
 net/decnet/netfilter/dn_rtmsg.c                |  2 +-
 net/ipv4/netfilter/arp_tables.c                |  3 +-
 net/ipv4/netfilter/arptable_filter.c           |  5 ++-
 net/ipv4/netfilter/ip_tables.c                 |  3 +-
 net/ipv4/netfilter/ipt_CLUSTERIP.c             |  2 +-
 net/ipv4/netfilter/ipt_SYNPROXY.c              |  4 +--
 net/ipv4/netfilter/ipt_rpfilter.c              |  5 ++-
 net/ipv4/netfilter/iptable_filter.c            |  7 ++---
 net/ipv4/netfilter/iptable_mangle.c            | 14 ++++-----
 net/ipv4/netfilter/iptable_nat.c               | 21 ++++++-------
 net/ipv4/netfilter/iptable_raw.c               |  7 ++---
 net/ipv4/netfilter/iptable_security.c          |  7 ++---
 net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 12 ++++----
 net/ipv4/netfilter/nf_conntrack_proto_icmp.c   |  4 +--
 net/ipv4/netfilter/nf_defrag_ipv4.c            |  4 +--
 net/ipv4/netfilter/nf_dup_ipv4.c               | 23 +++-----------
 net/ipv4/netfilter/nf_nat_l3proto_ipv4.c       | 42 +++++++++++++-------------
 net/ipv4/netfilter/nf_tables_arp.c             |  6 ++--
 net/ipv4/netfilter/nf_tables_ipv4.c            | 10 +++---
 net/ipv4/netfilter/nft_chain_nat_ipv4.c        | 22 +++++++-------
 net/ipv4/netfilter/nft_chain_route_ipv4.c      |  6 ++--
 net/ipv4/netfilter/nft_dup_ipv4.c              |  2 +-
 net/ipv4/netfilter/nft_masq_ipv4.c             |  2 +-
 net/ipv4/netfilter/nft_redir_ipv4.c            |  2 +-
 net/ipv4/netfilter/nft_reject_ipv4.c           |  5 ++-
 net/ipv6/netfilter/ip6_tables.c                |  3 +-
 net/ipv6/netfilter/ip6t_REJECT.c               |  2 +-
 net/ipv6/netfilter/ip6t_SYNPROXY.c             |  4 +--
 net/ipv6/netfilter/ip6t_rpfilter.c             |  6 ++--
 net/ipv6/netfilter/ip6table_filter.c           |  5 ++-
 net/ipv6/netfilter/ip6table_mangle.c           | 14 ++++-----
 net/ipv6/netfilter/ip6table_nat.c              | 21 ++++++-------
 net/ipv6/netfilter/ip6table_raw.c              |  5 ++-
 net/ipv6/netfilter/ip6table_security.c         |  5 ++-
 net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 12 ++++----
 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c |  3 +-
 net/ipv6/netfilter/nf_defrag_ipv6_hooks.c      |  6 ++--
 net/ipv6/netfilter/nf_dup_ipv6.c               | 23 +++-----------
 net/ipv6/netfilter/nf_nat_l3proto_ipv6.c       | 42 +++++++++++++-------------
 net/ipv6/netfilter/nf_nat_masquerade_ipv6.c    |  2 +-
 net/ipv6/netfilter/nf_tables_ipv6.c            | 10 +++---
 net/ipv6/netfilter/nft_chain_nat_ipv6.c        | 22 +++++++-------
 net/ipv6/netfilter/nft_chain_route_ipv6.c      |  6 ++--
 net/ipv6/netfilter/nft_dup_ipv6.c              |  2 +-
 net/ipv6/netfilter/nft_redir_ipv6.c            |  3 +-
 net/ipv6/netfilter/nft_reject_ipv6.c           |  7 ++---
 net/netfilter/core.c                           |  2 +-
 net/netfilter/ipset/ip_set_core.c              |  9 ++----
 net/netfilter/ipvs/ip_vs_core.c                | 40 ++++++++++++------------
 net/netfilter/nf_conntrack_core.c              | 10 +++---
 net/netfilter/nf_conntrack_proto_dccp.c        |  2 +-
 net/netfilter/nf_conntrack_proto_generic.c     |  2 +-
 net/netfilter/nf_conntrack_proto_gre.c         |  3 +-
 net/netfilter/nf_conntrack_proto_sctp.c        |  2 +-
 net/netfilter/nf_conntrack_proto_tcp.c         |  2 +-
 net/netfilter/nf_conntrack_proto_udp.c         |  1 +
 net/netfilter/nf_conntrack_proto_udplite.c     |  1 +
 net/netfilter/nf_nat_core.c                    |  4 +--
 net/netfilter/nf_tables_core.c                 | 10 +++---
 net/netfilter/nf_tables_netdev.c               | 20 ++++++------
 net/netfilter/nft_log.c                        |  3 +-
 net/netfilter/nft_meta.c                       |  4 +--
 net/netfilter/nft_queue.c                      |  2 +-
 net/netfilter/nft_reject_inet.c                | 19 ++++++------
 net/netfilter/xt_LOG.c                         |  2 +-
 net/netfilter/xt_NFLOG.c                       |  2 +-
 net/netfilter/xt_TCPMSS.c                      |  2 +-
 net/netfilter/xt_TEE.c                         |  4 +--
 net/netfilter/xt_TPROXY.c                      | 24 +++++++--------
 net/netfilter/xt_addrtype.c                    |  4 +--
 net/netfilter/xt_connlimit.c                   |  4 +--
 net/netfilter/xt_osf.c                         |  2 +-
 net/netfilter/xt_recent.c                      |  2 +-
 net/netfilter/xt_socket.c                      | 14 +++++----
 net/openvswitch/conntrack.c                    |  2 +-
 net/sched/act_connmark.c                       |  5 +--
 net/sched/act_ipt.c                            |  1 +
 net/sched/em_ipset.c                           |  1 +
 security/selinux/hooks.c                       | 10 +++---
 security/smack/smack_netfilter.c               |  4 +--
 108 files changed, 389 insertions(+), 435 deletions(-)