From a3d1367c6dd545dbf681fbb415d72be59f266ee2 Mon Sep 17 00:00:00 2001
From: thompsa <thompsa@FreeBSD.org>
Date: Wed, 13 Jul 2005 20:40:19 +0000
Subject: [PATCH] Previously the bridge MTU was set to ETHERMTU and could not
 be changed. Since we can only bridge interfaces with the same value it meant
 that all members had to be set at ETHERMTU as well.

Allow the first member to be added to define the MTU for the bridge, the check
still applies to all additional members.

Print an informative message if the MTU is incorrect [1]

Requested by:	Niki Denev [1]
Approved by:	mlaier (mentor)
MFC after:	3 days
---
 share/man/man4/if_bridge.4 | 3 +++
 sys/net/if_bridge.c        | 7 ++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/share/man/man4/if_bridge.4 b/share/man/man4/if_bridge.4
index 0a927e53ad66..0a8c624ab1b8 100644
--- a/share/man/man4/if_bridge.4
+++ b/share/man/man4/if_bridge.4
@@ -133,6 +133,9 @@ the filter for processing.
 Note that packets to and from the bridging host will be seen by the
 filter on the interface with the appropriate address configured as well
 as on the interface on which the packet arrives or departs.
+.Pp
+The MTU of the first member interface to be added is used as the bridge MTU,
+all additional members are required to have exactly the same value.
 .Sh EXAMPLES
 The following when placed in the file
 .Pa /etc/rc.conf
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index c7987c2f4e01..bd0958e0565e 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -716,8 +716,13 @@ bridge_ioctl_add(struct bridge_softc *sc, void *arg)
 	if (ifs == NULL)
 		return (ENOENT);
 
-	if (sc->sc_ifp->if_mtu != ifs->if_mtu)
+	/* Allow the first member to define the MTU */
+	if (LIST_EMPTY(&sc->sc_iflist))
+		sc->sc_ifp->if_mtu = ifs->if_mtu;
+	else if (sc->sc_ifp->if_mtu != ifs->if_mtu) {
+		if_printf(sc->sc_ifp, "invalid MTU for %s\n", ifs->if_xname);
 		return (EINVAL);
+	}
 
 	if (ifs->if_bridge == sc)
 		return (EEXIST);