diff --git a/debian/Makefile b/debian/Makefile new file mode 100644 index 0000000..3f06cde --- /dev/null +++ b/debian/Makefile @@ -0,0 +1,28 @@ +# +# apt update -y +# apt upgrade -y +# apt install --reinstall linux-headers-$(uname -r) -y +# apt install build-essential autoconf autogen libtool pkg-config libgmp3-dev bison flex libreadline-dev git libedit-dev libmnl-dev make dkms -y +# apt autoremove -y +# + +obj-m += nft_fullcone.o + +nft_fullcone-y := ../src/nft_ext_fullcone.o ../src/nf_nat_fullcone.o + +KVERSION = $(shell uname -r) + +all: + make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules + +install: + make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules_install + depmod -A + modprobe nft_fullcone + +uninstall: + rmmod nft_fullcone || echo "Please remove all nft rules with fullcone and run [rmmod nft_fullcone] manually" + rm -f /lib/modules/$(KVERSION)/extra/nft_fullcone.ko && depmod -A + +clean: + make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean diff --git a/src/nf_nat_fullcone.c b/src/nf_nat_fullcone.c index 0757ef9..0b13cbe 100644 --- a/src/nf_nat_fullcone.c +++ b/src/nf_nat_fullcone.c @@ -854,7 +854,11 @@ static uint16_t find_appropriate_port6(struct net *net, const u16 zone, /* for now we do the same thing for both --random and --random-fully */ /* select a random starting point */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) + start = (uint16_t) (get_random_u32() % (u32) range_size); +#else start = (uint16_t) (prandom_u32() % (u32) range_size); +#endif } else { if ((original_port >= min && original_port <= min + range_size - 1) @@ -927,7 +931,11 @@ static uint16_t find_appropriate_port(struct net *net, const u16 zone, /* for now we do the same thing for both --random and --random-fully */ /* select a random starting point */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) + start = (uint16_t) (get_random_u32() % (u32) range_size); +#else start = (uint16_t) (prandom_u32() % (u32) range_size); +#endif } else { if ((original_port >= min && original_port <= min + range_size - 1) diff --git a/src/nft_ext_fullcone.c b/src/nft_ext_fullcone.c index c28947a..96d1feb 100644 --- a/src/nft_ext_fullcone.c +++ b/src/nft_ext_fullcone.c @@ -179,7 +179,11 @@ static int nft_fullcone_init(const struct nft_ctx *ctx, const struct nft_expr *e return err; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0) +static int nft_fullcone_dump(struct sk_buff *skb, const struct nft_expr *expr, bool reset) +#else static int nft_fullcone_dump(struct sk_buff *skb, const struct nft_expr *expr) +#endif { const struct nft_fullcone *priv = nft_expr_priv(expr);