WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] netback: allow arbitrary mtu size until frontend con

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] netback: allow arbitrary mtu size until frontend connects
From: Olaf Hering <olaf@xxxxxxxxx>
Date: Sun, 6 Feb 2011 14:42:53 +0100
Delivery-date: Sun, 06 Feb 2011 05:43:36 -0800
Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1296999774; l=2818; s=domk; d=aepfle.de; h=In-Reply-To:Content-Type:MIME-Version:References:Subject:To:From: Date:X-RZG-CLASS-ID:X-RZG-AUTH; bh=brYdCwvdoE91RTkq1UiKWCy7IY4=; b=sb1ueNsuhrOMmRrQ4gu1yUFW++m5vjlJqQ30c8jAC2Or2XaTMAXJgJb3dx39VLZsUVc bSv4rKdukkQOfT9p/ml8HzY9Kp/7fU0SBW/Tt7bkKVGv6Y9nOoAUc5u1kOYRa4i+nKdxh NqM5D4THJnKiSrq/0zoc+MaFPkSuJc2hD7Y=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20110206134123.GA9752@xxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20110206134123.GA9752@xxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.20 (2009-06-14)
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@xxxxxxxxx>

---
 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);

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel