diff --git a/man/org.freedesktop.network1.xml b/man/org.freedesktop.network1.xml
index 0b7a6b5ed3..1c3abcad23 100644
--- a/man/org.freedesktop.network1.xml
+++ b/man/org.freedesktop.network1.xml
@@ -458,6 +458,10 @@ node /org/freedesktop/network1/link/_1 {
interface org.freedesktop.network1.DHCPServer {
properties:
readonly a(uayayayayt) Leases = [...];
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
+ readonly u PoolSize = ...;
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
+ readonly u PoolOffset = ...;
};
interface org.freedesktop.DBus.Peer { ... };
interface org.freedesktop.DBus.Introspectable { ... };
@@ -466,8 +470,6 @@ node /org/freedesktop/network1/link/_1 {
};
-
-
@@ -480,10 +482,23 @@ node /org/freedesktop/network1/link/_1 {
+
+
+
+
- Provides information about leases.
+ Provides information about the DHCP server. The Leases property contains
+ the currently active leases. The PoolSize property contains the total number
+ of addresses in the dynamic address pool. The PoolOffset property contains
+ the offset from the subnet base address where the pool starts. These correspond to the
+ PoolSize= and PoolOffset= settings in
+ systemd.network5.
+ UINT32_MAX is used as a sentinel value for PoolSize
+ and PoolOffset to indicate that the information is unavailable (i.e. no
+ DHCP server is configured or the link is in relay mode), rather than a valid pool size or
+ offset.
@@ -589,6 +604,10 @@ $ gdbus introspect --system \
History
+
+ DHCP Server Object
+ PoolSize and PoolOffset were added in version 261.
+
DHCPv4 Client Object
State was added in version 255.
diff --git a/src/network/networkd-dhcp-server-bus.c b/src/network/networkd-dhcp-server-bus.c
index db2ee37f34..e5ee6d3f6d 100644
--- a/src/network/networkd-dhcp-server-bus.c
+++ b/src/network/networkd-dhcp-server-bus.c
@@ -74,6 +74,46 @@ static int property_get_leases(
return sd_bus_message_close_container(reply);
}
+static int property_get_pool_size(
+ 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);
+ sd_dhcp_server *s;
+ uint32_t v;
+
+ assert(reply);
+
+ s = l->dhcp_server;
+ v = s && !sd_dhcp_server_is_in_relay_mode(s) ? s->pool_size : UINT32_MAX;
+
+ return sd_bus_message_append_basic(reply, 'u', &v);
+}
+
+static int property_get_pool_offset(
+ 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);
+ sd_dhcp_server *s;
+ uint32_t v;
+
+ assert(reply);
+
+ s = l->dhcp_server;
+ v = s && !sd_dhcp_server_is_in_relay_mode(s) ? s->pool_offset : UINT32_MAX;
+
+ return sd_bus_message_append_basic(reply, 'u', &v);
+}
+
static int dhcp_server_emit_changed_strv(Link *link, char **properties) {
_cleanup_free_ char *path = NULL;
@@ -104,6 +144,8 @@ static const sd_bus_vtable dhcp_server_vtable[] = {
SD_BUS_VTABLE_START(0),
SD_BUS_PROPERTY("Leases", "a(uayayayayt)", property_get_leases, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
+ SD_BUS_PROPERTY("PoolSize", "u", property_get_pool_size, 0, SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("PoolOffset", "u", property_get_pool_offset, 0, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_VTABLE_END
};