sbwml 2023-04-28 04:40:05 +08:00
commit e4eab3c1ff
3 changed files with 40 additions and 0 deletions

28
debian/Makefile vendored Normal file
View File

@ -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

View File

@ -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)

View File

@ -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);