[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#759534: marked as done ([libapr1] apr_mcast_interface does not work for IPv6)



Your message dated Mon, 17 Aug 2015 17:04:51 +0000
with message-id <E1ZRNq7-0002zg-4c@franck.debian.org>
and subject line Bug#759534: fixed in apr 1.5.2-2
has caused the Debian Bug report #759534,
regarding [libapr1] apr_mcast_interface does not work for IPv6
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
759534: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=759534
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: libapr1
Version: 1.5.1-2
Severity: normal
Tags: patch

--- Please enter the report below this line. ---

Hi.

When trying to set the mcast interface with apr_mcast_interface(), apr
goes through all interfaces and tries to match the given address to the
interfaces address. This does not work as it is currently implemented in
linux, since the match is tried by comparing (memcmp()) the sin6_addr
field of the given struct sockaddr_in6 and sa_data from a  generic
struct sockaddr, which do not line up.

The attached patch fix_ipv6_find_if_index.patch fixes this for me.

Also attached is a test program, that does not work correctly without
the patch applied. The program goes through all interfaces of a host,
chooses the ipv6 ones, that are not the loopback device, and tries to
send a multicast packet on each address.

There has to be a second ipv6 interface, for this error to actually have
any effect.

Regards
  nautsch


--- System information. ---
Architecture: amd64
Kernel:       Linux 3.14-2-amd64

Debian Release: jessie/sid
  500 unstable        ftp.de.debian.org   500 stable          ftp.uni-kl.de
--- Package information. ---
Depends       (Version) | Installed
=======================-+-===========
libc6         (>= 2.15) | libuuid1      (>= 2.16) |

Package's Recommends field is empty.

Package's Suggests field is empty.

Index: apr-1.5.1/network_io/unix/multicast.c
===================================================================
--- apr-1.5.1.orig/network_io/unix/multicast.c
+++ apr-1.5.1/network_io/unix/multicast.c
@@ -62,7 +62,7 @@ static unsigned int find_if_index(const
     for (ifp = ifs; ifp; ifp = ifp->ifa_next) {
         if (ifp->ifa_addr != NULL && ifp->ifa_addr->sa_family == AF_INET6) {
             if (memcmp(&iface->sa.sin6.sin6_addr,
-                       &ifp->ifa_addr->sa_data[0],
+                       &((struct sockaddr_in6*)ifp->ifa_addr)->sin6_addr,
                        sizeof(iface->sa.sin6.sin6_addr)) == 0) {
                 index = if_nametoindex(ifp->ifa_name);
                 break;

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

#include <netdb.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <ifaddrs.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>

#include <apr.h>
#include <apr_errno.h>
#include <apr_network_io.h>

#define BCADDR_SITE "ff15::1234"

#define MC_PORT 30000

int main(int argc, char **argv)
{
	apr_socket_t *s;
	apr_sockaddr_t *addr;
	apr_pool_t *pool;
	apr_status_t err;
	char buffer[1024];

	apr_initialize();
	atexit(apr_terminate);

	apr_pool_create(&pool, NULL);

	if ((err = apr_socket_create(&s, APR_INET6, SOCK_DGRAM, 0, pool)) != APR_SUCCESS) {
		fprintf(stderr, "failed to create socket\n");
		return 1;
	}

	if ((err = apr_sockaddr_info_get(&addr, BCADDR_SITE, APR_INET6, MC_PORT, 0, pool)) != APR_SUCCESS) {
		fprintf(stderr, "could not create mcast addrinfo %s\n", apr_strerror(err, buffer, 1024));
		return 1;
	}

	{
		struct ifaddrs *ifaddrs;
		struct ifaddrs *ia;
		getifaddrs(&ifaddrs);

		for (ia = ifaddrs; ia; ia = ia->ifa_next) {
			apr_sockaddr_t *src_addr;
			char addr_str[INET6_ADDRSTRLEN + 1];
			apr_size_t len = 6;
			apr_status_t ret;

			if (!ia->ifa_addr) {
				continue;
			}

			switch (ia->ifa_addr->sa_family) {
				case AF_INET6:
					// we cannot send multicasts on the loopback interface
					if (IN6_IS_ADDR_LOOPBACK(&((struct sockaddr_in6*)ia->ifa_addr)->sin6_addr)) {
						continue;
					}
					if (inet_ntop(AF_INET6, &((struct sockaddr_in6*)ia->ifa_addr)->sin6_addr, addr_str, INET6_ADDRSTRLEN) == NULL) {
						fprintf(stderr, "failed to create string v6 address: %s\n", strerror(errno));
						return 1;
					}
					fprintf(stderr, "v6 addr: %s belongs to device %d\n", addr_str, if_nametoindex(ia->ifa_name));
					break;
				default:
					continue;
			}

			if ((ret = apr_sockaddr_info_get(&src_addr, addr_str, APR_INET6, MC_PORT, 0, pool)) != APR_SUCCESS) {
				fprintf(stderr, "could no create sockaddr for mcast_interface %s\n", apr_strerror(ret, buffer, 1024));
				return 1;
			}

			if (apr_mcast_interface(s, src_addr) != APR_SUCCESS) {
				fprintf(stderr, "could not set mcast interface");
				return 1;
			}

			if ((err = apr_socket_sendto(s, addr, 0, "hallo\n", &len)) != APR_SUCCESS) {
				fprintf(stderr, "failed to send %s\n", apr_strerror(err, buffer, 1024));
				return 1;
			}
			fprintf(stderr, "sent\n");
		}

		freeifaddrs(ifaddrs);
	}

	return 0;
}

--- End Message ---
--- Begin Message ---
Source: apr
Source-Version: 1.5.2-2

We believe that the bug you reported is fixed in the latest version of
apr, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 759534@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Stefan Fritsch <sf@debian.org> (supplier of updated apr package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Mon, 17 Aug 2015 18:49:41 +0200
Source: apr
Binary: libapr1 libapr1-dev libapr1-dbg
Architecture: source amd64
Version: 1.5.2-2
Distribution: unstable
Urgency: medium
Maintainer: Debian Apache Maintainers <debian-apache@lists.debian.org>
Changed-By: Stefan Fritsch <sf@debian.org>
Description:
 libapr1    - Apache Portable Runtime Library
 libapr1-dbg - Apache Portable Runtime Library - Debugging Symbols
 libapr1-dev - Apache Portable Runtime Library - Development Headers
Closes: 759534
Changes:
 apr (1.5.2-2) unstable; urgency=medium
 .
   * Remove the buildhost's hostname from libtool for reproducible builds.
   * Fix ipv6 address comparison in apr_mcast_interface/apr_mcast_join.
     Thanks to Andre Naujoks <nautsch2 gmail com> for the patch.
     Closes: #759534
Checksums-Sha1:
 63c982fdfb9b33c57f18d67710b40d8f41022800 2090 apr_1.5.2-2.dsc
 df3c52e194a119ede642829f965a9c4d549a4014 17924 apr_1.5.2-2.debian.tar.xz
 06dcbba6c11e2cc959b82a888691e84d4e50374c 259526 libapr1-dbg_1.5.2-2_amd64.deb
 5ed1f8327fe4765f063d9e88c05e3f6c7fe33f38 665722 libapr1-dev_1.5.2-2_amd64.deb
 1206ac2607b09018668d0789bf14ad366745ebce 96280 libapr1_1.5.2-2_amd64.deb
Checksums-Sha256:
 30707b429f88f17ad2c8d82bad9c2c1af3caa78b7e9fd10fb9434a7512f50294 2090 apr_1.5.2-2.dsc
 b039adf7d83977882aeeb0960607312bf73b53ae65d3530b87abede09e485182 17924 apr_1.5.2-2.debian.tar.xz
 052ea53ae33dc7ae2afb3a8a9fa4ea934c98fc6e203b50c01e8bcaf32ad57f79 259526 libapr1-dbg_1.5.2-2_amd64.deb
 9d3fd8bff15046aea14f044990f9fbc53f49385e2a8c974ce2e7de1830099251 665722 libapr1-dev_1.5.2-2_amd64.deb
 22d2b4c97bdf4845b16bfc0e83ea933499d5d86140c0f6b0bac4b1c1dbdfc8d4 96280 libapr1_1.5.2-2_amd64.deb
Files:
 fbdb361e83a7b0837e10f44ef6e78f23 2090 libs optional apr_1.5.2-2.dsc
 c5694d62afcd1685668ae86207cf720a 17924 libs optional apr_1.5.2-2.debian.tar.xz
 194863ce967d459bace080e51c5f4a83 259526 debug extra libapr1-dbg_1.5.2-2_amd64.deb
 b4fb07d40a74e19c60eb2d63daf8a141 665722 libdevel optional libapr1-dev_1.5.2-2_amd64.deb
 d5ab7b271793a9e037b4d0440661d88e 96280 libs optional libapr1_1.5.2-2_amd64.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIVAwUBVdIRscaHXzVBzv3gAQjQLhAAqPmsiPbI3Q/cY6H2HcZ0sIQyZkdP1kyR
wz6hI5UEEa3c8eKPd8hI0lv0fjH0wYk9peT8D7GPAp/2bgEmfywDZ8MbLOL0RaMx
cmWvvX7DzAlNHcHxj60Jm0wLV1WxDh8rMsZ0KXWaESrOUYeTwpVbEuTMlf2/QCCz
p3ABXC+UUb4VvD8wnV0tYLgS66KFG2WSCKLwzQ986cD1CJt3xnkaqB9G4bO85dPW
f6v/oH1nrRUXPxUWxko2JwvuCfA5KED2DIuA4jFMr4jdxV33FQinI5yAtbAhMsha
NXBsHKUNHH0CFIBSomU13snCDfy8KQQY8Q8m90JiPv/64gHaoB6DV8t8NTCzrHVf
huTXoC/ZqGrnRz+G4sZyTw6Z7cmHfxrLiUdbsOs/1ZkvtGThkjH+yQhWLU3sEzyu
HilNnqdvF6mfWSQreAJD2azsE8nzTcn3Z3nPaXhRdcsSua1OSAPhr4IdkAmWfLap
OH5C2ssn+vXjwEmFlUkoow0YwlR/hWRBH4noWE/Ev9qx+aj4l1v0nJ6qr8JqVECL
HPzmgV3ZLftAewC1L4glBH/1PKBqln4MdCOv3RbzkyOJ9rhre3vW7S9An+VplTtI
RWMd50AFnjmR0NZVGd8lpb0+aOh5qoqr1qWZcntw1YYkySkDIfvA7gFBNBMLe08X
HyoK236GeG0=
=3Vw6
-----END PGP SIGNATURE-----

--- End Message ---

Reply to: