Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net if MTU of the added interface doesn't match the brid...



details:   https://anonhg.NetBSD.org/src/rev/c048fd29ed35
branches:  trunk
changeset: 931627:c048fd29ed35
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Mon Apr 27 20:46:01 2020 +0000

description:
if MTU of the added interface doesn't match the bridge, modify the MTU
of the interface to that of the bridge instead of just refusing the
addition with EINVAL

this is a convenience feature to simplify bridge setup with non-standard
MTU, the useful behaviour observed with Linux xenbr

diffstat:

 sys/net/if_bridge.c |  15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r 1b2538c2d571 -r c048fd29ed35 sys/net/if_bridge.c
--- a/sys/net/if_bridge.c       Mon Apr 27 20:31:11 2020 +0000
+++ b/sys/net/if_bridge.c       Mon Apr 27 20:46:01 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bridge.c,v 1.170 2020/03/27 16:47:00 jdolecek Exp $ */
+/*     $NetBSD: if_bridge.c,v 1.171 2020/04/27 20:46:01 jdolecek Exp $ */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.170 2020/03/27 16:47:00 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.171 2020/04/27 20:46:01 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bridge_ipf.h"
@@ -830,8 +830,15 @@
        switch (ifs->if_type) {
        case IFT_ETHER:
                if (sc->sc_if.if_mtu != ifs->if_mtu) {
-                       error = EINVAL;
-                       goto out;
+                       /* Change MTU of added interface to bridge MTU */
+                       struct ifreq ifr;
+                       memset(&ifr, 0, sizeof(ifr));
+                       ifr.ifr_mtu = sc->sc_if.if_mtu;
+                       IFNET_LOCK(ifs);
+                       error = ether_ioctl(ifs, SIOCSIFMTU, &ifr);
+                       IFNET_UNLOCK(ifs);
+                       if (error != 0)
+                               goto out;
                }
                /* FALLTHROUGH */
        case IFT_L2TP:



Home | Main Index | Thread Index | Old Index