Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Jul 2021 20:07:24 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 33306493825b - main - if_bridge: allow MTU changes
Message-ID:  <202107282007.16SK7ObH062484@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=33306493825b291a308c0d37396e82de458f6cfe

commit 33306493825b291a308c0d37396e82de458f6cfe
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2021-07-23 15:22:18 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2021-07-28 20:01:12 +0000

    if_bridge: allow MTU changes
    
    if_bridge used to only allow MTU changes if the new MTU matched that of
    all member interfaces. This doesn't really make much sense, in that we
    really shouldn't be allowed to change the MTU of bridge member in the
    first place.
    
    Instead we now change the MTU of all member interfaces. If one fails we
    revert all interfaces back to the original MTU.
    
    We do not address the issue where bridge member interface MTUs can be
    changed here.
    
    Reviewed by:    donner
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D31288
---
 sys/net/if_bridge.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index 3e6b5ba8e0c2..adf1c9155ee1 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -917,6 +917,8 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 		break;
 
 	case SIOCSIFMTU:
+		oldmtu = sc->sc_ifp->if_mtu;
+
 		if (ifr->ifr_mtu < 576) {
 			error = EINVAL;
 			break;
@@ -926,17 +928,27 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 			break;
 		}
 		CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) {
-			if (bif->bif_ifp->if_mtu != ifr->ifr_mtu) {
-				log(LOG_NOTICE, "%s: invalid MTU: %u(%s)"
-				    " != %d\n", sc->sc_ifp->if_xname,
-				    bif->bif_ifp->if_mtu,
-				    bif->bif_ifp->if_xname, ifr->ifr_mtu);
+			error = (*bif->bif_ifp->if_ioctl)(bif->bif_ifp,
+			    SIOCSIFMTU, (caddr_t)ifr);
+			if (error != 0) {
+				log(LOG_NOTICE, "%s: invalid MTU: %u for"
+				    " member %s\n", sc->sc_ifp->if_xname,
+				    ifr->ifr_mtu,
+				    bif->bif_ifp->if_xname);
 				error = EINVAL;
 				break;
 			}
 		}
-		if (!error)
+		if (error) {
+			/* Restore the previous MTU on all member interfaces. */
+			ifr->ifr_mtu = oldmtu;
+			CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) {
+				(*bif->bif_ifp->if_ioctl)(bif->bif_ifp,
+				    SIOCSIFMTU, (caddr_t)ifr);
+			}
+		} else {
 			sc->sc_ifp->if_mtu = ifr->ifr_mtu;
+		}
 		break;
 	default:
 		/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107282007.16SK7ObH062484>