]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkctl: add reload command
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 23 Oct 2019 13:24:42 +0000 (22:24 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 24 Oct 2019 05:20:42 +0000 (14:20 +0900)
man/networkctl.xml
src/network/networkctl.c

index 14277a75f01ad48c632148758bf263df3c1d23c7..436dc12e4628939b393eaf9288eb1499f70a18d1 100644 (file)
@@ -261,6 +261,18 @@ s - Service VLAN, m - Two-port MAC Relay (TPMR)
         Takes interface name or index number.</para></listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term>
+          <command>reload</command>
+        </term>
+        <listitem><para>Reload <filename>.netdev</filename> and <filename>.network</filename> files.
+        If a new <filename>.netdev</filename> file is found, then the corresponding netdev is created.
+        Note that even if an existing <filename>.netdev</filename> is modified or removed,
+        <command>systemd-networkd</command> does not update or remove the netdev.
+        If a new, modified or removed <filename>.network</filename> file is found, then all interfaces
+        which match the file are reconfigured.</para></listitem>
+      </varlistentry>
+
     </variablelist>
   </refsect1>
 
index 60d6a3f75fad5248bf3ad395187272a5d19557fc..5f90e49db0467d2f1be72d42399179823aaec94a 100644 (file)
@@ -1815,6 +1815,28 @@ static int link_renew(int argc, char *argv[], void *userdata) {
 }
 
 
+static int verb_reload(int argc, char *argv[], void *userdata) {
+        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
+        _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
+        int r;
+
+        r = sd_bus_open_system(&bus);
+        if (r < 0)
+                return log_error_errno(r, "Failed to connect system bus: %m");
+
+        r = sd_bus_call_method(
+                        bus,
+                        "org.freedesktop.network1",
+                        "/org/freedesktop/network1",
+                        "org.freedesktop.network1.Manager",
+                        "Reload",
+                        &error, NULL, NULL);
+        if (r < 0)
+                return log_error_errno(r, "Failed to reload network settings: %m");
+
+        return 0;
+}
+
 static int help(void) {
         _cleanup_free_ char *link = NULL;
         int r;
@@ -1832,6 +1854,7 @@ static int help(void) {
                "  label                 Show current address label entries in the kernel\n"
                "  delete DEVICES...     Delete virtual netdevs\n"
                "  renew DEVICES...      Renew dynamic configurations\n"
+               "  reload                Reload .network and .netdev files\n"
                "\nOptions\n"
                "  -h --help             Show this help\n"
                "     --version          Show package version\n"
@@ -1917,6 +1940,7 @@ static int networkctl_main(int argc, char *argv[]) {
                 { "label",  VERB_ANY, VERB_ANY, 0,            list_address_labels },
                 { "delete", 2,        VERB_ANY, 0,            link_delete         },
                 { "renew",  2,        VERB_ANY, 0,            link_renew          },
+                { "reload", 1,        1,        0,            verb_reload         },
                 {}
         };