-
Notifications
You must be signed in to change notification settings - Fork 22
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
Generate unique MAC for bridges used for external networking #34
base: master
Are you sure you want to change the base?
Conversation
lib/charms/ovn_charm.py
Outdated
:raises: OSError | ||
""" | ||
with open('/etc/machine-id', 'r') as fin: | ||
return bytearray.fromhex(fin.read().rstrip()) |
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.
We need to hash this, ref [0]
0: https://www.freedesktop.org/software/systemd/man/machine-id.html
lib/charms/ovn_charm.py
Outdated
:rtype: str | ||
""" | ||
# initialize with 'fa:16:3e' prefix | ||
generated = bytearray.fromhex('fa163e') |
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.
This matches what is typically used for virtual machines etc. We should probably use a different prefix
lib/charms/ovn_charm.py
Outdated
# initialize with 'fa:16:3e' prefix | ||
generated = bytearray.fromhex('fa163e') | ||
# append last byte of bridge name | ||
generated.append(ord(bridge_name[-1:])) |
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.
This may easily collide, make this byte from some sort of checksum of the bridge name
When creating a bridge in Open vSwitch, a interface representing that bridge will appear in the system. Open vSwitch will use the lowest MAC address of the interfaces added to the bridge as MAC address of the bridge representor interface. Since the advent of predictable interface naming in Linux it has become common for network configuration renderers and backends to express network configuration in such a way that users will use the MAC address of an interface to match where a certain network config belongs. These two factors together creates a situation where the backend Netplan.io configures may choose to rename and use the Open vSwitch bridge representor interface and apply network config to it instead of using the real interface. To work around this issue we generate an unique MAC address for the bridges we add physical network interfaces to. Related-Bug: #1912643
:rtype: str | ||
""" | ||
# prefix from the IANA 64-bit MAC Unassigned range | ||
generated = bytearray.fromhex('b61d9e') |
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.
Need to review if this OUI makes sense to use, we also must make sure we set the unicast/multicast and universal/local bits correctly.
When creating a bridge in Open vSwitch, a interface representing
that bridge will appear in the system. Open vSwitch will use the
lowest MAC address of the interfaces added to the bridge as MAC
address of the bridge representor interface.
Since the advent of predictable interface naming in Linux it has
become common for network configuration renderers and backends
to express network configuration in such a way that users will
use the MAC address of an interface to match where a certain
network config belongs.
These two factors together creates a situation where the backend
Netplan.io configures may choose to rename and use the Open
vSwitch bridge representor interface and apply network config to
it instead of using the real interface.
To work around this issue we generate an unique MAC address for
the bridges we add physical network interfaces to.
Related-Bug: #1912643