X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=src%2Fodhcp6c.c;h=b2c6b9815558f14c54aee130821f859e820588e9;hb=9c409ef5ce654ed5dd3ce706317eaac718a22983;hp=df89eb9baeb68c050b620e3541cfd27eccb6d719;hpb=eaf3a11cad8a5dd389d5f52cc76e424e0242074b;p=odhcp6c.git diff --git a/src/odhcp6c.c b/src/odhcp6c.c index df89eb9..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]; @@ -439,6 +459,7 @@ void odhcp6c_update_entry_safe(enum odhcp6c_state state, struct odhcp6c_entry *n if (x) { x->valid = new->valid; x->preferred = new->preferred; + x->prefix_class = new->prefix_class; } else { odhcp6c_add_state(state, new, sizeof(*new)); }