kernel_optimize_test/net/ipv6
Willy Tarreau 8f939b7957 ipv6: use prandom_u32() for ID generation
[ Upstream commit 62f20e068ccc50d6ab66fdb72ba90da2b9418c99 ]

This is a complement to commit aa6dd211e4b1 ("inet: use bigger hash
table for IP ID generation"), but focusing on some specific aspects
of IPv6.

Contary to IPv4, IPv6 only uses packet IDs with fragments, and with a
minimum MTU of 1280, it's much less easy to force a remote peer to
produce many fragments to explore its ID sequence. In addition packet
IDs are 32-bit in IPv6, which further complicates their analysis. On
the other hand, it is often easier to choose among plenty of possible
source addresses and partially work around the bigger hash table the
commit above permits, which leaves IPv6 partially exposed to some
possibilities of remote analysis at the risk of weakening some
protocols like DNS if some IDs can be predicted with a good enough
probability.

Given the wide range of permitted IDs, the risk of collision is extremely
low so there's no need to rely on the positive increment algorithm that
is shared with the IPv4 code via ip_idents_reserve(). We have a fast
PRNG, so let's simply call prandom_u32() and be done with it.

Performance measurements at 10 Gbps couldn't show any difference with
the previous code, even when using a single core, because due to the
large fragments, we're limited to only ~930 kpps at 10 Gbps and the cost
of the random generation is completely offset by other operations and by
the network transfer time. In addition, this change removes the need to
update a shared entry in the idents table so it may even end up being
slightly faster on large scale systems where this matters.

The risk of at least one collision here is about 1/80 million among
10 IDs, 1/850k among 100 IDs, and still only 1/8.5k among 1000 IDs,
which remains very low compared to IPv4 where all IDs are reused
every 4 to 80ms on a 10 Gbps flow depending on packet sizes.

Reported-by: Amit Klein <aksecurity@gmail.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20210529110746.6796-1-w@1wt.eu
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-07-19 09:44:44 +02:00
..
ila
netfilter netfilter: nft_fib_ipv6: skip ipv6 packets from any to link-local 2021-06-23 14:42:42 +02:00
addrconf_core.c
addrconf.c net: ipv4: Remove unneed BUG() function 2021-06-30 08:47:20 -04:00
addrlabel.c
af_inet6.c
ah6.c xfrm: Use actual socket sk instead of skb socket for xfrm_output_resume 2021-04-14 08:42:05 +02:00
anycast.c
calipso.c cipso,calipso: resolve a number of problems with the DOI refcounts 2021-03-17 17:06:15 +01:00
datagram.c
esp6_offload.c xfrm: Provide private skb extensions for segmented and hw offloaded ESP packets 2021-04-14 08:42:07 +02:00
esp6.c xfrm: xfrm_state_mtu should return at least 1280 for ipv6 2021-07-14 16:56:14 +02:00
exthdrs_core.c
exthdrs_offload.c
exthdrs.c ipv6: fix out-of-bound access in ip6_parse_tlv() 2021-07-14 16:56:28 +02:00
fib6_notifier.c
fib6_rules.c
fou6.c
icmp.c net: icmp: pass zeroed opts from icmp{,v6}_ndo_send before sending 2021-03-04 11:38:46 +01:00
inet6_connection_sock.c
inet6_hashtables.c
ip6_checksum.c
ip6_fib.c ipv6: fix suspecious RCU usage warning 2021-03-30 14:31:57 +02:00
ip6_flowlabel.c
ip6_gre.c ipv6: remove extra dev_hold() for fallback tunnels 2021-05-22 11:40:55 +02:00
ip6_icmp.c net: icmp: pass zeroed opts from icmp{,v6}_ndo_send before sending 2021-03-04 11:38:46 +01:00
ip6_input.c ipv6: weaken the v4mapped source check 2021-03-30 14:32:01 +02:00
ip6_offload.c
ip6_offload.h
ip6_output.c net: ipv6: Validate GSO SKB before finish IPv6 processing 2021-01-23 16:04:00 +01:00
ip6_tunnel.c ip6_tunnel: fix GRE6 segmentation 2021-07-14 16:56:25 +02:00
ip6_udp_tunnel.c
ip6_vti.c ipv6: remove extra dev_hold() for fallback tunnels 2021-05-22 11:40:55 +02:00
ip6mr.c
ipcomp6.c
ipv6_sockglue.c
Kconfig
Makefile
mcast_snoop.c net: bridge: mcast: fix broken length + header check for MRDv6 Adv. 2021-05-14 09:50:44 +02:00
mcast.c mld: fix panic in mld_newpack() 2021-06-03 09:00:48 +02:00
mip6.c
ndisc.c
netfilter.c
output_core.c ipv6: use prandom_u32() for ID generation 2021-07-19 09:44:44 +02:00
ping.c
proc.c
protocol.c
raw.c net-ipv6: bugfix - raw & sctp - switch to ipv6_can_nonlocal_bind() 2021-04-14 08:42:02 +02:00
reassembly.c ipv6: record frag_max_size in atomic fragments in input path 2021-06-03 09:00:50 +02:00
route.c ipv6: Fix KASAN: slab-out-of-bounds Read in fib6_nh_flush_exceptions 2021-06-10 13:39:20 +02:00
rpl_iptunnel.c
rpl.c
seg6_hmac.c
seg6_iptunnel.c
seg6_local.c
seg6.c
sit.c ipv6: remove extra dev_hold() for fallback tunnels 2021-05-22 11:40:55 +02:00
syncookies.c
sysctl_net_ipv6.c
tcp_ipv6.c ipv6: weaken the v4mapped source check 2021-03-30 14:32:01 +02:00
tcpv6_offload.c
tunnel6.c
udp_impl.h
udp_offload.c udp: ipv4: manipulate network header of NATed UDP GRO fraglist 2021-02-10 09:29:23 +01:00
udp.c udp: fix race between close() and udp_abort() 2021-06-23 14:42:42 +02:00
udplite.c
xfrm6_input.c
xfrm6_output.c
xfrm6_policy.c
xfrm6_protocol.c
xfrm6_state.c
xfrm6_tunnel.c