LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

Re: News contrib to LVS

To: lvs-users@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: News contrib to LVS
From: ratz <ratz@xxxxxx>
Date: Sat, 23 Dec 2000 13:07:45 +0100
Hi Alexandre,

Alexandre Cassen wrote:
> 
> Hi,
> 
> I have just publish a little contribution to LVS after negociation with my
> employer. The solution described in the contrib homepage is used in a
> production environnement.

I wish I could have such fruitful negotiations with my employer :)
 
> The projet is named : Keepalived
> 
> The main goal of the keepalived project is to add a strong & robust keepalive
> facility to the Linux Virtual Server project. This project is similar to the
> MON project, but it is in C with multilayer TCP/IP stack checks. Keepalived
> implements a framework based on three family checks : Layer3, Layer4 & Layer5.
> This framework gives the daemon the ability of checking a LVS server pool
> states.When one of the server of the LVS server pool is down, keepalived
> informs the linux kernel via a setsockopt call to remove this server entrie
> from the LVS topology.

Looks interesting at the first glance. Some inputs though:

o Your signalhandling code looks somewhat fishy in keepalived.c. 
What if a signal occurs during the execution of logmessage? Why 
don't you use sigaction with that installs the signalhandler back 
after exec? This is the code I mean:

if (signal(SIGTERM,sig_handler) == SIG_IGN)
  signal(SIGTERM,SIG_IGN);

signal(SIGINT,sig_handler);
signal(SIGHUP,sig_handler);

void sig_handler(int signum)
{
  keep_going=0;
  ClearLst(lstVS);
  logmessage("Ending keepalived daemon\n",getpid());
  signal(signum,sig_handler);
}

o You should be using memset(3) and not bzero(3).

o What happens if your tcpcheck can't connect? eg firewall,
tcpwrapper? IMHO your code will timeout for some long time.
How about implementing some kind of timer in tcpcheck.c? 
Just think about if this tcpcheck blocks the further checks
until it's timeouted? Maybe I've overseen something in your
code but I can't see how you handle this problem.

o I suggest you have a look at the http_get attached in this
mail. With it you could even perform simple base64 and ssl
authentication. So SSL healthchecks would be a part of your
deamon too.

> Hope it will help,

I hope that too and I hope I haven't insulted you with my 
suggestions.
 
> Happy christmas and happy new year,

The same to you,
Roberto Nibali, ratz

BTW: I found some code I can give you to show you what I meant
with my comments:

-----------------------------------------------------------------
/*
 Module: portchecker.

 This module is used as a plugin for the healthcheck methods used in the
 terreActive load balancer monitoring tool. It can verify a service running
 behind a servers port listening.

 c) 1999-2000 by terreActive AG, Roberto Nibali, ratz

*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

void catch_alarm(int sig){
}

int main(int argc, char **argv){
        int sockfd;
        struct sockaddr_in servaddr;
        struct sigaction new_action;
        int ec=0;
        new_action.sa_handler=catch_alarm;
        sigemptyset(&new_action.sa_mask);
        new_action.sa_flags=0;

        if (argc != 4) {
                fprintf(stderr, "Usage %s <IP> <PORT> <TIMEOUT>\n", argv[0]);
                exit(1);
        }
        if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
                exit(1);
        }
        memset(&servaddr, 0, sizeof(servaddr));
        servaddr.sin_family = AF_INET;
        servaddr.sin_port = htons(strtoul(argv[2],NULL,10));
        if (inet_pton(AF_INET, argv[1], &servaddr.sin_addr) <= 0) {
                exit(1);
        }
        if (sigaction(SIGALRM, &new_action, NULL) == -1){
                exit(1);
        }
        alarm(strtoul(argv[3],NULL,10));
        if (connect(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) <
0) {
                ec = 1;
        }
        close(sockfd);
        exit(ec);
}
-----------------------------------------------------------------

Attachment: httpget.tar.gz
Description: GNU Zip compressed data

<Prev in Thread] Current Thread [Next in Thread>