Skip to content

Commit cb9d43f

Browse files
Ursula Braundavem330
Ursula Braun
authored andcommitted
net/smc: determine vlan_id of stacked net_device
An SMC link group is bound to a specific vlan_id. Its link uses the RoCE-GIDs established for the specific vlan_id. This patch makes sure the appropriate vlan_id is determined for stacked scenarios like for instance a master bonding device with vlan devices enslaved. Signed-off-by: Ursula Braun <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9b67e26 commit cb9d43f

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

net/smc/smc_core.c

+23-3
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ void smc_lgr_terminate(struct smc_link_group *lgr)
360360
static int smc_vlan_by_tcpsk(struct socket *clcsock, unsigned short *vlan_id)
361361
{
362362
struct dst_entry *dst = sk_dst_get(clcsock->sk);
363-
int rc = 0;
363+
struct net_device *ndev;
364+
int i, nest_lvl, rc = 0;
364365

365366
*vlan_id = 0;
366367
if (!dst) {
@@ -372,8 +373,27 @@ static int smc_vlan_by_tcpsk(struct socket *clcsock, unsigned short *vlan_id)
372373
goto out_rel;
373374
}
374375

375-
if (is_vlan_dev(dst->dev))
376-
*vlan_id = vlan_dev_vlan_id(dst->dev);
376+
ndev = dst->dev;
377+
if (is_vlan_dev(ndev)) {
378+
*vlan_id = vlan_dev_vlan_id(ndev);
379+
goto out_rel;
380+
}
381+
382+
rtnl_lock();
383+
nest_lvl = dev_get_nest_level(ndev);
384+
for (i = 0; i < nest_lvl; i++) {
385+
struct list_head *lower = &ndev->adj_list.lower;
386+
387+
if (list_empty(lower))
388+
break;
389+
lower = lower->next;
390+
ndev = (struct net_device *)netdev_lower_get_next(ndev, &lower);
391+
if (is_vlan_dev(ndev)) {
392+
*vlan_id = vlan_dev_vlan_id(ndev);
393+
break;
394+
}
395+
}
396+
rtnl_unlock();
377397

378398
out_rel:
379399
dst_release(dst);

0 commit comments

Comments
 (0)