IPPROTO_DIVERT and PF_INET6

Edwin Groothuis edwin at mavetju.org
Sat May 3 10:17:22 UTC 2008


Greetings,

Before somebody shoots me down on it: I know that ipfw_divert() is
not suitable for IPv6 packets.

So, to the point. This code:

	struct sockaddr_in6     addr6;
        struct in6_addr ip6_any = IN6ADDR_ANY_INIT;

        sin = socket(PF_INET6, SOCK_RAW, IPPROTO_DIVERT);
        if (sin == -1)
                errx(1, "Unable to create sin socket.");
        if (sin > fdmax)
                fdmax = sin;

        addr6.sin6_family = AF_INET6;
        addr6.sin6_addr = ip6_any;
        addr6.sin6_port = htons(8669);

        if (bind(sin, (struct sockaddr *) &addr6, sizeof(addr6)) == -1)
                errx(1, "Unable to bind incoming divert socket: %s",
                    strerror(errno));

compiles and run fine, but it gives me this in the lsof output:

    nat6to4d  67887       root    3u    IPv6 0xc8b05000        0t0  HOPOPTS *:*

HOPOPTS is "0" according to /etc/protocols. Making everything IPv4,
it gives this:

    nat6to4d  67899       root    3u    IPv4 0xc865421c        0t0   DIVERT *:8669

which is what I expected. So why doesn't this get displayed for the
IPv6 sockets?

Edwin

-- 
Edwin Groothuis      |            Personal website: http://www.mavetju.org
edwin at mavetju.org    |              Weblog: http://www.mavetju.org/weblog/


More information about the freebsd-net mailing list