pfr_setflags_ktables(&changeq, PFR_TFLAG_ACTIVE, 0);
pfr_setflags_ktables(&changeq);
pfr_add_tables(struct pfr_table *tbl, int size, int *nadd, int flags){	struct pfr_ktableworkq	 addq, changeq;	struct pfr_ktable	*p, *q, key;	int			 i, rv, s, xadd = 0;	long			 tzero = time.tv_sec;	ACCEPT_FLAGS(PFR_FLAG_ATOMIC+PFR_FLAG_DUMMY);	SLIST_INIT(&addq);	SLIST_INIT(&changeq);	for (i = 0; i < size; i++) {		if (copyin(tbl+i, &key.pfrkt_t, sizeof(key.pfrkt_t)))			senderr(EFAULT);		if (pfr_validate_table(&key.pfrkt_t, PFR_TFLAG_USRMASK))			senderr(EINVAL);		key.pfrkt_flags |= PFR_TFLAG_ACTIVE;		p = RB_FIND(pfr_ktablehead, &pfr_ktables, &key);		if (p == NULL) {			p = pfr_create_ktable(&key.pfrkt_t, tzero);			if (p == NULL)				senderr(ENOMEM);			SLIST_FOREACH(q, &addq, pfrkt_workq) {				if (!strcmp(p->pfrkt_name, q->pfrkt_name))					goto _skip;			}			SLIST_INSERT_HEAD(&addq, p, pfrkt_workq);			xadd++;		} else if (!(p->pfrkt_flags & PFR_TFLAG_ACTIVE)) {			SLIST_FOREACH(q, &changeq, pfrkt_workq)				if (!strcmp(key.pfrkt_name, q->pfrkt_name))					goto _skip;			SLIST_INSERT_HEAD(&changeq, p, pfrkt_workq);			xadd++;		}_skip:	}	if (!(flags & PFR_FLAG_DUMMY)) {		if (flags & PFR_FLAG_ATOMIC)			s = splsoftnet();		pfr_insert_ktables(&addq);		pfr_setflags_ktables(&changeq, PFR_TFLAG_ACTIVE, 0);		if (flags & PFR_FLAG_ATOMIC)			splx(s);	} else		 pfr_destroy_ktables(&addq, 0);	if (nadd != NULL)		*nadd = xadd;	return (0);_bad:	pfr_destroy_ktables(&addq, 0);	return (rv);}