We should not assume mac header is set in output path.
Use skb_eth_hdr() instead of skb_mac_header() in ice_xmit_frame_ring()
and ice_eswitch_set_target_vsi(). Also use skb_checksum_start_offset()
instead of skb->csum_start - skb->mac_header in ice_tx_csum().
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
drivers/net/ethernet/intel/ice/ice_eswitch.c | 2 +-
drivers/net/ethernet/intel/ice/ice_txrx.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index b069e6c514fb1279ddd9e941e76271be0e72c912..387e8fa8e924c64ce1146e0d86e0f8a853640085 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -244,7 +244,7 @@ ice_eswitch_set_target_vsi(struct sk_buff *skb,
u64 cd_cmd, dst_vsi;
if (!dst) {
- struct ethhdr *eth = (struct ethhdr *)skb_mac_header(skb);
+ struct ethhdr *eth = skb_eth_hdr(skb);
if (unlikely(eth->h_proto == htons(ETH_P_LLDP)))
return;diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
index 31303ab5be175a5ce698f16715ea8d75eeea7bc5..5e73cdc71a68dc23022ff91d10b2c8c872939ff2 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx.c
+++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
@@ -1743,7 +1743,7 @@ int ice_tx_csum(struct ice_tx_buf *first, struct ice_tx_offload_params *off)
!(first->tx_flags & ICE_TX_FLAGS_TSO) &&
!skb_csum_is_sctp(skb)) {
/* Set GCS */
- u16 csum_start = (skb->csum_start - skb->mac_header) / 2;
+ u16 csum_start = skb_checksum_start_offset(skb) / 2;
u16 csum_offset = skb->csum_offset / 2;
u16 gcs_params;
@@ -2219,7 +2219,7 @@ ice_xmit_frame_ring(struct sk_buff *skb, struct ice_tx_ring *tx_ring)
goto out_drop;
/* allow CONTROL frames egress from main VSI if FW LLDP disabled */
- eth = (struct ethhdr *)skb_mac_header(skb);
+ eth = skb_eth_hdr(skb);
if ((ice_is_switchdev_running(vsi->back) ||
ice_lag_is_switchdev_running(vsi->back)) &&
--
2.55.0.966.g6673acef38-goog