>From 3ab6fc3a87c6782c324d0638da950efe35ca2194 Mon Sep 17 00:00:00 2001 From: Nathan Hintz <[email protected]> Date: Sun, 1 Dec 2013 11:15:46 -0800 Subject: [PATCH,v2 2/2] 6relayd: minimize interface updates
This is an attempt to prevent frequently triggering dnsmasq/firewall reload when only the validity timers have changed. This is necessary because it seems the state file is being used for multiple purposes: 1) to transfer address information to dnsmasq, and 2) to provide state information that is useful for debugging but not relevant to dnsmasq. Signed-off-by: Nathan Hintz <[email protected]> --- src/dhcpv6-ia.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c index f7b380d..2e37763 100644 --- a/src/dhcpv6-ia.c +++ b/src/dhcpv6-ia.c @@ -203,7 +203,7 @@ static int send_reconf(struct relayd_interface *iface, struct assignment *assign } -static void write_statefile(void) +static void write_statefile(bool address_change) { if (config->dhcpv6_statefile) { time_t now = monotonic_time(), wall_time = time(NULL); @@ -272,7 +272,7 @@ static void write_statefile(void) fclose(fp); } - if (config->dhcpv6_cb) { + if (address_change && config->dhcpv6_cb) { char *argv[2] = {config->dhcpv6_cb, NULL}; if (!vfork()) { execv(argv[0], argv); @@ -414,13 +414,16 @@ static void update(struct relayd_interface *iface) border->assigned = 1 << (64 - minprefix); bool change = len != (int)iface->pd_addr_len; + bool address_change = change; for (int i = 0; !change && i < len; ++i) if (addr[i].addr.s6_addr32[0] != iface->pd_addr[i].addr.s6_addr32[0] || addr[i].addr.s6_addr32[1] != iface->pd_addr[i].addr.s6_addr32[1] || - (addr[i].preferred> 0) != (iface->pd_addr[i].preferred> 0) || - (addr[i].valid> (uint32_t)now + 7200) != - (iface->pd_addr[i].valid> (uint32_t)now + 7200)) + (addr[i].preferred> 0) != (iface->pd_addr[i].preferred> 0)) { + change = address_change = true; + } else if ((addr[i].valid> (uint32_t)now + 7200) != + (iface->pd_addr[i].valid> (uint32_t)now + 7200)) { change = true; + } if (change) { struct assignment *c; @@ -467,7 +470,7 @@ static void update(struct relayd_interface *iface) } } - write_statefile(); + write_statefile(address_change); } } @@ -891,7 +894,7 @@ size_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct relayd_interface *if } if (update_state) - write_statefile(); + write_statefile(true); out: return response_len; -- 1.8.4.2 _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
