mirror of
https://github.com/morgan9e/systemd
synced 2026-04-15 00:47:10 +09:00
resolved: add link_get_default_route helper
The dbus property getter for DefaultRoute does not simply check link->default_route. Instead, if l->default_route is not explicitly configured, it checks dns_scope_is_default_route(l->unicast_scope). Add a link_get_default_route() helper with this logic so that it can be used for consistency.
This commit is contained in:
@@ -26,6 +26,7 @@ static BUS_DEFINE_PROPERTY_GET(property_get_dnssec_supported, "b", Link, link_dn
|
||||
static BUS_DEFINE_PROPERTY_GET2(property_get_dnssec_mode, "s", Link, link_get_dnssec_mode, dnssec_mode_to_string);
|
||||
static BUS_DEFINE_PROPERTY_GET2(property_get_llmnr_support, "s", Link, link_get_llmnr_support, resolve_support_to_string);
|
||||
static BUS_DEFINE_PROPERTY_GET2(property_get_mdns_support, "s", Link, link_get_mdns_support, resolve_support_to_string);
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_default_route, "b", Link, link_get_default_route);
|
||||
|
||||
static int property_get_dns_over_tls_mode(
|
||||
sd_bus *bus,
|
||||
@@ -162,30 +163,6 @@ static int property_get_domains(
|
||||
return sd_bus_message_close_container(reply);
|
||||
}
|
||||
|
||||
static int property_get_default_route(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
Link *l = ASSERT_PTR(userdata);
|
||||
|
||||
assert(reply);
|
||||
|
||||
/* Return what is configured, if there's something configured */
|
||||
if (l->default_route >= 0)
|
||||
return sd_bus_message_append(reply, "b", l->default_route);
|
||||
|
||||
/* Otherwise report what is in effect */
|
||||
if (l->unicast_scope)
|
||||
return sd_bus_message_append(reply, "b", dns_scope_is_default_route(l->unicast_scope));
|
||||
|
||||
return sd_bus_message_append(reply, "b", false);
|
||||
}
|
||||
|
||||
static int property_get_scopes_mask(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "mkdir.h"
|
||||
#include "netif-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "resolved-dns-scope.h"
|
||||
#include "resolved-link.h"
|
||||
#include "resolved-llmnr.h"
|
||||
#include "resolved-mdns.h"
|
||||
@@ -834,6 +835,20 @@ ResolveSupport link_get_mdns_support(Link *link) {
|
||||
return MIN(link->mdns_support, link->manager->mdns_support);
|
||||
}
|
||||
|
||||
bool link_get_default_route(Link *l) {
|
||||
assert(l);
|
||||
|
||||
/* Return what is configured, if there's something configured */
|
||||
if (l->default_route >= 0)
|
||||
return l->default_route;
|
||||
|
||||
/* Otherwise report what is in effect */
|
||||
if (l->unicast_scope)
|
||||
return dns_scope_is_default_route(l->unicast_scope);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int link_address_new(Link *l,
|
||||
LinkAddress **ret,
|
||||
int family,
|
||||
|
||||
@@ -109,6 +109,8 @@ DnsOverTlsMode link_get_dns_over_tls_mode(Link *l);
|
||||
ResolveSupport link_get_llmnr_support(Link *link);
|
||||
ResolveSupport link_get_mdns_support(Link *link);
|
||||
|
||||
bool link_get_default_route(Link *l);
|
||||
|
||||
int link_save_user(Link *l);
|
||||
int link_load_user(Link *l);
|
||||
void link_remove_user(Link *l);
|
||||
|
||||
Reference in New Issue
Block a user