linux/include/net
Richard Gobert 5ef31ea5d0 net: gro: fix udp bad offset in socket lookup by adding {inner_}network_offset to napi_gro_cb
Commits a602456 ("udp: Add GRO functions to UDP socket") and 57c67ff ("udp:
additional GRO support") introduce incorrect usage of {ip,ipv6}_hdr in the
complete phase of gro. The functions always return skb->network_header,
which in the case of encapsulated packets at the gro complete phase, is
always set to the innermost L3 of the packet. That means that calling
{ip,ipv6}_hdr for skbs which completed the GRO receive phase (both in
gro_list and *_gro_complete) when parsing an encapsulated packet's _outer_
L3/L4 may return an unexpected value.

This incorrect usage leads to a bug in GRO's UDP socket lookup.
udp{4,6}_lib_lookup_skb functions use ip_hdr/ipv6_hdr respectively. These
*_hdr functions return network_header which will point to the innermost L3,
resulting in the wrong offset being used in __udp{4,6}_lib_lookup with
encapsulated packets.

This patch adds network_offset and inner_network_offset to napi_gro_cb, and
makes sure both are set correctly.

To fix the issue, network_offsets union is used inside napi_gro_cb, in
which both the outer and the inner network offsets are saved.

Reproduction example:

Endpoint configuration example (fou + local address bind)

    # ip fou add port 6666 ipproto 4
    # ip link add name tun1 type ipip remote 2.2.2.1 local 2.2.2.2 encap fou encap-dport 5555 encap-sport 6666 mode ipip
    # ip link set tun1 up
    # ip a add 1.1.1.2/24 dev tun1

Netperf TCP_STREAM result on net-next before patch is applied:

net-next main, GRO enabled:
    $ netperf -H 1.1.1.2 -t TCP_STREAM -l 5
    Recv   Send    Send
    Socket Socket  Message  Elapsed
    Size   Size    Size     Time     Throughput
    bytes  bytes   bytes    secs.    10^6bits/sec

    131072  16384  16384    5.28        2.37

net-next main, GRO disabled:
    $ netperf -H 1.1.1.2 -t TCP_STREAM -l 5
    Recv   Send    Send
    Socket Socket  Message  Elapsed
    Size   Size    Size     Time     Throughput
    bytes  bytes   bytes    secs.    10^6bits/sec

    131072  16384  16384    5.01     2745.06

patch applied, GRO enabled:
    $ netperf -H 1.1.1.2 -t TCP_STREAM -l 5
    Recv   Send    Send
    Socket Socket  Message  Elapsed
    Size   Size    Size     Time     Throughput
    bytes  bytes   bytes    secs.    10^6bits/sec

    131072  16384  16384    5.01     2877.38

Fixes: a6024562ff ("udp: Add GRO functions to UDP socket")
Signed-off-by: Richard Gobert <richardbgobert@gmail.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2024-05-02 11:02:48 +02:00
..
9p
bluetooth Bluetooth: hci_event: Fix sending HCI_OP_READ_ENC_KEY_SIZE 2024-04-24 16:26:11 -04:00
caif
iucv s390/iucv: use new address translation helpers 2024-03-13 09:23:48 +01:00
mana net: mana: Fix Rx DMA datasize and skb_over_panic 2024-04-03 19:32:03 -07:00
netfilter netfilter: flowtable: validate pppoe header 2024-04-11 12:13:11 +02:00
netns net: Namespace-ify sysctl_optmem_max 2023-12-15 11:01:27 +00:00
nfc nfc: core: make nfc_class constant 2024-03-05 11:21:18 -08:00
page_pool net: page_pool: fix recycle stats for system page_pool allocator 2024-02-19 12:30:27 -08:00
phonet
sctp sctp: preserve const qualifier in sctp_sk() 2024-02-05 11:08:06 +00:00
tc_act net/sched: Retire ipt action 2024-01-02 12:41:16 +00:00
6lowpan.h
act_api.h net/sched: Add helper macros with module names 2024-02-02 10:57:55 -08:00
addrconf.h ipv6: fix race condition between ipv6_get_ifaddr and ipv6_del_addr 2024-04-09 17:09:05 -07:00
af_ieee802154.h
af_rxrpc.h rxrpc, afs: Allow afs to pin rxrpc_peer objects 2023-12-24 15:22:50 +00:00
af_unix.h af_unix: Suppress false-positive lockdep splat for spin_lock() in __unix_gc(). 2024-04-25 08:37:02 -07:00
af_vsock.h virtio/vsock: send credit update during setting SO_RCVLOWAT 2023-12-15 10:37:35 +00:00
ah.h
amt.h
arp.h
atmclip.h
ax25.h
ax88796.h
bareudp.h
bond_3ad.h bonding: Add independent control state machine 2024-02-06 13:17:54 +01:00
bond_alb.h
bond_options.h bonding: Add independent control state machine 2024-02-06 13:17:54 +01:00
bonding.h bonding: Add independent control state machine 2024-02-06 13:17:54 +01:00
bpf_sk_storage.h
busy_poll.h net: add napi_busy_loop_rcu() 2024-02-09 10:01:09 -08:00
calipso.h
cfg80211-wext.h
cfg80211.h wifi: cfg80211: add a flag to disable wireless extensions 2024-03-25 15:23:06 +01:00
cfg802154.h mac802154: fix llsec key resources release in mac802154_llsec_key_del 2024-03-06 21:01:26 +01:00
checksum.h
cipso_ipv4.h
cls_cgroup.h
codel.h
codel_impl.h
codel_qdisc.h
compat.h
datalink.h
dcbevent.h
dcbnl.h
devlink.h
dropreason-core.h tcp: introduce dropreasons in receive path 2024-02-28 10:39:21 +00:00
dropreason.h
dsa.h ethtool: replace struct ethtool_eee with a new struct ethtool_keee on kernel side 2024-01-31 12:30:47 +00:00
dsa_stubs.h
dsfield.h
dst.h net: dst: Make dst_destroy() static and return void. 2024-02-06 11:45:53 +01:00
dst_cache.h
dst_metadata.h
dst_ops.h
eee.h net: add helpers for EEE configuration 2024-03-05 19:21:17 -08:00
erspan.h
esp.h
espintcp.h
ethoc.h
failover.h
fib_notifier.h
fib_rules.h fib: remove unnecessary input parameters in fib_default_rule_add 2024-01-03 16:42:48 -08:00
firewire.h
flow.h
flow_dissector.h
flow_offload.h
fou.h
fq.h
fq_impl.h
garp.h
gen_stats.h
genetlink.h genetlink: make info in GENL_REQ_ATTR_CHECK() const 2024-02-23 18:17:36 -08:00
geneve.h
gre.h
gro.h net: gro: fix udp bad offset in socket lookup by adding {inner_}network_offset to napi_gro_cb 2024-05-02 11:02:48 +02:00
gro_cells.h
gso.h
gtp.h
gue.h
handshake.h
hotdata.h net: move rps_sock_flow_table to net_hotdata 2024-03-07 21:12:43 -08:00
hwbm.h
icmp.h
ieee80211_radiotap.h
ieee802154_netdev.h
if_inet6.h ipv6: anycast: complete RCU handling of struct ifacaddr6 2024-02-26 18:40:34 -08:00
ife.h
inet6_connection_sock.h
inet6_hashtables.h
inet_common.h
inet_connection_sock.h tcp: properly terminate timers for kernel sockets 2024-03-25 19:51:57 -07:00
inet_dscp.h
inet_ecn.h
inet_frag.h
inet_hashtables.h tcp: Remove dead code and fields for bhash2. 2023-12-22 22:15:35 +00:00
inet_sock.h inet: Add getsockopt support for IP_ROUTER_ALERT and IPV6_ROUTER_ALERT 2024-03-06 12:37:06 +00:00
inet_timewait_sock.h tcp: Remove dead code and fields for bhash2. 2023-12-22 22:15:35 +00:00
inetpeer.h
ioam6.h net: ioam6: multicast event 2024-02-28 11:19:41 +00:00
ip.h ipmr: fix kernel panic when forwarding mcast packets 2024-01-26 21:05:26 -08:00
ip6_checksum.h
ip6_fib.h net/ipv6: Remove expired routes with a separated list of routes. 2024-02-12 10:24:12 +00:00
ip6_route.h ipv6: annotate data-races around cnf.mtu6 2024-03-01 08:42:31 +00:00
ip6_tunnel.h
ip_fib.h inet: allow ip_valid_fib_dump_req() to be called with RTNL or RCU 2024-02-26 11:46:12 +00:00
ip_tunnels.h geneve: fix header validation in geneve[6]_xmit_skb 2024-04-08 11:51:04 +01:00
ip_vs.h
ipcomp.h
ipconfig.h
ipv6.h ipv6: annotate data-races around cnf.forwarding 2024-03-01 08:42:31 +00:00
ipv6_frag.h
ipv6_stubs.h
iw_handler.h
kcm.h
l3mdev.h
lag.h
lapb.h
lib80211.h
llc.h
llc_c_ac.h
llc_c_ev.h
llc_c_st.h
llc_conn.h
llc_if.h
llc_pdu.h llc: Drop support for ETH_P_TR_802_2. 2024-01-19 21:30:09 -08:00
llc_s_ac.h
llc_s_ev.h
llc_s_st.h
llc_sap.h
lwtunnel.h
mac80211.h wifi: mac80211: don't use rate mask for scanning 2024-04-08 20:11:34 +02:00
mac802154.h
macsec.h macsec: Enable devices to advertise whether they update sk_buff md_dst during offloads 2024-04-25 08:20:54 -07:00
mctp.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-02-29 14:24:56 -08:00
mctpdevice.h
mip6.h
mld.h
mpls.h
mpls_iptunnel.h
mptcp.h
mrp.h
ncsi.h
ndisc.h
neighbour.h
net_debug.h
net_failover.h
net_namespace.h net: add exit_batch_rtnl() method 2024-02-07 18:55:10 -08:00
net_ratelimit.h
net_trackers.h
netdev_queues.h netdev: add queue stat for alloc failures 2024-03-07 21:13:26 -08:00
netdev_rx_queue.h
netevent.h
netkit.h
netlabel.h netlabel: cleanup struct netlbl_lsm_catmap 2024-02-07 12:38:30 +00:00
netlink.h genetlink: introduce helpers to do filtered multicast 2023-12-19 15:31:40 +01:00
netmem.h net: introduce abstraction for network memory 2024-02-20 09:22:58 +01:00
netprio_cgroup.h
netrom.h
nexthop.h net: nexthop: Have all NH notifiers carry NH ID 2024-03-11 14:14:07 -07:00
nl802154.h
nsh.h
p8022.h
pie.h
ping.h
pkt_cls.h net/sched: Add helper macros with module names 2024-02-02 10:57:55 -08:00
pkt_sched.h net/sched: Add helper macros with module names 2024-02-02 10:57:55 -08:00
pptp.h
protocol.h ipv6: move tcp_ipv6_hash_secret and udp_ipv6_hash_secret to net_hotdata 2024-03-07 21:12:43 -08:00
psample.h
psnap.h
raw.h
rawv6.h
red.h
regulatory.h
request_sock.h tcp: Clear req->syncookie in reqsk_alloc(). 2024-03-19 19:35:59 -07:00
rose.h
route.h ipv4: Set the routing scope properly in ip_route_output_ports(). 2024-02-12 17:33:05 -08:00
rpl.h
rps.h net: move rps_sock_flow_table to net_hotdata 2024-03-07 21:12:43 -08:00
rsi_91x.h
rtnetlink.h rtnetlink: add RTNL_FLAG_DUMP_UNLOCKED flag 2024-02-26 11:46:12 +00:00
rtnh.h
sch_generic.h net/sched: Fix mirred deadlock on device recursion 2024-04-17 18:22:52 -07:00
scm.h af_unix: Try to run GC async. 2024-01-26 20:34:25 -08:00
secure_seq.h
seg6.h
seg6_hmac.h
seg6_local.h
selftests.h
slhc_vj.h
smc.h net/smc: manage system EID in SMC stack instead of ISM driver 2023-12-26 20:24:33 +00:00
snmp.h
sock.h net: fix sk_memory_allocated_{add|sub} vs softirqs 2024-04-23 19:02:24 -07:00
sock_reuseport.h
Space.h
stp.h
strparser.h
switchdev.h net: bridge: switchdev: Skip MDB replays of deferred events on offload 2024-02-16 09:36:37 +00:00
tc_wrapper.h Merge branch 'x86/bugs' into x86/core, to pick up pending changes before dependent patches 2024-02-14 10:49:37 +01:00
tcp.h tcp: make the dropreason really work when calling tcp_rcv_state_process() 2024-02-28 10:39:22 +00:00
tcp_ao.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-01-04 18:06:46 -08:00
tcp_states.h
tcx.h
timewait_sock.h
tipc.h
tls.h tls: fix lockless read of strp->msg_ready in ->poll 2024-04-25 08:32:37 -07:00
tls_prot.h
tls_toe.h
transp_v6.h
tso.h
tun_proto.h
udp.h
udp_tunnel.h
udplite.h
vsock_addr.h
vxlan.h
wext.h
x25.h
x25device.h
xdp.h net, xdp: Correct grammar 2023-12-14 16:38:59 +01:00
xdp_priv.h
xdp_sock.h xsk: Don't assume metadata is always requested in TX completion 2024-03-19 13:47:29 +01:00
xdp_sock_drv.h xsk: fix usage of multi-buffer BPF helpers for ZC XDP 2024-01-24 16:24:06 -08:00
xfrm.h xfrm: get global statistics from the offloaded device 2024-02-05 16:45:49 -08:00
xsk_buff_pool.h xsk: add functions to fill control buffer 2023-12-13 16:16:40 -08:00