Skip to contentSkip to conversation

net/ipv6: Change accept_unsolicited_na to accept_untracked_na

PATCH In review Arun Ajith S 2 participants 3 messages May 27, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ipv6: Change accept_unsolicited_na to accept_untracked_na

RFC 9131 changes default behavior of handling RX of NA messages when the corresponding entry is absent in the neighbour cache. The current implementation is limited to accept just unsolicited NAs. However, the RFC is more generic where it also accepts solicited NAs. Both types should result in adding a STALE entry for this case.

This change expands the current implementation to match the RFC. The sysctl knob is also renamed to accept_untracked_na to better reflect the implementation.

---
This change updates the accept_unsolicited_na feature that merged to net-next for v5.19 to be better compliant with the RFC. It also involves renaming the sysctl knob to accept_untracked_na before shipping in a release.

 Documentation/networking/ip-sysctl.rst        |  18 +---
 include/linux/ipv6.h                          |   2 +-
 include/uapi/linux/ipv6.h                     |   2 +-
 net/ipv6/addrconf.c                           |   6 +-
 net/ipv6/ndisc.c                              | 101 ++++++++++--------
 .../net/ndisc_unsolicited_na_test.sh          |  23 ++--
 6 files changed, 75 insertions(+), 77 deletions(-)
Documentation/networking/ip-sysctl.rst +5 -13
index b882d4238581..2f8a0d01a4bb 100644
@@ -2474,21 +2474,13 @@ drop_unsolicited_na - BOOLEAN
 
 	By default this is turned off.
 
-accept_unsolicited_na - BOOLEAN
+accept_untracked_na - BOOLEAN
 	Add a new neighbour cache entry in STALE state for routers on receiving an
-	unsolicited neighbour advertisement with target link-layer address option
-	specified. This is as per router-side behavior documented in RFC9131.
-	This has lower precedence than drop_unsolicited_na.
+	neighbour advertisement with target link-layer address option specified
+	if a corresponding entry is not already present.
+	This is as per router-side behavior documented in RFC9131.
 
-	 ====   ======  ======  ==============================================
-	 drop   accept  fwding                   behaviour
-	 ----   ------  ------  ----------------------------------------------
-	    1        X       X  Drop NA packet and don't pass up the stack
-	    0        0       X  Pass NA packet up the stack, don't update NC
-	    0        1       0  Pass NA packet up the stack, don't update NC
-	    0        1       1  Pass NA packet up the stack, and add a STALE
-	                        NC entry
-	 ====   ======  ======  ==============================================
+	This has lower precedence than drop_unsolicited_na.
 
 	This will optimize the return path for the initial off-link communication
 	that is initiated by a directly connected host, by ensuring that
include/linux/ipv6.h +1 -1
index 38c8203d52cb..37dfdcfcdd54 100644
@@ -61,7 +61,7 @@ struct ipv6_devconf {
 	__s32		suppress_frag_ndisc;
 	__s32		accept_ra_mtu;
 	__s32		drop_unsolicited_na;
-	__s32		accept_unsolicited_na;
+	__s32		accept_untracked_na;
 	struct ipv6_stable_secret {
 		bool initialized;
 		struct in6_addr secret;
include/uapi/linux/ipv6.h +1 -1
index 549ddeaf788b..03cdbe798fe3 100644
@@ -194,7 +194,7 @@ enum {
 	DEVCONF_IOAM6_ID,
 	DEVCONF_IOAM6_ID_WIDE,
 	DEVCONF_NDISC_EVICT_NOCARRIER,
-	DEVCONF_ACCEPT_UNSOLICITED_NA,
+	DEVCONF_ACCEPT_UNTRACKED_NA,
 	DEVCONF_MAX
 };
 
net/ipv6/addrconf.c +3 -3
index ca0aa744593e..1b1932502e9e 100644
@@ -5586,7 +5586,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,
 	array[DEVCONF_IOAM6_ID] = cnf->ioam6_id;
 	array[DEVCONF_IOAM6_ID_WIDE] = cnf->ioam6_id_wide;
 	array[DEVCONF_NDISC_EVICT_NOCARRIER] = cnf->ndisc_evict_nocarrier;
-	array[DEVCONF_ACCEPT_UNSOLICITED_NA] = cnf->accept_unsolicited_na;
+	array[DEVCONF_ACCEPT_UNTRACKED_NA] = cnf->accept_untracked_na;
 }
 
 static inline size_t inet6_ifla6_size(void)
@@ -7038,8 +7038,8 @@ static const struct ctl_table addrconf_sysctl[] = {
 		.extra2		= (void *)SYSCTL_ONE,
 	},
 	{
-		.procname	= "accept_unsolicited_na",
-		.data		= &ipv6_devconf.accept_unsolicited_na,
+		.procname	= "accept_untracked_na",
+		.data		= &ipv6_devconf.accept_untracked_na,
 		.maxlen		= sizeof(int),
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_minmax,
net/ipv6/ndisc.c +54 -47

129 lines not on this page · raw message

tools/testing/selftests/net/ndisc_unsolicited_na_test.sh +11 -12
index f508657ee126..86e621b7b9c7 100755
@@ -1,15 +1,14 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
-# This test is for the accept_unsolicited_na feature to
+# This test is for the accept_untracked_na feature to
 # enable RFC9131 behaviour. The following is the test-matrix.
 # drop   accept  fwding                   behaviour
 # ----   ------  ------  ----------------------------------------------
-#    1        X       X  Drop NA packet and don't pass up the stack
-#    0        0       X  Pass NA packet up the stack, don't update NC
-#    0        1       0  Pass NA packet up the stack, don't update NC
-#    0        1       1  Pass NA packet up the stack, and add a STALE
-#                           NC entry
+#    1        X       X  Don't update NC
+#    0        0       X  Don't update NC
+#    0        1       0  Don't update NC
+#    0        1       1  Add a STALE NC entry
 
 ret=0
 # Kselftest framework requirement - SKIP code is 4.
@@ -72,7 +71,7 @@ setup()
 	set -e
 
 	local drop_unsolicited_na=$1
-	local accept_unsolicited_na=$2
+	local accept_untracked_na=$2
 	local forwarding=$3
 
 	# Setup two namespaces and a veth tunnel across them.
@@ -93,7 +92,7 @@ setup()
 	${IP_ROUTER_EXEC} sysctl -qw \
                 ${ROUTER_CONF}.drop_unsolicited_na=${drop_unsolicited_na}
 	${IP_ROUTER_EXEC} sysctl -qw \
-                ${ROUTER_CONF}.accept_unsolicited_na=${accept_unsolicited_na}
+                ${ROUTER_CONF}.accept_untracked_na=${accept_untracked_na}
 	${IP_ROUTER_EXEC} sysctl -qw ${ROUTER_CONF}.disable_ipv6=0
 	${IP_ROUTER} addr add ${ROUTER_ADDR_WITH_MASK} dev ${ROUTER_INTF}
 
@@ -144,13 +143,13 @@ link_up() {
 
 verify_ndisc() {
 	local drop_unsolicited_na=$1
-	local accept_unsolicited_na=$2
+	local accept_untracked_na=$2
 	local forwarding=$3
 
 	neigh_show_output=$(${IP_ROUTER} neigh show \
                 to ${HOST_ADDR} dev ${ROUTER_INTF} nud stale)
 	if [ ${drop_unsolicited_na} -eq 0 ] && \
-			[ ${accept_unsolicited_na} -eq 1 ] && \
+			[ ${accept_untracked_na} -eq 1 ] && \
 			[ ${forwarding} -eq 1 ]; then
 		# Neighbour entry expected to be present for 011 case
 		[[ ${neigh_show_output} ]]
@@ -179,14 +178,14 @@ test_unsolicited_na_combination() {
 	test_unsolicited_na_common $1 $2 $3
 	test_msg=("test_unsolicited_na: "
 		"drop_unsolicited_na=$1 "
-		"accept_unsolicited_na=$2 "
+		"accept_untracked_na=$2 "
 		"forwarding=$3")
 	log_test $? 0 "${test_msg[*]}"
 	cleanup
 }
 
 test_unsolicited_na_combinations() {
-	# Args: drop_unsolicited_na accept_unsolicited_na forwarding
+	# Args: drop_unsolicited_na accept_untracked_na forwarding
 
 	# Expect entry
 	test_unsolicited_na_combination 0 1 1
Signature · 1 line
2.27.0
#1 lore raw
Quoted 4 lines · Arun Ajith S

This change expands the current implementation to match the RFC. The sysctl knob is also renamed to accept_untracked_na to better reflect the implementation.

Say in imperative, "Expand and rename accept_unsolicited na to accept_untracked_na" in both commit/patch subject and message.

Quoted 11 lines
Documentation/networking/ip-sysctl.rst +4 -4
-accept_unsolicited_na - BOOLEAN
+accept_untracked_na - BOOLEAN
 	Add a new neighbour cache entry in STALE state for routers on receiving an
-	unsolicited neighbour advertisement with target link-layer address option
-	specified. This is as per router-side behavior documented in RFC9131.
-	This has lower precedence than drop_unsolicited_na.
+	neighbour advertisement with target link-layer address option specified
+	if a corresponding entry is not already present.
+	This is as per router-side behavior documented in RFC9131.
 

Documentation/networking/ip-sysctl.rst drop_unsolicited_na - BOOLEAN · line 2483

Quoted 10 lines
Documentation/networking/ip-sysctl.rst +1 -9
-	 ====   ======  ======  ==============================================
-	 drop   accept  fwding                   behaviour
-	 ----   ------  ------  ----------------------------------------------
-	    1        X       X  Drop NA packet and don't pass up the stack
-	    0        0       X  Pass NA packet up the stack, don't update NC
-	    0        1       0  Pass NA packet up the stack, don't update NC
-	    0        1       1  Pass NA packet up the stack, and add a STALE
-	                        NC entry
-	 ====   ======  ======  ==============================================
+	This has lower precedence than drop_unsolicited_na.

I think you should have made similar logical expansion of drop_unsolicited_na to drop_untracked_na. Otherwise, ...

Quoted 13 lines
net/ipv6/ndisc.c +3 -8
 	/* RFC 9131 updates original Neighbour Discovery RFC 4861.
-	 * An unsolicited NA can now create a neighbour cache entry
-	 * on routers if it has Target LL Address option.
+	 * NAs with Target LL Address option without a corresponding
+	 * entry in the neighbour cache can now create a STALE neighbour
+	 * cache entry on routers.
 	 *
-	 * drop   accept  fwding                   behaviour
-	 * ----   ------  ------  ----------------------------------------------
-	 *    1        X       X  Drop NA packet and don't pass up the stack
-	 *    0        0       X  Pass NA packet up the stack, don't update NC
-	 *    0        1       0  Pass NA packet up the stack, don't update NC
-	 *    0        1       1  Pass NA packet up the stack, and add a STALE

net/ipv6/ndisc.c static void ndisc_recv_na(struct sk_buff *skb) · line 1060

Quoted 10 lines
net/ipv6/ndisc.c +7 -2
-	 *                          NC entry
-	 * Note that we don't do a (daddr == all-routers-mcast) check.
+	 *   entry accept  fwding  solicited        behaviour
+	 * ------- ------  ------  ---------    ----------------------
+	 * present      X       X         0     Set state to STALE
+	 * present      X       X         1     Set state to REACHABLE
+	 *  absent      0       X         X     Do nothing
+	 *  absent      1       0         X     Do nothing
+	 *  absent      1       1         X     Add a new STALE entry
 	 */

The Documentation/ diff above drops behavior table but in the code comment it is updated. Why didn't update in Documentation/ instead?

And my nitpick: for consistency, prefer en-US words over en-UK or mixed varieties when writing (s/behaviour/behavior/gc, s/neighbour/neighbor/gc).

Signature · 1 line
An old man doll... just what I always wanted! - Clara
#2 lore raw
Quoted 10 lines · Bagas Sanjaya
Quoted 4 lines · Arun Ajith S

This change expands the current implementation to match the RFC. The sysctl knob is also renamed to accept_untracked_na to better reflect the implementation.

Say in imperative, "Expand and rename accept_unsolicited na to accept_untracked_na" in both commit/patch subject and message.

Okay, I will fix this.

Quoted 10 lines
Quoted 10 lines
Documentation/networking/ip-sysctl.rst +4 -4
-accept_unsolicited_na - BOOLEAN
+accept_untracked_na - BOOLEAN
      Add a new neighbour cache entry in STALE state for routers on receiving an
-     unsolicited neighbour advertisement with target link-layer address option
-     specified. This is as per router-side behavior documented in RFC9131.
-     This has lower precedence than drop_unsolicited_na.
+     neighbour advertisement with target link-layer address option specified
+     if a corresponding entry is not already present.
+     This is as per router-side behavior documented in RFC9131.
Quoted 15 lines

Documentation/networking/ip-sysctl.rst drop_unsolicited_na - BOOLEAN · line 2483

Quoted 11 lines
Documentation/networking/ip-sysctl.rst +1 -9
-      ====   ======  ======  ==============================================
-      drop   accept  fwding                   behaviour
-      ----   ------  ------  ----------------------------------------------
-         1        X       X  Drop NA packet and don't pass up the stack
-         0        0       X  Pass NA packet up the stack, don't update NC
-         0        1       0  Pass NA packet up the stack, don't update NC
-         0        1       1  Pass NA packet up the stack, and add a STALE
-                             NC entry
-      ====   ======  ======  ==============================================
+     This has lower precedence than drop_unsolicited_na.

I think you should have made similar logical expansion of drop_unsolicited_na to drop_untracked_na. Otherwise, ...

drop_unsolicited_na is a separate feature which is pre-existing in linux-5.18.

Quoted 24 lines
Quoted 13 lines
      /* RFC 9131 updates original Neighbour Discovery RFC 4861.
net/ipv6/ndisc.c +3 -8
-      * An unsolicited NA can now create a neighbour cache entry
-      * on routers if it has Target LL Address option.
+      * NAs with Target LL Address option without a corresponding
+      * entry in the neighbour cache can now create a STALE neighbour
+      * cache entry on routers.
       *
-      * drop   accept  fwding                   behaviour
-      * ----   ------  ------  ----------------------------------------------
-      *    1        X       X  Drop NA packet and don't pass up the stack
-      *    0        0       X  Pass NA packet up the stack, don't update NC
-      *    0        1       0  Pass NA packet up the stack, don't update NC
-      *    0        1       1  Pass NA packet up the stack, and add a STALE

net/ipv6/ndisc.c static void ndisc_recv_na(struct sk_buff *skb) · line 1060

Quoted 10 lines
net/ipv6/ndisc.c +7 -2
-      *                          NC entry
-      * Note that we don't do a (daddr == all-routers-mcast) check.
+      *   entry accept  fwding  solicited        behaviour
+      * ------- ------  ------  ---------    ----------------------
+      * present      X       X         0     Set state to STALE
+      * present      X       X         1     Set state to REACHABLE
+      *  absent      0       X         X     Do nothing
+      *  absent      1       0         X     Do nothing
+      *  absent      1       1         X     Add a new STALE entry
       */
Quoted 3 lines

The Documentation/ diff above drops behavior table but in the code comment it is updated. Why didn't update in Documentation/ instead?

In the documentation, I skipped the table and mentioned the behavior in words.
1. drop_unsolicited_na takes precedence over accept_untracked_na.
2. The feature applies only for routers (fwding=1) and when target link-layer address
option is specified.

Some of the behavior mentioned in the table is existing behavior and didn't want to
document under this feature. I thought it best to skip the table in Documentation as
it is more for code-readability.

Quoted 3 lines

And my nitpick: for consistency, prefer en-US words over en-UK or mixed varieties when writing (s/behaviour/behavior/gc, s/neighbour/neighbor/gc).

Sure, I tried to use UK-en since the code uses that, but I might have mixed it up unintentionally. I'll make it uniform in the next version of the patch.

Quoted 2 lines

--
An old man doll... just what I always wanted! - Clara

I accidentally replied in HTML earlier. Fixing it to be plaintext.