Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/xen/xen - setup vfr rules when running as domain-0
details: https://anonhg.NetBSD.org/src/rev/22024e2043d3
branches: trunk
changeset: 565831:22024e2043d3
user: cl <cl%NetBSD.org@localhost>
date: Wed Apr 21 17:36:59 2004 +0000
description:
- setup vfr rules when running as domain-0
- patch ethernet address if running as domain-0 so that arp can work
also include bpfilter.h to get NBPFILTER
diffstat:
sys/arch/xen/xen/if_xennet.c | 54 +++++++++++++++++++++++++++++++++++++++++--
1 files changed, 51 insertions(+), 3 deletions(-)
diffs (104 lines):
diff -r 92ff4171000e -r 22024e2043d3 sys/arch/xen/xen/if_xennet.c
--- a/sys/arch/xen/xen/if_xennet.c Wed Apr 21 17:26:42 2004 +0000
+++ b/sys/arch/xen/xen/if_xennet.c Wed Apr 21 17:36:59 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_xennet.c,v 1.4 2004/04/21 12:43:43 cl Exp $ */
+/* $NetBSD: if_xennet.c,v 1.5 2004/04/21 17:36:59 cl Exp $ */
/*
*
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xennet.c,v 1.4 2004/04/21 12:43:43 cl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet.c,v 1.5 2004/04/21 17:36:59 cl Exp $");
#include "opt_inet.h"
@@ -75,6 +75,7 @@
#include <nfs/nfsmount.h>
#include <nfs/nfsdiskless.h>
+#include "bpfilter.h"
#if NBPFILTER > 0
#include <net/bpf.h>
#include <net/bpfdesc.h>
@@ -126,6 +127,7 @@
static void network_alloc_tx_buffers(struct xennet_softc *);
void xennet_init(struct xennet_softc *);
void xennet_reset(struct xennet_softc *);
+static void xennet_setvfrrules(struct ifnet *, struct ifaddr *);
#ifdef mediacode
static int xennet_mediachange (struct ifnet *);
static void xennet_mediastatus(struct ifnet *, struct ifmediareq *);
@@ -196,8 +198,19 @@
sc->sc_ifno = xneta->xa_netop.vif;
- memcpy(sc->sc_enaddr, xneta->xa_netop.u.get_vif_info.vmac,
+ memcpy(sc->sc_enaddr, xneta->xa_netop.u.get_vif_info.vmac,
ETHER_ADDR_LEN);
+ if (xen_start_info.flags & SIF_PRIVILEGED) {
+ /* XXX for domain-0 change out ethernet address to be
+ * different than the physical address since arp
+ * replies from other domains will report the physical
+ * address.
+ */
+ if (sc->sc_enaddr[0] != 0xaa)
+ sc->sc_enaddr[0] = 0xaa;
+ else
+ sc->sc_enaddr[0] = 0xab;
+ }
/* Initialize ifnet structure. */
memcpy(ifp->if_xname, sc->sc_dev.dv_xname, IFNAMSIZ);
@@ -682,6 +695,8 @@
#ifdef INET
case AF_INET:
xennet_init(sc);
+ if (xen_start_info.flags & SIF_PRIVILEGED)
+ xennet_setvfrrules(ifp, ifa);
arp_ifinit(ifp, ifa);
break;
#endif
@@ -760,6 +775,39 @@
DPRINTFN(XEDB_FOLLOW, ("%s: xennet_reset()\n", sc->sc_dev.dv_xname));
}
+static void
+xennet_setvfrrules(struct ifnet *ifp, struct ifaddr *ifa)
+{
+ struct xennet_softc *sc = ifp->if_softc;
+ struct in_addr *ip;
+ network_op_t op;
+
+ ip = &IA_SIN(ifa)->sin_addr;
+ if (in_nullhost(*ip))
+ return;
+
+ memset(&op, 0, sizeof(op));
+ op.u.net_rule.proto = NETWORK_PROTO_ANY;
+ op.u.net_rule.action = NETWORK_ACTION_ACCEPT;
+
+ op.cmd = NETWORK_OP_ADDRULE;
+
+ op.u.net_rule.src_vif = sc->sc_ifno;
+ op.u.net_rule.dst_vif = VIF_PHYSICAL_INTERFACE;
+ op.u.net_rule.src_addr = ntohl(ip->s_addr);
+ op.u.net_rule.src_addr_mask = ~0UL;
+ op.u.net_rule.dst_addr = 0;
+ op.u.net_rule.dst_addr_mask = 0;
+ (void)HYPERVISOR_network_op(&op);
+
+ op.u.net_rule.src_vif = VIF_ANY_INTERFACE;
+ op.u.net_rule.dst_vif = sc->sc_ifno;
+ op.u.net_rule.src_addr = 0;
+ op.u.net_rule.src_addr_mask = 0;
+ op.u.net_rule.dst_addr = ntohl(ip->s_addr);
+ op.u.net_rule.dst_addr_mask = ~0UL;
+ (void)HYPERVISOR_network_op(&op);
+}
#ifdef mediacode
/*
Home |
Main Index |
Thread Index |
Old Index