Module Name: src Committed By: martin Date: Thu Oct 19 07:23:51 UTC 2023
Modified Files: src/share/man/man4 [netbsd-10]: lagg.4 src/sys/net/lagg [netbsd-10]: if_lagg.c src/tests/net/if_lagg [netbsd-10]: t_lagg.sh Log Message: Pull up following revision(s) (requested by yamaguchi in ticket #429): sys/net/lagg/if_lagg.c: revision 1.50 sys/net/lagg/if_lagg.c: revision 1.51 tests/net/if_lagg/t_lagg.sh: revision 1.10 sys/net/lagg/if_lagg.c: revision 1.49 tests/net/if_lagg/t_lagg.sh: revision 1.9 share/man/man4/lagg.4: revision 1.5 lagg(4): release LAGG_LOCK before mtu changing PR kern/57650 Make the lagg interface up before change its MTU This change is related to PR kern/57650 Fix missing IFNET_LOCK holding while destroy the lagg interface copy MTU of lagg to a interface added to lagg even if the interface is the first member of the lagg This change breaks ATF test case for lagg MTU Update the test case for MTU of lag to adapt new behavior Update lagg(4) manual 1. corrected the wrong example - lagg(4) can not add multiple port and set its priority at once - This is the restriction of ifconfig(8) 2. adapted to changed behavior related to MTU - Changed not to copy MTU of the 1st physical interface to lagg(4) to prevent locking against myself To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.4.2.1 src/share/man/man4/lagg.4 cvs rdiff -u -r1.48 -r1.48.4.1 src/sys/net/lagg/if_lagg.c cvs rdiff -u -r1.8 -r1.8.2.1 src/tests/net/if_lagg/t_lagg.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/share/man/man4/lagg.4 diff -u src/share/man/man4/lagg.4:1.4 src/share/man/man4/lagg.4:1.4.2.1 --- src/share/man/man4/lagg.4:1.4 Tue May 24 20:50:18 2022 +++ src/share/man/man4/lagg.4 Thu Oct 19 07:23:51 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: lagg.4,v 1.4 2022/05/24 20:50:18 andvar Exp $ +.\" $NetBSD: lagg.4,v 1.4.2.1 2023/10/19 07:23:51 martin Exp $ .\" .\" Copyright (c) 2005, 2006 Reyk Floeter <r...@openbsd.org> .\" @@ -150,8 +150,10 @@ most easily done with the .Cm create command. .Pp -The MTU of the first interface to be added is used as the lagg MTU. -All additional interfaces are required to have exactly the same value. +The MTU of the +.Xr lagg 4 +is applied to each physical interfaces. +And the physical interfaces can not change its MTU directly. .Sh EXAMPLES Create a link aggregation using LACP with two .Xr wm 4 @@ -171,9 +173,10 @@ Gigabit Ethernet interfaces and set each # ifconfig wm0 up # ifconfig wm1 up # ifconfig lagg0 create -# ifconfig lagg0 laggproto failover \e - laggport wm0 pri 1000 laggport wm1 pri 2000 \e - 192.168.1.1 netmask 255.255.255.0 +# ifconfig lagg0 laggproto failover +# ifconfig lagg0 laggport wm0 pri 1000 +# ifconfig lagg0 laggport wm1 pri 2000 +# ifconfig lagg0 inet 192.168.1.1 netmask 255.255.255.0 .Ed .Sh SEE ALSO .Xr ifconfig 8 Index: src/sys/net/lagg/if_lagg.c diff -u src/sys/net/lagg/if_lagg.c:1.48 src/sys/net/lagg/if_lagg.c:1.48.4.1 --- src/sys/net/lagg/if_lagg.c:1.48 Sun Jun 26 17:55:24 2022 +++ src/sys/net/lagg/if_lagg.c Thu Oct 19 07:23:50 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg.c,v 1.48 2022/06/26 17:55:24 riastradh Exp $ */ +/* $NetBSD: if_lagg.c,v 1.48.4.1 2023/10/19 07:23:50 martin 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.48 2022/06/26 17:55:24 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.48.4.1 2023/10/19 07:23:50 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -444,11 +444,13 @@ lagg_clone_destroy(struct ifnet *ifp) lagg_stop(ifp, 1); + IFNET_LOCK(ifp); LAGG_LOCK(sc); while ((lp = LAGG_PORTS_FIRST(sc)) != NULL) { lagg_port_teardown(sc, lp, false); } LAGG_UNLOCK(sc); + IFNET_UNLOCK(ifp); switch (ifp->if_type) { case IFT_ETHER: @@ -727,8 +729,8 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd LAGG_UNLOCK(sc); break; case SIOCSIFMTU: - LAGG_LOCK(sc); /* set the MTU to each port */ + LAGG_LOCK(sc); LAGG_PORTS_FOREACH(sc, lp) { error = lagg_lp_ioctl(lp, cmd, (void *)ifr); @@ -742,6 +744,7 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd break; } } + LAGG_UNLOCK(sc); /* set the MTU to the lagg interface */ if (error == 0) @@ -750,12 +753,14 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd if (error != 0) { /* undo the changed MTU */ ifr->ifr_mtu = ifp->if_mtu; + + LAGG_LOCK(sc); LAGG_PORTS_FOREACH(sc, lp) { if (lp->lp_ioctl != NULL) lagg_lp_ioctl(lp, cmd, (void *)ifr); } + LAGG_UNLOCK(sc); } - LAGG_UNLOCK(sc); break; case SIOCADDMULTI: if (sc->sc_if.if_type == IFT_ETHER) { @@ -2238,11 +2243,12 @@ lagg_port_setup(struct lagg_softc *sc, lagg_port_setsadl(lp, NULL); } else { lagg_port_setsadl(lp, CLLADDR(ifp->if_sadl)); - error = lagg_setmtu(ifp_port, ifp->if_mtu); - if (error != 0) - goto restore_sadl; } + error = lagg_setmtu(ifp_port, ifp->if_mtu); + if (error != 0) + goto restore_sadl; + error = lagg_proto_allocport(sc, lp); if (error != 0) goto restore_mtu; @@ -2258,9 +2264,6 @@ lagg_port_setup(struct lagg_softc *sc, IFNET_UNLOCK(ifp_port); if (is_1st_port) { - error = lagg_setmtu(ifp, lp->lp_mtu); - if (error != 0) - goto restore_ifp_port; if (lp->lp_iftype == IFT_ETHER && lagg_lladdr_equal(sc->sc_lladdr_rand, CLLADDR(ifp->if_sadl))) { @@ -2280,11 +2283,6 @@ lagg_port_setup(struct lagg_softc *sc, return 0; -restore_ifp_port: - IFNET_LOCK(ifp_port); - if (stopped) { - if_stop(ifp_port, 0); - } free_port: KASSERT(IFNET_LOCKED(ifp_port)); lagg_proto_freeport(sc, lp); Index: src/tests/net/if_lagg/t_lagg.sh diff -u src/tests/net/if_lagg/t_lagg.sh:1.8 src/tests/net/if_lagg/t_lagg.sh:1.8.2.1 --- src/tests/net/if_lagg/t_lagg.sh:1.8 Thu Mar 31 03:26:33 2022 +++ src/tests/net/if_lagg/t_lagg.sh Thu Oct 19 07:23:50 2023 @@ -1,4 +1,4 @@ -# $NetBSD: t_lagg.sh,v 1.8 2022/03/31 03:26:33 yamaguchi Exp $ +# $NetBSD: t_lagg.sh,v 1.8.2.1 2023/10/19 07:23:50 martin Exp $ # # Copyright (c) 2021 Internet Initiative Japan Inc. # All rights reserved. @@ -367,6 +367,7 @@ lagg_mtu_head() lagg_mtu_body() { local atf_ifconfig="atf_check -s exit:0 rump.ifconfig" + local mtu_lagg=1500 local mtu_1st=1450 local mtu_big=1460 local mtu_small=1440 @@ -379,59 +380,47 @@ lagg_mtu_body() rump_server_add_iface $SOCK_HOST0 shmif2 $BUS2 $atf_ifconfig lagg0 create $atf_ifconfig lagg0 laggproto lacp + $atf_ifconfig lagg0 up $atf_ifconfig shmif0 mtu $mtu_1st $atf_ifconfig shmif1 mtu $mtu_big $atf_ifconfig shmif2 mtu $mtu_small - atf_check -s exit:0 -o match:"mtu *1500" rump.ifconfig lagg0 + # check initial MTU settings + atf_check -s exit:0 -o match:"mtu *$mtu_lagg" rump.ifconfig lagg0 atf_check -s exit:0 -o match:"mtu *$mtu_1st" rump.ifconfig shmif0 atf_check -s exit:0 -o match:"mtu *$mtu_big" rump.ifconfig shmif1 atf_check -s exit:0 -o match:"mtu *$mtu_small" rump.ifconfig shmif2 # copy MTU from 1st port $atf_ifconfig lagg0 laggport shmif0 - atf_check -s exit:0 -o match:"mtu *$mtu_1st" rump.ifconfig lagg0 - atf_check -s exit:0 -o match:"mtu *$mtu_1st" rump.ifconfig shmif0 + atf_check -s exit:0 -o match:"mtu *$mtu_lagg" rump.ifconfig lagg0 + atf_check -s exit:0 -o match:"mtu *$mtu_lagg" rump.ifconfig shmif0 # copy MTU to added port $atf_ifconfig lagg0 laggport shmif1 $atf_ifconfig lagg0 laggport shmif2 - atf_check -s exit:0 -o match:"mtu *$mtu_1st" rump.ifconfig lagg0 - atf_check -s exit:0 -o match:"mtu *$mtu_1st" rump.ifconfig shmif0 - atf_check -s exit:0 -o match:"mtu *$mtu_1st" rump.ifconfig shmif1 - atf_check -s exit:0 -o match:"mtu *$mtu_1st" rump.ifconfig shmif2 + atf_check -s exit:0 -o match:"mtu *$mtu_lagg" rump.ifconfig lagg0 + atf_check -s exit:0 -o match:"mtu *$mtu_lagg" rump.ifconfig shmif0 + atf_check -s exit:0 -o match:"mtu *$mtu_lagg" rump.ifconfig shmif1 + atf_check -s exit:0 -o match:"mtu *$mtu_lagg" rump.ifconfig shmif2 # reset MTU after detaching from lagg0 $atf_ifconfig lagg0 -laggport shmif2 atf_check -s exit:0 -o match:"mtu *$mtu_small" rump.ifconfig shmif2 # change MTU of lagg0 - $atf_ifconfig lagg0 mtu 1500 - atf_check -s exit:0 -o match:"mtu *1500" rump.ifconfig lagg0 - atf_check -s exit:0 -o match:"mtu *1500" rump.ifconfig shmif0 - atf_check -s exit:0 -o match:"mtu *1500" rump.ifconfig shmif1 + mtu_lagg=1400 + $atf_ifconfig lagg0 mtu $mtu_lagg + atf_check -s exit:0 -o match:"mtu *$mtu_lagg" rump.ifconfig lagg0 + atf_check -s exit:0 -o match:"mtu *$mtu_lagg" rump.ifconfig shmif0 + atf_check -s exit:0 -o match:"mtu *$mtu_lagg" rump.ifconfig shmif1 # reset MTU after detching from lagg0 $atf_ifconfig lagg0 -laggport shmif0 $atf_ifconfig lagg0 -laggport shmif1 atf_check -s exit:0 -o match:"mtu *$mtu_1st" rump.ifconfig shmif0 atf_check -s exit:0 -o match:"mtu *$mtu_big" rump.ifconfig shmif1 - - # MTU should not be changed - atf_check -s exit:0 -o match:"mtu *1500" rump.ifconfig lagg0 - - # copy MTU from 1st port even when MTU of lagg0 is changhed - $atf_ifconfig lagg0 mtu 1400 - atf_check -s exit:0 -o match:"mtu *1400" rump.ifconfig lagg0 - $atf_ifconfig lagg0 laggport shmif0 - atf_check -s exit:0 -o match:"mtu *$mtu_1st" rump.ifconfig lagg0 - atf_check -s exit:0 -o match:"mtu *$mtu_1st" rump.ifconfig shmif0 - - # MTU of lagg0 need not reset - $atf_ifconfig lagg0 -laggport shmif0 - atf_check -s exit:0 -o match:"mtu *$mtu_1st" rump.ifconfig lagg0 - atf_check -s exit:0 -o match:"mtu *$mtu_1st" rump.ifconfig shmif0 } lagg_mtu_cleanup()