/* Reload thread */ static int reload_vrrp_thread(thread_t * thread) { /* set the reloading flag */ SET_RELOAD; /* Destroy master thread */ vrrp_dispatcher_release(vrrp_data); kernel_netlink_close(); thread_cleanup_master(master); #ifdef _HAVE_IPVS_SYNCD_ /* TODO - Note: this didn't work if we found ipvs_syndc on vrrp before on old_vrrp */ if (global_data->lvs_syncd_if) ipvs_syncd_cmd(IPVS_STOPDAEMON, NULL, (global_data->lvs_syncd_vrrp->state == VRRP_STATE_MAST) ? IPVS_MASTER: IPVS_BACKUP, global_data->lvs_syncd_syncid, false); #endif free_global_data(global_data); free_vrrp_buffer(); gratuitous_arp_close(); ndisc_close(); #ifdef _WITH_LVS_ if (vrrp_ipvs_needed()) { /* Clean ipvs related */ ipvs_stop(); } #endif /* Save previous conf data */ old_vrrp_data = vrrp_data; vrrp_data = NULL; reset_interface_queue(); /* Reload the conf */ #ifdef _DEBUG_ mem_allocated = 0; #endif start_vrrp(); #ifdef _HAVE_IPVS_SYNCD_ if (global_data->lvs_syncd_if) ipvs_syncd_cmd(IPVS_STARTDAEMON, NULL, (global_data->lvs_syncd_vrrp->state == VRRP_STATE_MAST) ? IPVS_MASTER: IPVS_BACKUP, global_data->lvs_syncd_syncid, false); #endif /* free backup data */ free_vrrp_data(old_vrrp_data); free_old_interface_queue(); UNSET_RELOAD; return 0; }
/* Reload thread */ int reload_vrrp_thread(thread * thread_obj) { /* set the reloading flag */ SET_RELOAD; SYS_VRRP_LOG_INFO("VRRP configure have been reload."); /* Close sockpool */ free_vrrp_sockpool(vrrp_data); /* Signal handling */ signal_reset(); signal_set(SIGHUP, sighup_vrrp, NULL); signal_set(SIGINT, sigend_vrrp, NULL); signal_set(SIGTERM, sigend_vrrp, NULL); signal_ignore(SIGPIPE); /* Destroy master thread */ thread_destroy_master(master); master = thread_make_master(); free_global_data(data); /* add by zhouben */ backup_if_queue(); kernel_netlink_close(); free_vrrp_buffer(); gratuitous_arp_close(); ndisc_close(); vrrp_trackip_close(); /* Save previous conf data */ old_vrrp_data = vrrp_data; vrrp_data = NULL; #ifdef _WITH_LVS_ /* Clean ipvs related */ //ipvs_stop(); #endif /* Reload the conf */ mem_allocated = 0; vrrp_signal_init(); signal_set(SIGCHLD, thread_child_handler, master); start_vrrp(); /* free backup data */ free_old_interface_queue_only(); free_vrrp_data(old_vrrp_data); UNSET_RELOAD; /*end of reload, store the state to file*/ reloading = 0; vrrp_state_store(); return 0; }
/* Daemon stop sequence */ static void stop_vrrp(void) { signal_handler_destroy(); if (!(debug & 8)) shutdown_vrrp_instances(); /* Clear static entries */ netlink_rtlist(vrrp_data->static_routes, IPROUTE_DEL); netlink_iplist(vrrp_data->static_addresses, IPADDRESS_DEL, NULL); #ifdef _WITH_SNMP_ if (snmp) vrrp_snmp_agent_close(); #endif /* Stop daemon */ pidfile_rm(vrrp_pidfile); #ifdef _WITH_LVS_ if (vrrp_ipvs_needed()) { /* Clean ipvs related */ ipvs_stop(); } #endif /* Clean data */ free_global_data(global_data); vrrp_dispatcher_release(vrrp_data); free_vrrp_data(vrrp_data); free_vrrp_buffer(); free_interface_queue(); kernel_netlink_close(); thread_destroy_master(master); gratuitous_arp_close(); ndisc_close(); #ifdef _DEBUG_ keepalived_free_final("VRRP Child process"); #endif /* * Reached when terminate signal catched. * finally return to parent process. */ closelog(); exit(0); }
/* Reload thread */ int reload_vrrp_thread(thread_t * thread) { /* set the reloading flag */ SET_RELOAD; /* Signal handling */ signal_handler_reset(); /* Destroy master thread */ vrrp_dispatcher_release(vrrp_data); kernel_netlink_close(); thread_destroy_master(master); master = thread_make_master(); free_global_data(global_data); free_interface_queue(); free_vrrp_buffer(); gratuitous_arp_close(); ndisc_close(); #ifdef _WITH_LVS_ if (vrrp_ipvs_needed()) { /* Clean ipvs related */ ipvs_stop(); } #endif /* Save previous conf data */ old_vrrp_data = vrrp_data; vrrp_data = NULL; /* Reload the conf */ #ifdef _DEBUG_ mem_allocated = 0; #endif vrrp_signal_init(); signal_set(SIGCHLD, thread_child_handler, master); start_vrrp(); /* free backup data */ free_vrrp_data(old_vrrp_data); UNSET_RELOAD; return 0; }
/* Daemon stop sequence */ static void stop_vrrp(void) { /* Destroy master thread */ signal_handler_destroy(); free_vrrp_sockpool(vrrp_data); thread_destroy_master(master); /* Clear static entries */ netlink_rtlist_ipv4(vrrp_data->static_routes, IPROUTE_DEL); netlink_iplist_ipv4(-1, vrrp_data->static_addresses, IPADDRESS_DEL); if (!(debug & 8)) shutdown_vrrp_instances(); free_interface_queue(); gratuitous_arp_close(); ndisc_close(); vrrp_trackip_close(); /* Stop daemon */ pidfile_rm(vrrp_pidfile); /* Clean data */ free_global_data(data); free_vrrp_data(vrrp_data); free_vrrp_buffer(); #ifdef _WITH_LVS_ /* Clean ipvs related */ //ipvs_stop(); #endif #ifdef _DEBUG_ keepalived_free_final("VRRP Child process"); #endif /* * Reached when terminate signal catched. * finally return to parent process. */ closelog(); exit(0); }
/* Reload thread */ int reload_vrrp_thread(thread_t * thread) { /* set the reloading flag */ SET_RELOAD; /* Close sockpool */ free_vrrp_sockpool(vrrp_data); /* Signal handling */ signal_reset(); signal_handler_destroy(); /* Destroy master thread */ thread_destroy_master(master); master = thread_make_master(); free_global_data(data); free_interface_queue(); free_vrrp_buffer(); gratuitous_arp_close(); ndisc_close(); /* Save previous conf data */ old_vrrp_data = vrrp_data; vrrp_data = NULL; #ifdef _WITH_LVS_ /* Clean ipvs related */ ipvs_stop(); #endif /* Reload the conf */ mem_allocated = 0; vrrp_signal_init(); signal_set(SIGCHLD, thread_child_handler, master); start_vrrp(); /* free backup data */ free_vrrp_data(old_vrrp_data); UNSET_RELOAD; return 0; }
/* Daemon stop sequence */ static void stop_vrrp(void) { /* Ensure any interfaces are in backup mode, * sending a priority 0 vrrp message */ restore_vrrp_interfaces(); #ifdef _HAVE_LIBIPTC_ iptables_fini(); #endif /* Clear static entries */ netlink_rtlist(vrrp_data->static_routes, IPROUTE_DEL); netlink_rulelist(vrrp_data->static_rules, IPRULE_DEL); netlink_iplist(vrrp_data->static_addresses, IPADDRESS_DEL); #ifdef _WITH_SNMP_ if (global_data->enable_snmp_keepalived || global_data->enable_snmp_rfc) vrrp_snmp_agent_close(); #endif /* Stop daemon */ pidfile_rm(vrrp_pidfile); #ifdef _WITH_LVS_ if (vrrp_ipvs_needed()) { /* Clean ipvs related */ ipvs_stop(); } #endif /* Clean data */ free_global_data(global_data); vrrp_dispatcher_release(vrrp_data); /* This is not nice, but it significantly increases the chances * of an IGMP leave group being sent for some reason. * Since we are about to exit, it doesn't affect anything else * running. */ sleep ( 1 ); if (!__test_bit(DONT_RELEASE_VRRP_BIT, &debug)) shutdown_vrrp_instances(); free_vrrp_data(vrrp_data); free_vrrp_buffer(); free_interface_queue(); kernel_netlink_close(); thread_destroy_master(master); gratuitous_arp_close(); ndisc_close(); signal_handler_destroy(); #ifdef _DEBUG_ keepalived_free_final("VRRP Child process"); #endif /* * Reached when terminate signal catched. * finally return to parent process. */ closelog(); exit(0); }