netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Florian Fainelli" <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: amwang@redhat.com, jiri@resnulli.us, stephen@networkplumber.org,
	kaber@trash.net, davem@davemloft.net, vyasevic@redhat.com,
	johannes@sipsolutions.net, eric.dumazet@gmail.com,
	"Florian Fainelli" <f.fainelli@gmail.com>
Subject: [PATCH 3/3] net: bridge: handle NETDEV_CHANGEROOM event
Date: Tue, 20 Aug 2013 13:45:52 +0100	[thread overview]
Message-ID: <1377002752-4622-4-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1377002752-4622-1-git-send-email-f.fainelli@gmail.com>

When a device which is a port member of a bridge has
needed_headroom/tailroom requirement changes, we need to walk the list
of bridge members, compute the minimum headroom or tailroom value, and
update the parent bridge device with the new values.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 net/bridge/br_if.c      | 32 ++++++++++++++++++++++++++++++++
 net/bridge/br_notify.c  |  5 +++++
 net/bridge/br_private.h |  2 ++
 3 files changed, 39 insertions(+)

diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index aa6c9a8..017622b 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -296,6 +296,38 @@ int br_min_mtu(const struct net_bridge *br)
 	return mtu;
 }
 
+int br_min_headroom(const struct net_bridge *br)
+{
+	const struct net_bridge_port *p;
+	unsigned short needed_headroom = 0;
+
+	ASSERT_RTNL();
+
+	list_for_each_entry(p, &br->port_list, list) {
+		if (!needed_headroom ||
+			p->dev->needed_headroom < needed_headroom)
+			needed_headroom = p->dev->needed_headroom;
+	}
+
+	return needed_headroom;
+}
+
+int br_min_tailroom(const struct net_bridge *br)
+{
+	const struct net_bridge_port *p;
+	unsigned short needed_tailroom = 0;
+
+	ASSERT_RTNL();
+
+	list_for_each_entry(p, &br->port_list, list) {
+		if (!needed_tailroom ||
+			p->dev->needed_tailroom < needed_tailroom)
+			needed_tailroom = p->dev->needed_tailroom;
+	}
+
+	return needed_tailroom;
+}
+
 /*
  * Recomputes features using slave's features
  */
diff --git a/net/bridge/br_notify.c b/net/bridge/br_notify.c
index 2998dd1..1c7be7c 100644
--- a/net/bridge/br_notify.c
+++ b/net/bridge/br_notify.c
@@ -107,6 +107,11 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
 		/* Propagate to master device */
 		call_netdevice_notifiers(event, br->dev);
 		break;
+
+	case NETDEV_CHANGEROOM:
+		dev_set_headroom(br->dev, br_min_headroom(br));
+		dev_set_tailroom(br->dev, br_min_tailroom(br));
+		break;
 	}
 
 	/* Events that may cause spanning tree to refresh */
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index d41283c..81dc7aa 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -421,6 +421,8 @@ extern int br_add_if(struct net_bridge *br,
 extern int br_del_if(struct net_bridge *br,
 	      struct net_device *dev);
 extern int br_min_mtu(const struct net_bridge *br);
+extern int br_min_headroom(const struct net_bridge *br);
+extern int br_min_tailroom(const struct net_bridge *br);
 extern netdev_features_t br_features_recompute(struct net_bridge *br,
 	netdev_features_t features);
 
-- 
1.8.1.2

  parent reply	other threads:[~2013-08-20 12:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-20 12:45 [PATCH 0/3] net: propagate dynamic needed_headroom/tailroom changes Florian Fainelli
2013-08-20 12:45 ` [PATCH 1/3] net: add a new NETDEV_CHANGEROOM event type Florian Fainelli
2013-08-20 15:16   ` Johannes Berg
2013-08-20 15:30     ` Florian Fainelli
2013-08-20 16:10       ` Jiri Pirko
2013-08-20 16:35       ` Johannes Berg
2013-08-20 17:30         ` Florian Fainelli
2013-08-20 12:45 ` [PATCH 2/3] net: vlan: handle NETDEV_CHANGEROOM events Florian Fainelli
2013-08-20 12:45 ` Florian Fainelli [this message]
2013-08-20 13:29 ` [PATCH 0/3] net: propagate dynamic needed_headroom/tailroom changes Jiri Pirko
2013-08-20 14:24   ` Florian Fainelli
2013-08-20 14:27     ` Jiri Pirko

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=1377002752-4622-4-git-send-email-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=amwang@redhat.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=jiri@resnulli.us \
    --cc=johannes@sipsolutions.net \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=vyasevic@redhat.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;
as well as URLs for NNTP newsgroup(s).