[xtables-addons PATCH 1/2] extensions: replace `PDE_DATA`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The `PDE_DATA` function for retrieving private data from a procfs inode
has been replaced by `pde_data` in 5.17.  Replace all instances of the
former with the latter, but add a macro to xtables_compat.h in order to
preserve compatibility with older kernels.

Link: https://lore.kernel.org/lkml/20211124081956.87711-1-songmuchun@xxxxxxxxxxxxx/
Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx>
---
 extensions/compat_xtables.h   | 4 ++++
 extensions/pknock/xt_pknock.c | 2 +-
 extensions/xt_DNETMAP.c       | 6 +++---
 extensions/xt_condition.c     | 4 ++--
 extensions/xt_quota2.c        | 4 ++--
 5 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/extensions/compat_xtables.h b/extensions/compat_xtables.h
index eff3bde91c32..5ea2af6a4a79 100644
--- a/extensions/compat_xtables.h
+++ b/extensions/compat_xtables.h
@@ -27,6 +27,10 @@
 #	define ip6_route_me_harder(xnet, xsk, xskb) ip6_route_me_harder((xnet), (xskb))
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0)
+#define pde_data(inode) PDE_DATA(inode)
+#endif
+
 static inline struct net *par_net(const struct xt_action_param *par)
 {
 	return par->state->net;
diff --git a/extensions/pknock/xt_pknock.c b/extensions/pknock/xt_pknock.c
index 3c304e0b20c7..287d525f27d5 100644
--- a/extensions/pknock/xt_pknock.c
+++ b/extensions/pknock/xt_pknock.c
@@ -277,7 +277,7 @@ pknock_proc_open(struct inode *inode, struct file *file)
 	int ret = seq_open(file, &pknock_seq_ops);
 	if (ret == 0) {
 		struct seq_file *sf = file->private_data;
-		sf->private = PDE_DATA(inode);
+		sf->private = pde_data(inode);
 	}
 	return ret;
 }
diff --git a/extensions/xt_DNETMAP.c b/extensions/xt_DNETMAP.c
index b850918325da..47cf704a2fd5 100644
--- a/extensions/xt_DNETMAP.c
+++ b/extensions/xt_DNETMAP.c
@@ -576,14 +576,14 @@ static int dnetmap_seq_open(struct inode *inode, struct file *file)
 	if (st == NULL)
 		return -ENOMEM;
 
-	st->p = PDE_DATA(inode);
+	st->p = pde_data(inode);
 	return 0;
 }
 
 static ssize_t
 dnetmap_tg_proc_write(struct file *file, const char __user *input,size_t size, loff_t *loff)
 {
-	struct dnetmap_prefix *p = PDE_DATA(file_inode(file));
+	struct dnetmap_prefix *p = pde_data(file_inode(file));
 	struct dnetmap_entry *e;
 	char buf[sizeof("+192.168.100.100:200.200.200.200")];
 	const char *c = buf;
@@ -793,7 +793,7 @@ static int dnetmap_stat_proc_show(struct seq_file *m, void *data)
 
 static int dnetmap_stat_proc_open(struct inode *inode, struct file *file)
 {
-	return single_open(file, dnetmap_stat_proc_show, PDE_DATA(inode));
+	return single_open(file, dnetmap_stat_proc_show, pde_data(inode));
 }
 
 static const struct proc_ops dnetmap_stat_proc_fops = {
diff --git a/extensions/xt_condition.c b/extensions/xt_condition.c
index cf07966e71b7..41639c317e7f 100644
--- a/extensions/xt_condition.c
+++ b/extensions/xt_condition.c
@@ -83,14 +83,14 @@ static int condition_proc_show(struct seq_file *m, void *data)
 
 static int condition_proc_open(struct inode *inode, struct file *file)
 {
-	return single_open(file, condition_proc_show, PDE_DATA(inode));
+	return single_open(file, condition_proc_show, pde_data(inode));
 }
 
 static ssize_t
 condition_proc_write(struct file *file, const char __user *buffer,
                      size_t length, loff_t *loff)
 {
-	struct condition_variable *var = PDE_DATA(file_inode(file));
+	struct condition_variable *var = pde_data(file_inode(file));
 	char newval;
 
 	if (length > 0) {
diff --git a/extensions/xt_quota2.c b/extensions/xt_quota2.c
index 70bf0957e815..182771e26ca0 100644
--- a/extensions/xt_quota2.c
+++ b/extensions/xt_quota2.c
@@ -73,14 +73,14 @@ static int quota_proc_show(struct seq_file *m, void *data)
 
 static int quota_proc_open(struct inode *inode, struct file *file)
 {
-	return single_open(file, quota_proc_show, PDE_DATA(inode));
+	return single_open(file, quota_proc_show, pde_data(inode));
 }
 
 static ssize_t
 quota_proc_write(struct file *file, const char __user *input,
                  size_t size, loff_t *loff)
 {
-	struct xt_quota_counter *e = PDE_DATA(file_inode(file));
+	struct xt_quota_counter *e = pde_data(file_inode(file));
 	char buf[sizeof("+-18446744073709551616")];
 
 	if (size > sizeof(buf))
-- 
2.34.1




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux