On Tue, Jun 30, 2020 at 12:08:03PM +0200, Martin Pieuchot wrote: > On 29/06/20(Mon) 11:59, Vitaliy Makkoveev wrote: > > [...] > > I reworked tool for reproduce. Now I avoided fork()/exec() route and it > > takes couple of minutes to take panic on 4 cores. Also some screenshots > > attached. > > Setting kern.pool_debug=2 makes the race reproducible in seconds. > > Could you turn this test into something committable in regress/? We can > link it to the build once a fix is committed. >
We have 3 races with cloned interfaces: 1. if_clone_create() vs if_clone_create() 2. if_clone_destroy() vs if_clone_destroy() 3. if_clone_destroy() vs the rest of stack It makes sences to commit unified test to regress/, so I suggest to wait a little. > > #include <sys/socket.h> > > #include <sys/ioctl.h> > > #include <net/if.h> > > #include <stdio.h> > > #include <stdlib.h> > > #include <err.h> > > #include <errno.h> > > #include <pthread.h> > > #include <string.h> > > #include <unistd.h> > > > > static struct ifreq ifr; > > > > static void *clone_create(void *arg) > > { > > int s; > > > > if((s=socket(AF_INET, SOCK_DGRAM, 0))<0) > > err(1, "socket()"); > > while(1){ > > if(ioctl(s, SIOCIFCREATE, &ifr)<0) > > if(errno==EINVAL) > > exit(1); > > } > > > > return NULL; > > } > > > > static void *clone_destroy(void *arg) > > { > > int s; > > > > if((s=socket(AF_INET, SOCK_DGRAM, 0))<0) > > err(1, "socket()"); > > while(1){ > > if(ioctl(s, SIOCIFDESTROY, &ifr)<0) > > if(errno==EINVAL) > > exit(1); > > } > > > > return NULL; > > } > > > > int main(int argc, char *argv[]) > > { > > pthread_t thr; > > int i; > > > > if(argc!=2){ > > fprintf(stderr, "usage: %s ifname\n", getprogname()); > > return 1; > > } > > > > if(getuid()!=0){ > > fprintf(stderr, "should be root\n"); > > return 1; > > } > > > > memset(&ifr, 0, sizeof(ifr)); > > strlcpy(ifr.ifr_name, argv[1], sizeof(ifr.ifr_name)); > > > > for(i=0; i<8*4; ++i){ > > if(pthread_create(&thr, NULL, clone_create, NULL)!=0) > > errx(1, "pthread_create(clone_create)"); > > } > > > > clone_destroy(NULL); > > > > return 0; > > } > > > > ---- cut end ---- > > > > >