git: 1879f7affbf8 - stable/13 - MFC: if_bridge: change MTU for new members
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 09 Apr 2024 10:51:24 UTC
The branch stable/13 has been updated by eugen:
URL: https://cgit.FreeBSD.org/src/commit/?id=1879f7affbf80c701c76081b2b8511f4c7dd81f5
commit 1879f7affbf80c701c76081b2b8511f4c7dd81f5
Author: Eugene Grosbein <eugen@FreeBSD.org>
AuthorDate: 2024-04-09 10:49:05 +0000
Commit: Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2024-04-09 10:50:20 +0000
MFC: if_bridge: change MTU for new members
Rather than reject new bridge members because they have the wrong MTU
change it to match the bridge. If that fails, reject the new interface.
PR: 264883
Different Revision: https://reviews.freebsd.org/D35597
(cherry picked from commit 1865ebfb12ddaf3d0ff1458e6152b3cb1f1bdee8)
---
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 662b425bc89e..e0fe45e3d326 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -945,6 +945,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 < IF_MINMTU) {
error = EINVAL;
break;
@@ -954,17 +956,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:
/*