Problem with ctdb_sys_have_ip
ronnie sahlberg
ronniesahlberg at gmail.com
Fri Aug 28 12:22:38 MDT 2009
Can you send me a patch for this with a signoff line ?
On Sat, Aug 29, 2009 at 4:10 AM, Harald Klatte<klatte at hrz.uni-kassel.de> wrote:
> On Sat, 29 Aug 2009, ronnie sahlberg wrote:
>
> ........
>>
>> Can you try adding this code at this point :
>> #ifdef HAVE_SOCK_SIN_LEN
>> addr->ip.sin_len = sizeof(addr->ip);
>> #endif
>>
> .........
>
> With a little hint from a friend we already solved the problem.
>
> On some systems the addrlen parameter of bind() must be set to
> the EXACT length of the source data type.
>
> So the follwing works as it should:
>
> bool ctdb_sys_have_ip(ctdb_sock_addr *_addr)
> {
> int s;
> int addrlen;
> 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;
> addrlen = sizeof(struct sockaddr_in);
> break;
> case AF_INET6:
> addr->ip6.sin6_port = 0;
> addrlen = sizeof(struct sockaddr_in6);
> break;
> }
>
> s = socket(addr->sa.sa_family, SOCK_STREAM, htons(IPPROTO_TCP));
> if (s == -1) {
> return false;
> }
>
> ret = bind(s, (struct sockaddr *)addr, addrlen);
> if (ret == -1) {
> DEBUG(DEBUG_DEBUG,(" failed to bind address to socket (%s)\n", strerror(errno) ));
> return false;
> }
>
> close(s);
> return ret == 0;
> }
>
>
> Please change the original code.
>
>
> Thanks
>
> Harald
>
>
> --
>
> +----------+ Harald Klatte email: klatte at hrz.uni-kassel.de
> |Uni-Kassel| ITS, Universitaet Kassel Tel.: (49) 561/804-2280
> +----------+ Moenchebergstr. 11, 34109 Kassel Fax: (49) 561/804-2297
>
>
More information about the samba-technical
mailing list