/* These are weird, but module loading must not be done with mutex held (since they will register), and we have to have a single function to use try_then_request_module().  */
struct xt_match* xt_find_match(u8 af, const char *name, u8 revision)
/* These are weird, but module loading must not be done with mutex held (since they will register), and we have to have a single function to use try_then_request_module().  */
struct xt_match* xt_find_match(u8 af, const char *name, u8 revision)
{
	struct xt_match *m;
	int err = 0;
	if (mutex_lock_interruptible(&xt[af].mutex) != 0)
		return ERR_PTR(-EINTR);
	list_for_each_entry(m, &xt[af].match, list) {
		if (strcmp(m->name, name) == 0) {
			if (m->revision == revision) {
				if (try_module_get(m->me)) {
					mutex_unlock(&xt[af].mutex);
					return m;
				}
			} else
				err = -EPROTOTYPE;
		}
	}
	mutex_unlock(&xt[af].mutex);
	if (af != NFPROTO_UNSPEC)
		return xt_find_match(NFPROTO_UNSPEC, name, revision);
	return ERR_PTR(err);
}