Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sfc: check hash is valid before using it

On EF100, the RX hash field in the packet prefix may not be valid (e.g.
if the header parse failed), and this is indicated by a one-bit flag
elsewhere in the packet prefix. Only call skb_set_hash() if the
RSS_HASH_VALID bit is set.

Signed-off-by: Edward Cree <ecree@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Edward Cree and committed by
David S. Miller
06888543 e591d298

+18 -1
+5
drivers/net/ethernet/sfc/ef100_rx.c
··· 31 31 #define ESF_GZ_RX_PREFIX_NT_OR_INNER_L3_CLASS_WIDTH \ 32 32 ESF_GZ_RX_PREFIX_HCLASS_NT_OR_INNER_L3_CLASS_WIDTH 33 33 34 + bool ef100_rx_buf_hash_valid(const u8 *prefix) 35 + { 36 + return PREFIX_FIELD(prefix, RSS_HASH_VALID); 37 + } 38 + 34 39 static bool check_fcs(struct efx_channel *channel, u32 *prefix) 35 40 { 36 41 u16 rxclass;
+1
drivers/net/ethernet/sfc/ef100_rx.h
··· 14 14 15 15 #include "net_driver.h" 16 16 17 + bool ef100_rx_buf_hash_valid(const u8 *prefix); 17 18 void efx_ef100_ev_rx(struct efx_channel *channel, const efx_qword_t *p_event); 18 19 void ef100_rx_write(struct efx_rx_queue *rx_queue); 19 20 void __ef100_rx_packet(struct efx_channel *channel);
+8
drivers/net/ethernet/sfc/efx.h
··· 45 45 __ef100_rx_packet, __efx_rx_packet, 46 46 channel); 47 47 } 48 + static inline bool efx_rx_buf_hash_valid(struct efx_nic *efx, const u8 *prefix) 49 + { 50 + if (efx->type->rx_buf_hash_valid) 51 + return INDIRECT_CALL_1(efx->type->rx_buf_hash_valid, 52 + ef100_rx_buf_hash_valid, 53 + prefix); 54 + return true; 55 + } 48 56 49 57 /* Maximum number of TCP segments we support for soft-TSO */ 50 58 #define EFX_TSO_MAX_SEGS 100
+2
drivers/net/ethernet/sfc/net_driver.h
··· 1265 1265 * @rx_write: Write RX descriptors and doorbell 1266 1266 * @rx_defer_refill: Generate a refill reminder event 1267 1267 * @rx_packet: Receive the queued RX buffer on a channel 1268 + * @rx_buf_hash_valid: Determine whether the RX prefix contains a valid hash 1268 1269 * @ev_probe: Allocate resources for event queue 1269 1270 * @ev_init: Initialise event queue on the NIC 1270 1271 * @ev_fini: Deinitialise event queue on the NIC ··· 1410 1409 void (*rx_write)(struct efx_rx_queue *rx_queue); 1411 1410 void (*rx_defer_refill)(struct efx_rx_queue *rx_queue); 1412 1411 void (*rx_packet)(struct efx_channel *channel); 1412 + bool (*rx_buf_hash_valid)(const u8 *prefix); 1413 1413 int (*ev_probe)(struct efx_channel *channel); 1414 1414 int (*ev_init)(struct efx_channel *channel); 1415 1415 void (*ev_fini)(struct efx_channel *channel);
+2 -1
drivers/net/ethernet/sfc/rx_common.c
··· 525 525 return; 526 526 } 527 527 528 - if (efx->net_dev->features & NETIF_F_RXHASH) 528 + if (efx->net_dev->features & NETIF_F_RXHASH && 529 + efx_rx_buf_hash_valid(efx, eh)) 529 530 skb_set_hash(skb, efx_rx_buf_hash(efx, eh), 530 531 PKT_HASH_TYPE_L3); 531 532 if (csum) {