forked from altcloud/fence-virt
Add sequence numbers to requests for tracking
Signed-off-by: Lon Hohberger <lhh@redhat.com>
This commit is contained in:
parent
51f06f5ce3
commit
701a876e73
@ -133,8 +133,8 @@ tcp_exchange(int fd, fence_auth_type_t auth, void *key,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
send_multicast_packets(ip_list_t *ipl, fence_virt_args_t *args, void *key,
|
send_multicast_packets(ip_list_t *ipl, fence_virt_args_t *args,
|
||||||
size_t key_len)
|
uint32_t seqno, void *key, size_t key_len)
|
||||||
{
|
{
|
||||||
fence_req_t freq;
|
fence_req_t freq;
|
||||||
int mc_sock;
|
int mc_sock;
|
||||||
@ -180,6 +180,7 @@ send_multicast_packets(ip_list_t *ipl, fence_virt_args_t *args, void *key,
|
|||||||
sizeof(freq.domain));
|
sizeof(freq.domain));
|
||||||
freq.request = args->op;
|
freq.request = args->op;
|
||||||
freq.hashtype = args->net.hash;
|
freq.hashtype = args->net.hash;
|
||||||
|
freq.seqno = seqno;
|
||||||
|
|
||||||
/* Store source address */
|
/* Store source address */
|
||||||
if (ipa->ipa_family == PF_INET) {
|
if (ipa->ipa_family == PF_INET) {
|
||||||
@ -218,8 +219,10 @@ mcast_fence_virt(fence_virt_args_t *args)
|
|||||||
{
|
{
|
||||||
ip_list_t ipl;
|
ip_list_t ipl;
|
||||||
char key[MAX_KEY_LEN];
|
char key[MAX_KEY_LEN];
|
||||||
|
struct timeval tv;
|
||||||
int lfd, key_len = 0, fd;
|
int lfd, key_len = 0, fd;
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
|
uint32_t seqno;
|
||||||
|
|
||||||
/* Initialize NSS; required to do hashing, as silly as that
|
/* Initialize NSS; required to do hashing, as silly as that
|
||||||
sounds... */
|
sounds... */
|
||||||
@ -268,8 +271,12 @@ mcast_fence_virt(fence_virt_args_t *args)
|
|||||||
|
|
||||||
attempts = args->timeout * 10 / args->retr_time;
|
attempts = args->timeout * 10 / args->retr_time;
|
||||||
|
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
seqno = (uint32_t)tv.tv_usec;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (send_multicast_packets(&ipl, args, key, key_len)) {
|
if (send_multicast_packets(&ipl, args, seqno,
|
||||||
|
key, key_len)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
/* */
|
/* */
|
||||||
#include <uuid/uuid.h>
|
|
||||||
|
|
||||||
#define PLUGIN_VERSION_LISTENER ((double)0.1)
|
#define PLUGIN_VERSION_LISTENER ((double)0.1)
|
||||||
#define PLUGIN_VERSION_BACKEND ((double)0.1)
|
#define PLUGIN_VERSION_BACKEND ((double)0.1)
|
||||||
|
|
||||||
@ -28,17 +26,17 @@ typedef int (*fence_null_callback)(const char *vm_name,
|
|||||||
|
|
||||||
/* Turn the VM 'off'. Returns 0 to caller if successful or
|
/* Turn the VM 'off'. Returns 0 to caller if successful or
|
||||||
nonzero if unsuccessful. */
|
nonzero if unsuccessful. */
|
||||||
typedef int (*fence_off_callback)(const char *vm_name,
|
typedef int (*fence_off_callback)(const char *vm_name, uint32_t seqno,
|
||||||
void *priv);
|
void *priv);
|
||||||
|
|
||||||
/* Turn the VM 'on'. Returns 0 to caller if successful or
|
/* Turn the VM 'on'. Returns 0 to caller if successful or
|
||||||
nonzero if unsuccessful. */
|
nonzero if unsuccessful. */
|
||||||
typedef int (*fence_on_callback)(const char *vm_name,
|
typedef int (*fence_on_callback)(const char *vm_name, uint32_t seqno,
|
||||||
void *priv);
|
void *priv);
|
||||||
|
|
||||||
/* Reboot a VM. Returns 0 to caller if successful or
|
/* Reboot a VM. Returns 0 to caller if successful or
|
||||||
nonzero if unsuccessful. */
|
nonzero if unsuccessful. */
|
||||||
typedef int (*fence_reboot_callback)(const char *vm_name,
|
typedef int (*fence_reboot_callback)(const char *vm_name, uint32_t seqno,
|
||||||
void *priv);
|
void *priv);
|
||||||
|
|
||||||
/* Get status of a VM. Returns 0 to caller if VM is alive or
|
/* Get status of a VM. Returns 0 to caller if VM is alive or
|
||||||
|
@ -77,7 +77,8 @@ typedef struct __attribute__ ((packed)) _fence_req {
|
|||||||
uint8_t address[MAX_ADDR_LEN]; /* We're this IP */
|
uint8_t address[MAX_ADDR_LEN]; /* We're this IP */
|
||||||
#define DEFAULT_MCAST_PORT 1229
|
#define DEFAULT_MCAST_PORT 1229
|
||||||
uint16_t port; /* Port we bound to */
|
uint16_t port; /* Port we bound to */
|
||||||
uint8_t random[10]; /* Random Data */
|
uint8_t random[6]; /* Random Data */
|
||||||
|
uint32_t seqno; /* Request identifier; can be random */
|
||||||
uint32_t family; /* Address family */
|
uint32_t family; /* Address family */
|
||||||
uint8_t hash[MAX_HASH_LENGTH]; /* Binary hash */
|
uint8_t hash[MAX_HASH_LENGTH]; /* Binary hash */
|
||||||
} fence_req_t;
|
} fence_req_t;
|
||||||
@ -92,6 +93,7 @@ typedef struct __attribute__((packed)) _serial_fence_req {
|
|||||||
uint8_t request;
|
uint8_t request;
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
uint8_t domain[MAX_DOMAINNAME_LENGTH];
|
uint8_t domain[MAX_DOMAINNAME_LENGTH];
|
||||||
|
uint32_t seqno;
|
||||||
} serial_req_t;
|
} serial_req_t;
|
||||||
|
|
||||||
typedef struct __attribute__((packed)) _serial_fense_resp {
|
typedef struct __attribute__((packed)) _serial_fense_resp {
|
||||||
|
@ -146,7 +146,7 @@ libvirt_null(const char *vm_name, void *priv)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
libvirt_off(const char *vm_name, void *priv)
|
libvirt_off(const char *vm_name, uint32_t seqno, void *priv)
|
||||||
{
|
{
|
||||||
struct libvirt_info *info = (struct libvirt_info *)priv;
|
struct libvirt_info *info = (struct libvirt_info *)priv;
|
||||||
virDomainPtr vdp;
|
virDomainPtr vdp;
|
||||||
@ -195,7 +195,7 @@ libvirt_off(const char *vm_name, void *priv)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
libvirt_on(const char *vm_name, void *priv)
|
libvirt_on(const char *vm_name, uint32_t seqno, void *priv)
|
||||||
{
|
{
|
||||||
dbg_printf(5, "%s %s\n", __FUNCTION__, vm_name);
|
dbg_printf(5, "%s %s\n", __FUNCTION__, vm_name);
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ libvirt_status(const char *vm_name, void *priv)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
libvirt_reboot(const char *vm_name, void *priv)
|
libvirt_reboot(const char *vm_name, uint32_t seqno, void *priv)
|
||||||
{
|
{
|
||||||
struct libvirt_info *info = (struct libvirt_info *)priv;
|
struct libvirt_info *info = (struct libvirt_info *)priv;
|
||||||
virDomainPtr vdp, nvdp;
|
virDomainPtr vdp, nvdp;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
/* Local includes */
|
/* Local includes */
|
||||||
|
#include <stdint.h>
|
||||||
#include <fence_virt.h>
|
#include <fence_virt.h>
|
||||||
#include <simpleconfig.h>
|
#include <simpleconfig.h>
|
||||||
#include <server_plugin.h>
|
#include <server_plugin.h>
|
||||||
|
@ -102,6 +102,7 @@ check_history(void *a, void *b) {
|
|||||||
fence_req_t *old = a, *current = b;
|
fence_req_t *old = a, *current = b;
|
||||||
|
|
||||||
if (old->request == current->request &&
|
if (old->request == current->request &&
|
||||||
|
old->seqno == current->seqno &&
|
||||||
!strcasecmp((const char *)old->domain,
|
!strcasecmp((const char *)old->domain,
|
||||||
(const char *)current->domain)) {
|
(const char *)current->domain)) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -187,13 +188,16 @@ do_fence_request_tcp(fence_req_t *req, mcast_info *info)
|
|||||||
response = info->cb->null((char *)req->domain, info->priv);
|
response = info->cb->null((char *)req->domain, info->priv);
|
||||||
break;
|
break;
|
||||||
case FENCE_ON:
|
case FENCE_ON:
|
||||||
response = info->cb->on((char *)req->domain, info->priv);
|
response = info->cb->on((char *)req->domain, req->seqno,
|
||||||
|
info->priv);
|
||||||
break;
|
break;
|
||||||
case FENCE_OFF:
|
case FENCE_OFF:
|
||||||
response = info->cb->off((char *)req->domain, info->priv);
|
response = info->cb->off((char *)req->domain, req->seqno,
|
||||||
|
info->priv);
|
||||||
break;
|
break;
|
||||||
case FENCE_REBOOT:
|
case FENCE_REBOOT:
|
||||||
response = info->cb->reboot((char *)req->domain, info->priv);
|
response = info->cb->reboot((char *)req->domain, req->seqno,
|
||||||
|
info->priv);
|
||||||
break;
|
break;
|
||||||
case FENCE_STATUS:
|
case FENCE_STATUS:
|
||||||
response = info->cb->status((char *)req->domain, info->priv);
|
response = info->cb->status((char *)req->domain, info->priv);
|
||||||
@ -277,7 +281,8 @@ mcast_dispatch(listener_context_t c, struct timeval *timeout)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Request %d domain %s\n", data.request, data.domain);
|
printf("Request %d seqno %d domain %s\n", data.request, data.seqno,
|
||||||
|
data.domain);
|
||||||
|
|
||||||
if (history_check(info->history, &data) == 1) {
|
if (history_check(info->history, &data) == 1) {
|
||||||
printf("We just did this request; dropping packet\n");
|
printf("We just did this request; dropping packet\n");
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <simpleconfig.h>
|
#include <simpleconfig.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <time.h>
|
||||||
#include <server_plugin.h>
|
#include <server_plugin.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
@ -58,7 +61,7 @@ null_null(const char *vm_name, void *priv)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
null_off(const char *vm_name, void *priv)
|
null_off(const char *vm_name, uint32_t seqno, void *priv)
|
||||||
{
|
{
|
||||||
VALIDATE(priv);
|
VALIDATE(priv);
|
||||||
printf("[Null] OFF operation on %s\n", vm_name);
|
printf("[Null] OFF operation on %s\n", vm_name);
|
||||||
@ -68,7 +71,7 @@ null_off(const char *vm_name, void *priv)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
null_on(const char *vm_name, void *priv)
|
null_on(const char *vm_name, uint32_t seqno, void *priv)
|
||||||
{
|
{
|
||||||
VALIDATE(priv);
|
VALIDATE(priv);
|
||||||
printf("[Null] ON operation on %s\n", vm_name);
|
printf("[Null] ON operation on %s\n", vm_name);
|
||||||
@ -100,7 +103,7 @@ null_status(const char *vm_name, void *priv)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
null_reboot(const char *vm_name, void *priv)
|
null_reboot(const char *vm_name, uint32_t seqno, void *priv)
|
||||||
{
|
{
|
||||||
VALIDATE(priv);
|
VALIDATE(priv);
|
||||||
printf("[Null] REBOOT operation on %s\n", vm_name);
|
printf("[Null] REBOOT operation on %s\n", vm_name);
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <list.h>
|
#include <list.h>
|
||||||
#include <simpleconfig.h>
|
#include <simpleconfig.h>
|
||||||
#include <server_plugin.h>
|
#include <server_plugin.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user