Prevent a panic caused by freeing things in the wrong order, when unbinding an interface with multicast addresses. To demonstrate the panic, try this: % ip/ipconfig ether /net/ether0 add 2001:db8::1234 /32 % up/ipconfig ether /net/ether0 unbind Notes: Tue May 1 19:26:32 BST 2007 miller (typo: up/ipconfig -> ip/ipconfig) Reference: /n/sources/patch/applied/unbind-panic Date: Tue May 1 20:23:42 CES 2007 Signed-off-by: miller@hamnavoe.com Reviewed-by: geoff --- /sys/src/9/ip/ipifc.c Tue May 1 20:19:11 2007 +++ /sys/src/9/ip/ipifc.c Tue May 1 20:19:07 2007 @@ -185,6 +185,14 @@ ifc->conv->inuse--; ifc->ifcid++; + /* disassociate logical interfaces */ + while(ifc->lifc){ + err = ipifcremlifc(ifc, ifc->lifc); + /* note: err nonzero means lifc not found, which can't happen in this case */ + if(err) + error(err); + } + /* disassociate device */ if(ifc->m && ifc->m->unbind) (*ifc->m->unbind)(ifc); @@ -196,13 +204,6 @@ qclose(ifc->conv->rq); qclose(ifc->conv->wq); qclose(ifc->conv->sq); - - /* disassociate logical interfaces */ - while(ifc->lifc){ - err = ipifcremlifc(ifc, ifc->lifc); - if(err) - error(err); - } ifc->m = nil; wunlock(ifc);