Skip to content

get rid of skb->nf_bridge pointer

Florian Westphal netdev netfilter-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest14 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14netfilter: bridge: really save frag_max_size between PRE and POST_ROUTINGnet/bridge/br_netfilter.c+15 -22 replies
2/14net: untangle ip_fragment and bridge netfilterinclude/linux/netfilter_bridge.h include/net/ip.h net/bridge/br_netfilter.c +1 more+53 -282 replies
3/14netfilter: bridge: don't use nf_bridge_info data to store mac headernet/bridge/br_netfilter.c+32 -250 replies
4/14netfilter: bridge: start splitting mask into public/private chunksinclude/linux/netfilter_bridge.h include/linux/skbuff.h net/bridge/br_netfilter.c+17 -70 replies
5/14netfilter: bridge: make BRNF_PKT_TYPE flag a boolinclude/linux/netfilter_bridge.h include/linux/skbuff.h net/bridge/br_netfilter.c+10 -100 replies
6/14netfilter: bridge: rename and resize 'data' fieldinclude/linux/skbuff.h net/bridge/br_netfilter.c+7 -40 replies
7/14netfilter: bridge: add helpers for fetching physin/outdevinclude/linux/netfilter_bridge.h net/ipv4/netfilter/nf_reject_ipv4.c net/ipv6/netfilter/nf_reject_ipv6.c +5 more+97 -340 replies
8/14netfilter: physdev: use helpersnet/netfilter/xt_physdev.c+22 -120 replies
9/14netfilter: bridge: add and use nf_bridge_info_get helpernet/bridge/br_netfilter.c+16 -80 replies
10/14netfilter: bridge: move bridge netfilter state into sk_buffinclude/linux/netfilter_bridge.h include/linux/skbuff.h net/bridge/br_device.c +11 more+75 -520 replies
11/14netfilter: bridge: remove skb->nf_bridgeinclude/linux/netfilter.h include/linux/netfilter_bridge.h include/linux/skbuff.h +3 more+289 -1010 replies
12/14netfilter: bridge: discard nf_bridge info on xmitnet/bridge/br_netfilter.c+14 -10 replies
13/14netfilter: bridge: neigh_head and physoutdev can't be used at same timeinclude/linux/netfilter_bridge.h net/bridge/br_netfilter.c+7 -20 replies
14/14netfilter: bridge: hold physinport ref during neigh resolutioninclude/linux/netfilter_bridge.h net/bridge/br_netfilter.c+16 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH nf-next 00/14] get rid of skb->nf_bridge pointer

[ netdev hackers are encouraged to look at patches #2 and #11 specifically,
those are the ones with largest impact outside netfilter land ]

Remove skb->nf_bridge pointer.

Unfortunately we still need some way to decide if skb is bridged or not, else kfree_skb, skb_clone etc. would have to do costly lookups in bridge netfilter.

We use a 2 bit state field in the skb for this purpose. If its zero, skb is not bridged (same as skb->nf_bridge == NULL in current kernel).

nf_bridge_info is stored in an rhashtable; bridge netfilter and the few other places (nfqueue, nflog, physdev match) that need to access bridge netfilter data do on-demand lookups in an rhashtable to access the data associated with a bridged skb.

skb_clone and skb_copy will call into netfilter core helpers for bridged skbs to duplicate the information if needed. Likewise, kfree_skb removes and frees the bridge netfilter meta data as well if needed.

In order to avoid those lookups where we're dealing with non-bridged skbs, we store 2 bit state field in the skb.

Tested, on host connected to kvm-bridge:

ping -s $bignum $ip_behind_bridge

on bridge:
-j REDIRECT
-j DNAT --to-destination $ip_behind_bridge
-m physdev match with in/outdev match in FORWARD and INPUT (indev only)
- same w. active -j NFQUEUE.

Patch 11 substitutes the pointer for on-demand lookups, most of the other patches prepare for this change by adding helpers and splitting state information into 'public' and 'bridge netfilter private'.

The alternative to the rhashtable is to store the bridge netfilter metadata in skb->cb[], but there are some caveats since we need such metadata to survive local delivery too (else we'd break use of physdev match in INPUT).

This is why external store was chosen.

Feedback and suggestions welcome.

 include/linux/netfilter.h                  |    8 
 include/linux/netfilter_bridge.h           |  104 +++++-
 include/linux/skbuff.h                     |   87 ++---
 include/net/ip.h                           |    4 
 net/bridge/br_device.c                     |   19 -
 net/bridge/br_netfilter.c                  |  482 ++++++++++++++++++++---------
 net/bridge/br_private.h                    |    2 
 net/core/skbuff.c                          |    5 
 net/ipv4/ip_output.c                       |   30 +
 net/ipv4/netfilter/nf_defrag_ipv4.c        |    3 
 net/ipv4/netfilter/nf_reject_ipv4.c        |    6 
 net/ipv6/netfilter/nf_defrag_ipv6_hooks.c  |    3 
 net/ipv6/netfilter/nf_reject_ipv6.c        |    6 
 net/netfilter/core.c                       |   49 ++
 net/netfilter/ipset/ip_set_hash_netiface.c |   32 +
 net/netfilter/nf_log_common.c              |    7 
 net/netfilter/nf_queue.c                   |   22 -
 net/netfilter/nfnetlink_log.c              |   17 -
 net/netfilter/nfnetlink_queue_core.c       |   34 +-
 net/netfilter/xt_physdev.c                 |   36 +-
 20 files changed, 670 insertions(+), 286 deletions(-)