All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olaf Hering <olaf@aepfle.de>
To: xen-devel@lists.xensource.com
Subject: [PATCH] netback: allow arbitrary mtu size until frontend connects
Date: Sun, 6 Feb 2011 14:42:53 +0100	[thread overview]
Message-ID: <20110206134253.GB9752@aepfle.de> (raw)
In-Reply-To: <20110206134123.GA9752@aepfle.de>


Allow arbitrary mtu size until the frontend is connected.  Once the
connection is established, adjust mtu by checking if the backend
supports the 'feature-sg'.  If the backend does support it, keep the
current mtu. Otherwise set it to the default value, which is 1500.

This helps the vif-bridge hotplug script to set the mtu size to 9000
while bringing up the guest.

Signed-off-by: Olaf Hering <olaf@aepfle.de>

---
 drivers/xen/netback/common.h    |    8 ++++++++
 drivers/xen/netback/interface.c |    8 +++++++-
 drivers/xen/netback/xenbus.c    |    9 +++++++++
 3 files changed, 24 insertions(+), 1 deletion(-)

--- linux-2.6.18-xen.hg.orig/drivers/xen/netback/common.h
+++ linux-2.6.18-xen.hg/drivers/xen/netback/common.h
@@ -82,6 +82,8 @@ typedef struct netif_st {
 	u8 can_queue:1;	/* can queue packets for receiver? */
 	u8 copying_receiver:1;	/* copy packets to receiver?       */
 
+	u8 frontend_connected:1; /* is frontend already connected? */
+
 	/* Allow netif_be_start_xmit() to peek ahead in the rx request ring. */
 	RING_IDX rx_req_cons_peek;
 
@@ -217,4 +219,10 @@ static inline int netbk_can_sg(struct ne
 	return netif->features & NETIF_F_SG;
 }
 
+static inline int netbk_frontend_connected(struct net_device *dev)
+{
+	netif_t *netif = netdev_priv(dev);
+	return !!netif->frontend_connected;
+}
+
 #endif /* __NETIF__BACKEND__COMMON_H__ */
--- linux-2.6.18-xen.hg.orig/drivers/xen/netback/interface.c
+++ linux-2.6.18-xen.hg/drivers/xen/netback/interface.c
@@ -83,9 +83,13 @@ static int net_close(struct net_device *
 	return 0;
 }
 
+/* accept the max value if frontend is not yet connected */
 static int netbk_change_mtu(struct net_device *dev, int mtu)
 {
-	int max = netbk_can_sg(dev) ? 65535 - ETH_HLEN : ETH_DATA_LEN;
+	int max = 65535 - ETH_HLEN;
+
+	if (netbk_frontend_connected(dev))
+		max = netbk_can_sg(dev) ? max : ETH_DATA_LEN;
 
 	if (mtu > max)
 		return -EINVAL;
@@ -359,6 +363,8 @@ err_rx:
 
 void netif_disconnect(netif_t *netif)
 {
+	netif->frontend_connected = 0;
+
 	if (netback_carrier_ok(netif)) {
 		rtnl_lock();
 		netback_carrier_off(netif);
--- linux-2.6.18-xen.hg.orig/drivers/xen/netback/xenbus.c
+++ linux-2.6.18-xen.hg/drivers/xen/netback/xenbus.c
@@ -329,6 +329,13 @@ static int xen_net_read_mac(struct xenbu
 	return 0;
 }
 
+static void xen_net_adjust_mtu(netif_t *netif)
+{
+	if (!netif->dev->change_mtu)
+		return;
+	netif->dev->change_mtu(netif->dev, netif->dev->mtu);
+}
+
 static void connect(struct backend_info *be)
 {
 	int err;
@@ -338,6 +345,8 @@ static void connect(struct backend_info
 	if (err)
 		return;
 
+	be->netif->frontend_connected = 1;
+	xen_net_adjust_mtu(be->netif);
 	err = xen_net_read_mac(dev, be->netif->fe_dev_addr);
 	if (err) {
 		xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename);

  reply	other threads:[~2011-02-06 13:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-06 13:41 [PATCH] set mtu from bridge also on vif interface Olaf Hering
2011-02-06 13:42 ` Olaf Hering [this message]
2011-02-07  9:03   ` [PATCH] netback: allow arbitrary mtu size until frontend connects Jan Beulich
2011-02-07  9:11     ` Ian Campbell
2011-02-07  9:49       ` Jan Beulich
2011-02-07 10:15         ` Ian Campbell
2011-02-07  9:26     ` Olaf Hering
2011-02-07  9:34       ` Ian Campbell
2011-02-07  9:52         ` Olaf Hering
2011-02-07 15:30         ` Olaf Hering
2011-02-07  9:07 ` [PATCH] set mtu from bridge also on vif interface Ian Campbell
2011-02-07  9:25   ` Olaf Hering
2011-02-07  9:36     ` Ian Campbell

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=20110206134253.GB9752@aepfle.de \
    --to=olaf@aepfle.de \
    --cc=xen-devel@lists.xensource.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.