mirror of
https://git.proxmox.com/git/mirror_corosync
synced 2025-08-04 19:21:48 +00:00
Use memb_ring_id_copy for alignment purposes on 64 aligned arches and keep
the port id in host byte order until it is used in the totem protocol stack. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1164 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
parent
b11d49db6b
commit
afb4ca0606
@ -55,7 +55,6 @@
|
||||
#include "totemip.h"
|
||||
#include "totem.h"
|
||||
#include "vsf.h"
|
||||
#include "swab.h"
|
||||
#include "../lcr/lcr_ifact.h"
|
||||
#include "print.h"
|
||||
|
||||
@ -202,7 +201,7 @@ void sync_callbacks_load (void)
|
||||
res = sync_callbacks_retrieve (sync_recovery_index, &sync_callbacks);
|
||||
/*
|
||||
* No more service handlers have sync callbacks at this time
|
||||
` */
|
||||
*/
|
||||
if (res == -1) {
|
||||
sync_processing = 0;
|
||||
break;
|
||||
@ -345,10 +344,8 @@ static struct memb_ring_id deliver_ring_id;
|
||||
|
||||
void sync_endian_convert (struct req_exec_sync_barrier_start *req_exec_sync_barrier_start)
|
||||
{
|
||||
totemip_copy_endian_convert(&req_exec_sync_barrier_start->ring_id.rep,
|
||||
&req_exec_sync_barrier_start->ring_id.rep);
|
||||
req_exec_sync_barrier_start->ring_id.seq = swab64 (req_exec_sync_barrier_start->ring_id.seq);
|
||||
|
||||
/* XXX no swab on mar_req_header_t? */
|
||||
swab_memb_ring_id_t (&req_exec_sync_barrier_start->ring_id);
|
||||
}
|
||||
|
||||
static void sync_deliver_fn (
|
||||
|
22
exec/totem.h
22
exec/totem.h
@ -34,6 +34,7 @@
|
||||
#ifndef TOTEM_H_DEFINED
|
||||
#define TOTEM_H_DEFINED
|
||||
#include "totemip.h"
|
||||
#include "../include/swab.h"
|
||||
|
||||
#define MESSAGE_SIZE_MAX 1024*1024 /* (1MB) */
|
||||
#define PROCESSOR_COUNT_MAX 384
|
||||
@ -160,5 +161,26 @@ struct memb_ring_id {
|
||||
unsigned long long seq;
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef struct memb_ring_id memb_ring_id_t;
|
||||
|
||||
static inline void swab_memb_ring_id_t (memb_ring_id_t *to_swab)
|
||||
{
|
||||
swab_totem_ip_address_t (&to_swab->rep);
|
||||
to_swab->seq = swab64 (to_swab->seq);
|
||||
}
|
||||
|
||||
static inline void memb_ring_id_copy(
|
||||
memb_ring_id_t *out, memb_ring_id_t *in)
|
||||
{
|
||||
totemip_copy (&out->rep, &in->rep);
|
||||
out->seq = in->seq;
|
||||
}
|
||||
|
||||
static inline void memb_ring_id_copy_endian_convert(
|
||||
memb_ring_id_t *out, memb_ring_id_t *in)
|
||||
{
|
||||
totemip_copy_endian_convert (&out->rep, &in->rep);
|
||||
out->seq = swab64 (in->seq);
|
||||
}
|
||||
|
||||
#endif /* TOTEM_H_DEFINED */
|
||||
|
@ -235,7 +235,7 @@ extern int totem_config_read (
|
||||
* Get mcast port
|
||||
*/
|
||||
if (!objdb_get_string (objdb, object_interface_handle, "mcastport", &str)) {
|
||||
totem_config->interfaces[ringnumber].ip_port = htons (atoi (str));
|
||||
totem_config->interfaces[ringnumber].ip_port = atoi (str);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -213,7 +213,7 @@ int totemip_totemip_to_sockaddr_convert(struct totem_ip_address *ip_addr,
|
||||
sin->sin_len = sizeof(struct sockaddr_in);
|
||||
#endif
|
||||
sin->sin_family = ip_addr->family;
|
||||
sin->sin_port = port;
|
||||
sin->sin_port = htons (port);
|
||||
memcpy(&sin->sin_addr, ip_addr->addr, sizeof(struct in_addr));
|
||||
*addrlen = sizeof(struct sockaddr_in);
|
||||
ret = 0;
|
||||
@ -227,7 +227,7 @@ int totemip_totemip_to_sockaddr_convert(struct totem_ip_address *ip_addr,
|
||||
sin->sin6_len = sizeof(struct sockaddr_in6);
|
||||
#endif
|
||||
sin->sin6_family = ip_addr->family;
|
||||
sin->sin6_port = port;
|
||||
sin->sin6_port = htons (port);
|
||||
sin->sin6_scope_id = 2;
|
||||
memcpy(&sin->sin6_addr, ip_addr->addr, sizeof(struct in6_addr));
|
||||
|
||||
@ -239,8 +239,8 @@ int totemip_totemip_to_sockaddr_convert(struct totem_ip_address *ip_addr,
|
||||
}
|
||||
|
||||
/* Converts an address string string into a totem_ip_address.
|
||||
family can be AF_INET, AF_INET6 or 0 ("for "don't care")
|
||||
*/
|
||||
* family can be AF_INET, AF_INET6 or 0 (for "don't care")
|
||||
*/
|
||||
int totemip_parse(struct totem_ip_address *totemip, char *addr, int family)
|
||||
{
|
||||
struct addrinfo *ainfo;
|
||||
@ -268,6 +268,8 @@ int totemip_parse(struct totem_ip_address *totemip, char *addr, int family)
|
||||
else
|
||||
memcpy(totemip->addr, &sa6->sin6_addr, sizeof(struct in6_addr));
|
||||
|
||||
freeaddrinfo(ainfo);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2005 Red Hat Inc
|
||||
* Author: Patrick Caulfield (pcaulfie@redhat.com)
|
||||
*
|
||||
* Copyright (c) 2006 Sun Microsystems, 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
|
||||
@ -37,9 +38,13 @@
|
||||
#ifndef TOTEMIP_H_DEFINED
|
||||
#define TOTEMIP_H_DEFINED
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "../include/swab.h"
|
||||
|
||||
#ifdef SO_NOSIGPIPE
|
||||
#ifndef MSG_NOSIGNAL
|
||||
#define MSG_NOSIGNAL 0
|
||||
@ -56,9 +61,16 @@ struct totem_ip_address
|
||||
{
|
||||
unsigned int nodeid;
|
||||
unsigned short family;
|
||||
unsigned char addr[TOTEMIP_ADDRLEN];
|
||||
unsigned char addr[TOTEMIP_ADDRLEN]; /* in Network Byteorder */
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef struct totem_ip_address totem_ip_address_t;
|
||||
|
||||
static inline void swab_totem_ip_address_t (totem_ip_address_t *to_swab)
|
||||
{
|
||||
to_swab->nodeid = swab32 (to_swab->nodeid);
|
||||
to_swab->family = swab16 (to_swab->family);
|
||||
}
|
||||
|
||||
extern int totemip_equal(struct totem_ip_address *addr1, struct totem_ip_address *addr2);
|
||||
extern int totemip_compare(const void *a, const void *b);
|
||||
@ -83,4 +95,13 @@ static inline int totemip_zero_check(struct totem_ip_address *addr)
|
||||
return (addr->family == 0);
|
||||
}
|
||||
|
||||
static inline unsigned int totemip_compute_nodeid_from_addr(
|
||||
const struct totem_ip_address *addr)
|
||||
{
|
||||
struct in_addr *in = (struct in_addr *)addr->addr;
|
||||
assert(addr->family == AF_INET);
|
||||
|
||||
return (unsigned int)ntohl(in->s_addr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -704,7 +704,7 @@ static int netif_determine (
|
||||
* field is only 32 bits.
|
||||
*/
|
||||
if (bound_to->family == AF_INET && bound_to->nodeid == 0) {
|
||||
memcpy (&bound_to->nodeid, bound_to->addr, sizeof (int));
|
||||
bound_to->nodeid = totemip_compute_nodeid_from_addr(bound_to);
|
||||
}
|
||||
|
||||
return (res);
|
||||
|
@ -2206,7 +2206,7 @@ static int orf_token_mcast (
|
||||
memcpy (&sort_queue_item.iovec[1], message_item->iovec,
|
||||
message_item->iov_len * sizeof (struct iovec));
|
||||
|
||||
memcpy (&mcast->ring_id, &instance->my_ring_id, sizeof (struct memb_ring_id));
|
||||
memb_ring_id_copy (&mcast->ring_id, &instance->my_ring_id);
|
||||
|
||||
sort_queue_item.iov_len = message_item->iov_len + 1;
|
||||
|
||||
@ -2357,8 +2357,9 @@ static int orf_token_rtr (
|
||||
/*
|
||||
* Missing message not found in current retransmit list so add it
|
||||
*/
|
||||
memcpy (&rtr_list[orf_token->rtr_list_entries].ring_id,
|
||||
&instance->my_ring_id, sizeof (struct memb_ring_id));
|
||||
memb_ring_id_copy (
|
||||
&rtr_list[orf_token->rtr_list_entries].ring_id,
|
||||
&instance->my_ring_id);
|
||||
rtr_list[orf_token->rtr_list_entries].seq = instance->my_aru + i;
|
||||
orf_token->rtr_list_entries++;
|
||||
}
|
||||
@ -2529,7 +2530,7 @@ static int orf_token_send_initial (struct totemsrp_instance *instance)
|
||||
orf_token.aru = SEQNO_START_MSG - 1;
|
||||
orf_token.aru_addr = instance->my_id.addr[0].nodeid;
|
||||
|
||||
memcpy (&orf_token.ring_id, &instance->my_ring_id, sizeof (struct memb_ring_id));
|
||||
memb_ring_id_copy (&orf_token.ring_id, &instance->my_ring_id);
|
||||
orf_token.fcc = 0;
|
||||
orf_token.backlog = 0;
|
||||
|
||||
@ -2552,8 +2553,8 @@ static void memb_state_commit_token_update (
|
||||
memb_list = (struct memb_commit_token_memb_entry *)(addr + commit_token->addr_entries);
|
||||
|
||||
memb_index_this = (commit_token->memb_index + 1) % commit_token->addr_entries;
|
||||
memcpy (&memb_list[memb_index_this].ring_id,
|
||||
&instance->my_old_ring_id, sizeof (struct memb_ring_id));
|
||||
memb_ring_id_copy (&memb_list[memb_index_this].ring_id,
|
||||
&instance->my_old_ring_id);
|
||||
assert (!totemip_zero_check(&instance->my_old_ring_id.rep));
|
||||
|
||||
memb_list[memb_index_this].aru = instance->old_ring_state_aru;
|
||||
@ -3725,8 +3726,7 @@ static void memb_commit_token_endian_convert (struct memb_commit_token *in, stru
|
||||
out->header.endian_detector = ENDIAN_LOCAL;
|
||||
out->header.nodeid = swab32 (in->header.nodeid);
|
||||
out->token_seq = swab32 (in->token_seq);
|
||||
totemip_copy_endian_convert(&out->ring_id.rep, &in->ring_id.rep);
|
||||
out->ring_id.seq = swab64 (in->ring_id.seq);
|
||||
memb_ring_id_copy_endian_convert (&out->ring_id, &in->ring_id);
|
||||
out->retrans_flg = swab32 (in->retrans_flg);
|
||||
out->memb_index = swab32 (in->memb_index);
|
||||
out->addr_entries = swab32 (in->addr_entries);
|
||||
@ -3740,11 +3740,9 @@ static void memb_commit_token_endian_convert (struct memb_commit_token *in, stru
|
||||
* Only convert the memb entry if it has been set
|
||||
*/
|
||||
if (in_memb_list[i].ring_id.rep.family != 0) {
|
||||
totemip_copy_endian_convert (&out_memb_list[i].ring_id.rep,
|
||||
&in_memb_list[i].ring_id.rep);
|
||||
|
||||
out_memb_list[i].ring_id.seq =
|
||||
swab64 (in_memb_list[i].ring_id.seq);
|
||||
memb_ring_id_copy_endian_convert (
|
||||
&out_memb_list[i].ring_id,
|
||||
&in_memb_list[i].ring_id);
|
||||
out_memb_list[i].aru = swab32 (in_memb_list[i].aru);
|
||||
out_memb_list[i].high_delivered = swab32 (in_memb_list[i].high_delivered);
|
||||
out_memb_list[i].received_flg = swab32 (in_memb_list[i].received_flg);
|
||||
@ -3762,16 +3760,15 @@ static void orf_token_endian_convert (struct orf_token *in, struct orf_token *ou
|
||||
out->seq = swab32 (in->seq);
|
||||
out->token_seq = swab32 (in->token_seq);
|
||||
out->aru = swab32 (in->aru);
|
||||
totemip_copy_endian_convert(&out->ring_id.rep, &in->ring_id.rep);
|
||||
memb_ring_id_copy_endian_convert (&out->ring_id, &in->ring_id);
|
||||
out->aru_addr = swab32(in->aru_addr);
|
||||
out->ring_id.seq = swab64 (in->ring_id.seq);
|
||||
out->fcc = swab32 (in->fcc);
|
||||
out->backlog = swab32 (in->backlog);
|
||||
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++) {
|
||||
totemip_copy_endian_convert(&out->rtr_list[i].ring_id.rep, &in->rtr_list[i].ring_id.rep);
|
||||
out->rtr_list[i].ring_id.seq = swab64 (in->rtr_list[i].ring_id.seq);
|
||||
memb_ring_id_copy_endian_convert(&out->rtr_list[i].ring_id,
|
||||
&in->rtr_list[i].ring_id);
|
||||
out->rtr_list[i].seq = swab32 (in->rtr_list[i].seq);
|
||||
}
|
||||
}
|
||||
@ -3783,8 +3780,7 @@ static void mcast_endian_convert (struct mcast *in, struct mcast *out)
|
||||
out->header.nodeid = swab32 (in->header.nodeid);
|
||||
out->seq = swab32 (in->seq);
|
||||
out->this_seqno = swab32 (in->this_seqno);
|
||||
totemip_copy_endian_convert(&out->ring_id.rep, &in->ring_id.rep);
|
||||
out->ring_id.seq = swab64 (in->ring_id.seq);
|
||||
memb_ring_id_copy_endian_convert(&out->ring_id, &in->ring_id);
|
||||
out->node_id = swab32 (in->node_id);
|
||||
out->guarantee = swab32 (in->guarantee);
|
||||
srp_addr_copy_endian_convert (&out->system_from, &in->system_from);
|
||||
@ -3797,8 +3793,7 @@ static void memb_merge_detect_endian_convert (
|
||||
out->header.type = in->header.type;
|
||||
out->header.endian_detector = ENDIAN_LOCAL;
|
||||
out->header.nodeid = swab32 (in->header.nodeid);
|
||||
totemip_copy_endian_convert(&out->ring_id.rep, &in->ring_id.rep);
|
||||
out->ring_id.seq = swab64 (in->ring_id.seq);
|
||||
memb_ring_id_copy_endian_convert(&out->ring_id, &in->ring_id);
|
||||
srp_addr_copy_endian_convert (&out->system_from, &in->system_from);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user