diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-10-23 22:24:42 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-10-24 14:20:42 +0900 |
commit | a227674cfb3bc90887b3085e6011103bfefcbf10 (patch) | |
tree | 2f074850fb7e54defc01faf5c779f9921d782f2c | |
parent | e272b62136e49f84307ce5b2e54568c88be9764d (diff) | |
download | systemd-a227674cfb3bc90887b3085e6011103bfefcbf10.tar.gz systemd-a227674cfb3bc90887b3085e6011103bfefcbf10.tar.bz2 systemd-a227674cfb3bc90887b3085e6011103bfefcbf10.zip |
networkctl: add reload command
-rw-r--r-- | man/networkctl.xml | 12 | ||||
-rw-r--r-- | src/network/networkctl.c | 24 |
2 files changed, 36 insertions, 0 deletions
diff --git a/man/networkctl.xml b/man/networkctl.xml index 14277a75f0..436dc12e46 100644 --- a/man/networkctl.xml +++ b/man/networkctl.xml @@ -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> diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 60d6a3f75f..5f90e49db0 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -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 }, {} }; |