diff --git a/exec/Makefile b/exec/Makefile index 33ac0166..f35454ff 100644 --- a/exec/Makefile +++ b/exec/Makefile @@ -29,13 +29,13 @@ # THE POSSIBILITY OF SUCH DAMAGE. # Production mode flags -CFLAGS = -O3 -Wall -fomit-frame-pointer -LDFLAGS = -lpthread +#CFLAGS = -O3 -Wall -fomit-frame-pointer +#LDFLAGS = -lpthread # Debug mode flags -#CFLAGS = -g -Wall +CFLAGS = -g -Wall ##-DDEBUG -#LDFLAGS = -g -lpthread +LDFLAGS = -g -lpthread # Profile mode flags #CFLAGS = -O3 -pg @@ -45,8 +45,8 @@ LDFLAGS = -lpthread #CFLAGS = -ftest-coverage -fprofile-arcs #LDFLAGS = -g -TOTEM_SRC = aispoll.c totemnet.c totemrrp.c totemsrp.c totemmrp.c totempg.c totemconfig.c tlist.c hdb.c crypto.c wthread.c -TOTEM_OBJS = aispoll.o totemnet.o totemrrp.o totemsrp.o totemmrp.o totempg.o totemconfig.o tlist.o hdb.o crypto.o wthread.o +TOTEM_SRC = aispoll.c totemip.c totemnet.c totemrrp.c totemsrp.c totemmrp.c totempg.c totemconfig.c tlist.c hdb.c crypto.c wthread.c +TOTEM_OBJS = aispoll.o totemip.o totemnet.o totemrrp.o totemsrp.o totemmrp.o totempg.o totemconfig.o tlist.o hdb.o crypto.o wthread.o EXEC_SRC = main.c clm.c amf.c ckpt.c evt.c lck.c evs.c mainparse.c print.c mempool.c \ util.c sync.c @@ -92,6 +92,9 @@ totemsrp.o: totemsrp.c totemrrp.o: totemrrp.c $(CC) $(CFLAGS) -fPIC -c -o $@ $(*F).c +totemip.o: totemip.c + $(CC) $(CFLAGS) -fPIC -c -o $@ $(*F).c + totemnet.o: totemnet.c $(CC) $(CFLAGS) -fPIC -c -o $@ $(*F).c diff --git a/exec/amf.c b/exec/amf.c index 813d7e72..68afe898 100644 --- a/exec/amf.c +++ b/exec/amf.c @@ -237,9 +237,9 @@ static void amf_confchg_njoin ( static int amf_confchg_fn ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id); /*** @@ -252,19 +252,19 @@ static int amf_exec_init_fn (struct openais_config *); static int amf_init_two_fn (struct conn_info *conn_info); -static void amf_synchronize (void *message, struct in_addr source_addr); +static void amf_synchronize (void *message, struct totem_ip_address *source_addr); -static int message_handler_req_exec_amf_componentregister (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_amf_componentregister (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_amf_componentunregister (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_amf_componentunregister (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_amf_errorreport (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_amf_errorreport (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_amf_errorcancelall (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_amf_errorcancelall (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_amf_readinessstateset (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_amf_readinessstateset (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_amf_hastateset (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_amf_hastateset (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); static int message_handler_req_amf_componentregister (struct conn_info *conn_info, void *message); @@ -361,7 +361,7 @@ struct libais_handler amf_libais_handlers[] = } }; -int (*amf_aisexec_handler_fns[]) (void *, struct in_addr source_addr, int endian_conversion_required) = { +int (*amf_aisexec_handler_fns[]) (void *, struct totem_ip_address *source_addr, int endian_conversion_required) = { message_handler_req_exec_amf_componentregister, message_handler_req_exec_amf_componentunregister, message_handler_req_exec_amf_errorreport, @@ -521,7 +521,7 @@ static void component_unregister ( req_exec_amf_componentunregister.header.id = MESSAGE_REQ_EXEC_AMF_COMPONENTUNREGISTER; req_exec_amf_componentunregister.source.conn_info = 0; - req_exec_amf_componentunregister.source.in_addr.s_addr = 0; + req_exec_amf_componentunregister.source.addr.family = 0; memset (&req_exec_amf_componentunregister.req_lib_amf_componentunregister, 0, sizeof (struct req_lib_amf_componentunregister)); @@ -554,7 +554,7 @@ static void component_register ( req_exec_amf_componentregister.header.id = MESSAGE_REQ_EXEC_AMF_COMPONENTREGISTER; req_exec_amf_componentregister.source.conn_info = 0; - req_exec_amf_componentregister.source.in_addr.s_addr = 0; + req_exec_amf_componentregister.source.addr.family = 0; req_exec_amf_componentregister.currentReadinessState = component->currentReadinessState; req_exec_amf_componentregister.newReadinessState = component->newReadinessState; req_exec_amf_componentregister.currentHAState = component->currentHAState; @@ -1454,7 +1454,7 @@ void error_report ( req_exec_amf_errorreport.header.id = MESSAGE_REQ_EXEC_AMF_ERRORREPORT; req_exec_amf_errorreport.source.conn_info = 0; - req_exec_amf_errorreport.source.in_addr.s_addr = 0; + req_exec_amf_errorreport.source.addr.family = 0; memcpy (&req_exec_amf_errorreport.req_lib_amf_errorreport.erroneousComponent, &component->name, sizeof (SaNameT)); @@ -1870,7 +1870,7 @@ static int amf_exec_init_fn (struct openais_config *openais_config) void amf_confchg_njoin (struct saAmfComponent *component ,void *data) { - if (component->source_addr.s_addr != this_ip->sin_addr.s_addr) { + if (!totemip_equal(&component->source_addr, this_ip)) { return; } @@ -1880,13 +1880,13 @@ void amf_confchg_njoin (struct saAmfComponent *component ,void *data) void amf_confchg_nleave (struct saAmfComponent *component ,void *data) { - struct in_addr *source_addr = (struct in_addr *)data; + struct totem_ip_address *source_addr = (struct totem_ip_address *)data; struct saAmfUnit *unit; struct list_head *list; struct saAmfComponent *leave_component = NULL; enum amfDisabledUnlockedState disablestate = AMF_DISABLED_UNLOCKED_OUT_OF_SERVICE_COMPLETED; - if (component->source_addr.s_addr != source_addr->s_addr) { + if (!totemip_equal(&component->source_addr, source_addr)) { return; } @@ -1904,7 +1904,7 @@ void amf_confchg_nleave (struct saAmfComponent *component ,void *data) component = list_entry (list, struct saAmfComponent, saAmfComponentList); - if (component->source_addr.s_addr != source_addr->s_addr) { + if (!totemip_equal(&component->source_addr, source_addr)) { disablestate = AMF_DISABLED_UNLOCKED_FAILED; continue; } @@ -1917,7 +1917,7 @@ void amf_confchg_nleave (struct saAmfComponent *component ,void *data) component->currentReadinessState = SA_AMF_OUT_OF_SERVICE; component->newHAState = SA_AMF_QUIESCED; component->currentHAState = SA_AMF_QUIESCED; - component->source_addr.s_addr = 0; + component->source_addr.family = 0; leave_component = component; } @@ -1936,9 +1936,9 @@ void amf_confchg_nleave (struct saAmfComponent *component ,void *data) static int amf_confchg_fn ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id) { int i; @@ -1997,7 +1997,7 @@ int amf_exit_fn (struct conn_info *conn_info) return (0); } -static int message_handler_req_exec_amf_componentregister (void *message, struct in_addr source_addr, int endian_conversion_required) +static int message_handler_req_exec_amf_componentregister (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_amf_componentregister *req_exec_amf_componentregister = (struct req_exec_amf_componentregister *)message; struct res_lib_amf_componentregister res_lib_amf_componentregister; @@ -2018,7 +2018,7 @@ static int message_handler_req_exec_amf_componentregister (void *message, struct /* * If a node is joining menber ship ,Component States Synchronize */ - if (req_exec_amf_componentregister->source.in_addr.s_addr == 0) { + if (req_exec_amf_componentregister->source.addr.family == 0) { amf_synchronize (message, source_addr); return (0); } @@ -2057,7 +2057,7 @@ static int message_handler_req_exec_amf_componentregister (void *message, struct component->local = 0; component->registered = 1; component->conn_info = req_exec_amf_componentregister->source.conn_info; - component->source_addr = source_addr; + totemip_copy(&component->source_addr, source_addr); component->currentReadinessState = SA_AMF_OUT_OF_SERVICE; component->newReadinessState = SA_AMF_OUT_OF_SERVICE; component->currentHAState = 0; @@ -2104,7 +2104,7 @@ static int message_handler_req_exec_amf_componentregister (void *message, struct return (0); } -static void amf_synchronize (void *message, struct in_addr source_addr) +static void amf_synchronize (void *message, struct totem_ip_address *source_addr) { struct req_exec_amf_componentregister *req_exec_amf_componentregister = (struct req_exec_amf_componentregister *)message; struct saAmfComponent *component; @@ -2118,7 +2118,7 @@ static void amf_synchronize (void *message, struct in_addr source_addr) amfProxyComponent = findComponent (&req_exec_amf_componentregister->req_lib_amf_componentregister.proxyCompName); /* If this processor is component owner */ - if (component->source_addr.s_addr == this_ip->sin_addr.s_addr) { + if (totemip_equal(&component->source_addr, this_ip)) { /* No Operation */ return; @@ -2135,7 +2135,7 @@ static void amf_synchronize (void *message, struct in_addr source_addr) component->local = 0; component->registered = 1; component->conn_info = req_exec_amf_componentregister->source.conn_info; - component->source_addr = source_addr; + totemip_copy(&component->source_addr, source_addr); component->currentReadinessState = SA_AMF_OUT_OF_SERVICE; component->newReadinessState = SA_AMF_OUT_OF_SERVICE; component->currentHAState = SA_AMF_QUIESCED; @@ -2160,7 +2160,7 @@ static void amf_synchronize (void *message, struct in_addr source_addr) return; } -static int message_handler_req_exec_amf_componentunregister (void *message, struct in_addr source_addr, int endian_conversion_required) +static int message_handler_req_exec_amf_componentunregister (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_amf_componentunregister *req_exec_amf_componentunregister = (struct req_exec_amf_componentunregister *)message; struct res_lib_amf_componentunregister res_lib_amf_componentunregister; @@ -2228,7 +2228,7 @@ static int message_handler_req_exec_amf_componentunregister (void *message, stru return (0); } -static int message_handler_req_exec_amf_errorreport (void *message, struct in_addr source_addr, int endian_conversion_required) +static int message_handler_req_exec_amf_errorreport (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_amf_errorreport *req_exec_amf_errorreport = (struct req_exec_amf_errorreport *)message; struct res_lib_amf_errorreport res_lib_amf_errorreport; @@ -2269,7 +2269,7 @@ static int message_handler_req_exec_amf_errorreport (void *message, struct in_ad return (0); } -static int message_handler_req_exec_amf_errorcancelall (void *message, struct in_addr source_addr, int endian_conversion_required) +static int message_handler_req_exec_amf_errorcancelall (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_amf_errorcancelall *req_exec_amf_errorcancelall = (struct req_exec_amf_errorcancelall *)message; struct res_lib_amf_errorcancelall res_lib_amf_errorcancelall; @@ -2318,7 +2318,7 @@ static int message_handler_req_exec_amf_errorcancelall (void *message, struct in * node. That cluster node API has verified the readiness state, so its time to let * the rest of the cluster nodes know about the readiness state change. */ -static int message_handler_req_exec_amf_readinessstateset (void *message, struct in_addr source_addr, int endian_conversion_required) +static int message_handler_req_exec_amf_readinessstateset (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_amf_readinessstateset *req_exec_amf_readinessstateset = (struct req_exec_amf_readinessstateset *)message; struct saAmfComponent *component; @@ -2343,7 +2343,7 @@ static int message_handler_req_exec_amf_readinessstateset (void *message, struct * node. That cluster node API has verified the ha state, so its time to let * the rest of the cluster nodes know about the HA state change. */ -static int message_handler_req_exec_amf_hastateset (void *message, struct in_addr source_addr, int endian_conversion_required) +static int message_handler_req_exec_amf_hastateset (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_amf_hastateset *req_exec_amf_hastateset = (struct req_exec_amf_hastateset *)message; struct saAmfComponent *component; @@ -2849,7 +2849,7 @@ static void amf_dump_comp (struct saAmfComponent *component ,void *data) log_printf (level, "----------------\n" ); log_printf (level, "registered = %d\n" ,component->registered); log_printf (level, "local = %d\n" ,component->local ); - log_printf (level, "source_addr = %s\n" ,inet_ntoa (component->source_addr)); + log_printf (level, "source_addr = %s\n" ,totemip_print (&component->source_addr)); memset (name, 0 , sizeof(name)); memcpy (name, component->name.value, component->name.length); log_printf (level, "name = %s\n" ,name ); diff --git a/exec/ckpt.c b/exec/ckpt.c index 8169f63d..0695d0bb 100644 --- a/exec/ckpt.c +++ b/exec/ckpt.c @@ -91,31 +91,31 @@ static int ckpt_exit_fn (struct conn_info *conn_info); static int ckpt_init_two_fn (struct conn_info *conn_info); -static int message_handler_req_exec_ckpt_checkpointopen (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_ckpt_checkpointopen (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_ckpt_synchronize_state (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_ckpt_synchronize_state (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_ckpt_synchronize_section (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_ckpt_synchronize_section (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_ckpt_checkpointclose (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_ckpt_checkpointclose (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_ckpt_checkpointunlink (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_ckpt_checkpointunlink (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_ckpt_checkpointretentiondurationset (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_ckpt_checkpointretentiondurationset (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_ckpt_checkpointretentiondurationexpire (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_ckpt_checkpointretentiondurationexpire (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_ckpt_sectioncreate (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_ckpt_sectioncreate (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_ckpt_sectiondelete (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_ckpt_sectiondelete (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_ckpt_sectionexpirationtimeset (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_ckpt_sectionexpirationtimeset (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_ckpt_sectionwrite (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_ckpt_sectionwrite (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_ckpt_sectionoverwrite (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_ckpt_sectionoverwrite (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); -static int message_handler_req_exec_ckpt_sectionread (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_ckpt_sectionread (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); static int message_handler_req_lib_ckpt_checkpointopen (struct conn_info *conn_info, void *message); @@ -157,9 +157,9 @@ static void ckpt_recovery_initialize (void); static int ckpt_recovery_process (void); static void ckpt_recovery_finalize(); static void ckpt_recovery_abort(void); -static void ckpt_recovery_process_members_exit(struct in_addr *left_list, +static void ckpt_recovery_process_members_exit(struct totem_ip_address *left_list, int left_list_entries); -static void ckpt_replace_localhost_ip (struct in_addr *joined_list); +static void ckpt_replace_localhost_ip (struct totem_ip_address *joined_list); void checkpoint_release (struct saCkptCheckpoint *checkpoint); void timer_function_retention (void *data); @@ -189,9 +189,9 @@ static struct memb_ring_id saved_ring_id; static int ckpt_confchg_fn( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id); /* @@ -310,7 +310,7 @@ struct libais_handler ckpt_libais_handlers[] = }; -static int (*ckpt_aisexec_handler_fns[]) (void *msg, struct in_addr source_addr, int endian_conversion_required) = { +static int (*ckpt_aisexec_handler_fns[]) (void *msg, struct totem_ip_address *source_addr, int endian_conversion_required) = { message_handler_req_exec_ckpt_checkpointopen, message_handler_req_exec_ckpt_checkpointclose, message_handler_req_exec_ckpt_checkpointunlink, @@ -427,7 +427,7 @@ struct req_exec_ckpt_synchronize_state { SaNameT checkpointName; SaCkptCheckpointCreationAttributesT checkpointCreationAttributes; SaCkptSectionDescriptorT sectionDescriptor; - struct in_addr source_addr; + struct totem_ip_address *source_addr; struct ckpt_refcnt ckpt_refcount[PROCESSOR_COUNT_MAX]; }; @@ -443,25 +443,25 @@ struct req_exec_ckpt_synchronize_section { /* * Implementation */ -static int processor_index_set(struct in_addr *proc_addr, +static int processor_index_set(struct totem_ip_address *proc_addr, struct ckpt_refcnt *ckpt_refcount) { int i; for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) { - if (ckpt_refcount[i].addr.s_addr == 0) { + if (ckpt_refcount[i].addr.family == 0) { /* * If the source addresses do not match and this element * has no stored value then store the new value and * return the Index. */ - memcpy(&ckpt_refcount[i].addr, proc_addr, sizeof(struct in_addr)); + totemip_copy(&ckpt_refcount[i].addr, proc_addr); return i; } /* * If the source addresses match then this processor index * has already been set */ - else if (ckpt_refcount[i].addr.s_addr == proc_addr->s_addr) { + else if (totemip_equal(&ckpt_refcount[i].addr, proc_addr)) { return -1; } @@ -471,13 +471,13 @@ static int processor_index_set(struct in_addr *proc_addr, * to store the new Processor. */ for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) { - if (ckpt_refcount[i].addr.s_addr == 0) { + if (ckpt_refcount[i].addr.family == 0) { log_printf (LOG_LEVEL_ERROR,"Processor Set: Index %d has proc 0 and count 0\n", i); } else { log_printf (LOG_LEVEL_ERROR,"Processor Set: Index %d has proc %s and count %d\n", i, - inet_ntoa(ckpt_refcount[i].addr), + totemip_print(&ckpt_refcount[i].addr), ckpt_refcount[i].count); } } @@ -485,21 +485,21 @@ static int processor_index_set(struct in_addr *proc_addr, return -1; } -static int processor_add (struct in_addr *proc_addr, int count, struct ckpt_refcnt *ckpt_refcount) +static int processor_add (struct totem_ip_address *proc_addr, int count, struct ckpt_refcnt *ckpt_refcount) { int i; for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) { - if (ckpt_refcount[i].addr.s_addr == 0) { + if (ckpt_refcount[i].addr.family == 0) { log_printf (LOG_LEVEL_DEBUG,"processor_add found empty slot to insert new item\n"); - memcpy(&ckpt_refcount[i].addr, proc_addr, sizeof(struct in_addr)); + totemip_copy(&ckpt_refcount[i].addr, proc_addr); ckpt_refcount[i].count = count; return i; } /*Dont know how we missed this in the processor find but update this*/ - else if (ckpt_refcount[i].addr.s_addr == proc_addr->s_addr) { + else if (totemip_equal(&ckpt_refcount[i].addr, proc_addr)) { ckpt_refcount[i].count += count; log_printf (LOG_LEVEL_DEBUG,"processor_add for existent proc. ip %s, New count = %d\n", - inet_ntoa(ckpt_refcount[i].addr), + totemip_print(&ckpt_refcount[i].addr), ckpt_refcount[i].count); return i; @@ -511,13 +511,13 @@ static int processor_add (struct in_addr *proc_addr, int count, struct ckpt_refc */ log_printf (LOG_LEVEL_ERROR,"Processor Add Failed. Dumping Refcount Array\n"); for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) { - if (ckpt_refcount[i].addr.s_addr == 0) { + if (ckpt_refcount[i].addr.family == 0) { log_printf (LOG_LEVEL_ERROR,"Processor Add: Index %d has proc 0 and count 0\n", i); } else { log_printf (LOG_LEVEL_ERROR,"Processor Add: Index %d has proc %s and count %d\n", i, - inet_ntoa(ckpt_refcount[i].addr), + totemip_print(&ckpt_refcount[i].addr), ckpt_refcount[i].count); } } @@ -525,7 +525,7 @@ static int processor_add (struct in_addr *proc_addr, int count, struct ckpt_refc } -static int processor_index_find(struct in_addr *proc_addr, +static int processor_index_find(struct totem_ip_address *proc_addr, struct ckpt_refcnt *ckpt_refcount) { int i; @@ -534,7 +534,7 @@ static int processor_index_find(struct in_addr *proc_addr, * If the source addresses match then return the index */ - if (ckpt_refcount[i].addr.s_addr == proc_addr->s_addr) { + if (totemip_equal(&ckpt_refcount[i].addr, proc_addr)) { return i; } } @@ -564,13 +564,13 @@ static void merge_ckpt_refcounts(struct ckpt_refcnt *local, struct ckpt_refcnt * int index,i; for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) { - if (local[i].addr.s_addr == 0) { + if (local[i].addr.family == 0) { continue; } index = processor_index_find (&local[i].addr, network); if (index == -1) { /*Could Not Find the Local Entry in the remote.Add to it*/ log_printf (LOG_LEVEL_DEBUG,"calling processor_add for ip %s, count %d\n", - inet_ntoa(local[i].addr), + totemip_print(&local[i].addr), local[i].count); index = processor_add (&local[i].addr, local[i].count, network); if (index == -1) { @@ -589,7 +589,7 @@ static void merge_ckpt_refcounts(struct ckpt_refcnt *local, struct ckpt_refcnt * /*Found a match for this proc in the Network choose the larger of the 2.*/ network[index].count += local[i].count; log_printf (LOG_LEVEL_DEBUG,"setting count for %s = %d\n", - inet_ntoa(network[index].addr), + totemip_print(&network[index].addr), network[index].count); } } @@ -720,7 +720,7 @@ static int ckpt_recovery_process (void) memcpy(&request_exec_sync_state.sectionDescriptor, &ckptCheckpointSection->sectionDescriptor, sizeof(SaCkptSectionDescriptorT)); - memcpy(&request_exec_sync_state.source_addr, &this_ip->sin_addr, sizeof(struct in_addr)); + memcpy(&request_exec_sync_state.source_addr, &this_ip, sizeof(struct totem_ip_address)); memcpy(request_exec_sync_state.ckpt_refcount, checkpoint->ckpt_refcount, @@ -729,14 +729,14 @@ static int ckpt_recovery_process (void) log_printf (LOG_LEVEL_DEBUG, "CKPT: New Sync State Message Values\n"); for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) { - if (request_exec_sync_state.ckpt_refcount[i].addr.s_addr == 0) { + if (request_exec_sync_state.ckpt_refcount[i].addr.family == 0) { log_printf (LOG_LEVEL_DEBUG,"Index %d has proc 0 and count %d\n", i, request_exec_sync_state.ckpt_refcount[i].count); } else { log_printf (LOG_LEVEL_DEBUG,"Index %d has proc %s and count %d\n", i, - inet_ntoa(request_exec_sync_state.ckpt_refcount[i].addr), + totemip_print(&request_exec_sync_state.ckpt_refcount[i].addr), request_exec_sync_state.ckpt_refcount[i].count); } } @@ -966,15 +966,15 @@ static void ckpt_recovery_abort (void) return; } -static void ckpt_replace_localhost_ip (struct in_addr *joined_list) { +static void ckpt_replace_localhost_ip (struct totem_ip_address *joined_list) { struct list_head *checkpoint_list; struct saCkptCheckpoint *checkpoint; - struct in_addr local_ip; + struct totem_ip_address local_ip; int index; assert(joined_list); - local_ip.s_addr = inet_addr("127.0.0.1"); + totemip_localhost(AF_INET, &local_ip); for (checkpoint_list = checkpoint_list_head.next; checkpoint_list != &checkpoint_list_head; @@ -988,31 +988,31 @@ static void ckpt_replace_localhost_ip (struct in_addr *joined_list) { } memcpy(&checkpoint->ckpt_refcount[index].addr, joined_list, sizeof(struct in_addr)); log_printf (LOG_LEVEL_DEBUG, "Transitioning From Local Host replacing 127.0.0.1 with %s ...\n", - inet_ntoa(*joined_list)); + totemip_print(joined_list)); } process_localhost_transition = 0; } -static void ckpt_recovery_process_members_exit(struct in_addr *left_list, +static void ckpt_recovery_process_members_exit(struct totem_ip_address *left_list, int left_list_entries) { struct list_head *checkpoint_list; struct saCkptCheckpoint *checkpoint; - struct in_addr *member; - struct in_addr local_ip; + struct totem_ip_address *member; + struct totem_ip_address local_ip; int index; int i; - local_ip.s_addr = inet_addr("127.0.0.1"); + totemip_localhost(AF_INET, &local_ip); if (left_list_entries == 0) { return; } if ((left_list_entries == 1) && - (left_list->s_addr == local_ip.s_addr)) { + (totemip_equal(left_list, &local_ip))) { process_localhost_transition = 1; return; } @@ -1104,9 +1104,9 @@ void clean_checkpoint_list(struct list_head *head) static int ckpt_confchg_fn ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id) { @@ -1297,7 +1297,7 @@ static int ckpt_exec_init_fn (struct openais_config *openais_config) * Initialize the saved ring ID. */ saved_ring_id.seq = 0; - saved_ring_id.rep.s_addr = this_ip->sin_addr.s_addr; + totemip_copy(&saved_ring_id.rep, this_ip); #ifdef TODO int res; @@ -1348,7 +1348,7 @@ static int ckpt_exit_fn (struct conn_info *conn_info) return (0); } -static int message_handler_req_exec_ckpt_checkpointopen (void *message, struct in_addr source_addr, int endian_conversion_required) +static int message_handler_req_exec_ckpt_checkpointopen (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_ckpt_checkpointopen *req_exec_ckpt_checkpointopen = (struct req_exec_ckpt_checkpointopen *)message; struct req_lib_ckpt_checkpointopen *req_lib_ckpt_checkpointopen = (struct req_lib_ckpt_checkpointopen *)&req_exec_ckpt_checkpointopen->req_lib_ckpt_checkpointopen; @@ -1468,12 +1468,12 @@ static int message_handler_req_exec_ckpt_checkpointopen (void *message, struct i * */ - proc_index = processor_index_find(&source_addr,ckptCheckpoint->ckpt_refcount); + proc_index = processor_index_find(source_addr,ckptCheckpoint->ckpt_refcount); if (proc_index == -1) {/* Could not find, lets set the processor to an index.*/ - proc_index = processor_index_set(&source_addr,ckptCheckpoint->ckpt_refcount); + proc_index = processor_index_set(source_addr,ckptCheckpoint->ckpt_refcount); } if (proc_index != -1 ) { - ckptCheckpoint->ckpt_refcount[proc_index].addr = source_addr; + totemip_copy(&ckptCheckpoint->ckpt_refcount[proc_index].addr, source_addr); ckptCheckpoint->ckpt_refcount[proc_index].count++; } else { @@ -1552,14 +1552,14 @@ static int recovery_checkpoint_open(SaNameT *checkpointName, log_printf (LOG_LEVEL_DEBUG, "CKPT: recovery_checkpoint_open %s\n", &checkpointName->value); log_printf (LOG_LEVEL_DEBUG, "CKPT: recovery_checkpoint_open refcount Values\n"); for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) { - if (ref_cnt[i].addr.s_addr == 0) { + if (ref_cnt[i].addr.family == 0) { log_printf (LOG_LEVEL_DEBUG,"Index %d has proc 0 and count %d\n", i, ref_cnt[i].count); } else { log_printf (LOG_LEVEL_DEBUG,"Index %d has proc %s and count %d\n", i, - inet_ntoa(ref_cnt[i].addr), + totemip_print(&ref_cnt[i].addr), ref_cnt[i].count); } } @@ -1673,7 +1673,7 @@ error_exit: return (error); } -static int message_handler_req_exec_ckpt_synchronize_state (void *message, struct in_addr source_addr, int endian_conversion_required) +static int message_handler_req_exec_ckpt_synchronize_state (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { int retcode; struct req_exec_ckpt_synchronize_state *req_exec_ckpt_sync_state @@ -1707,7 +1707,7 @@ static int message_handler_req_exec_ckpt_synchronize_state (void *message, struc return (0); } -static int message_handler_req_exec_ckpt_synchronize_section (void *message, struct in_addr source_addr, int endian_conversion_required) +static int message_handler_req_exec_ckpt_synchronize_section (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { int retcode; struct req_exec_ckpt_synchronize_section *req_exec_ckpt_sync_section @@ -1823,7 +1823,7 @@ void timer_function_retention (void *data) assert (totempg_mcast (&iovec, 1, TOTEMPG_AGREED) == 0); } -extern int message_handler_req_exec_ckpt_checkpointclose (void *message, struct in_addr source_addr, int endian_conversion_required) +extern int message_handler_req_exec_ckpt_checkpointclose (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_ckpt_checkpointclose *req_exec_ckpt_checkpointclose = (struct req_exec_ckpt_checkpointclose *)message; struct res_lib_ckpt_checkpointclose res_lib_ckpt_checkpointclose; @@ -1845,7 +1845,7 @@ extern int message_handler_req_exec_ckpt_checkpointclose (void *message, struct * sent out later as a part of the sync process. */ - proc_index = processor_index_find(&source_addr, checkpoint->ckpt_refcount); + proc_index = processor_index_find(source_addr, checkpoint->ckpt_refcount); if (proc_index != -1 ) { checkpoint->ckpt_refcount[proc_index].count--; } @@ -1887,7 +1887,7 @@ error_exit: return (0); } -static int message_handler_req_exec_ckpt_checkpointunlink (void *message, struct in_addr source_addr, int endian_conversion_required) +static int message_handler_req_exec_ckpt_checkpointunlink (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_ckpt_checkpointunlink *req_exec_ckpt_checkpointunlink = (struct req_exec_ckpt_checkpointunlink *)message; @@ -1932,7 +1932,7 @@ error_exit: return (0); } -static int message_handler_req_exec_ckpt_checkpointretentiondurationset (void *message, struct in_addr source_addr, int endian_conversion_required) +static int message_handler_req_exec_ckpt_checkpointretentiondurationset (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_ckpt_checkpointretentiondurationset *req_exec_ckpt_checkpointretentiondurationset = (struct req_exec_ckpt_checkpointretentiondurationset *)message; struct res_lib_ckpt_checkpointretentiondurationset res_lib_ckpt_checkpointretentiondurationset; @@ -1975,7 +1975,7 @@ static int message_handler_req_exec_ckpt_checkpointretentiondurationset (void *m return (0); } -static int message_handler_req_exec_ckpt_checkpointretentiondurationexpire (void *message, struct in_addr source_addr, int endian_conversion_required) +static int message_handler_req_exec_ckpt_checkpointretentiondurationexpire (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_ckpt_checkpointretentiondurationexpire *req_exec_ckpt_checkpointretentiondurationexpire = (struct req_exec_ckpt_checkpointretentiondurationexpire *)message; struct req_exec_ckpt_checkpointunlink req_exec_ckpt_checkpointunlink; @@ -1992,7 +1992,7 @@ static int message_handler_req_exec_ckpt_checkpointretentiondurationexpire (void req_exec_ckpt_checkpointunlink.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK; req_exec_ckpt_checkpointunlink.source.conn_info = 0; - req_exec_ckpt_checkpointunlink.source.in_addr.s_addr = 0; + req_exec_ckpt_checkpointunlink.source.addr.family = 0; memcpy (&req_exec_ckpt_checkpointunlink.req_lib_ckpt_checkpointunlink.checkpointName, &req_exec_ckpt_checkpointretentiondurationexpire->checkpointName, @@ -2123,7 +2123,7 @@ error_exit: } -static int message_handler_req_exec_ckpt_sectioncreate (void *message, struct in_addr source_addr, int endian_conversion_required) { +static int message_handler_req_exec_ckpt_sectioncreate (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_ckpt_sectioncreate *req_exec_ckpt_sectioncreate = (struct req_exec_ckpt_sectioncreate *)message; struct req_lib_ckpt_sectioncreate *req_lib_ckpt_sectioncreate = (struct req_lib_ckpt_sectioncreate *)&req_exec_ckpt_sectioncreate->req_lib_ckpt_sectioncreate; struct res_lib_ckpt_sectioncreate res_lib_ckpt_sectioncreate; @@ -2262,7 +2262,7 @@ error_exit: return (0); } -static int message_handler_req_exec_ckpt_sectiondelete (void *message, struct in_addr source_addr, int endian_conversion_required) { +static int message_handler_req_exec_ckpt_sectiondelete (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_ckpt_sectiondelete *req_exec_ckpt_sectiondelete = (struct req_exec_ckpt_sectiondelete *)message; struct req_lib_ckpt_sectiondelete *req_lib_ckpt_sectiondelete = (struct req_lib_ckpt_sectiondelete *)&req_exec_ckpt_sectiondelete->req_lib_ckpt_sectiondelete; struct res_lib_ckpt_sectiondelete res_lib_ckpt_sectiondelete; @@ -2325,7 +2325,7 @@ error_exit: return (0); } -static int message_handler_req_exec_ckpt_sectionexpirationtimeset (void *message, struct in_addr source_addr, int endian_conversion_required) { +static int message_handler_req_exec_ckpt_sectionexpirationtimeset (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_ckpt_sectionexpirationtimeset *req_exec_ckpt_sectionexpirationtimeset = (struct req_exec_ckpt_sectionexpirationtimeset *)message; struct req_lib_ckpt_sectionexpirationtimeset *req_lib_ckpt_sectionexpirationtimeset = (struct req_lib_ckpt_sectionexpirationtimeset *)&req_exec_ckpt_sectionexpirationtimeset->req_lib_ckpt_sectionexpirationtimeset; struct res_lib_ckpt_sectionexpirationtimeset res_lib_ckpt_sectionexpirationtimeset; @@ -2458,7 +2458,7 @@ error_exit: } -static int message_handler_req_exec_ckpt_sectionwrite (void *message, struct in_addr source_addr, int endian_conversion_required) { +static int message_handler_req_exec_ckpt_sectionwrite (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_ckpt_sectionwrite *req_exec_ckpt_sectionwrite = (struct req_exec_ckpt_sectionwrite *)message; struct req_lib_ckpt_sectionwrite *req_lib_ckpt_sectionwrite = (struct req_lib_ckpt_sectionwrite *)&req_exec_ckpt_sectionwrite->req_lib_ckpt_sectionwrite; struct res_lib_ckpt_sectionwrite res_lib_ckpt_sectionwrite; @@ -2555,7 +2555,7 @@ error_exit: return (0); } -static int message_handler_req_exec_ckpt_sectionoverwrite (void *message, struct in_addr source_addr, int endian_conversion_required) { +static int message_handler_req_exec_ckpt_sectionoverwrite (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_ckpt_sectionoverwrite *req_exec_ckpt_sectionoverwrite = (struct req_exec_ckpt_sectionoverwrite *)message; struct req_lib_ckpt_sectionoverwrite *req_lib_ckpt_sectionoverwrite = (struct req_lib_ckpt_sectionoverwrite *)&req_exec_ckpt_sectionoverwrite->req_lib_ckpt_sectionoverwrite; struct res_lib_ckpt_sectionoverwrite res_lib_ckpt_sectionoverwrite; @@ -2631,7 +2631,7 @@ error_exit: } return (0); } -static int message_handler_req_exec_ckpt_sectionread (void *message, struct in_addr source_addr, int endian_conversion_required) { +static int message_handler_req_exec_ckpt_sectionread (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_ckpt_sectionread *req_exec_ckpt_sectionread = (struct req_exec_ckpt_sectionread *)message; struct req_lib_ckpt_sectionread *req_lib_ckpt_sectionread = (struct req_lib_ckpt_sectionread *)&req_exec_ckpt_sectionread->req_lib_ckpt_sectionread; struct res_lib_ckpt_sectionread res_lib_ckpt_sectionread; diff --git a/exec/ckpt.h b/exec/ckpt.h index c46ce40a..4a3d5cf5 100644 --- a/exec/ckpt.h +++ b/exec/ckpt.h @@ -41,7 +41,7 @@ struct ckpt_refcnt { int count; - struct in_addr addr; + struct totem_ip_address addr; }; struct saCkptCheckpointSection { diff --git a/exec/clm.c b/exec/clm.c index 2c76e8ec..53c155ac 100644 --- a/exec/clm.c +++ b/exec/clm.c @@ -81,16 +81,16 @@ static unsigned long long view_initial = 0; static DECLARE_LIST_INIT (library_notification_send_listhead); -SaClmClusterNodeT *clm_get_by_nodeid (struct in_addr node_id) +SaClmClusterNodeT *clm_get_by_nodeid (unsigned int node_id) { SaClmClusterNodeT *ret = NULL; int i; - if (node_id.s_addr == SA_CLM_LOCAL_NODE_ID) { + if (node_id == SA_CLM_LOCAL_NODE_ID) { return (&clusterNodes[0]); } for (i = 0; i < clusterNodeEntries; i++) { - if (clusterNodes[i].nodeId == node_id.s_addr) { + if (clusterNodes[i].nodeId == node_id) { ret = &clusterNodes[i]; break; } @@ -103,9 +103,9 @@ SaClmClusterNodeT *clm_get_by_nodeid (struct in_addr node_id) */ static int clm_confchg_fn ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id); static void clm_sync_init (void); @@ -122,7 +122,7 @@ static int clm_init_two_fn (struct conn_info *conn_info); static int clm_exit_fn (struct conn_info *conn_info); -static int message_handler_req_exec_clm_nodejoin (void *message, struct in_addr source_addr, +static int message_handler_req_exec_clm_nodejoin (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); static int message_handler_req_lib_clm_clustertrack (struct conn_info *conn_info, @@ -170,7 +170,7 @@ struct libais_handler clm_libais_handlers[] = } }; -static int (*clm_aisexec_handler_fns[]) (void *, struct in_addr source_addr, int endian_conversion_required) = { +static int (*clm_aisexec_handler_fns[]) (void *, struct totem_ip_address *source_addr, int endian_conversion_required) = { message_handler_req_exec_clm_nodejoin }; @@ -202,12 +202,21 @@ static int clm_exec_init_fn (struct openais_config *openais_config) /* * Build local cluster node data structure */ - thisClusterNode.nodeId = this_ip->sin_addr.s_addr; - sprintf ((char *)thisClusterNode.nodeAddress.value, "%s", inet_ntoa (this_ip->sin_addr)); + sprintf ((char *)thisClusterNode.nodeAddress.value, "%s", totemip_print (this_ip)); thisClusterNode.nodeAddress.length = strlen ((char *)thisClusterNode.nodeAddress.value); + if (this_ip->family == AF_INET) { thisClusterNode.nodeAddress.family = SA_CLM_AF_INET; - sprintf ((char *)thisClusterNode.nodeName.value, "%s", inet_ntoa (this_ip->sin_addr)); - thisClusterNode.nodeName.length = strlen ((char *)thisClusterNode.nodeName.value); + } else + if (this_ip->family == AF_INET6) { + thisClusterNode.nodeAddress.family = SA_CLM_AF_INET6; + } else { + assert (0); + } + + strcpy ((char *)thisClusterNode.nodeName.value, (char *)thisClusterNode.nodeAddress.value); + thisClusterNode.nodeName.length = thisClusterNode.nodeAddress.length; + thisClusterNode.nodeId = this_ip->nodeid; + printf ("setting B to %x\n", this_ip->nodeid); thisClusterNode.member = 1; { struct sysinfo s_info; @@ -384,9 +393,9 @@ static int clm_nodejoin_send (void) static int clm_confchg_fn ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id) { @@ -401,36 +410,42 @@ static int clm_confchg_fn ( log_printf (LOG_LEVEL_NOTICE, "CLM CONFIGURATION CHANGE\n"); log_printf (LOG_LEVEL_NOTICE, "New Configuration:\n"); for (i = 0; i < member_list_entries; i++) { - log_printf (LOG_LEVEL_NOTICE, "\t%s\n", inet_ntoa (member_list[i])); + log_printf (LOG_LEVEL_NOTICE, "\t%s\n", totemip_print (&member_list[i])); } log_printf (LOG_LEVEL_NOTICE, "Members Left:\n"); for (i = 0; i < left_list_entries; i++) { - log_printf (LOG_LEVEL_NOTICE, "\t%s\n", inet_ntoa (left_list[i])); + log_printf (LOG_LEVEL_NOTICE, "\t%s\n", totemip_print (&left_list[i])); } log_printf (LOG_LEVEL_NOTICE, "Members Joined:\n"); for (i = 0; i < joined_list_entries; i++) { - log_printf (LOG_LEVEL_NOTICE, "\t%s\n", inet_ntoa (joined_list[i])); + log_printf (LOG_LEVEL_NOTICE, "\t%s\n", totemip_print (&joined_list[i])); } for (i = 0; i < left_list_entries; i++) { - nodes[i] = left_list[i].s_addr; + nodes[i] = left_list[i].nodeid; } libraryNotificationLeave (nodes, i); + /* * Load the thisClusterNode data structure in case we are * transitioning to network interface up or down */ - thisClusterNode.nodeId = this_ip->sin_addr.s_addr; - strcpy ((char *)thisClusterNode.nodeName.value, (char *)inet_ntoa (this_ip->sin_addr)); - - sprintf ((char *)thisClusterNode.nodeAddress.value, "%s", inet_ntoa (this_ip->sin_addr)); + sprintf ((char *)thisClusterNode.nodeAddress.value, "%s", totemip_print (this_ip)); thisClusterNode.nodeAddress.length = strlen ((char *)thisClusterNode.nodeAddress.value); + if (this_ip->family == AF_INET) { thisClusterNode.nodeAddress.family = SA_CLM_AF_INET; - sprintf ((char *)thisClusterNode.nodeName.value, "%s", inet_ntoa (this_ip->sin_addr)); - thisClusterNode.nodeName.length = strlen ((char *)thisClusterNode.nodeName.value); - + } else + if (this_ip->family == AF_INET6) { + thisClusterNode.nodeAddress.family = SA_CLM_AF_INET6; + } else { + assert (0); + } + strcpy ((char *)thisClusterNode.nodeName.value, + (char *)thisClusterNode.nodeAddress.value); + thisClusterNode.nodeName.length = thisClusterNode.nodeAddress.length; + thisClusterNode.nodeId = this_ip->nodeid; return (0); } @@ -481,12 +496,12 @@ static void exec_clm_nodejoin_endian_conversion (struct req_exec_clm_nodejoin *i SA_MAX_NAME_LENGTH); } -static int message_handler_req_exec_clm_nodejoin (void *message, struct in_addr source_addr, +static int message_handler_req_exec_clm_nodejoin (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_clm_nodejoin *req_exec_clm_nodejoin = (struct req_exec_clm_nodejoin *)message; struct req_exec_clm_nodejoin req_exec_clm_nodejoin_storage; - int found; + int found = 0; int i; if (endian_conversion_required) { @@ -503,9 +518,7 @@ static int message_handler_req_exec_clm_nodejoin (void *message, struct in_addr * Determine if nodejoin already received */ for (found = 0, i = 0; i < clusterNodeEntries; i++) { - if (memcmp (&clusterNodes[i], &req_exec_clm_nodejoin->clusterNode, - sizeof (SaClmClusterNodeT)) == 0) { - + if (clusterNodes[i].nodeId == req_exec_clm_nodejoin->clusterNode.nodeId) { found = 1; } } diff --git a/exec/clm.h b/exec/clm.h index 0f6b0a21..0698cd63 100644 --- a/exec/clm.h +++ b/exec/clm.h @@ -45,7 +45,7 @@ struct libclm_ci { int tracking_enabled; }; -extern SaClmClusterNodeT *clm_get_by_nodeid (struct in_addr node_id); +extern SaClmClusterNodeT *clm_get_by_nodeid (unsigned int node_id); extern struct service_handler clm_service_handler; diff --git a/exec/evs.c b/exec/evs.c index 4c613a4e..7760ef8a 100644 --- a/exec/evs.c +++ b/exec/evs.c @@ -52,6 +52,7 @@ #include "../include/saAis.h" #include "../include/ipc_gen.h" +#include "totemip.h" #include "../include/ipc_evs.h" #include "../include/list.h" #include "../include/queue.h" @@ -73,14 +74,14 @@ static int evs_executive_initialize (struct openais_config *); static int evs_confchg_fn ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id); static int evs_init_two_fn (struct conn_info *conn_info); -static int message_handler_req_exec_mcast (void *message, struct in_addr source_addr, int endian_conversion_required); +static int message_handler_req_exec_mcast (void *message, struct totem_ip_address *source_addr, int endian_conversion_required); static int message_handler_req_evs_join (struct conn_info *conn_info, void *message); static int message_handler_req_evs_leave (struct conn_info *conn_info, void *message); @@ -124,7 +125,7 @@ struct libais_handler evs_libais_handlers[] = } }; -static int (*evs_aisexec_handler_fns[]) (void *, struct in_addr source_addr, int endian_conversion_required) = { +static int (*evs_aisexec_handler_fns[]) (void *, struct totem_ip_address *source_addr, int endian_conversion_required) = { message_handler_req_exec_mcast }; @@ -156,9 +157,9 @@ struct res_evs_confchg_callback res_evs_confchg_callback; static int evs_confchg_fn ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id) { @@ -174,15 +175,18 @@ static int evs_confchg_fn ( res_evs_confchg_callback.header.error = SA_OK; for (i = 0; i < member_list_entries; i++) { - res_evs_confchg_callback.member_list[i].s_addr = member_list[i].s_addr; + totemip_copy((struct totem_ip_address *)&res_evs_confchg_callback.member_list[i], + &member_list[i]); } res_evs_confchg_callback.member_list_entries = member_list_entries; for (i = 0; i < left_list_entries; i++) { - res_evs_confchg_callback.left_list[i].s_addr = left_list[i].s_addr; + totemip_copy((struct totem_ip_address *)&res_evs_confchg_callback.left_list[i], + &left_list[i]); } res_evs_confchg_callback.left_list_entries = left_list_entries; for (i = 0; i < joined_list_entries; i++) { - res_evs_confchg_callback.joined_list[i].s_addr = joined_list[i].s_addr; + totemip_copy((struct totem_ip_address *)&res_evs_confchg_callback.joined_list[i], + &joined_list[i]); } res_evs_confchg_callback.joined_list_entries = joined_list_entries; @@ -407,7 +411,8 @@ static int message_handler_req_evs_membership_get (struct conn_info *conn_info, res_lib_evs_membership_get.header.size = sizeof (struct res_lib_evs_membership_get); res_lib_evs_membership_get.header.id = MESSAGE_RES_EVS_MEMBERSHIP_GET; res_lib_evs_membership_get.header.error = EVS_OK; - res_lib_evs_membership_get.local_addr.s_addr = this_ip->sin_addr.s_addr; + totemip_copy((struct totem_ip_address *)&res_lib_evs_membership_get.local_addr, + this_ip); memcpy (&res_lib_evs_membership_get.member_list, &res_evs_confchg_callback.member_list, sizeof (res_lib_evs_membership_get.member_list)); @@ -421,7 +426,7 @@ static int message_handler_req_evs_membership_get (struct conn_info *conn_info, return (0); } -static int message_handler_req_exec_mcast (void *message, struct in_addr source_addr, int endian_conversion_required) +static int message_handler_req_exec_mcast (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_exec_evs_mcast *req_exec_evs_mcast = (struct req_exec_evs_mcast *)message; struct res_evs_deliver_callback res_evs_deliver_callback; @@ -460,7 +465,8 @@ static int message_handler_req_exec_mcast (void *message, struct in_addr source_ } if (found) { - res_evs_deliver_callback.source_addr.s_addr = source_addr.s_addr; + totemip_copy((struct totem_ip_address *)&res_evs_deliver_callback.evs_address, + source_addr); libais_send_response (conn_info, &res_evs_deliver_callback, sizeof (struct res_evs_deliver_callback)); libais_send_response (conn_info, msg_addr, diff --git a/exec/evt.c b/exec/evt.c index 27ccdd6c..2ace80c7 100644 --- a/exec/evt.c +++ b/exec/evt.c @@ -55,6 +55,7 @@ #include "aispoll.h" #include "mempool.h" #include "main.h" +#include "totemip.h" #include "totempg.h" #include "hdb.h" #include "clm.h" @@ -81,9 +82,9 @@ static int lib_evt_event_data_get(struct conn_info *conn_info, static int evt_conf_change( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id); static int evt_initialize(struct conn_info *conn_info); @@ -157,14 +158,14 @@ static struct libais_handler evt_libais_handlers[] = { }; -static int evt_remote_evt(void *msg, struct in_addr source_addr, +static int evt_remote_evt(void *msg, struct totem_ip_address *source_addr, int endian_conversion_required); -static int evt_remote_recovery_evt(void *msg, struct in_addr source_addr, +static int evt_remote_recovery_evt(void *msg, struct totem_ip_address *source_addr, int endian_conversion_required); -static int evt_remote_chan_op(void *msg, struct in_addr source_addr, +static int evt_remote_chan_op(void *msg, struct totem_ip_address *source_addr, int endian_conversion_required); -static int (*evt_exec_handler_fns[]) (void *m, struct in_addr s, +static int (*evt_exec_handler_fns[]) (void *m, struct totem_ip_address *s, int endian_conversion_required) = { evt_remote_evt, evt_remote_chan_op, @@ -286,15 +287,15 @@ static struct list_head *next_retained = 0; static struct list_head *next_chan = 0; static enum recovery_phases recovery_phase = evt_recovery_complete; static int left_member_count = 0; -static struct in_addr *left_member_list = 0; +static struct totem_ip_address *left_member_list = 0; static int joined_member_count = 0; -static struct in_addr *joined_member_list = 0; +static struct totem_ip_address *joined_member_list = 0; static int total_member_count = 0; -static struct in_addr *current_member_list = 0; +static struct totem_ip_address *current_member_list = 0; static int trans_member_count = 0; -static struct in_addr *trans_member_list = 0; +static struct totem_ip_address *trans_member_list = 0; static int add_count = 0; -static struct in_addr *add_list = 0; +static struct totem_ip_address *add_list = 0; static int processed_open_counts = 0; /* @@ -559,7 +560,7 @@ struct event_svr_channel_subscr { * mn_entry: List of all nodes. */ struct member_node_data { - struct in_addr mn_node_addr; + struct totem_ip_address mn_node_addr; SaClmClusterNodeT mn_node_info; SaEvtEventIdT mn_last_msg_id; SaClmNodeIdT mn_started; @@ -1170,19 +1171,19 @@ static SaErrorT evt_close_channel(SaNameT *cn, uint64_t unlink_id) #define NODE_HASH_SIZE 256 static struct member_node_data *nl[NODE_HASH_SIZE] = {0}; inline int -hash_sock_addr(struct in_addr addr) +hash_sock_addr(struct totem_ip_address *addr) { - return addr.s_addr & (NODE_HASH_SIZE - 1); + return addr->nodeid & (NODE_HASH_SIZE - 1); } -static struct member_node_data **lookup_node(struct in_addr addr) +static struct member_node_data **lookup_node(struct totem_ip_address *addr) { int index = hash_sock_addr(addr); struct member_node_data **nlp; nlp = &nl[index]; for (nlp = &nl[index]; *nlp; nlp = &((*nlp)->mn_next)) { - if ((*nlp)->mn_node_addr.s_addr == addr.s_addr) { + if (totemip_equal(&(*nlp)->mn_node_addr, addr)) { break; } } @@ -1191,7 +1192,7 @@ static struct member_node_data **lookup_node(struct in_addr addr) } static struct member_node_data * -evt_find_node(struct in_addr addr) +evt_find_node(struct totem_ip_address *addr) { struct member_node_data **nlp; @@ -1206,7 +1207,7 @@ evt_find_node(struct in_addr addr) } static SaErrorT -evt_add_node(struct in_addr addr, SaClmClusterNodeT *cn) +evt_add_node(struct totem_ip_address *addr, SaClmClusterNodeT *cn) { struct member_node_data **nlp; struct member_node_data *nl; @@ -1231,7 +1232,7 @@ evt_add_node(struct in_addr addr, SaClmClusterNodeT *cn) if (nl) { memset(nl, 0, sizeof(*nl)); err = SA_AIS_OK; - nl->mn_node_addr = addr; + totemip_copy(&nl->mn_node_addr, addr); nl->mn_started = 1; } list_init(&nl->mn_entry); @@ -1256,11 +1257,11 @@ static struct member_node_data* oldest_node() int i; for (i = 0; i < trans_member_count; i++) { - mn = evt_find_node(trans_member_list[i]); + mn = evt_find_node(&trans_member_list[i]); if (!mn || (mn->mn_started == 0)) { log_printf(LOG_LEVEL_ERROR, "Transitional config Node %s not active\n", - inet_ntoa(trans_member_list[i])); + totemip_print(&trans_member_list[i])); continue; } if ((oldest == NULL) || @@ -1285,7 +1286,7 @@ static struct member_node_data* oldest_node() * a new node. */ static int check_last_event(struct lib_event_data *evtpkt, - struct in_addr addr) + struct totem_ip_address *addr) { struct member_node_data *nd; SaClmClusterNodeT *cn; @@ -1296,7 +1297,7 @@ static int check_last_event(struct lib_event_data *evtpkt, log_printf(LOG_LEVEL_DEBUG, "Node ID 0x%x not found for event %llx\n", evtpkt->led_publisher_node_id, evtpkt->led_event_id); - cn = clm_get_by_nodeid(addr); + cn = clm_get_by_nodeid(addr->nodeid); if (!cn) { log_printf(LOG_LEVEL_DEBUG, "Cluster Node 0x%x not found for event %llx\n", @@ -1964,8 +1965,8 @@ static void retain_event(struct event_data *evt) "retention of event id 0x%llx failed\n", evt->ed_event.led_event_id); } else { - log_printf(RETENTION_TIME_DEBUG, "Retain event ID 0x%llx\n", - evt->ed_event.led_event_id); + log_printf(RETENTION_TIME_DEBUG, "Retain event ID 0x%llx for %u ms\n", + evt->ed_event.led_event_id, msec_in_future); } } @@ -2769,9 +2770,9 @@ static void remove_chan_open_info(SaClmNodeIdT node_id) */ static int evt_conf_change( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id) { log_printf(RECOVERY_DEBUG, "Evt conf change %d\n", @@ -2801,7 +2802,7 @@ static int evt_conf_change( } if (left_list_entries) { left_member_list = - malloc(sizeof(struct in_addr) * left_list_entries); + malloc(sizeof(struct totem_ip_address) * left_list_entries); if (!left_member_list) { /* * ERROR: No recovery. @@ -2811,7 +2812,7 @@ static int evt_conf_change( assert(0); } memcpy(left_member_list, left_list, - sizeof(struct in_addr) * left_list_entries); + sizeof(struct totem_ip_address) * left_list_entries); } if (trans_member_list) { @@ -2820,7 +2821,7 @@ static int evt_conf_change( } if (member_list_entries) { trans_member_list = - malloc(sizeof(struct in_addr) * member_list_entries); + malloc(sizeof(struct totem_ip_address) * member_list_entries); if (!trans_member_list) { /* @@ -2831,7 +2832,7 @@ static int evt_conf_change( assert(0); } memcpy(trans_member_list, member_list, - sizeof(struct in_addr) * member_list_entries); + sizeof(struct totem_ip_address) * member_list_entries); } } @@ -2846,7 +2847,7 @@ static int evt_conf_change( } if (joined_list_entries) { joined_member_list = - malloc(sizeof(struct in_addr) * joined_list_entries); + malloc(sizeof(struct totem_ip_address) * joined_list_entries); if (!joined_member_list) { /* * ERROR: No recovery. @@ -2856,7 +2857,7 @@ static int evt_conf_change( assert(0); } memcpy(joined_member_list, joined_list, - sizeof(struct in_addr) * joined_list_entries); + sizeof(struct totem_ip_address) * joined_list_entries); } @@ -2866,7 +2867,7 @@ static int evt_conf_change( } if (member_list_entries) { current_member_list = - malloc(sizeof(struct in_addr) * member_list_entries); + malloc(sizeof(struct totem_ip_address) * member_list_entries); if (!current_member_list) { /* @@ -2877,7 +2878,7 @@ static int evt_conf_change( assert(0); } memcpy(current_member_list, member_list, - sizeof(struct in_addr) * member_list_entries); + sizeof(struct totem_ip_address) * member_list_entries); } } @@ -3041,7 +3042,7 @@ try_deliver_event(struct event_data *evt, /* * Receive the network event message and distribute it to local subscribers */ -static int evt_remote_evt(void *msg, struct in_addr source_addr, +static int evt_remote_evt(void *msg, struct totem_ip_address *source_addr, int endian_conversion_required) { /* @@ -3057,19 +3058,19 @@ static int evt_remote_evt(void *msg, struct in_addr source_addr, SaClmClusterNodeT *cn; log_printf(LOG_LEVEL_DEBUG, "Remote event data received from %s\n", - inet_ntoa(source_addr)); + totemip_print(source_addr)); /* * See where the message came from so that we can set the * publishing node id in the message before delivery. */ - cn = clm_get_by_nodeid (source_addr); + cn = clm_get_by_nodeid (source_addr->nodeid); if (!cn) { /* * Not sure how this can happen... */ log_printf(LOG_LEVEL_DEBUG, "No cluster node data for %s\n", - inet_ntoa(source_addr)); + totemip_print(source_addr)); errno = ENXIO; return -1; } @@ -3081,7 +3082,7 @@ static int evt_remote_evt(void *msg, struct in_addr source_addr, } evtpkt->led_publisher_node_id = cn->nodeId; - evtpkt->led_in_addr = source_addr; + totemip_copy(&evtpkt->led_addr, source_addr); evtpkt->led_receive_time = clust_time_now(); if (evtpkt->led_chan_unlink_id != EVT_CHAN_ACTIVE) { @@ -3153,7 +3154,7 @@ inline SaTimeT calc_retention_time(SaTimeT retention, /* * Receive a recovery network event message and save it in the retained list */ -static int evt_remote_recovery_evt(void *msg, struct in_addr source_addr, +static int evt_remote_recovery_evt(void *msg, struct totem_ip_address *source_addr, int endian_conversion_required) { /* @@ -3174,7 +3175,7 @@ static int evt_remote_recovery_evt(void *msg, struct in_addr source_addr, log_printf(RECOVERY_EVENT_DEBUG, "Remote recovery event data received from %s\n", - inet_ntoa(source_addr)); + totemip_print(source_addr)); if (recovery_phase == evt_recovery_complete) { log_printf(RECOVERY_EVENT_DEBUG, @@ -3211,19 +3212,19 @@ static int evt_remote_recovery_evt(void *msg, struct in_addr source_addr, * If we haven't seen this event yet and it has remaining time, process * the event. */ - if (!check_last_event(evtpkt, evtpkt->led_in_addr) && + if (!check_last_event(evtpkt, &evtpkt->led_addr) && evtpkt->led_retention_time) { /* * See where the message came from so that we can set the * publishing node id in the message before delivery. */ - md = evt_find_node(evtpkt->led_in_addr); + md = evt_find_node(&evtpkt->led_addr); if (!md) { /* * Not sure how this can happen */ log_printf(LOG_LEVEL_NOTICE, "No node for %s\n", - inet_ntoa(evtpkt->led_in_addr)); + totemip_print(&evtpkt->led_addr)); errno = ENXIO; return -1; } @@ -3468,8 +3469,8 @@ convert_chan_packet(struct req_evt_chan_command *cpkt) break; case EVT_SET_ID_OP: - cpkt->u.chc_set_id.chc_addr.s_addr = - swab32(cpkt->u.chc_set_id.chc_addr.s_addr); + cpkt->u.chc_set_id.chc_nodeid = + swab32(cpkt->u.chc_set_id.chc_nodeid); cpkt->u.chc_set_id.chc_last_id = swab64(cpkt->u.chc_set_id.chc_last_id); break; @@ -3501,11 +3502,11 @@ convert_chan_packet(struct req_evt_chan_command *cpkt) * Used to communicate channel opens/closes, clear retention time, * config change updates... */ -static int evt_remote_chan_op(void *msg, struct in_addr source_addr, +static int evt_remote_chan_op(void *msg, struct totem_ip_address *source_addr, int endian_conversion_required) { struct req_evt_chan_command *cpkt = msg; - struct in_addr local_node = {SA_CLM_LOCAL_NODE_ID}; + unsigned int local_node = {SA_CLM_LOCAL_NODE_ID}; SaClmClusterNodeT *cn, *my_node; struct member_node_data *mn; struct event_svr_channel_instance *eci; @@ -3520,11 +3521,11 @@ static int evt_remote_chan_op(void *msg, struct in_addr source_addr, mn = evt_find_node(source_addr); if (mn == NULL) { - cn = clm_get_by_nodeid(source_addr); + cn = clm_get_by_nodeid(source_addr->nodeid); if (cn == NULL) { log_printf(LOG_LEVEL_WARNING, "Evt remote channel op: Node data for addr %s is NULL\n", - inet_ntoa(source_addr)); + totemip_print(source_addr)); return 0; } else { evt_add_node(source_addr, cn); @@ -3709,24 +3710,22 @@ static int evt_remote_chan_op(void *msg, struct in_addr source_addr, * start using an event ID that is unique. */ case EVT_SET_ID_OP: { - struct in_addr my_addr; int log_level = LOG_LEVEL_DEBUG; - my_addr.s_addr = my_node->nodeId; - if (cpkt->u.chc_set_id.chc_addr.s_addr == my_addr.s_addr) { + if (cpkt->u.chc_set_id.chc_nodeid == my_node->nodeId) { log_level = RECOVERY_DEBUG; } log_printf(log_level, "Received Set event ID OP from %s to %llx for %x my addr %x base %llx\n", - inet_ntoa(source_addr), + totemip_print(source_addr), cpkt->u.chc_set_id.chc_last_id, - cpkt->u.chc_set_id.chc_addr.s_addr, - my_addr.s_addr, + cpkt->u.chc_set_id.chc_nodeid, + my_node->nodeId, base_id); - if (cpkt->u.chc_set_id.chc_addr.s_addr == my_addr.s_addr) { + if (cpkt->u.chc_set_id.chc_nodeid == my_node->nodeId) { if (cpkt->u.chc_set_id.chc_last_id >= base_id) { log_printf(RECOVERY_DEBUG, "Set event ID from %s to %llx\n", - inet_ntoa(source_addr), cpkt->u.chc_set_id.chc_last_id); + totemip_print(source_addr), cpkt->u.chc_set_id.chc_last_id); base_id = cpkt->u.chc_set_id.chc_last_id + 1; } } @@ -3742,7 +3741,7 @@ static int evt_remote_chan_op(void *msg, struct in_addr source_addr, if (recovery_phase == evt_recovery_complete) { log_printf(LOG_LEVEL_ERROR, "Evt open count msg from %s, but not in membership change\n", - inet_ntoa(source_addr)); + totemip_print(source_addr)); } /* @@ -3786,15 +3785,15 @@ static int evt_remote_chan_op(void *msg, struct in_addr source_addr, if (recovery_phase == evt_recovery_complete) { log_printf(LOG_LEVEL_ERROR, "Evt config msg from %s, but not in membership change\n", - inet_ntoa(source_addr)); + totemip_print(source_addr)); } log_printf(RECOVERY_DEBUG, "Receive EVT_CONF_CHANGE_DONE from %s members %d checked in %d\n", - inet_ntoa(source_addr), total_member_count, checked_in+1); + totemip_print(source_addr), total_member_count, checked_in+1); if (!mn) { log_printf(RECOVERY_DEBUG, "NO NODE DATA AVAILABLE FOR %s\n", - inet_ntoa(source_addr)); + totemip_print(source_addr)); } if (++checked_in == total_member_count) { @@ -3825,7 +3824,7 @@ static int evt_remote_chan_op(void *msg, struct in_addr source_addr, case EVT_CONF_DONE: { log_printf(RECOVERY_DEBUG, "Receive EVT_CONF_DONE from %s, members %d checked in %d\n", - inet_ntoa(source_addr), + totemip_print(source_addr), total_member_count, checked_in+1); if (++checked_in == total_member_count) { /* @@ -3857,9 +3856,9 @@ static void evt_sync_init(void) { SaClmClusterNodeT *cn; struct member_node_data *md; - struct in_addr my_node = {SA_CLM_LOCAL_NODE_ID}; + unsigned int my_node = {SA_CLM_LOCAL_NODE_ID}; int left_list_entries = left_member_count; - struct in_addr *left_list = left_member_list; + struct totem_ip_address *left_list = left_member_list; log_printf(RECOVERY_DEBUG, "Evt synchronize initialization\n"); @@ -3877,17 +3876,17 @@ static void evt_sync_init(void) * account for nodes that left the membership */ while (left_list_entries--) { - md = evt_find_node(*left_list); + md = evt_find_node(left_list); if (md == 0) { log_printf(LOG_LEVEL_WARNING, "Can't find cluster node at %s\n", - inet_ntoa(left_list[0])); + totemip_print(&left_list[0])); /* * Mark this one as down. */ } else { log_printf(RECOVERY_DEBUG, "cluster node at %s down\n", - inet_ntoa(left_list[0])); + totemip_print(&left_list[0])); md->mn_started = 0; remove_chan_open_info(md->mn_node_info.nodeId); } @@ -3970,17 +3969,17 @@ static int evt_sync_process(void) * that we've seen from him. He will set his base ID for * generating event and message IDs to the highest one seen. */ - md = evt_find_node(*add_list); + md = evt_find_node(add_list); if (md != NULL) { log_printf(RECOVERY_DEBUG, "Send set evt ID %llx to %s\n", - md->mn_last_msg_id, inet_ntoa(*add_list)); + md->mn_last_msg_id, totemip_print(add_list)); md->mn_started = 1; memset(&cpkt, 0, sizeof(cpkt)); cpkt.chc_head.id = MESSAGE_REQ_EXEC_EVT_CHANCMD; cpkt.chc_head.size = sizeof(cpkt); cpkt.chc_op = EVT_SET_ID_OP; - cpkt.u.chc_set_id.chc_addr = *add_list; + cpkt.u.chc_set_id.chc_nodeid = add_list->nodeid; cpkt.u.chc_set_id.chc_last_id = md->mn_last_msg_id; chn_iovec.iov_base = &cpkt; chn_iovec.iov_len = cpkt.chc_head.size; @@ -3988,7 +3987,7 @@ static int evt_sync_process(void) if (res != 0) { log_printf(RECOVERY_DEBUG, "Unable to send event id to %s\n", - inet_ntoa(*add_list)); + totemip_print(add_list)); /* * We'll try again later. */ @@ -3999,17 +3998,17 @@ static int evt_sync_process(void) /* * Not seen before, add it to our list of nodes. */ - cn = clm_get_by_nodeid(*add_list); + cn = clm_get_by_nodeid(add_list->nodeid); if (!cn) { /* * Error: shouldn't happen */ log_printf(LOG_LEVEL_ERROR, "recovery error node: %s not found\n", - inet_ntoa(*add_list)); + totemip_print(add_list)); assert(0); } else { - evt_add_node(*add_list, cn); + evt_add_node(add_list, cn); } } diff --git a/exec/handlers.h b/exec/handlers.h index d3060000..0bf4a4dc 100644 --- a/exec/handlers.h +++ b/exec/handlers.h @@ -54,13 +54,13 @@ struct libais_handler { struct service_handler { struct libais_handler *libais_handlers; int libais_handlers_count; - int (**aisexec_handler_fns) (void *msg, struct in_addr source_addr, int endian_conversion_needed); + int (**aisexec_handler_fns) (void *msg, struct totem_ip_address *source_addr, int endian_conversion_needed); int aisexec_handler_fns_count; int (*confchg_fn) ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id); int (*libais_init_fn) (struct conn_info *conn_info, void *msg); int (*libais_init_two_fn) (struct conn_info *conn_info); diff --git a/exec/lck.c b/exec/lck.c index 784fb578..1b383fc7 100644 --- a/exec/lck.c +++ b/exec/lck.c @@ -518,8 +518,10 @@ static int lck_exec_init_fn (struct openais_config *openais_config) /* * Initialize the saved ring ID. */ +#ifdef TODO saved_ring_id.seq = 0; saved_ring_id.rep.s_addr = this_ip->sin_addr.s_addr; +#endif return (0); } diff --git a/exec/main.c b/exec/main.c index 53cefbbc..dda570b5 100644 --- a/exec/main.c +++ b/exec/main.c @@ -183,8 +183,8 @@ static void sigusr2_handler (int num) return; } -struct sockaddr_in *this_ip; -struct sockaddr_in this_non_loopback_ip; +struct totem_ip_address *this_ip; +struct totem_ip_address this_non_loopback_ip; #define LOCALHOST_IP inet_addr("127.0.0.1") char *socketname = "libais.socket"; @@ -787,7 +787,7 @@ static int pool_sizes[] = { 0, 0, 0, 0, 0, 4096, 0, 1, 0, /* 256 */ 1024, 0, 1, 4096, 0, 0, 0, 0, /* 65536 */ 1, 1, 1, 1, 1, 1, 1, 1, 1 }; -static int (*aisexec_handler_fns[AIS_SERVICE_HANDLER_AISEXEC_FUNCTIONS_MAX]) (void *msg, struct in_addr source_addr, int endian_conversion_required); +static int (*aisexec_handler_fns[AIS_SERVICE_HANDLER_AISEXEC_FUNCTIONS_MAX]) (void *msg, struct totem_ip_address *source_addr, int endian_conversion_required); static int aisexec_handler_fns_count = 1; /* @@ -838,7 +838,7 @@ void aisexec_sync_fns_build (void) char delivery_data[MESSAGE_SIZE_MAX]; static void deliver_fn ( - struct in_addr source_addr, + struct totem_ip_address *source_addr, struct iovec *iovec, int iov_len, int endian_conversion_required) @@ -876,15 +876,15 @@ static void deliver_fn ( static void confchg_fn ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id) { int i; - if (this_ip->sin_addr.s_addr != LOCALHOST_IP) { - memcpy(&this_non_loopback_ip, this_ip, sizeof(struct sockaddr_in)); + if (!totemip_localhost_check(this_ip)) { + totemip_copy(&this_non_loopback_ip, this_ip); } /* @@ -1047,8 +1047,8 @@ static void aisexec_mlockall (void) int message_source_is_local(struct message_source *source) { int ret = 0; - if ((source->in_addr.s_addr == LOCALHOST_IP) - ||(source->in_addr.s_addr == this_non_loopback_ip.sin_addr.s_addr)) { + if ((totemip_localhost_check(&source->addr) + ||(totemip_equal(&source->addr, &this_non_loopback_ip)))) { ret = 1; } return ret; @@ -1056,7 +1056,7 @@ int message_source_is_local(struct message_source *source) void message_source_set (struct message_source *source, struct conn_info *conn_info) { - source->in_addr.s_addr = this_ip->sin_addr.s_addr; + totemip_copy(&source->addr, this_ip); source->conn_info = conn_info; } @@ -1071,9 +1071,9 @@ int main (int argc, char **argv) char *error_string; struct openais_config openais_config; - memset(&this_non_loopback_ip, 0, sizeof(struct sockaddr_in)); + memset(&this_non_loopback_ip, 0, sizeof(struct totem_ip_address)); - this_non_loopback_ip.sin_addr.s_addr = LOCALHOST_IP; + totemip_localhost(AF_INET, &this_non_loopback_ip); aisexec_uid_determine (); diff --git a/exec/main.h b/exec/main.h index 9d6a4432..9ff9aeb8 100644 --- a/exec/main.h +++ b/exec/main.h @@ -146,7 +146,7 @@ enum nodeexec_message_types { MESSAGE_REQ_EXEC_LCK_LOCKPURGE = 30 }; -extern struct sockaddr_in *this_ip; +extern struct totem_ip_address *this_ip; poll_handle aisexec_poll_handle; diff --git a/exec/mainparse.h b/exec/mainparse.h index e8ece488..0e1b316c 100644 --- a/exec/mainparse.h +++ b/exec/mainparse.h @@ -147,7 +147,7 @@ struct saAmfComponent { int registered; int local; struct conn_info *conn_info; - struct in_addr source_addr; + struct totem_ip_address source_addr; SaNameT name; SaAmfReadinessStateT currentReadinessState; SaAmfReadinessStateT newReadinessState; diff --git a/exec/sync.c b/exec/sync.c index 001f9b2e..9b046b05 100644 --- a/exec/sync.c +++ b/exec/sync.c @@ -59,7 +59,7 @@ #define LOG_SERVICE LOG_SERVICE_SYNC struct barrier_data { - struct in_addr addr; + struct totem_ip_address addr; int completed; }; @@ -208,9 +208,9 @@ void sync_register ( void sync_confchg_fn ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id) { int i; @@ -228,7 +228,7 @@ void sync_confchg_fn ( sync_recovery_index = 0; memset (&barrier_data_confchg, 0, sizeof (barrier_data_confchg)); for (i = 0; i < member_list_entries; i++) { - barrier_data_confchg[i].addr.s_addr = member_list[i].s_addr; + totemip_copy(&barrier_data_confchg[i].addr, &member_list[i]); barrier_data_confchg[i].completed = 0; } memcpy (barrier_data_process, barrier_data_confchg, @@ -239,7 +239,7 @@ void sync_confchg_fn ( static struct memb_ring_id deliver_ring_id; -int sync_deliver_fn (void *msg, struct in_addr source_addr, +int sync_deliver_fn (void *msg, struct totem_ip_address *source_addr, int endian_conversion_needed) { struct req_exec_sync_barrier_start *req_exec_sync_barrier_start = @@ -265,7 +265,7 @@ int sync_deliver_fn (void *msg, struct in_addr source_addr, * Set completion for source_addr's address */ for (i = 0; i < barrier_data_confchg_entries; i++) { - if (source_addr.s_addr == barrier_data_process[i].addr.s_addr) { + if (totemip_equal(source_addr, &barrier_data_process[i].addr)) { barrier_data_process[i].completed = 1; break; } diff --git a/exec/sync.h b/exec/sync.h index 5a99964e..e4c51478 100644 --- a/exec/sync.h +++ b/exec/sync.h @@ -53,12 +53,12 @@ void sync_register (totemsrp_handle handle, void sync_confchg_fn ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id); -int sync_deliver_fn (void *msg, struct in_addr source_addr, +int sync_deliver_fn (void *msg, struct totem_ip_address *source_addr, int endian_conversion_needed); int sync_in_process (void); diff --git a/exec/totem.h b/exec/totem.h index 8c1bb7ba..54c4a535 100644 --- a/exec/totem.h +++ b/exec/totem.h @@ -33,9 +33,10 @@ */ #ifndef TOTEM_H_DEFINED #define TOTEM_H_DEFINED +#include "totemip.h" #define MESSAGE_SIZE_MAX 256000 -#define PROCESSOR_COUNT_MAX 16 +#define PROCESSOR_COUNT_MAX 32 #define FRAME_SIZE_MAX 9000 #define SEND_THREADS_MAX 16 @@ -60,8 +61,8 @@ enum { } totem_timeout_types; struct totem_interface { - struct sockaddr_in bindnet; - struct sockaddr_in boundto; + struct totem_ip_address bindnet; + struct totem_ip_address boundto; }; struct totem_logging_configuration { @@ -81,7 +82,9 @@ struct totem_config { */ struct totem_interface *interfaces; int interface_count; - struct sockaddr_in mcast_addr; + struct totem_ip_address mcast_addr; + uint16_t ip_port; + int node_id; /* * key information @@ -138,7 +141,7 @@ enum totem_callback_token_type { }; struct memb_ring_id { - struct in_addr rep; + struct totem_ip_address rep; unsigned long long seq; } __attribute__((packed)); diff --git a/exec/totemconfig.c b/exec/totemconfig.c index d92d0c47..22ba54d2 100644 --- a/exec/totemconfig.c +++ b/exec/totemconfig.c @@ -150,7 +150,6 @@ extern int totem_config_read ( memset (totem_config->interfaces, 0, sizeof (struct totem_interface) * interface_max); - totem_config->mcast_addr.sin_family = AF_INET; totem_config->secauth = 1; fp = fopen ("/etc/ais/openais.conf", "r"); @@ -215,14 +214,17 @@ extern int totem_config_read ( if ((loc = strstr_rs (line, "threads:"))) { totem_config->threads = atoi (loc); } else + if ((loc = strstr_rs (line, "nodeid:"))) { + res = totem_config->node_id = atoi (loc); + } else if ((loc = strstr_rs (line, "netmtu:"))) { totem_config->net_mtu = atoi (loc); } else if ((loc = strstr_rs (line, "mcastaddr:"))) { - res = inet_aton (loc, &totem_config->mcast_addr.sin_addr); + res = totemip_parse (&totem_config->mcast_addr, loc); } else if ((loc = strstr_rs (line, "mcastport:"))) { - res = totem_config->mcast_addr.sin_port = htons (atoi (loc)); + res = totem_config->ip_port = htons (atoi (loc)); } else if ((loc = strstr_rs (line, "bindnetaddr:"))) { if (interface_max == totem_config->interface_count) { @@ -231,8 +233,7 @@ extern int totem_config_read ( totem_config->interface_count); goto parse_error; } - res = inet_aton (loc, - &totem_config->interfaces[totem_config->interface_count].bindnet.sin_addr); + res = totemip_parse (&totem_config->interfaces[totem_config->interface_count].bindnet, loc); totem_config->interface_count += 1; } else if ((loc = strstr_rs (line, "token:"))) { @@ -305,16 +306,23 @@ int totem_config_validate ( /* * Some error checking of parsed data to make sure its valid */ - if (totem_config->mcast_addr.sin_addr.s_addr == 0) { + if ((int *)&totem_config->mcast_addr.addr == 0) { error_reason = "No multicast address specified"; goto parse_error; } - if (totem_config->mcast_addr.sin_port == 0) { + if (totem_config->ip_port == 0) { error_reason = "No multicast port specified"; goto parse_error; } + if (totem_config->mcast_addr.family == AF_INET6 && + totem_config->node_id == 0) { + + error_reason = "An IPV6 network requires that a node ID be specified."; + goto parse_error; + } + if (totem_config->interface_count == 0) { error_reason = "No bindnet specified"; goto parse_error; @@ -470,6 +478,7 @@ int totem_config_keyread ( { int fd; int res; + int i; if (totem_config->secauth == 0) { return (0); @@ -497,6 +506,16 @@ int totem_config_keyread ( res * 8, key_location); goto parse_error; } + if (totem_config->mcast_addr.family != totem_config->interfaces[0].bindnet.family) { + strcpy (error_string_response, "Multicast address family does not match bind address family"); + goto parse_error; + } + for (i = 0; i < totem_config->interface_count; i++) { + if (totem_config->mcast_addr.family != totem_config->interfaces[i].bindnet.family) { + strcpy (error_string_response, "Not all bind address belong to the same IP family"); + goto parse_error; + } + } return (0); parse_error: diff --git a/exec/totemip.c b/exec/totemip.c new file mode 100644 index 00000000..5df76aee --- /dev/null +++ b/exec/totemip.c @@ -0,0 +1,366 @@ +/* + * Copyright (c) 2005 Red Hat Inc + * + * All rights reserved. + * + * Author: Patrick Caulfield (pcaulfie@redhat.com) + * + * This software licensed under BSD license, the text of which follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the MontaVista Software, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* IPv4/6 abstraction */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* ARGH!! I hate netlink */ +#include +#include + +#include "totemip.h" + +#define LOCALHOST_IPV4 "127.0.0.1" +#define LOCALHOST_IPV6 "::1" + +#define NETLINK_BUFSIZE 16384 + +/* Compare two addresses */ +int totemip_equal(struct totem_ip_address *addr1, struct totem_ip_address *addr2) +{ + int addrlen = 0; + + if (addr1->family != addr2->family) + return 0; + + if (addr1->family == AF_INET) { + addrlen = sizeof(struct in_addr); + } + if (addr1->family == AF_INET6) { + addrlen = sizeof(struct in6_addr); + } + assert(addrlen); + + if (memcmp(addr1->addr, addr2->addr, addrlen) == 0) + return 1; + else + return 0; + +} + +/* Copy a totem_ip_address */ +void totemip_copy(struct totem_ip_address *addr1, struct totem_ip_address *addr2) +{ + memcpy(addr1, addr2, sizeof(struct totem_ip_address)); +} + +/* For sorting etc. params are void * for qsort's benefit */ +int totemip_compare(const void *a, const void *b) +{ + int i; + const struct totem_ip_address *addr1 = a; + const struct totem_ip_address *addr2 = b; + struct in6_addr *sin6a; + struct in6_addr *sin6b; + + if (addr1->family != addr2->family) + return (addr1->family > addr2->family); + + if (addr1->family == AF_INET) { + struct in_addr *in1 = (struct in_addr *)addr1->addr; + struct in_addr *in2 = (struct in_addr *)addr2->addr; + + /* A bit clunky but avoids sign problems */ + if (in1->s_addr == in2->s_addr) + return 0; + if (htonl(in1->s_addr) < htonl(in2->s_addr)) + return -1; + else + return +1; + } + + /* Compare IPv6 addresses */ + sin6a = (struct in6_addr *)addr1->addr; + sin6b = (struct in6_addr *)addr2->addr; + + /* Remember, addresses are in big-endian format. + We compare 16bits at a time rather than 32 to avoid sign problems */ + for (i = 0; i < 8; i++) { + int res = htons(sin6a->s6_addr16[i]) - + htons(sin6b->s6_addr16[i]); + if (res) { + return res; + } + } + return 0; +} + +/* Build a localhost totem_ip_address */ +int totemip_localhost(int family, struct totem_ip_address *localhost) +{ + char *addr_text; + + if (family == AF_INET) + addr_text = LOCALHOST_IPV4; + else + addr_text = LOCALHOST_IPV6; + + if (inet_pton(family, addr_text, (char *)localhost->addr) <= 0) + return -1; + + return 0; +} + +int totemip_localhost_check(struct totem_ip_address *addr) +{ + struct totem_ip_address localhost; + + if (totemip_localhost(addr->family, &localhost)) + return 0; + return totemip_equal(addr, &localhost); +} + +const char *totemip_print(struct totem_ip_address *addr) +{ + static char buf[INET6_ADDRSTRLEN]; + + return inet_ntop(addr->family, addr->addr, buf, sizeof(buf)); +} + +/* Make a totem_ip_address into a usable sockaddr_storage */ +int totemip_totemip_to_sockaddr_convert(struct totem_ip_address *ip_addr, + uint16_t port, struct sockaddr_storage *saddr, int *addrlen) +{ + int ret = -1; + + if (ip_addr->family == AF_INET) { + struct sockaddr_in *sin = (struct sockaddr_in *)saddr; + + memset(sin, 0, sizeof(struct sockaddr_in)); + sin->sin_family = ip_addr->family; + sin->sin_port = port; + memcpy(&sin->sin_addr, ip_addr->addr, sizeof(struct in_addr)); + + *addrlen = sizeof(struct sockaddr_in); + ret = 0; + } + + if (ip_addr->family == AF_INET6) { + struct sockaddr_in6 *sin = (struct sockaddr_in6 *)saddr; + + memset(sin, 0, sizeof(struct sockaddr_in6)); + sin->sin6_family = ip_addr->family; + sin->sin6_port = port; + sin->sin6_scope_id = 2; + memcpy(&sin->sin6_addr, ip_addr->addr, sizeof(struct in6_addr)); + + *addrlen = sizeof(struct sockaddr_in6); + ret = 0; + } + + return ret; +} + +/* Converts an address string string into a totem_ip_address */ +int totemip_parse(struct totem_ip_address *totemip, char *addr) +{ + struct addrinfo *ainfo; + struct addrinfo ahints; + struct sockaddr_in *sa; + struct sockaddr_in6 *sa6; + int ret; + + memset(&ahints, 0, sizeof(ahints)); + ahints.ai_socktype = SOCK_DGRAM; + ahints.ai_protocol = IPPROTO_UDP; + + /* Lookup the nodename address */ + ret = getaddrinfo(addr, NULL, &ahints, &ainfo); + if (ret) + return -errno; + + sa = (struct sockaddr_in *)ainfo->ai_addr; + sa6 = (struct sockaddr_in6 *)ainfo->ai_addr; + totemip->family = ainfo->ai_family; + + if (ainfo->ai_family == AF_INET) + memcpy(totemip->addr, &sa->sin_addr, sizeof(struct in_addr)); + else + memcpy(totemip->addr, &sa6->sin6_addr, sizeof(struct in6_addr)); + + return 0; +} + +/* Make a sockaddr_* into a totem_ip_address */ +int totemip_sockaddr_to_totemip_convert(struct sockaddr_storage *saddr, struct totem_ip_address *ip_addr) +{ + int ret = -1; + + ip_addr->family = saddr->ss_family; + ip_addr->nodeid = 0; + + if (saddr->ss_family == AF_INET) { + struct sockaddr_in *sin = (struct sockaddr_in *)saddr; + + memcpy(ip_addr->addr, &sin->sin_addr, sizeof(struct in_addr)); + ret = 0; + } + + if (saddr->ss_family == AF_INET6) { + struct sockaddr_in6 *sin = (struct sockaddr_in6 *)saddr; + + memcpy(ip_addr->addr, &sin->sin6_addr, sizeof(struct in6_addr)); + + ret = 0; + } + return ret; +} + +int totemip_iface_check(struct totem_ip_address *bindnet, + struct totem_ip_address *boundto, + int *interface_up, + int *interface_num) +{ + int fd; + struct { + struct nlmsghdr nlh; + struct rtgenmsg g; + } req; + struct sockaddr_nl nladdr; + static char rcvbuf[NETLINK_BUFSIZE]; + + *interface_up = 0; + *interface_num = 0; + + /* Ask netlink for a list of interface addresses */ + fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); + if (fd <0) + return -1; + + setsockopt(fd,SOL_SOCKET,SO_RCVBUF,&rcvbuf,sizeof(rcvbuf)); + + memset(&nladdr, 0, sizeof(nladdr)); + nladdr.nl_family = AF_NETLINK; + + req.nlh.nlmsg_len = sizeof(req); + req.nlh.nlmsg_type = RTM_GETADDR; + req.nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST; + req.nlh.nlmsg_pid = 0; + req.nlh.nlmsg_seq = 1; + req.g.rtgen_family = bindnet->family; + + if (sendto(fd, (void *)&req, sizeof(req), 0, + (struct sockaddr*)&nladdr, sizeof(nladdr)) < 0) { + close(fd); + return -1; + } + + /* Look through the return buffer for our address */ + while (1) + { + int status; + struct nlmsghdr *h; + struct iovec iov = { rcvbuf, sizeof(rcvbuf) }; + struct msghdr msg = { + (void*)&nladdr, sizeof(nladdr), + &iov, 1, + NULL, 0, + 0 + }; + + status = recvmsg(fd, &msg, 0); + if (!status) { + close(fd); + return -1; + } + + h = (struct nlmsghdr *)rcvbuf; + if (h->nlmsg_type == NLMSG_DONE) + break; + + if (h->nlmsg_type == NLMSG_ERROR) { + close(fd); + return -1; + } + + while (NLMSG_OK(h, status)) { + if (h->nlmsg_type == RTM_NEWADDR) { + struct ifaddrmsg *msg = NLMSG_DATA(h); + struct rtattr *rta = (struct rtattr *)(msg+1); + struct totem_ip_address ipaddr; + unsigned char *data = (unsigned char *)(rta+1); + + ipaddr.family = bindnet->family; + memcpy(ipaddr.addr, data, TOTEMIP_ADDRLEN); + if (totemip_equal(&ipaddr, bindnet)) { + + /* Found it - check I/F is UP */ + struct ifreq ifr; + int ioctl_fd; /* Can't do ioctls on netlink FDs */ + + ioctl_fd = socket(AF_INET, SOCK_STREAM, 0); + if (ioctl_fd < 0) { + close(fd); + return -1; + } + memset(&ifr, 0, sizeof(ifr)); + ifr.ifr_ifindex = msg->ifa_index; + + /* SIOCGIFFLAGS needs an interface name */ + status = ioctl(ioctl_fd, SIOCGIFNAME, &ifr); + status = ioctl(ioctl_fd, SIOCGIFFLAGS, &ifr); + if (status) { + close(ioctl_fd); + close(fd); + return -1; + } + + if (ifr.ifr_flags & IFF_UP) + *interface_up = 1; + + *interface_num = msg->ifa_index; + close(ioctl_fd); + goto finished; + } + } + + h = NLMSG_NEXT(h, status); + } + } +finished: + totemip_copy (boundto, bindnet); + close(fd); + return 0; +} diff --git a/exec/totemip.h b/exec/totemip.h new file mode 100644 index 00000000..6ac2e3a7 --- /dev/null +++ b/exec/totemip.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2005 Red Hat Inc + * + * All rights reserved. + * + * Author: Patrick Caulfield (pcaulfie@redhat.com) + * + * This software licensed under BSD license, the text of which follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the MontaVista Software, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* IPv4/6 abstraction */ + +#ifndef TOTEMIP_H_DEFINED +#define TOTEMIP_H_DEFINED + +#define TOTEMIP_ADDRLEN (sizeof(struct in6_addr)) + +/* These are the things that get passed around */ +struct totem_ip_address +{ + unsigned int nodeid; + unsigned short family; + unsigned char addr[TOTEMIP_ADDRLEN]; +} __attribute__((packed)); + + +extern int totemip_equal(struct totem_ip_address *addr1, struct totem_ip_address *addr2); +extern int totemip_compare(const void *a, const void *b); +extern void totemip_copy(struct totem_ip_address *addr1, struct totem_ip_address *addr2); +int totemip_localhost(int family, struct totem_ip_address *localhost); +extern int totemip_localhost_check(struct totem_ip_address *addr); +extern const char *totemip_print(struct totem_ip_address *addr); +extern int totemip_sockaddr_to_totemip_convert(struct sockaddr_storage *saddr, struct totem_ip_address *ip_addr); +extern int totemip_totemip_to_sockaddr_convert(struct totem_ip_address *ip_addr, + uint16_t port, struct sockaddr_storage *saddr, int *addrlen); +extern int totemip_parse(struct totem_ip_address *totemip, char *addr); +extern int totemip_iface_check(struct totem_ip_address *bindnet, struct totem_ip_address *boundto, int *interface_up, int *interface_num); + +/* These two simulate a zero in_addr by clearing the family field */ +static inline void totemip_zero_set(struct totem_ip_address *addr) +{ + addr->family = 0; +} +static inline int totemip_zero_check(struct totem_ip_address *addr) +{ + return (addr->family == 0); +} + +#endif diff --git a/exec/totemmrp.c b/exec/totemmrp.c index da1b72e3..46979d6d 100644 --- a/exec/totemmrp.c +++ b/exec/totemmrp.c @@ -63,20 +63,20 @@ totemsrp_handle totemsrp_handle_in; void (*pg_deliver_fn) ( - struct in_addr source_addr, + struct totem_ip_address *source_addr, struct iovec *iovec, int iov_len, int endian_conversion_required) = 0; void (*pg_confchg_fn) ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id) = 0; void totemmrp_deliver_fn ( - struct in_addr source_addr, + struct totem_ip_address *source_addr, struct iovec *iovec, int iov_len, int endian_conversion_required) @@ -86,9 +86,9 @@ void totemmrp_deliver_fn ( void totemmrp_confchg_fn ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id) { pg_confchg_fn (configuration_type, @@ -107,15 +107,15 @@ int totemmrp_initialize ( struct totem_config *totem_config, void (*deliver_fn) ( - struct in_addr source_addr, + struct totem_ip_address *source_addr, struct iovec *iovec, int iov_len, int endian_conversion_required), void (*confchg_fn) ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id)) { int result; diff --git a/exec/totemmrp.h b/exec/totemmrp.h index 2e5396a5..25400096 100644 --- a/exec/totemmrp.h +++ b/exec/totemmrp.h @@ -63,15 +63,15 @@ int totemmrp_initialize ( struct totem_config *totem_config, void (*deliver_fn) ( - struct in_addr source_addr, + struct totem_ip_address *source_addr, struct iovec *iovec, int iov_len, int endian_conversion_required), void (*confchg_fn) ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id)); int totemmrp_finalize (void); @@ -101,6 +101,4 @@ void totemmrp_callback_token_destroy ( void totemmrp_new_msg_signal (void); -extern struct sockaddr_in config_mcast_addr; - #endif /* TOTEMMRP_H_DEFINED */ diff --git a/exec/totemnet.c b/exec/totemnet.c index 710723db..87161634 100644 --- a/exec/totemnet.c +++ b/exec/totemnet.c @@ -79,8 +79,6 @@ #define BIND_STATE_REGULAR 1 #define BIND_STATE_LOOPBACK 2 -#define LOCALHOST_IP inet_addr("127.0.0.1") - #define HMAC_HASH_SIZE 20 struct security_header { unsigned char hash_digest[HMAC_HASH_SIZE]; /* The hash *MUST* be first in the data structure */ @@ -94,7 +92,8 @@ struct totemnet_mcast_thread_state { }; struct totemnet_socket { - int mcast; + int mcast_recv; + int mcast_send; int token; }; @@ -121,13 +120,13 @@ struct totemnet_instance { void (*totemnet_deliver_fn) ( void *context, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len); void (*totemnet_iface_change_fn) ( void *context, - struct sockaddr_in *iface_sockaddr_in); + struct totem_ip_address *iface_address); /* * Function and data used to log messages @@ -156,9 +155,7 @@ struct totemnet_instance { struct totemnet_socket totemnet_sockets; - struct sockaddr_in sockaddr_in_mcast; - - struct in_addr in_addr_mcast; + struct totem_ip_address mcast_address; int stats_sent; @@ -172,7 +169,7 @@ struct totemnet_instance { struct timeval stats_tv_start; - struct sockaddr_in my_id; + struct totem_ip_address my_id; int firstrun; @@ -200,23 +197,23 @@ static struct saHandleDatabase totemnet_instance_database = { .handleInstanceDestructor = 0 }; -static int loopback_determine (struct sockaddr_in *bound_to); +static int loopback_determine (int family, struct totem_ip_address *bound_to); static void netif_down_check (struct totemnet_instance *instance); static int totemnet_build_sockets ( struct totemnet_instance *instance, - struct sockaddr_in *sockaddr_mcast, - struct sockaddr_in *sockaddr_bindnet, + struct totem_ip_address *bindnet_address, + struct totem_ip_address *mcastaddress, struct totemnet_socket *sockets, - struct sockaddr_in *bound_to, + struct totem_ip_address *bound_to, int *interface_up); static int totemnet_build_sockets_loopback ( struct totemnet_instance *instance, - struct sockaddr_in *sockaddr_mcast, - struct sockaddr_in *sockaddr_bindnet, + struct totem_ip_address *mcast_address, + struct totem_ip_address *bindnet_address, struct totemnet_socket *sockets, - struct sockaddr_in *bound_to); + struct totem_ip_address *bound_to); static void totemnet_instance_initialize (struct totemnet_instance *instance) { @@ -389,7 +386,9 @@ void totemnet_iovec_send ( unsigned char encrypt_data[FRAME_SIZE_MAX]; struct iovec iovec_encrypt[20]; struct iovec *iovec_sendmsg; + struct sockaddr_storage sockaddr; int iov_len; + int addrlen; if (instance->totem_config->secauth == 1) { @@ -421,8 +420,10 @@ void totemnet_iovec_send ( /* * Build multicast message */ - msg_mcast.msg_name = &instance->sockaddr_in_mcast; - msg_mcast.msg_namelen = sizeof (struct sockaddr_in); + totemip_totemip_to_sockaddr_convert(&instance->mcast_address, + instance->totem_config->ip_port, &sockaddr, &addrlen); + msg_mcast.msg_name = &sockaddr; + msg_mcast.msg_namelen = addrlen; msg_mcast.msg_iov = iovec_sendmsg; msg_mcast.msg_iovlen = iov_len; msg_mcast.msg_control = 0; @@ -430,19 +431,19 @@ void totemnet_iovec_send ( msg_mcast.msg_flags = 0; /* - * Transmit token or multicast message + * Transmit multicast message * An error here is recovered by totemnet */ - res = sendmsg (instance->totemnet_sockets.mcast, &msg_mcast, MSG_NOSIGNAL | MSG_DONTWAIT); + res = sendmsg (instance->totemnet_sockets.mcast_send, &msg_mcast, + MSG_NOSIGNAL | MSG_DONTWAIT); } void totemnet_msg_send ( struct totemnet_instance *instance, - struct in_addr *system_to, + struct totem_ip_address *system_to, void *msg, int msg_len) { - struct sockaddr_in next_addr; struct msghdr msg_mcast; int res = 0; int buf_len; @@ -450,6 +451,8 @@ void totemnet_msg_send ( unsigned char encrypt_data[FRAME_SIZE_MAX]; struct iovec iovec[2]; struct iovec iovec_sendmsg; + struct sockaddr_storage sockaddr; + int addrlen; int fd; if (instance->totem_config->secauth == 1) { @@ -484,21 +487,18 @@ void totemnet_msg_send ( /* * system_to is non-zero, so its a token send operation */ - next_addr.sin_addr.s_addr = system_to->s_addr; - next_addr.sin_port = instance->sockaddr_in_mcast.sin_port; - next_addr.sin_family = AF_INET; - + totemip_totemip_to_sockaddr_convert(system_to, instance->totem_config->ip_port, &sockaddr, &addrlen); fd = instance->totemnet_sockets.token; - msg_mcast.msg_name = &next_addr; } else { /* * system_to is zero, so its a mcast send operation */ - fd = instance->totemnet_sockets.mcast; - msg_mcast.msg_name = &instance->sockaddr_in_mcast; + totemip_totemip_to_sockaddr_convert(&instance->mcast_address, instance->totem_config->ip_port, &sockaddr, &addrlen); + fd = instance->totemnet_sockets.mcast_send; } - msg_mcast.msg_namelen = sizeof (struct sockaddr_in); + msg_mcast.msg_name = &sockaddr; + msg_mcast.msg_namelen = addrlen; msg_mcast.msg_iov = &iovec_sendmsg; msg_mcast.msg_iovlen = 1; msg_mcast.msg_control = 0; @@ -510,7 +510,6 @@ void totemnet_msg_send ( * An error here is recovered by totemnet */ res = sendmsg (fd, &msg_mcast, MSG_NOSIGNAL | MSG_DONTWAIT); -//printf ("sent %d bytes\n", res); } static void totemnet_mcast_thread_state_constructor ( @@ -538,7 +537,9 @@ static void totemnet_mcast_worker_fn (void *thread_state, void *work_item_in) int buf_len; struct iovec iovec_encrypted; struct iovec *iovec_sendmsg; + struct sockaddr_storage sockaddr; unsigned int iovs; + int addrlen; if (instance->totem_config->secauth == 1) { memmove (&work_item->iovec[1], &work_item->iovec[0], @@ -564,8 +565,11 @@ static void totemnet_mcast_worker_fn (void *thread_state, void *work_item_in) iovs = work_item->iov_len; } - msg_mcast.msg_name = &instance->sockaddr_in_mcast; - msg_mcast.msg_namelen = sizeof (struct sockaddr_in); + totemip_totemip_to_sockaddr_convert(&instance->mcast_address, + instance->totem_config->ip_port, &sockaddr, &addrlen); + + msg_mcast.msg_name = &sockaddr; + msg_mcast.msg_namelen = addrlen; msg_mcast.msg_iov = iovec_sendmsg; msg_mcast.msg_iovlen = iovs; msg_mcast.msg_control = 0; @@ -573,17 +577,16 @@ static void totemnet_mcast_worker_fn (void *thread_state, void *work_item_in) msg_mcast.msg_flags = 0; /* - * Transmit token or multicast message + * Transmit multicast message * An error here is recovered by totemnet */ - res = sendmsg (instance->totemnet_sockets.mcast, &msg_mcast, MSG_NOSIGNAL | MSG_DONTWAIT); - + res = sendmsg (instance->totemnet_sockets.mcast_send, &msg_mcast, + MSG_NOSIGNAL | MSG_DONTWAIT); if (res > 0) { instance->stats_sent += res; } } - int totemnet_finalize ( totemnet_handle handle) { @@ -621,7 +624,8 @@ static int net_deliver_fn ( struct msghdr msg_recv; struct iovec *iovec; struct security_header *security_header; - struct sockaddr_in system_from; + struct sockaddr_storage system_from; + struct totem_ip_address from_address; int bytes_received; int res = 0; unsigned char *msg_offset; @@ -639,7 +643,7 @@ static int net_deliver_fn ( * Receive datagram */ msg_recv.msg_name = &system_from; - msg_recv.msg_namelen = sizeof (struct sockaddr_in); + msg_recv.msg_namelen = sizeof (struct sockaddr_storage); msg_recv.msg_iov = iovec; msg_recv.msg_iovlen = 1; msg_recv.msg_control = 0; @@ -659,6 +663,7 @@ static int net_deliver_fn ( instance->totemnet_log_printf (instance->totemnet_log_level_security, "Received message is too short... ignoring %d.\n", bytes_received); return (0); } + totemip_sockaddr_to_totemip_convert(&system_from, &from_address); security_header = (struct security_header *)iovec->iov_base; @@ -687,7 +692,7 @@ static int net_deliver_fn ( */ instance->totemnet_deliver_fn ( instance->context, - &system_from.sin_addr, + &from_address, msg_offset, size_delv); @@ -697,73 +702,34 @@ static int net_deliver_fn ( static int netif_determine ( struct totemnet_instance *instance, - struct sockaddr_in *bindnet, - struct sockaddr_in *bound_to, - int *interface_up) + struct totem_ip_address *bindnet, + struct totem_ip_address *bound_to, + int *interface_up, + int *interface_num) { - struct sockaddr_in *sockaddr_in; - int id_fd; - struct ifconf ifc; - int numreqs = 0; int res; - int i; - in_addr_t mask_addr; - *interface_up = 0; + res = totemip_iface_check (bindnet, bound_to, + interface_up, interface_num); /* - * Generate list of local interfaces in ifc.ifc_req structure + * If the desired binding is to an IPV4 network and nodeid isn't + * specified, retrieve the node id from this_ip network address + * + * IPV6 networks must have a node ID specified since the node id + * field is only 32 bits. */ - id_fd = socket (AF_INET, SOCK_STREAM, 0); - ifc.ifc_buf = 0; - do { - numreqs += 32; - ifc.ifc_len = sizeof (struct ifreq) * numreqs; - ifc.ifc_buf = (void *)realloc(ifc.ifc_buf, ifc.ifc_len); - res = ioctl (id_fd, SIOCGIFCONF, &ifc); - if (res < 0) { - close (id_fd); - return -1; - } - } while (ifc.ifc_len == sizeof (struct ifreq) * numreqs); - res = -1; - - /* - * Find interface address to bind to - */ - for (i = 0; i < ifc.ifc_len / sizeof (struct ifreq); i++) { - sockaddr_in = (struct sockaddr_in *)&ifc.ifc_ifcu.ifcu_req[i].ifr_ifru.ifru_addr; - mask_addr = inet_addr ("255.255.255.0"); - - if ((sockaddr_in->sin_family == AF_INET) && - (sockaddr_in->sin_addr.s_addr & mask_addr) == - (bindnet->sin_addr.s_addr & mask_addr)) { - - bound_to->sin_addr.s_addr = sockaddr_in->sin_addr.s_addr; - res = i; - - if (ioctl(id_fd, SIOCGIFFLAGS, &ifc.ifc_ifcu.ifcu_req[i]) < 0) { - printf ("couldn't do ioctl\n"); - } - - *interface_up = ifc.ifc_ifcu.ifcu_req[i].ifr_ifru.ifru_flags & IFF_UP; - break; /* for */ - } + if (bound_to->family == AF_INET && bound_to->nodeid == 0) { + memcpy (&bound_to->nodeid, bound_to->addr, sizeof (int)); } - free (ifc.ifc_buf); - close (id_fd); - + return (res); } + -static int loopback_determine (struct sockaddr_in *bound_to) +static int loopback_determine (int family, struct totem_ip_address *bound_to) { - - bound_to->sin_addr.s_addr = LOCALHOST_IP; - if (&bound_to->sin_addr.s_addr == 0) { - return -1; - } - return 1; + return totemip_localhost(family, bound_to); } @@ -777,6 +743,7 @@ static void timer_function_netif_check_timeout ( struct totemnet_instance *instance = (struct totemnet_instance *)data; int res; int interface_up; + int interface_num; /* * Build sockets for every interface @@ -784,23 +751,28 @@ static void timer_function_netif_check_timeout ( netif_determine (instance, &instance->totemnet_interface->bindnet, &instance->totemnet_interface->boundto, - &interface_up); + &interface_up, &interface_num); - if (instance->totemnet_sockets.mcast > 0) { - close (instance->totemnet_sockets.mcast); + if (instance->totemnet_sockets.mcast_recv > 0) { + close (instance->totemnet_sockets.mcast_recv); poll_dispatch_delete (instance->totemnet_poll_handle, - instance->totemnet_sockets.mcast); + instance->totemnet_sockets.mcast_recv); + } + if (instance->totemnet_sockets.mcast_send > 0) { + close (instance->totemnet_sockets.mcast_send); + poll_dispatch_delete (instance->totemnet_poll_handle, + instance->totemnet_sockets.mcast_send); } if (instance->totemnet_sockets.token > 0) { close (instance->totemnet_sockets.token); poll_dispatch_delete (instance->totemnet_poll_handle, - instance->totemnet_sockets.token); + instance->totemnet_sockets.token); } if (!interface_up) { instance->netif_bind_state = BIND_STATE_LOOPBACK; res = totemnet_build_sockets_loopback(instance, - &instance->sockaddr_in_mcast, + &instance->mcast_address, &instance->totemnet_interface->bindnet, &instance->totemnet_sockets, &instance->totemnet_interface->boundto); @@ -815,10 +787,8 @@ static void timer_function_netif_check_timeout ( /* * Create and bind the multicast and unicast sockets */ - memcpy (&instance->sockaddr_in_mcast.sin_addr, - &instance->in_addr_mcast, sizeof (struct in_addr)); res = totemnet_build_sockets (instance, - &instance->sockaddr_in_mcast, + &instance->mcast_address, &instance->totemnet_interface->bindnet, &instance->totemnet_sockets, &instance->totemnet_interface->boundto, @@ -826,7 +796,7 @@ static void timer_function_netif_check_timeout ( poll_dispatch_add ( instance->totemnet_poll_handle, - instance->totemnet_sockets.mcast, + instance->totemnet_sockets.mcast_recv, POLLIN, instance, net_deliver_fn, UINT_MAX); poll_dispatch_add ( @@ -835,8 +805,7 @@ static void timer_function_netif_check_timeout ( POLLIN, instance, net_deliver_fn, UINT_MAX); } - memcpy (&instance->my_id, &instance->totemnet_interface->boundto, - sizeof (struct sockaddr_in)); + totemip_copy (&instance->my_id, &instance->totemnet_interface->boundto); /* * This stuff depends on totemnet_build_sockets @@ -845,7 +814,7 @@ static void timer_function_netif_check_timeout ( if (instance->netif_state_report & NETIF_STATE_REPORT_UP) { instance->totemnet_log_printf (instance->totemnet_log_level_notice, " The network interface [%s] is now up.\n", - inet_ntoa (instance->totemnet_interface->boundto.sin_addr)); + totemip_print (&instance->totemnet_interface->boundto)); instance->netif_state_report = NETIF_STATE_REPORT_DOWN; instance->totemnet_iface_change_fn (instance->context, &instance->my_id); } @@ -854,15 +823,17 @@ static void timer_function_netif_check_timeout ( * If this is a single processor, detect downs which may not * be detected by token loss when the interface is downed */ - /* + +/* if (instance->my_memb_entries <= 1) { poll_timer_add (instance->totemnet_poll_handle, - instance->timeout_downcheck, + instance->totem_config->downcheck_timeout, (void *)instance, timer_function_netif_check_timeout, &instance->timer_netif_check_timeout); } - */ +*/ + } else { if (instance->netif_state_report & NETIF_STATE_REPORT_DOWN) { instance->totemnet_log_printf (instance->totemnet_log_level_notice, @@ -874,11 +845,13 @@ static void timer_function_netif_check_timeout ( /* * Add a timer to retry building interfaces and request memb_gather_enter */ +/* poll_timer_add (instance->totemnet_poll_handle, instance->totem_config->downcheck_timeout, (void *)instance, timer_function_netif_check_timeout, &instance->timer_netif_check_timeout); +*/ } } @@ -892,15 +865,16 @@ static void netif_down_check (struct totemnet_instance *instance) timer_function_netif_check_timeout (instance); } - struct sockaddr_in sockaddr_in_test; static int totemnet_build_sockets_loopback ( struct totemnet_instance *instance, - struct sockaddr_in *sockaddr_mcast, - struct sockaddr_in *sockaddr_bindnet, + struct totem_ip_address *mcast_addr, + struct totem_ip_address *bindnet_addr, struct totemnet_socket *sockets, - struct sockaddr_in *bound_to) + struct totem_ip_address *bound_to) { struct ip_mreq mreq; + struct sockaddr_storage sockaddr; + int addrlen; int res; memset (&mreq, 0, sizeof (struct ip_mreq)); @@ -908,21 +882,18 @@ static int totemnet_build_sockets_loopback ( /* * Determine the ip address bound to and the interface name */ - res = loopback_determine (bound_to); + res = loopback_determine (mcast_addr->family, bound_to); if (res == -1) { return (-1); } - /* TODO this should be somewhere else */ - instance->my_id.sin_addr.s_addr = bound_to->sin_addr.s_addr; - instance->my_id.sin_family = AF_INET; - instance->my_id.sin_port = sockaddr_mcast->sin_port; + totemip_copy(&instance->my_id, bound_to); /* * Setup unicast socket */ - sockets->token = socket (AF_INET, SOCK_DGRAM, 0); + sockets->token = socket (bound_to->family, SOCK_DGRAM, 0); if (sockets->token == -1) { perror ("socket2"); return (-1); @@ -932,102 +903,63 @@ static int totemnet_build_sockets_loopback ( * Bind to unicast socket used for token send/receives * This has the side effect of binding to the correct interface */ - sockaddr_in_test.sin_addr.s_addr = bound_to->sin_addr.s_addr; - sockaddr_in_test.sin_family = AF_INET; - sockaddr_in_test.sin_port = sockaddr_mcast->sin_port; - - res = bind (sockets->token, (struct sockaddr *)&sockaddr_in_test, - sizeof (struct sockaddr_in)); + totemip_totemip_to_sockaddr_convert(bound_to, instance->totem_config->ip_port, &sockaddr, &addrlen); + res = bind (sockets->token, (struct sockaddr *)&sockaddr, addrlen); if (res == -1) { perror ("bind2 failed"); return (-1); } - memcpy(&instance->sockaddr_in_mcast, &sockaddr_in_test, sizeof(struct sockaddr_in)); - sockets->mcast = sockets->token; + sockets->mcast_send = sockets->token; + sockets->mcast_recv = sockets->token; return (0); } +/* Set the socket priority to INTERACTIVE to ensure + that our messages don't get queued behind anything else */ +static void totemnet_traffic_control_set(struct totemnet_instance *instance, int sock) +{ + int prio = 6; /* TC_PRIO_INTERACTIVE */ + if (setsockopt(sock, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(int))) + instance->totemnet_log_printf (instance->totemnet_log_level_warning, "Could not set traffic priority. (%s)\n", strerror (errno)); +} -static int totemnet_build_sockets ( +static int totemnet_build_sockets_ipv4 ( struct totemnet_instance *instance, - struct sockaddr_in *sockaddr_mcast, - struct sockaddr_in *sockaddr_bindnet, + struct totem_ip_address *mcast_address, + struct totem_ip_address *bindnet_address, struct totemnet_socket *sockets, - struct sockaddr_in *bound_to, + struct totem_ip_address *bound_to, int *interface_up) { struct ip_mreq mreq; - struct sockaddr_in sockaddr_in_test; - char flag; - int res; + struct sockaddr_storage bound_ss; + struct sockaddr_in *bound_sin = (struct sockaddr_in *)&bound_ss; + struct sockaddr_storage mcast_ss; + struct sockaddr_in *mcast_sin = (struct sockaddr_in *)&mcast_ss; + struct sockaddr_storage sockaddr; unsigned int sendbuf_size; unsigned int recvbuf_size; unsigned int optlen = sizeof (sendbuf_size); - - memset (&mreq, 0, sizeof (struct ip_mreq)); - - /* - * Determine the ip address bound to and the interface name - */ - res = netif_determine (instance, - sockaddr_bindnet, - bound_to, - interface_up); - - if (res == -1) { - return (-1); - } - - /* TODO this should be somewhere else */ - instance->my_id.sin_addr.s_addr = bound_to->sin_addr.s_addr; - instance->my_id.sin_family = AF_INET; - instance->my_id.sin_port = sockaddr_mcast->sin_port; + int flag; + int addrlen; + int res; /* * Create multicast socket */ - sockets->mcast = socket (AF_INET, SOCK_DGRAM, 0); - if (sockets->mcast == -1) { + sockets->mcast_send = socket (AF_INET, SOCK_DGRAM, 0); + if (sockets->mcast_send == -1) { perror ("socket"); return (-1); } - if (setsockopt (sockets->mcast, SOL_IP, IP_MULTICAST_IF, - &bound_to->sin_addr, sizeof (struct in_addr)) < 0) { - - instance->totemnet_log_printf (instance->totemnet_log_level_warning, "Could not bind to device for multicast, group messaging may not work properly. (%s)\n", strerror (errno)); - } - - recvbuf_size = MCAST_SOCKET_BUFFER_SIZE; - sendbuf_size = MCAST_SOCKET_BUFFER_SIZE; - /* - * Set buffer sizes to avoid overruns - */ - res = setsockopt (sockets->mcast, SOL_SOCKET, SO_RCVBUF, &recvbuf_size, optlen); - res = setsockopt (sockets->mcast, SOL_SOCKET, SO_SNDBUF, &sendbuf_size, optlen); - - res = getsockopt (sockets->mcast, SOL_SOCKET, SO_RCVBUF, &recvbuf_size, &optlen); - if (res == 0) { - instance->totemnet_log_printf (instance->totemnet_log_level_notice, - "Multicast socket recv buffer size (%d bytes).\n", recvbuf_size); - } - - res = getsockopt (sockets->mcast, SOL_SOCKET, SO_SNDBUF, &sendbuf_size, &optlen); - if (res == 0) { - instance->totemnet_log_printf (instance->totemnet_log_level_notice, - "Multicast socket send buffer size (%d bytes).\n", sendbuf_size); - } - /* * Bind to multicast socket used for multicast send/receives */ - sockaddr_in_test.sin_family = AF_INET; - sockaddr_in_test.sin_addr.s_addr = sockaddr_mcast->sin_addr.s_addr; - sockaddr_in_test.sin_port = sockaddr_mcast->sin_port; - res = bind (sockets->mcast, (struct sockaddr *)&sockaddr_in_test, - sizeof (struct sockaddr_in)); + totemip_totemip_to_sockaddr_convert(mcast_address, instance->totem_config->ip_port, &sockaddr, &addrlen); + res = bind (sockets->mcast_send, (struct sockaddr *)&sockaddr, addrlen); if (res == -1) { perror ("bind failed"); return (-1); @@ -1046,50 +978,262 @@ static int totemnet_build_sockets ( * Bind to unicast socket used for token send/receives * This has the side effect of binding to the correct interface */ - sockaddr_in_test.sin_family = AF_INET; - sockaddr_in_test.sin_addr.s_addr = bound_to->sin_addr.s_addr; - sockaddr_in_test.sin_port = sockaddr_mcast->sin_port; - res = bind (sockets->token, (struct sockaddr *)&sockaddr_in_test, - sizeof (struct sockaddr_in)); + totemip_totemip_to_sockaddr_convert(bound_to, instance->totem_config->ip_port, &sockaddr, &addrlen); + res = bind (sockets->token, (struct sockaddr *)&sockaddr, addrlen); if (res == -1) { perror ("bind2 failed"); return (-1); } -#ifdef CONFIG_USE_BROADCAST -/* This config option doesn't work */ -{ - int on = 1; - setsockopt (sockets->mcast, SOL_SOCKET, SO_BROADCAST, (char *)&on, sizeof (on)); -} -#else - /* - * Join group membership on socket - */ - mreq.imr_multiaddr.s_addr = sockaddr_mcast->sin_addr.s_addr; - mreq.imr_interface.s_addr = bound_to->sin_addr.s_addr; + totemip_totemip_to_sockaddr_convert(bound_to, instance->totem_config->ip_port, &bound_ss, &addrlen); + totemip_totemip_to_sockaddr_convert(mcast_address, instance->totem_config->ip_port, &mcast_ss, &addrlen); + memset (&mreq, 0, sizeof (struct ip_mreq)); - res = setsockopt (sockets->mcast, IPPROTO_IP, IP_ADD_MEMBERSHIP, + if (setsockopt (sockets->mcast_send, SOL_IP, IP_MULTICAST_IF, + &bound_sin->sin_addr, sizeof (struct in_addr)) < 0) { + + instance->totemnet_log_printf (instance->totemnet_log_level_warning, "Could not bind to device for multicast, group messaging may not work properly. (%s)\n", strerror (errno)); + } + + recvbuf_size = MCAST_SOCKET_BUFFER_SIZE; + sendbuf_size = MCAST_SOCKET_BUFFER_SIZE; + /* + * Set buffer sizes to avoid overruns + */ + res = setsockopt (sockets->mcast_send, SOL_SOCKET, SO_RCVBUF, &recvbuf_size, optlen); + res = setsockopt (sockets->mcast_send, SOL_SOCKET, SO_SNDBUF, &sendbuf_size, optlen); + + res = getsockopt (sockets->mcast_send, SOL_SOCKET, SO_RCVBUF, &recvbuf_size, &optlen); + if (res == 0) { + instance->totemnet_log_printf (instance->totemnet_log_level_notice, + "Multicast socket send buffer size (%d bytes).\n", recvbuf_size); + } + + res = getsockopt (sockets->mcast_send, SOL_SOCKET, SO_SNDBUF, &sendbuf_size, + &optlen); + if (res == 0) { + instance->totemnet_log_printf (instance->totemnet_log_level_notice, + "Multicast socket send buffer size (%d bytes).\n", sendbuf_size); + } + + /* + * Join group membership + */ + mreq.imr_multiaddr.s_addr = mcast_sin->sin_addr.s_addr; + mreq.imr_interface.s_addr = bound_sin->sin_addr.s_addr; + + res = setsockopt (sockets->mcast_send, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof (mreq)); if (res == -1) { - perror ("join multicast group failed"); + perror ("join ipv4 multicast group failed"); return (-1); } -#endif /* * Turn on multicast loopback */ flag = 1; - res = setsockopt (sockets->mcast, IPPROTO_IP, IP_MULTICAST_LOOP, + res = setsockopt (sockets->mcast_send, IPPROTO_IP, IP_MULTICAST_LOOP, &flag, sizeof (flag)); if (res == -1) { perror ("turn off loopback"); return (-1); } + /* + * ipv4 binds to a network address, not a network interface like + * ipv6. So it is acceptable to utilize the same file descriptor + * for both send and receive since outgoing packets will be + * set with the correct source address + */ + sockets->mcast_recv = sockets->mcast_send; return (0); } + +static int totemnet_build_sockets_ipv6 ( + struct totemnet_instance *instance, + struct totem_ip_address *mcast_address, + struct totem_ip_address *bindnet_address, + struct totemnet_socket *sockets, + struct totem_ip_address *bound_to, + int *interface_up, + int interface_num) +{ + struct sockaddr_storage sockaddr; + struct ipv6_mreq mreq; + struct sockaddr_storage mcast_ss; + struct sockaddr_in6 *mcast_sin = (struct sockaddr_in6 *)&mcast_ss; + unsigned int sendbuf_size; + unsigned int recvbuf_size; + unsigned int optlen = sizeof (sendbuf_size); + int addrlen; + int res; + int flag; + + /* + * Create multicast recv socket + */ + sockets->mcast_recv = socket (AF_INET6, SOCK_DGRAM, 0); + if (sockets->mcast_recv == -1) { + perror ("socket"); + return (-1); + } + + /* + * Bind to multicast socket used for multicast receives + */ + totemip_totemip_to_sockaddr_convert(mcast_address, + instance->totem_config->ip_port, &sockaddr, &addrlen); + + res = bind (sockets->mcast_recv, (struct sockaddr *)&sockaddr, addrlen); + if (res == -1) { + perror ("bind failed"); + return (-1); + } + + /* + * Setup mcast send socket + */ + sockets->mcast_send = socket (AF_INET6, SOCK_DGRAM, 0); + if (sockets->mcast_send == -1) { + perror ("socket"); + return (-1); + } + + totemip_totemip_to_sockaddr_convert(bound_to, instance->totem_config->ip_port - 1, + &sockaddr, &addrlen); + res = bind (sockets->mcast_send, (struct sockaddr *)&sockaddr, addrlen); + if (res == -1) { + perror ("bind2 failed"); + return (-1); + } + + /* + * Setup unicast socket + */ + sockets->token = socket (AF_INET6, SOCK_DGRAM, 0); + if (sockets->token == -1) { + perror ("socket2"); + return (-1); + } + + /* + * Bind to unicast socket used for token send/receives + * This has the side effect of binding to the correct interface + */ + totemip_totemip_to_sockaddr_convert(bound_to, instance->totem_config->ip_port, &sockaddr, &addrlen); + res = bind (sockets->token, (struct sockaddr *)&sockaddr, addrlen); + if (res == -1) { + perror ("bind2 failed"); + return (-1); + } + + recvbuf_size = MCAST_SOCKET_BUFFER_SIZE; + sendbuf_size = MCAST_SOCKET_BUFFER_SIZE; + /* + * Set buffer sizes to avoid overruns + */ + res = setsockopt (sockets->mcast_recv, SOL_SOCKET, SO_RCVBUF, &recvbuf_size, optlen); + res = setsockopt (sockets->mcast_send, SOL_SOCKET, SO_SNDBUF, &sendbuf_size, optlen); + + res = getsockopt (sockets->mcast_recv, SOL_SOCKET, SO_RCVBUF, &recvbuf_size, &optlen); + if (res == 0) { + instance->totemnet_log_printf (instance->totemnet_log_level_notice, + "Receive multicast socket recv buffer size (%d bytes).\n", recvbuf_size); +} + + res = getsockopt (sockets->mcast_send, SOL_SOCKET, SO_SNDBUF, &sendbuf_size, &optlen); + if (res == 0) { + instance->totemnet_log_printf (instance->totemnet_log_level_notice, + "Transmit multicat socket send buffer size (%d bytes).\n", sendbuf_size); + } + + /* + * Join group membership on socket + */ + totemip_totemip_to_sockaddr_convert(mcast_address, + instance->totem_config->ip_port, &mcast_ss, &addrlen); + memset(&mreq, 0, sizeof(mreq)); + memcpy(&mreq.ipv6mr_multiaddr, &mcast_sin->sin6_addr, sizeof(struct in6_addr)); + mreq.ipv6mr_interface = interface_num; + + res = setsockopt (sockets->mcast_recv, SOL_IPV6, IPV6_ADD_MEMBERSHIP, + &mreq, sizeof (mreq)); + if (res == -1) { + perror ("join ipv6 multicast group failed"); + return (-1); + } + + /* + * Turn on multicast loopback + */ + flag = 1; + res = setsockopt (sockets->mcast_send, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, + &flag, sizeof (flag)); + if (res == -1) { + perror ("turn off loopback"); + return (-1); + } + + flag = 255; + res = setsockopt (sockets->mcast_send, SOL_IPV6, IPV6_MULTICAST_HOPS, + &flag, sizeof (flag)); + if (res == -1) { + perror ("setp mcast hops"); + return (-1); + } + + /* + * Bind to a specific interface for multicast send and receive + */ + if (setsockopt (sockets->mcast_send, IPPROTO_IPV6, IPV6_MULTICAST_IF, + &interface_num, sizeof (interface_num)) < 0) { + } + + if (setsockopt (sockets->mcast_recv, IPPROTO_IPV6, IPV6_MULTICAST_IF, + &interface_num, sizeof (interface_num)) < 0) { + } + return 0; +} + +static int totemnet_build_sockets ( + struct totemnet_instance *instance, + struct totem_ip_address *mcast_address, + struct totem_ip_address *bindnet_address, + struct totemnet_socket *sockets, + struct totem_ip_address *bound_to, + int *interface_up) +{ + int interface_num; + int res; + + /* + * Determine the ip address bound to and the interface name + */ + res = netif_determine (instance, + bindnet_address, + bound_to, + interface_up, + &interface_num); + + if (res == -1) { + return (-1); + } + + totemip_copy(&instance->my_id, bound_to); + + if (mcast_address->family== AF_INET) + res = totemnet_build_sockets_ipv4 (instance, mcast_address, + bindnet_address, sockets, bound_to, interface_up); + else { + res = totemnet_build_sockets_ipv6 (instance, mcast_address, + bindnet_address, sockets, bound_to, interface_up, interface_num); +} + + /* We only send out of the token socket */ + totemnet_traffic_control_set(instance, sockets->token); + return res; +} /* * Totem Network interface - also does encryption/decryption @@ -1108,18 +1252,17 @@ int totemnet_initialize ( void (*deliver_fn) ( void *context, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len), void (*iface_change_fn) ( void *context, - struct sockaddr_in *iface_sockaddr_in)) + struct totem_ip_address *iface_address)) { SaAisErrorT error; struct totemnet_instance *instance; - memset (&sockaddr_in_test, 0, sizeof (struct sockaddr_in)); error = saHandleCreate (&totemnet_instance_database, sizeof (struct totemnet_instance), handle); if (error != SA_OK) { @@ -1134,7 +1277,6 @@ int totemnet_initialize ( totemnet_instance_initialize (instance); instance->totem_config = totem_config; - /* * Configure logging */ @@ -1145,12 +1287,6 @@ int totemnet_initialize ( instance->totemnet_log_level_debug = totem_config->totem_logging_configuration.log_level_debug; instance->totemnet_log_printf = totem_config->totem_logging_configuration.log_printf; - memcpy (&instance->sockaddr_in_mcast, &totem_config->mcast_addr, - sizeof (struct sockaddr_in)); - - memcpy (&instance->in_addr_mcast, &totem_config->mcast_addr.sin_addr, - sizeof (struct in_addr)); - /* * Initialize random number generator for later use to generate salt */ @@ -1164,8 +1300,7 @@ int totemnet_initialize ( /* * Initialize local variables for totemnet */ - memcpy (&instance->sockaddr_in_mcast, &totem_config->mcast_addr, - sizeof (struct sockaddr_in)); + totemip_copy (&instance->mcast_address, &totem_config->mcast_addr); memset (instance->iov_buffer, 0, FRAME_SIZE_MAX); /* @@ -1184,6 +1319,8 @@ int totemnet_initialize ( instance->totemnet_interface = &totem_config->interfaces[interface_no]; instance->totemnet_poll_handle = poll_handle; + instance->totemnet_interface->bindnet.nodeid = instance->totem_config->node_id; + instance->context = context; instance->totemnet_deliver_fn = deliver_fn; @@ -1246,11 +1383,11 @@ int totemnet_recv_flush (totemnet_handle handle) instance->flushing = 1; do { - ufd.fd = instance->totemnet_sockets.mcast; + ufd.fd = instance->totemnet_sockets.mcast_recv; ufd.events = POLLIN; nfds = poll (&ufd, 1, 0); if (nfds == 1 && ufd.revents & POLLIN) { - net_deliver_fn (0, instance->totemnet_sockets.mcast, + net_deliver_fn (0, instance->totemnet_sockets.mcast_recv, ufd.revents, instance, &prio); } } while (nfds == 1); @@ -1286,7 +1423,7 @@ error_exit: int totemnet_token_send ( totemnet_handle handle, - struct in_addr *system_to, + struct totem_ip_address *system_to, void *msg, int msg_len) { @@ -1324,7 +1461,7 @@ int totemnet_mcast_flush_send ( goto error_exit; } - totemnet_msg_send (instance, 0, msg, msg_len); + totemnet_msg_send (instance, NULL, msg, msg_len); saHandleInstancePut (&totemnet_instance_database, handle); diff --git a/exec/totemnet.h b/exec/totemnet.h index c1187f24..6611a84f 100644 --- a/exec/totemnet.h +++ b/exec/totemnet.h @@ -61,13 +61,13 @@ extern int totemnet_initialize ( void (*deliver_fn) ( void *context, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len), void (*iface_change_fn) ( void *context, - struct sockaddr_in *iface_sockaddr_in)); + struct totem_ip_address *iface_address)); extern int totemnet_processor_count_set ( totemnet_handle handle, @@ -75,7 +75,7 @@ extern int totemnet_processor_count_set ( extern int totemnet_token_send ( totemnet_handle handle, - struct in_addr *system_to, + struct totem_ip_address *system_to, void *msg, int msg_len); diff --git a/exec/totempg.c b/exec/totempg.c index a86f1792..b29898d2 100644 --- a/exec/totempg.c +++ b/exec/totempg.c @@ -81,6 +81,7 @@ * */ +#include #include "totempg.h" #include "totemsrp.h" #include "totemmrp.h" @@ -89,7 +90,7 @@ #include #include #include -#include + #include "swab.h" @@ -140,20 +141,20 @@ static int mcast_packed_msg_count = 0; struct totem_config *totempg_totem_config; static void (*app_deliver_fn) ( - struct in_addr source_addr, + struct totem_ip_address *source_addr, struct iovec *iovec, int iov_len, int endian_conversion_required) = 0; static void (*app_confchg_fn) ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id) = 0; struct assembly { - struct in_addr addr; + struct totem_ip_address addr; unsigned char data[MESSAGE_SIZE_MAX]; int index; unsigned char last_frag_num; @@ -178,12 +179,12 @@ int fragment_continuation = 0; static struct iovec iov_delv; -static struct assembly *find_assembly (struct in_addr addr) +static struct assembly *find_assembly (struct totem_ip_address *addr) { int i; for (i = 0; i < assembly_list_entries; i++) { - if (addr.s_addr == assembly_list[i]->addr.s_addr) { + if (totemip_equal(addr, &assembly_list[i]->addr)) { return (assembly_list[i]); } } @@ -192,9 +193,9 @@ static struct assembly *find_assembly (struct in_addr addr) static void totempg_confchg_fn ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id) { int i; @@ -208,7 +209,7 @@ static void totempg_confchg_fn ( */ for (i = 0; i < left_list_entries; i++) { for (j = 0; j < assembly_list_entries; j++) { - if (left_list[i].s_addr == assembly_list[j]->addr.s_addr) { + if (totemip_equal(&left_list[i], &assembly_list[j]->addr)) { assembly_list[j]->index = 0; } } @@ -220,7 +221,7 @@ static void totempg_confchg_fn ( for (i = 0; i < member_list_entries; i++) { found = 0; for (j = 0; j < assembly_list_entries; j++) { - if (member_list[i].s_addr == assembly_list[j]->addr.s_addr) { + if (totemip_equal(&member_list[i], &assembly_list[j]->addr)) { found = 1; break; } @@ -229,8 +230,8 @@ static void totempg_confchg_fn ( assembly_list[assembly_list_entries] = malloc (sizeof (struct assembly)); assert (assembly_list[assembly_list_entries]); // TODO - assembly_list[assembly_list_entries]->addr.s_addr = - member_list[i].s_addr; + totemip_copy(&assembly_list[assembly_list_entries]->addr, + &member_list[i]); assembly_list[assembly_list_entries]->index = 0; assembly_list_entries += 1; } @@ -244,7 +245,7 @@ static void totempg_confchg_fn ( } static void totempg_deliver_fn ( - struct in_addr source_addr, + struct totem_ip_address *source_addr, struct iovec *iovec, int iov_len, int endian_conversion_required) @@ -462,16 +463,16 @@ int totempg_initialize ( struct totem_config *totem_config, void (*deliver_fn) ( - struct in_addr source_addr, + struct totem_ip_address *source_addr, struct iovec *iovec, int iov_len, int endian_conversion_required), void (*confchg_fn) ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id)) { int res; diff --git a/exec/totempg.h b/exec/totempg.h index 6b2d51a6..3832e6ca 100644 --- a/exec/totempg.h +++ b/exec/totempg.h @@ -57,16 +57,16 @@ int totempg_initialize ( struct totem_config *totem_config, void (*deliver_fn) ( - struct in_addr source_addr, + struct totem_ip_address *source_addr, struct iovec *iovec, int iov_len, int endian_conversion_required), void (*confchg_fn) ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id)); void totempg_finalize (void); diff --git a/exec/totemrrp.c b/exec/totemrrp.c index 3f3304cd..e7151435 100644 --- a/exec/totemrrp.c +++ b/exec/totemrrp.c @@ -91,7 +91,7 @@ struct rrp_algo { void (*mcast_recv) ( struct totemrrp_instance *instance, void *context, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, unsigned int msg_len); @@ -109,14 +109,14 @@ struct rrp_algo { struct totemrrp_instance *instance, unsigned int interface_no, void *context, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, unsigned int msg_len, unsigned int token_seqid); void (*token_send) ( struct totemrrp_instance *instance, - struct in_addr *system_to, + struct totem_ip_address *system_to, void *msg, unsigned int msg_len); }; @@ -132,13 +132,13 @@ struct totemrrp_instance { void (*totemrrp_deliver_fn) ( void *context, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len); void (*totemrrp_iface_change_fn) ( void *context, - struct sockaddr_in *iface_sockaddr_in); + struct totem_ip_address *iface_addr); void (*totemrrp_token_seqid_get) ( void *msg, @@ -178,7 +178,7 @@ struct totemrrp_instance { void passive_mcast_recv ( struct totemrrp_instance *instance, void *context, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, unsigned int msg_len); @@ -195,21 +195,21 @@ void passive_mcast_flush_send ( void passive_token_recv ( struct totemrrp_instance *instance, unsigned int interface_no, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, unsigned int msg_len, unsigned int token_seqid); void passive_token_send ( struct totemrrp_instance *instance, - struct in_addr *system_to, + struct totem_ip_address *system_to, void *msg, unsigned int msg_len); void active_mcast_recv ( struct totemrrp_instance *instance, void *context, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, unsigned int msg_len); @@ -227,14 +227,14 @@ void active_token_recv ( struct totemrrp_instance *instance, unsigned int interface_no, void *context, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, unsigned int msg_len, unsigned int token_seqid); void active_token_send ( struct totemrrp_instance *instance, - struct in_addr *system_to, + struct totem_ip_address *system_to, void *msg, unsigned int msg_len); @@ -365,7 +365,7 @@ error_exit: static void timer_function_active_token (void *context) { - struct active_instance *instance = (struct active_instance *)context; +// struct active_instance *instance = (struct active_instance *)context; } @@ -389,7 +389,7 @@ void active_token_timer_cancel (struct active_instance *active_instance) void active_mcast_recv ( struct totemrrp_instance *instance, void *context, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, unsigned int msg_len) { @@ -433,7 +433,7 @@ void active_token_recv ( struct totemrrp_instance *instance, unsigned int interface_no, void *context, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, unsigned int msg_len, unsigned int token_seqid) @@ -487,7 +487,7 @@ void active_token_recv ( void active_token_send ( struct totemrrp_instance *instance, - struct in_addr *system_to, + struct totem_ip_address *system_to, void *msg, unsigned int msg_len) { @@ -519,7 +519,7 @@ static void totemrrp_instance_initialize (struct totemrrp_instance *instance) void rrp_deliver_fn ( void *context, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len) { @@ -560,13 +560,13 @@ void rrp_deliver_fn ( void rrp_iface_change_fn ( void *context, - struct sockaddr_in *iface_sockaddr_in) + struct totem_ip_address *iface_addr) { struct deliver_fn_context *deliver_fn_context = (struct deliver_fn_context *)context; deliver_fn_context->instance->totemrrp_iface_change_fn ( deliver_fn_context->context, - iface_sockaddr_in); + iface_addr); } int totemrrp_finalize ( @@ -607,13 +607,13 @@ int totemrrp_initialize ( void (*deliver_fn) ( void *context, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len), void (*iface_change_fn) ( void *context, - struct sockaddr_in *iface_sockaddr_in), + struct totem_ip_address *iface_addr), void (*token_seqid_get) ( void *msg, @@ -772,7 +772,7 @@ error_exit: int totemrrp_token_send ( totemrrp_handle handle, - struct in_addr *system_to, + struct totem_ip_address *system_to, void *msg, int msg_len) { diff --git a/exec/totemrrp.h b/exec/totemrrp.h index 4c6fa723..2a59a9bc 100644 --- a/exec/totemrrp.h +++ b/exec/totemrrp.h @@ -61,13 +61,13 @@ extern int totemrrp_initialize ( void (*deliver_fn) ( void *context, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len), void (*iface_change_fn) ( void *context, - struct sockaddr_in *iface_sockaddr_in), + struct totem_ip_address *iface_addr), void (*token_seqid_get) ( void *msg, @@ -80,7 +80,7 @@ extern int totemrrp_processor_count_set ( extern int totemrrp_token_send ( totemrrp_handle handle, - struct in_addr *system_to, + struct totem_ip_address *system_to, void *msg, int msg_len); diff --git a/exec/totemsrp.c b/exec/totemsrp.c index 2b38224d..e9eb3a51 100644 --- a/exec/totemsrp.c +++ b/exec/totemsrp.c @@ -133,7 +133,7 @@ enum message_type { * New membership algorithm local variables */ struct consensus_list_item { - struct in_addr addr; + struct totem_ip_address addr; int set; }; @@ -156,6 +156,7 @@ struct message_header { char type; char encapsulated; unsigned short endian_detector; + unsigned int nodeid; } __attribute__((packed)); struct mcast { @@ -163,7 +164,7 @@ struct mcast { unsigned int seq; int this_seqno; struct memb_ring_id ring_id; - struct in_addr source; + struct totem_ip_address source; int guarantee; } __attribute__((packed)); @@ -187,7 +188,7 @@ struct orf_token { unsigned int seq; unsigned int token_seq; unsigned int aru; - struct in_addr aru_addr; + struct totem_ip_address aru_addr; struct memb_ring_id ring_id; short int fcc; int retrans_flg; @@ -197,9 +198,9 @@ struct orf_token { struct memb_join { struct message_header header; - struct in_addr proc_list[PROCESSOR_COUNT_MAX]; + struct totem_ip_address proc_list[PROCESSOR_COUNT_MAX]; int proc_list_entries; - struct in_addr failed_list[PROCESSOR_COUNT_MAX]; + struct totem_ip_address failed_list[PROCESSOR_COUNT_MAX]; int failed_list_entries; unsigned long long ring_seq; } __attribute__((packed)); @@ -228,7 +229,7 @@ struct memb_commit_token { unsigned int retrans_flg; int memb_index; int addr_entries; - struct in_addr addr[PROCESSOR_COUNT_MAX]; + struct totem_ip_address addr[PROCESSOR_COUNT_MAX]; struct memb_commit_token_memb_entry memb_list[PROCESSOR_COUNT_MAX]; }__attribute__((packed)); @@ -273,17 +274,19 @@ struct totemsrp_instance { int consensus_list_entries; - struct in_addr my_proc_list[PROCESSOR_COUNT_MAX]; + struct totem_ip_address my_proc_list[PROCESSOR_COUNT_MAX]; - struct in_addr my_failed_list[PROCESSOR_COUNT_MAX]; + struct totem_ip_address my_failed_list[PROCESSOR_COUNT_MAX]; - struct in_addr my_new_memb_list[PROCESSOR_COUNT_MAX]; + struct totem_ip_address my_new_memb_list[PROCESSOR_COUNT_MAX]; - struct in_addr my_trans_memb_list[PROCESSOR_COUNT_MAX]; + struct totem_ip_address my_trans_memb_list[PROCESSOR_COUNT_MAX]; - struct in_addr my_memb_list[PROCESSOR_COUNT_MAX]; + struct totem_ip_address my_memb_list[PROCESSOR_COUNT_MAX]; - struct in_addr my_deliver_memb_list[PROCESSOR_COUNT_MAX]; + struct totem_ip_address my_deliver_memb_list[PROCESSOR_COUNT_MAX]; + + struct totem_ip_address my_nodeid_lookup_list[PROCESSOR_COUNT_MAX]; int my_proc_list_entries; @@ -297,6 +300,8 @@ struct totemsrp_instance { int my_deliver_memb_entries; + int my_nodeid_lookup_entries; + struct memb_ring_id my_ring_id; struct memb_ring_id my_old_ring_id; @@ -389,9 +394,9 @@ struct totemsrp_instance { enum memb_state memb_state; - struct sockaddr_in my_id; + struct totem_ip_address my_id; - struct sockaddr_in next_memb; + struct totem_ip_address next_memb; char iov_buffer[FRAME_SIZE_MAX]; @@ -404,19 +409,19 @@ struct totemsrp_instance { */ int (*totemsrp_recv) (char *group, struct iovec *iovec, int iov_len); - struct sockaddr_in sockaddr_in_mcast; + struct totem_ip_address mcast_address; void (*totemsrp_deliver_fn) ( - struct in_addr source_addr, + struct totem_ip_address *source_addr, struct iovec *iovec, int iov_len, int endian_conversion_required); void (*totemsrp_confchg_fn) ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id); int global_seqno; @@ -452,7 +457,7 @@ struct message_handlers { int count; int (*handler_functions[6]) ( struct totemsrp_instance *instance, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len, int endian_conversion_needed); @@ -463,42 +468,42 @@ struct message_handlers { */ static int message_handler_orf_token ( struct totemsrp_instance *instance, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len, int endian_conversion_needed); static int message_handler_mcast ( struct totemsrp_instance *instance, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len, int endian_conversion_needed); static int message_handler_memb_merge_detect ( struct totemsrp_instance *instance, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len, int endian_conversion_needed); static int message_handler_memb_join ( struct totemsrp_instance *instance, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len, int endian_conversion_needed); static int message_handler_memb_commit_token ( struct totemsrp_instance *instance, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len, int endian_conversion_needed); static int message_handler_token_hold_cancel ( struct totemsrp_instance *instance, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len, int endian_conversion_needed); @@ -509,7 +514,7 @@ static void token_callbacks_execute (struct totemsrp_instance *instance, enum to static void memb_state_gather_enter (struct totemsrp_instance *instance); static void messages_deliver_to_app (struct totemsrp_instance *instance, int skip, unsigned int end_point); static int orf_token_mcast (struct totemsrp_instance *instance, struct orf_token *oken, - int fcc_mcasts_allowed, struct in_addr *system_from); + int fcc_mcasts_allowed, struct totem_ip_address *system_from); static void messages_free (struct totemsrp_instance *instance, unsigned int token_aru); static void memb_ring_id_store (struct totemsrp_instance *instance, struct memb_commit_token *commit_token); @@ -529,14 +534,13 @@ static void timer_function_merge_detect_timeout (void *data); void main_deliver_fn ( void *context, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len); void main_iface_change_fn ( void *context, - struct sockaddr_in *iface_sockaddr_in); - + struct totem_ip_address *iface_address); /* * All instances in one database @@ -607,16 +611,16 @@ int totemsrp_initialize ( struct totem_config *totem_config, void (*deliver_fn) ( - struct in_addr source_addr, + struct totem_ip_address *source_addr, struct iovec *iovec, int iov_len, int endian_conversion_required), void (*confchg_fn) ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id)) { struct totemsrp_instance *instance; @@ -650,10 +654,9 @@ int totemsrp_initialize ( /* * Initialize local variables for totemsrp */ - memcpy (&instance->sockaddr_in_mcast, &totem_config->mcast_addr, - sizeof (struct sockaddr_in)); + totemip_copy (&instance->mcast_address, &totem_config->mcast_addr); - memset (&instance->next_memb, 0, sizeof (struct sockaddr_in)); + memset (&instance->next_memb, 0, sizeof (struct totem_ip_address)); memset (instance->iov_buffer, 0, FRAME_SIZE_MAX); /* @@ -742,9 +745,6 @@ int totemsrp_initialize ( queue_init (&instance->new_message_queue, (MESSAGE_SIZE_MAX / (totem_config->net_mtu - 25) /* for totempg_mcat header */), sizeof (struct message_item)); -// queue_init (&instance->new_message_queue, -// 2000, -// sizeof (struct message_item)); return (0); @@ -779,9 +779,9 @@ static void memb_consensus_reset (struct totemsrp_instance *instance) } static void memb_set_subtract ( - struct in_addr *out_list, int *out_list_entries, - struct in_addr *one_list, int one_list_entries, - struct in_addr *two_list, int two_list_entries) + struct totem_ip_address *out_list, int *out_list_entries, + struct totem_ip_address *one_list, int one_list_entries, + struct totem_ip_address *two_list, int two_list_entries) { int found = 0; int i; @@ -791,13 +791,13 @@ static void memb_set_subtract ( for (i = 0; i < one_list_entries; i++) { for (j = 0; j < two_list_entries; j++) { - if (one_list[i].s_addr == two_list[j].s_addr) { + if (totemip_equal(&one_list[i], &two_list[j])) { found = 1; break; } } if (found == 0) { - out_list[*out_list_entries].s_addr = one_list[i].s_addr; + totemip_copy(&out_list[*out_list_entries], &one_list[i]); *out_list_entries = *out_list_entries + 1; } found = 0; @@ -809,18 +809,18 @@ static void memb_set_subtract ( */ static void memb_consensus_set ( struct totemsrp_instance *instance, - struct in_addr *addr) + struct totem_ip_address *addr) { int found = 0; int i; for (i = 0; i < instance->consensus_list_entries; i++) { - if (addr->s_addr == instance->consensus_list[i].addr.s_addr) { + if (totemip_equal(addr, &instance->consensus_list[i].addr)) { found = 1; break; /* found entry */ } } - instance->consensus_list[i].addr.s_addr = addr->s_addr; + totemip_copy(&instance->consensus_list[i].addr, addr); instance->consensus_list[i].set = 1; if (found == 0) { instance->consensus_list_entries++; @@ -833,12 +833,12 @@ static void memb_consensus_set ( */ static int memb_consensus_isset ( struct totemsrp_instance *instance, - struct in_addr *addr) + struct totem_ip_address *addr) { int i; for (i = 0; i < instance->consensus_list_entries; i++) { - if (addr->s_addr == instance->consensus_list[i].addr.s_addr) { + if (totemip_equal(addr, &instance->consensus_list[i].addr)) { return (instance->consensus_list[i].set); } } @@ -851,7 +851,7 @@ static int memb_consensus_isset ( static int memb_consensus_agreed ( struct totemsrp_instance *instance) { - struct in_addr token_memb[PROCESSOR_COUNT_MAX]; + struct totem_ip_address token_memb[PROCESSOR_COUNT_MAX]; int token_memb_entries = 0; int agreed = 1; int i; @@ -873,9 +873,9 @@ static int memb_consensus_agreed ( static void memb_consensus_notset ( struct totemsrp_instance *instance, - struct in_addr *no_consensus_list, + struct totem_ip_address *no_consensus_list, int *no_consensus_list_entries, - struct in_addr *comparison_list, + struct totem_ip_address *comparison_list, int comparison_list_entries) { int i; @@ -884,7 +884,7 @@ static void memb_consensus_notset ( for (i = 0; i < instance->my_proc_list_entries; i++) { if (memb_consensus_isset (instance, &instance->my_proc_list[i]) == 0) { - no_consensus_list[*no_consensus_list_entries].s_addr = instance->my_proc_list[i].s_addr; + totemip_copy(&no_consensus_list[*no_consensus_list_entries], &instance->my_proc_list[i]); *no_consensus_list_entries = *no_consensus_list_entries + 1; } } @@ -893,8 +893,8 @@ static void memb_consensus_notset ( /* * Is set1 equal to set2 Entries can be in different orders */ -static int memb_set_equal (struct in_addr *set1, int set1_entries, - struct in_addr *set2, int set2_entries) +static int memb_set_equal (struct totem_ip_address *set1, int set1_entries, + struct totem_ip_address *set2, int set2_entries) { int i; int j; @@ -906,7 +906,7 @@ static int memb_set_equal (struct in_addr *set1, int set1_entries, } for (i = 0; i < set2_entries; i++) { for (j = 0; j < set1_entries; j++) { - if (set1[j].s_addr == set2[i].s_addr) { + if (totemip_equal(&set1[j], &set2[i])) { found = 1; break; } @@ -923,8 +923,8 @@ static int memb_set_equal (struct in_addr *set1, int set1_entries, * Is subset fully contained in fullset */ static int memb_set_subset ( - struct in_addr *subset, int subset_entries, - struct in_addr *fullset, int fullset_entries) + struct totem_ip_address *subset, int subset_entries, + struct totem_ip_address *fullset, int fullset_entries) { int i; int j; @@ -935,7 +935,7 @@ static int memb_set_subset ( } for (i = 0; i < subset_entries; i++) { for (j = 0; j < fullset_entries; j++) { - if (subset[i].s_addr == fullset[j].s_addr) { + if (totemip_equal(&subset[i], &fullset[j])) { found = 1; } } @@ -951,8 +951,8 @@ static int memb_set_subset ( * merge subset into fullset taking care not to add duplicates */ static void memb_set_merge ( - struct in_addr *subset, int subset_entries, - struct in_addr *fullset, int *fullset_entries) + struct totem_ip_address *subset, int subset_entries, + struct totem_ip_address *fullset, int *fullset_entries) { int found = 0; int i; @@ -960,13 +960,13 @@ static void memb_set_merge ( for (i = 0; i < subset_entries; i++) { for (j = 0; j < *fullset_entries; j++) { - if (fullset[j].s_addr == subset[i].s_addr) { + if (totemip_equal(&fullset[j], &subset[i])) { found = 1; break; } } if (found == 0) { - fullset[j].s_addr = subset[i].s_addr; + totemip_copy(&fullset[j], &subset[i]); *fullset_entries = *fullset_entries + 1; } found = 0; @@ -975,9 +975,9 @@ static void memb_set_merge ( } static void memb_set_and ( - struct in_addr *set1, int set1_entries, - struct in_addr *set2, int set2_entries, - struct in_addr *and, int *and_entries) + struct totem_ip_address *set1, int set1_entries, + struct totem_ip_address *set2, int set2_entries, + struct totem_ip_address *and, int *and_entries) { int i; int j; @@ -987,13 +987,13 @@ static void memb_set_and ( for (i = 0; i < set2_entries; i++) { for (j = 0; j < set1_entries; j++) { - if (set1[j].s_addr == set2[i].s_addr) { + if (totemip_equal(&set1[j], &set2[i])) { found = 1; break; } } if (found) { - and[*and_entries].s_addr = set1[j].s_addr; + totemip_copy(&and[*and_entries], &set1[j]); *and_entries = *and_entries + 1; } found = 0; @@ -1001,20 +1001,18 @@ static void memb_set_and ( return; } -#ifdef CODE_COVERGE static void memb_set_print ( char *string, - struct in_addr *list, + struct totem_ip_address *list, int list_entries) { int i; printf ("List '%s' contains %d entries:\n", string, list_entries); for (i = 0; i < list_entries; i++) { - printf ("addr %s\n", inet_ntoa (list[i])); + printf ("addr %s\n", totemip_print (&list[i])); } } -#endif static void reset_token_retransmit_timeout (struct totemsrp_instance *instance) { @@ -1080,7 +1078,7 @@ static void ring_reset (struct totemsrp_instance *instance) static void ring_state_restore (struct totemsrp_instance *instance) { if (instance->old_ring_state_saved) { - instance->my_ring_id.rep.s_addr = 0; + totemip_zero_set(&instance->my_ring_id.rep); instance->my_aru = instance->old_ring_state_aru; instance->my_high_seq_received = instance->old_ring_state_high_seq_received; instance->totemsrp_log_printf (instance->totemsrp_log_level_debug, @@ -1144,13 +1142,13 @@ static void cancel_token_hold_retransmit_timeout (struct totemsrp_instance *inst static void memb_state_consensus_timeout_expired ( struct totemsrp_instance *instance) { - struct in_addr no_consensus_list[PROCESSOR_COUNT_MAX]; + struct totem_ip_address no_consensus_list[PROCESSOR_COUNT_MAX]; int no_consensus_list_entries; if (memb_consensus_agreed (instance)) { memb_consensus_reset (instance); - memb_consensus_set (instance, &instance->my_id.sin_addr); + memb_consensus_set (instance, &instance->my_id); reset_token_timeout (instance); // REVIEWED } else { @@ -1334,9 +1332,9 @@ static void deliver_messages_from_recovery_to_regular (struct totemsrp_instance */ static void memb_state_operational_enter (struct totemsrp_instance *instance) { - struct in_addr joined_list[PROCESSOR_COUNT_MAX]; + struct totem_ip_address joined_list[PROCESSOR_COUNT_MAX]; int joined_list_entries = 0; - struct in_addr left_list[PROCESSOR_COUNT_MAX]; + struct totem_ip_address left_list[PROCESSOR_COUNT_MAX]; int left_list_entries = 0; unsigned int aru_save; @@ -1391,7 +1389,7 @@ static void memb_state_operational_enter (struct totemsrp_instance *instance) */ instance->my_memb_entries = instance->my_new_memb_entries; memcpy (instance->my_memb_list, instance->my_new_memb_list, - sizeof (struct in_addr) * instance->my_memb_entries); + sizeof (struct totem_ip_address) * instance->my_memb_entries); instance->last_released = 0; instance->my_set_retrans_flg = 0; /* @@ -1405,7 +1403,7 @@ static void memb_state_operational_enter (struct totemsrp_instance *instance) instance->my_proc_list_entries = instance->my_new_memb_entries; memcpy (instance->my_proc_list, instance->my_new_memb_list, - sizeof (struct in_addr) * instance->my_memb_entries); + sizeof (struct totem_ip_address) * instance->my_memb_entries); instance->my_failed_list_entries = 0; instance->my_high_delivered = instance->my_aru; @@ -1420,7 +1418,7 @@ static void memb_state_operational_enter (struct totemsrp_instance *instance) static void memb_state_gather_enter (struct totemsrp_instance *instance) { - memb_set_merge (&instance->my_id.sin_addr, 1, + memb_set_merge (&instance->my_id, 1, instance->my_proc_list, &instance->my_proc_list_entries); memb_join_message_send (instance); @@ -1457,7 +1455,7 @@ static void memb_state_gather_enter (struct totemsrp_instance *instance) memb_consensus_reset (instance); - memb_consensus_set (instance, &instance->my_id.sin_addr); + memb_consensus_set (instance, &instance->my_id); instance->totemsrp_log_printf (instance->totemsrp_log_level_notice, "entering GATHER state.\n"); @@ -1538,7 +1536,7 @@ static void memb_state_recovery_enter ( commit_token->addr_entries); memcpy (instance->my_new_memb_list, commit_token->addr, - sizeof (struct in_addr) * instance->my_new_memb_entries); + sizeof (struct totem_ip_address) * instance->my_new_memb_entries); /* * Build transitional configuration @@ -1549,11 +1547,11 @@ static void memb_state_recovery_enter ( for (i = 0; i < instance->my_new_memb_entries; i++) { instance->totemsrp_log_printf (instance->totemsrp_log_level_notice, - "position [%d] member %s:\n", i, inet_ntoa (commit_token->addr[i])); + "position [%d] member %s:\n", i, totemip_print (&commit_token->addr[i])); instance->totemsrp_log_printf (instance->totemsrp_log_level_notice, "previous ring seq %lld rep %s\n", commit_token->memb_list[i].ring_id.seq, - inet_ntoa (commit_token->memb_list[i].ring_id.rep)); + totemip_print (&commit_token->memb_list[i].ring_id.rep)); instance->totemsrp_log_printf (instance->totemsrp_log_level_notice, "aru %x high delivered %x received flag %d\n", @@ -1561,7 +1559,7 @@ static void memb_state_recovery_enter ( commit_token->memb_list[i].high_delivered, commit_token->memb_list[i].received_flg); - assert (commit_token->memb_list[i].ring_id.rep.s_addr); + assert (!totemip_zero_check(&commit_token->memb_list[i].ring_id.rep)); } /* * Determine if any received flag is false @@ -1575,7 +1573,7 @@ static void memb_state_recovery_enter ( #endif instance->my_deliver_memb_entries = instance->my_trans_memb_entries; memcpy (instance->my_deliver_memb_list, instance->my_trans_memb_list, - sizeof (struct in_addr) * instance->my_trans_memb_entries); + sizeof (struct totem_ip_address) * instance->my_trans_memb_entries); #ifdef COMPILE_OUT local_received_flg = 0; break; @@ -1644,6 +1642,8 @@ static void memb_state_recovery_enter ( memcpy (&message_item.mcast->ring_id, &instance->my_ring_id, sizeof (struct memb_ring_id)); message_item.mcast->header.encapsulated = 1; + message_item.mcast->header.nodeid = instance->my_id.nodeid; + assert (message_item.mcast->header.nodeid); message_item.iov_len = sort_queue_item->iov_len; memcpy (&message_item.iovec, &sort_queue_item->iovec, sizeof (struct iovec) * sort_queue_item->iov_len); @@ -1732,8 +1732,11 @@ int totemsrp_mcast ( message_item.mcast->header.type = MESSAGE_TYPE_MCAST; message_item.mcast->header.endian_detector = ENDIAN_LOCAL; message_item.mcast->header.encapsulated = 2; + message_item.mcast->header.nodeid = instance->my_id.nodeid; + assert (message_item.mcast->header.nodeid); + message_item.mcast->guarantee = guarantee; - message_item.mcast->source.s_addr = instance->my_id.sin_addr.s_addr; + totemip_copy(&message_item.mcast->source, &instance->my_id); for (i = 0; i < iov_len; i++) { // TODO LEAK @@ -1796,16 +1799,6 @@ error_exit: return (0); } -/* - * Misc Management - */ -static int in_addr_compare (const void *a, const void *b) { - struct in_addr *in_addr_a = (struct in_addr *)a; - struct in_addr *in_addr_b = (struct in_addr *)b; - - return (in_addr_a->s_addr > in_addr_b->s_addr); -} - /* * ORF Token Management */ @@ -1969,7 +1962,7 @@ static int orf_token_mcast ( struct totemsrp_instance *instance, struct orf_token *token, int fcc_mcasts_allowed, - struct in_addr *system_from) + struct totem_ip_address *system_from) { struct message_item *message_item = 0; struct queue *mcast_queue; @@ -2030,9 +2023,6 @@ static int orf_token_mcast ( sort_queue_item_ptr = sq_item_add (sort_queue, &sort_queue_item, message_item->mcast->seq); -// XXX printf ("ORIG [%s.%d-%d]\n", inet_ntoa (message_item->mcast->source), -// XXX message_item->mcast->seq, message_item->mcast->this_seqno); - totemrrp_mcast_noflush_send (instance->totemrrp_handle, sort_queue_item_ptr->iovec, sort_queue_item_ptr->iov_len); @@ -2183,7 +2173,7 @@ static int orf_token_rtr ( static void token_retransmit (struct totemsrp_instance *instance) { totemrrp_token_send (instance->totemrrp_handle, - &instance->next_memb.sin_addr, + &instance->next_memb, instance->orf_token_retransmit, instance->orf_token_retransmit_size); } @@ -2234,7 +2224,7 @@ static void timer_function_merge_detect_timeout(void *data) switch (instance->memb_state) { case MEMB_STATE_OPERATIONAL: - if (instance->my_ring_id.rep.s_addr == instance->my_id.sin_addr.s_addr) { + if (totemip_equal(&instance->my_ring_id.rep, &instance->my_id)) { memb_merge_detect_transmit (instance); } break; @@ -2259,13 +2249,15 @@ static int token_send ( memcpy (instance->orf_token_retransmit, orf_token, iov_len); instance->orf_token_retransmit_size = iov_len; + orf_token->header.nodeid = instance->my_id.nodeid; + assert (orf_token->header.nodeid); if (forward_token == 0) { return (0); } totemrrp_token_send (instance->totemrrp_handle, - &instance->next_memb.sin_addr, + &instance->next_memb, orf_token, iov_len); @@ -2289,6 +2281,9 @@ static int token_hold_cancel_send (struct totemsrp_instance *instance) */ token_hold_cancel.header.type = MESSAGE_TYPE_TOKEN_HOLD_CANCEL; token_hold_cancel.header.endian_detector = ENDIAN_LOCAL; + token_hold_cancel.header.nodeid = instance->my_id.nodeid; + assert (token_hold_cancel.header.nodeid); + memcpy (&token_hold_cancel.ring_id, &instance->my_ring_id, sizeof (struct memb_ring_id)); @@ -2299,6 +2294,7 @@ static int token_hold_cancel_send (struct totemsrp_instance *instance) return (0); } +//AAA static int orf_token_send_initial (struct totemsrp_instance *instance) { @@ -2308,6 +2304,8 @@ static int orf_token_send_initial (struct totemsrp_instance *instance) orf_token.header.type = MESSAGE_TYPE_ORF_TOKEN; orf_token.header.endian_detector = ENDIAN_LOCAL; orf_token.header.encapsulated = 0; + orf_token.header.nodeid = instance->my_id.nodeid; + assert (orf_token.header.nodeid); orf_token.seq = 0; orf_token.seq = SEQNO_START_MSG; orf_token.token_seq = SEQNO_START_TOKEN; @@ -2324,7 +2322,8 @@ static int orf_token_send_initial (struct totemsrp_instance *instance) orf_token.aru = 0; orf_token.aru = SEQNO_START_MSG - 1; - orf_token.aru_addr.s_addr = instance->my_id.sin_addr.s_addr; + totemip_copy(&orf_token.aru_addr, &instance->my_id); + memcpy (&orf_token.ring_id, &instance->my_ring_id, sizeof (struct memb_ring_id)); orf_token.fcc = 0; @@ -2344,7 +2343,7 @@ static void memb_state_commit_token_update ( memb_index_this = (memb_commit_token->memb_index + 1) % memb_commit_token->addr_entries; memcpy (&memb_commit_token->memb_list[memb_index_this].ring_id, &instance->my_old_ring_id, sizeof (struct memb_ring_id)); -assert (instance->my_old_ring_id.rep.s_addr != 0); + assert (!totemip_zero_check(&instance->my_old_ring_id.rep)); memb_commit_token->memb_list[memb_index_this].aru = instance->old_ring_state_aru; /* @@ -2353,6 +2352,9 @@ assert (instance->my_old_ring_id.rep.s_addr != 0); */ memb_commit_token->memb_list[memb_index_this].high_delivered = instance->my_high_delivered; memb_commit_token->memb_list[memb_index_this].received_flg = instance->my_received_flg; + + memb_commit_token->header.nodeid = instance->my_id.nodeid; + assert (memb_commit_token->header.nodeid); } static int memb_state_commit_token_send (struct totemsrp_instance *instance, @@ -2371,27 +2373,27 @@ static int memb_state_commit_token_send (struct totemsrp_instance *instance, iovec.iov_base = memb_commit_token; iovec.iov_len = sizeof (struct memb_commit_token); - - instance->next_memb.sin_addr.s_addr = memb_commit_token->addr[memb_index_next].s_addr; - instance->next_memb.sin_family = AF_INET; - instance->next_memb.sin_port = instance->sockaddr_in_mcast.sin_port; + totemip_copy(&instance->next_memb, &memb_commit_token->addr[memb_index_next]); + assert (instance->next_memb.nodeid != 0); totemrrp_token_send (instance->totemrrp_handle, - &instance->next_memb.sin_addr, + &instance->next_memb, memb_commit_token, sizeof (struct memb_commit_token)); return (0); } + static int memb_lowest_in_config (struct totemsrp_instance *instance) { - struct in_addr token_memb[PROCESSOR_COUNT_MAX]; + struct totem_ip_address token_memb[PROCESSOR_COUNT_MAX]; int token_memb_entries = 0; - struct in_addr lowest_addr; + struct totem_ip_address lowest_addr; int i; - lowest_addr.s_addr = 0xFFFFFFFF; + memset(&lowest_addr, 0xff, sizeof(lowest_addr)); + lowest_addr.family = instance->mcast_address.family; memb_set_subtract (token_memb, &token_memb_entries, instance->my_proc_list, instance->my_proc_list_entries, @@ -2401,18 +2403,19 @@ static int memb_lowest_in_config (struct totemsrp_instance *instance) * find representative by searching for smallest identifier */ for (i = 0; i < token_memb_entries; i++) { - if (lowest_addr.s_addr > token_memb[i].s_addr) { - lowest_addr.s_addr = token_memb[i].s_addr; + if (totemip_compare(&lowest_addr, &token_memb[i]) > 0) { + totemip_copy(&lowest_addr, &token_memb[i]); } } - return (instance->my_id.sin_addr.s_addr == lowest_addr.s_addr); + return (totemip_equal(&instance->my_id, &lowest_addr)); } + static void memb_state_commit_token_create ( struct totemsrp_instance *instance, struct memb_commit_token *commit_token) { - struct in_addr token_memb[PROCESSOR_COUNT_MAX]; + struct totem_ip_address token_memb[PROCESSOR_COUNT_MAX]; int token_memb_entries = 0; instance->totemsrp_log_printf (instance->totemsrp_log_level_notice, @@ -2426,14 +2429,16 @@ static void memb_state_commit_token_create ( commit_token->header.type = MESSAGE_TYPE_MEMB_COMMIT_TOKEN; commit_token->header.endian_detector = ENDIAN_LOCAL; commit_token->header.encapsulated = 0; + commit_token->header.nodeid = instance->my_id.nodeid; + assert (commit_token->header.nodeid); - commit_token->ring_id.rep.s_addr = instance->my_id.sin_addr.s_addr; + totemip_copy(&commit_token->ring_id.rep, &instance->my_id); commit_token->ring_id.seq = instance->token_ring_id_seq + 4; qsort (token_memb, token_memb_entries, - sizeof (struct in_addr), in_addr_compare); + sizeof (struct totem_ip_address), totemip_compare); memcpy (commit_token->addr, token_memb, - token_memb_entries * sizeof (struct in_addr)); + token_memb_entries * sizeof (struct totem_ip_address)); memset (commit_token->memb_list, 0, sizeof (struct memb_commit_token_memb_entry) * PROCESSOR_COUNT_MAX); commit_token->memb_index = token_memb_entries - 1; @@ -2447,15 +2452,17 @@ static void memb_join_message_send (struct totemsrp_instance *instance) memb_join.header.type = MESSAGE_TYPE_MEMB_JOIN; memb_join.header.endian_detector = ENDIAN_LOCAL; memb_join.header.encapsulated = 0; + memb_join.header.nodeid = instance->my_id.nodeid; + assert (memb_join.header.nodeid); memb_join.ring_seq = instance->my_ring_id.seq; memcpy (memb_join.proc_list, instance->my_proc_list, - instance->my_proc_list_entries * sizeof (struct in_addr)); + instance->my_proc_list_entries * sizeof (struct totem_ip_address)); memb_join.proc_list_entries = instance->my_proc_list_entries; memcpy (memb_join.failed_list, instance->my_failed_list, - instance->my_failed_list_entries * sizeof (struct in_addr)); + instance->my_failed_list_entries * sizeof (struct totem_ip_address)); memb_join.failed_list_entries = instance->my_failed_list_entries; totemrrp_mcast_flush_send ( @@ -2471,6 +2478,9 @@ static void memb_merge_detect_transmit (struct totemsrp_instance *instance) memb_merge_detect.header.type = MESSAGE_TYPE_MEMB_MERGE_DETECT; memb_merge_detect.header.endian_detector = ENDIAN_LOCAL; memb_merge_detect.header.encapsulated = 0; + memb_merge_detect.header.nodeid = instance->my_id.nodeid; + assert (memb_merge_detect.header.nodeid); + memcpy (&memb_merge_detect.ring_id, &instance->my_ring_id, sizeof (struct memb_ring_id)); @@ -2489,7 +2499,7 @@ static void memb_ring_id_create_or_load ( char filename[256]; sprintf (filename, "/tmp/ringid_%s", - inet_ntoa (instance->my_id.sin_addr)); + totemip_print (&instance->my_id)); fd = open (filename, O_RDONLY, 0777); if (fd > 0) { res = read (fd, &memb_ring_id->seq, sizeof (unsigned long long)); @@ -2511,8 +2521,8 @@ static void memb_ring_id_create_or_load ( "Couldn't open %s %s\n", filename, strerror (errno)); } - memb_ring_id->rep.s_addr = instance->my_id.sin_addr.s_addr; - assert (memb_ring_id->rep.s_addr); + totemip_copy(&memb_ring_id->rep, &instance->my_id); + assert (!totemip_zero_check(&memb_ring_id->rep)); instance->token_ring_id_seq = memb_ring_id->seq; } @@ -2525,7 +2535,7 @@ static void memb_ring_id_store ( int res; sprintf (filename, "/tmp/ringid_%s", - inet_ntoa (instance->my_id.sin_addr)); + totemip_print (&instance->my_id)); fd = open (filename, O_WRONLY, 0777); if (fd == -1) { @@ -2668,7 +2678,7 @@ static void token_callbacks_execute ( */ static int message_handler_orf_token ( struct totemsrp_instance *instance, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len, int endian_conversion_needed) @@ -2736,11 +2746,11 @@ if (random()%100 < 10) { * Determine if we should hold (in reality drop) the token */ instance->my_token_held = 0; - if (instance->my_ring_id.rep.s_addr == instance->my_id.sin_addr.s_addr && + if (totemip_equal(&instance->my_ring_id.rep, &instance->my_id) && instance->my_seq_unchanged > instance->totem_config->seqno_unchanged_const) { instance->my_token_held = 1; } else - if (instance->my_ring_id.rep.s_addr != instance->my_id.sin_addr.s_addr && + if (!totemip_equal(&instance->my_ring_id.rep, &instance->my_id) && instance->my_seq_unchanged >= instance->totem_config->seqno_unchanged_const) { instance->my_token_held = 1; } @@ -2750,7 +2760,7 @@ if (random()%100 < 10) { * this processor is the ring rep */ forward_token = 1; - if (instance->my_ring_id.rep.s_addr == instance->my_id.sin_addr.s_addr) { + if (totemip_equal(&instance->my_ring_id.rep, &instance->my_id)) { if (instance->my_token_held) { forward_token = 0; } @@ -2823,24 +2833,24 @@ printf ("zero \n"); } mcasted = orf_token_mcast (instance, token, transmits_allowed, system_from); if (sq_lt_compare (instance->my_aru, token->aru) || - instance->my_id.sin_addr.s_addr == token->aru_addr.s_addr || - token->aru_addr.s_addr == 0) { + totemip_equal(&instance->my_id, &token->aru_addr) || + totemip_zero_check(&token->aru_addr)) { token->aru = instance->my_aru; if (token->aru == token->seq) { - token->aru_addr.s_addr = 0; + totemip_zero_set(&token->aru_addr); } else { - token->aru_addr.s_addr = instance->my_id.sin_addr.s_addr; + totemip_copy(&token->aru_addr, &instance->my_id); } } - if (token->aru == last_aru && token->aru_addr.s_addr != 0) { + if (token->aru == last_aru && !totemip_zero_check(&token->aru_addr)) { instance->my_aru_count += 1; } else { instance->my_aru_count = 0; } if (instance->my_aru_count > instance->totem_config->fail_to_recv_const && - token->aru_addr.s_addr != instance->my_id.sin_addr.s_addr) { + !totemip_equal(&token->aru_addr, &instance->my_id)) { printf ("FAILED TO RECEIVE\n"); // TODO if we fail to receive, it may be possible to end with a gather @@ -2898,7 +2908,7 @@ printf ("FAILED TO RECEIVE\n"); instance->my_received_flg = 1; instance->my_deliver_memb_entries = instance->my_trans_memb_entries; memcpy (instance->my_deliver_memb_list, instance->my_trans_memb_list, - sizeof (struct in_addr) * instance->my_trans_memb_entries); + sizeof (struct totem_ip_address) * instance->my_trans_memb_entries); } if (instance->my_retrans_flg_count >= 3 && token->aru >= instance->my_install_seq) { instance->my_rotation_counter += 1; @@ -2939,7 +2949,7 @@ printf ("I held %0.4f ms\n", ((float)tv_diff.tv_usec) / 100.0); */ reset_token_timeout (instance); // REVIEWED reset_token_retransmit_timeout (instance); // REVIEWED - if (instance->my_id.sin_addr.s_addr == instance->my_ring_id.rep.s_addr && + if (totemip_equal(&instance->my_id, &instance->my_ring_id.rep) && instance->my_token_held == 1) { start_token_hold_retransmit_timeout (instance); @@ -3019,9 +3029,6 @@ static void messages_deliver_to_app ( mcast = sort_queue_item_p->iovec[0].iov_base; assert (mcast != (struct mcast *)0xdeadbeef); -// XXX printf ("[%s.%d-%d]\n", inet_ntoa (mcast->source), -// XXX mcast->seq, mcast->this_seqno); - /* * Skip messages not originated in instance->my_deliver_memb */ @@ -3048,7 +3055,7 @@ static void messages_deliver_to_app ( if (sort_queue_item_p->iov_len > 1 && sort_queue_item_p->iovec[0].iov_len == sizeof (struct mcast)) { instance->totemsrp_deliver_fn ( - mcast->source, + &mcast->source, &sort_queue_item_p->iovec[1], sort_queue_item_p->iov_len - 1, mcast->header.endian_detector != ENDIAN_LOCAL); @@ -3057,7 +3064,7 @@ static void messages_deliver_to_app ( sort_queue_item_p->iovec[0].iov_base += sizeof (struct mcast); instance->totemsrp_deliver_fn ( - mcast->source, + &mcast->source, sort_queue_item_p->iovec, sort_queue_item_p->iov_len, mcast->header.endian_detector != ENDIAN_LOCAL); @@ -3082,7 +3089,7 @@ static void messages_deliver_to_app ( */ static int message_handler_mcast ( struct totemsrp_instance *instance, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len, int endian_conversion_needed) @@ -3116,10 +3123,11 @@ if (random()%100 < 50) { return (0); } #endif - if (system_from->s_addr != instance->my_id.sin_addr.s_addr) { + if (!totemip_equal(system_from, &instance->my_id)) { cancel_token_retransmit_timeout (instance); } + assert (system_from->nodeid != 0); /* * If the message is foreign execute the switch below */ @@ -3159,7 +3167,7 @@ if (random()%100 < 50) { instance->totemsrp_log_printf (instance->totemsrp_log_level_debug, "Received ringid(%s:%lld) seq %x\n", - inet_ntoa (mcast_header.ring_id.rep), + totemip_print (&mcast_header.ring_id.rep), mcast_header.ring_id.seq, mcast_header.seq); @@ -3204,7 +3212,7 @@ if (random()%100 < 50) { static int message_handler_memb_merge_detect ( struct totemsrp_instance *instance, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len, int endian_conversion_needed) @@ -3220,6 +3228,7 @@ static int message_handler_memb_merge_detect ( return (0); } + assert (system_from->nodeid != 0); /* * Execute merge operation */ @@ -3257,7 +3266,7 @@ static int message_handler_memb_merge_detect ( static int memb_join_process ( struct totemsrp_instance *instance, struct memb_join *memb_join, - struct in_addr *system_from) + struct totem_ip_address *system_from) { struct memb_commit_token my_commit_token; @@ -3304,7 +3313,7 @@ static int memb_join_process ( memb_join->proc_list_entries, instance->my_proc_list, &instance->my_proc_list_entries); - if (memb_set_subset (&instance->my_id.sin_addr, 1, + if (memb_set_subset (&instance->my_id, 1, memb_join->failed_list, memb_join->failed_list_entries)) { memb_set_merge (system_from, 1, @@ -3326,14 +3335,17 @@ static void memb_join_endian_convert (struct memb_join *in, struct memb_join *ou out->header.type = in->header.type; out->header.endian_detector = ENDIAN_LOCAL; + out->header.nodeid = swab32 (in->header.nodeid); out->proc_list_entries = swab32 (in->proc_list_entries); out->failed_list_entries = swab32 (in->failed_list_entries); out->ring_seq = swab64 (in->ring_seq); for (i = 0; i < out->proc_list_entries; i++) { - out->proc_list[i].s_addr = in->proc_list[i].s_addr; + totemip_copy(&out->proc_list[i], &in->proc_list[i]); + out->proc_list[i].family = swab16(out->proc_list[i].family); } for (i = 0; i < out->failed_list_entries; i++) { - out->failed_list[i].s_addr = in->failed_list[i].s_addr; + totemip_copy(&out->failed_list[i], &in->failed_list[i]); + out->failed_list[i].family = swab16(out->failed_list[i].family); } } @@ -3343,16 +3355,21 @@ static void memb_commit_token_endian_convert (struct memb_commit_token *in, stru out->header.type = in->header.type; out->header.endian_detector = ENDIAN_LOCAL; + out->header.nodeid = swab32 (in->header.nodeid); out->token_seq = swab32 (in->token_seq); - out->ring_id.rep.s_addr = in->ring_id.rep.s_addr; + totemip_copy(&out->ring_id.rep, &in->ring_id.rep); out->ring_id.seq = swab64 (in->ring_id.seq); out->retrans_flg = swab32 (in->retrans_flg); out->memb_index = swab32 (in->memb_index); out->addr_entries = swab32 (in->addr_entries); for (i = 0; i < out->addr_entries; i++) { - out->addr[i].s_addr = in->addr[i].s_addr; - out->memb_list[i].ring_id.rep.s_addr = - in->memb_list[i].ring_id.rep.s_addr; + totemip_copy(&out->addr[i], &in->addr[i]); + out->addr[i].family = swab16(in->addr[i].family); + + totemip_copy(&out->memb_list[i].ring_id.rep, + &in->memb_list[i].ring_id.rep); + out->memb_list[i].ring_id.rep.family = swab16(in->memb_list[i].ring_id.rep.family); + out->memb_list[i].ring_id.seq = swab64 (in->memb_list[i].ring_id.seq); out->memb_list[i].aru = swab32 (in->memb_list[i].aru); @@ -3367,16 +3384,20 @@ static void orf_token_endian_convert (struct orf_token *in, struct orf_token *ou out->header.type = in->header.type; out->header.endian_detector = ENDIAN_LOCAL; + out->header.nodeid = swab32 (in->header.nodeid); out->seq = swab32 (in->seq); out->token_seq = swab32 (in->token_seq); out->aru = swab32 (in->aru); - out->ring_id.rep.s_addr = in->ring_id.rep.s_addr; + totemip_copy(&out->ring_id.rep, &in->ring_id.rep); + out->ring_id.rep.family = swab16(in->ring_id.rep.family); + out->ring_id.seq = swab64 (in->ring_id.seq); out->fcc = swab32 (in->fcc); out->retrans_flg = swab32 (in->retrans_flg); out->rtr_list_entries = swab32 (in->rtr_list_entries); for (i = 0; i < out->rtr_list_entries; i++) { - out->rtr_list[i].ring_id.rep.s_addr = in->rtr_list[i].ring_id.rep.s_addr; + totemip_copy(&out->rtr_list[i].ring_id.rep, &in->rtr_list[i].ring_id.rep); + out->rtr_list[i].ring_id.rep.family = swab16(in->rtr_list[i].ring_id.rep.family); out->rtr_list[i].ring_id.seq = swab64 (in->rtr_list[i].ring_id.seq); out->rtr_list[i].seq = swab32 (in->rtr_list[i].seq); } @@ -3386,8 +3407,10 @@ static void mcast_endian_convert (struct mcast *in, struct mcast *out) { out->header.type = in->header.type; out->header.endian_detector = ENDIAN_LOCAL; + out->header.nodeid = swab32 (in->header.nodeid); out->seq = swab32 (in->seq); - out->ring_id.rep.s_addr = in->ring_id.rep.s_addr; + totemip_copy(&out->ring_id.rep, &in->ring_id.rep); + out->ring_id.rep.family = swab16(in->ring_id.rep.family); out->ring_id.seq = swab64 (in->ring_id.seq); out->source = in->source; out->guarantee = in->guarantee; @@ -3395,7 +3418,7 @@ static void mcast_endian_convert (struct mcast *in, struct mcast *out) static int message_handler_memb_join ( struct totemsrp_instance *instance, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len, int endian_conversion_needed) @@ -3412,6 +3435,11 @@ static int message_handler_memb_join ( memb_join = (struct memb_join *)msg; } + memb_set_merge(memb_join->proc_list, memb_join->proc_list_entries, + instance->my_nodeid_lookup_list, &instance->my_nodeid_lookup_entries); + + assert (system_from->nodeid != 0); + if (instance->token_ring_id_seq < memb_join->ring_seq) { instance->token_ring_id_seq = memb_join->ring_seq; } @@ -3462,14 +3490,14 @@ static int message_handler_memb_join ( static int message_handler_memb_commit_token ( struct totemsrp_instance *instance, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len, int endian_conversion_needed) { struct memb_commit_token memb_commit_token_convert; struct memb_commit_token *memb_commit_token; - struct in_addr sub[PROCESSOR_COUNT_MAX]; + struct totem_ip_address sub[PROCESSOR_COUNT_MAX]; int sub_entries; @@ -3527,7 +3555,7 @@ if (random()%100 < 10) { instance->totemsrp_log_printf (instance->totemsrp_log_level_notice, "Sending initial ORF token\n"); - if (instance->my_id.sin_addr.s_addr == instance->my_ring_id.rep.s_addr) { + if (totemip_equal(&instance->my_id, &instance->my_ring_id.rep)) { // TODO convert instead of initiate orf_token_send_initial (instance); reset_token_timeout (instance); // REVIEWED @@ -3540,7 +3568,7 @@ if (random()%100 < 10) { static int message_handler_token_hold_cancel ( struct totemsrp_instance *instance, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len, int endian_conversion_needed) @@ -3551,7 +3579,7 @@ static int message_handler_token_hold_cancel ( sizeof (struct memb_ring_id)) == 0) { instance->my_seq_unchanged = 0; - if (instance->my_ring_id.rep.s_addr == instance->my_id.sin_addr.s_addr) { + if (totemip_equal(&instance->my_ring_id.rep, &instance->my_id)) { timer_function_token_retransmit_timeout (instance); } } @@ -3560,7 +3588,7 @@ static int message_handler_token_hold_cancel ( void main_deliver_fn ( void *context, - struct in_addr *system_from, + struct totem_ip_address *system_from, void *msg, int msg_len) { @@ -3572,6 +3600,9 @@ void main_deliver_fn ( return; } + system_from->nodeid = message_header->nodeid; + assert (system_from->nodeid != 0); + /* * Handle incoming message */ @@ -3585,15 +3616,14 @@ void main_deliver_fn ( void main_iface_change_fn ( void *context, - struct sockaddr_in *iface_sockaddr_in) + struct totem_ip_address *iface_addr) { struct totemsrp_instance *instance = (struct totemsrp_instance *)context; - memcpy (&instance->my_id, - iface_sockaddr_in, - sizeof (struct sockaddr_in)); - memcpy (&instance->my_memb_list[0], - &iface_sockaddr_in->sin_addr, - sizeof (struct in_addr)); + + totemip_copy (&instance->my_id, iface_addr); + assert (instance->my_id.nodeid); + + totemip_copy (&instance->my_memb_list[0], iface_addr); if (instance->first_run++ == 0) { memb_ring_id_create_or_load (instance, &instance->my_ring_id); @@ -3601,11 +3631,10 @@ void main_iface_change_fn ( instance->totemsrp_log_level_notice, "Created or loaded sequence id %lld.%s for this ring.\n", instance->my_ring_id.seq, - inet_ntoa (instance->my_ring_id.rep)); + totemip_print (&instance->my_ring_id.rep)); } memb_state_gather_enter (instance); - } void totemsrp_net_mtu_adjust (struct totem_config *totem_config) { diff --git a/exec/totemsrp.h b/exec/totemsrp.h index f8361c69..c094614b 100644 --- a/exec/totemsrp.h +++ b/exec/totemsrp.h @@ -58,15 +58,15 @@ int totemsrp_initialize ( struct totem_config *totem_config, void (*deliver_fn) ( - struct in_addr source_addr, + struct totem_ip_address *source_addr, struct iovec *iovec, int iov_len, int endian_conversion_required), void (*confchg_fn) ( enum totem_configuration_type configuration_type, - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries, + struct totem_ip_address *member_list, int member_list_entries, + struct totem_ip_address *left_list, int left_list_entries, + struct totem_ip_address *joined_list, int joined_list_entries, struct memb_ring_id *ring_id)); void totemsrp_finalize (totemsrp_handle handle); @@ -99,8 +99,6 @@ void totemsrp_callback_token_destroy ( int totemsrp_new_msg_signal (totemsrp_handle handle); -extern struct sockaddr_in config_mcast_addr; - extern void totemsrp_net_mtu_adjust (struct totem_config *totem_config); #endif /* TOTEMSRP_H_DEFINED */ diff --git a/include/evs.h b/include/evs.h index 3f0915ec..d0b30092 100644 --- a/include/evs.h +++ b/include/evs.h @@ -67,19 +67,28 @@ typedef enum { EVS_ERR_TOO_MANY_GROUPS=30 } evs_error_t; +#define TOTEMIP_ADDRLEN (sizeof(struct in6_addr)) + +/* These are the things that get passed around */ +struct evs_address { + unsigned int nodeid; + unsigned short family; + unsigned char addr[TOTEMIP_ADDRLEN]; +}; + struct evs_group { char key[32]; }; typedef void (*evs_deliver_fn_t) ( - struct in_addr source_addr, + struct evs_address *source_addr, void *msg, int msg_len); typedef void (*evs_confchg_fn_t) ( - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries); + struct evs_address *member_list, int member_list_entries, + struct evs_address *left_list, int left_list_entries, + struct evs_address *joined_list, int joined_list_entries); typedef struct { evs_deliver_fn_t evs_deliver_fn; @@ -162,8 +171,8 @@ evs_error_t evs_mcast_groups ( */ evs_error_t evs_membership_get ( evs_handle_t handle, - struct in_addr *local_addr, - struct in_addr *member_list, + struct evs_address *local_addr, + struct evs_address *member_list, int *member_list_entries); #endif /* OPENAIS_EVS_H_DEFINED */ diff --git a/include/ipc_evs.h b/include/ipc_evs.h index 2cc56128..818bad35 100644 --- a/include/ipc_evs.h +++ b/include/ipc_evs.h @@ -34,7 +34,7 @@ #ifndef IPC_EVS_H_DEFINED #define IPC_EVS_H_DEFINED -#include +//#include #include "saAis.h" #include "evs.h" #include "ipc_gen.h" @@ -59,7 +59,7 @@ enum res_lib_evs_types { struct res_evs_deliver_callback { struct res_header header; - struct in_addr source_addr; + struct evs_address evs_address; int msglen; char msg[0]; }; @@ -69,9 +69,9 @@ struct res_evs_confchg_callback { int member_list_entries; int left_list_entries; int joined_list_entries; - struct in_addr member_list[16]; - struct in_addr left_list[16]; - struct in_addr joined_list[16]; + struct evs_address member_list[16]; + struct evs_address left_list[16]; + struct evs_address joined_list[16]; }; struct req_lib_evs_join { diff --git a/include/ipc_evt.h b/include/ipc_evt.h index 320a76a3..d4439c46 100644 --- a/include/ipc_evt.h +++ b/include/ipc_evt.h @@ -252,7 +252,7 @@ struct res_evt_event_data { * MESSAGE_REQ_EXEC_EVT_RECOVERY_EVENTDATA (4) * * led_head: Request/Results head - * led_in_addr: address of node (4 only) + * led_addr: address of node (4 only) * led_receive_time: Time that the message was received (4 only) * led_svr_channel_handle: Server channel handle (1 only) * led_lib_channel_handle: Lib channel handle (2 only) @@ -273,7 +273,7 @@ struct res_evt_event_data { */ struct lib_event_data { struct res_header led_head; - struct in_addr led_in_addr; + struct totem_ip_address led_addr; SaTimeT led_receive_time; uint32_t led_svr_channel_handle; SaEvtChannelHandleT led_lib_channel_handle; @@ -359,7 +359,7 @@ enum evt_chan_ops { * based on the highest ID seen by any of the members */ struct evt_set_id { - struct in_addr chc_addr; + unsigned int chc_nodeid; uint64_t chc_last_id; }; diff --git a/include/ipc_gen.h b/include/ipc_gen.h index cd634220..935c3bac 100644 --- a/include/ipc_gen.h +++ b/include/ipc_gen.h @@ -35,6 +35,7 @@ #define IPC_GEN_H_DEFINED #include +#include "../exec/totemip.h" enum service_types { EVS_SERVICE = 0, @@ -111,7 +112,7 @@ struct res_lib_dispatch_init { }; struct message_source { struct conn_info *conn_info; - struct in_addr in_addr; + struct totem_ip_address addr; } __attribute__((packed)); #endif /* IPC_GEN_H_DEFINED */ diff --git a/lib/evs.c b/lib/evs.c index 2f54c33e..b24e29a9 100644 --- a/lib/evs.c +++ b/lib/evs.c @@ -292,7 +292,7 @@ evs_error_t evs_dispatch ( case MESSAGE_RES_EVS_DELIVER_CALLBACK: res_evs_deliver_callback = (struct res_evs_deliver_callback *)&dispatch_data; callbacks.evs_deliver_fn ( - res_evs_deliver_callback->source_addr, + &res_evs_deliver_callback->evs_address, &res_evs_deliver_callback->msg, res_evs_deliver_callback->msglen); break; @@ -540,8 +540,8 @@ error_exit: evs_error_t evs_membership_get ( evs_handle_t handle, - struct in_addr *local_addr, - struct in_addr *member_list, + struct evs_address *local_addr, + struct evs_address *member_list, int *member_list_entries) { evs_error_t error; diff --git a/man/evs_initialize.3 b/man/evs_initialize.3 index db37b2eb..8354aaca 100644 --- a/man/evs_initialize.3 +++ b/man/evs_initialize.3 @@ -61,14 +61,14 @@ is called. The callback functions are described by the following type definitio .nf .ta 4n 20n 32n typedef void (*evs_deliver_fn_t) ( - struct in_addr source_addr, + struct evs_address source_addr, void *msg, int msg_len); typedef void (*evs_confchg_fn_t) ( - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries); + struct evs_address *member_list, int member_list_entries, + struct evs_address *left_list, int left_list_entries, + struct evs_address *joined_list, int joined_list_entries); .ta .fi .RE @@ -101,6 +101,27 @@ is called. If a delivery of a message occurs, .I evs_deliver_fn is called. +The +.I evs_address +structure is defined +.IP +.RS +.ne 18 +.nf +.PP +struct evs_address { + unsigned int nodeid; + unsigned short family; + unsigned char addr[TOTEMIP_ADDRLEN]; +}; +.ta +.fi +.RE +.IP +.PP +where nodeid is a 32 bit unique node identifier, family is of the value AF_INET for an IPV4 network, or AF_INET6 for an IPV6 network, and addr is a 32 bit address for an IPV4 network, or 128 bit address for an IPV6 network. + + .SH RETURN VALUE This call returns the EVS_OK value if successful, otherwise an error is returned. .PP diff --git a/man/evs_membership_get.3 b/man/evs_membership_get.3 index 20ca89eb..b6b4bb8f 100644 --- a/man/evs_membership_get.3 +++ b/man/evs_membership_get.3 @@ -37,14 +37,15 @@ evs_join \- Joins one or more groups in the EVS library .SH SYNOPSIS .B #include .sp -.BI "int evs_membership_get(evs_handle_t " handle ", struct in_addr *" local_addr ", struct in_addr *" member_list ", int *" member_list_entries "); +.BI "int evs_membership_get(evs_handle_t " handle ", struct evs_address *" local_addr ", struct evs_address *" member_list ", int *" member_list_entries "); .SH DESCRIPTION The .B evs_membership_get function is used to determine the current processors in the configuration and also the local processor identifier. The argument -.I handle is used to reference the evs instantiation. +.I handle +is used to reference the evs instantiation. The argument .I local_addr will return the local address of the processor. diff --git a/man/openais.conf.5 b/man/openais.conf.5 index 752b903a..49aa6591 100644 --- a/man/openais.conf.5 +++ b/man/openais.conf.5 @@ -71,6 +71,12 @@ Multiple bindnetaddr directives may be specified. When multiple bindnetaddr directives are specified, the totem redundant ring protocol will use multiple interfaces to replicate the network traffic. +This may also be an IPV6 address, in which case IPV6 networking will be used. +In this case, the full address must be specified and there is no automatic +selection of the network interface within a specific subnet as with IPv4. + +If IPv6 networking is used, the nodeid field must be specified. + .TP mcastaddr This is the multicast address used by openais executive. The default @@ -78,12 +84,24 @@ should work for most networks, but the network administrator should be queried about a multicast address to use. Avoid 224.x.x.x because this is a "config" multicast address. +This may also be an IPV6 multicast address, in which case IPV6 networking +will be used. If IPv6 networking is used, the nodeid field must be specified. + .TP mcastport This specifies the UDP port number. It is possible to use the same multicast address on a network with the openais services configured for different UDP ports. +.TP +nodeid +This configuration option is optional when using IPv4 and required when using +IPv6. This is a 32 bit value specifying the node identifier delivered to the +cluster membership service. If this is not specified with IPv4, the node id +will be determined from the 32 bit IP address the system is bound to. + +The node identifier value of zero is reserved and should not be used. + .PP Within the .B totem diff --git a/man/openais_overview.8 b/man/openais_overview.8 index 485244d3..bb57460e 100644 --- a/man/openais_overview.8 +++ b/man/openais_overview.8 @@ -41,7 +41,7 @@ faults. The API consists of Availability Management Framework (AMF) which provides application failover, Cluster Membership (CLM), Checkpointing (CKPT), Eventing (EVT), Messaging (MSG), and Distributed Locking (DLOCK). -Currently Messaging and Distributed Locking are unimplemented. +Currently Messaging is unimplemented. Faults occur for various reasons: .PP @@ -169,6 +169,26 @@ of the makefile. -lais Specify this to get access to all AIS libraries without specifying each library individually. +.SH IPv6 +The openais project supports both IPv4 and IPv6 network addresses. The entire +cluster must use either IPv4 or IPv6 for the cluster communication mechanism. +In order to use IPv6, IPv6 addresses must be specified in the bindnetaddr and +mcastaddr fields in the configuration file. The nodeid field must also be +set. + +An example of this is: +nodeid: 2 +bindnetaddr: fec0::1:a800:4ff:fe00:20 +mcastaddr: ff05::1 + +To configure a host for IPv6, use the ifconfig program to add interfaces: +box20: ifconfig eth0 add fec0::1:a800:4ff:fe00:20/64 +box30: ifconfig eth0 add fec0::1:a800:4ff:fe00:30/64 + +If the /64 is not specified, a route for the IPv6 network will not be configured +which will cause significant problems. Make sure a route is available for +IPv6 traffic. + .SH ARCHITECTURE The AIS libraries are a thin IPC interface to the openais executive. The openais executive provides services for the SA Forum AIS libraries as well @@ -186,18 +206,16 @@ authenticate all messages. The openais executive library uses SOBER-128 as a pseudo random number generator. The EVS library feeds the PRNG using the /dev/random Linux device. .PP +.SH SAFTEST COMPLIANCE +The openais libraries are now nearly compliant with every aspect of the SA +Forum's AIS specification. The AMF service, however, is not compliant with the +B.01.01 specification. The remaining services pass most of the tests of the +saftest suite against the B.01.01 specification. + .SH BUGS -The openais libraries are not particularly compliant with every aspect of the -SA Forum's AIS specification. The APIs themselves are consistent, but some of -the return values and other details are not quite right yet. The project does -intend to be fully compliant with SAF specifications in 2005. +The openais project does not currently implement the messaging service. +The distributed locking service is buggy and incomplete. -The AMF that is currently available is AMF A.01.01. The rest of the services -are of the B.01.01 specification. This is a limitation for those developers that -desire AMF B.01.01. The project intends to resolve this inconsistently in 2005. - -The openais project does not currently implement the messaging service or -distributed locking service. .SH "SEE ALSO" .BR openais.conf (5), .BR evs_overview (8) diff --git a/test/evsbench.c b/test/evsbench.c index 7cccd4ab..f95f9a37 100644 --- a/test/evsbench.c +++ b/test/evsbench.c @@ -58,32 +58,39 @@ int outstanding = 0; -void evs_deliver_fn (struct in_addr source_addr, void *msg, int msg_len) +void evs_deliver_fn (struct evs_address *source_addr, void *msg, int msg_len) { outstanding--; // printf ("Delivering message %s\n", msg); } void evs_confchg_fn ( - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries) + struct evs_address *member_list, int member_list_entries, + struct evs_address *left_list, int left_list_entries, + struct evs_address *joined_list, int joined_list_entries) { int i; + char buf[1024]; printf ("CONFIGURATION CHANGE\n"); printf ("--------------------\n"); printf ("New configuration\n"); for (i = 0; i < member_list_entries; i++) { - printf ("%s\n", inet_ntoa (member_list[i])); + inet_ntop (member_list[i].family, member_list[i].addr, + buf, sizeof (buf)); + printf ("%s\n", buf); } printf ("Members Left:\n"); for (i = 0; i < left_list_entries; i++) { - printf ("%s\n", inet_ntoa (left_list[i])); + inet_ntop (left_list[i].family, left_list[i].addr, + buf, sizeof (buf)); + printf ("%s\n", buf); } printf ("Members Joined:\n"); for (i = 0; i < joined_list_entries; i++) { - printf ("%s\n", inet_ntoa (joined_list[i])); + inet_ntop (joined_list[i].family, joined_list[i].addr, + buf, sizeof (buf)); + printf ("%s\n", buf); } } diff --git a/test/testevs.c b/test/testevs.c index 743295dd..555fb0be 100644 --- a/test/testevs.c +++ b/test/testevs.c @@ -42,7 +42,7 @@ char *delivery_string; int deliveries = 0; -void evs_deliver_fn (struct in_addr source_addr, void *msg, int msg_len) +void evs_deliver_fn (struct evs_address *source_addr, void *msg, int msg_len) { char *buf = msg; @@ -53,25 +53,32 @@ void evs_deliver_fn (struct in_addr source_addr, void *msg, int msg_len) } void evs_confchg_fn ( - struct in_addr *member_list, int member_list_entries, - struct in_addr *left_list, int left_list_entries, - struct in_addr *joined_list, int joined_list_entries) + struct evs_address *member_list, int member_list_entries, + struct evs_address *left_list, int left_list_entries, + struct evs_address *joined_list, int joined_list_entries) { int i; + char buf[256]; printf ("CONFIGURATION CHANGE\n"); printf ("--------------------\n"); printf ("New configuration\n"); for (i = 0; i < member_list_entries; i++) { - printf ("%s\n", inet_ntoa (member_list[i])); + inet_ntop (member_list[i].family, member_list[i].addr, + buf, sizeof (buf)); + printf ("%s\n", buf); } printf ("Members Left:\n"); for (i = 0; i < left_list_entries; i++) { - printf ("%s\n", inet_ntoa (left_list[i])); + inet_ntop (left_list[i].family, left_list[i].addr, + buf, sizeof (buf)); + printf ("%s\n", buf); } printf ("Members Joined:\n"); for (i = 0; i < joined_list_entries; i++) { - printf ("%s\n", inet_ntoa (joined_list[i])); + inet_ntop (joined_list[i].family, joined_list[i].addr, + buf, sizeof (buf)); + printf ("%s\n", buf); } } @@ -98,9 +105,10 @@ int main (void) evs_error_t result; int i = 0; int fd; - struct in_addr member_list[16]; - struct in_addr local_addr; + struct evs_address member_list[16]; + struct evs_address local_addr; int member_list_entries = sizeof (member_list) / sizeof (struct in_addr); + char buf[1024]; result = evs_initialize (&handle, &callbacks); if (result != EVS_OK) { @@ -108,12 +116,18 @@ int main (void) exit (0); } - result = evs_membership_get (handle, &local_addr, member_list, &member_list_entries); - printf ("Current membership from evs_membership_get entries %d\n", member_list_entries); + result = evs_membership_get (handle, &local_addr, + member_list, &member_list_entries); + printf ("Current membership from evs_membership_get entries %d\n", + member_list_entries); for (i = 0; i < member_list_entries; i++) { - printf ("Member [%d] is %s\n", i, inet_ntoa (member_list[i])); + inet_ntop (member_list[i].family, member_list[i].addr, + buf, sizeof (buf)); + printf ("member [%d] is %s\n", i, buf); } - printf ("local processor from evs_membership_get %s\n", inet_ntoa (local_addr)); + inet_ntop (local_addr.family, local_addr.addr, + buf, sizeof (buf)); + printf ("local processor from evs_membership_get %s\n", buf); printf ("Init result %d\n", result); result = evs_join (handle, groups, 3); @@ -137,7 +151,7 @@ try_again_one: result = evs_mcast_joined (handle, EVS_TYPE_AGREED, &iov, 1); if (result == EVS_ERR_TRY_AGAIN) { -printf ("try again\n"); +//printf ("try again\n"); goto try_again_one; } result = evs_dispatch (handle, EVS_DISPATCH_ALL);