Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
768f80eb
Commit
768f80eb
authored
Aug 30, 2021
by
Antoine Kaufmann
Browse files
lib/nicbm: include hostname in mac address seed
Reduces the risk of getting the same mac in multi-host clusters
parent
4a78389a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
lib/simbricks/nicbm/nicbm.cc
lib/simbricks/nicbm/nicbm.cc
+13
-1
No files found.
lib/simbricks/nicbm/nicbm.cc
View file @
768f80eb
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include "lib/simbricks/nicbm/nicbm.h"
#include "lib/simbricks/nicbm/nicbm.h"
#include <limits.h>
#include <signal.h>
#include <signal.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
...
@@ -474,7 +475,18 @@ void Runner::EventTrigger() {
...
@@ -474,7 +475,18 @@ void Runner::EventTrigger() {
Runner
::
Runner
(
Device
&
dev
)
:
dev_
(
dev
),
events_
(
EventCmp
())
{
Runner
::
Runner
(
Device
&
dev
)
:
dev_
(
dev
),
events_
(
EventCmp
())
{
// mac_addr = lrand48() & ~(3ULL << 46);
// mac_addr = lrand48() & ~(3ULL << 46);
dma_pending_
=
0
;
dma_pending_
=
0
;
srand48
(
time
(
NULL
)
^
getpid
());
uint32_t
hnhash
=
time
(
NULL
)
^
getpid
();
char
hostname
[
HOST_NAME_MAX
];
memset
(
hostname
,
0
,
sizeof
(
hostname
));
if
(
gethostname
(
hostname
,
HOST_NAME_MAX
))
{
fprintf
(
stderr
,
"Runner::Runner: warning getting hostname failed
\n
"
);
}
for
(
size_t
i
=
0
;
i
<
sizeof
(
hostname
)
/
sizeof
(
uint32_t
);
i
++
)
{
hnhash
^=
((
uint32_t
*
)
hostname
)[
i
];
}
srand48
(
hnhash
);
mac_addr_
=
lrand48
();
mac_addr_
=
lrand48
();
mac_addr_
<<=
16
;
mac_addr_
<<=
16
;
mac_addr_
^=
lrand48
();
mac_addr_
^=
lrand48
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment