Skip to content

Commit 0a66e55

Browse files
Amit Cohenkuba-moo
authored andcommitted
mlxsw: spectrum_ptp: Add missing verification before pushing Tx header
Tx header should be pushed for each packet which is transmitted via Spectrum ASICs. The cited commit moved the call to skb_cow_head() from mlxsw_sp_port_xmit() to functions which handle Tx header. In case that mlxsw_sp->ptp_ops->txhdr_construct() is used to handle Tx header, and txhdr_construct() is mlxsw_sp_ptp_txhdr_construct(), there is no call for skb_cow_head() before pushing Tx header size to SKB. This flow is relevant for Spectrum-1 and Spectrum-4, for PTP packets. Add the missing call to skb_cow_head() to make sure that there is both enough room to push the Tx header and that the SKB header is not cloned and can be modified. An additional set will be sent to net-next to centralize the handling of the Tx header by pushing it to every packet just before transmission. Cc: Richard Cochran <[email protected]> Fixes: 24157bc ("mlxsw: Send PTP packets as data packets to overcome a limitation") Signed-off-by: Amit Cohen <[email protected]> Signed-off-by: Petr Machata <[email protected]> Link: https://patch.msgid.link/5145780b07ebbb5d3b3570f311254a3a2d554a44.1729866134.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 04c20a9 commit 0a66e55

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "spectrum.h"
1717
#include "spectrum_ptp.h"
1818
#include "core.h"
19+
#include "txheader.h"
1920

2021
#define MLXSW_SP1_PTP_CLOCK_CYCLES_SHIFT 29
2122
#define MLXSW_SP1_PTP_CLOCK_FREQ_KHZ 156257 /* 6.4nSec */
@@ -1684,6 +1685,12 @@ int mlxsw_sp_ptp_txhdr_construct(struct mlxsw_core *mlxsw_core,
16841685
struct sk_buff *skb,
16851686
const struct mlxsw_tx_info *tx_info)
16861687
{
1688+
if (skb_cow_head(skb, MLXSW_TXHDR_LEN)) {
1689+
this_cpu_inc(mlxsw_sp_port->pcpu_stats->tx_dropped);
1690+
dev_kfree_skb_any(skb);
1691+
return -ENOMEM;
1692+
}
1693+
16871694
mlxsw_sp_txhdr_construct(skb, tx_info);
16881695
return 0;
16891696
}

0 commit comments

Comments
 (0)