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

Commit 1cd67182 authored by Christoph Hellwig's avatar Christoph Hellwig
Browse files

netfilter/x_tables: switch to proc_create_seq_private



And remove proc boilerplate code.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent fd24de89
Loading
Loading
Loading
Loading
+6 −36
Original line number Diff line number Diff line
@@ -1648,22 +1648,6 @@ static const struct seq_operations xt_match_seq_ops = {
	.show	= xt_match_seq_show,
};

static int xt_match_open(struct inode *inode, struct file *file)
{
	struct nf_mttg_trav *trav;
	trav = __seq_open_private(file, &xt_match_seq_ops, sizeof(*trav));
	if (!trav)
		return -ENOMEM;
	return 0;
}

static const struct file_operations xt_match_ops = {
	.open	 = xt_match_open,
	.read	 = seq_read,
	.llseek	 = seq_lseek,
	.release = seq_release_private,
};

static void *xt_target_seq_start(struct seq_file *seq, loff_t *pos)
{
	return xt_mttg_seq_start(seq, pos, true);
@@ -1698,22 +1682,6 @@ static const struct seq_operations xt_target_seq_ops = {
	.show	= xt_target_seq_show,
};

static int xt_target_open(struct inode *inode, struct file *file)
{
	struct nf_mttg_trav *trav;
	trav = __seq_open_private(file, &xt_target_seq_ops, sizeof(*trav));
	if (!trav)
		return -ENOMEM;
	return 0;
}

static const struct file_operations xt_target_ops = {
	.open	 = xt_target_open,
	.read	 = seq_read,
	.llseek	 = seq_lseek,
	.release = seq_release_private,
};

#define FORMAT_TABLES	"_tables_names"
#define	FORMAT_MATCHES	"_tables_matches"
#define FORMAT_TARGETS 	"_tables_targets"
@@ -1787,7 +1755,8 @@ int xt_proto_init(struct net *net, u_int8_t af)

	strlcpy(buf, xt_prefix[af], sizeof(buf));
	strlcat(buf, FORMAT_MATCHES, sizeof(buf));
	proc = proc_create_data(buf, 0440, net->proc_net, &xt_match_ops,
	proc = proc_create_seq_private(buf, 0440, net->proc_net,
			&xt_match_seq_ops, sizeof(struct nf_mttg_trav),
			(void *)(unsigned long)af);
	if (!proc)
		goto out_remove_tables;
@@ -1796,7 +1765,8 @@ int xt_proto_init(struct net *net, u_int8_t af)

	strlcpy(buf, xt_prefix[af], sizeof(buf));
	strlcat(buf, FORMAT_TARGETS, sizeof(buf));
	proc = proc_create_data(buf, 0440, net->proc_net, &xt_target_ops,
	proc = proc_create_seq_private(buf, 0440, net->proc_net,
			 &xt_target_seq_ops, sizeof(struct nf_mttg_trav),
			 (void *)(unsigned long)af);
	if (!proc)
		goto out_remove_matches;