From 455321c2002fc070889c89f935ec851baa85c60a Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Tue, 29 Apr 2003 15:47:27 +0000 Subject: bitkeeper revision 1.193 (3eae9e8fDbEyBEL7yKPAlkULZMIM4g) network.c, dev.c, vif.h, hypervisor-if.h, kernel.c, domain.c: Allow DHCP from domain-0 Xenolinux. Link-local IP addresses are now allocated consecutively from 169.254.1.0. --- .../arch/xeno/drivers/network/network.c | 40 +++++++++++++++------- 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'xenolinux-2.4.21-pre4-sparse') diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/network/network.c b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/network/network.c index 7cf0fecbec..a125695e54 100644 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/network/network.c +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/network/network.c @@ -470,9 +470,9 @@ static int inetdev_notify(struct notifier_block *this, (void)HYPERVISOR_network_op(&op); /* - * Xen creates a pair of bootstrap rules which allows domain 0 to - * send and receive any packet. These rules can be removed once we - * have configured an IP address. + * When the first real interface is brought up we delete the start-of-day + * bootstrap rules -- they were only installed to allow an initial DHCP + * request and response. */ if ( (idx == 0) && (event == NETDEV_UP) && !removed_bootstrap_rules ) { @@ -480,11 +480,9 @@ static int inetdev_notify(struct notifier_block *this, op.cmd = NETWORK_OP_DELETERULE; op.u.net_rule.proto = NETWORK_PROTO_ANY; op.u.net_rule.action = NETWORK_ACTION_ACCEPT; - op.u.net_rule.src_vif = 0; op.u.net_rule.dst_vif = VIF_PHYSICAL_INTERFACE; (void)HYPERVISOR_network_op(&op); - op.u.net_rule.src_vif = VIF_ANY_INTERFACE; op.u.net_rule.dst_vif = 0; (void)HYPERVISOR_network_op(&op); @@ -511,13 +509,32 @@ int __init init_module(void) INIT_LIST_HEAD(&dev_list); - /* - * Domain 0 must poke its own network rules as it discovers its IP - * addresses. All other domains have a privileged "parent" to do this - * for them at start of day. - */ if ( start_info.dom_id == 0 ) + { + /* + * Domain 0 creates wildcard rules to allow DHCP to find its first IP + * address. These wildcard rules are deleted when the first inet + * interface is brought up. + */ + network_op_t op; + memset(&op, 0, sizeof(op)); + op.cmd = NETWORK_OP_ADDRULE; + op.u.net_rule.proto = NETWORK_PROTO_ANY; + op.u.net_rule.action = NETWORK_ACTION_ACCEPT; + op.u.net_rule.src_vif = 0; + op.u.net_rule.dst_vif = VIF_PHYSICAL_INTERFACE; + (void)HYPERVISOR_network_op(&op); + op.u.net_rule.src_vif = VIF_ANY_INTERFACE; + op.u.net_rule.dst_vif = 0; + (void)HYPERVISOR_network_op(&op); + + /* + * Domain 0 must poke its own network rules as it discovers its IP + * addresses. All other domains have a privileged "parent" to do this + * for them at start of day. + */ (void)register_inetaddr_notifier(¬ifier_inetdev); + } for ( i = 0; i < MAX_DOMAIN_VIFS; i++ ) { @@ -548,8 +565,7 @@ int __init init_module(void) dev->stop = network_close; dev->get_stats = network_get_stats; - memset(dev->dev_addr, 0, ETH_ALEN); - *(unsigned int *)(dev->dev_addr + 1) = i; + memcpy(dev->dev_addr, start_info.net_vmac[i], ETH_ALEN); if ( (err = register_netdev(dev)) != 0 ) { -- cgit v1.2.3