-
Notifications
You must be signed in to change notification settings - Fork 201
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
Added pciid match support #375
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Fatih USTA <[email protected]>
Signed-off-by: Fatih USTA <[email protected]>
Signed-off-by: Fatih USTA <[email protected]>
Sorry, this is taking much longer than anticipated. I like the idea of having |
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.
My apologies, this PR fell through the cracks. I've now done an initial high-level round of review, as this is touching quite some core parts of Netplan and the original issue seems to be fixed as of recently (#503).
Please let me know if you're still interested in driving this forward, so I can do a more detailed review and talk to our architect about the new YAML schema.
@@ -125,7 +125,7 @@ NETPLAN_PUBLIC gboolean | |||
netplan_netdef_has_match(const NetplanNetDefinition* netdef); | |||
|
|||
NETPLAN_PUBLIC gboolean | |||
netplan_netdef_match_interface(const NetplanNetDefinition* netdef, const char* name, const char* mac, const char* driver_name); | |||
netplan_netdef_match_interface(const NetplanNetDefinition* netdef, const char* name, const char* mac, const char* driver_name, const char* pciid); |
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.
todo: We cannot just change public API like this, but would rather need to introduce a new netplan_netdef_match_interface2()
function. Keeping the original function backwards compatible.
@@ -249,6 +249,7 @@ struct netplan_net_definition { | |||
char* driver; | |||
char* mac; | |||
char* original_name; | |||
char* pciid; |
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.
todo: This has the potential of breaking ABI and we'd need to move the new field to the very end of the netplan_net_definition
struct, e.g. called match_pciid
.
- **pciid** (scalar) – since **0.107** | ||
|
||
> The PCI ID, corresponding to the `ID_PATH` udev properity. (`0000:98:00.1`) | ||
> Matching on pci id is *only* supported with networkd. | ||
> `udevadm info /sys/class/net/DEVICE_NAME` |
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.
nitpick (non-blocking): Version needs to be bumped.
question: Also, is there any possibility of doing the same for the NetworkManager backend? The match
stanza is a very central piece of Netplan's configuration and we should try not to diverge between the backends here.
@@ -857,6 +857,7 @@ static const mapping_entry_handler match_handlers[] = { | |||
{"driver", YAML_NO_NODE, {.variable=handle_match_driver}}, | |||
{"macaddress", YAML_SCALAR_NODE, {.generic=handle_netdef_mac}, netdef_offset(match.mac)}, | |||
{"name", YAML_SCALAR_NODE, {.generic=handle_netdef_id}, netdef_offset(match.original_name)}, | |||
{"pciid", YAML_SCALAR_NODE, {.generic=handle_netdef_str}, netdef_offset(match.pciid)}, |
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.
todo: We'd probably want to have a more specific handler here, that validates the input string is an actual PCI ID.
@@ -164,6 +164,27 @@ def test_eth_match_by_mac_rename(self): | |||
self.assert_nm(None) | |||
self.assert_nm_udev(NM_UNMANAGED % 'lom1' + NM_UNMANAGED_MAC % '11:22:33:44:55:66') | |||
|
|||
def test_eth_match_by_pciid_rename(self): |
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.
nitpick: Thanks for providing some test cases! I'd love to see an integration test along the lines of tests/integration/ethernets.py:test_rename_interfaces()
, too (if possible).
@@ -174,14 +174,42 @@ def get_interface_macaddress(interface): | |||
return link.get('addr', '') | |||
|
|||
|
|||
def get_interface_pciid(interface): # pragma: nocover (covered in autopkgtest) |
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.
question: Can we apply some test-mocking to get this net method covered by unit tests?
Description
Netplan doesn't match mac address of ethernet when using bond. So member ethernet doesn't up.
This PR fixes ethernet up problem, but still prints warning message(below).
I try to add PCI ID match support for better renaming to the ethernet.
Checklist
make check
successfully.make check-coverage
).Also may fixes this issue: https://bugs.launchpad.net/netplan/+bug/1608447