From: hume-github Date: Tue, 18 Sep 2012 18:19:39 +0000 (-0300) Subject: Fix for Solaris when setting ip-opt multicast-loop (must be a char, not int). X-Git-Tag: collectd-5.0.5~4^2 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=e4998db54e69d5ec37146a2ba50d97de14c419d4 Fix for Solaris when setting ip-opt multicast-loop (must be a char, not int). General logging additions for tracking down the problem. Signed-off-by: Florian Forster --- diff --git a/src/network.c b/src/network.c index 34cd1c01..be222769 100644 --- a/src/network.c +++ b/src/network.c @@ -58,6 +58,7 @@ #endif #if HAVE_LIBGCRYPT +# include # include GCRY_THREAD_OPTION_PTHREAD_IMPL; #endif @@ -1645,7 +1646,7 @@ static int network_set_ttl (const sockent_t *se, const struct addrinfo *ai) sizeof (network_config_ttl)) != 0) { char errbuf[1024]; - ERROR ("setsockopt: %s", + ERROR ("network plugin: setsockopt (ipv4-ttl): %s", sstrerror (errno, errbuf, sizeof (errbuf))); return (-1); } @@ -1666,7 +1667,7 @@ static int network_set_ttl (const sockent_t *se, const struct addrinfo *ai) sizeof (network_config_ttl)) != 0) { char errbuf[1024]; - ERROR ("setsockopt: %s", + ERROR ("network plugin: setsockopt(ipv6-ttl): %s", sstrerror (errno, errbuf, sizeof (errbuf))); return (-1); @@ -1713,7 +1714,7 @@ static int network_set_interface (const sockent_t *se, const struct addrinfo *ai &mreq, sizeof (mreq)) != 0) { char errbuf[1024]; - ERROR ("setsockopt: %s", + ERROR ("network plugin: setsockopt (ipv4-multicast-if): %s", sstrerror (errno, errbuf, sizeof (errbuf))); return (-1); } @@ -1732,7 +1733,7 @@ static int network_set_interface (const sockent_t *se, const struct addrinfo *ai sizeof (se->interface)) != 0) { char errbuf[1024]; - ERROR ("setsockopt: %s", + ERROR ("network plugin: setsockopt (ipv6-multicast-if): %s", sstrerror (errno, errbuf, sizeof (errbuf))); return (-1); @@ -1758,7 +1759,7 @@ static int network_set_interface (const sockent_t *se, const struct addrinfo *ai sizeof(interface_name)) == -1 ) { char errbuf[1024]; - ERROR ("setsockopt: %s", + ERROR ("network plugin: setsockopt (bind-if): %s", sstrerror (errno, errbuf, sizeof (errbuf))); return (-1); } @@ -1782,14 +1783,18 @@ static int network_set_interface (const sockent_t *se, const struct addrinfo *ai static int network_bind_socket (int fd, const struct addrinfo *ai, const int interface_idx) { +#if KERNEL_SOLARIS + char loop = 0; +#else int loop = 0; +#endif int yes = 1; /* allow multiple sockets to use the same PORT number */ if (setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) == -1) { char errbuf[1024]; - ERROR ("setsockopt: %s", + ERROR ("network plugin: setsockopt (reuseaddr): %s", sstrerror (errno, errbuf, sizeof (errbuf))); return (-1); } @@ -1832,7 +1837,7 @@ static int network_bind_socket (int fd, const struct addrinfo *ai, const int int &loop, sizeof (loop)) == -1) { char errbuf[1024]; - ERROR ("setsockopt: %s", + ERROR ("network plugin: setsockopt (multicast-loop): %s", sstrerror (errno, errbuf, sizeof (errbuf))); return (-1); @@ -1842,7 +1847,7 @@ static int network_bind_socket (int fd, const struct addrinfo *ai, const int int &mreq, sizeof (mreq)) == -1) { char errbuf[1024]; - ERROR ("setsockopt: %s", + ERROR ("network plugin: setsockopt (add-membership): %s", sstrerror (errno, errbuf, sizeof (errbuf))); return (-1); @@ -1880,7 +1885,7 @@ static int network_bind_socket (int fd, const struct addrinfo *ai, const int int &loop, sizeof (loop)) == -1) { char errbuf[1024]; - ERROR ("setsockopt: %s", + ERROR ("network plugin: setsockopt (ipv6-multicast-loop): %s", sstrerror (errno, errbuf, sizeof (errbuf))); return (-1); @@ -1890,7 +1895,7 @@ static int network_bind_socket (int fd, const struct addrinfo *ai, const int int &mreq, sizeof (mreq)) == -1) { char errbuf[1024]; - ERROR ("setsockopt: %s", + ERROR ("network plugin: setsockopt (ipv6-add-membership): %s", sstrerror (errno, errbuf, sizeof (errbuf))); return (-1); @@ -1918,7 +1923,7 @@ static int network_bind_socket (int fd, const struct addrinfo *ai, const int int sizeof(interface_name)) == -1 ) { char errbuf[1024]; - ERROR ("setsockopt: %s", + ERROR ("network plugin: setsockopt (bind-if): %s", sstrerror (errno, errbuf, sizeof (errbuf))); return (-1); }