Ethernet Bridge development
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: Chris Shaw <chriss@watertech.com>
Cc: bridge@osdl.org
Subject: Re: [Bridge] MTU Question
Date: Wed, 30 Jun 2004 10:32:08 -0700	[thread overview]
Message-ID: <20040630103208.07fd4ea4@dell_ss3.pdx.osdl.net> (raw)
In-Reply-To: <002001c45ebb$86e7ccd0$8805640a@internal.watertech.com>


Try the following (2.4) patch to allow bridge to be MTU aware.

diff -Nru a/net/bridge/br_device.c b/net/bridge/br_device.c
--- a/net/bridge/br_device.c	2004-06-30 10:30:31 -07:00
+++ b/net/bridge/br_device.c	2004-06-30 10:30:31 -07:00
@@ -121,6 +121,22 @@
 	return -1;
 }
 
+static int br_change_mtu(struct net_device *dev, int new_mtu)
+{
+	struct net_bridge *br = dev->priv;
+	int max_mtu;
+
+	read_lock_bh(&br->lock);
+	max_mtu = br_min_mtu(br);
+	read_unlock_bh(&br->lock);
+
+	if (new_mtu < 68 || new_mtu > max_mtu)
+		return -EINVAL;
+
+	dev->mtu = new_mtu;
+	return 0;
+}
+
 void br_dev_setup(struct net_device *dev)
 {
 	memset(dev->dev_addr, 0, ETH_ALEN);
@@ -134,4 +150,5 @@
 	dev->accept_fastpath = br_dev_accept_fastpath;
 	dev->tx_queue_len = 0;
 	dev->set_mac_address = NULL;
+	dev->change_mtu = br_change_mtu;
 }
diff -Nru a/net/bridge/br_if.c b/net/bridge/br_if.c
--- a/net/bridge/br_if.c	2004-06-30 10:30:31 -07:00
+++ b/net/bridge/br_if.c	2004-06-30 10:30:31 -07:00
@@ -220,6 +220,24 @@
 	return 0;
 }
 
+int br_min_mtu(struct net_bridge *br)
+{
+	struct net_bridge_port *p;
+	int mtu;
+
+	p = br->port_list;
+	if (!p)
+		mtu = 1500;
+	else {
+		mtu = p->dev->mtu;
+		while ((p = p->next) != NULL) {
+			if (p->dev->mtu < mtu)
+				mtu = p->dev->mtu;
+		}
+	}
+	return mtu;
+}
+
 int br_add_if(struct net_bridge *br, struct net_device *dev)
 {
 	struct net_bridge_port *p;
@@ -250,6 +268,7 @@
 	br_fdb_insert(br, p, dev->dev_addr, 1);
 	if ((br->dev.flags & IFF_UP) && (dev->flags & IFF_UP))
 		br_stp_enable_port(p);
+	br->dev.mtu = br_min_mtu(dev->priv);
 	write_unlock_bh(&br->lock);
 
 	return 0;
diff -Nru a/net/bridge/br_private.h b/net/bridge/br_private.h
--- a/net/bridge/br_private.h	2004-06-30 10:30:31 -07:00
+++ b/net/bridge/br_private.h	2004-06-30 10:30:31 -07:00
@@ -164,6 +164,7 @@
 			    int num);
 extern void br_get_port_ifindices(struct net_bridge *br,
 			   int *ifindices);
+extern int br_min_mtu(struct net_bridge *br);
 
 /* br_input.c */
 extern void br_handle_frame(struct sk_buff *skb);

  parent reply	other threads:[~2004-06-30 17:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-30  0:02 [Bridge] MTU Question Chris Shaw
2004-06-30  4:22 ` shemminger
     [not found]   ` <002001c45ebb$86e7ccd0$8805640a@internal.watertech.com>
2004-06-30 17:32     ` Stephen Hemminger [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-06-30 18:03 Eble, Dan
2004-06-30 18:15 ` Stephen Hemminger
2004-06-30 18:16 Chris Saw

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040630103208.07fd4ea4@dell_ss3.pdx.osdl.net \
    --to=shemminger@osdl.org \
    --cc=bridge@osdl.org \
    --cc=chriss@watertech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox