diff options
author | Simon Chopin <87005181+schopin-pro@users.noreply.github.com> | 2021-07-26 15:54:21 +0200 |
---|---|---|
committer | Lukas Märdian <slyon@ubuntu.com> | 2021-08-04 13:39:20 +0200 |
commit | 38e2aed39b8294a475a921bd72a8b13ab122f980 (patch) | |
tree | 26a15e2c1d564b1e24505098e3a401ddac2d93f4 /src/networkd.c | |
parent | bae7df8f142678d1151ff926cccc9de3e1ca4bb5 (diff) |
Gateway fields deprecation and default routing support (FR-728) (LP: #1756590) (#216)
This patchset deprecates the gateway4/6 fields, advising the user to use a proper route instead. The rationale is that it groups all routing matters in the same place, making things more consistent. Along with this deprecation comes the support for the "default" keyword in the route to field, and an expansion of the gateway validation step to encompass all default routes.
Examples
```
network:
ethernets:
en1:
addresses:
- 1.2.3.4/8
- fc00:123:4567:89ab:cdef::1234/64
routes:
- to: default
via: 1.1.1.1
- to: default
via: "fc00:123:4567:89cb:cdef::1"
```
Addresses LP: #1756590
COMMITS:
* tests: split gateway4/6 into their own tests
* doc: add a paragraph regarding default routes
* netplan: deprecate gateway4/6
* tests: gw: add a multipass check
* parse: accept default routes as valid input
* validation: look at all routes for default route validation
This makes the default route validation much more comprehensive, looking
at all the routes. The underlying code is a bit more involved as a
result, though.
* networkd: support default route specification
* nm: support default route specification
* Rewording of error messages for consistency
Co-authored-by: Lukas Märdian <slyon@ubuntu.com>
* Whitespace fixes in string literals
Co-authored-by: Lukas Märdian <slyon@ubuntu.com>
* tests: add an integration test for default routes
* tests:integration:routing: not using DHCP in routes_default
Co-authored-by: Lukas Märdian <slyon@ubuntu.com>
Diffstat (limited to 'src/networkd.c')
-rw-r--r-- | src/networkd.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/networkd.c b/src/networkd.c index c51e949..8884286 100644 --- a/src/networkd.c +++ b/src/networkd.c @@ -422,9 +422,14 @@ write_netdev_file(const NetplanNetDefinition* def, const char* rootdir, const ch static void write_route(NetplanIPRoute* r, GString* s) { + const char *to; g_string_append_printf(s, "\n[Route]\n"); - g_string_append_printf(s, "Destination=%s\n", r->to); + if (g_strcmp0(r->to, "default") == 0) + to = get_global_network(r->family); + else + to = r->to; + g_string_append_printf(s, "Destination=%s\n", to); if (r->via) g_string_append_printf(s, "Gateway=%s\n", r->via); |