X-Git-Url: https://git.decadent.org.uk/gitweb/?p=odhcp6c.git;a=blobdiff_plain;f=src%2Fodhcp6c.c;h=b2c6b9815558f14c54aee130821f859e820588e9;hp=6da604728c4f330d446e10c5c0e941c6ce529d65;hb=9c409ef5ce654ed5dd3ce706317eaac718a22983;hpb=eb0b01e94374774609c31ab4508d8cfca8a400e1 diff --git a/src/odhcp6c.c b/src/odhcp6c.c index 6da6047..b2c6b98 100644 --- a/src/odhcp6c.c +++ b/src/odhcp6c.c @@ -192,7 +192,7 @@ int main(_unused int argc, char* const argv[]) while (do_signal != SIGTERM) { // Main logic odhcp6c_clear_state(STATE_SERVER_ID); - odhcp6c_clear_state(STATE_SERVER_CAND); + odhcp6c_clear_state(STATE_IA_NA); odhcp6c_clear_state(STATE_IA_PD); odhcp6c_clear_state(STATE_SNTP_IP); odhcp6c_clear_state(STATE_SNTP_FQDN); @@ -201,6 +201,15 @@ int main(_unused int argc, char* const argv[]) dhcpv6_set_ia_na_mode(ia_na_mode); bound = false; + // Server candidates need deep-delete + size_t cand_len; + struct dhcpv6_server_cand *cand = odhcp6c_get_state(STATE_SERVER_CAND, &cand_len); + for (size_t i = 0; i < cand_len / sizeof(*cand); ++i) { + free(cand[i].ia_na); + free(cand[i].ia_pd); + } + odhcp6c_clear_state(STATE_SERVER_CAND); + syslog(LOG_NOTICE, "(re)starting transaction on %s", ifname); do_signal = 0; @@ -366,10 +375,9 @@ bool odhcp6c_signal_process(void) { if (do_signal == SIGIO) { do_signal = 0; - bool ra_rtnled = ra_rtnl_process(); bool ra_updated = ra_process(); - if (ra_rtnled || (ra_updated && (bound || allow_slaac_only == 0))) + if (ra_updated && (bound || allow_slaac_only == 0)) script_call("ra-updated"); // Immediate process urgent events else if (ra_updated && !bound && allow_slaac_only > 0) script_delay_call("ra-updated", allow_slaac_only); @@ -405,6 +413,18 @@ size_t odhcp6c_remove_state(enum odhcp6c_state state, size_t offset, size_t len) } +void* odhcp6c_move_state(enum odhcp6c_state state, size_t *len) +{ + *len = state_len[state]; + void *data = state_data[state]; + + state_len[state] = 0; + state_data[state] = NULL; + + return data; +} + + void* odhcp6c_get_state(enum odhcp6c_state state, size_t *len) { *len = state_len[state];