diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-11-27 22:37:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-27 22:37:22 +0100 |
commit | e849ae95243e54fac05990ffab5ff386a5a881ff (patch) | |
tree | 020ca8af3f48cf2d96b8587bef4ae7a81f4778a6 | |
parent | 94f760ec9d03737da8799739635b25d7ee6c637c (diff) | |
parent | 3476951cbb5ee5d015e86e645340e9310c84579e (diff) | |
download | systemd-e849ae95243e54fac05990ffab5ff386a5a881ff.tar.gz |
Merge pull request #10951 from thom311/network-dhcp-route-option
add accessor for sd_dhcp_route's "option"
-rw-r--r-- | src/libsystemd-network/sd-dhcp-lease.c | 6 | ||||
-rw-r--r-- | src/network/networkd-dhcp4.c | 13 | ||||
-rw-r--r-- | src/systemd/sd-dhcp-lease.h | 1 |
3 files changed, 15 insertions, 5 deletions
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c index a90c01d7db..c2455c7133 100644 --- a/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/libsystemd-network/sd-dhcp-lease.c @@ -1299,3 +1299,9 @@ int sd_dhcp_route_get_gateway(sd_dhcp_route *route, struct in_addr *gateway) { *gateway = route->gw_addr; return 0; } + +int sd_dhcp_route_get_option(sd_dhcp_route *route) { + assert_return(route, -EINVAL); + + return route->option; +} diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index 45b784d023..597791e02b 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -4,7 +4,6 @@ #include <linux/if.h> #include "alloc-util.h" -#include "dhcp-lease-internal.h" #include "hostname-util.h" #include "parse-util.h" #include "netdev/vrf.h" @@ -87,11 +86,14 @@ static int link_set_dhcp_routes(Link *link) { log_link_debug_errno(link, n, "DHCP error: could not get routes: %m"); for (i = 0; i < n; i++) { - if (static_routes[i]->option == SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE) + switch (sd_dhcp_route_get_option(static_routes[i])) { + case SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE: classless_route = true; - - if (static_routes[i]->option == SD_DHCP_OPTION_STATIC_ROUTE) + break; + case SD_DHCP_OPTION_STATIC_ROUTE: static_route = true; + break; + } } for (i = 0; i < n; i++) { @@ -99,7 +101,8 @@ static int link_set_dhcp_routes(Link *link) { /* if the DHCP server returns both a Classless Static Routes option and a Static Routes option, the DHCP client MUST ignore the Static Routes option. */ - if (classless_route && static_routes[i]->option == SD_DHCP_OPTION_STATIC_ROUTE) + if (classless_route && + sd_dhcp_route_get_option(static_routes[i]) != SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE) continue; r = route_new(&route); diff --git a/src/systemd/sd-dhcp-lease.h b/src/systemd/sd-dhcp-lease.h index 2a60145f5b..4875f10555 100644 --- a/src/systemd/sd-dhcp-lease.h +++ b/src/systemd/sd-dhcp-lease.h @@ -57,6 +57,7 @@ int sd_dhcp_lease_get_timezone(sd_dhcp_lease *lease, const char **timezone); int sd_dhcp_route_get_destination(sd_dhcp_route *route, struct in_addr *destination); int sd_dhcp_route_get_destination_prefix_length(sd_dhcp_route *route, uint8_t *length); int sd_dhcp_route_get_gateway(sd_dhcp_route *route, struct in_addr *gateway); +int sd_dhcp_route_get_option(sd_dhcp_route *route); _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_lease, sd_dhcp_lease_unref); |