[bind10-dev] #1534, IPV6_USE_MIN_MTU and similar

JINMEI Tatuya / 神明達哉 jinmei at isc.org
Wed Feb 22 04:07:18 UTC 2012


At Tue, 21 Feb 2012 12:59:57 +0100,
Michal 'vorner' Vaner <michal.vaner at nic.cz> wrote:

> > Shane Kerr <shane at isc.org> wrote:
> > > So it looks like MTU is set per-destination, which means that a
> > > connected socket is required. :(
> > 
> > Michal points out on jabber that one can happily *set* the MTU, just
> > *reading* the value is not supported.
> > 
> > As we discussed on jabber, we can try to connect() during the tests,
> > which is where the pain lies.
> 
> The current error is following:
> [ RUN      ] get_sock.udp6_create
> sockcreator_tests.cc:140: Failure
> Value of: options
>   Actual: 16436
> Expected: 1280
> [  FAILED  ] get_sock.udp6_create (0 ms)

Hmm, actually, if I checked the actual packet size with IPV6_MTU, it
seems to be working.  I compiled the small program copied below and
invoked it with a reachable IPv6 address on git.bind10, and saw this
output:

getsockopt: Transport endpoint is not connected
set IPV6_MTU to 1234

I did tcpdump at the other end and confirmed that the packet was
actually fragmented at 1280 octets:

17:04:29.887207 IP6 2001:4f8:3:d:20f:1fff:fe04:919b > 2001:4f8:3:36::162: frag (0|1232) 38462 > 8888: UDP, length 2000
17:04:29.887278 IP6 2001:4f8:3:d:20f:1fff:fe04:919b > 2001:4f8:3:36::162: frag (1232|776)

So, apparently, this OS shows a deviant behavior again and it's
difficult to confirm it with a standalone unit test, but it somehow
provides the expected feature.

---
JINMEI, Tatuya
Internet Systems Consortium, Inc.

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <string.h>
#include <stdio.h>

int
main(int argc, char* argv[]) {
	struct addrinfo hints, *res;
	int error;
	int s;
	const int on = 1;
	const int mtu = 1280;
	int newmtu = 1234;
	socklen_t optsize;
	char buf[2000];
	memset(&hints, 0, sizeof(hints));
	hints.ai_family = AF_INET6;
	hints.ai_socktype = SOCK_DGRAM;
	hints.ai_protocol = IPPROTO_UDP;
	hints.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV;

	error = getaddrinfo(argv[1], "8888", &hints, &res);
	if (error != 0) {
		return (error);
	}
	s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
	if (s == -1) {
		return (1);
	}
	if (setsockopt(s, IPPROTO_IPV6, IPV6_MTU, &mtu, sizeof(mtu))
	    != 0) {
		fprintf(stderr, "setsockopt(IPV6_MTU) failed\n");
	}
	optsize = sizeof(newmtu);
	if (getsockopt(s, IPPROTO_IPV6, IPV6_MTU, &newmtu, &optsize)
	    != 0) {
		perror("getsockopt");
	}
	printf("set IPV6_MTU to %d\n", newmtu);
	if (sendto(s, buf, sizeof(buf), 0, res->ai_addr, res->ai_addrlen)
	    == -1) {
		perror("sendto");
		return (2);
	}
	return (0);
}


More information about the bind10-dev mailing list