* Must be passed a malloc'd structure so we don't explode if the kld is * unloaded, we leak the struct on deallocation to deal with this, but if a * filter is loaded with the same name as a leaked one we re-use the entry. */
| 73 | * filter is loaded with the same name as a leaked one we re-use the entry. |
| 74 | */ |
| 75 | int |
| 76 | accept_filt_add(struct accept_filter *filt) |
| 77 | { |
| 78 | struct accept_filter *p; |
| 79 | |
| 80 | ACCEPT_FILTER_LOCK(); |
| 81 | SLIST_FOREACH(p, &accept_filtlsthd, accf_next) |
| 82 | if (strcmp(p->accf_name, filt->accf_name) == 0) { |
| 83 | if (p->accf_callback != NULL) { |
| 84 | ACCEPT_FILTER_UNLOCK(); |
| 85 | return (EEXIST); |
| 86 | } else { |
| 87 | p->accf_callback = filt->accf_callback; |
| 88 | ACCEPT_FILTER_UNLOCK(); |
| 89 | free(filt, M_ACCF); |
| 90 | return (0); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | if (p == NULL) |
| 95 | SLIST_INSERT_HEAD(&accept_filtlsthd, filt, accf_next); |
| 96 | ACCEPT_FILTER_UNLOCK(); |
| 97 | return (0); |
| 98 | } |
| 99 | |
| 100 | int |
| 101 | accept_filt_del(char *name) |
no test coverage detected