kernel_optimize_test/net/ipv6
Benjamin Poirier 1837b2e2bc mld, igmp: Fix reserved tailroom calculation
The current reserved_tailroom calculation fails to take hlen and tlen into
account.

skb:
[__hlen__|__data____________|__tlen___|__extra__]
^                                               ^
head                                            skb_end_offset

In this representation, hlen + data + tlen is the size passed to alloc_skb.
"extra" is the extra space made available in __alloc_skb because of
rounding up by kmalloc. We can reorder the representation like so:

[__hlen__|__data____________|__extra__|__tlen___]
^                                               ^
head                                            skb_end_offset

The maximum space available for ip headers and payload without
fragmentation is min(mtu, data + extra). Therefore,
reserved_tailroom
= data + extra + tlen - min(mtu, data + extra)
= skb_end_offset - hlen - min(mtu, skb_end_offset - hlen - tlen)
= skb_tailroom - min(mtu, skb_tailroom - tlen) ; after skb_reserve(hlen)

Compare the second line to the current expression:
reserved_tailroom = skb_end_offset - min(mtu, skb_end_offset)
and we can see that hlen and tlen are not taken into account.

The min() in the third line can be expanded into:
if mtu < skb_tailroom - tlen:
	reserved_tailroom = skb_tailroom - mtu
else:
	reserved_tailroom = tlen

Depending on hlen, tlen, mtu and the number of multicast address records,
the current code may output skbs that have less tailroom than
dev->needed_tailroom or it may output more skbs than needed because not all
space available is used.

Fixes: 4c672e4b ("ipv6: mld: fix add_grhead skb_over_panic for devs with large MTUs")
Signed-off-by: Benjamin Poirier <bpoirier@suse.com>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-03-03 15:41:07 -05:00
..
ila
netfilter netfilter: conntrack: resched in nf_ct_iterate_cleanup 2016-02-01 00:15:26 +01:00
addrconf_core.c
addrconf.c rtnl: RTM_GETNETCONF: fix wrong return value 2016-02-19 15:33:46 -05:00
addrlabel.c
af_inet6.c
ah6.c
anycast.c
datagram.c ipv6/udp: use sticky pktinfo egress ifindex on connect() 2016-01-29 20:31:26 -08:00
esp6.c
exthdrs_core.c
exthdrs_offload.c
exthdrs.c
fib6_rules.c
icmp.c
inet6_connection_sock.c soreuseport: fast reuseport UDP socket selection 2016-01-04 22:49:58 -05:00
inet6_hashtables.c
ip6_checksum.c
ip6_fib.c
ip6_flowlabel.c ipv6: fix a lockdep splat 2016-02-08 10:33:32 -05:00
ip6_gre.c tunnel: Clear IPCB(skb)->opt before dst_link_failure called 2016-02-23 19:11:56 -05:00
ip6_icmp.c
ip6_input.c
ip6_offload.c
ip6_offload.h
ip6_output.c ipv6: enforce flowi6_oif usage in ip6_dst_lookup_tail() 2016-01-29 20:31:26 -08:00
ip6_tunnel.c tunnel: Clear IPCB(skb)->opt before dst_link_failure called 2016-02-23 19:11:56 -05:00
ip6_udp_tunnel.c
ip6_vti.c
ip6mr.c
ipcomp6.c
ipv6_sockglue.c
Kconfig ipv4+ipv6: Make INET*_ESP select CRYPTO_ECHAINIV 2016-01-25 10:45:41 -08:00
Makefile
mcast_snoop.c
mcast.c mld, igmp: Fix reserved tailroom calculation 2016-03-03 15:41:07 -05:00
mip6.c
ndisc.c ipv6: honor ifindex in case we receive ll addresses in router advertisements 2015-12-23 22:03:54 -05:00
netfilter.c
output_core.c
ping.c
proc.c
protocol.c
raw.c
reassembly.c inet: kill unused skb_free op 2016-01-05 22:25:57 -05:00
route.c ipv6: enforce flowi6_oif usage in ip6_dst_lookup_tail() 2016-01-29 20:31:26 -08:00
sit.c sit: set rtnl_link_ops before calling register_netdevice 2016-01-25 10:51:53 -08:00
syncookies.c
sysctl_net_ipv6.c
tcp_ipv6.c tcp/dccp: fix another race at listener dismantle 2016-02-18 11:35:51 -05:00
tcpv6_offload.c
tunnel6.c
udp_impl.h
udp_offload.c
udp.c udp: fix potential infinite loop in SO_REUSEPORT logic 2016-01-19 13:52:25 -05:00
udplite.c
xfrm6_input.c
xfrm6_mode_beet.c
xfrm6_mode_ro.c
xfrm6_mode_transport.c
xfrm6_mode_tunnel.c ipv6: update skb->csum when CE mark is propagated 2016-01-15 15:07:23 -05:00
xfrm6_output.c
xfrm6_policy.c
xfrm6_protocol.c
xfrm6_state.c
xfrm6_tunnel.c