mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
synced 2026-04-23 08:55:56 -04:00
netdevsim: generate random switch id instead of using dev id
Current implementation of parent_id/switch_id does not follow the original idea of being unique. The values are "0", "1", etc. Instead of that, generate 32 random bytes. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
d514f41e79
commit
514cf64cc5
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <net/devlink.h>
|
||||
|
||||
@@ -204,6 +205,8 @@ static struct nsim_dev *nsim_dev_create(struct nsim_bus_dev *nsim_bus_dev)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
nsim_dev = devlink_priv(devlink);
|
||||
nsim_dev->nsim_bus_dev = nsim_bus_dev;
|
||||
nsim_dev->switch_id.id_len = sizeof(nsim_dev->switch_id.id);
|
||||
get_random_bytes(nsim_dev->switch_id.id, nsim_dev->switch_id.id_len);
|
||||
|
||||
nsim_dev->fib_data = nsim_fib_create();
|
||||
if (IS_ERR(nsim_dev->fib_data)) {
|
||||
|
||||
Reference in New Issue
Block a user