Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee999d8b authored by Jan Engelhardt's avatar Jan Engelhardt Committed by Patrick McHardy
Browse files

netfilter: x_tables: use NFPROTO_* in extensions

parent 7e9c6eeb
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -206,10 +206,10 @@ static void ebt_log(const struct sk_buff *skb, unsigned int hooknr,
	li.u.log.logflags = info->bitmask;

	if (info->bitmask & EBT_LOG_NFLOG)
		nf_log_packet(PF_BRIDGE, hooknr, skb, in, out, &li,
		nf_log_packet(NFPROTO_BRIDGE, hooknr, skb, in, out, &li,
			      "%s", info->prefix);
	else
		ebt_log_packet(PF_BRIDGE, hooknr, skb, in, out, &li,
		ebt_log_packet(NFPROTO_BRIDGE, hooknr, skb, in, out, &li,
			       info->prefix);
}

@@ -234,7 +234,7 @@ static int __init ebt_log_init(void)
	ret = ebt_register_watcher(&log);
	if (ret < 0)
		return ret;
	nf_log_register(PF_BRIDGE, &ebt_log_logger);
	nf_log_register(NFPROTO_BRIDGE, &ebt_log_logger);
	return 0;
}

+1 −1
Original line number Diff line number Diff line
@@ -310,7 +310,7 @@ static int __init ebt_ulog_init(void)
		netlink_kernel_release(ebtulognl);

	if (ret == 0)
		nf_log_register(PF_BRIDGE, &ebt_ulog_logger);
		nf_log_register(NFPROTO_BRIDGE, &ebt_ulog_logger);

	return ret;
}
+30 −28
Original line number Diff line number Diff line
@@ -463,7 +463,8 @@ static inline int check_target(struct arpt_entry *e, const char *name)
	t = arpt_get_target(e);
	target = t->u.kernel.target;

	ret = xt_check_target(target, NF_ARP, t->u.target_size - sizeof(*t),
	ret = xt_check_target(target, NFPROTO_ARP,
			      t->u.target_size - sizeof(*t),
			      name, e->comefrom, 0, 0);
	if (!ret && t->u.kernel.target->checkentry
	    && !t->u.kernel.target->checkentry(name, e, target, t->data,
@@ -488,7 +489,8 @@ find_check_entry(struct arpt_entry *e, const char *name, unsigned int size,
		return ret;

	t = arpt_get_target(e);
	target = try_then_request_module(xt_find_target(NF_ARP, t->u.user.name,
	target = try_then_request_module(xt_find_target(NFPROTO_ARP,
							t->u.user.name,
							t->u.user.revision),
					 "arpt_%s", t->u.user.name);
	if (IS_ERR(target) || !target) {
@@ -788,7 +790,7 @@ static void compat_standard_from_user(void *dst, void *src)
	int v = *(compat_int_t *)src;

	if (v > 0)
		v += xt_compat_calc_jump(NF_ARP, v);
		v += xt_compat_calc_jump(NFPROTO_ARP, v);
	memcpy(dst, &v, sizeof(v));
}

@@ -797,7 +799,7 @@ static int compat_standard_to_user(void __user *dst, void *src)
	compat_int_t cv = *(int *)src;

	if (cv > 0)
		cv -= xt_compat_calc_jump(NF_ARP, cv);
		cv -= xt_compat_calc_jump(NFPROTO_ARP, cv);
	return copy_to_user(dst, &cv, sizeof(cv)) ? -EFAULT : 0;
}

@@ -815,7 +817,7 @@ static int compat_calc_entry(struct arpt_entry *e,
	t = arpt_get_target(e);
	off += xt_compat_target_offset(t->u.kernel.target);
	newinfo->size -= off;
	ret = xt_compat_add_offset(NF_ARP, entry_offset, off);
	ret = xt_compat_add_offset(NFPROTO_ARP, entry_offset, off);
	if (ret)
		return ret;

@@ -866,9 +868,9 @@ static int get_info(struct net *net, void __user *user, int *len, int compat)
	name[ARPT_TABLE_MAXNAMELEN-1] = '\0';
#ifdef CONFIG_COMPAT
	if (compat)
		xt_compat_lock(NF_ARP);
		xt_compat_lock(NFPROTO_ARP);
#endif
	t = try_then_request_module(xt_find_table_lock(net, NF_ARP, name),
	t = try_then_request_module(xt_find_table_lock(net, NFPROTO_ARP, name),
				    "arptable_%s", name);
	if (t && !IS_ERR(t)) {
		struct arpt_getinfo info;
@@ -878,7 +880,7 @@ static int get_info(struct net *net, void __user *user, int *len, int compat)
		if (compat) {
			struct xt_table_info tmp;
			ret = compat_table_info(private, &tmp);
			xt_compat_flush_offsets(NF_ARP);
			xt_compat_flush_offsets(NFPROTO_ARP);
			private = &tmp;
		}
#endif
@@ -901,7 +903,7 @@ static int get_info(struct net *net, void __user *user, int *len, int compat)
		ret = t ? PTR_ERR(t) : -ENOENT;
#ifdef CONFIG_COMPAT
	if (compat)
		xt_compat_unlock(NF_ARP);
		xt_compat_unlock(NFPROTO_ARP);
#endif
	return ret;
}
@@ -925,7 +927,7 @@ static int get_entries(struct net *net, struct arpt_get_entries __user *uptr,
		return -EINVAL;
	}

	t = xt_find_table_lock(net, NF_ARP, get.name);
	t = xt_find_table_lock(net, NFPROTO_ARP, get.name);
	if (t && !IS_ERR(t)) {
		const struct xt_table_info *private = t->private;

@@ -967,7 +969,7 @@ static int __do_replace(struct net *net, const char *name,
		goto out;
	}

	t = try_then_request_module(xt_find_table_lock(net, NF_ARP, name),
	t = try_then_request_module(xt_find_table_lock(net, NFPROTO_ARP, name),
				    "arptable_%s", name);
	if (!t || IS_ERR(t)) {
		ret = t ? PTR_ERR(t) : -ENOENT;
@@ -1134,7 +1136,7 @@ static int do_add_counters(struct net *net, void __user *user, unsigned int len,
		goto free;
	}

	t = xt_find_table_lock(net, NF_ARP, name);
	t = xt_find_table_lock(net, NFPROTO_ARP, name);
	if (!t || IS_ERR(t)) {
		ret = t ? PTR_ERR(t) : -ENOENT;
		goto free;
@@ -1218,7 +1220,7 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e,
	entry_offset = (void *)e - (void *)base;

	t = compat_arpt_get_target(e);
	target = try_then_request_module(xt_find_target(NF_ARP,
	target = try_then_request_module(xt_find_target(NFPROTO_ARP,
							t->u.user.name,
							t->u.user.revision),
					 "arpt_%s", t->u.user.name);
@@ -1232,7 +1234,7 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e,

	off += xt_compat_target_offset(target);
	*size += off;
	ret = xt_compat_add_offset(NF_ARP, entry_offset, off);
	ret = xt_compat_add_offset(NFPROTO_ARP, entry_offset, off);
	if (ret)
		goto release_target;

@@ -1333,7 +1335,7 @@ static int translate_compat_table(const char *name,

	duprintf("translate_compat_table: size %u\n", info->size);
	j = 0;
	xt_compat_lock(NF_ARP);
	xt_compat_lock(NFPROTO_ARP);
	/* Walk through entries, checking offsets. */
	ret = COMPAT_ARPT_ENTRY_ITERATE(entry0, total_size,
					check_compat_entry_size_and_hooks,
@@ -1383,8 +1385,8 @@ static int translate_compat_table(const char *name,
	ret = COMPAT_ARPT_ENTRY_ITERATE(entry0, total_size,
					compat_copy_entry_from_user,
					&pos, &size, name, newinfo, entry1);
	xt_compat_flush_offsets(NF_ARP);
	xt_compat_unlock(NF_ARP);
	xt_compat_flush_offsets(NFPROTO_ARP);
	xt_compat_unlock(NFPROTO_ARP);
	if (ret)
		goto free_newinfo;

@@ -1420,8 +1422,8 @@ static int translate_compat_table(const char *name,
	COMPAT_ARPT_ENTRY_ITERATE(entry0, total_size, compat_release_entry, &j);
	return ret;
out_unlock:
	xt_compat_flush_offsets(NF_ARP);
	xt_compat_unlock(NF_ARP);
	xt_compat_flush_offsets(NFPROTO_ARP);
	xt_compat_unlock(NFPROTO_ARP);
	goto out;
}

@@ -1607,8 +1609,8 @@ static int compat_get_entries(struct net *net,
		return -EINVAL;
	}

	xt_compat_lock(NF_ARP);
	t = xt_find_table_lock(net, NF_ARP, get.name);
	xt_compat_lock(NFPROTO_ARP);
	t = xt_find_table_lock(net, NFPROTO_ARP, get.name);
	if (t && !IS_ERR(t)) {
		const struct xt_table_info *private = t->private;
		struct xt_table_info info;
@@ -1623,13 +1625,13 @@ static int compat_get_entries(struct net *net,
				 private->size, get.size);
			ret = -EAGAIN;
		}
		xt_compat_flush_offsets(NF_ARP);
		xt_compat_flush_offsets(NFPROTO_ARP);
		module_put(t->me);
		xt_table_unlock(t);
	} else
		ret = t ? PTR_ERR(t) : -ENOENT;

	xt_compat_unlock(NF_ARP);
	xt_compat_unlock(NFPROTO_ARP);
	return ret;
}

@@ -1709,7 +1711,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
			break;
		}

		try_then_request_module(xt_find_revision(NF_ARP, rev.name,
		try_then_request_module(xt_find_revision(NFPROTO_ARP, rev.name,
							 rev.revision, 1, &ret),
					"arpt_%s", rev.name);
		break;
@@ -1787,7 +1789,7 @@ void arpt_unregister_table(struct xt_table *table)
static struct xt_target arpt_standard_target __read_mostly = {
	.name		= ARPT_STANDARD_TARGET,
	.targetsize	= sizeof(int),
	.family		= NF_ARP,
	.family		= NFPROTO_ARP,
#ifdef CONFIG_COMPAT
	.compatsize	= sizeof(compat_int_t),
	.compat_from_user = compat_standard_from_user,
@@ -1799,7 +1801,7 @@ static struct xt_target arpt_error_target __read_mostly = {
	.name		= ARPT_ERROR_TARGET,
	.target		= arpt_error,
	.targetsize	= ARPT_FUNCTION_MAXNAMELEN,
	.family		= NF_ARP,
	.family		= NFPROTO_ARP,
};

static struct nf_sockopt_ops arpt_sockopts = {
@@ -1821,12 +1823,12 @@ static struct nf_sockopt_ops arpt_sockopts = {

static int __net_init arp_tables_net_init(struct net *net)
{
	return xt_proto_init(net, NF_ARP);
	return xt_proto_init(net, NFPROTO_ARP);
}

static void __net_exit arp_tables_net_exit(struct net *net)
{
	xt_proto_fini(net, NF_ARP);
	xt_proto_fini(net, NFPROTO_ARP);
}

static struct pernet_operations arp_tables_net_ops = {
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ checkentry(const char *tablename, const void *e, const struct xt_target *target,

static struct xt_target arpt_mangle_reg __read_mostly = {
	.name		= "mangle",
	.family		= NF_ARP,
	.family		= NFPROTO_ARP,
	.target		= target,
	.targetsize	= sizeof(struct arpt_mangle),
	.checkentry	= checkentry,
+4 −4
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ static struct xt_table packet_filter = {
	.lock		= __RW_LOCK_UNLOCKED(packet_filter.lock),
	.private	= NULL,
	.me		= THIS_MODULE,
	.af		= NF_ARP,
	.af		= NFPROTO_ARP,
};

/* The work comes in here from netfilter.c */
@@ -89,21 +89,21 @@ static struct nf_hook_ops arpt_ops[] __read_mostly = {
	{
		.hook		= arpt_in_hook,
		.owner		= THIS_MODULE,
		.pf		= NF_ARP,
		.pf		= NFPROTO_ARP,
		.hooknum	= NF_ARP_IN,
		.priority	= NF_IP_PRI_FILTER,
	},
	{
		.hook		= arpt_out_hook,
		.owner		= THIS_MODULE,
		.pf		= NF_ARP,
		.pf		= NFPROTO_ARP,
		.hooknum	= NF_ARP_OUT,
		.priority	= NF_IP_PRI_FILTER,
	},
	{
		.hook		= arpt_forward_hook,
		.owner		= THIS_MODULE,
		.pf		= NF_ARP,
		.pf		= NFPROTO_ARP,
		.hooknum	= NF_ARP_FORWARD,
		.priority	= NF_IP_PRI_FILTER,
	},
Loading