Module Name:    src
Committed By:   yamaguchi
Date:           Thu Apr  4 09:19:43 UTC 2024

Modified Files:
        src/sys/net/lagg: if_lagg.c if_lagg_lacp.c

Log Message:
Added comments to lagg(4)


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/net/lagg/if_lagg.c
cvs rdiff -u -r1.36 -r1.37 src/sys/net/lagg/if_lagg_lacp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/lagg/if_lagg.c
diff -u src/sys/net/lagg/if_lagg.c:1.66 src/sys/net/lagg/if_lagg.c:1.67
--- src/sys/net/lagg/if_lagg.c:1.66	Thu Apr  4 08:50:58 2024
+++ src/sys/net/lagg/if_lagg.c	Thu Apr  4 09:19:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg.c,v 1.66 2024/04/04 08:50:58 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg.c,v 1.67 2024/04/04 09:19:42 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter <r...@openbsd.org>
@@ -20,7 +20,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.66 2024/04/04 08:50:58 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.67 2024/04/04 09:19:42 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2165,6 +2165,7 @@ lagg_port_setsadl(struct lagg_port *lp, 
 
 		if (ifp_port->if_init != NULL) {
 			error = 0;
+			/* Apply updated ifp_port->if_sadl to the device */
 			if (ISSET(ifp_port->if_flags, IFF_RUNNING))
 				error = if_init(ifp_port);
 
@@ -2929,7 +2930,9 @@ lagg_chg_sadl(struct ifnet *ifp, const u
 	error = 0;
 	ifa_lla = NULL;
 
+	/* Renew all AF_LINK address to update sdl_type */
 	while (1) {
+		/* find a Link-Level address that has the previous sdl_type */
 		s = pserialize_read_enter();
 		IFADDR_READER_FOREACH(ifa_cur, ifp) {
 			sdl = satocsdl(ifa_cur->ifa_addr);
@@ -2945,7 +2948,10 @@ lagg_chg_sadl(struct ifnet *ifp, const u
 
 		if (ifa_cur == NULL)
 			break;
-
+		/*
+		 * create a new address that has new sdl_type,
+		 * and copy address from the previous.
+		 */
 		ifa_next = if_dl_create(ifp, &nsdl);
 		if (ifa_next == NULL) {
 			error = ENOMEM;
@@ -2957,6 +2963,7 @@ lagg_chg_sadl(struct ifnet *ifp, const u
 		    CLLADDR(sdl), ifp->if_addrlen);
 		ifa_insert(ifp, ifa_next);
 
+		/* the next Link-Level address is already set */
 		if (ifa_lla == NULL &&
 		    memcmp(CLLADDR(sdl), lla, lla_len) == 0) {
 			ifa_lla = ifa_next;
@@ -2972,6 +2979,7 @@ lagg_chg_sadl(struct ifnet *ifp, const u
 			ifafree(ifa_cur);
 		}
 
+		/* remove the old address */
 		ifaref(ifa_cur);
 		ifa_release(ifa_cur, &psref_cur);
 		ifa_remove(ifp, ifa_cur);
@@ -2981,6 +2989,7 @@ lagg_chg_sadl(struct ifnet *ifp, const u
 		ifa_release(ifa_next, &psref_next);
 	}
 
+	/* acquire or create the next Link-Level address */
 	if (ifa_lla != NULL) {
 		ifa_next = ifa_lla;
 
@@ -3000,13 +3009,19 @@ lagg_chg_sadl(struct ifnet *ifp, const u
 		ifa_insert(ifp, ifa_next);
 	}
 
+	/* Activate the next Link-Level address */
 	if (ifa_next != ifp->if_dl) {
+		/* save the current address */
 		ifa_cur = ifp->if_dl;
 		if (ifa_cur != NULL)
 			ifa_acquire(ifa_cur, &psref_cur);
 
 		if_activate_sadl(ifp, ifa_next, nsdl);
 
+		/*
+		 * free the saved address after switching,
+		 * if the address is not if_hwdl.
+		 */
 		if (ifa_cur != NULL) {
 			if (ifa_cur != ifp->if_hwdl) {
 				ifaref(ifa_cur);

Index: src/sys/net/lagg/if_lagg_lacp.c
diff -u src/sys/net/lagg/if_lagg_lacp.c:1.36 src/sys/net/lagg/if_lagg_lacp.c:1.37
--- src/sys/net/lagg/if_lagg_lacp.c:1.36	Thu Apr  4 09:09:24 2024
+++ src/sys/net/lagg/if_lagg_lacp.c	Thu Apr  4 09:19:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_lagg_lacp.c,v 1.36 2024/04/04 09:09:24 yamaguchi Exp $	*/
+/*	$NetBSD: if_lagg_lacp.c,v 1.37 2024/04/04 09:19:42 yamaguchi Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.36 2024/04/04 09:09:24 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.37 2024/04/04 09:19:42 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"
@@ -2718,6 +2718,12 @@ lacp_dump_markertlv(const struct markerd
 	}
 }
 
+/*
+ * lacp_linkstate:
+ *   callback on link state changed.
+ *   enable, disable or reset LACP processing on the physical port.
+ */
+
 static void
 lacp_linkstate(struct lagg_proto_softc *xlsc, struct lagg_port *lp)
 {

Reply via email to