xsk: Don't assume metadata is always requested in TX completion
authorStanislav Fomichev <sdf@google.com>
Mon, 18 Mar 2024 16:54:27 +0000 (09:54 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 19 Mar 2024 12:47:29 +0000 (13:47 +0100)
`compl->tx_timestam != NULL` means that the user has explicitly
requested the metadata via XDP_TX_METADATA+XDP_TX_METADATA_TIMESTAMP.

Fixes: 48eb03dd2630 ("xsk: Add TX timestamp and TX checksum offload support")
Reported-by: Daniele Salvatore Albano <d.albano@gmail.com>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Daniele Salvatore Albano <d.albano@gmail.com>
Link: https://lore.kernel.org/bpf/20240318165427.1403313-1-sdf@google.com
include/net/xdp_sock.h

index 3cb4dc9bd70e44bcce5f9cb3119de61e933967ab..3d54de168a6d9d57d1f7001c648fbc25af10965a 100644 (file)
@@ -188,6 +188,8 @@ static inline void xsk_tx_metadata_complete(struct xsk_tx_metadata_compl *compl,
 {
        if (!compl)
                return;
+       if (!compl->tx_timestamp)
+               return;
 
        *compl->tx_timestamp = ops->tmo_fill_timestamp(priv);
 }