commit 7de61994a9fdd6f692ac0e47e2e61e195c470538
parent a0474d76cb9af3ad344610854ea3a9bb1d47dc14
Author: Jesus Galan Lopez (yiyus) <yiyu.jgl@gmail.com>
Date: Thu, 10 Jun 2010 01:24:42 +0200
fixes (and debug iprints!) in the tap network device
Diffstat:
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/9vx/a/devether.c b/src/9vx/a/devether.c
@@ -163,6 +163,9 @@ etheriq(Ether* ether, Block* bp, int fromwire)
/* is it for me? */
tome = memcmp(pkt->d, ether->ea, sizeof(pkt->d)) == 0;
fromme = memcmp(pkt->s, ether->ea, sizeof(pkt->s)) == 0;
+iprint("XXX PACK: %2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux -> %2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux\n",
+pkt->s[0], pkt->s[1], pkt->s[2],pkt->s[3], pkt->s[4], pkt->s[5],
+pkt->d[0], pkt->d[1], pkt->d[2],pkt->d[3], pkt->d[4], pkt->d[5]);
/*
* Multiplex the packet to all the connections which want it.
* If the packet is not to be used subsequently (fromwire != 0),
@@ -443,6 +446,9 @@ etherprobe(int cardno, int ctlrno)
memmove(ether->ni.addr, ether->ea, Eaddrlen);
memset(ether->ni.bcast, 0xFF, Eaddrlen);
+iprint("XXX EADDR: %2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux:%2.2ux\n",
+ether->ea[0], ether->ea[1], ether->ea[2],ether->ea[3], ether->ea[4], ether->ea[5]);
+
return ether;
}
diff --git a/src/9vx/ethertap.c b/src/9vx/ethertap.c
@@ -32,7 +32,7 @@
extern char *macaddr;
extern char *netdev;
-extern int eafrom(char *ma);
+extern int eafrom(char *ma, uchar ea[6]);
typedef struct Ctlr Ctlr;
struct Ctlr {
@@ -64,8 +64,6 @@ opentap(void)
close(fd);
return -1;
}
- // qemu does this:
- // fcntl(fd, F_SETFL, O_NONBLOCK);
return fd;
}
#elif defined(__FreeBSD__)
@@ -77,11 +75,6 @@ opentap(void)
if((fd = open("/dev/tap", O_RDWR)) < 0)
return -1;
- fstat(fd, &s);
- // we don't need the dev name, qemu does
- // dev = devname(s.st_rdev, S_IFCHR);
- // qemu does this:
- // fcntl(fd, F_SETFL, O_NONBLOCK);
return fd;
}
#endif
@@ -89,7 +82,7 @@ opentap(void)
static int
setup(void)
{
- if (macaddr && (eafrom(macaddr) == -1)){
+ if (macaddr && (eafrom(macaddr, ea) == -1)){
iprint("ve: cannot read mac address\n");
return -1;
}
@@ -178,6 +171,7 @@ tappnp(Ether* e)
return -1;
memset(&c, 0, sizeof c);
c.fd = setup();
+ memcpy(c.ea, ea, Eaddrlen);
if(c.fd== -1){
iprint("ve: tap failed to initialize\n");
return -1;
diff --git a/src/9vx/etherve.c b/src/9vx/etherve.c
@@ -34,7 +34,7 @@ struct Ctlr {
static uchar ea[6] = {0x00, 0x48, 0x01, 0x23, 0x45, 0x67};
int
-eafrom(char *ma)
+eafrom(char *ma, uchar ea[6])
{
int i;
char **nc = &ma;
@@ -78,7 +78,7 @@ setup(void)
if ((pd = pcap_open_live(netdev, 1514, 1, 1, errbuf)) == nil)
return nil;
- if (macaddr && (eafrom(macaddr) == -1))
+ if (macaddr && (eafrom(macaddr, ea) == -1))
return veerror("cannot read mac address");
pcap_lookupnet(netdev, &net, &mask, errbuf);