diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-06-01 19:50:00 +1000 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-06-24 13:07:57 +0800 |
commit | 9f895134427d9a72be3d296e596c0360014a9753 (patch) | |
tree | 0e6be253452ed04940e41c22ceb5ac6466e6474b /discover/network.c | |
parent | c75acc64833eb7263b340079e7ba3153ebc60aec (diff) | |
download | talos-petitboot-9f895134427d9a72be3d296e596c0360014a9753.tar.gz talos-petitboot-9f895134427d9a72be3d296e596c0360014a9753.zip |
discover: bring network interfaces down in network_shutdown
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/network.c')
-rw-r--r-- | discover/network.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/discover/network.c b/discover/network.c index 4a4f932..23bf1ee 100644 --- a/discover/network.c +++ b/discover/network.c @@ -134,26 +134,42 @@ static int network_send_link_query(struct network *network) return 0; } -static int interface_up(struct network *network, struct interface *interface) +static int interface_change(struct network *network, + struct interface *interface, + bool up) { int rc; + const char *statestr = up ? "up" : "down"; const char *argv[] = { pb_system_apps.ip, "link", "set", interface->name, - "up", + statestr, NULL, }; rc = pb_run_cmd(argv, 1, network->dry_run); if (rc) { - pb_log("failed to bring interface %s up\n", interface->name); + pb_log("failed to bring interface %s %s\n", interface->name, + statestr); return -1; } return 0; } +static int interface_up(struct network *network, + struct interface *interface) +{ + return interface_change(network, interface, true); +} + +static int interface_down(struct network *network, + struct interface *interface) +{ + return interface_change(network, interface, false); +} + static void configure_interface_dhcp(struct network *network, struct interface *interface) { @@ -417,9 +433,14 @@ err: int network_shutdown(struct network *network) { + struct interface *interface; + if (network->waiter) waiter_remove(network->waiter); + list_for_each_entry(&network->interfaces, interface, list) + interface_down(network, interface); + close(network->netlink_sd); talloc_free(network); return 0; |