Skip to content

Commit ee661a4

Browse files
committed
Merge tag 'mlx5-fixes-2020-11-03' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5 fixes 2020-11-03 v1->v2: - Fix fixes line tag in patch #1 - Toss ktls refcount leak fix, Maxim will look further into the root cause. - Toss eswitch chain 0 prio patch, until we determine if it is needed for -rc and net. * tag 'mlx5-fixes-2020-11-03' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux: net/mlx5e: Fix incorrect access of RCU-protected xdp_prog net/mlx5e: Fix VXLAN synchronization after function reload net/mlx5: E-switch, Avoid extack error log for disabled vport net/mlx5: Fix deletion of duplicate rules net/mlx5e: Use spin_lock_bh for async_icosq_lock net/mlx5e: Protect encap route dev from concurrent release net/mlx5e: Fix modify header actions memory leak ==================== Link: https://lore.kernel.org/r/20201105202129.23644-1-saeedm@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 847f0a2 + 1a50cf9 commit ee661a4

13 files changed

Lines changed: 90 additions & 51 deletions

File tree

drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,16 @@ void mlx5e_rep_update_flows(struct mlx5e_priv *priv,
107107
mlx5e_tc_encap_flows_del(priv, e, &flow_list);
108108

109109
if (neigh_connected && !(e->flags & MLX5_ENCAP_ENTRY_VALID)) {
110+
struct net_device *route_dev;
111+
110112
ether_addr_copy(e->h_dest, ha);
111113
ether_addr_copy(eth->h_dest, ha);
112114
/* Update the encap source mac, in case that we delete
113115
* the flows when encap source mac changed.
114116
*/
115-
ether_addr_copy(eth->h_source, e->route_dev->dev_addr);
117+
route_dev = __dev_get_by_index(dev_net(priv->netdev), e->route_dev_ifindex);
118+
if (route_dev)
119+
ether_addr_copy(eth->h_source, route_dev->dev_addr);
116120

117121
mlx5e_tc_encap_flows_add(priv, e, &flow_list);
118122
}

drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,
7777
return 0;
7878
}
7979

80-
static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv,
81-
struct net_device *mirred_dev,
82-
struct net_device **out_dev,
83-
struct net_device **route_dev,
84-
struct flowi4 *fl4,
85-
struct neighbour **out_n,
86-
u8 *out_ttl)
80+
static int mlx5e_route_lookup_ipv4_get(struct mlx5e_priv *priv,
81+
struct net_device *mirred_dev,
82+
struct net_device **out_dev,
83+
struct net_device **route_dev,
84+
struct flowi4 *fl4,
85+
struct neighbour **out_n,
86+
u8 *out_ttl)
8787
{
8888
struct neighbour *n;
8989
struct rtable *rt;
@@ -117,18 +117,28 @@ static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv,
117117
ip_rt_put(rt);
118118
return ret;
119119
}
120+
dev_hold(*route_dev);
120121

121122
if (!(*out_ttl))
122123
*out_ttl = ip4_dst_hoplimit(&rt->dst);
123124
n = dst_neigh_lookup(&rt->dst, &fl4->daddr);
124125
ip_rt_put(rt);
125-
if (!n)
126+
if (!n) {
127+
dev_put(*route_dev);
126128
return -ENOMEM;
129+
}
127130

128131
*out_n = n;
129132
return 0;
130133
}
131134

135+
static void mlx5e_route_lookup_ipv4_put(struct net_device *route_dev,
136+
struct neighbour *n)
137+
{
138+
neigh_release(n);
139+
dev_put(route_dev);
140+
}
141+
132142
static const char *mlx5e_netdev_kind(struct net_device *dev)
133143
{
134144
if (dev->rtnl_link_ops)
@@ -193,8 +203,8 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv,
193203
fl4.saddr = tun_key->u.ipv4.src;
194204
ttl = tun_key->ttl;
195205

196-
err = mlx5e_route_lookup_ipv4(priv, mirred_dev, &out_dev, &route_dev,
197-
&fl4, &n, &ttl);
206+
err = mlx5e_route_lookup_ipv4_get(priv, mirred_dev, &out_dev, &route_dev,
207+
&fl4, &n, &ttl);
198208
if (err)
199209
return err;
200210

@@ -223,7 +233,7 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv,
223233
e->m_neigh.family = n->ops->family;
224234
memcpy(&e->m_neigh.dst_ip, n->primary_key, n->tbl->key_len);
225235
e->out_dev = out_dev;
226-
e->route_dev = route_dev;
236+
e->route_dev_ifindex = route_dev->ifindex;
227237

228238
/* It's important to add the neigh to the hash table before checking
229239
* the neigh validity state. So if we'll get a notification, in case the
@@ -278,26 +288,26 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv,
278288

279289
e->flags |= MLX5_ENCAP_ENTRY_VALID;
280290
mlx5e_rep_queue_neigh_stats_work(netdev_priv(out_dev));
281-
neigh_release(n);
291+
mlx5e_route_lookup_ipv4_put(route_dev, n);
282292
return err;
283293

284294
destroy_neigh_entry:
285295
mlx5e_rep_encap_entry_detach(netdev_priv(e->out_dev), e);
286296
free_encap:
287297
kfree(encap_header);
288298
release_neigh:
289-
neigh_release(n);
299+
mlx5e_route_lookup_ipv4_put(route_dev, n);
290300
return err;
291301
}
292302

293303
#if IS_ENABLED(CONFIG_INET) && IS_ENABLED(CONFIG_IPV6)
294-
static int mlx5e_route_lookup_ipv6(struct mlx5e_priv *priv,
295-
struct net_device *mirred_dev,
296-
struct net_device **out_dev,
297-
struct net_device **route_dev,
298-
struct flowi6 *fl6,
299-
struct neighbour **out_n,
300-
u8 *out_ttl)
304+
static int mlx5e_route_lookup_ipv6_get(struct mlx5e_priv *priv,
305+
struct net_device *mirred_dev,
306+
struct net_device **out_dev,
307+
struct net_device **route_dev,
308+
struct flowi6 *fl6,
309+
struct neighbour **out_n,
310+
u8 *out_ttl)
301311
{
302312
struct dst_entry *dst;
303313
struct neighbour *n;
@@ -318,15 +328,25 @@ static int mlx5e_route_lookup_ipv6(struct mlx5e_priv *priv,
318328
return ret;
319329
}
320330

331+
dev_hold(*route_dev);
321332
n = dst_neigh_lookup(dst, &fl6->daddr);
322333
dst_release(dst);
323-
if (!n)
334+
if (!n) {
335+
dev_put(*route_dev);
324336
return -ENOMEM;
337+
}
325338

326339
*out_n = n;
327340
return 0;
328341
}
329342

343+
static void mlx5e_route_lookup_ipv6_put(struct net_device *route_dev,
344+
struct neighbour *n)
345+
{
346+
neigh_release(n);
347+
dev_put(route_dev);
348+
}
349+
330350
int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv,
331351
struct net_device *mirred_dev,
332352
struct mlx5e_encap_entry *e)
@@ -348,8 +368,8 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv,
348368
fl6.daddr = tun_key->u.ipv6.dst;
349369
fl6.saddr = tun_key->u.ipv6.src;
350370

351-
err = mlx5e_route_lookup_ipv6(priv, mirred_dev, &out_dev, &route_dev,
352-
&fl6, &n, &ttl);
371+
err = mlx5e_route_lookup_ipv6_get(priv, mirred_dev, &out_dev, &route_dev,
372+
&fl6, &n, &ttl);
353373
if (err)
354374
return err;
355375

@@ -378,7 +398,7 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv,
378398
e->m_neigh.family = n->ops->family;
379399
memcpy(&e->m_neigh.dst_ip, n->primary_key, n->tbl->key_len);
380400
e->out_dev = out_dev;
381-
e->route_dev = route_dev;
401+
e->route_dev_ifindex = route_dev->ifindex;
382402

383403
/* It's importent to add the neigh to the hash table before checking
384404
* the neigh validity state. So if we'll get a notification, in case the
@@ -433,15 +453,15 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv,
433453

434454
e->flags |= MLX5_ENCAP_ENTRY_VALID;
435455
mlx5e_rep_queue_neigh_stats_work(netdev_priv(out_dev));
436-
neigh_release(n);
456+
mlx5e_route_lookup_ipv6_put(route_dev, n);
437457
return err;
438458

439459
destroy_neigh_entry:
440460
mlx5e_rep_encap_entry_detach(netdev_priv(e->out_dev), e);
441461
free_encap:
442462
kfree(encap_header);
443463
release_neigh:
444-
neigh_release(n);
464+
mlx5e_route_lookup_ipv6_put(route_dev, n);
445465
return err;
446466
}
447467
#endif

drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ void mlx5e_activate_xsk(struct mlx5e_channel *c)
122122
set_bit(MLX5E_RQ_STATE_ENABLED, &c->xskrq.state);
123123
/* TX queue is created active. */
124124

125-
spin_lock(&c->async_icosq_lock);
125+
spin_lock_bh(&c->async_icosq_lock);
126126
mlx5e_trigger_irq(&c->async_icosq);
127-
spin_unlock(&c->async_icosq_lock);
127+
spin_unlock_bh(&c->async_icosq_lock);
128128
}
129129

130130
void mlx5e_deactivate_xsk(struct mlx5e_channel *c)

drivers/net/ethernet/mellanox/mlx5/core/en/xsk/tx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ int mlx5e_xsk_wakeup(struct net_device *dev, u32 qid, u32 flags)
3636
if (test_and_set_bit(MLX5E_SQ_STATE_PENDING_XSK_TX, &c->async_icosq.state))
3737
return 0;
3838

39-
spin_lock(&c->async_icosq_lock);
39+
spin_lock_bh(&c->async_icosq_lock);
4040
mlx5e_trigger_irq(&c->async_icosq);
41-
spin_unlock(&c->async_icosq_lock);
41+
spin_unlock_bh(&c->async_icosq_lock);
4242
}
4343

4444
return 0;

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static int post_rx_param_wqes(struct mlx5e_channel *c,
188188

189189
err = 0;
190190
sq = &c->async_icosq;
191-
spin_lock(&c->async_icosq_lock);
191+
spin_lock_bh(&c->async_icosq_lock);
192192

193193
cseg = post_static_params(sq, priv_rx);
194194
if (IS_ERR(cseg))
@@ -199,7 +199,7 @@ static int post_rx_param_wqes(struct mlx5e_channel *c,
199199

200200
mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, cseg);
201201
unlock:
202-
spin_unlock(&c->async_icosq_lock);
202+
spin_unlock_bh(&c->async_icosq_lock);
203203

204204
return err;
205205

@@ -265,10 +265,10 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq,
265265

266266
BUILD_BUG_ON(MLX5E_KTLS_GET_PROGRESS_WQEBBS != 1);
267267

268-
spin_lock(&sq->channel->async_icosq_lock);
268+
spin_lock_bh(&sq->channel->async_icosq_lock);
269269

270270
if (unlikely(!mlx5e_wqc_has_room_for(&sq->wq, sq->cc, sq->pc, 1))) {
271-
spin_unlock(&sq->channel->async_icosq_lock);
271+
spin_unlock_bh(&sq->channel->async_icosq_lock);
272272
err = -ENOSPC;
273273
goto err_dma_unmap;
274274
}
@@ -299,7 +299,7 @@ resync_post_get_progress_params(struct mlx5e_icosq *sq,
299299
icosq_fill_wi(sq, pi, &wi);
300300
sq->pc++;
301301
mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, cseg);
302-
spin_unlock(&sq->channel->async_icosq_lock);
302+
spin_unlock_bh(&sq->channel->async_icosq_lock);
303303

304304
return 0;
305305

@@ -360,7 +360,7 @@ static int resync_handle_seq_match(struct mlx5e_ktls_offload_context_rx *priv_rx
360360
err = 0;
361361

362362
sq = &c->async_icosq;
363-
spin_lock(&c->async_icosq_lock);
363+
spin_lock_bh(&c->async_icosq_lock);
364364

365365
cseg = post_static_params(sq, priv_rx);
366366
if (IS_ERR(cseg)) {
@@ -372,7 +372,7 @@ static int resync_handle_seq_match(struct mlx5e_ktls_offload_context_rx *priv_rx
372372
mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, cseg);
373373
priv_rx->stats->tls_resync_res_ok++;
374374
unlock:
375-
spin_unlock(&c->async_icosq_lock);
375+
spin_unlock_bh(&c->async_icosq_lock);
376376

377377
return err;
378378
}

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5253,6 +5253,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)
52535253

52545254
mlx5e_disable_async_events(priv);
52555255
mlx5_lag_remove(mdev);
5256+
mlx5_vxlan_reset_to_default(mdev->vxlan);
52565257
}
52575258

52585259
int mlx5e_update_nic_rx(struct mlx5e_priv *priv)

drivers/net/ethernet/mellanox/mlx5/core/en_rep.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ struct mlx5e_encap_entry {
186186
unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
187187

188188
struct net_device *out_dev;
189-
struct net_device *route_dev;
189+
int route_dev_ifindex;
190190
struct mlx5e_tc_tunnel *tunnel;
191191
int reformat_type;
192192
u8 flags;

drivers/net/ethernet/mellanox/mlx5/core/en_rx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget)
15841584
} while ((++work_done < budget) && (cqe = mlx5_cqwq_get_cqe(cqwq)));
15851585

15861586
out:
1587-
if (rq->xdp_prog)
1587+
if (rcu_access_pointer(rq->xdp_prog))
15881588
mlx5e_xdp_rx_poll_complete(rq);
15891589

15901590
mlx5_cqwq_update_db_record(cqwq);

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4658,6 +4658,7 @@ __mlx5e_add_fdb_flow(struct mlx5e_priv *priv,
46584658
return flow;
46594659

46604660
err_free:
4661+
dealloc_mod_hdr_actions(&parse_attr->mod_hdr_acts);
46614662
mlx5e_flow_put(priv, flow);
46624663
out:
46634664
return ERR_PTR(err);
@@ -4802,6 +4803,7 @@ mlx5e_add_nic_flow(struct mlx5e_priv *priv,
48024803
return 0;
48034804

48044805
err_free:
4806+
dealloc_mod_hdr_actions(&parse_attr->mod_hdr_acts);
48054807
mlx5e_flow_put(priv, flow);
48064808
out:
48074809
return err;

drivers/net/ethernet/mellanox/mlx5/core/eswitch.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,8 +1902,6 @@ int mlx5_devlink_port_function_hw_addr_get(struct devlink *devlink,
19021902
ether_addr_copy(hw_addr, vport->info.mac);
19031903
*hw_addr_len = ETH_ALEN;
19041904
err = 0;
1905-
} else {
1906-
NL_SET_ERR_MSG_MOD(extack, "Eswitch vport is disabled");
19071905
}
19081906
mutex_unlock(&esw->state_lock);
19091907
return err;

0 commit comments

Comments
 (0)