summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2024-07-17 17:56:50 +0000
committerFelix Fietkau2024-09-02 15:33:59 +0000
commit480551a3adc411cb506e516e9eb4485b0ec741cb (patch)
treef5544b88454d8c9082b297d7bd154a5113b255bc
parent68c8a4f94cd3cfd654a52cbc8b57c5c9d99640dd (diff)
interface: add support for disabling renew on topology change
In some cases this may trigger too many dhcp requests, tripping up upstream servers, so there needs to be an option to disable this behavior. Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--interface.c6
-rw-r--r--interface.h1
-rw-r--r--scripts/netifd-proto.sh1
3 files changed, 7 insertions, 1 deletions
diff --git a/interface.c b/interface.c
index 641bcdd..eb3bece 100644
--- a/interface.c
+++ b/interface.c
@@ -45,6 +45,7 @@ enum {
IFACE_ATTR_DNS,
IFACE_ATTR_DNS_SEARCH,
IFACE_ATTR_DNS_METRIC,
+ IFACE_ATTR_RENEW,
IFACE_ATTR_METRIC,
IFACE_ATTR_INTERFACE,
IFACE_ATTR_IP6ASSIGN,
@@ -73,6 +74,7 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = {
[IFACE_ATTR_PEERDNS] = { .name = "peerdns", .type = BLOBMSG_TYPE_BOOL },
[IFACE_ATTR_METRIC] = { .name = "metric", .type = BLOBMSG_TYPE_INT32 },
[IFACE_ATTR_DNS] = { .name = "dns", .type = BLOBMSG_TYPE_ARRAY },
+ [IFACE_ATTR_RENEW] = { .name = "renew", .type = BLOBMSG_TYPE_BOOL },
[IFACE_ATTR_DNS_SEARCH] = { .name = "dns_search", .type = BLOBMSG_TYPE_ARRAY },
[IFACE_ATTR_DNS_METRIC] = { .name = "dns_metric", .type = BLOBMSG_TYPE_INT32 },
[IFACE_ATTR_INTERFACE] = { .name = "interface", .type = BLOBMSG_TYPE_STRING },
@@ -452,7 +454,8 @@ interface_main_dev_cb(struct device_user *dep, enum device_event ev)
interface_set_link_state(iface, device_link_active(dep->dev));
break;
case DEV_EVENT_TOPO_CHANGE:
- interface_proto_event(iface->proto, PROTO_CMD_RENEW, false);
+ if (iface->renew)
+ interface_proto_event(iface->proto, PROTO_CMD_RENEW, false);
return;
default:
break;
@@ -850,6 +853,7 @@ interface_alloc(const char *name, struct blob_attr *config, bool dynamic)
force_link = true;
iface->autostart = blobmsg_get_bool_default(tb[IFACE_ATTR_AUTO], true);
+ iface->renew = blobmsg_get_bool_default(tb[IFACE_ATTR_RENEW], true);
iface->force_link = blobmsg_get_bool_default(tb[IFACE_ATTR_FORCE_LINK], force_link);
iface->dynamic = dynamic;
iface->proto_ip.no_defaultroute =
diff --git a/interface.h b/interface.h
index 9343ade..122864f 100644
--- a/interface.h
+++ b/interface.h
@@ -124,6 +124,7 @@ struct interface {
bool dynamic;
bool policy_rules_set;
bool link_up_event;
+ bool renew;
time_t start_time;
enum interface_state state;
diff --git a/scripts/netifd-proto.sh b/scripts/netifd-proto.sh
index 0785b9c..c25aa9f 100644
--- a/scripts/netifd-proto.sh
+++ b/scripts/netifd-proto.sh
@@ -23,6 +23,7 @@ proto_config_add_array() {
proto_config_add_defaults() {
proto_config_add_boolean "defaultroute"
proto_config_add_boolean "peerdns"
+ proto_config_add_boolean "renew"
proto_config_add_int "metric"
}