Mellanox, mlx5 fixes 2019-04-09
Subsystems (5)
Hi Dave,
This series provides some fixes to mlx5 driver.
I've cc'ed some of the checksum fixes to Eric Dumazet and i would like to get his feedback before you pull.
For -stable v4.19
('net/mlx5: FPGA, tls, idr remove on flow delete') ('net/mlx5: FPGA, tls, hold rcu read lock a bit longer')
For -stable v4.20
('net/mlx5e: Rx, Check ip headers sanity')
('Revert "net/mlx5e: Enable reporting checksum unnecessary also for L3 packets"') ('net/mlx5e: Rx, Fixup skb checksum for packets with tail padding')
For -stable v5.0
('net/mlx5e: Switch to Toeplitz RSS hash by default') ('net/mlx5e: Protect against non-uplink representor for encap') ('net/mlx5e: XDP, Avoid checksum complete when XDP prog is loaded')
Thanks,
Saeed.
Thanks,
Saeed.
---
The following changes since commit c03fd0171ba6c8807ff5ba7c797896c84e18f3bc:
Merge tag 'mac80211-for-davem-2019-04-09' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211 (2019-04-09 10:57:10 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2019-04-09
for you to fetch changes up to 7ee2ace9c544a0886e02b54b625e521df8692d20:
net/mlx5e: Switch to Toeplitz RSS hash by default (2019-04-09 12:33:51 -0700)
----------------------------------------------------------------
mlx5-fixes-2019-04-09
----------------------------------------------------------------
Dmytro Linkin (1):
net/mlx5e: Protect against non-uplink representor for encap
Eran Ben Elisha (2):
net/mlx5e: Skip un-needed tx recover if interface state is down net/mlx5e: Use fail-safe channels reopen in tx reporter recover
Konstantin Khlebnikov (1):
net/mlx5e: Switch to Toeplitz RSS hash by default
Or Gerlitz (1):
Revert "net/mlx5e: Enable reporting checksum unnecessary also for L3 packets"
Saeed Mahameed (5):
net/mlx5: FPGA, tls, hold rcu read lock a bit longer net/mlx5: FPGA, tls, idr remove on flow delete net/mlx5e: XDP, Avoid checksum complete when XDP prog is loaded net/mlx5e: Rx, Fixup skb checksum for packets with tail padding net/mlx5e: Rx, Check ip headers sanity
drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + .../ethernet/mellanox/mlx5/core/en/reporter_tx.c | 11 ++- .../net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 4 + .../net/ethernet/mellanox/mlx5/core/en_ethtool.c | 3 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 21 +++-- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 94 +++++++++++++++++----- drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 6 ++ drivers/net/ethernet/mellanox/mlx5/core/en_stats.h | 4 + drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c | 61 ++++++-------- 9 files changed, 140 insertions(+), 65 deletions(-)
PATCH 1/10 net/mlx5: FPGA, tls, hold rcu read lock a bit longer
To avoid use-after-free, hold the rcu read lock until we are done copying flow data into the command buffer.
--- .../net/ethernet/mellanox/mlx5/core/fpga/tls.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c +9 -9
@@ -217,22 +217,22 @@ int mlx5_fpga_tls_resync_rx(struct mlx5_core_dev *mdev, u32 handle, u32 seq,void *cmd;int ret; -rcu_read_lock (); - flow =idr_find (&mdev->fpga->tls->rx_idr,ntohl (handle)); -rcu_read_unlock (); - -if (!flow) { -WARN_ONCE (1 ,"Received NULL pointer for handle\n" ); -return -EINVAL ; - } - buf =kzalloc (size,GFP_ATOMIC );if (!buf)return -ENOMEM ; cmd = (buf +1 ); +rcu_read_lock (); + flow =idr_find (&mdev->fpga->tls->rx_idr,ntohl (handle)); +if (unlikely (!flow)) { +rcu_read_unlock (); +WARN_ONCE (1 ,"Received NULL pointer for handle\n" ); +kfree (buf); +return -EINVAL ; + }mlx5_fpga_tls_flow_to_cmd (flow, cmd); +rcu_read_unlock ();MLX5_SET (tls_cmd, cmd, swid,ntohl (handle));MLX5_SET64 (tls_cmd, cmd, tls_rcd_sn,be64_to_cpu (rcd_sn));
Signature · 1 line
2.20.1
PATCH 2/10 net/mlx5: FPGA, tls, idr remove on flow delete
In reply to Saeed MahameedFlow is kfreed on mlx5_fpga_tls_del_flow but kept in the idr data structure, this is risky and can cause use-after-free, since the idr_remove is delayed until tls_send_teardown_cmd completion.
Instead of delaying idr_remove, in this patch we do it on mlx5_fpga_tls_del_flow, before actually kfree(flow).
Added synchronize_rcu before kfree(flow)
--- .../ethernet/mellanox/mlx5/core/fpga/tls.c | 43 +++++++------------ 1 file changed, 15 insertions(+), 28 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c +15 -28
@@ -148,14 +148,16 @@ static int mlx5_fpga_tls_alloc_swid(struct idr *idr, spinlock_t *idr_spinlock,return ret; } -static void mlx5_fpga_tls_release_swid (struct idr *idr, -spinlock_t *idr_spinlock,u32 swid) +static void *mlx5_fpga_tls_release_swid (struct idr *idr, +spinlock_t *idr_spinlock,u32 swid) {unsigned long flags; +void *ptr;spin_lock_irqsave (idr_spinlock, flags); -idr_remove (idr, swid); + ptr =idr_remove (idr, swid);spin_unlock_irqrestore (idr_spinlock, flags); +return ptr; } static void mlx_tls_kfree_complete(struct mlx5_fpga_conn *conn,
@@ -165,20 +167,12 @@ static void mlx_tls_kfree_complete(struct mlx5_fpga_conn *conn,kfree (buf); } -struct mlx5_teardown_stream_context { -struct mlx5_fpga_tls_command_context cmd; -u32 swid; -}; -static void mlx5_fpga_tls_teardown_completion (struct mlx5_fpga_conn *conn,struct mlx5_fpga_device *fdev,struct mlx5_fpga_tls_command_context *cmd,struct mlx5_fpga_dma_buf *resp) { -struct mlx5_teardown_stream_context *ctx = - container_of(cmd, struct mlx5_teardown_stream_context, cmd); -if (resp) {u32 syndrome =MLX5_GET (tls_resp, resp->sg[0 ].data, syndrome);
@@ -186,14 +180,6 @@ mlx5_fpga_tls_teardown_completion(struct mlx5_fpga_conn *conn,mlx5_fpga_err (fdev,"Teardown stream failed with syndrome = %d" , syndrome); - else if (MLX5_GET(tls_cmd, cmd->buf.sg[0].data, direction_sx)) - mlx5_fpga_tls_release_swid(&fdev->tls->tx_idr, - &fdev->tls->tx_idr_spinlock, - ctx->swid); - else - mlx5_fpga_tls_release_swid(&fdev->tls->rx_idr, - &fdev->tls->rx_idr_spinlock, - ctx->swid); }mlx5_fpga_tls_put_command_ctx (cmd); }
@@ -253,7 +239,7 @@ int mlx5_fpga_tls_resync_rx(struct mlx5_core_dev *mdev, u32 handle, u32 seq,static void mlx5_fpga_tls_send_teardown_cmd (struct mlx5_core_dev *mdev,void *flow,u32 swid,gfp_t flags) { -struct mlx5_teardown_stream_context *ctx; +struct mlx5_fpga_tls_command_context *ctx;struct mlx5_fpga_dma_buf *buf;void *cmd;
@@ -261,7 +247,7 @@ static void mlx5_fpga_tls_send_teardown_cmd(struct mlx5_core_dev *mdev,if (!ctx)return ; - buf = &ctx->cmd.buf; + buf = &ctx->buf; cmd = (ctx +1 );MLX5_SET (tls_cmd, cmd, command_type,CMD_TEARDOWN_STREAM );MLX5_SET (tls_cmd, cmd, swid, swid);
@@ -272,8 +258,7 @@ static void mlx5_fpga_tls_send_teardown_cmd(struct mlx5_core_dev *mdev, buf->sg[0 ].data = cmd; buf->sg[0 ].size =MLX5_TLS_COMMAND_SIZE ; - ctx->swid = swid; -mlx5_fpga_tls_cmd_send (mdev->fpga, &ctx->cmd, +mlx5_fpga_tls_cmd_send (mdev->fpga, ctx, mlx5_fpga_tls_teardown_completion); }
@@ -283,13 +268,14 @@ void mlx5_fpga_tls_del_flow(struct mlx5_core_dev *mdev, u32 swid,struct mlx5_fpga_tls *tls = mdev->fpga->tls;void *flow; -rcu_read_lock ();if (direction_sx) - flow =idr_find (&tls->tx_idr, swid); + flow =mlx5_fpga_tls_release_swid (&tls->tx_idr, + &tls->tx_idr_spinlock, + swid);else - flow =idr_find (&tls->rx_idr, swid); - -rcu_read_unlock (); + flow =mlx5_fpga_tls_release_swid (&tls->rx_idr, + &tls->rx_idr_spinlock, + swid);if (!flow) { mlx5_fpga_err(mdev->fpga, "No flow information for swid %u\n",
@@ -297,6 +283,7 @@ void mlx5_fpga_tls_del_flow(struct mlx5_core_dev *mdev, u32 swid,return ; } +synchronize_rcu ();/* before kfree(flow) */ mlx5_fpga_tls_send_teardown_cmd (mdev, flow, swid, flags); }
Signature · 1 line
2.20.1
PATCH 3/10 net/mlx5e: Skip un-needed tx recover if interface state is down
In reply to Saeed MahameedFrom: Eran Ben Elisha <[email protected]>
Skip recover operation if interface is in down state as TX objects are not open. This fixes a bug were the recover flow re-opened TX objects which were not opened before, leading to a possible memory leak at driver unload.
--- drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c +7 -1
@@ -186,12 +186,18 @@ static int mlx5e_tx_reporter_recover_from_ctx(struct mlx5e_tx_err_ctx *err_ctx)static int mlx5e_tx_reporter_recover_all (struct mlx5e_priv *priv) { -int err; +int err =0 ;rtnl_lock ();mutex_lock (&priv->state_lock); + +if (!test_bit (MLX5E_STATE_OPENED , &priv->state)) + goto out; +mlx5e_close_locked (priv->netdev); err =mlx5e_open_locked (priv->netdev); + +out:mutex_unlock (&priv->state_lock);rtnl_unlock ();
Signature · 1 line
2.20.1
PATCH 4/10 net/mlx5e: Use fail-safe channels reopen in tx reporter recover
In reply to Saeed MahameedFrom: Eran Ben Elisha <[email protected]>
When requested to recover from error, the tx reporter might open new channels and close the existing ones. Use safe channels switch flow in order to guarantee opened channels at the end of the recover flow. For this purpose, define mlx5e_safe_reopen_channels function and use it within those flows.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + .../ethernet/mellanox/mlx5/core/en/reporter_tx.c | 3 +-- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 13 ++++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -0
@@ -858,6 +858,7 @@ void mlx5e_close_channels(struct mlx5e_channels *chs);* switching channels */ typedef int (*mlx5e_fp_hw_modify )(struct mlx5e_priv *priv); +int mlx5e_safe_reopen_channels (struct mlx5e_priv *priv);int mlx5e_safe_switch_channels (struct mlx5e_priv *priv,struct mlx5e_channels *new_chs,mlx5e_fp_hw_modify hw_modify);
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c +1 -2
@@ -194,8 +194,7 @@ static int mlx5e_tx_reporter_recover_all(struct mlx5e_priv *priv)if (!test_bit (MLX5E_STATE_OPENED , &priv->state)) goto out; -mlx5e_close_locked (priv->netdev); - err =mlx5e_open_locked (priv->netdev); + err =mlx5e_safe_reopen_channels (priv); out:mutex_unlock (&priv->state_lock);
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +10 -3
@@ -2937,6 +2937,14 @@ int mlx5e_safe_switch_channels(struct mlx5e_priv *priv,return 0 ; } +int mlx5e_safe_reopen_channels (struct mlx5e_priv *priv) +{ +struct mlx5e_channels new_channels = {}; + + new_channels.params = priv->channels.params; +return mlx5e_safe_switch_channels (priv, &new_channels,NULL ); +} +void mlx5e_timestamp_init (struct mlx5e_priv *priv) { priv->tstamp.tx_type =HWTSTAMP_TX_OFF ;
@@ -4161,11 +4169,10 @@ static void mlx5e_tx_timeout_work(struct work_struct *work)if (!report_failed) goto unlock; -mlx5e_close_locked (priv->netdev); - err =mlx5e_open_locked (priv->netdev); + err =mlx5e_safe_reopen_channels (priv);if (err)netdev_err (priv->netdev, -"mlx5e_open_locked failed recovering from a tx_timeout, err(%d).\n" , +"mlx5e_safe_reopen_channels failed recovering from a tx_timeout, err(%d).\n" , err); unlock:
Signature · 1 line
2.20.1
PATCH 5/10 net/mlx5e: XDP, Avoid checksum complete when XDP prog is loaded
In reply to Saeed MahameedXDP programs might change packets data contents which will make the reported skb checksum (checksum complete) invalid.
When XDP programs are loaded/unloaded set/clear rx RQs MLX5E_RQ_STATE_NO_CSUM_COMPLETE flag.
--- drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 3 ++- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 6 +++++- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +2 -1
@@ -1768,7 +1768,8 @@ static int set_pflag_rx_no_csum_complete(struct net_device *netdev, bool enable)struct mlx5e_channel *c;int i; -if (!test_bit (MLX5E_STATE_OPENED , &priv->state)) +if (!test_bit (MLX5E_STATE_OPENED , &priv->state) || + priv->channels.params.xdp_prog)return 0 ;for (i =0 ; i < channels->num; i++) {
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +5 -1
@@ -951,7 +951,11 @@ static int mlx5e_open_rq(struct mlx5e_channel *c,if (params->rx_dim_enabled)__set_bit (MLX5E_RQ_STATE_AM , &c->rq.state); -if (MLX5E_GET_PFLAG (params,MLX5E_PFLAG_RX_NO_CSUM_COMPLETE )) +/* We disable csum_complete when XDP is enabled since +* XDP programs might manipulate packets which will render +* skb->checksum incorrect. +*/ +if (MLX5E_GET_PFLAG (params,MLX5E_PFLAG_RX_NO_CSUM_COMPLETE ) || c->xdp)__set_bit (MLX5E_RQ_STATE_NO_CSUM_COMPLETE , &c->rq.state);return 0 ;
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +2 -1
@@ -752,7 +752,8 @@ static inline void mlx5e_handle_csum(struct net_device *netdev,return ; } -if (unlikely (test_bit (MLX5E_RQ_STATE_NO_CSUM_COMPLETE , &rq->state))) +/* True when explicitly set via priv flag, or XDP prog is loaded */ +if (test_bit (MLX5E_RQ_STATE_NO_CSUM_COMPLETE , &rq->state)) goto csum_unnecessary;/* CQE csum doesn't cover padding octets in short ethernet
Signature · 1 line
2.20.1
PATCH 6/10 net/mlx5e: Rx, Fixup skb checksum for packets with tail padding
In reply to Saeed MahameedWhen an ethernet frame with ip payload is padded, the padding octets are not covered by the hardware checksum.
Prior to the cited commit, skb checksum was forced to be CHECKSUM_NONE when padding is detected. After it, the kernel will try to trim the padding bytes and subtract their checksum from skb->csum.
In this patch we fixup skb->csum for any ip packet with tail padding of any size, if any padding found.
FCS case is just one special case of this general purpose patch, hence, it is removed.
--- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 79 +++++++++++++++---- .../ethernet/mellanox/mlx5/core/en_stats.c | 6 ++ .../ethernet/mellanox/mlx5/core/en_stats.h | 4 + 3 files changed, 74 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +64 -15
@@ -712,17 +712,6 @@ static inline void mlx5e_enable_ecn(struct mlx5e_rq *rq, struct sk_buff *skb) rq->stats->ecn_mark += !!rc; } -static u32 mlx5e_get_fcs (const struct sk_buff *skb) -{ -const void *fcs_bytes; -u32 _fcs_bytes; - - fcs_bytes =skb_header_pointer (skb, skb->len -ETH_FCS_LEN , -ETH_FCS_LEN , &_fcs_bytes); - -return __get_unaligned_cpu32 (fcs_bytes); -} -static u8 get_ip_proto (struct sk_buff *skb,int network_depth,__be16 proto) {void *ip_p = skb->data + network_depth;
@@ -733,6 +722,68 @@ static u8 get_ip_proto(struct sk_buff *skb, int network_depth, __be16 proto)#define short_frame (size) ((size) <= ETH_ZLEN + ETH_FCS_LEN) +#define MAX_PADDING 8 + +static void +tail_padding_csum_slow (struct sk_buff *skb,int offset,int len, +struct mlx5e_rq_stats *stats) +{ + stats->csum_complete_tail_slow++; + skb->csum =csum_block_add (skb->csum, +skb_checksum (skb, offset, len,0 ), + offset); +} + +static void +tail_padding_csum (struct sk_buff *skb,int offset, +struct mlx5e_rq_stats *stats) +{ +u8 tail_padding[MAX_PADDING ]; +int len = skb->len - offset; +void *tail; + +if (unlikely (len >MAX_PADDING )) { +tail_padding_csum_slow (skb, offset, len, stats); +return ; + } + + tail =skb_header_pointer (skb, offset, len, tail_padding); +if (unlikely (!tail)) { +tail_padding_csum_slow (skb, offset, len, stats); +return ; + } + + stats->csum_complete_tail++; + skb->csum =csum_block_add (skb->csum,csum_partial (tail, len,0 ), offset); +} + +static void +mlx5e_skb_padding_csum (struct sk_buff *skb,int network_depth,__be16 proto, +struct mlx5e_rq_stats *stats) +{ +struct ipv6hdr *ip6; +struct iphdr *ip4; +int pkt_len; + +switch (proto) { +case htons (ETH_P_IP ): + ip4 = (struct iphdr *)(skb->data + network_depth); + pkt_len = network_depth +ntohs (ip4->tot_len); +break ; +case htons (ETH_P_IPV6 ): + ip6 = (struct ipv6hdr *)(skb->data + network_depth); + pkt_len = network_depth +sizeof (*ip6) +ntohs (ip6->payload_len); +break ; +default : +return ; + } + +if (likely (pkt_len >= skb->len)) +return ; + +tail_padding_csum (skb, pkt_len, stats); +} + static inline void mlx5e_handle_csum(struct net_device *netdev, struct mlx5_cqe64 *cqe, struct mlx5e_rq *rq,
@@ -781,10 +832,8 @@ static inline void mlx5e_handle_csum(struct net_device *netdev, skb->csum =csum_partial (skb->data +ETH_HLEN , network_depth -ETH_HLEN , skb->csum); -if (unlikely (netdev->features &NETIF_F_RXFCS )) - skb->csum =csum_block_add (skb->csum, - (__force __wsum )mlx5e_get_fcs (skb), - skb->len -ETH_FCS_LEN ); + +mlx5e_skb_padding_csum (skb, network_depth, proto, stats); stats->csum_complete++;return ; }
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +6 -0
@@ -59,6 +59,8 @@ static const struct counter_desc sw_stats_desc[] = { { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_unnecessary) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_none) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_complete) }, + { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_complete_tail) }, + { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_complete_tail_slow) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_unnecessary_inner) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_drop) }, { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_redirect) },
@@ -151,6 +153,8 @@ static void mlx5e_grp_sw_update_stats(struct mlx5e_priv *priv) s->rx_removed_vlan_packets += rq_stats->removed_vlan_packets; s->rx_csum_none += rq_stats->csum_none; s->rx_csum_complete += rq_stats->csum_complete; + s->rx_csum_complete_tail += rq_stats->csum_complete_tail; + s->rx_csum_complete_tail_slow += rq_stats->csum_complete_tail_slow; s->rx_csum_unnecessary += rq_stats->csum_unnecessary; s->rx_csum_unnecessary_inner += rq_stats->csum_unnecessary_inner; s->rx_xdp_drop += rq_stats->xdp_drop;
@@ -1190,6 +1194,8 @@ static const struct counter_desc rq_stats_desc[] = { { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, packets) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, bytes) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete) }, + { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete_tail) }, + { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete_tail_slow) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary_inner) }, { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_none) },
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +4 -0
@@ -71,6 +71,8 @@ struct mlx5e_sw_stats {u64 rx_csum_unnecessary;u64 rx_csum_none;u64 rx_csum_complete; +u64 rx_csum_complete_tail; +u64 rx_csum_complete_tail_slow;u64 rx_csum_unnecessary_inner;u64 rx_xdp_drop;u64 rx_xdp_redirect;
@@ -181,6 +183,8 @@ struct mlx5e_rq_stats {u64 packets;u64 bytes;u64 csum_complete; +u64 csum_complete_tail; +u64 csum_complete_tail_slow;u64 csum_unnecessary;u64 csum_unnecessary_inner;u64 csum_none;
Signature · 1 line
2.20.1
PATCH 7/10 net/mlx5e: Rx, Check ip headers sanity
In reply to Saeed MahameedIn the two places is_last_ethertype_ip is being called, the caller will be looking inside the ip header, to be safe, add ip{4,6} header sanity check. And return true only on valid ip headers, i.e: the whole header is contained in the linear part of the skb.
Note: Such situation is very rare and hard to reproduce, since mlx5e allocates a large enough headroom to contain the largest header one can imagine.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +8 -1
@@ -692,7 +692,14 @@ static inline bool is_last_ethertype_ip(struct sk_buff *skb, int *network_depth, { *proto = ((struct ethhdr *)skb->data)->h_proto; *proto =__vlan_get_protocol (skb, *proto, network_depth); -return (*proto ==htons (ETH_P_IP ) || *proto ==htons (ETH_P_IPV6 )); + +if (*proto ==htons (ETH_P_IP )) +return pskb_may_pull (skb, *network_depth +sizeof (struct iphdr )); + +if (*proto ==htons (ETH_P_IPV6 )) +return pskb_may_pull (skb, *network_depth +sizeof (struct ipv6hdr )); + +return false; }static inline void mlx5e_enable_ecn (struct mlx5e_rq *rq,struct sk_buff *skb)
Signature · 1 line
2.20.1
PATCH 8/10 net/mlx5e: Protect against non-uplink representor for encap
In reply to Saeed MahameedFrom: Dmytro Linkin <[email protected]>
TC encap offload is supported only for the physical uplink representor. Fail for non uplink representor.
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +4 -0
@@ -39,6 +39,10 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,return -EOPNOTSUPP ; } +if (!(mlx5e_eswitch_rep (*out_dev) && +mlx5e_is_uplink_rep (netdev_priv (*out_dev)))) +return -EOPNOTSUPP ; +return 0 ; }
Signature · 1 line
2.20.1
PATCH 9/10 Revert "net/mlx5e: Enable reporting checksum unnecessary also for L3 packets"
In reply to Saeed MahameedFrom: Or Gerlitz <[email protected]>
This reverts commit b820e6fb0978f9c2ac438c199d2bb2f35950e9c9.
Prior the commit we are reverting, checksum unnecessary was only set when both the L3 OK and L4 OK bits are set on the CQE. This caused packets of IP protocols such as SCTP which are not dealt by the current HW L4 parser (hence the L4 OK bit is not set, but the L4 header type none bit is set) to go through the checksum none code, where currently we wrongly report checksum unnecessary for them, a regression. Fix this by a revert.
Note that on our usual track we report checksum complete, so the revert isn't expected to have any notable performance impact. Also, when we are not on the checksum complete track, the L4 protocols for which we report checksum none are not high performance ones, we will still report checksum unnecessary for UDP/TCP.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1 -2
@@ -847,8 +847,7 @@ static inline void mlx5e_handle_csum(struct net_device *netdev, csum_unnecessary:if (likely ((cqe->hds_ip_ext &CQE_L3_OK ) && - ((cqe->hds_ip_ext &CQE_L4_OK ) || - (get_cqe_l4_hdr_type (cqe) ==CQE_L4_HDR_TYPE_NONE )))) { + (cqe->hds_ip_ext &CQE_L4_OK ))) { skb->ip_summed =CHECKSUM_UNNECESSARY ;if (cqe_is_tunneled (cqe)) { skb->csum_level =1 ;
Signature · 1 line
2.20.1
PATCH 10/10 net/mlx5e: Switch to Toeplitz RSS hash by default
In reply to Saeed MahameedFrom: Konstantin Khlebnikov <[email protected]>
Although XOR hash function can perform very well on some special use cases, to align with all drivers, mlx5 driver should use Toeplitz hash by default.
Toeplitz is more stable for the general use case and it is more standard and reliable.
On top of that, since XOR (MLX5_RX_HASH_FN_INVERTED_XOR8) gives only a repeated 8 bits pattern. When used for udp tunneling RSS source port manipulation it results in fixed source port, which will cause bad RSS spread.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -1
@@ -4564,7 +4564,7 @@ void mlx5e_build_rss_params(struct mlx5e_rss_params *rss_params, {enum mlx5e_traffic_types tt; - rss_params->hfunc =ETH_RSS_HASH_XOR ; + rss_params->hfunc =ETH_RSS_HASH_TOP ;netdev_rss_key_fill (rss_params->toeplitz_hash_key,sizeof (rss_params->toeplitz_hash_key)); mlx5e_build_default_indir_rqt(rss_params->indirection_rqt,
Signature · 1 line
2.20.1
David Miller
maintainerFrom: Saeed Mahameed <[email protected]>
Date: Tue, 9 Apr 2019 12:36:26 -0700
Quoted 2 lines
I've cc'ed some of the checksum fixes to Eric Dumazet and i would like to get his feedback before you pull.
Ok, I'll wait for that.
From: Saeed Mahameed <[email protected]>
Date: Tue, 9 Apr 2019 12:36:26 -0700
Quoted 4 lines
This series provides some fixes to mlx5 driver.
I've cc'ed some of the checksum fixes to Eric Dumazet and i would like to get his feedback before you pull.
I gave him enough time to provide feedback.
Pulled.
Quoted 9 lines
For -stable v4.19
('net/mlx5: FPGA, tls, idr remove on flow delete') ('net/mlx5: FPGA, tls, hold rcu read lock a bit longer')For -stable v4.20
('net/mlx5e: Rx, Check ip headers sanity')
('Revert "net/mlx5e: Enable reporting checksum unnecessary also for L3 packets"') ('net/mlx5e: Rx, Fixup skb checksum for packets with tail padding')
Quoted 4 lines
For -stable v5.0
('net/mlx5e: Switch to Toeplitz RSS hash by default') ('net/mlx5e: Protect against non-uplink representor for encap') ('net/mlx5e: XDP, Avoid checksum complete when XDP prog is loaded')
Queued up, thanks.