-
Notifications
You must be signed in to change notification settings - Fork 216
Reimplement optional-addresses (LP: #1880029) #339
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,9 @@ typedef enum { | |
NETPLAN_OPTIONAL_DHCP4 = 1<<2, | ||
NETPLAN_OPTIONAL_DHCP6 = 1<<3, | ||
NETPLAN_OPTIONAL_STATIC = 1<<4, | ||
NETPLAN_OPTIONAL_IPV4 = 1<<5, | ||
NETPLAN_OPTIONAL_IPV6 = 1<<6, | ||
NETPLAN_OPTIONAL_NONE = 1<<7, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have the "none" case implicitly, if the bitfield == 0x0 |
||
} NetplanOptionalAddressFlag; | ||
|
||
/* Fields below are valid for dhcp4 and dhcp6 unless otherwise noted. */ | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -739,15 +739,12 @@ netplan_netdef_write_network_file( | |||||
is_optional = TRUE; | ||||||
} | ||||||
|
||||||
if (is_optional || def->optional_addresses) { | ||||||
if (is_optional) { | ||||||
g_string_append(link, "RequiredForOnline=no\n"); | ||||||
} | ||||||
for (unsigned i = 0; NETPLAN_OPTIONAL_ADDRESS_TYPES[i].name != NULL; ++i) { | ||||||
if (def->optional_addresses & NETPLAN_OPTIONAL_ADDRESS_TYPES[i].flag) { | ||||||
g_string_append_printf(link, "OptionalAddresses=%s\n", NETPLAN_OPTIONAL_ADDRESS_TYPES[i].name); | ||||||
} | ||||||
} | ||||||
if (is_optional) { | ||||||
g_string_append(link, "RequiredForOnline=no\n"); | ||||||
} | ||||||
Comment on lines
+742
to
+744
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ACK. This is the easiest case, and basically a shortcut for IPV4_LL + DHCP4 + STATIC4 + IPV6_RA/LL + DHCP6 + STATIC6. |
||||||
|
||||||
if (def->optional_addresses & NETPLAN_OPTIONAL_NONE) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
g_string_append(link, "RequiredFamilyForOnline=both\n"); | ||||||
} | ||||||
|
||||||
if (def->mtubytes) | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1530,6 +1530,10 @@ NETPLAN_OPTIONAL_ADDRESS_TYPES[] = { | |
{"dhcp4", NETPLAN_OPTIONAL_DHCP4}, | ||
{"dhcp6", NETPLAN_OPTIONAL_DHCP6}, | ||
{"static", NETPLAN_OPTIONAL_STATIC}, | ||
/* All above are deprecated */ | ||
{"ipv4", NETPLAN_OPTIONAL_IPV4}, | ||
{"ipv6", NETPLAN_OPTIONAL_IPV6}, | ||
{"none", NETPLAN_OPTIONAL_NONE}, | ||
{NULL}, | ||
}; | ||
|
||
|
@@ -1543,6 +1547,14 @@ handle_optional_addresses(NetplanParser* npp, yaml_node_t* node, const void* _, | |
|
||
for (unsigned i = 0; NETPLAN_OPTIONAL_ADDRESS_TYPES[i].name != NULL; ++i) { | ||
if (g_ascii_strcasecmp(scalar(entry), NETPLAN_OPTIONAL_ADDRESS_TYPES[i].name) == 0) { | ||
|
||
/* Values below NETPLAN_OPTIONAL_STATIC (including it) are not valid and | ||
* considered deprecated. See LP: #1880029 | ||
*/ | ||
if (NETPLAN_OPTIONAL_ADDRESS_TYPES[i].flag <= NETPLAN_OPTIONAL_STATIC) | ||
g_warning("Flag \"%s\" in optional-addresses is deprecated. Valid values are: " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't deprecate the original keywords, but rather try to get them implemented in the corresponding backend renderers. That is especially:
|
||
"\"ipv4\", \"ipv6\" and \"none\"\n", NETPLAN_OPTIONAL_ADDRESS_TYPES[i].name); | ||
|
||
npp->current.netdef->optional_addresses |= NETPLAN_OPTIONAL_ADDRESS_TYPES[i].flag; | ||
found = TRUE; | ||
break; | ||
|
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.
IMO we shouldn't introduce new IPV4 & IPv6 flags, but rather extend "_STATIC" to "_STATIC4" and "_STATIC6". But the "static4" and "static6" filters should just be internally and should not propagate to the YAML.
The "_IPv4" filter is then just a shortcut for IPV4_LL + DHCP4 + STATIC4.
The "_IPv6" filter is then just a shortcut for IPV6_RA (should this actually be called IPV6_LL?!) + DHCP6 + STATIC6.