systemd / systemd

The systemd System and Service Manager
https://systemd.io
GNU General Public License v2.0
13.29k stars 3.8k forks source link

Add more information to networkd's dbus API/networkctl json #20912

Closed LaserEyess closed 2 years ago

LaserEyess commented 3 years ago

Is your feature request related to a problem? Please describe. When querying dbus or networkctl --json for network information, there are certain network critical parameters that are missing. I believe this is done because these parameters are not really controlled by networkd, they are instead queried from netlink, so networkctl can parse them when called, but networkd does not pass them to dbus, and networkctl doesn't include them with its json output.

Compare networkctl status bond1

● 3: bond1                                                                            
                     Link File: /usr/lib/systemd/network/99-default.link
                  Network File: /etc/systemd/network/10-bond1.network
                          Type: bond
                         State: routable (configuring)
                  Online state: online                                                
                        Driver: bonding
                    HW Address: 8a:29:73:34:ec:d3
                           MTU: 1500 (min: 68, max: 65535)
                         QDisc: noqueue
  IPv6 Address Generation Mode: eui64
                          Mode: balance-xor
                        Miimon: 0
                       Updelay: 0
                     Downdelay: 0
          Queue Length (Tx/Rx): 16/16
              Auto negotiation: no
                         Speed: 1Gbps
                        Duplex: full
                       Address: 10.0.1.5
                                fe80::8829:73ff:fe34:ecd3
                       Gateway: 10.0.1.1
                           DNS: 10.0.1.1
                Search Domains: local.domain
                           NTP: 10.0.1.1
             Activation Policy: up
           Required For Online: yes
             DHCP6 Client DUID: DUID-EN/Vendor:0000ab11215228c20dd809350000

to networkctl --json=pretty status bond1

{
    "Index" : 3,
    "Name" : "bond1",
    "AlternativeNames" : [],
    "Type" : "bond",
    "Driver" : "bonding",
    "SetupState" : "configuring",
    "OperationalState" : "routable",
    "CarrierState" : "carrier",
    "AddressState" : "routable",
    "IPv4AddressState" : "routable",
    "IPv6AddressState" : "degraded",
    "OnlineState" : "online",
    "NetworkFile" : "/etc/systemd/network/10-bond1.network",
    "LinkFile" : "/usr/lib/systemd/network/99-default.link",
    "Path" : null,
    "Vendor" : null,
    "Model" : null
}

Some network critical things I see missing:

Some things that would be really nice and are also missing:

Other network tools with dbus APIs expose this information, see NetworkManager. They have all of the above information and more on their dbus API, including DNS information and NTP information. I know timesyncd and resolved expose NTP and DNS information as well, so I guess that isn't strictly necessary. But that means that for listening for changed properties it would require watching three signals instead of one. Not that difficult, but it opens the potential for race conditions which networkd-dispatcher has struggled with before.

Describe the solution you'd like Expose this information on the dbus API, so that they can be used by tools such as networkd-dispatcher or other similar scripts using networkd's dbus API.

Describe alternatives you've considered Currently what networkd-dispatcher does is shell out networkctl which requires manually parsing the output since the machine readable version doesn't contain this information. This is obviously less than ideal, and quite fragile.

Some other solutions:

The systemd version you checked that didn't have the feature you are asking for

systemd 249 (249.4-1-arch)
+PAM +AUDIT -SELINUX -APPARMOR -IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT -QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +XKBCOMMON +UTMP -SYSVINIT default-hierarchy=unified

I also briefly looked at the git log for src/network and didn't see anything relevant.

LaserEyess commented 2 years ago

With #21532 (and related fixes) and #21360 merged I consider this implemented. Thank you!