ia64/xen-unstable

changeset 2410:46918bf8df85

bitkeeper revision 1.1159.68.2 (41383cdfHn8bdXUvTO9mrnc7pCTLGA)

Send a fake ARP packet when a vif comes up, to let switches
see the MAC address.
author mjw@wray-m-3.hpl.hp.com
date Fri Sep 03 09:43:59 2004 +0000 (2004-09-03)
parents f406a0f99a84
children 8b7e79495b43
files linux-2.6.8.1-xen-sparse/drivers/xen/netfront/netfront.c
line diff
     1.1 --- a/linux-2.6.8.1-xen-sparse/drivers/xen/netfront/netfront.c	Thu Sep 02 15:35:56 2004 +0000
     1.2 +++ b/linux-2.6.8.1-xen-sparse/drivers/xen/netfront/netfront.c	Fri Sep 03 09:43:59 2004 +0000
     1.3 @@ -26,6 +26,9 @@
     1.4  #include <asm-xen/hypervisor-ifs/io/netif.h>
     1.5  #include <asm/page.h>
     1.6  
     1.7 +#include <net/arp.h>
     1.8 +#include <net/route.h>
     1.9 +
    1.10  #if 0
    1.11  #define DPRINTK(fmt, args...) \
    1.12      printk(KERN_INFO "[XEN] %s" fmt, __FUNCTION__, ##args)
    1.13 @@ -171,6 +174,32 @@ static int netctrl_connected_count(void)
    1.14      return connected;
    1.15  }
    1.16  
    1.17 +/** Send a packet on a net device to encourage switches to learn the
    1.18 + * MAC. We send a fake ARP request.
    1.19 + *
    1.20 + * @param dev device
    1.21 + * @return 0 on success, error code otherwise
    1.22 + */
    1.23 +static int vif_wake(struct net_device *dev){
    1.24 +    int err = 0;
    1.25 +    struct sk_buff *skb;
    1.26 +    u32 src_ip;
    1.27 +    u32 dst_ip = INADDR_BROADCAST;
    1.28 +    unsigned char dst_hw[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
    1.29 +
    1.30 +    src_ip = inet_select_addr(dev, dst_ip, RT_SCOPE_LINK);
    1.31 +    skb = arp_create(ARPOP_REQUEST, ETH_P_ARP,
    1.32 +                     dst_ip, dev, src_ip,
    1.33 +                     dst_hw, dev->dev_addr, NULL);
    1.34 +    if(skb == NULL){
    1.35 +        err = -ENOMEM;
    1.36 +        goto exit;
    1.37 +    }
    1.38 +    err = dev_queue_xmit(skb);
    1.39 +  exit:
    1.40 +    return err;
    1.41 +}
    1.42 +
    1.43  static inline struct sk_buff *alloc_skb_page(void)
    1.44  {
    1.45      struct sk_buff *skb;
    1.46 @@ -739,6 +768,7 @@ static void netif_status_change(netif_fe
    1.47          (void)request_irq(np->irq, netif_int, SA_SAMPLE_RANDOM, 
    1.48                            dev->name, dev);
    1.49          netctrl_connected_count();
    1.50 +        vif_wake(dev);
    1.51          break;
    1.52  
    1.53      default: