Bug in ctdb_sys_have_ip (CTDB) ?

ronnie sahlberg ronniesahlberg at gmail.com
Thu Jun 4 00:14:40 GMT 2009


The bind() should fail and return -1 if the address does not exist locally
and then  'return ret ==0' means we do return false/0.

Only if bind() was successful and returned 0, will we return true/1 from
this function.

We should only be able to bind to the address iff the address exists locally
on the system.





On Wed, Jun 3, 2009 at 3:08 AM, <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.
> 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