Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177713020
D61712.1795107658.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
6 KB
Referenced Files
None
Subscribers
None
D61712.1795107658.diff
View Options
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -1257,6 +1257,20 @@
/* prefixlen + ifidlen must be equal to 128 */
plen0 = in6_mask2len(&ib->ia_prefixmask.sin6_addr, NULL);
+ /*
+ * On PPP links the link-local address may be a /128
+ * holding the 64-bit interface identifier negotiated
+ * by IPV6CP (RFC 5072): tun(4) is IFT_PPP, ng_iface(4)
+ * used by mpd5 is IFT_PROPVIRTUAL.
+ * Other point-to-point interfaces (gif, gre, ...) are
+ * left alone, a /128 link-local address there is
+ * often a hand-picked fe80::1 or fe80::2.
+ */
+ if (plen0 == 128 &&
+ (ifp->if_flags & IFF_POINTOPOINT) != 0 &&
+ (ifp->if_type == IFT_PPP ||
+ ifp->if_type == IFT_PROPVIRTUAL))
+ plen0 = 64;
if (prefixlen == plen0) {
memcpy(&newaddr, &ib->ia_addr.sin6_addr,
sizeof(newaddr));
diff --git a/tests/sys/netinet6/ndp.sh b/tests/sys/netinet6/ndp.sh
--- a/tests/sys/netinet6/ndp.sh
+++ b/tests/sys/netinet6/ndp.sh
@@ -864,9 +864,10 @@
# SLAAC interface identifier selection in in6_ifadd(): a link-local
# address with the advertised prefix length lends its identifier to the
-# autoconfigured address, otherwise the identifier is derived from the MAC
-# address, which covers PPP links with a /128 link-local address as well as
-# interfaces without a link-local address. The MAC address below gives the
+# autoconfigured address, and so does a /128 one on a PPP link, where
+# IPV6CP negotiates the identifier. Otherwise the
+# identifier is derived from the MAC address, which covers interfaces
+# without a link-local address. The MAC address below gives the
# EUI-64 based identifier 11:22ff:fe33:4455. Stable addresses (RFC 7217)
# are switched off on the host, they bypass both paths.
ndp_slaac_prefix="2001:db8:ffff:2000"
@@ -1018,6 +1019,58 @@
vnet_cleanup
}
+atf_test_case "ndp_slaac_ifid_lladdr_plen128_p2p" "cleanup"
+ndp_slaac_ifid_lladdr_plen128_p2p_head() {
+ atf_set descr 'SLAAC takes the interface ID from a /128 link-local address on a point-to-point link'
+ atf_set require.user root
+ atf_set require.progs python3 scapy
+}
+
+ndp_slaac_ifid_lladdr_plen128_p2p_body() {
+ local tun jname pid i
+
+ vnet_init
+
+ jname="v6t-ndp_slaac_ifid_lladdr_plen128_p2p"
+
+ tun=$(ifconfig tun create)
+ list_interface ${tun}
+
+ vnet_mkjail ${jname} ${tun}
+
+ atf_check ifconfig -j ${jname} ${tun} inet6 -auto_linklocal \
+ -ifdisabled accept_rtadv -stableaddr no_dad
+ atf_check ifconfig -j ${jname} ${tun} inet6 \
+ fe80::${ndp_slaac_ll_ifid} fe80::1 prefixlen 128
+ atf_check ifconfig -j ${jname} ${tun} up
+
+ # The RA is written to the tun(4) device, which ra.py keeps open:
+ # closing it purges the addresses. Loading scapy can take a few
+ # seconds, so hold the device well past the polling below and stop
+ # ra.py once the address has been checked.
+ python3 $(atf_get_srcdir)/ra.py --sendif ${tun} --tun --hold 30 \
+ --src fe80::1 --dst ff02::1 \
+ --prefix "${ndp_slaac_prefix}::" --prefixlen 64 &
+ pid=$!
+ for i in $(jot 150); do
+ if ifconfig -j ${jname} ${tun} inet6 | \
+ grep -q "inet6 ${ndp_slaac_prefix}:.*autoconf"; then
+ break
+ fi
+ sleep 0.1
+ done
+
+ atf_check \
+ -o match:"inet6 ${ndp_slaac_prefix}:${ndp_slaac_ll_ifid} prefixlen 64.*autoconf" \
+ ifconfig -j ${jname} ${tun} inet6
+ kill ${pid} 2>/dev/null
+ wait ${pid}
+}
+
+ndp_slaac_ifid_lladdr_plen128_p2p_cleanup() {
+ vnet_cleanup
+}
+
atf_init_test_cases()
{
atf_add_test_case "ndp_add_gu_success"
@@ -1036,4 +1089,5 @@
atf_add_test_case "ndp_slaac_ifid_lladdr"
atf_add_test_case "ndp_slaac_ifid_no_lladdr"
atf_add_test_case "ndp_slaac_ifid_lladdr_plen128"
+ atf_add_test_case "ndp_slaac_ifid_lladdr_plen128_p2p"
}
diff --git a/tests/sys/netinet6/ra.py b/tests/sys/netinet6/ra.py
--- a/tests/sys/netinet6/ra.py
+++ b/tests/sys/netinet6/ra.py
@@ -6,8 +6,28 @@
#
import argparse
+import fcntl
+import os
import scapy.all as sp
+import socket
+import struct
import sys
+import time
+
+TUNSIFHEAD = 0x80047460 # _IOW('t', 96, int)
+
+
+#
+# Write an IPv6 packet to a tun(4) device, so that its interface receives it.
+# The interface goes down when the device is closed: keep it open for a
+# while.
+#
+def send_tun(ifname, pkt, hold):
+ fd = os.open("/dev/" + ifname, os.O_RDWR)
+ fcntl.ioctl(fd, TUNSIFHEAD, struct.pack("i", 1))
+ os.write(fd, struct.pack("!I", socket.AF_INET6) + bytes(pkt))
+ time.sleep(hold)
+ os.close(fd)
#
@@ -18,6 +38,11 @@
description="Emits Router Advertisement packets")
parser.add_argument('--sendif', nargs=1, required=True,
help='The interface through which the packet will be sent')
+ parser.add_argument('--tun', action='store_true',
+ help='--sendif is a tun(4) interface that receives the packet')
+ parser.add_argument('--hold', nargs=1, required=False,
+ type=int, default=[0],
+ help='Seconds to keep the tun(4) device open')
parser.add_argument('--src', nargs=1, required=True,
help='The source IP address')
parser.add_argument('--dst', nargs=1, required=True,
@@ -56,8 +81,7 @@
help='The route info preference advertised')
args = parser.parse_args()
- pkt = sp.Ether(src=sp.get_if_hwaddr(args.sendif[0])) / \
- sp.IPv6(src=args.src, dst=args.dst, hlim=args.hoplimit) / \
+ pkt = sp.IPv6(src=args.src, dst=args.dst, hlim=args.hoplimit) / \
sp.ICMPv6ND_RA(chlim=64,
prf=args.rtrpref,
routerlifetime=args.rtrltime)
@@ -76,7 +100,11 @@
prf=args.rtipref[i],
rtlifetime=args.rtiltime[i])
- sp.sendp(pkt, iface=args.sendif[0], verbose=False)
+ if args.tun:
+ send_tun(args.sendif[0], pkt, args.hold[0])
+ else:
+ pkt = sp.Ether(src=sp.get_if_hwaddr(args.sendif[0])) / pkt
+ sp.sendp(pkt, iface=args.sendif[0], verbose=False)
sys.exit(0)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 19, 5:00 PM (22 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41845960
Default Alt Text
D61712.1795107658.diff (6 KB)
Attached To
Mode
D61712: netinet6: Use the negotiated interface ID for SLAAC on PPP links
Attached
Detach File
Event Timeline