diff options
author | Christoph Hellwig <hch@lst.de> | 2018-04-15 04:36:56 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2018-05-16 01:24:30 -0400 |
commit | 1cd6718272903c72f36ac23a7e72ed4cebf1f8e8 (patch) | |
tree | 53b71609a94437cb542fe4f45464d0f1e14363fe | |
parent | fd24de8904a747830142cc0bf2bb05302c242a7a (diff) |
netfilter/x_tables: switch to proc_create_seq_private
And remove proc boilerplate code.
Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r-- | net/netfilter/x_tables.c | 42 |
1 files changed, 6 insertions, 36 deletions
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index 344dd01a5027..0e314f95a4a3 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c | |||
@@ -1648,22 +1648,6 @@ static const struct seq_operations xt_match_seq_ops = { | |||
1648 | .show = xt_match_seq_show, | 1648 | .show = xt_match_seq_show, |
1649 | }; | 1649 | }; |
1650 | 1650 | ||
1651 | static int xt_match_open(struct inode *inode, struct file *file) | ||
1652 | { | ||
1653 | struct nf_mttg_trav *trav; | ||
1654 | trav = __seq_open_private(file, &xt_match_seq_ops, sizeof(*trav)); | ||
1655 | if (!trav) | ||
1656 | return -ENOMEM; | ||
1657 | return 0; | ||
1658 | } | ||
1659 | |||
1660 | static const struct file_operations xt_match_ops = { | ||
1661 | .open = xt_match_open, | ||
1662 | .read = seq_read, | ||
1663 | .llseek = seq_lseek, | ||
1664 | .release = seq_release_private, | ||
1665 | }; | ||
1666 | |||
1667 | static void *xt_target_seq_start(struct seq_file *seq, loff_t *pos) | 1651 | static void *xt_target_seq_start(struct seq_file *seq, loff_t *pos) |
1668 | { | 1652 | { |
1669 | return xt_mttg_seq_start(seq, pos, true); | 1653 | return xt_mttg_seq_start(seq, pos, true); |
@@ -1698,22 +1682,6 @@ static const struct seq_operations xt_target_seq_ops = { | |||
1698 | .show = xt_target_seq_show, | 1682 | .show = xt_target_seq_show, |
1699 | }; | 1683 | }; |
1700 | 1684 | ||
1701 | static int xt_target_open(struct inode *inode, struct file *file) | ||
1702 | { | ||
1703 | struct nf_mttg_trav *trav; | ||
1704 | trav = __seq_open_private(file, &xt_target_seq_ops, sizeof(*trav)); | ||
1705 | if (!trav) | ||
1706 | return -ENOMEM; | ||
1707 | return 0; | ||
1708 | } | ||
1709 | |||
1710 | static const struct file_operations xt_target_ops = { | ||
1711 | .open = xt_target_open, | ||
1712 | .read = seq_read, | ||
1713 | .llseek = seq_lseek, | ||
1714 | .release = seq_release_private, | ||
1715 | }; | ||
1716 | |||
1717 | #define FORMAT_TABLES "_tables_names" | 1685 | #define FORMAT_TABLES "_tables_names" |
1718 | #define FORMAT_MATCHES "_tables_matches" | 1686 | #define FORMAT_MATCHES "_tables_matches" |
1719 | #define FORMAT_TARGETS "_tables_targets" | 1687 | #define FORMAT_TARGETS "_tables_targets" |
@@ -1787,8 +1755,9 @@ int xt_proto_init(struct net *net, u_int8_t af) | |||
1787 | 1755 | ||
1788 | strlcpy(buf, xt_prefix[af], sizeof(buf)); | 1756 | strlcpy(buf, xt_prefix[af], sizeof(buf)); |
1789 | strlcat(buf, FORMAT_MATCHES, sizeof(buf)); | 1757 | strlcat(buf, FORMAT_MATCHES, sizeof(buf)); |
1790 | proc = proc_create_data(buf, 0440, net->proc_net, &xt_match_ops, | 1758 | proc = proc_create_seq_private(buf, 0440, net->proc_net, |
1791 | (void *)(unsigned long)af); | 1759 | &xt_match_seq_ops, sizeof(struct nf_mttg_trav), |
1760 | (void *)(unsigned long)af); | ||
1792 | if (!proc) | 1761 | if (!proc) |
1793 | goto out_remove_tables; | 1762 | goto out_remove_tables; |
1794 | if (uid_valid(root_uid) && gid_valid(root_gid)) | 1763 | if (uid_valid(root_uid) && gid_valid(root_gid)) |
@@ -1796,8 +1765,9 @@ int xt_proto_init(struct net *net, u_int8_t af) | |||
1796 | 1765 | ||
1797 | strlcpy(buf, xt_prefix[af], sizeof(buf)); | 1766 | strlcpy(buf, xt_prefix[af], sizeof(buf)); |
1798 | strlcat(buf, FORMAT_TARGETS, sizeof(buf)); | 1767 | strlcat(buf, FORMAT_TARGETS, sizeof(buf)); |
1799 | proc = proc_create_data(buf, 0440, net->proc_net, &xt_target_ops, | 1768 | proc = proc_create_seq_private(buf, 0440, net->proc_net, |
1800 | (void *)(unsigned long)af); | 1769 | &xt_target_seq_ops, sizeof(struct nf_mttg_trav), |
1770 | (void *)(unsigned long)af); | ||
1801 | if (!proc) | 1771 | if (!proc) |
1802 | goto out_remove_matches; | 1772 | goto out_remove_matches; |
1803 | if (uid_valid(root_uid) && gid_valid(root_gid)) | 1773 | if (uid_valid(root_uid) && gid_valid(root_gid)) |