diff options
-rw-r--r-- | src/network/networkd-link-bus.c | 34 | ||||
-rw-r--r-- | src/network/networkd-link-bus.h | 1 | ||||
-rw-r--r-- | src/network/networkd-manager-bus.c | 5 |
3 files changed, 35 insertions, 5 deletions
diff --git a/src/network/networkd-link-bus.c b/src/network/networkd-link-bus.c index dec0d9be46..8b271f9693 100644 --- a/src/network/networkd-link-bus.c +++ b/src/network/networkd-link-bus.c @@ -114,7 +114,7 @@ int bus_link_method_set_ntp_servers(sd_bus_message *message, void *userdata, sd_ return sd_bus_reply_method_return(message, NULL); } -int bus_link_method_set_dns_servers(sd_bus_message *message, void *userdata, sd_bus_error *error) { +static int bus_link_method_set_dns_servers_internal(sd_bus_message *message, void *userdata, sd_bus_error *error, bool extended) { struct in_addr_full **dns = NULL; size_t allocated = 0, n = 0; Link *l = userdata; @@ -127,19 +127,21 @@ int bus_link_method_set_dns_servers(sd_bus_message *message, void *userdata, sd_ if (r < 0) return r; - r = sd_bus_message_enter_container(message, 'a', "(iay)"); + r = sd_bus_message_enter_container(message, 'a', extended ? "(iayqs)" : "(iay)"); if (r < 0) return r; for (;;) { + const char *server_name = NULL; union in_addr_union a; + uint16_t port = 0; + const void *d; int family; size_t sz; - const void *d; assert_cc(sizeof(int) == sizeof(int32_t)); - r = sd_bus_message_enter_container(message, 'r', "iay"); + r = sd_bus_message_enter_container(message, 'r', extended ? "iayqs" : "iay"); if (r < 0) goto finalize; if (r == 0) @@ -167,6 +169,19 @@ int bus_link_method_set_dns_servers(sd_bus_message *message, void *userdata, sd_ goto finalize; } + if (extended) { + r = sd_bus_message_read(message, "q", &port); + if (r < 0) + goto finalize; + + if (IN_SET(port, 53, 853)) + port = 0; + + r = sd_bus_message_read(message, "s", &server_name); + if (r < 0) + goto finalize; + } + r = sd_bus_message_exit_container(message); if (r < 0) goto finalize; @@ -177,7 +192,7 @@ int bus_link_method_set_dns_servers(sd_bus_message *message, void *userdata, sd_ } memcpy(&a, d, sz); - r = in_addr_full_new(family, &a, 0, 0, NULL, dns + n); + r = in_addr_full_new(family, &a, port, 0, server_name, dns + n); if (r < 0) goto finalize; @@ -218,6 +233,14 @@ finalize: return r; } +int bus_link_method_set_dns_servers(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return bus_link_method_set_dns_servers_internal(message, userdata, error, false); +} + +int bus_link_method_set_dns_servers_ex(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return bus_link_method_set_dns_servers_internal(message, userdata, error, true); +} + int bus_link_method_set_domains(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_(ordered_set_freep) OrderedSet *search_domains = NULL, *route_domains = NULL; Link *l = userdata; @@ -696,6 +719,7 @@ const sd_bus_vtable link_vtable[] = { SD_BUS_METHOD("SetNTP", "as", NULL, bus_link_method_set_ntp_servers, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("SetDNS", "a(iay)", NULL, bus_link_method_set_dns_servers, SD_BUS_VTABLE_UNPRIVILEGED), + SD_BUS_METHOD("SetDNSEx", "a(iayqs)", NULL, bus_link_method_set_dns_servers_ex, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("SetDomains", "a(sb)", NULL, bus_link_method_set_domains, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("SetDefaultRoute", "b", NULL, bus_link_method_set_default_route, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("SetLLMNR", "s", NULL, bus_link_method_set_llmnr, SD_BUS_VTABLE_UNPRIVILEGED), diff --git a/src/network/networkd-link-bus.h b/src/network/networkd-link-bus.h index afe0197dbd..94474f22ff 100644 --- a/src/network/networkd-link-bus.h +++ b/src/network/networkd-link-bus.h @@ -21,6 +21,7 @@ int property_get_address_state(sd_bus *bus, const char *path, const char *interf int bus_link_method_set_ntp_servers(sd_bus_message *message, void *userdata, sd_bus_error *error); int bus_link_method_set_dns_servers(sd_bus_message *message, void *userdata, sd_bus_error *error); +int bus_link_method_set_dns_servers_ex(sd_bus_message *message, void *userdata, sd_bus_error *error); int bus_link_method_set_domains(sd_bus_message *message, void *userdata, sd_bus_error *error); int bus_link_method_set_default_route(sd_bus_message *message, void *userdata, sd_bus_error *error); int bus_link_method_set_llmnr(sd_bus_message *message, void *userdata, sd_bus_error *error); diff --git a/src/network/networkd-manager-bus.c b/src/network/networkd-manager-bus.c index e956c5ed9a..355a932db2 100644 --- a/src/network/networkd-manager-bus.c +++ b/src/network/networkd-manager-bus.c @@ -151,6 +151,10 @@ static int bus_method_set_link_dns_servers(sd_bus_message *message, void *userda return call_link_method(userdata, message, bus_link_method_set_dns_servers, error); } +static int bus_method_set_link_dns_servers_ex(sd_bus_message *message, void *userdata, sd_bus_error *error) { + return call_link_method(userdata, message, bus_link_method_set_dns_servers_ex, error); +} + static int bus_method_set_link_domains(sd_bus_message *message, void *userdata, sd_bus_error *error) { return call_link_method(userdata, message, bus_link_method_set_domains, error); } @@ -243,6 +247,7 @@ const sd_bus_vtable manager_vtable[] = { SD_BUS_METHOD("GetLinkByIndex", "i", "so", method_get_link_by_index, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("SetLinkNTP", "ias", NULL, bus_method_set_link_ntp_servers, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("SetLinkDNS", "ia(iay)", NULL, bus_method_set_link_dns_servers, SD_BUS_VTABLE_UNPRIVILEGED), + SD_BUS_METHOD("SetLinkDNSEx", "ia(iayqs)", NULL, bus_method_set_link_dns_servers_ex, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("SetLinkDomains", "ia(sb)", NULL, bus_method_set_link_domains, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("SetLinkDefaultRoute", "ib", NULL, bus_method_set_link_default_route, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("SetLinkLLMNR", "is", NULL, bus_method_set_link_llmnr, SD_BUS_VTABLE_UNPRIVILEGED), |