🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
7 messages
7 total messages Started by Vincent Jardin via B4 Relay Thu, 26 Nov 2026 21:37
[PATCH net-next 0/5] lisp: add a LISP (RFC 9300) tunnel device
#23250
Author: Vincent Jardin via B4 Relay
Date: Thu, 26 Nov 2026 21:37
83 lines
13707 bytes
LISP (Locator/ID Separation Protocol, RFC 9300) carries the packets sent
to an endpoint identifier (EID) over UDP, to a routing locator (RLOC) of
the site of that EID. An EID prefix and its RLOCs are a mapping, which
the LISP control plane (RFC 9301) provides.

This series adds the data plane of a LISP router (xTR): a tunnel device,
link kind "lisp", for IPv4 and IPv6 EIDs over IPv4 and IPv6 RLOCs.

A mapping is a route. The device takes the RLOC of a packet from its
tunnel metadata, which the lwtunnel encapsulation of the route
or of its nexthop provides. A remote site is a nexthop, shared by its
EID prefixes:

  ip link add link wan name lisp101 type lisp id 101 local 192.0.2.1
  ip link set lisp101 master site up
  ip -6 nexthop add id 1 encap ip dst 198.51.100.1 dev lisp101
  ip route add 10.2.0.0/24 vrf site nhid 1
  ip -6 route add 2001:db8:2::/48 vrf site nhid 1

Design:

- The kernel has no map-cache and it does not resolve anything: no
  upcall, no state that the packets of a host create. Its tables are the
  routes and the nexthops, which a control plane in user space writes,
  as it does for any other routing protocol. A packet without RLOC ends
  up dropped.

- A remote site is a nexthop object, not a device: it has been designed
  to scale.

- The common UDP tunnel code is used: its sockets, GRO cells, GSO, the
  dst cache of the encapsulation, and a zero UDP checksum unless the
  encapsulation asks for one.

Note: a LISP driver was posted to netdev back to 2014 and was not
merged. It had a device per remote RLOC and IPv4 RLOCs only, and a
map-cache that traffic fills was not accepted.
lwtunnels is an alternative.

This design shall allow routing daemons like FRRouting to support LISP.

Patches:
- patch 1 adds the driver, drivers/net/lisp.c, and its link attributes
- patch 2 describes them in the rt-link netlink spec
- patch 3 adds Documentation/networking/lisp.rst
- patch 4 adds a selftest, lisp.sh
- patch 5 adds a scale selftest, lisp_scale.sh

The series only adds: no existing code path is changed.

The lisp link type of iproute2 comes as a separate series, for
iproute2-next. Tests are skipped without it. Tell me if you want
iproute2 series too for a simultaneous review.

---
Vincent Jardin (5):
      lisp: add LISP (Locator/ID Separation Protocol)
      netlink: specs: rt-link: add the lisp link type
      docs: net: document the LISP devices
      selftests: net: add a test of the LISP devices
      selftests: net: add a scale test for LISP

 Documentation/netlink/specs/rt-link.yaml  |   35 +
 Documentation/networking/index.rst        |    1 +
 Documentation/networking/lisp.rst         |  142 ++++
 MAINTAINERS                               |    8 +
 drivers/net/Kconfig                       |   20 +
 drivers/net/Makefile                      |    1 +
 drivers/net/lisp.c                        | 1033 ++++++++++++++++++++++++++
 include/uapi/linux/if_link.h              |   12 +
 tools/testing/selftests/net/Makefile      |    2 +
 tools/testing/selftests/net/config        |    4 +
 tools/testing/selftests/net/lisp.sh       | 1120 +++++++++++++++++++++++++++++
 tools/testing/selftests/net/lisp_scale.sh |  532 ++++++++++++++
 12 files changed, 2910 insertions(+)
---
base-commit: eb6d6c80d35449c27471b1874f13066c09a8964d
change-id: 20261126-for-upstream-lisp-v1-b47ac698d026

Best regards,
-- 
Vincent Jardin <vjardin@free.fr>
[PATCH net-next 4/5] selftests: net: add a test of the LISP devices
#23252
Author: Vincent Jardin via B4 Relay
Date: Thu, 26 Nov 2026 21:37
1199 lines
49862 bytes
From: Vincent Jardin <vjardin@free.fr>

Scenario: 2 xTRs carry the packets of 2 hosts through a core router.
The EIDs of the first one are in a VRF and its RLOCs in another one,
the second one uses its main table.

Signed-off-by: Vincent Jardin <vjardin@free.fr>
---
 MAINTAINERS                          |    1 +
 tools/testing/selftests/net/Makefile |    1 +
 tools/testing/selftests/net/config   |    4 +
 tools/testing/selftests/net/lisp.sh  | 1120 ++++++++++++++++++++++++++++++++++
 4 files changed, 1126 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index addedadf43446..0d3a537d87023 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -15512,6 +15512,7 @@ L:	netdev@vger.kernel.org
 S:	Maintained
 F:	Documentation/networking/lisp.rst
 F:	drivers/net/lisp.c
+F:	tools/testing/selftests/net/lisp*.sh
 
 LIST KUNIT TEST
 M:	David Gow <david@davidgow.net>
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index fb0a64662053f..7263049ab7c44 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -63,6 +63,7 @@ TEST_PROGS := \
 	l2_tos_ttl_inherit.sh \
 	l2tp.sh \
 	link_netns.py \
+	lisp.sh \
 	lwt_dst_cache_ref_loop.sh \
 	macvlan_mcast_shared_mac.sh \
 	msg_zerocopy.sh \
diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config
index dab62cdfa27ba..767c0fdb79353 100644
--- a/tools/testing/selftests/net/config
+++ b/tools/testing/selftests/net/config
@@ -31,8 +31,10 @@ CONFIG_IP6_NF_MATCH_SRH=m
 CONFIG_IP6_NF_NAT=m
 CONFIG_IP6_NF_RAW=m
 CONFIG_IP6_NF_TARGET_REJECT=m
+CONFIG_IP_ADVANCED_ROUTER=y
 CONFIG_IP_MROUTE=y
 CONFIG_IP_MULTICAST=y
+CONFIG_IP_MULTIPLE_TABLES=y
 CONFIG_IP_NF_FILTER=m
 CONFIG_IP_NF_IPTABLES=m
 CONFIG_IP_NF_IPTABLES_LEGACY=m
@@ -42,6 +44,7 @@ CONFIG_IP_NF_NAT=m
 CONFIG_IP_NF_RAW=m
 CONFIG_IP_NF_TARGET_REJECT=m
 CONFIG_IP_NF_TARGET_TTL=m
+CONFIG_IP_ROUTE_MULTIPATH=y
 CONFIG_IP_SCTP=m
 CONFIG_IPV6=y
 CONFIG_IPV6_FOU=m
@@ -64,6 +67,7 @@ CONFIG_L2TP=m
 CONFIG_L2TP_ETH=m
 CONFIG_L2TP_IP=m
 CONFIG_L2TP_V3=y
+CONFIG_LISP=m
 CONFIG_MACSEC=m
 CONFIG_MACVLAN=y
 CONFIG_MACVTAP=y
diff --git a/tools/testing/selftests/net/lisp.sh b/tools/testing/selftests/net/lisp.sh
new file mode 100755
index 0000000000000..780053db366bc
--- /dev/null
+++ b/tools/testing/selftests/net/lisp.sh
@@ -0,0 +1,1120 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Vincent Jardin <vjardin@free.fr>, Free Mobile
+#
+# Test the LISP data plane of drivers/net/lisp.c between two xTRs.
+#
+# The EIDs of x1 are in the VRF "site" and its RLOCs in the VRF "wan". x2 keeps
+# everything in its main table. The instance 101 has one LISP device on each
+# xTR. The instance 102 has a device on x1, in the VRF "site2", and uses a device
+# that collects metadata on x2.
+#
+#  h1          x1                         core               x2            h2
+#  10.1.0.2    10.1.0.1 (site)                               10.2.0.1      10.2.0.2
+#  fd00:1::2   fd00:1::1                                     fd00:2::1     fd00:2::2
+#        veth       lisp101 (site)                    lisp101      veth
+#                   lisp102 (site2)                   lispmd
+#                   192.0.2.1 (wan)      192.0.2.2
+#                   2001:db8:1::1  veth  2001:db8:1::2
+#                                        198.51.100.2        198.51.100.1
+#                                        2001:db8:2::2  veth 2001:db8:2::1
+
+source lib.sh
+
+# shellcheck disable=SC2155 # prefer RO variable over return value from cmd
+readonly CLI="$(dirname "$(readlink -f "$0")")/../../../net/ynl/pyynl/cli.py"
+
+ALL_TESTS="
+	netlink_test
+	ping_test
+	fields_test
+	mtu_test
+	pmtu_test
+	multipath_test
+	instance_test
+	receive_test
+	rpfilter_test
+	updown_test
+	tcp_test
+	cross_vrf_test
+	cross_netns_test
+	netns_test
+"
+
+LISP_PORT=4341
+IID=101
+
+X1_RLOC4=192.0.2.1
+X1_RLOC6=2001:db8:1::1
+X2_RLOC4=198.51.100.1
+X2_RLOC6=2001:db8:2::1
+
+# ID of the nexthop that reaches the other xTR at its RLOC of a family
+NH4=14
+NH6=16
+# IDs of the nexthops that a test makes for itself
+NH_FIELDS=24
+NH_GROUP=30
+NH_INSTANCE=40
+NH_OTHER=99
+
+# An RLOC that is not the one of an xTR
+OTHER_RLOC4=203.0.113.9
+
+TCP_PORT=5000
+TCP_TIMEOUT=60
+TCP_FILE=
+
+################################################################################
+# Helpers
+
+h1_ping()
+{
+	ip netns exec "$h1" ping -q -c 1 -W 2 "$@" > /dev/null 2>&1
+}
+
+h2_ping()
+{
+	ip netns exec "$h2" ping -q -c 1 -W 1 "$@" > /dev/null 2>&1
+}
+
+tc_packets()
+{
+	local ns=$1; shift
+	local dev=$1; shift
+	local pref=$1; shift
+
+	tc -n "$ns" -j -s filter show dev "$dev" ingress pref "$pref" |
+		jq '[.[] | select(.options.actions) |
+		     .options.actions[0].stats.packets] | add'
+}
+
+# On the core, coming from x1.
+core_packets()
+{
+	tc_packets "$core" c1 "$1"
+}
+
+h2_packets()
+{
+	tc_packets "$h2" eth0 "$1"
+}
+
+link_stat()
+{
+	local ns=$1; shift
+	local dev=$1; shift
+	local stat=$1; shift
+
+	ip -n "$ns" -j -s -s link show dev "$dev" | jq ".[0].stats64$stat"
+}
+
+# What the kernel answers to the creation of a device with these attributes,
+# which ip refuses to send.
+ynl_add()
+{
+	local data=$1; shift
+
+	ip netns exec "$x2" "$CLI" --family rt-link --create --excl \
+		--do newlink --json "{\"ifname\": \"t0\",
+			\"linkinfo\": {\"kind\": \"lisp\", \"data\": $data}}" 2>&1
+}
+
+# The EID prefixes of the instance 101 use the RLOCs of a family.
+use_rlocs()
+{
+	local family=$1; shift
+	local nh=NH$family
+
+	ip -n "$x1" route replace 10.2.0.0/24 vrf site nhid "${!nh}"
+	ip -n "$x1" -6 route replace fd00:2::/64 vrf site nhid "${!nh}"
+	ip -n "$x2" route replace 10.1.0.0/24 nhid "${!nh}"
+	ip -n "$x2" -6 route replace fd00:1::/64 nhid "${!nh}"
+}
+
+core_send()
+{
+	local bytes=$1; shift
+
+	ip netns exec "$core" bash -c \
+		"printf '$bytes' > /dev/udp/$X1_RLOC4/$LISP_PORT"
+}
+
+################################################################################
+# Setup
+
+host_setup()
+{
+	local ns=$1; shift
+	local id=$1; shift
+
+	ip -n "$ns" link set eth0 up
+	ip -n "$ns" addr add "10.$id.0.2/24" dev eth0
+	ip -n "$ns" addr add "fd00:$id::2/64" dev eth0 nodad
+	ip -n "$ns" route add default via "10.$id.0.1"
+	ip -n "$ns" -6 route add default via "fd00:$id::1"
+	tc -n "$ns" qdisc add dev eth0 clsact
+}
+
+setup()
+{
+	local ns
+
+	setup_ns h1 x1 core x2 h2 || return
+
+	for ns in "$h1" "$x1" "$core" "$x2" "$h2"; do
+		ip netns exec "$ns" sysctl -wq net.ipv6.conf.all.accept_dad=0
+		ip netns exec "$ns" sysctl -wq net.ipv6.conf.default.accept_dad=0
+	done
+	ip netns exec "$x2" sysctl -wq net.ipv6.bindv6only=1
+
+	ip link add eth0 netns "$h1" type veth peer name eth0 netns "$x1"
+	ip link add eth1 netns "$x1" type veth peer name c1 netns "$core"
+	ip link add eth1 netns "$x2" type veth peer name c2 netns "$core"
+	ip link add eth0 netns "$h2" type veth peer name eth0 netns "$x2"
+
+	for ns in "$x1" "$core" "$x2"; do
+		ip netns exec "$ns" sysctl -wq net.ipv4.ip_forward=1
+		ip netns exec "$ns" sysctl -wq net.ipv6.conf.all.forwarding=1
+	done
+
+	host_setup "$h1" 1
+	host_setup "$h2" 2
+
+	ip -n "$core" link set c1 up
+	ip -n "$core" link set c2 up
+	ip -n "$core" addr add 192.0.2.2/30 dev c1
+	ip -n "$core" addr add 2001:db8:1::2/64 dev c1 nodad
+	ip -n "$core" addr add 198.51.100.2/30 dev c2
+	ip -n "$core" addr add 2001:db8:2::2/64 dev c2 nodad
+	tc -n "$core" qdisc add dev c1 clsact
+	tc -n "$core" qdisc add dev c2 clsact
+
+	# The packets of the instance 101, by family of RLOC: the I flag and
+	# the instance ID after the UDP header, and DF in the IPv4 header.
+	tc -n "$core" filter add dev c1 ingress protocol ip pref 4 u32 \
+		match ip protocol 17 0xff match ip dport $LISP_PORT 0xffff \
+		match u16 0x4000 0xffff at 6 match u8 0x08 0xff at 28 \
+		match u32 $((IID << 8)) 0xffffffff at 32 action continue
+	tc -n "$core" filter add dev c1 ingress protocol ipv6 pref 6 u32 \
+		match ip6 protocol 17 0xff match ip6 dport $LISP_PORT 0xffff \
+		match u8 0x08 0xff at 48 \
+		match u32 $((IID << 8)) 0xffffffff at 52 action continue
+
+	ip -n "$x1" link add site type vrf table 10
+	ip -n "$x1" link add wan type vrf table 20
+	ip -n "$x1" link add site2 type vrf table 30
+	ip -n "$x1" link set site up
+	ip -n "$x1" link set wan up
+	ip -n "$x1" link set site2 up
+	ip -n "$x1" link set eth0 master site up
+	ip -n "$x1" link set eth1 master wan up
+	ip -n "$x1" addr add 10.1.0.1/24 dev eth0
+	ip -n "$x1" addr add fd00:1::1/64 dev eth0 nodad
+	ip -n "$x1" addr add $X1_RLOC4/30 dev eth1
+	ip -n "$x1" addr add $X1_RLOC6/64 dev eth1 nodad
+	ip -n "$x1" route add default vrf wan via 192.0.2.2
+	ip -n "$x1" -6 route add default vrf wan via 2001:db8:1::2
+
+	ip -n "$x1" link add link wan name lisp101 type lisp id $IID \
+		local $X1_RLOC4 local $X1_RLOC6 || return
+	ip -n "$x1" link set lisp101 master site up
+	ip -n "$x1" -6 nexthop add id $NH4 encap ip dst $X2_RLOC4 dev lisp101
+	ip -n "$x1" -6 nexthop add id $NH6 encap ip6 dst $X2_RLOC6 dev lisp101
+
+	ip -n "$x2" link set eth0 up
+	ip -n "$x2" link set eth1 up
+	ip -n "$x2" addr add 10.2.0.1/24 dev eth0
+	ip -n "$x2" addr add fd00:2::1/64 dev eth0 nodad
+	ip -n "$x2" addr add $X2_RLOC4/30 dev eth1
+	ip -n "$x2" addr add $X2_RLOC6/64 dev eth1 nodad
+	ip -n "$x2" route add default via 198.51.100.2
+	ip -n "$x2" -6 route add default via 2001:db8:2::2
+
+	ip -n "$x2" link add lisp101 type lisp id $IID
+	ip -n "$x2" link set lisp101 up
+	ip -n "$x2" -6 nexthop add id $NH4 encap ip dst $X1_RLOC4 dev lisp101
+	ip -n "$x2" -6 nexthop add id $NH6 encap ip6 dst $X1_RLOC6 dev lisp101
+
+	use_rlocs 4
+}
+
+cleanup()
+{
+	[[ -n $TCP_FILE ]] && rm -f "$TCP_FILE" "$TCP_FILE.out"
+	cleanup_all_ns
+}
+
+################################################################################
+# Tests
+
+netlink_test()
+{
+	local out
+
+	RET=0
+
+	out=$(ip -n "$x2" link add t0 type lisp id $IID 2>&1)
+	check_fail $? "an instance ID is used twice"
+	[[ $out == *"already has this instance ID"* ]]
+	check_err $? "unexpected error for a used instance ID: $out"
+
+	ip -n "$x2" link add t1 type lisp external
+	check_err $? "no device that collects metadata"
+	out=$(ip -n "$x2" link add t0 type lisp external 2>&1)
+	check_fail $? "two devices collect metadata"
+	[[ $out == *"already collects the metadata"* ]]
+	check_err $? "unexpected error for a second device with metadata: $out"
+	out=$(ip -n "$x2" -d -j link show dev t1 |
+	      jq -c '.[0].linkinfo.info_data')
+	[[ $out == '{"external":true}' ]]
+	check_err $? "unexpected attributes with metadata: $out"
+	ip -n "$x2" link del t1
+
+	out=$(ip -n "$x2" link add t0 type lisp id 7 local 224.0.0.1 2>&1)
+	check_fail $? "a multicast local RLOC is accepted"
+	[[ $out == *"not a unicast address"* ]]
+	check_err $? "unexpected error for a multicast RLOC: $out"
+
+	out=$(ip -n "$x2" link add t0 type lisp id 7 local fe80::1 2>&1)
+	check_fail $? "a link-local local RLOC is accepted"
+	[[ $out == *"not a global unicast address"* ]]
+	check_err $? "unexpected error for a link-local RLOC: $out"
+
+	out=$(ip -n "$x2" link set lisp101 type lisp id 7 2>&1)
+	check_fail $? "the instance ID of a device can be changed"
+	[[ $out == *"Operation not supported"* ]]
+	check_err $? "unexpected error for a change: $out"
+	ip -n "$x1" link set lisp101 type lisp local 192.0.2.99 2> /dev/null
+	check_fail $? "a local RLOC of a device can be changed"
+
+	ip -n "$x2" link add t0 type lisp id 16777215 local 192.0.2.9 \
+		local 2001:db8::9
+	check_err $? "the highest instance ID is refused"
+	out=$(ip -n "$x2" -d -j link show dev t0 | jq -c \
+		'.[0] | [.mtu, .linkinfo.info_data.id,
+			 .linkinfo.info_data.local, .linkinfo.info_data.local6]')
+	[[ $out == '[1444,16777215,"192.0.2.9","2001:db8::9"]' ]]
+	check_err $? "unexpected attributes: $out"
+	ip -n "$x2" link del t0
+
+	[[ $(ip -n "$x1" -j link show dev lisp101 | jq -r '.[0].link') == wan ]]
+	check_err $? "the link of the RLOCs is not reported"
+
+	# The same instance ID can be used with RLOCs of another l3mdev, but
+	# not twice with the same one.
+	ip -n "$x1" link add link site2 name t0 type lisp id $IID
+	check_err $? "an instance ID cannot be used with two l3mdevs"
+	ip -n "$x1" link set t0 up
+	check_err $? "an instance ID cannot be up with two l3mdevs"
+	ip -n "$x1" link del t0
+
+	out=$(ip -n "$x1" link add link eth1 name t0 type lisp id $IID 2>&1)
+	check_fail $? "an instance ID is used twice with the links of an l3mdev"
+	[[ $out == *"already has this instance ID"* ]]
+	check_err $? "unexpected error for a used l3mdev: $out"
+
+	# A link that joins the l3mdev later: the device cannot be up.
+	ip -n "$x1" link add port9 type dummy
+	ip -n "$x1" link add link port9 name t0 type lisp id $IID
+	check_err $? "an instance ID cannot be used with a link of the main table"
+	ip -n "$x1" link set port9 master wan
+	out=$(ip -n "$x1" link set t0 up 2>&1)
+	check_fail $? "an instance ID is up twice with the same l3mdev"
+	[[ $out == *"Device or resource busy"* ]]
+	check_err $? "unexpected error for a used l3mdev: $out"
+
+	# A device goes with its link.
+	ip -n "$x1" link del port9
+	busywait "$BUSYWAIT_TIMEOUT" bash -c \
+		"! ip -n $x1 link show dev t0 > /dev/null 2>&1"
+	check_err $? "a device outlives its link"
+
+	log_test "Device attributes"
+
+	if ! "$CLI" --family rt-link --list-ops > /dev/null 2>&1; then
+		log_test_skip "Device attributes that ip does not send" \
+			"YNL CLI not usable"
+		return
+	fi
+
+	RET=0
+
+	out=$(ynl_add '{"id": 16777216}')
+	[[ $out == *"Numerical result out of range"* ]]
+	check_err $? "unexpected answer to an instance ID of 25 bits: $out"
+	out=$(ynl_add '{"local": "192.0.2.9"}')
+	[[ $out == *"Invalid argument"* ]]
+	check_err $? "unexpected answer without instance ID: $out"
+	out=$(ynl_add '{"id": 7, "collect-metadata": true}')
+	[[ $out == *"Invalid argument"* ]]
+	check_err $? "unexpected answer with an instance ID and metadata: $out"
+	out=$(ynl_add '{"id": 7, "local": "192.0.2.9"}')
+	check_err $? "unexpected answer to valid attributes: $out"
+	ip -n "$x2" link del t0
+
+	log_test "Device attributes that ip does not send"
+}
+
+rloc_family_test()
+{
+	local family=$1; shift
+	local other=$1; shift
+	local before_other
+	local before
+
+	RET=0
+
+	use_rlocs "$family"
+	before=$(core_packets "$family")
+	before_other=$(core_packets "$other")
+
+	h1_ping 10.2.0.2
+	check_err $? "no answer from the IPv4 EID"
+	h1_ping fd00:2::2
+	check_err $? "no answer from the IPv6 EID"
+
+	(( $(core_packets "$family") - before == 2 ))
+	check_err $? "unexpected LISP header with IPv$family RLOCs"
+	(( $(core_packets "$other") == before_other ))
+	check_err $? "packets sent to IPv$other RLOCs"
+
+	log_test "IPv4 and IPv6 EIDs with IPv$family RLOCs"
+}
+
+ping_test()
+{
+	rloc_family_test 4 6
+	rloc_family_test 6 4
+	use_rlocs 4
+}
+
+# The TTL and the DSCP of a packet go to the outer header, then come back with
+# what the core did to them. The host sends 20, x1 forwards 19, which the core
+# gets in the outer header and forwards as 18. x2 forwards 17.
+fields_test()
+{
+	RET=0
+
+	tc -n "$core" filter add dev c1 ingress protocol ip pref 10 u32 \
+		match ip dport $LISP_PORT 0xffff match ip tos 0x28 0xff \
+		match u8 19 0xff at 8 action pass
+	tc -n "$h2" filter add dev eth0 ingress protocol ip pref 10 u32 \
+		match ip protocol 1 0xff match ip tos 0x28 0xff \
+		match u8 17 0xff at 8 action pass
+	tc -n "$h2" filter add dev eth0 ingress protocol ipv6 pref 11 u32 \
+		match ip6 protocol 58 0xff match ip6 priority 0x28 0xff \
+		match u8 17 0xff at 7 action pass
+
+	h1_ping -t 20 -Q 0x28 10.2.0.2
+	check_err $? "no answer from the IPv4 EID"
+	h1_ping -t 20 -Q 0x28 fd00:2::2
+	check_err $? "no answer from the IPv6 EID"
+
+	(( $(core_packets 10) == 2 ))
+	check_err $? "the outer header did not inherit the TTL and the DSCP"
+	(( $(h2_packets 10) == 1 ))
+	check_err $? "the IPv4 packet did not get the outer TTL and DSCP"
+	(( $(h2_packets 11) == 1 ))
+	check_err $? "the IPv6 packet did not get the outer TTL and DSCP"
+
+	tc -n "$core" filter del dev c1 ingress pref 10
+	tc -n "$h2" filter del dev eth0 ingress pref 10
+	tc -n "$h2" filter del dev eth0 ingress pref 11
+	log_test "TTL and DSCP inherited"
+
+	RET=0
+
+	ip -n "$x1" -6 nexthop add id $NH_FIELDS encap ip dst $X2_RLOC4 ttl 5 \
+		tos 0x40 dev lisp101
+	ip -n "$x1" route replace 10.2.0.0/24 vrf site nhid $NH_FIELDS
+	ip -n "$x1" -6 route replace fd00:2::/64 vrf site nhid $NH_FIELDS
+
+	tc -n "$core" filter add dev c1 ingress protocol ip pref 10 u32 \
+		match ip dport $LISP_PORT 0xffff match ip tos 0x42 0xff \
+		match u8 5 0xff at 8 action pass
+	tc -n "$core" filter add dev c2 egress protocol ip pref 10 u32 \
+		match ip dport $LISP_PORT 0xffff match ip tos 0x02 0x03 \
+		action pedit ex munge ip tos set 0x03 retain 0x03 \
+		pipe action csum ip4h
+	tc -n "$h2" filter add dev eth0 ingress protocol ip pref 10 u32 \
+		match ip protocol 1 0xff match ip tos 0x43 0xff \
+		match u8 3 0xff at 8 action pass
+	tc -n "$h2" filter add dev eth0 ingress protocol ipv6 pref 11 u32 \
+		match ip6 protocol 58 0xff match ip6 priority 0x43 0xff \
+		match u8 3 0xff at 7 action pass
+
+	h1_ping -Q 0x2a 10.2.0.2
+	check_err $? "no answer from the IPv4 EID"
+	h1_ping -Q 0x2a fd00:2::2
+	check_err $? "no answer from the IPv6 EID"
+
+	(( $(core_packets 10) == 2 ))
+	check_err $? "the outer header did not get the TTL and DSCP of the nexthop"
+	(( $(h2_packets 10) == 1 ))
+	check_err $? "the IPv4 packet did not get the outer TTL, DSCP and ECN"
+	(( $(h2_packets 11) == 1 ))
+	check_err $? "the IPv6 packet did not get the outer TTL, DSCP and ECN"
+
+	tc -n "$core" filter del dev c1 ingress pref 10
+	tc -n "$core" filter del dev c2 egress pref 10
+	tc -n "$h2" filter del dev eth0 ingress pref 10
+	tc -n "$h2" filter del dev eth0 ingress pref 11
+	use_rlocs 4
+	ip -n "$x1" nexthop del id $NH_FIELDS
+	log_test "TTL and DSCP of the nexthop, congestion marked by the core"
+}
+
+mtu_test()
+{
+	local family
+
+	for family in 4 6; do
+		RET=0
+		use_rlocs "$family"
+
+		h1_ping -M do -s 1416 10.2.0.2
+		check_err $? "an IPv4 packet of 1444 bytes is lost"
+		h1_ping -M do -s 1417 10.2.0.2
+		check_fail $? "an IPv4 packet of 1445 bytes goes through"
+		h1_ping -s 1396 fd00:2::2
+		check_err $? "an IPv6 packet of 1444 bytes is lost"
+		h1_ping -s 1397 fd00:2::2
+		check_fail $? "an IPv6 packet of 1445 bytes goes through"
+		h1_ping -s 3000 10.2.0.2
+		check_err $? "IPv4 fragments are lost"
+
+		log_test "Device MTU with IPv$family RLOCs"
+	done
+
+	ip -n "$h1" route flush cache
+	ip -n "$h1" -6 route flush cache
+	use_rlocs 4
+}
+
+pmtu_family_test()
+{
+	local family=$1; shift
+	local hlen=$1; shift
+	local mtu=$((1400 - hlen))
+
+	RET=0
+	use_rlocs "$family"
+
+	h1_ping -M do -s 1372 10.2.0.2
+	check_fail $? "a packet goes through a path that is too small"
+	h1_ping -M do -s 1372 10.2.0.2
+	check_fail $? "a packet goes through a path that is known as too small"
+	ip -n "$h1" route get 10.2.0.2 | grep -qw "mtu $mtu"
+	check_err $? "no IPv4 path MTU of $mtu on the host"
+	h1_ping -M do -s $((mtu - 28)) 10.2.0.2
+	check_err $? "an IPv4 packet of the path MTU is lost"
+
+	h1_ping -s 1352 fd00:2::2
+	check_fail $? "an IPv6 packet goes through a path that is too small"
+	ip -n "$h1" -6 route get fd00:2::2 | grep -qw "mtu $mtu"
+	check_err $? "no IPv6 path MTU of $mtu on the host"
+	h1_ping -s $((mtu - 48)) fd00:2::2
+	check_err $? "an IPv6 packet of the path MTU is lost"
+
+	log_test "Path MTU with IPv$family RLOCs"
+
+	ip -n "$h1" route flush cache
+	ip -n "$h1" -6 route flush cache
+	ip -n "$x1" route flush cache
+	ip -n "$x1" -6 route flush cache
+}
+
+frag_family_test()
+{
+	local family=$1; shift
+
+	RET=0
+	use_rlocs "$family"
+
+	# x1 learns the path MTU to the RLOC with a first packet.
+	h1_ping -s 1232 fd00:2::2
+	h1_ping -s 1232 fd00:2::2
+	check_err $? "an IPv6 packet of 1280 bytes is lost"
+	h1_ping -s 1233 fd00:2::2
+	check_fail $? "an IPv6 packet of 1281 bytes goes through"
+	ip -n "$h1" -6 route get fd00:2::2 | grep -qw "mtu 1280"
+	check_err $? "no IPv6 path MTU of 1280 on the host"
+
+	log_test "Path that leaves less than 1280 bytes, IPv$family RLOCs"
+
+	ip -n "$h1" -6 route flush cache
+	ip -n "$x1" route flush cache
+	ip -n "$x1" -6 route flush cache
+}
+
+pmtu_test()
+{
+	ip -n "$core" link set c2 mtu 1400
+	ip -n "$x2" link set eth1 mtu 1400
+
+	pmtu_family_test 4 36
+	pmtu_family_test 6 56
+
+	ip -n "$core" link set c2 mtu 1300
+	ip -n "$x2" link set eth1 mtu 1300
+
+	frag_family_test 4
+	frag_family_test 6
+
+	ip -n "$core" link set c2 mtu 1500
+	ip -n "$x2" link set eth1 mtu 1500
+	use_rlocs 4
+}
+
+multipath_test()
+{
+	local before4
+	local before6
+	local i
+
+	RET=0
+
+	for i in $(seq 16 47); do
+		ip -n "$h2" addr add "10.2.0.$i/24" dev eth0
+	done
+	ip -n "$x1" nexthop add id $NH_GROUP group $NH4/$NH6
+	ip -n "$x1" route replace 10.2.0.0/24 vrf site nhid $NH_GROUP
+
+	before4=$(core_packets 4)
+	before6=$(core_packets 6)
+	for i in $(seq 16 47); do
+		h1_ping "10.2.0.$i"
+		check_err $? "no answer from 10.2.0.$i"
+	done
+
+	(( $(core_packets 4) > before4 ))
+	check_err $? "nothing was sent to the IPv4 RLOC of the group"
+	(( $(core_packets 6) > before6 ))
+	check_err $? "nothing was sent to the IPv6 RLOC of the group"
+	(( $(core_packets 4) + $(core_packets 6) - before4 - before6 == 32 ))
+	check_err $? "packets were not sent once"
+
+	# The group counts what it sends to each RLOC.
+	(( $(ip -n "$x1" -j -s nexthop show id $NH_GROUP | jq --argjson id $NH4 \
+	     '.[0].group_stats[] | select(.id == $id) | .packets') ==
+	   $(core_packets 4) - before4 ))
+	check_err $? "unexpected count of the packets sent to the IPv4 RLOC"
+	(( $(ip -n "$x1" -j -s nexthop show id $NH_GROUP | jq --argjson id $NH6 \
+	     '.[0].group_stats[] | select(.id == $id) | .packets') ==
+	   $(core_packets 6) - before6 ))
+	check_err $? "unexpected count of the packets sent to the IPv6 RLOC"
+
+	use_rlocs 4
+	ip -n "$x1" nexthop del id $NH_GROUP
+	for i in $(seq 16 47); do
+		ip -n "$h2" addr del "10.2.0.$i/24" dev eth0
+	done
+	log_test "Group of nexthops"
+}
+
+# Another instance uses the same sockets: a device in another VRF of x1, and
+# the device that collects metadata on x2, where the routes give the instance
+# ID.
+instance_test()
+{
+	local rx_before
+	local tx_errors
+	local family
+	local addr
+
+	RET=0
+
+	ip -n "$x1" link add link wan name lisp102 type lisp id 102
+	ip -n "$x1" link set lisp102 master site2 up
+	ip -n "$x1" addr add 10.9.1.1/32 dev lisp102
+	ip -n "$x1" addr add fd00:91::1/128 dev lisp102 nodad
+
+	ip -n "$x2" link add lispmd type lisp external
+	ip -n "$x2" link set lispmd up
+	ip -n "$x2" link add dummy0 type dummy
+	ip -n "$x2" link set dummy0 up
+	ip -n "$x2" addr add 10.9.2.1/24 dev dummy0
+	ip -n "$x2" addr add fd00:92::1/64 dev dummy0 nodad
+	tc -n "$x2" qdisc add dev lispmd clsact
+
+	for family in 4 6; do
+		if [[ $family == 4 ]]; then
+			ip -n "$x1" -6 nexthop add id $NH_INSTANCE encap ip \
+				dst $X2_RLOC4 dev lisp102
+			ip -n "$x2" -6 nexthop add id $NH_INSTANCE encap ip \
+				id 102 dst $X1_RLOC4 dev lispmd
+			tc -n "$x2" filter add dev lispmd ingress pref 1 \
+				flower enc_key_id 102 enc_src_ip $X1_RLOC4 \
+				action pass
+		else
+			ip -n "$x1" -6 nexthop replace id $NH_INSTANCE encap ip6 \
+				dst $X2_RLOC6 dev lisp102
+			ip -n "$x2" -6 nexthop replace id $NH_INSTANCE encap ip6 \
+				id 102 dst $X1_RLOC6 dev lispmd
+			tc -n "$x2" filter add dev lispmd ingress pref 1 \
+				flower enc_key_id 102 enc_src_ip $X1_RLOC6 \
+				action pass
+		fi
+		ip -n "$x1" route replace 10.9.2.0/24 vrf site2 nhid $NH_INSTANCE
+		ip -n "$x1" -6 route replace fd00:92::/64 vrf site2 \
+			nhid $NH_INSTANCE
+		ip -n "$x2" route replace 10.9.1.0/24 nhid $NH_INSTANCE
+		ip -n "$x2" -6 route replace fd00:91::/64 nhid $NH_INSTANCE
+
+		rx_before=$(link_stat "$x1" lisp101 .rx.packets)
+		for addr in 10.9.2.1 fd00:92::1; do
+			ip netns exec "$x1" ping -q -c 1 -W 2 -I site2 "$addr" \
+				> /dev/null 2>&1
+			check_err $? "no answer from $addr with IPv$family RLOCs"
+		done
+
+		(( $(tc_packets "$x2" lispmd 1) == 2 ))
+		check_err $? "no metadata with IPv$family RLOCs"
+		(( $(link_stat "$x1" lisp101 .rx.packets) == rx_before ))
+		check_err $? "packets received by another instance"
+
+		tc -n "$x2" filter del dev lispmd ingress pref 1
+	done
+
+	h1_ping 10.2.0.2
+	check_err $? "the first instance is lost"
+
+	# An instance ID that does not fit the header: the device refuses it.
+	ip -n "$x2" -6 route del fd00:91::/64
+	ip -n "$x2" -6 nexthop replace id $NH_INSTANCE encap ip id 16777216 \
+		dst $X1_RLOC4 dev lispmd
+	tx_errors=$(link_stat "$x2" lispmd .tx.errors)
+	ip netns exec "$x2" ping -q -c 1 -W 1 10.9.1.1 > /dev/null 2>&1
+	check_fail $? "an instance ID of 25 bits is sent"
+	(( $(link_stat "$x2" lispmd .tx.errors) == tx_errors + 1 ))
+	check_err $? "an instance ID of 25 bits is not refused by the device"
+
+	ip -n "$x2" route del 10.9.1.0/24
+	ip -n "$x2" nexthop del id $NH_INSTANCE
+	ip -n "$x2" link del dummy0
+	ip -n "$x2" link del lispmd
+	ip -n "$x1" link del lisp102
+	log_test "Instances with a device each and with metadata"
+}
+
+receive_test()
+{
+	local frame_errors
+	local length_errors
+	local rx
+
+	RET=0
+
+	rx=$(link_stat "$x1" lisp101 .rx.packets)
+	frame_errors=$(link_stat "$x1" lisp101 .rx.frame_errors)
+	length_errors=$(link_stat "$x1" lisp101 .rx.length_errors)
+
+	# Neither IPv4 nor IPv6 after the header.
+	core_send '\x08\x00\x00\x00\x00\x00\x65\x00\x00\x00\x00\x00'
+	busywait "$BUSYWAIT_TIMEOUT" until_counter_is \
+		"== $((frame_errors + 1))" \
+		link_stat "$x1" lisp101 .rx.frame_errors > /dev/null
+	check_err $? "a payload of an unknown version is not counted"
+
+	# An IPv4 header that is cut.
+	core_send '\x08\x00\x00\x00\x00\x00\x65\x00\x45\x00\x00\x00'
+	busywait "$BUSYWAIT_TIMEOUT" until_counter_is \
+		"== $((length_errors + 1))" \
+		link_stat "$x1" lisp101 .rx.length_errors > /dev/null
+	check_err $? "a short payload is not counted"
+
+	# An encrypted payload, an unknown instance, and no instance.
+	core_send '\x09\x00\x00\x00\x00\x00\x65\x00\x00\x00\x00\x00'
+	core_send '\x08\x00\x00\x00\x00\x00\x66\x00\x00\x00\x00\x00'
+	core_send '\x00\x00\x00\x00\x00\x00\x65\x00\x00\x00\x00\x00'
+	core_send '\x08\x00\x00\x00\x00\x00\x65\x00\x00\x00\x00\x00'
+	busywait "$BUSYWAIT_TIMEOUT" until_counter_is \
+		"== $((frame_errors + 2))" \
+		link_stat "$x1" lisp101 .rx.frame_errors > /dev/null
+	check_err $? "packets of other instances are counted"
+
+	# Without the I flag, the instance is 0.
+	ip -n "$x1" link add link wan name lisp0 type lisp id 0
+	ip -n "$x1" link set lisp0 up
+	core_send '\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00'
+	busywait "$BUSYWAIT_TIMEOUT" until_counter_is "== 1" \
+		link_stat "$x1" lisp0 .rx.frame_errors > /dev/null
+	check_err $? "a packet without instance ID is not for the instance 0"
+	ip -n "$x1" link del lisp0
+
+	(( $(link_stat "$x1" lisp101 .rx.packets) == rx ))
+	check_err $? "packets were received"
+
+	# A route without RLOC.
+	ip -n "$x1" route add 10.3.0.0/24 vrf site dev lisp101
+	rx=$(link_stat "$x1" lisp101 .tx.errors)
+	h1_ping -W 1 10.3.0.1
+	(( $(link_stat "$x1" lisp101 .tx.errors) == rx + 1 ))
+	check_err $? "a packet without RLOC is not counted"
+	ip -n "$x1" route del 10.3.0.0/24 vrf site
+
+	log_test "Packets that are dropped"
+}
+
+# the reverse path filter of IPv4 dropped on x1
+x1_filtered()
+{
+	ip netns exec "$x1" nstat -asz TcpExtIPReversePathFilter |
+		awk '$1 == "TcpExtIPReversePathFilter" { print $2 }'
+}
+
+h1_echos()
+{
+	ip netns exec "$h1" nstat -asz IcmpInEchos |
+		awk '$1 == "IcmpInEchos" { print $2 }'
+}
+
+rpfilter_test()
+{
+	local filtered
+	local echos
+	local all
+
+	RET=0
+
+	use_rlocs 4
+	all=$(ip netns exec "$x1" sysctl -n net.ipv4.conf.all.rp_filter)
+	ip netns exec "$x1" sysctl -qw net.ipv4.conf.all.rp_filter=0
+	ip netns exec "$x1" sysctl -qw net.ipv4.conf.lisp101.rp_filter=1
+
+	h2_ping 10.1.0.2
+	check_err $? "a source is dropped, whose route sends to the device"
+
+	# The route of the source has another RLOC than the one of x2.
+	ip -n "$x1" -6 nexthop add id $NH_OTHER encap ip dst $OTHER_RLOC4 \
+		dev lisp101
+	ip -n "$x1" route replace 10.2.0.0/24 vrf site nhid $NH_OTHER
+	echos=$(h1_echos)
+	h2_ping 10.1.0.2
+	busywait "$BUSYWAIT_TIMEOUT" until_counter_is "== $((echos + 1))" \
+		h1_echos > /dev/null
+	check_err $? "a source is dropped for the RLOC that it comes from"
+
+	ip -n "$x1" link add nomap type dummy
+	ip -n "$x1" link set nomap master site up
+	ip -n "$x1" route replace 10.2.0.0/24 vrf site dev nomap
+	filtered=$(x1_filtered)
+	h2_ping 10.1.0.2
+	busywait "$BUSYWAIT_TIMEOUT" until_counter_is "== $((filtered + 1))" \
+		x1_filtered > /dev/null
+	check_err $? "a source without mapping is not dropped by the filter"
+
+	ip netns exec "$x1" sysctl -qw net.ipv4.conf.lisp101.rp_filter=0
+	echos=$(h1_echos)
+	h2_ping 10.1.0.2
+	busywait "$BUSYWAIT_TIMEOUT" until_counter_is "== $((echos + 1))" \
+		h1_echos > /dev/null
+	check_err $? "a source without mapping is dropped without the filter"
+
+	ip netns exec "$x1" sysctl -qw net.ipv4.conf.all.rp_filter="$all"
+	ip -n "$x1" link del nomap
+	ip -n "$x1" nexthop del id $NH_OTHER
+	use_rlocs 4
+	h2_ping 10.1.0.2
+	check_err $? "no connectivity after the test"
+
+	log_test "Reverse path filter on a device"
+}
+
+updown_test()
+{
+	RET=0
+
+	ip -n "$x1" link add link wan name lisp102 type lisp id 102
+	ip -n "$x1" link set lisp102 up
+	ip -n "$x1" link set lisp101 down
+	h1_ping -W 1 10.2.0.2
+	check_fail $? "an answer through a device that is down"
+
+	ip -n "$x1" nexthop show id $NH4 > /dev/null 2>&1
+	check_fail $? "a nexthop outlives its device"
+	ip -n "$x1" link set lisp101 up
+	ip -n "$x1" -6 nexthop add id $NH4 encap ip dst $X2_RLOC4 dev lisp101
+	ip -n "$x1" -6 nexthop add id $NH6 encap ip6 dst $X2_RLOC6 dev lisp101
+	use_rlocs 4
+	ip -n "$x1" link del lisp102
+	h1_ping 10.2.0.2
+	check_err $? "no answer once the device is up again"
+
+	ip -n "$x1" link set lisp101 down
+	ip -n "$x1" link set lisp101 up
+	ip -n "$x1" -6 nexthop add id $NH4 encap ip dst $X2_RLOC4 dev lisp101
+	ip -n "$x1" -6 nexthop add id $NH6 encap ip6 dst $X2_RLOC6 dev lisp101
+	use_rlocs 4
+	h1_ping fd00:2::2
+	check_err $? "no answer with a new socket"
+
+	log_test "Devices going down and up"
+}
+
+tcp_family_test()
+{
+	local family=$1; shift
+	local addr=$1; shift
+	local pid
+
+	ip netns exec "$h2" timeout $TCP_TIMEOUT socat -u \
+		"TCP$family-LISTEN:$TCP_PORT,reuseaddr" \
+		"OPEN:$TCP_FILE.out,creat,trunc" &
+	pid=$!
+	wait_local_port_listen "$h2" $TCP_PORT tcp
+	if ip netns exec "$h1" timeout $TCP_TIMEOUT socat -u "OPEN:$TCP_FILE" \
+			"TCP$family:$addr:$TCP_PORT"; then
+		wait $pid
+		check_err $? "the listener of $addr did not end"
+	else
+		check_err 1 "no TCP connection to $addr"
+		kill_process $pid
+	fi
+
+	cmp -s "$TCP_FILE" "$TCP_FILE.out"
+	check_err $? "the data sent to $addr is not what was received"
+}
+
+tcp_test()
+{
+	local family
+
+	if ! command -v socat > /dev/null; then
+		log_test_skip "TCP" "socat not installed"
+		return
+	fi
+
+	TCP_FILE=$(mktemp)
+	head -c 16M /dev/urandom > "$TCP_FILE"
+
+	for family in 4 6; do
+		RET=0
+		use_rlocs "$family"
+		tcp_family_test 4 10.2.0.2
+		tcp_family_test 6 "[fd00:2::2]"
+		log_test "TCP with IPv$family RLOCs"
+	done
+	use_rlocs 4
+}
+
+# Two xTRs whose EIDs and RLOCs are in two routing domains with the same
+# addresses: the EID of an xTR is the RLOC of the other one. A packet and its
+# outer header have then the same addresses, the other way around, and they
+# only reach their destinations when each one is routed in its own domain.
+CROSS_A4=192.0.2.9
+CROSS_A6=2001:db8:3::1
+CROSS_B4=192.0.2.10
+CROSS_B6=2001:db8:3::2
+
+cross_nexthops()
+{
+	local ns=$1; shift
+	local rloc4=$1; shift
+	local rloc6=$1; shift
+
+	ip -n "$ns" -6 nexthop add id $NH4 encap ip dst "$rloc4" dev lisp0
+	ip -n "$ns" -6 nexthop add id $NH6 encap ip6 dst "$rloc6" dev lisp0
+}
+
+cross_routes()
+{
+	local ns=$1; shift
+	local nh=$1; shift
+	local eid4=$1; shift
+	local eid6=$1; shift
+
+	ip -n "$ns" route replace "$eid4/32" "$@" nhid "$nh"
+	ip -n "$ns" -6 route replace "$eid6/128" "$@" nhid "$nh"
+}
+
+cross_ping()
+{
+	local ns=$1; shift
+	local eid4=$1; shift
+	local eid6=$1; shift
+	local before
+
+	before=$(link_stat "$ns" lisp0 .rx.packets)
+	ip netns exec "$ns" ping -q -c 1 -W 2 "$@" "$eid4" > /dev/null 2>&1
+	check_err $? "no answer from the EID $eid4"
+	ip netns exec "$ns" ping -q -c 1 -W 2 "$@" "$eid6" > /dev/null 2>&1
+	check_err $? "no answer from the EID $eid6"
+	(( $(link_stat "$ns" lisp0 .rx.packets) == before + 2 ))
+	check_err $? "the answers did not come through the LISP device"
+}
+
+# The first xTR has its EIDs in a VRF and its RLOCs in the main table, the
+# second one has its RLOCs in a VRF and its EIDs in the main table.
+#
+#   y1                                           y2
+#   VRF "eid", lisp0: B4, B6 ................... lisp0: A4, A6
+#   eth0: A4, A6 ------------------------------- VRF "rloc", eth0: B4, B6
+cross_vrf_test()
+{
+	local family
+	local before
+	local ns
+	local nh
+
+	setup_ns y1 y2
+	ip link add eth0 netns "$y1" type veth peer name eth0 netns "$y2"
+
+	for ns in "$y1" "$y2"; do
+		ip -n "$ns" rule add pref 32765 table local
+		ip -n "$ns" rule del pref 0
+		ip -n "$ns" -6 rule add pref 32765 table local
+		ip -n "$ns" -6 rule del pref 0
+	done
+
+	ip -n "$y1" link set eth0 up
+	ip -n "$y1" addr add $CROSS_A4/30 dev eth0
+	ip -n "$y1" addr add $CROSS_A6/64 dev eth0 nodad
+	ip -n "$y1" link add eid type vrf table 10
+	ip -n "$y1" link set eid up
+	ip -n "$y1" link add lisp0 type lisp id 7
+	ip -n "$y1" link set lisp0 master eid up
+	ip -n "$y1" addr add $CROSS_B4/32 dev lisp0
+	ip -n "$y1" addr add $CROSS_B6/128 dev lisp0 nodad
+	cross_nexthops "$y1" $CROSS_B4 $CROSS_B6
+
+	ip -n "$y2" link add rloc type vrf table 10
+	ip -n "$y2" link set rloc up
+	ip -n "$y2" link set eth0 master rloc up
+	ip -n "$y2" addr add $CROSS_B4/30 dev eth0
+	ip -n "$y2" addr add $CROSS_B6/64 dev eth0 nodad
+	ip -n "$y2" link add link rloc name lisp0 type lisp id 7
+	ip -n "$y2" link set lisp0 up
+	ip -n "$y2" addr add $CROSS_A4/32 dev lisp0
+	ip -n "$y2" addr add $CROSS_A6/128 dev lisp0 nodad
+	cross_nexthops "$y2" $CROSS_A4 $CROSS_A6
+
+	for family in 4 6; do
+		RET=0
+		nh=NH$family
+		cross_routes "$y1" "${!nh}" $CROSS_A4 $CROSS_A6 vrf eid
+		cross_routes "$y2" "${!nh}" $CROSS_B4 $CROSS_B6
+
+		cross_ping "$y1" $CROSS_A4 $CROSS_A6 -I eid
+		cross_ping "$y2" $CROSS_B4 $CROSS_B6
+
+		# In the main table of y1, the same addresses are the RLOCs
+		# of y2, which answer without LISP.
+		before=$(link_stat "$y1" lisp0 .tx.packets)
+		ip netns exec "$y1" ping -q -c 1 -W 2 $CROSS_B4 > /dev/null 2>&1
+		check_err $? "no answer from the RLOC $CROSS_B4"
+		ip netns exec "$y1" ping -q -c 1 -W 2 $CROSS_B6 > /dev/null 2>&1
+		check_err $? "no answer from the RLOC $CROSS_B6"
+		(( $(link_stat "$y1" lisp0 .tx.packets) == before ))
+		check_err $? "packets for an RLOC were sent to the LISP device"
+
+		log_test "EIDs and RLOCs in a VRF and the main table, IPv$family RLOCs"
+	done
+
+	cleanup_ns "$y1" "$y2"
+}
+
+# Both xTRs have their EIDs in a netns and their RLOCs in another one. The
+# netns of the EIDs has no other device than the LISP one.
+#
+#   ain                                          bin
+#   lisp0: B4, B6 .............................. lisp0: A4, A6
+#   aout                                         bout
+#   eth0: A4, A6 ------------------------------- eth0: B4, B6
+cross_netns_test()
+{
+	local family
+	local nh
+
+	setup_ns ain aout bin bout
+	ip link add eth0 netns "$aout" type veth peer name eth0 netns "$bout"
+
+	ip -n "$aout" link set eth0 up
+	ip -n "$aout" addr add $CROSS_A4/30 dev eth0
+	ip -n "$aout" addr add $CROSS_A6/64 dev eth0 nodad
+	ip -n "$ain" link add lisp0 link-netns "$aout" type lisp id 8
+	ip -n "$ain" link set lisp0 up
+	ip -n "$ain" addr add $CROSS_B4/32 dev lisp0
+	ip -n "$ain" addr add $CROSS_B6/128 dev lisp0 nodad
+	cross_nexthops "$ain" $CROSS_B4 $CROSS_B6
+
+	ip -n "$bout" link set eth0 up
+	ip -n "$bout" addr add $CROSS_B4/30 dev eth0
+	ip -n "$bout" addr add $CROSS_B6/64 dev eth0 nodad
+	ip -n "$bin" link add lisp0 link-netns "$bout" type lisp id 8
+	ip -n "$bin" link set lisp0 up
+	ip -n "$bin" addr add $CROSS_A4/32 dev lisp0
+	ip -n "$bin" addr add $CROSS_A6/128 dev lisp0 nodad
+	cross_nexthops "$bin" $CROSS_A4 $CROSS_A6
+
+	for family in 4 6; do
+		RET=0
+		nh=NH$family
+		cross_routes "$ain" "${!nh}" $CROSS_A4 $CROSS_A6
+		cross_routes "$bin" "${!nh}" $CROSS_B4 $CROSS_B6
+
+		cross_ping "$ain" $CROSS_A4 $CROSS_A6
+		cross_ping "$bin" $CROSS_B4 $CROSS_B6
+
+		log_test "EIDs and RLOCs in two netns, IPv$family RLOCs"
+	done
+
+	cleanup_ns "$ain" "$aout" "$bin" "$bout"
+}
+
+netns_test()
+{
+	local port
+
+	RET=0
+	port=$(printf ':%04X' $LISP_PORT)
+
+	setup_ns eid rloc
+	ip -n "$eid" link add lisp0 link-netns "$rloc" type lisp id 5
+	check_err $? "no device with a link netns"
+	ip -n "$eid" link set lisp0 up
+	ip -n "$eid" -d link show dev lisp0 | grep -q link-netns
+	check_err $? "the link netns is not reported"
+	ip netns exec "$rloc" grep -q "$port " /proc/net/udp /proc/net/udp6
+	check_err $? "no socket in the link netns"
+	ip netns exec "$eid" grep -q "$port " /proc/net/udp /proc/net/udp6
+	check_fail $? "a socket in the netns of the device"
+
+	cleanup_ns "$rloc"
+	busywait "$BUSYWAIT_TIMEOUT" bash -c \
+		"! ip -n $eid link show dev lisp0 > /dev/null 2>&1"
+	check_err $? "the device outlives the netns of its RLOCs"
+	cleanup_ns "$eid"
+
+	log_test "RLOCs in another netns"
+}
+
+################################################################################
+# Main
+
+require_command jq
+
+if ! ip link help lisp 2>&1 | grep -q "^Usage: ... lisp"; then
+	echo "SKIP: iproute2 does not know the lisp devices"
+	exit "$ksft_skip"
+fi
+
+trap cleanup EXIT
+
+setup_ns probe
+out=$(ip -n "$probe" link add lisp0 type lisp id 1 2>&1)
+if [[ $out == *"Unknown device type"* ]]; then
+	echo "SKIP: the kernel does not have the lisp devices (CONFIG_LISP)"
+	exit "$ksft_skip"
+fi
+cleanup_ns "$probe"
+
+if ! setup; then
+	echo "FAIL: the setup of the test failed"
+	exit "$ksft_fail"
+fi
+
+tests_run
+
+exit "$EXIT_STATUS"

-- 
2.43.0
[PATCH net-next 5/5] selftests: net: add a scale test for LISP
#23251
Author: Vincent Jardin via B4 Relay
Date: Thu, 26 Nov 2026 21:37
569 lines
26372 bytes
From: Vincent Jardin <vjardin@free.fr>

Scenario: an xTR with the mappings of many remote sites on one LISP
device.
1 nexthop per site, half of them with an IPv4 RLOC and half with an
IPv6 one, and 4 routes per site, 2 IPv4 and 2 IPv6 EID prefixes.

Another xTR stands for all the sites.

Signed-off-by: Vincent Jardin <vjardin@free.fr>
---
 tools/testing/selftests/net/Makefile      |   1 +
 tools/testing/selftests/net/lisp_scale.sh | 532 ++++++++++++++++++++++++++++++
 2 files changed, 533 insertions(+)

diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 7263049ab7c44..27a1e9e6b4ed3 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -64,6 +64,7 @@ TEST_PROGS := \
 	l2tp.sh \
 	link_netns.py \
 	lisp.sh \
+	lisp_scale.sh \
 	lwt_dst_cache_ref_loop.sh \
 	macvlan_mcast_shared_mac.sh \
 	msg_zerocopy.sh \
diff --git a/tools/testing/selftests/net/lisp_scale.sh b/tools/testing/selftests/net/lisp_scale.sh
new file mode 100755
index 0000000000000..badba6491a42c
--- /dev/null
+++ b/tools/testing/selftests/net/lisp_scale.sh
@@ -0,0 +1,532 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Vincent Jardin <vjardin@free.fr>, Free Mobile
+#
+# Scale of the LISP data plane of drivers/net/lisp.c: the mappings of many
+# remote sites on one device of an xTR. A site is an RLOC, which is a nexthop,
+# and EID prefixes, which are routes to it. The sites with an even number have
+# an IPv4 RLOC, the others an IPv6 one. Each site has two IPv4 and two IPv6 EID
+# prefixes.
+#
+# x2 stands for all the remote sites: their RLOCs and their EIDs are local to
+# it, and it answers to the EIDs of x1.
+#
+#   x1 (VRF "site")                                    x2
+#   172.16.0.1, fd01::1    lisp101 ...... lisp101      10.0.0.0/8, fd00::/16
+#   192.0.2.1, 2001:db8:1::1  veth        veth         198.18.0.0/15,
+#                                                      2001:db8:ffff::/48
+#
+# LISP_SITES is the number of sites: 40000 by default, 8000 on a slow machine,
+# which is also the least: the tests change sites of their own, below 8000.
+
+source lib.sh
+
+if [[ $KSFT_MACHINE_SLOW == yes ]]; then
+	: "${LISP_SITES:=8000}"
+else
+	: "${LISP_SITES:=40000}"
+fi
+
+ALL_TESTS="
+	install_test
+	stats_test
+	move_test
+	replace_test
+	withdraw_test
+	churn_test
+	down_test
+"
+
+X1_RLOC4=192.0.2.1
+X1_RLOC6=2001:db8:1::1
+
+# The nexthop of a site has its number plus 1 as ID. Those of the sites that
+# move are above the others, and the groups above them.
+NH_MOVED=1000000
+NH_GROUP=2000000
+
+################################################################################
+# Helpers
+
+site_addr()
+{
+	local site=$1; shift
+	local format=$1; shift
+
+	awk -v i="$site" "BEGIN { printf \"$format\", $* }"
+}
+
+site_rloc()
+{
+	local site=$1; shift
+
+	if (( site % 2 )); then
+		site_addr "$site" "2001:db8:ffff:%x::1" i
+	else
+		site_addr "$site" "198.18.%d.%d" "int(i / 256), i % 256"
+	fi
+}
+
+# The IPv4 RLOC that a site gets when a test moves it.
+site_moved_rloc()
+{
+	site_addr "$1" "198.19.%d.%d" "int(i / 256), i % 256"
+}
+
+site_eid4()
+{
+	site_addr "$1" "10.%d.%d.129" "int(i / 256), i % 256"
+}
+
+site_eid6()
+{
+	site_addr "$1" "fd00:%x:1::1" i
+}
+
+sites_batch()
+{
+	local family=$1; shift
+	local first=$1; shift
+	local last=$1; shift
+	local program=$1; shift
+
+	awk -v first="$first" -v last="$last" -v moved="$NH_MOVED" \
+	    -v group="$NH_GROUP" "
+	BEGIN {
+		for (i = first; i < last; i++) {
+			nh = i + 1
+			hi = int(i / 256)
+			lo = i % 256
+			if (i % 2) {
+				encap = \"ip6\"
+				rloc = sprintf(\"2001:db8:ffff:%x::1\", i)
+			} else {
+				encap = \"ip\"
+				rloc = sprintf(\"198.18.%d.%d\", hi, lo)
+			}
+			$program
+		}
+	}" | ip -n "$x1" ${family:+-$family} -batch -
+}
+
+SITE_ROUTES='
+	printf "route %s 10.%d.%d.0/25 vrf site nhid %d\n", cmd, hi, lo, to
+	printf "route %s 10.%d.%d.128/25 vrf site nhid %d\n", cmd, hi, lo, to
+	printf "route %s fd00:%x:0::/64 vrf site nhid %d\n", cmd, i, to
+	printf "route %s fd00:%x:1::/64 vrf site nhid %d\n", cmd, i, to
+'
+
+sites_add()
+{
+	local first=$1; shift
+	local last=$1; shift
+
+	sites_batch 6 "$first" "$last" '
+		printf "nexthop add id %d encap %s dst %s dev lisp101\n", \
+			nh, encap, rloc
+	' && sites_batch "" "$first" "$last" \
+		"cmd = \"add\"; to = nh; $SITE_ROUTES"
+}
+
+count_nexthops()
+{
+	ip -n "$x1" nexthop show dev lisp101 | wc -l
+}
+
+count_routes()
+{
+	local family=$1; shift
+
+	ip -n "$x1" "-$family" route show vrf site | grep -c " nhid "
+}
+
+site_ping()
+{
+	local site=$1; shift
+
+	ip netns exec "$x1" ping -q -c 1 -W 2 -I site "$(site_eid4 "$site")" \
+		> /dev/null 2>&1 &&
+	ip netns exec "$x1" ping -q -c 1 -W 2 -I site "$(site_eid6 "$site")" \
+		> /dev/null 2>&1
+}
+
+rloc_filter()
+{
+	local rloc=$1; shift
+	local protocol=ip
+
+	[[ $rloc == *:* ]] && protocol=ipv6
+	tc -n "$x2" filter add dev eth0 ingress protocol $protocol pref 1 \
+		flower dst_ip "$rloc" action pass
+}
+
+rloc_packets()
+{
+	tc -n "$x2" -j -s filter show dev eth0 ingress pref 1 |
+		jq '[.[] | select(.options.actions) |
+		     .options.actions[0].stats.packets] | add'
+	tc -n "$x2" filter del dev eth0 ingress pref 1
+}
+
+site_check()
+{
+	local site=$1; shift
+	local rloc=$1; shift
+
+	rloc_filter "$rloc"
+	site_ping "$site"
+	check_err $? "no answer from the site $site"
+	(( $(rloc_packets) == 2 ))
+	check_err $? "the site $site is not reached through $rloc"
+}
+
+elapsed()
+{
+	local start=$1; shift
+
+	echo "$(( $(timestamp_ms) - start )) ms"
+}
+
+################################################################################
+# Setup
+
+setup()
+{
+	local ns
+
+	setup_ns x1 x2 || return
+
+	ip link add eth0 netns "$x1" type veth peer name eth0 netns "$x2"
+	for ns in "$x1" "$x2"; do
+		ip netns exec "$ns" sysctl -wq net.ipv4.ip_forward=1
+		ip netns exec "$ns" sysctl -wq net.ipv6.conf.all.forwarding=1
+		ip -n "$ns" link set eth0 up
+	done
+
+	ip -n "$x1" addr add $X1_RLOC4/30 dev eth0
+	ip -n "$x1" addr add $X1_RLOC6/64 dev eth0 nodad
+	ip -n "$x1" route add 198.18.0.0/15 via 192.0.2.2
+	ip -n "$x1" -6 route add 2001:db8:ffff::/48 via 2001:db8:1::2
+	ip -n "$x1" link add site type vrf table 10
+	ip -n "$x1" link set site up
+	ip -n "$x1" link add lisp101 type lisp id 101 \
+		local $X1_RLOC4 local $X1_RLOC6 || return
+	ip -n "$x1" link set lisp101 master site up
+	ip -n "$x1" addr add 172.16.0.1/32 dev lisp101
+	ip -n "$x1" addr add fd01::1/128 dev lisp101 nodad
+
+	ip -n "$x2" addr add 192.0.2.2/30 dev eth0
+	ip -n "$x2" addr add 2001:db8:1::2/64 dev eth0 nodad
+	ip -n "$x2" route add local 198.18.0.0/15 dev lo
+	ip -n "$x2" -6 route add local 2001:db8:ffff::/48 dev lo
+	ip -n "$x2" route add local 10.0.0.0/8 dev lo
+	ip -n "$x2" -6 route add local fd00::/16 dev lo
+	ip -n "$x2" link add lisp101 type lisp id 101
+	ip -n "$x2" link set lisp101 up
+	ip -n "$x2" route add 172.16.0.1/32 encap ip dst $X1_RLOC4 dev lisp101
+	ip -n "$x2" -6 route add fd01::1/128 encap ip6 dst $X1_RLOC6 \
+		dev lisp101
+	tc -n "$x2" qdisc add dev eth0 clsact
+}
+
+cleanup()
+{
+	cleanup_all_ns
+}
+
+################################################################################
+# Tests
+
+install_test()
+{
+	local start
+	local site
+
+	RET=0
+
+	start=$(timestamp_ms)
+	sites_add 0 "$LISP_SITES"
+	check_err $? "the sites are not installed"
+	log_info "$LISP_SITES sites installed in $(elapsed "$start")"
+
+	(( $(count_nexthops) == LISP_SITES ))
+	check_err $? "unexpected count of nexthops"
+	(( $(count_routes 4) == 2 * LISP_SITES ))
+	check_err $? "unexpected count of IPv4 routes"
+	(( $(count_routes 6) == 2 * LISP_SITES ))
+	check_err $? "unexpected count of IPv6 routes"
+
+	for site in 0 1 $((LISP_SITES / 2)) $((LISP_SITES / 2 + 1)) \
+		    $((LISP_SITES - 2)) $((LISP_SITES - 1)); do
+		site_check "$site" "$(site_rloc "$site")"
+	done
+
+	log_test "$LISP_SITES sites: $LISP_SITES nexthops, $((4 * LISP_SITES)) routes"
+}
+
+stats_test()
+{
+	local rx_before
+	local tx_before
+	local packets
+	local i
+
+	RET=0
+
+	ip -n "$x1" nexthop add id $NH_GROUP group 6001/6002
+	sites_batch "" 6000 6064 "cmd = \"replace\"; to = group; $SITE_ROUTES"
+
+	tx_before=$(ip -n "$x1" -j -s link show dev lisp101 |
+		    jq '.[0].stats64.tx.packets')
+	rx_before=$(ip -n "$x1" -j -s link show dev lisp101 |
+		    jq '.[0].stats64.rx.packets')
+	for i in $(seq 6000 6063); do
+		site_ping "$i"
+		check_err $? "no answer from the site $i"
+	done
+
+	(( $(ip -n "$x1" -j -s link show dev lisp101 |
+	     jq '.[0].stats64.tx.packets') == tx_before + 128 ))
+	check_err $? "unexpected count of sent packets"
+	(( $(ip -n "$x1" -j -s link show dev lisp101 |
+	     jq '.[0].stats64.rx.packets') == rx_before + 128 ))
+	check_err $? "unexpected count of received packets"
+
+	packets=$(ip -n "$x1" -j -s nexthop show id $NH_GROUP |
+		  jq -c '[.[0].group_stats[].packets]')
+	(( $(jq 'add' <<< "$packets") >= 128 ))
+	check_err $? "unexpected count of the packets of the group: $packets"
+	[[ $(jq 'min' <<< "$packets") != 0 ]]
+	check_err $? "an RLOC of the group is not used: $packets"
+
+	sites_batch "" 6000 6064 "cmd = \"replace\"; to = nh; $SITE_ROUTES"
+	ip -n "$x1" nexthop del id $NH_GROUP
+	log_test "Counters of the device and of a group"
+}
+
+move_test()
+{
+	local start
+
+	RET=0
+
+	start=$(timestamp_ms)
+	sites_batch 6 1000 2000 '
+		printf "nexthop add id %d encap ip dst 198.19.%d.%d dev lisp101\n", \
+			moved + i, hi, lo
+	' && sites_batch "" 1000 2000 \
+		"cmd = \"replace\"; to = moved + i; $SITE_ROUTES" &&
+	sites_batch "" 1000 2000 'printf "nexthop del id %d\n", nh'
+	check_err $? "the sites are not moved"
+	log_info "1000 sites moved to new nexthops in $(elapsed "$start")"
+
+	(( $(count_nexthops) == LISP_SITES ))
+	check_err $? "unexpected count of nexthops"
+	site_check 1000 "$(site_moved_rloc 1000)"
+	site_check 1999 "$(site_moved_rloc 1999)"
+	site_check 2000 "$(site_rloc 2000)"
+
+	log_test "RLOC changed with new nexthops"
+}
+
+replace_test()
+{
+	local start
+
+	RET=0
+
+	start=$(timestamp_ms)
+	sites_batch 6 2000 2100 '
+		printf "nexthop replace id %d encap ip dst 198.19.%d.%d dev lisp101\n", \
+			nh, hi, lo
+	'
+	check_err $? "the nexthops are not replaced"
+	log_info "100 nexthops replaced in $(elapsed "$start")"
+
+	site_check 2000 "$(site_moved_rloc 2000)"
+	site_check 2099 "$(site_moved_rloc 2099)"
+	site_check 2100 "$(site_rloc 2100)"
+
+	log_test "RLOC changed in place"
+}
+
+withdraw_test()
+{
+	local start
+
+	RET=0
+
+	start=$(timestamp_ms)
+	sites_batch "" 3000 4000 '
+		printf "route del 10.%d.%d.0/25 vrf site\n", hi, lo
+		printf "route del 10.%d.%d.128/25 vrf site\n", hi, lo
+		printf "route del fd00:%x:0::/64 vrf site\n", i
+		printf "route del fd00:%x:1::/64 vrf site\n", i
+	' && sites_batch "" 3000 4000 'printf "nexthop del id %d\n", nh'
+	check_err $? "the sites are not withdrawn"
+	log_info "1000 sites withdrawn in $(elapsed "$start")"
+
+	start=$(timestamp_ms)
+	sites_batch "" 4000 4100 'printf "nexthop del id %d\n", nh'
+	check_err $? "the nexthops are not removed"
+	log_info "100 nexthops removed with their routes in $(elapsed "$start")"
+
+	(( $(count_nexthops) == LISP_SITES - 1100 ))
+	check_err $? "unexpected count of nexthops"
+	(( $(count_routes 4) == 2 * (LISP_SITES - 1100) ))
+	check_err $? "unexpected count of IPv4 routes"
+	(( $(count_routes 6) == 2 * (LISP_SITES - 1100) ))
+	check_err $? "unexpected count of IPv6 routes"
+
+	site_ping 3500
+	check_fail $? "an answer from a site that left"
+	site_ping 4050
+	check_fail $? "an answer from a site whose nexthop was removed"
+	site_check 4100 "$(site_rloc 4100)"
+
+	log_test "Sites withdrawn"
+}
+
+churn_test()
+{
+	local loops=()
+	local pids=()
+	local rounds=0
+	local site
+	local out
+	local pid
+
+	RET=0
+
+	out=$(mktemp -d)
+	for site in 5500 5501; do
+		ip netns exec "$x1" ping -q -f -w 10 -I site \
+			"$(site_eid4 "$site")" > "$out/$site.4" 2>&1 &
+		pids+=($!)
+		ip netns exec "$x1" ping -q -f -w 10 -I site \
+			"$(site_eid6 "$site")" > "$out/$site.6" 2>&1 &
+		pids+=($!)
+	done
+
+	for site in 5000 5001; do
+		while :; do
+			ip netns exec "$x1" ping -q -f -w 1 -I site \
+				"$(site_eid4 "$site")"
+			ip netns exec "$x1" ping -q -f -w 1 -I site \
+				"$(site_eid6 "$site")"
+		done > /dev/null 2>&1 &
+		loops+=($!)
+	done
+
+	while kill -0 "${pids[0]}" 2> /dev/null; do
+		sites_batch "" 5000 5200 'printf "nexthop del id %d\n", nh'
+		sites_add 5000 5200
+		check_err $? "the sites are not installed again"
+		sites_batch 6 5000 5016 '
+			printf "nexthop replace id %d encap ip dst 198.19.%d.%d dev lisp101\n", \
+				nh, hi, lo
+		'
+		sites_batch 6 5000 5016 '
+			printf "nexthop replace id %d encap %s dst %s dev lisp101\n", \
+				nh, encap, rloc
+		'
+		rounds=$((rounds + 1))
+	done
+	log_info "$rounds rounds of changes under traffic"
+
+	for pid in "${loops[@]}"; do
+		kill_process "$pid"
+	done
+	for pid in "${pids[@]}"; do
+		wait "$pid"
+		check_err $? "no answer from a site that did not change"
+	done
+	# The ping that a loop was running goes on for a second without it.
+	ip netns pids "$x1" | xargs -r kill 2> /dev/null
+
+	# The changes of the other sites cost them less than half their packets.
+	for site in 5500 5501; do
+		awk '/packets transmitted/ { n++; if ($4 * 2 < $1) lost = 1 }
+		     END { exit lost || n != 2 }' "$out/$site.4" "$out/$site.6"
+		check_err $? "most packets of a site that did not change are lost"
+	done
+	rm -rf "$out"
+
+	(( $(count_nexthops) == LISP_SITES - 1100 ))
+	check_err $? "unexpected count of nexthops"
+	site_check 5002 "$(site_rloc 5002)"
+	site_check 5199 "$(site_rloc 5199)"
+	site_check 5500 "$(site_rloc 5500)"
+
+	log_test "Mappings changed under traffic"
+}
+
+down_test()
+{
+	local start
+	local pid
+
+	RET=0
+
+	ip netns exec "$x1" ping -q -f -w 4 -I site "$(site_eid4 7500)" \
+		> /dev/null 2>&1 &
+	pid=$!
+
+	start=$(timestamp_ms)
+	ip -n "$x1" link set lisp101 down
+	log_info "device down with its nexthops and routes in $(elapsed "$start")"
+	(( $(count_nexthops) == 0 ))
+	check_err $? "nexthops outlive the device"
+	(( $(count_routes 4) == 0 && $(count_routes 6) == 0 ))
+	check_err $? "routes outlive the device"
+
+	ip -n "$x1" link set lisp101 up
+	ip -n "$x1" addr add fd01::1/128 dev lisp101 nodad
+	sites_add 7000 7100
+	check_err $? "no site can be installed again"
+	site_check 7000 "$(site_rloc 7000)"
+	site_check 7099 "$(site_rloc 7099)"
+
+	start=$(timestamp_ms)
+	ip -n "$x1" link del lisp101
+	log_info "device deleted in $(elapsed "$start")"
+	(( $(ip -n "$x1" nexthop | wc -l) == 0 ))
+	check_err $? "nexthops outlive the device"
+	wait $pid
+
+	log_test "Device down and deleted"
+}
+
+################################################################################
+# Main
+
+require_command jq
+
+if ! ip link help lisp 2>&1 | grep -q "^Usage: ... lisp"; then
+	echo "SKIP: iproute2 does not know the lisp devices"
+	exit "$ksft_skip"
+fi
+
+if (( LISP_SITES < 8000 || LISP_SITES > 65536 )); then
+	echo "SKIP: LISP_SITES must be between 8000 and 65536"
+	exit "$ksft_skip"
+fi
+
+trap cleanup EXIT
+
+setup_ns probe
+out=$(ip -n "$probe" link add lisp0 type lisp id 1 2>&1)
+if [[ $out == *"Unknown device type"* ]]; then
+	echo "SKIP: the kernel does not have the lisp devices (CONFIG_LISP)"
+	exit "$ksft_skip"
+fi
+cleanup_ns "$probe"
+
+if ! setup; then
+	echo "FAIL: the setup of the test failed"
+	exit "$ksft_fail"
+fi
+
+tests_run
+
+exit "$EXIT_STATUS"

-- 
2.43.0
Re: [PATCH net-next 0/5] lisp: add a LISP (RFC 9300) tunnel device
#23482
Author: Matthieu Baerts
Date: Fri, 27 Nov 2026 10:24
22 lines
11959 bytes
Hi Vincent,

Thank you for working on that.

On 26/11/2026 22:37, Vincent Jardin wrote:

(...)

> The lisp link type of iproute2 comes as a separate series, for
> iproute2-next. Tests are skipped without it. Tell me if you want
> iproute2 series too for a simultaneous review.

Do you mind sharing a branch on top of iproute2-next with these patches,
please? (or the patches)

With that, we can build an iproute2 version supporting lisp, and the CI
can validate this series next time, instead of always marking this
series as "Changes Requested" because some tests are marked as 'skip'.

Cheers,
Matt
Re: [PATCH net-next 4/5] selftests: net: add a test of the LISP devices
#23749
Author: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 22:25
104 lines
11515 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The whole selftest needs an iproute2 that supports the new 'lisp'
  link type, and nothing in the series says so.
- [Low] In mtu_test() (tools/testing/selftests/net/lisp.sh:468-492), the
  `for family in 4 6` loop flushes h1's route caches only after both…

--

selftests: net: add a test of the LISP devices

This adds tools/testing/selftests/net/lisp.sh. In the test, two xTRs carry
the traffic of two hosts through a core router. x1 keeps its EIDs and its
RLOCs in separate VRFs, and x2 uses its main table. The net selftest
config, the Makefile and MAINTAINERS are updated to match.

> diff --git a/tools/testing/selftests/net/lisp.sh b/tools/testing/selftests/net/lisp.sh
> new file mode 100755
> index 0000000000000..780053db366bc
> --- /dev/null
> +++ b/tools/testing/selftests/net/lisp.sh
> @@ -0,0 +1,1120 @@

[ ... ]

> +mtu_test()
> +{
> +	local family
> +
> +	for family in 4 6; do
> +		RET=0
> +		use_rlocs "$family"
> +
> +		h1_ping -M do -s 1416 10.2.0.2
> +		check_err $? "an IPv4 packet of 1444 bytes is lost"
> +		h1_ping -M do -s 1417 10.2.0.2
> +		check_fail $? "an IPv4 packet of 1445 bytes goes through"
> +		h1_ping -s 1396 fd00:2::2
> +		check_err $? "an IPv6 packet of 1444 bytes is lost"
> +		h1_ping -s 1397 fd00:2::2
> +		check_fail $? "an IPv6 packet of 1445 bytes goes through"
> +		h1_ping -s 3000 10.2.0.2
> +		check_err $? "IPv4 fragments are lost"
> +
> +		log_test "Device MTU with IPv$family RLOCs"
> +	done
> +
> +	ip -n "$h1" route flush cache
> +	ip -n "$h1" -6 route flush cache

[Severity: Low]
Does the IPv6 RLOC pass of this loop still exercise x1's lisp101?

In the first pass, x1 refuses the 1445 byte pings because lisp101 has an
MTU of 1444, which lisp_setup() sets:

    dev->mtu = ETH_DATA_LEN - LISP_IPV6_HLEN;

h1 then caches a PMTU of 1444 for 10.2.0.2 and for fd00:2::2. Those caches
are flushed only after the loop ends. pmtu_family_test() and
frag_family_test() flush on every pass.

In the second pass:

- h1_ping -M do -s 1417 10.2.0.2 fails on h1 itself with EMSGSIZE and
  never reaches x1. The check_fail passes no matter what lisp101 does.

- h1_ping -s 1397 fd00:2::2 is fragmented on h1 to the cached 1444, so x1
  forwards it. The check_fail passes only because x2's lisp101 refuses the
  1445 byte reply from h2.

- h1_ping -s 3000 10.2.0.2 is fragmented on h1 to 1444 in both passes, so
  x1 never handles an oversized packet in this test.

Would flushing h1's caches at the end of each pass keep the second pass
meaningful?

[ ... ]

> +require_command jq
> +
> +if ! ip link help lisp 2>&1 | grep -q "^Usage: ... lisp"; then
> +	echo "SKIP: iproute2 does not know the lisp devices"
> +	exit "$ksft_skip"
> +fi

[Severity: Low]
This isn't a bug, but the whole test needs an iproute2 that supports the
lisp link type. That covers "type lisp id N local A local A6", "external",
"link-netns", and the info_data JSON keys id, local, local6 and external.

Neither the commit message nor Documentation/networking/lisp.rst mentions
this dependency or points to the iproute2 change. With a stock iproute2,
the test always stops here with SKIP.

Could the commit message say which iproute2 version or patch is needed?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-for-upstream-lisp-v1-v1-0-7382a4bcfd9b%40free.fr
Re: [PATCH net-next 5/5] selftests: net: add a scale test for LISP
#23751
Author: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 22:25
129 lines
12394 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The background loops in churn_test()
  (tools/testing/selftests/net/lisp_scale.sh) can be left running when…
- [Low] The sub-tests in tools/testing/selftests/net/lisp_scale.sh depend
  on each other through hard-coded state.

--

selftests: net: add a scale test for LISP

This adds lisp_scale.sh, a selftest that installs the mappings of many
remote sites on one LISP device of an xTR. Each site gets one nexthop and
four EID routes, and a second namespace stands in for all the sites. The
sub-tests cover counters, RLOC moves and replacements, withdrawals, churn
under traffic, and taking the device down and deleting it.

> diff --git a/tools/testing/selftests/net/lisp_scale.sh b/tools/testing/selftests/net/lisp_scale.sh
> new file mode 100755
> index 0000000000000..badba6491a42c
> --- /dev/null
> +++ b/tools/testing/selftests/net/lisp_scale.sh
> @@ -0,0 +1,532 @@

[ ... ]

> +churn_test()
> +{
> +	local loops=()
> +	local pids=()
> +	local rounds=0
> +	local site
> +	local out
> +	local pid
> +
> +	RET=0
> +
> +	out=$(mktemp -d)

[ ... ]

> +	for site in 5000 5001; do
> +		while :; do
> +			ip netns exec "$x1" ping -q -f -w 1 -I site \
> +				"$(site_eid4 "$site")"
> +			ip netns exec "$x1" ping -q -f -w 1 -I site \
> +				"$(site_eid6 "$site")"
> +		done > /dev/null 2>&1 &
> +		loops+=($!)
> +	done

[Severity: Medium]
If the script exits before churn_test() reaches its kill_process loop,
what stops these while : loops?

The loop subshells run in the init netns, and their PIDs are kept only in
the local loops array. The EXIT trap only runs this:

cleanup()
{
	cleanup_all_ns
}

cleanup_ns() in lib.sh kills only the processes listed by "ip netns pids"
for the namespace and then deletes it, so it never touches these subshells.

Suppose the script gets Ctrl-C while the churn loop is running. In a
non-interactive shell, background commands ignore SIGINT. A SIGTERM sent
only to the script PID has the same effect. In both cases x1 is deleted
and every "ip netns exec $x1" then fails at once.

Would the two loops then keep forking failing ip processes until someone
kills them by hand?

The kselftest runner timeout signals the whole process group, so this
mostly affects manual interruption and harnesses that signal only the
script PID.

The mktemp -d directory in $out would also be left behind, because
rm -rf "$out" only runs on the normal path.

Could the loop kill and the rm -rf be registered with the lib.sh defer
helpers? tests_run() already wraps each test in in_defer_scope.
Alternatively, the PIDs and $out could live in globals that cleanup()
handles, or the loops could stop at a deadline instead of using while :.

[ ... ]

> +	rm -rf "$out"
> +
> +	(( $(count_nexthops) == LISP_SITES - 1100 ))
> +	check_err $? "unexpected count of nexthops"

[Severity: Low]
Does churn_test() need to depend on what withdraw_test() did here?

The 1100 comes from withdraw_test() deleting the nexthops of sites
3000..3999 and then 4000..4099:

	sites_batch "" 4000 4100 'printf "nexthop del id %d\n", nh'

churn_test() deletes and re-adds sites 5000..5199, so it does not change
the total. This check just repeats the one at the end of withdraw_test().
move_test() also asserts count_nexthops == LISP_SITES, and most sub-tests
rely on the sites created by install_test().

tests_run() in lib.sh iterates ${TESTS:-$ALL_TESTS}, so a subset can be
run. With TESTS=churn_test, this check would fail, and sites 5500/5501
would not exist, even if the churn handling itself works.

withdraw_test() sends its deletions through ip -batch without -force. If
it fails partway, the same problem would be reported again here as an
unexpected count of nexthops.

Could this cross-test count be dropped, or compared against a count taken
at the start of churn_test()?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-for-upstream-lisp-v1-v1-0-7382a4bcfd9b%40free.fr
Re: [PATCH net-next 0/5] lisp: add a LISP (RFC 9300) tunnel device
#24717
Author: Matthieu Baerts
Date: Mon, 30 Nov 2026 17:32
23 lines
12032 bytes
Hi Vincent,

On 27/11/2026 23:47, Vincent Jardin wrote:
> Hi Matt,
> 
> On Fri, Nov 27, 2026 at 11:24:55AM +0100, Matthieu Baerts wrote:
>> Do you mind sharing a branch on top of iproute2-next with these patches,
>> please? (or the patches)
> 
> Please see the patch series:
>   https://lore.kernel.org/all/20261127-iproute2-lisp-v1-0-df8ea175bc06@free.fr/

Thank you!

The CI should have it now.

(Next time in such situation where IPRoute2 needs to be patched, please
leave some time for someone to update the CI before sending a new
version ;) -> I don't know if I can reset the status of the v2 to "active".)

Cheers,
Matt
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads