Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ struct timeval {
long tv_usec; /* microseconds */
};

unsigned long timeval_to_jiffies(const struct timeval *tv);
unsigned long timeval_to_jiffies(const struct timeval *tv)
{
return timespec64_to_jiffies(&(struct timespec64){
Expand Down Expand Up @@ -383,6 +384,7 @@ static int sockaddr_cmp(const struct sockaddr_storage *sa1, const struct sockadd
#ifndef IN6PTON_XDIGIT
#define hex_to_bin compat_hex_to_bin
/* lib/hexdump.c */
int hex_to_bin(char ch);
int hex_to_bin(char ch)
{
if ((ch >= '0') && (ch <= '9'))
Expand Down Expand Up @@ -713,6 +715,7 @@ static inline void do_gettimeofday(struct timeval *tv)
#endif

#define TOLOWER(x) ((x) | 0x20)
unsigned long long strtoul(const char *cp, char **endp, unsigned int base);
unsigned long long strtoul(const char *cp, char **endp, unsigned int base)
{
unsigned long long result = 0;
Expand Down
2 changes: 1 addition & 1 deletion gen_compat_def
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ kbuild_test_compile() {
echo
else
echo " undeclared" >&2
echo "#undef HAVE_$1"
echo "// ${2:-symbol} is undeclared${3:+ in <$3>}. Compile:"
sed "s/^/\/\/ /" test.c
echo "// Output:"
Expand Down Expand Up @@ -122,6 +121,7 @@ kbuild_test_symbol nf_bridge_info_get linux/netfilter_bridge.h
kbuild_test_struct vlan_dev_priv linux/if_vlan.h
# Kernel version check broken by centos8
kbuild_test_symbol put_unaligned_be24 asm/unaligned.h
kbuild_test_symbol put_unaligned_be24 linux/unaligned.h
# totalram_pages changed from atomic to inline function.
kbuild_test_symbol totalram_pages linux/mm.h
kbuild_test_ref totalram_pages linux/mm.h
Expand Down
76 changes: 76 additions & 0 deletions ipt_NETFLOW.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@
# include <net/netfilter/nf_conntrack_core.h>
#endif
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,12,0)
#include <linux/unaligned.h>
#else
#include <asm/unaligned.h>
#endif
#ifdef HAVE_LLIST
/* llist.h is officially defined since linux 3.1,
* but centos6 have it backported on its 2.6.32.el6 */
Expand Down Expand Up @@ -1519,8 +1523,13 @@ static int switch_promisc(int newpromisc)

#ifdef CONFIG_SYSCTL
/* sysctl /proc/sys/net/netflow */
#ifdef HAVE_REGISTER_SYSCTL_PATHS
static int hsize_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#else
static int hsize_procctl(const ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#endif
{
int ret, hsize;
ctl_table_no_const lctl = *ctl;
Expand All @@ -1536,8 +1545,13 @@ static int hsize_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp
return ret;
}

# ifdef HAVE_REGISTER_SYSCTL_PATHS
static int sndbuf_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#else
static int sndbuf_procctl(const ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#endif
{
int ret;
struct ipt_netflow_sock *usock;
Expand Down Expand Up @@ -1571,8 +1585,13 @@ static int sndbuf_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *fil
}

static void free_templates(void);
# ifdef HAVE_REGISTER_SYSCTL_PATHS
static int destination_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#else
static int destination_procctl(const ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#endif
{
int ret;

Expand All @@ -1588,8 +1607,13 @@ static int destination_procctl(ctl_table *ctl, int write, BEFORE2632(struct file
}

#ifdef ENABLE_AGGR
# ifdef HAVE_REGISTER_SYSCTL_PATHS
static int aggregation_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#else
static int aggregation_procctl(const ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#endif
{
int ret;

Expand All @@ -1603,8 +1627,13 @@ static int aggregation_procctl(ctl_table *ctl, int write, BEFORE2632(struct file
#endif

#ifdef ENABLE_PROMISC
#ifdef HAVE_REGISTER_SYSCTL_PATHS
static int promisc_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#else
static int promisc_procctl(const ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#endif
{
int newpromisc = promisc;
int ret;
Expand All @@ -1620,8 +1649,13 @@ static int promisc_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *fi

#ifdef ENABLE_SAMPLER
static int parse_sampler(char *ptr);
#ifdef HAVE_REGISTER_SYSCTL_PATHS
static int sampler_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#else
static int sampler_procctl(const ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#endif
{
int ret;

Expand Down Expand Up @@ -1653,8 +1687,13 @@ static int sampler_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *fi

#ifdef SNMP_RULES
static int add_snmp_rules(char *ptr);
#ifdef HAVE_REGISTER_SYSCTL_PATHS
static int snmp_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#else
static int snmp_procctl(const ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#endif
{
int ret;

Expand All @@ -1678,8 +1717,13 @@ static void clear_ipt_netflow_stat(void)
}
}

#ifdef HAVE_REGISTER_SYSCTL_PATHS
static int flush_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#else
static int flush_procctl(const ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#endif
{
int ret;
int val = 0;
Expand Down Expand Up @@ -1707,8 +1751,13 @@ static int flush_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp
return ret;
}

#ifdef HAVE_REGISTER_SYSCTL_PATHS
static int protocol_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#else
static int protocol_procctl(const ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#endif
{
int ret;
int ver = protocol;
Expand Down Expand Up @@ -1740,8 +1789,13 @@ static int protocol_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *f
#ifdef CONFIG_NF_NAT_NEEDED
static void register_ct_events(void);
static void unregister_ct_events(void);
#ifdef HAVE_REGISTER_SYSCTL_PATHS
static int natevents_procctl(ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#else
static int natevents_procctl(const ctl_table *ctl, int write, BEFORE2632(struct file *filp,)
void __user *buffer, size_t *lenp, loff_t *fpos)
#endif
{
int ret;
int val = natevents;
Expand Down Expand Up @@ -1905,7 +1959,9 @@ static ctl_table netflow_sysctl_table[] = {
.proc_handler = &natevents_procctl,
},
#endif
# ifdef HAVE_REGISTER_SYSCTL_PATHS
{ }
#endif
};

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
Expand Down Expand Up @@ -4087,7 +4143,11 @@ static int ethtool_drvinfo(unsigned char *ptr, size_t size, struct net_device *d
ops->get_drvinfo(dev, &info);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
else if (dev->dev.parent && dev->dev.parent->driver) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,8,0)
strlcpy(info.driver, dev->dev.parent->driver->name, sizeof(info.driver));
#else
strscpy(info.driver, dev->dev.parent->driver->name, sizeof(info.driver));
#endif
}
#endif
n = scnprintf(ptr, len, "%s", info.driver);
Expand Down Expand Up @@ -5688,7 +5748,11 @@ static int __init ipt_netflow_init(void)
if (!destination)
destination = destination_buf;
if (destination != destination_buf) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,8,0)
strlcpy(destination_buf, destination, sizeof(destination_buf));
#else
strscpy(destination_buf, destination, sizeof(destination_buf));
#endif
destination = destination_buf;
}
if (add_destinations(destination) < 0)
Expand All @@ -5698,7 +5762,11 @@ static int __init ipt_netflow_init(void)
if (!aggregation)
aggregation = aggregation_buf;
if (aggregation != aggregation_buf) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,8,0)
strlcpy(aggregation_buf, aggregation, sizeof(aggregation_buf));
#else
strscpy(aggregation_buf, aggregation, sizeof(aggregation_buf));
#endif
aggregation = aggregation_buf;
}
add_aggregation(aggregation);
Expand All @@ -5708,7 +5776,11 @@ static int __init ipt_netflow_init(void)
if (!sampler)
sampler = sampler_buf;
if (sampler != sampler_buf) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,8,0)
strlcpy(sampler_buf, sampler, sizeof(sampler_buf));
#else
strscpy(sampler_buf, sampler, sizeof(sampler_buf));
#endif
sampler = sampler_buf;
}
parse_sampler(sampler);
Expand All @@ -5725,7 +5797,11 @@ static int __init ipt_netflow_init(void)
if (!snmp_rules)
snmp_rules = snmp_rules_buf;
if (snmp_rules != snmp_rules_buf) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,8,0)
strlcpy(snmp_rules_buf, snmp_rules, sizeof(snmp_rules_buf));
#else
strscpy(snmp_rules_buf, snmp_rules, sizeof(snmp_rules_buf));
#endif
snmp_rules = snmp_rules_buf;
}
add_snmp_rules(snmp_rules);
Expand Down