+/*
+ * netifd - network interface daemon
+ * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
#define _GNU_SOURCE
#include <string.h>
NOTIFY_ROUTES6,
NOTIFY_TUNNEL,
NOTIFY_DATA,
+ NOTIFY_KEEP,
__NOTIFY_LAST
};
[NOTIFY_ROUTES6] = { .name = "routes6", .type = BLOBMSG_TYPE_ARRAY },
[NOTIFY_TUNNEL] = { .name = "tunnel", .type = BLOBMSG_TYPE_TABLE },
[NOTIFY_DATA] = { .name = "data", .type = BLOBMSG_TYPE_TABLE },
+ [NOTIFY_KEEP] = { .name = "keep", .type = BLOBMSG_TYPE_BOOL },
};
static int
const char *devname;
int dev_create = 1;
bool addr_ext = false;
+ bool keep = false;
bool up;
if (!tb[NOTIFY_LINK_UP])
return 0;
}
+ if ((cur = tb[NOTIFY_KEEP]) != NULL)
+ keep = blobmsg_get_bool(cur);
+
if ((cur = tb[NOTIFY_ADDR_EXT]) != NULL) {
addr_ext = blobmsg_get_bool(cur);
if (addr_ext)
if (!tb[NOTIFY_IFNAME]) {
if (!iface->main_dev.dev)
return UBUS_STATUS_INVALID_ARGUMENT;
- } else {
+ } else if (!keep || iface->state != IFS_UP) {
+ keep = false;
devname = blobmsg_data(tb[NOTIFY_IFNAME]);
if (tb[NOTIFY_TUNNEL]) {
dev = proto_shell_create_tunnel(devname,
device_claim(&iface->l3_dev);
}
- interface_update_start(iface);
+ if (!keep)
+ interface_update_start(iface);
+
proto_apply_ip_settings(iface, data, addr_ext);
if ((cur = tb[NOTIFY_ROUTES]) != NULL)
interface_update_complete(state->proto.iface);
- state->proto.proto_event(&state->proto, IFPEV_UP);
+ if (!keep)
+ state->proto.proto_event(&state->proto, IFPEV_UP);
state->sm = S_IDLE;
if ((cur = tb[NOTIFY_DATA]))