linux/include/net
Ido Schimmel 811b8f534f net: sched: Fix truncation of offloaded action statistics
In case of tc offload, when user space queries the kernel for tc action
statistics, tc will query the offloaded statistics from device drivers.
Among other statistics, drivers are expected to pass the number of
packets that hit the action since the last query as a 64-bit number.

Unfortunately, tc treats the number of packets as a 32-bit number,
leading to truncation and incorrect statistics when the number of
packets since the last query exceeds 0xffffffff:

$ tc -s filter show dev swp2 ingress
filter protocol all pref 1 flower chain 0
filter protocol all pref 1 flower chain 0 handle 0x1
  skip_sw
  in_hw in_hw_count 1
        action order 1: mirred (Egress Redirect to device swp1) stolen
        index 1 ref 1 bind 1 installed 58 sec used 0 sec
        Action statistics:
        Sent 1133877034176 bytes 536959475 pkt (dropped 0, overlimits 0 requeues 0)
[...]

According to the above, 2111-byte packets were redirected which is
impossible as only 64-byte packets were transmitted and the MTU was
1500.

Fix by treating packets as a 64-bit number:

$ tc -s filter show dev swp2 ingress
filter protocol all pref 1 flower chain 0
filter protocol all pref 1 flower chain 0 handle 0x1
  skip_sw
  in_hw in_hw_count 1
        action order 1: mirred (Egress Redirect to device swp1) stolen
        index 1 ref 1 bind 1 installed 61 sec used 0 sec
        Action statistics:
        Sent 1370624380864 bytes 21416005951 pkt (dropped 0, overlimits 0 requeues 0)
[...]

Which shows that only 64-byte packets were redirected (1370624380864 /
21416005951 = 64).

Fixes: 3804070235 ("net/sched: Enable netdev drivers to update statistics of offloaded actions")
Reported-by: Joe Botha <joe@atomic.ac>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250204123839.1151804-1-idosch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2025-02-05 18:32:06 -08:00
..
9p
bluetooth Bluetooth: Get rid of cmd_timeout and use the reset callback 2025-01-15 10:36:42 -05:00
caif
iucv net: reformat kdoc return statements 2024-12-09 14:44:59 -08:00
libeth
mana
netfilter netfilter: flowtable: add CLOSING state 2025-01-19 16:41:56 +01:00
netns tcp: Add sysctl to configure TIME-WAIT reuse delay 2024-12-11 20:17:33 -08:00
nfc net: nfc: Propagate ISO14443 type A target ATS to userspace via netlink 2024-11-07 10:21:58 +01:00
page_pool net: page_pool: don't try to stash the napi id 2025-01-27 14:37:41 -08:00
phonet phonet: Convert phonet_routes.lock to spinlock_t. 2024-10-24 16:03:40 +02:00
sctp
tc_act
6lowpan.h
Space.h
act_api.h net/sched: act_api: unexport tcf_action_dump_1() 2024-10-23 11:43:47 +02:00
addrconf.h ipv6: Add __in6_dev_get_rtnl_net(). 2025-01-20 12:16:04 -08:00
af_ieee802154.h
af_rxrpc.h
af_unix.h
af_vsock.h
ah.h
amt.h
arp.h
atmclip.h
ax25.h ax25: rcu protect dev->ax25_ptr 2025-01-06 15:57:01 -08:00
ax88796.h
bareudp.h
bond_3ad.h
bond_alb.h
bond_options.h bonding: add ns target multicast address to slave device 2024-11-14 11:16:28 +01:00
bonding.h
bpf_sk_storage.h
busy_poll.h xsk: Bring back busy polling support 2025-01-10 18:07:56 -08:00
calipso.h
cfg80211-wext.h
cfg80211.h wifi: cfg80211: Add support for controlling EPCS 2025-01-13 15:34:09 +01:00
cfg802154.h
checksum.h net: checksum: Move from32to16() to generic header 2024-10-30 15:29:59 +01:00
cipso_ipv4.h
cls_cgroup.h
codel.h
codel_impl.h
codel_qdisc.h
compat.h
datalink.h
dcbevent.h
dcbnl.h
devlink.h devlink: add devl guard 2025-01-16 13:04:58 -08:00
dropreason-core.h af_unix: Set drop reason in unix_dgram_disconnected(). 2025-01-20 11:27:41 -08:00
dropreason.h
dsa.h net: dsa: implement get_ts_stats ethtool operation for user ports 2025-01-17 20:01:09 -08:00
dsa_stubs.h
dscp.h
dsfield.h
dst.h net: reformat kdoc return statements 2024-12-09 14:44:59 -08:00
dst_cache.h
dst_metadata.h
dst_ops.h
eee.h net: simplify eeecfg_mac_can_tx_lpi 2024-11-13 18:49:50 -08:00
erspan.h
esp.h
espintcp.h
ethoc.h
failover.h
fib_notifier.h
fib_rules.h
firewire.h
flow.h
flow_dissector.h
flow_offload.h net: sched: propagate "skip_sw" flag to struct flow_cls_common_offload 2024-10-30 17:33:53 -07:00
fou.h
fq.h
fq_impl.h
garp.h
gen_stats.h
genetlink.h net: reformat kdoc return statements 2024-12-09 14:44:59 -08:00
geneve.h
gre.h
gro.h
gro_cells.h
gso.h
gtp.h
gue.h
handshake.h
hotdata.h
hwbm.h
icmp.h
ieee8021q.h
ieee80211_radiotap.h wireless fixes for v6.12-rc5 2024-10-25 10:44:41 +01:00
ieee802154_netdev.h
if_inet6.h
ife.h
inet6_connection_sock.h
inet6_hashtables.h
inet_common.h
inet_connection_sock.h tcp/dccp: allow a connection when sk_max_ack_backlog is zero 2025-01-04 08:17:23 -08:00
inet_dscp.h
inet_ecn.h
inet_frag.h
inet_hashtables.h
inet_sock.h sctp: Prepare sctp_v4_get_dst() to dscp_t conversion. 2025-01-06 13:49:38 -08:00
inet_timewait_sock.h tcp: Measure TIME-WAIT reuse delay with millisecond precision 2024-12-11 20:17:33 -08:00
inetpeer.h inetpeer: remove create argument of inet_getpeer() 2024-12-17 19:37:00 -08:00
ioam6.h
ip.h sock: support SO_PRIORITY cmsg 2024-12-16 18:13:44 -08:00
ip6_checksum.h
ip6_fib.h
ip6_route.h
ip6_tunnel.h
ip_fib.h net: ip: make fib_validate_source() support drop reasons 2024-11-12 11:24:50 +01:00
ip_tunnels.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-10-31 18:10:07 -07:00
ip_vs.h
ipcomp.h
ipconfig.h
ipv6.h net: reformat kdoc return statements 2024-12-09 14:44:59 -08:00
ipv6_frag.h
ipv6_stubs.h
iw_handler.h
kcm.h
l3mdev.h
lag.h
lapb.h net: lapb: increase LAPB_HEADER_LEN 2024-12-06 17:43:08 -08:00
llc.h
llc_c_ac.h
llc_c_ev.h
llc_c_st.h
llc_conn.h
llc_if.h
llc_pdu.h
llc_s_ac.h
llc_s_ev.h
llc_s_st.h
llc_sap.h
lwtunnel.h
mac80211.h wifi: mac80211: set key link ID to the deflink one 2025-01-13 15:34:09 +01:00
mac802154.h
macsec.h net: macsec: Add endianness annotations in salt struct 2025-01-20 12:20:42 +00:00
mctp.h net: mctp: Expose transport binding identifier via IFLA attribute 2024-11-09 09:04:54 -08:00
mctpdevice.h net: mctp: Expose transport binding identifier via IFLA attribute 2024-11-09 09:04:54 -08:00
mip6.h
mld.h
mpls.h
mpls_iptunnel.h
mptcp.h
mrp.h
ncsi.h
ndisc.h
neighbour.h neighbour: Create netdev->neighbour association 2024-11-09 13:22:57 -08:00
neighbour_tables.h neighbour: Create netdev->neighbour association 2024-11-09 13:22:57 -08:00
net_debug.h Kbuild updates for v6.13 2024-11-30 13:41:50 -08:00
net_failover.h
net_namespace.h net: expedite synchronize_net() for cleanup_net() 2025-01-15 19:17:03 -08:00
net_ratelimit.h
net_shaper.h
net_trackers.h
netdev_queues.h net: move HDS config from ethtool state 2025-01-20 11:44:57 -08:00
netdev_rx_queue.h
netevent.h
netkit.h
netlabel.h Networking changes for 6.13. 2024-11-21 08:28:08 -08:00
netlink.h net: reformat kdoc return statements 2024-12-09 14:44:59 -08:00
netmem.h netmem: add a couple of page helper wrappers 2024-12-05 18:41:07 -08:00
netprio_cgroup.h
netrom.h
nexthop.h
nl802154.h
nsh.h
p8022.h
pfcp.h
pie.h
ping.h
pkt_cls.h net: sched: refine software bypass handling in tc_run 2025-01-20 09:21:27 +00:00
pkt_sched.h
pptp.h
proto_memory.h
protocol.h
psample.h
psnap.h
raw.h
rawv6.h
red.h
regulatory.h
request_sock.h
rose.h
route.h ipv4: Define inet_sk_init_flowi4() and use it in inet_sk_rebuild_header(). 2024-12-20 13:50:09 -08:00
rpl.h
rps.h
rsi_91x.h
rstreason.h
rtnetlink.h rtnetlink: Register rtnl_dellink() and rtnl_setlink() with RTNL_FLAG_DOIT_PERNET_WIP. 2024-11-11 17:26:52 -08:00
rtnh.h
sch_generic.h net: sched: Fix truncation of offloaded action statistics 2025-02-05 18:32:06 -08:00
scm.h lsm: replace context+len with lsm_context 2024-12-04 14:42:31 -05:00
secure_seq.h
seg6.h
seg6_hmac.h
seg6_local.h
selftests.h
slhc_vj.h
smc.h
snmp.h
sock.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2025-01-16 10:34:59 -08:00
sock_reuseport.h
stp.h
strparser.h
switchdev.h
tc_wrapper.h
tcp.h net: reformat kdoc return statements 2024-12-09 14:44:59 -08:00
tcp_ao.h net/tcp: Add missing lockdep annotations for TCP-AO hlist traversals 2024-11-03 12:10:11 -08:00
tcp_states.h
tcx.h
timewait_sock.h
tipc.h
tls.h tls: block decryption when a rekey is pending 2024-12-16 12:47:29 +00:00
tls_prot.h
tls_toe.h
transp_v6.h
tso.h
tun_proto.h
udp.h ipv6/udp: Add 4-tuple hash for connected socket 2024-11-18 11:56:21 +00:00
udp_tunnel.h
udplite.h
vsock_addr.h
vxlan.h vxlan: Track reserved bits explicitly as part of the configuration 2024-12-09 14:47:04 -08:00
wext.h
x25.h
x25device.h
xdp.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2025-01-16 10:34:59 -08:00
xdp_priv.h
xdp_sock.h
xdp_sock_drv.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2025-01-16 10:34:59 -08:00
xfrm.h ipsec-2025-01-27 2025-01-27 15:15:12 -08:00
xsk_buff_pool.h xdp, xsk: constify read-only arguments of some static inline helpers 2024-12-05 18:41:06 -08:00