compat_get_entries(struct compat_ipt_get_entries __user *uptr, int *len)
{
	int ret;
	struct compat_ipt_get_entries get;
	struct ipt_table *t;


	if (*len < sizeof(get)) {
		duprintf("compat_get_entries: %u < %u\n",
				*len, (unsigned int)sizeof(get));
		return -EINVAL;
	}

	if (copy_from_user(&get, uptr, sizeof(get)) != 0)
		return -EFAULT;

	if (*len != sizeof(struct compat_ipt_get_entries) + get.size) {
		duprintf("compat_get_entries: %u != %u\n", *len,
			(unsigned int)(sizeof(struct compat_ipt_get_entries) +
			get.size));
		return -EINVAL;
	}

	xt_compat_lock(AF_INET);
	t = xt_find_table_lock(AF_INET, get.name);
	if (t && !IS_ERR(t)) {
		struct xt_table_info *private = t->private;
		struct xt_table_info info;
		duprintf("t->private->number = %u\n",
			 private->number);
		ret = compat_table_info(private, &info);
		if (!ret && get.size == info.size) {
			ret = compat_copy_entries_to_user(private->size,
						   t, uptr->entrytable);
		} else if (!ret) {
			duprintf("compat_get_entries: I've got %u not %u!\n",
				 private->size,
				 get.size);
			ret = -EINVAL;
		}
		compat_flush_offsets();
		module_put(t->me);
		xt_table_unlock(t);
	} else
		ret = t ? PTR_ERR(t) : -ENOENT;

	xt_compat_unlock(AF_INET);
	return ret;
}
compat_get_entries(struct compat_ipt_get_entries __user *uptr, int *len)
{
	int ret;
	struct compat_ipt_get_entries get;
	struct ipt_table *t;


	if (*len < sizeof(get)) {
		duprintf("compat_get_entries: %u < %u\n",
				*len, (unsigned int)sizeof(get));
		return -EINVAL;
	}

	if (copy_from_user(&get, uptr, sizeof(get)) != 0)
		return -EFAULT;

	if (*len != sizeof(struct compat_ipt_get_entries) + get.size) {
		duprintf("compat_get_entries: %u != %u\n", *len,
			(unsigned int)(sizeof(struct compat_ipt_get_entries) +
			get.size));
		return -EINVAL;
	}

	xt_compat_lock(AF_INET);
	t = xt_find_table_lock(AF_INET, get.name);
	if (t && !IS_ERR(t)) {
		struct xt_table_info *private = t->private;
		struct xt_table_info info;
		duprintf("t->private->number = %u\n",
			 private->number);
		ret = compat_table_info(private, &info);
		if (!ret && get.size == info.size) {
			ret = compat_copy_entries_to_user(private->size,
						   t, uptr->entrytable);
		} else if (!ret) {
			duprintf("compat_get_entries: I've got %u not %u!\n",
				 private->size,
				 get.size);
			ret = -EINVAL;
		}
		compat_flush_offsets();
		module_put(t->me);
		xt_table_unlock(t);
	} else
		ret = t ? PTR_ERR(t) : -ENOENT;

	xt_compat_unlock(AF_INET);
	return ret;
}