Dev IP initialization
[akaros.git] / kern / src / net / devip.c
index 77cd1db..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
 }
 
 static void
-ipreset(void)
+ipinit(void)
 {
 {
+       qlock_init(&fslock);
        nullmediumlink();
        pktmediumlink();
 /* if only
        nullmediumlink();
        pktmediumlink();
 /* if only
@@ -270,6 +271,11 @@ ipreset(void)
 */
 }
 
 */
 }
 
+static void
+ipreset(void)
+{
+}
+
 static struct Fs*
 ipgetfs(int dev)
 {
 static struct Fs*
 ipgetfs(int dev)
 {
@@ -282,7 +288,9 @@ ipgetfs(int dev)
 
        qlock(&fslock);
        if(ipfs[dev] == NULL){
 
        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);
                ip_init(f);
                arpinit(f);
                netloginit(f);
@@ -406,11 +414,11 @@ ipopen(struct chan* c, int omode)
        case Qstats:
        case Qbootp:
        case Qipselftab:
        case Qstats:
        case Qbootp:
        case Qipselftab:
-               if(omode != OREAD)
+               if((omode & OREAD) != OREAD)
                        error(Eperm);
                break;
        case Qsnoop:
                        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)];
                        error(Eperm);
                p = f->p[PROTO(c->qid)];
                cv = p->conv[CONV(c->qid)];
@@ -1205,7 +1213,7 @@ struct dev ipdevtab = {
        "ip",
 
        ipreset,
        "ip",
 
        ipreset,
-       devinit,
+       ipinit,
        devshutdown,
        ipattach,
        ipwalk,
        devshutdown,
        ipattach,
        ipwalk,
@@ -1227,6 +1235,7 @@ Fsproto(struct Fs *f, struct Proto *p)
        if(f->np >= Maxproto)
                return -1;
 
        if(f->np >= Maxproto)
                return -1;
 
+       qlock_init(&p->qlock);
        p->f = f;
 
        if(p->ipproto > 0){
        p->f = f;
 
        if(p->ipproto > 0){
@@ -1276,6 +1285,10 @@ retry:
                        c = kzmalloc(sizeof(struct conv), 0);
                        if(c == NULL)
                                error(Enomem);
                        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;
                        qlock(&c->qlock);
                        c->p = p;
                        c->x = pp - p->conv;