I made some corection to the test codes

ipvs1:~# cat a.c
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <fcntl.h>

int main (void)
{
int ret, sock, status, flags;
struct sockaddr_in sa = { AF_INET };
socklen_t slen = sizeof (status);

sa.sin_addr.s_addr = inet_addr ("10.1.8.48");
sa.sin_port = htons (8088);

sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
flags = fcntl(sock, F_GETFL);
fcntl (sock, F_SETFL, flags|O_NONBLOCK);
ret = connect (sock, (struct sockaddr *)&sa, sizeof (sa));
printf ("connect return %d\n", ret);
if (ret != 0)
perror ("connect: ");
/*
After calling connect, keepalived use getsockopt(SO_ERROR)
to get the connection status in function tcp_socket_state.
But it report no error in this case.
*/

ret = getsockopt (sock, SOL_SOCKET, SO_ERROR, (void *) &status, &slen);
if (ret != 0)
perror ("getsockopt: ");
printf ("status = %d\n", status);
};
ipvs1:~# gcc a.c
ipvs1:~# ./a.out
connect return -1
connect: : Network is unreachable
status = 0
ipvs1:~#


Bin Tian wrote:
> Package: keepalived
> Version: 1.1.15-1
> Severity: normal
>
> If you add an unreachable route to one realserver, the healthchecker doesn't 
> remove the realserver. 
>
> For example, 
>
> # ip ro add unreachable 10.1.8.48
> # telnet 10.1.8.48 80
> Trying 10.1.8.48...
> telnet: Unable to connect to remote host: Network is unreachable
>
> But HTTP_GET/SMTP_CHECK/TCP_CHECK isn't aware of the connect problem.
>
> The following codes may be helpful to solve the problem
>
> ipvs1:~# cat a.c
> #include <stdio.h>
> #include <sys/socket.h>
> #include <netinet/in.h>
>
> int main (void)
> {
>         int ret, sock, status;
>         struct sockaddr_in sa = { AF_INET };
>         socklen_t slen = sizeof (status);
>
>         sa.sin_addr.s_addr = inet_addr ("10.1.8.48");
>         sa.sin_port = htons (80);
>
>         sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
>         ret = connect (sock, (struct sockaddr *)&sa, sizeof (sa));
>         printf ("connect return %d\n", ret);
>         if (ret != 0)
>                 perror ("connect: ");
>
>               /*
>                       After calling connect, keepalived use 
> getsockopt(SO_ERROR) 
>                       to get the connection status in function 
> tcp_socket_state.
>                       But it report no error in this case.
>               */
>         ret = getsockopt (sock, SOL_SOCKET, SO_ERROR, (void *) &status, 
> &slen);
>         if (ret != 0)
>                 perror ("getsockopt: ");
>         printf ("status = %d\n", status);
> };
> ipvs1:~# gcc a.c
> ipvs1:~# ./a.out
> connect return -1
> connect: : Network is unreachable
> status = 0
> ipvs1:~#
>
> -- System Information:
> Debian Release: lenny/sid
>   APT prefers testing
>   APT policy: (500, 'testing')
> Architecture: amd64 (x86_64)
>
> Kernel: Linux 2.6.26-1-amd64 (SMP w/4 CPU cores)
> Locale: LANG=zh_CN.UTF-8, LC_CTYPE=zh_CN.UTF-8 (charmap=UTF-8)
> Shell: /bin/sh linked to /bin/dash
>
> Versions of packages keepalived depends on:
> ii  iproute                       20080725-2 networking and traffic control 
> too
> ii  ipvsadm                       1:1.24-2   Linux Virtual Server support 
> progr
> ii  libc6                         2.7-15     GNU C Library: Shared libraries
> ii  libpopt0                      1.14-4     lib for parsing cmdline 
> parameters
> ii  libssl0.9.8                   0.9.8g-13  SSL shared libraries
>
> keepalived recommends no packages.
>
> keepalived suggests no packages.
>
> -- no debconf information
>
>
>   



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to