Dev IP initialization
[akaros.git] / kern / src / net / devip.c
index d76a990..3d904d2 100644 (file)
@@ -257,8 +257,9 @@ ipgen(struct chan *c, char *unused_char_p_t, struct dirtab*d, int unused_int, in
 }
 
 static void
-ipreset(void)
+ipinit(void)
 {
+       qlock_init(&fslock);
        nullmediumlink();
        pktmediumlink();
 /* if only
@@ -270,6 +271,11 @@ ipreset(void)
 */
 }
 
+static void
+ipreset(void)
+{
+}
+
 static struct Fs*
 ipgetfs(int dev)
 {
@@ -282,7 +288,9 @@ ipgetfs(int dev)
 
        qlock(&fslock);
        if(ipfs[dev] == NULL){
-               f = kzmalloc(sizeof(struct Fs), 0);
+               f = kzmalloc(sizeof(struct Fs), KMALLOC_WAIT);
+               rwinit(&f->rwlock);
+               qlock_init(&f->iprouter.qlock);
                ip_init(f);
                arpinit(f);
                netloginit(f);
@@ -406,11 +414,11 @@ ipopen(struct chan* c, int omode)
        case Qstats:
        case Qbootp:
        case Qipselftab:
-               if(omode != OREAD)
+               if((omode & OREAD) != OREAD)
                        error(Eperm);
                break;
        case Qsnoop:
-               if(omode != OREAD)
+               if((omode & OREAD) != OREAD)
                        error(Eperm);
                p = f->p[PROTO(c->qid)];
                cv = p->conv[CONV(c->qid)];
@@ -953,7 +961,7 @@ connected(void* a)
 static void
 connectctlmsg(struct Proto *x, struct conv *c, struct cmdbuf *cb)
 {
-       ERRSTACK(2);
+       ERRSTACK(1);
        char *p;
 
        if(c->state != 0)
@@ -1006,7 +1014,7 @@ announced(void* a)
 static void
 announcectlmsg(struct Proto *x, struct conv *c, struct cmdbuf *cb)
 {
-       ERRSTACK(2);
+       ERRSTACK(1);
        char *p;
 
        if(c->state != 0)
@@ -1080,7 +1088,7 @@ ttlctlmsg(struct conv *c, struct cmdbuf *cb)
 static long
 ipwrite(struct chan* ch, void *v, long n, int64_t off)
 {
-       ERRSTACK(2);
+       ERRSTACK(1);
        struct conv *c;
        struct Proto *x;
        char *p;
@@ -1205,7 +1213,7 @@ struct dev ipdevtab = {
        "ip",
 
        ipreset,
-       devinit,
+       ipinit,
        devshutdown,
        ipattach,
        ipwalk,
@@ -1227,6 +1235,7 @@ Fsproto(struct Fs *f, struct Proto *p)
        if(f->np >= Maxproto)
                return -1;
 
+       qlock_init(&p->qlock);
        p->f = f;
 
        if(p->ipproto > 0){
@@ -1276,6 +1285,10 @@ retry:
                        c = kzmalloc(sizeof(struct conv), 0);
                        if(c == NULL)
                                error(Enomem);
+                       qlock_init(&c->qlock);
+                       qlock_init(&c->listenq);
+                       rendez_init(&c->cr);
+                       rendez_init(&c->listenr);
                        qlock(&c->qlock);
                        c->p = p;
                        c->x = pp - p->conv;