-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create: Static MAC optional #808
Conversation
tested at length today with @tschettervictor. with the -M it creates a static mac using the prefix, no -m the bridged do not have a static mac (ether) Ready to merge based on @michael-o 's testing and feedback |
Testing... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested. Previous behavior has been restored. Good! New behavior MAC generation needs improvement. See comment.
@michael-o The jib script does not respect the FreeBSD prefix. The MAC addresses it creates are just random it seems. Is that why you shared the link to the Bugzilla report? |
@@ -113,7 +113,7 @@ generate_static_mac() { | |||
local jail_name="${1}" | |||
local external_interface="${2}" | |||
local external_interface_mac="$(ifconfig ${external_interface} | grep ether | awk '{print $2}')" | |||
local macaddr_prefix="$(echo ${external_interface_mac} | cut -d':' -f1-3)" | |||
local macaddr_prefix="58:9c:fc" | |||
local macaddr_suffix="$(echo -n "${external_interface_mac}${jail_name}" | sed 's#:##g' | sha256 | cut -b -5 | sed 's/\([0-9a-fA-F][0-9a-fA-F]\)\([0-9a-fA-F][0-9a-fA-F]\)\([0-9a-fA-F]\)/\1:\2:\3/')" | |||
if [ -z "${macaddr_prefix}" ] || [ -z "${macaddr_suffix}" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is worth looking, synchronizing with vm-bhyve here: https://github.com/churchers/vm-bhyve/blob/dc92eeaae983bef284eaa920f1a1b2aed33b3767/lib/vm-run#L905-L934
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... that seems to random for me. I need something that will be random, but the same for each if+jailname combo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will have a look again tomorrow, As fas as I understand you want it to be reproducible, then you cannot you the time for that, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth looking at /usr/src/sys/net/ieee_oui.h
:
75 #define OUI_FREEBSD_GENERATED_MASK 0x10ffff
76 #define OUI_FREEBSD_GENERATED_LOW OUI_FREEBSD(0x100000)
77 #define OUI_FREEBSD_GENERATED_HIGH OUI_FREEBSD(OUI_FREEBSD_GENERATED_MASK)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would look at /usr/src/sys/net/if_ethersubr.c
: ether_gen_addr_byname(const char *nameunit, struct ether_addr *hwaddr)
. This is exactly what you are looking for.
Correct, the jib script does generate a local MAC address, but does not use the FreeBSD prefix, hence my bug report. |
So @michael-o are you saying that we should use the freebsd prefix all the time?? Just making sure I am clear on what you are saying. |
Yes, pretty much like vm-bhyve does when a static MAC is requested. |
This is now done. FreeBSD prefix will be the prefix. |
great @tschettervictor thanks So default behavior will be dynamic MAC as before and optional to have it static, all we agree on that? cc @bmac2 @JRGTH @cedwards |
yes that was what everyone wanted. |
Yes, looking into the PR again. |
@tschettervictor I think it would be wise to have a similiar logic (which we mostly have) to |
Is that from vm-bhyve? Not finding that function. EDIT: found it. Since we are doing simple "sh" I'm not sure how we would implement that. What we currently do so just sha265 the name, and use the last 5-6 digits. |
tested. Since @michael-o, myself, and @tschettervictor all tested this and Micheal is now good with the state of this, merging to return default behavior. |
As per @michael-o I have now modified creating and cloning jails to retain old behavior. It is now required to use "-M|--static-mac" to have a statically assigned MAC address to your jail. MAC will be based on 2 things.
If the jail has a statically assigned MAC, then cloning it will also assign a new static MAC to the cloned jail, otherwise, default behavior will persist.
To test this PR here are the steps both for a VNET and bridged-VNET jail.
VNET
Do the above with VNET jails, then do it with bridged VNET jails. These are the only 2 scenarios that this PR touches.
@yaazkal
@JRGTH
@bmac2