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

RE: [Xen-devel] [patch 4/5] xen: netback mac selection

To: "Jody Belka" <lists-xen@xxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxxx>
Subject: RE: [Xen-devel] [patch 4/5] xen: netback mac selection
From: "Ian Pratt" <m+Ian.Pratt@xxxxxxxxxxxx>
Date: Mon, 31 Jan 2005 23:11:15 -0000
Delivery-date: Mon, 31 Jan 2005 23:13:24 +0000
Envelope-to: xen+James.Bulpin@xxxxxxxxxxxx
List-archive: <http://sourceforge.net/mailarchive/forum.php?forum=xen-devel>
List-help: <mailto:xen-devel-request@lists.sourceforge.net?subject=help>
List-id: List for Xen developers <xen-devel.lists.sourceforge.net>
List-post: <mailto:xen-devel@lists.sourceforge.net>
List-subscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=subscribe>
List-unsubscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=unsubscribe>
Sender: xen-devel-admin@xxxxxxxxxxxxxxxxxxxxx
Thread-index: AcUH5TiUI2YB3yRASTmguUC0/mcFPwABJCmg
Thread-topic: [Xen-devel] [patch 4/5] xen: netback mac selection
Out of interest, why do you care about the backend's address? It doesn't
appear on any packets. Does this patch also pass new parameters into the
vif-bridge script?

Thanks,
Ian

> Allow specification of backend vif MAC addresses. If a backend
> MAC is not provided, generate one as before
> 
> Signed-off-by: Jody Belka <knew-xen@xxxxxxxx>
> 
> 
> diffstat:
>  linux-2.6.10-xen-sparse/drivers/xen/netback/common.h    |    2 +
>  linux-2.6.10-xen-sparse/drivers/xen/netback/interface.c |   
> 25 +++++++++++-----
>  tools/python/xen/lowlevel/xu/xu.c                       |    6 +++
>  tools/python/xen/xend/server/messages.py                |    4 +-
>  tools/python/xen/xend/server/netif.py                   |   
> 22 +++++++++++++-
>  tools/python/xen/xm/create.py                           |   10 +++++-
>  xen/include/public/io/domain_controller.h               |    6 ++-
>  7 files changed, 61 insertions(+), 14 deletions(-)
> 
> 
> diff -drNU2 
> xen.orig/linux-2.6.10-xen-sparse/drivers/xen/netback/common.h 
> xen/linux-2.6.10-xen-sparse/drivers/xen/netback/common.h
> --- 
> xen.orig/linux-2.6.10-xen-sparse/drivers/xen/netback/common.h 
> 2005-01-30 00:46:28.000000000 +0100
> +++ xen/linux-2.6.10-xen-sparse/drivers/xen/netback/common.h  
> 2005-01-31 18:40:52.936589384 +0100
> @@ -36,4 +36,6 @@
>      unsigned int     handle;
>  
> +    u8               fe_dev_addr[6];
> +
>      /* Physical parameters of the comms window. */
>      unsigned long    tx_shmem_frame;
> diff -drNU2 
> xen.orig/linux-2.6.10-xen-sparse/drivers/xen/netback/interface
> .c xen/linux-2.6.10-xen-sparse/drivers/xen/netback/interface.c
> --- 
> xen.orig/linux-2.6.10-xen-sparse/drivers/xen/netback/inte
> rface.c       2005-01-30 00:46:28.000000000 +0100
> +++ 
> xen/linux-2.6.10-xen-sparse/drivers/xen/netback/interface.c   
> 2005-01-31 18:40:52.947587712 +0100
> @@ -164,11 +164,22 @@
>      dev->tx_queue_len = 0;
>  
> -    /*
> -     * Initialise a dummy MAC address. We choose the 
> numerically largest
> -     * non-broadcast address to prevent the address getting 
> stolen by an 
> -     * Ethernet bridge for STP purposes. (FE:FF:FF:FF:FF:FF)
> -     */
> -    memset(dev->dev_addr, 0xFF, ETH_ALEN);
> -    dev->dev_addr[0] &= ~0x01;
> +    if ( (create->be_mac[0] == 0) && (create->be_mac[1] == 0) &&
> +         (create->be_mac[2] == 0) && (create->be_mac[3] == 0) &&
> +         (create->be_mac[4] == 0) && (create->be_mac[5] == 0) )
> +    {
> +        /*
> +         * Initialise a dummy MAC address. We choose the 
> numerically largest
> +         * non-broadcast address to prevent the address 
> getting stolen by an
> +         * Ethernet bridge for STP purposes. (FE:FF:FF:FF:FF:FF)
> +         */ 
> +        memset(dev->dev_addr, 0xFF, ETH_ALEN);
> +        dev->dev_addr[0] &= ~0x01;
> +    }
> +    else
> +    {
> +        memcpy(dev->dev_addr, create->be_mac, ETH_ALEN);
> +    }
> +
> +    memcpy(netif->fe_dev_addr, create->mac, ETH_ALEN);
>  
>      rtnl_lock();
> diff -drNU2 xen.orig/tools/python/xen/lowlevel/xu/xu.c 
> xen/tools/python/xen/lowlevel/xu/xu.c
> --- xen.orig/tools/python/xen/lowlevel/xu/xu.c        
> 2005-01-30 00:46:29.000000000 +0100
> +++ xen/tools/python/xen/lowlevel/xu/xu.c     2005-01-31 
> 18:40:52.957586192 +0100
> @@ -624,4 +624,10 @@
>          P2C(netif_be_create_t, mac[4],       u8);
>          P2C(netif_be_create_t, mac[5],       u8);
> +        P2C(netif_be_create_t, be_mac[0],    u8);
> +        P2C(netif_be_create_t, be_mac[1],    u8);
> +        P2C(netif_be_create_t, be_mac[2],    u8);
> +        P2C(netif_be_create_t, be_mac[3],    u8);
> +        P2C(netif_be_create_t, be_mac[4],    u8);
> +        P2C(netif_be_create_t, be_mac[5],    u8);
>          break;
>      case TYPE(CMSG_NETIF_BE, CMSG_NETIF_BE_DESTROY):
> diff -drNU2 xen.orig/tools/python/xen/xend/server/messages.py 
> xen/tools/python/xen/xend/server/messages.py
> --- xen.orig/tools/python/xen/xend/server/messages.py 
> 2005-01-30 00:46:29.000000000 +0100
> +++ xen/tools/python/xen/xend/server/messages.py      
> 2005-01-31 18:40:52.969584368 +0100
> @@ -267,7 +267,7 @@
>      args = {}
>      for (k, v) in params.items():
> -        if k == 'mac':
> +        if k in ['mac', 'be_mac']:
>              for i in range(0, 6):
> -                args['mac[%d]' % i] = v[i]
> +                args['%s[%d]' % (k, i)] = v[i]
>          else:
>              args[k] = v
> diff -drNU2 xen.orig/tools/python/xen/xend/server/netif.py 
> xen/tools/python/xen/xend/server/netif.py
> --- xen.orig/tools/python/xen/xend/server/netif.py    
> 2005-01-30 00:46:29.000000000 +0100
> +++ xen/tools/python/xen/xend/server/netif.py 2005-01-31 
> 18:40:52.980582696 +0100
> @@ -110,5 +110,12 @@
>          if not vmac: return None
>          mac = [ int(x, 16) for x in vmac.split(':') ]
> -        if len(mac) != 6: raise XendError("invalid mac")
> +        if len(mac) != 6: raise XendError("invalid mac: %s" % vmac)
> +        return mac
> +
> +    def _get_config_be_mac(self, config):
> +        vmac = sxp.child_value(config, 'be_mac')
> +        if not vmac: return None
> +        mac = [ int(x, 16) for x in vmac.split(':') ]
> +        if len(mac) != 6: raise XendError("invalid backend 
> mac: %s" % vmac)
>          return mac
>  
> @@ -128,4 +135,5 @@
>          self.config = config
>          self.mac = None
> +        self.be_mac = None
>          self.bridge = None
>          self.script = None
> @@ -136,4 +144,5 @@
>              raise XendError("invalid mac")
>          self.mac = mac
> +        self.be_mac = self._get_config_be_mac(config)
>          self.bridge = sxp.child_value(config, 'bridge')
>          self.script = sxp.child_value(config, 'script')
> @@ -160,4 +169,5 @@
>          changes = {}
>          mac = self._get_config_mac(config)
> +        be_mac = self._get_config_be_mac(config)
>          bridge = sxp.child_value(config, 'bridge')
>          script = sxp.child_value(config, 'script')
> @@ -167,4 +177,6 @@
>          if (mac is not None) and (mac != self.mac):
>              raise XendError("cannot change mac")
> +        if (be_mac is not None) and (be_mac != self.be_mac):
> +            raise XendError("cannot change backend mac")
>          if (backendDomain is not None) and (backendDomain != 
> str(self.backendDomain)):
>              raise XendError("cannot change backend")
> @@ -191,4 +203,6 @@
>                 ['vif', vif],
>                 ['mac', mac]]
> +        if self.be_mac:
> +            val.append(['be_mac', self.get_be_mac()])
>          if self.bridge:
>              val.append(['bridge', self.bridge])
> @@ -215,4 +229,9 @@
>          return ':'.join(map(lambda x: "%02x" % x, self.mac))
>  
> +    def get_be_mac(self):
> +        """Get the backend MAC address as a string.
> +        """
> +        return ':'.join(map(lambda x: "%02x" % x, self.be_mac))
> +
>      def vifctl_params(self, vmname=None):
>          """Get the parameters to pass to vifctl.
> @@ -268,4 +287,5 @@
>                        { 'domid'        : self.controller.dom,
>                          'netif_handle' : self.vif,
> +                        'be_mac'       : self.be_mac or [0, 
> 0, 0, 0, 0, 0],
>                          'mac'          : self.mac })
>          self.getBackendInterface().writeRequest(msg, response=d)
> diff -drNU2 xen.orig/tools/python/xen/xm/create.py 
> xen/tools/python/xen/xm/create.py
> --- xen.orig/tools/python/xen/xm/create.py    2005-01-30 
> 00:46:29.000000000 +0100
> +++ xen/tools/python/xen/xm/create.py 2005-01-31 
> 18:40:52.990581176 +0100
> @@ -152,9 +152,11 @@
>            use="Add an IP address to the domain.")
>  
> -gopts.var('vif', 
> val="mac=MAC,bridge=BRIDGE,script=SCRIPT,backend=DOM",
> +gopts.var('vif', 
> val="mac=MAC,be_mac=MAC,bridge=BRIDGE,script=SCRIPT,backend=DOM",
>            fn=append_value, default=[],
>            use="""Add a network interface with the given MAC 
> address and bridge.
>            The vif is configured by calling the given 
> configuration script.
>            If mac is not specified a random MAC address is used.
> +          The MAC address of the backend interface can be 
> selected with be_mac.
> +          If not specified then the network backend chooses 
> it's own MAC address.
>            If bridge is not specified the default bridge is used.
>            If script is not specified the default script is used.
> @@ -286,4 +288,5 @@
>              if not mac:
>                  mac = randomMAC()
> +            be_mac = d.get('be_mac')
>              bridge = d.get('bridge')
>              script = d.get('script')
> @@ -292,4 +295,5 @@
>          else:
>              mac = randomMAC()
> +            be_mac = None
>              bridge = None
>              script = None
> @@ -298,4 +302,6 @@
>          config_vif = ['vif']
>          config_vif.append(['mac', mac])
> +        if be_mac:
> +            config_vif.append(['be_mac', be_mac])
>          if bridge:
>              config_vif.append(['bridge', bridge])
> @@ -384,5 +390,5 @@
>              k = k.strip()
>              v = v.strip()
> -            if k not in ['mac', 'bridge', 'script', 'backend', 'ip']:
> +            if k not in ['mac', 'be_mac', 'bridge', 
> 'script', 'backend', 'ip']:
>                  opts.err('Invalid vif specifier: ' + vif)
>              d[k] = v
> diff -drNU2 
> xen.orig/xen/include/public/io/domain_controller.h 
> xen/xen/include/public/io/domain_controller.h
> --- xen.orig/xen/include/public/io/domain_controller.h        
> 2005-01-30 00:46:29.000000000 +0100
> +++ xen/xen/include/public/io/domain_controller.h     
> 2005-01-31 18:40:53.000579656 +0100
> @@ -479,7 +479,9 @@
>      u8         mac[6];        /*  8 */
>      u16        __pad1;        /* 14 */
> +    u8         be_mac[6];     /* 16 */
> +    u16        __pad2;        /* 22 */
>      /* OUT */
> -    u32        status;        /* 16 */
> -} PACKED netif_be_create_t; /* 20 bytes */
> +    u32        status;        /* 24 */
> +} PACKED netif_be_create_t; /* 28 bytes */
>  
>  /*
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: IntelliVIEW -- Interactive 
> Reporting
> Tool for open source databases. Create drag-&-drop reports. Save time
> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.sourceforge.net/lists/listinfo/xen-devel
> 


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-devel

<Prev in Thread] Current Thread [Next in Thread>