Bug in ctdb_sys_have_ip (CTDB) ?

William Jojo w.jojo at hvcc.edu
Thu Jun 4 00:05:05 GMT 2009


miguel.sanders at arcelormittal.com wrote:
> Hi guys
>
> I have been searching for a problem in CTDB (not on Linux, on AIX) all day and I finally was able to determine the root cause.
> In system_common.c, there is a "ctdb_sys_have_ip" function which should return true if a local interface has a specific IP alias.
>   

Miguel,

How does this problem manifest? What symptoms are you seeing? And what 
version of CTDB?

I've got 1.0.84 (latest) available for AIX and a new build with your 
patches using 3.3.4 when you're ready to test. :-)



Cheers,
Bill

> The function looks like this:
> /*
>   see if we currently have an interface with the given IP
>
>   we try to bind to it, and if that fails then we don't have that IP
>   on an interface
>  */
> bool ctdb_sys_have_ip(ctdb_sock_addr *_addr)
> {
> 	int s;
> 	int ret;
> 	ctdb_sock_addr __addr = *_addr;
> 	ctdb_sock_addr *addr = &__addr;
>
> 	switch (addr->sa.sa_family) {
> 	case AF_INET:
> 		addr->ip.sin_port = 0;
> 		break;
> 	case AF_INET6:
> 		addr->ip6.sin6_port = 0;
> 		break;
> 	}
>
> 	s = socket(addr->sa.sa_family, SOCK_STREAM, IPPROTO_TCP);
> 	if (s == -1) {
> 		return false;
> 	}
>
> 	ret = bind(s, (struct sockaddr *)addr, sizeof(ctdb_sock_addr));
>
> 	close(s);
> 	return ret == 0;
> }
>
> I just don't see how this piece of code guarantees that the IP address to test (*_addr) is attached to a local interface.
> Afaik this will always return true if the IP address is somewhere on the subnet.
>
> Am I missing something?
>
> Thanks!
>
> Met vriendelijke groet
> Best regards
> Bien à vous
>
> Miguel SANDERS
> ArcelorMittal Gent
>
> UNIX Systems & Storage
> IT Supply Western Europe | John Kennedylaan 51
> B-9042 Gent
>
> T +32 9 347 3538 | F +32 9 347 4901 | M +32478 805 023
> E miguel.sanders at arcelormittal.com
> www.arcelormittal.com/gent
>
>
> **** 
> This message and any attachment are confidential, intended solely for the use of the individual or entity to whom it is addressed and may be protected by professional secrecy or intellectual property rights. 
> If you have received it by mistake, or are not the named recipient(s), please immediately notify the sender and delete the message. You are hereby notified that any unauthorized use, copying or dissemination of any or all information contained in this message is prohibited. 
> Arcelormittal shall not be liable for the message if altered, falsified, or in case of error in the recipient. 
> This message does not constitute any right or commitment for ArcelorMittal except when expressly agreed otherwise in writing in a separate agreement.  
> ****  
>
>   



More information about the samba-technical mailing list