mirror of
https://github.com/systemd/systemd.git
synced 2024-11-27 04:03:36 +08:00
networkd: expose nsid via dbus
This commit is contained in:
parent
fa2bc6f1d7
commit
535252dc26
@ -87,6 +87,8 @@ node /org/freedesktop/network1 {
|
||||
readonly s OnlineState = '...';
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
||||
readonly t NamespaceId = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
|
||||
readonly u NamespaceNSID = ...;
|
||||
};
|
||||
interface org.freedesktop.DBus.Peer { ... };
|
||||
interface org.freedesktop.DBus.Introspectable { ... };
|
||||
@ -148,8 +150,6 @@ node /org/freedesktop/network1 {
|
||||
|
||||
<!--property OnlineState is not documented!-->
|
||||
|
||||
<!--property NamespaceId is not documented!-->
|
||||
|
||||
<!--Autogenerated cross-references for systemd.directives, do not edit-->
|
||||
|
||||
<variablelist class="dbus-interface" generated="True" extra-ref="org.freedesktop.network1.Manager"/>
|
||||
@ -212,11 +212,24 @@ node /org/freedesktop/network1 {
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="NamespaceId"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="NamespaceNSID"/>
|
||||
|
||||
<!--End of Autogenerated section-->
|
||||
|
||||
<para>
|
||||
Provides information about the manager.
|
||||
</para>
|
||||
|
||||
<refsect2>
|
||||
<title>Properties</title>
|
||||
|
||||
<para><varname>NamespaceId</varname> contains the inode number of the network namespace that the
|
||||
network service runs in. A client may compare this with the inode number of its own network namespace
|
||||
to verify whether the service manages the same network namespace.</para>
|
||||
|
||||
<para><varname>NamespaceNSID</varname> contains the "nsid" identifier the kernel maintains for the
|
||||
network namespace, if there's one assigned.</para>
|
||||
</refsect2>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
@ -584,5 +597,9 @@ $ gdbus introspect --system \
|
||||
<title>DHCPv6 Client Object</title>
|
||||
<para><varname>State</varname> was added in version 255.</para>
|
||||
</refsect2>
|
||||
<refsect2>
|
||||
<title>Manager Object</title>
|
||||
<para><varname>NamespaceNSID</varname> was added in version 256.</para>
|
||||
</refsect2>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -279,6 +279,31 @@ static int property_get_namespace_id(
|
||||
return sd_bus_message_append(reply, "t", id);
|
||||
}
|
||||
|
||||
static int property_get_namespace_nsid(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
uint32_t nsid = UINT32_MAX;
|
||||
int r;
|
||||
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
|
||||
/* Returns our own "nsid", which is another ID for the network namespace, different from the inode
|
||||
* number. */
|
||||
|
||||
r = netns_get_nsid(/* netnsfd= */ -EBADF, &nsid);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to query network nsid, ignoring: %m");
|
||||
|
||||
return sd_bus_message_append(reply, "u", nsid);
|
||||
}
|
||||
|
||||
static const sd_bus_vtable manager_vtable[] = {
|
||||
SD_BUS_VTABLE_START(0),
|
||||
|
||||
@ -289,6 +314,7 @@ static const sd_bus_vtable manager_vtable[] = {
|
||||
SD_BUS_PROPERTY("IPv6AddressState", "s", property_get_address_state, offsetof(Manager, ipv6_address_state), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("OnlineState", "s", property_get_online_state, offsetof(Manager, online_state), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("NamespaceId", "t", property_get_namespace_id, 0, SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("NamespaceNSID", "u", property_get_namespace_nsid, 0, 0),
|
||||
|
||||
SD_BUS_METHOD_WITH_ARGS("ListLinks",
|
||||
SD_BUS_NO_ARGS,
|
||||
|
Loading…
Reference in New Issue
Block a user