Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Sep 2014 00:17:18 -0400
From:      Russell Yount <russell.yount@gmail.com>
To:        freebsd-pf@freebsd.org
Cc:        Russell Yount <russell.yount@gmail.com>
Subject:   pf IPv6 NAT using link local addresses
Message-ID:  <CA%2BstrHHaGpkGVeu8Nn-pTL5r32VzvN76SODH3KxgGyYUkF1_nQ@mail.gmail.com>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Specify IPv6 NAT with FreeBSD 9.3 in pf.conf as

     nat on $external inet6 from $local6 to any -> ($external)

results in pf attempting to load balance between the routable IPv6
addresses and the link-local IPv6 address as the translation addresses.

Specify IPv6 NAT with FreeBSD 9.3 in pf.conf as

     nat on $external inet6 from $local6 to any -> ($external:0)

results in pf using the link-local IPv6 address as address as the
translation address.

Both of these behaviors are wrong; pf does not understand scope of IPv6
link-local addresses as different from routable ipV6 addresses.

The following patch permits the use of ($external::0) syntax to select the
first routable IPv6 address rather than the link-local address so it can be
used with IPv6 NAT correctly. It only handles the case of one routable IPV6
address and ($external) syntax still attempts to round-robin between
routable IPv6 addresses and the link-local IPv6 address. Not sure if
changing ($external) syntax to omit link-local addresses would cause other
problems?

-Russ <russell.yount@gmail.com>

--- usr/src/sys/contrib//pf/net/pf_if.c-orig    2014-07-10
17:59:41.000000000 -0400
+++ usr/src/sys/contrib//pf/net/pf_if.c 2014-08-24 18:13:57.000000000 -0400
@@ -690,6 +690,10 @@
                    IN6_IS_ADDR_LINKLOCAL(
                    &((struct sockaddr_in6 *)ia->ifa_addr)->sin6_addr))
                        continue;
+               if ((flags & PFI_AFLAG_NOALIAS) && af == AF_INET6 &&
+                   IN6_IS_ADDR_LINKLOCAL(
+                   &((struct sockaddr_in6 *)ia->ifa_addr)->sin6_addr))
+                       continue;
                if (flags & PFI_AFLAG_NOALIAS) {
                        if (af == AF_INET && got4)
                                continue;

[-- Attachment #2 --]
--- usr/src/sys/contrib//pf/net/pf_if.c-orig	2014-07-10 17:59:41.000000000 -0400
+++ usr/src/sys/contrib//pf/net/pf_if.c	2014-08-24 18:13:57.000000000 -0400
@@ -690,6 +690,10 @@
 		    IN6_IS_ADDR_LINKLOCAL(
 		    &((struct sockaddr_in6 *)ia->ifa_addr)->sin6_addr))
 			continue;
+		if ((flags & PFI_AFLAG_NOALIAS) && af == AF_INET6 &&
+		    IN6_IS_ADDR_LINKLOCAL(
+		    &((struct sockaddr_in6 *)ia->ifa_addr)->sin6_addr))
+			continue;
 		if (flags & PFI_AFLAG_NOALIAS) {
 			if (af == AF_INET && got4)
 				continue;

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2BstrHHaGpkGVeu8Nn-pTL5r32VzvN76SODH3KxgGyYUkF1_nQ>