Add a `waserror` call to ipifcadd.
authorDan Cross <crossd@gmail.com>
Thu, 6 Apr 2017 19:17:49 +0000 (15:17 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 6 Apr 2017 20:14:49 +0000 (16:14 -0400)
When `ipifcadd` acquires a write lock, make sure we have
a stanza to check for `waserror` and release the lock if
one of its called functions should `error`.

Change-Id: I1a2c96166249a562d92f27368e6993bb577588af
Signed-off-by: Dan Cross <crossd@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/src/net/ipifc.c

index 8891524..614f8ac 100644 (file)
@@ -389,6 +389,7 @@ static void ipifcsetmtu(struct Ipifc *ifc, char **argv, int argc)
 static void ipifcadd(struct Ipifc *ifc, char **argv, int argc, int tentative,
                      struct Iplifc *lifcp)
 {
+       ERRSTACK(1);
        uint8_t ip[IPaddrlen], mask[IPaddrlen], rem[IPaddrlen];
        uint8_t bcast[IPaddrlen], net[IPaddrlen];
        struct Iplifc *lifc, **l;
@@ -439,6 +440,11 @@ static void ipifcadd(struct Ipifc *ifc, char **argv, int argc, int tentative,
        if (isv4(ip))
                tentative = 0;
        wlock(&ifc->rwlock);
+       if (waserror()) {
+               warn("Unexpected error thrown: %s", current_errstr());
+               wunlock(&ifc->rwlock);
+               nexterror();
+       }
 
        /* ignore if this is already a local address for this ifc */
        for (lifc = ifc->lifc; lifc; lifc = lifc->next) {
@@ -554,6 +560,7 @@ out:
        wunlock(&ifc->rwlock);
        if (tentative && sendnbrdisc)
                icmpns(f, 0, SRC_UNSPEC, ip, TARG_MULTI, ifc->mac);
+       poperror();
 }
 
 /*