ia64/xen-unstable

changeset 649:9080b9366dbc

bitkeeper revision 1.366 (3f180c249baezM9CBDGCdMy9FUJlxQ)

network.c, dev.c, vif.h, network.h:
Fixed DHCP lease renewal for domain 0.
author kaf24@scramble.cl.cam.ac.uk
date Fri Jul 18 15:03:00 2003 +0000 (2003-07-18)
parents 63be03a97e73
children aceefe65b9e5 784f6ddcee8e
files xen/include/hypervisor-ifs/network.h xen/include/xeno/vif.h xen/net/dev.c xenolinux-2.4.21-sparse/arch/xeno/drivers/network/network.c
line diff
     1.1 --- a/xen/include/hypervisor-ifs/network.h	Fri Jul 18 08:59:34 2003 +0000
     1.2 +++ b/xen/include/hypervisor-ifs/network.h	Fri Jul 18 15:03:00 2003 +0000
     1.3 @@ -169,5 +169,6 @@ int add_net_rule(net_rule_t *rule);
     1.4  /* Descriptor status values */
     1.5  #define RING_STATUS_OK               0  /* Everything is gravy. */
     1.6  #define RING_STATUS_BAD_PAGE         1  /* What they gave us was pure evil */
     1.7 +#define RING_STATUS_DROPPED          2  /* Unrouteable packet */
     1.8  
     1.9  #endif
     2.1 --- a/xen/include/xeno/vif.h	Fri Jul 18 08:59:34 2003 +0000
     2.2 +++ b/xen/include/xeno/vif.h	Fri Jul 18 15:03:00 2003 +0000
     2.3 @@ -100,8 +100,9 @@ net_vif_t *find_vif_by_id(unsigned long 
     2.4   *  VIF_DROP -- Drop this packet
     2.5   *  others   -- Send to specified VIF (reference held on return)
     2.6   */
     2.7 -#define VIF_PHYS ((net_vif_t *)0)
     2.8 -#define VIF_DROP ((net_vif_t *)1)
     2.9 +#define VIF_PHYS  ((net_vif_t *)0)
    2.10 +#define VIF_DROP  ((net_vif_t *)1)
    2.11 +#define VIF_LOCAL(_vif) ((unsigned long)(_vif) > 1)
    2.12  
    2.13  #endif /* __XENO_VIF_H__ */
    2.14  
     3.1 --- a/xen/net/dev.c	Fri Jul 18 08:59:34 2003 +0000
     3.2 +++ b/xen/net/dev.c	Fri Jul 18 15:03:00 2003 +0000
     3.3 @@ -619,14 +619,8 @@ int netif_rx(struct sk_buff *skb)
     3.4      if ( skb->dst_vif == NULL )
     3.5          skb->dst_vif = net_get_target_vif(skb->data, skb->len, skb->src_vif);
     3.6          
     3.7 -    if ( (skb->dst_vif == VIF_PHYS) || (skb->dst_vif == VIF_DROP) )
     3.8 -    {
     3.9 -        netdev_rx_stat[this_cpu].dropped++;
    3.10 -        unmap_domain_mem(skb->head);
    3.11 -        kfree_skb(skb);
    3.12 -        local_irq_restore(flags);
    3.13 -        return NET_RX_DROP;
    3.14 -    }
    3.15 +    if ( !VIF_LOCAL(skb->dst_vif) )
    3.16 +        skb->dst_vif = find_vif_by_id(0);
    3.17  
    3.18      deliver_packet(skb, skb->dst_vif);
    3.19      put_vif(skb->dst_vif);
    3.20 @@ -1844,24 +1838,7 @@ long do_net_update(void)
    3.21  
    3.22              target = net_get_target_vif(g_data, tx.size, vif);
    3.23  
    3.24 -            if ( target == VIF_PHYS )
    3.25 -            {
    3.26 -                vif->tx_shadow_ring[j].id     = tx.id;
    3.27 -                vif->tx_shadow_ring[j].size   = tx.size;
    3.28 -                vif->tx_shadow_ring[j].header = 
    3.29 -                    kmem_cache_alloc(net_header_cachep, GFP_KERNEL);
    3.30 -                if ( vif->tx_shadow_ring[j].header == NULL )
    3.31 -                { 
    3.32 -                    make_tx_response(vif, tx.id, RING_STATUS_OK);
    3.33 -                    goto tx_unmap_and_continue;
    3.34 -                }
    3.35 -
    3.36 -                memcpy(vif->tx_shadow_ring[j].header, g_data, PKT_PROT_LEN);
    3.37 -                vif->tx_shadow_ring[j].payload = tx.addr + PKT_PROT_LEN;
    3.38 -                get_page_tot(buf_page);
    3.39 -                j = TX_RING_INC(j);
    3.40 -            }
    3.41 -            else if ( target != VIF_DROP )
    3.42 +            if ( VIF_LOCAL(target) )
    3.43              {
    3.44                  /* Local delivery */
    3.45                  if ( (skb = dev_alloc_skb(ETH_FRAME_LEN + 32)) == NULL )
    3.46 @@ -1897,6 +1874,27 @@ long do_net_update(void)
    3.47  
    3.48                  make_tx_response(vif, tx.id, RING_STATUS_OK);
    3.49              }
    3.50 +            else if ( (target == VIF_PHYS) || IS_PRIV(current) )
    3.51 +            {
    3.52 +                vif->tx_shadow_ring[j].id     = tx.id;
    3.53 +                vif->tx_shadow_ring[j].size   = tx.size;
    3.54 +                vif->tx_shadow_ring[j].header = 
    3.55 +                    kmem_cache_alloc(net_header_cachep, GFP_KERNEL);
    3.56 +                if ( vif->tx_shadow_ring[j].header == NULL )
    3.57 +                { 
    3.58 +                    make_tx_response(vif, tx.id, RING_STATUS_OK);
    3.59 +                    goto tx_unmap_and_continue;
    3.60 +                }
    3.61 +
    3.62 +                memcpy(vif->tx_shadow_ring[j].header, g_data, PKT_PROT_LEN);
    3.63 +                vif->tx_shadow_ring[j].payload = tx.addr + PKT_PROT_LEN;
    3.64 +                get_page_tot(buf_page);
    3.65 +                j = TX_RING_INC(j);
    3.66 +            }
    3.67 +            else
    3.68 +            {
    3.69 +                make_tx_response(vif, tx.id, RING_STATUS_DROPPED);
    3.70 +            }
    3.71  
    3.72          tx_unmap_and_continue:
    3.73              unmap_domain_mem(g_data);
     4.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/drivers/network/network.c	Fri Jul 18 08:59:34 2003 +0000
     4.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/drivers/network/network.c	Fri Jul 18 15:03:00 2003 +0000
     4.3 @@ -446,11 +446,10 @@ static int inetdev_notify(struct notifie
     4.4      struct net_private *np;
     4.5      int idx = -1;
     4.6      network_op_t op;
     4.7 -    static int removed_bootstrap_rules = 0;
     4.8  
     4.9      list_for_each ( ent, &dev_list )
    4.10      {
    4.11 -        np  = list_entry(dev_list.next, struct net_private, list);
    4.12 +        np = list_entry(dev_list.next, struct net_private, list);
    4.13          if ( np->dev == dev )
    4.14              idx = np->idx;
    4.15      }
    4.16 @@ -484,27 +483,6 @@ static int inetdev_notify(struct notifie
    4.17      op.u.net_rule.dst_addr      = ntohl(ifa->ifa_address);
    4.18      op.u.net_rule.dst_addr_mask = ~0UL;
    4.19      (void)HYPERVISOR_network_op(&op);
    4.20 -
    4.21 -    /*
    4.22 -     * When the first real interface is brought up we delete the start-of-day
    4.23 -     * bootstrap rules -- they were only installed to allow an initial DHCP
    4.24 -     * request and response.
    4.25 -     */
    4.26 -    if ( (idx == 0) && (event == NETDEV_UP) && !removed_bootstrap_rules )
    4.27 -    {
    4.28 -        memset(&op, 0, sizeof(op));
    4.29 -        op.cmd = NETWORK_OP_DELETERULE;
    4.30 -        op.u.net_rule.proto         = NETWORK_PROTO_ANY;
    4.31 -        op.u.net_rule.action        = NETWORK_ACTION_ACCEPT;
    4.32 -        op.u.net_rule.src_vif       = 0;
    4.33 -        op.u.net_rule.dst_vif       = VIF_PHYSICAL_INTERFACE;
    4.34 -        (void)HYPERVISOR_network_op(&op);
    4.35 -        op.u.net_rule.src_vif       = VIF_ANY_INTERFACE;
    4.36 -        op.u.net_rule.dst_vif       = 0;
    4.37 -        (void)HYPERVISOR_network_op(&op);
    4.38 -
    4.39 -        removed_bootstrap_rules = 1;
    4.40 -    }
    4.41      
    4.42   out:
    4.43      return NOTIFY_DONE;
    4.44 @@ -525,32 +503,13 @@ int __init init_module(void)
    4.45  
    4.46      INIT_LIST_HEAD(&dev_list);
    4.47  
    4.48 +    /*
    4.49 +     * Domain 0 must poke its own network rules as it discovers its IP
    4.50 +     * addresses. All other domains have a privileged "parent" to do this for
    4.51 +     * them at start of day.
    4.52 +     */
    4.53      if ( start_info.dom_id == 0 )
    4.54 -    {
    4.55 -        /*
    4.56 -         * Domain 0 creates wildcard rules to allow DHCP to find its first IP
    4.57 -         * address. These wildcard rules are deleted when the first inet
    4.58 -         * interface is brought up.
    4.59 -         */
    4.60 -        network_op_t op;
    4.61 -        memset(&op, 0, sizeof(op));
    4.62 -        op.cmd = NETWORK_OP_ADDRULE;
    4.63 -        op.u.net_rule.proto         = NETWORK_PROTO_ANY;
    4.64 -        op.u.net_rule.action        = NETWORK_ACTION_ACCEPT;
    4.65 -        op.u.net_rule.src_vif       = 0;
    4.66 -        op.u.net_rule.dst_vif       = VIF_PHYSICAL_INTERFACE;
    4.67 -        (void)HYPERVISOR_network_op(&op);
    4.68 -        op.u.net_rule.src_vif       = VIF_ANY_INTERFACE;
    4.69 -        op.u.net_rule.dst_vif       = 0;
    4.70 -        (void)HYPERVISOR_network_op(&op);        
    4.71 -
    4.72 -        /*
    4.73 -         * Domain 0 must poke its own network rules as it discovers its IP
    4.74 -         * addresses. All other domains have a privileged "parent" to do this
    4.75 -         * for them at start of day.
    4.76 -         */
    4.77          (void)register_inetaddr_notifier(&notifier_inetdev);
    4.78 -    }
    4.79  
    4.80      for ( i = 0; i < MAX_DOMAIN_VIFS; i++ )
    4.81      {