I thought we already had something for this after the misc@ thread
a few months ago, but clearly not.

Adapted from FreeBSD if_lagg.c r171661 (which includes capability
setting which we already do).
http://svnweb.freebsd.org/base/head/sys/net/if_lagg.c?r1=171603&r2=171661

Index: if_trunk.c
===================================================================
RCS file: /cvs/src/sys/net/if_trunk.c,v
retrieving revision 1.78
diff -u -p -r1.78 if_trunk.c
--- if_trunk.c  28 Oct 2011 12:49:43 -0000      1.78
+++ if_trunk.c  22 Feb 2013 12:27:18 -0000
@@ -315,6 +315,20 @@ trunk_port_create(struct trunk_softc *tr
        if (ifp->if_type != IFT_ETHER)
                return (EPROTONOSUPPORT);
 
+       /* Take MTU from the first member port */
+       if (SLIST_EMPTY(&tr->tr_ports)) {
+               if (tr->tr_ifflags & IFF_DEBUG)
+                       printf("%s: first port, setting trunk mtu %u\n",
+                           tr->tr_ifname, ifp->if_mtu);
+               tr->tr_ac.ac_if.if_mtu = ifp->if_mtu;
+               tr->tr_ac.ac_if.if_hardmtu = ifp->if_mtu;
+       }
+       else if (tr->tr_ac.ac_if.if_mtu != ifp->if_mtu) {
+               printf("%s: adding %s failed, MTU %u != %u\n", tr->tr_ifname,
+                   ifp->if_xname, ifp->if_mtu, tr->tr_ac.ac_if.if_mtu);
+               return (EINVAL);
+       }
+
        if ((error = ifpromisc(ifp, 1)) != 0)
                return (error);
 
@@ -510,6 +524,10 @@ trunk_port_ioctl(struct ifnet *ifp, u_lo
                }
 
                trunk_port2req(tp, rp);
+               break;
+       case SIOCSIFMTU:
+               /* Do not allow the MTU to be changed once joined */
+               error = EINVAL;
                break;
        default:
                error = ENOTTY;

Reply via email to