mirror of
https://github.com/lgcosta/pf-linux-port.git
synced 2026-11-13 16:48:03 -03:00
M1: pf.c compiles into pf.ko
This commit is contained in:
1 parent
1fcd7b3046
commit
0119e70960
54 files changed
+14853
-96
No files matched your search
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1811,6 +1811,9 @@ deps_pfsrc/pf_if.o := \
|
||||
include/compat/net/if_types.h \
|
||||
include/compat/net/if_var.h \
|
||||
include/compat/net/ifq.h \
|
||||
include/compat/net/rtable.h \
|
||||
include/compat/sys/percpu.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/pfk_mbuf.h \
|
||||
include/pfk_net.h \
|
||||
include/pfk_if.h \
|
||||
@@ -1820,13 +1823,11 @@ deps_pfsrc/pf_if.o := \
|
||||
include/compat/net/toeplitz.h \
|
||||
include/net/pfvar.h \
|
||||
include/compat/sys/syslimits.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/compat/net/radix.h \
|
||||
include/net/pfvar_priv.h \
|
||||
include/compat/sys/rwlock.h \
|
||||
include/compat/sys/mutex.h \
|
||||
include/compat/sys/pclock.h \
|
||||
include/compat/sys/percpu.h \
|
||||
|
||||
pfsrc/pf_if.o: $(deps_pfsrc/pf_if.o)
|
||||
|
||||
|
||||
@@ -1811,6 +1811,9 @@ deps_pfsrc/pf_ioctl.o := \
|
||||
include/compat/net/if_types.h \
|
||||
include/compat/net/if_var.h \
|
||||
include/compat/net/ifq.h \
|
||||
include/compat/net/rtable.h \
|
||||
include/compat/sys/percpu.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/pfk_mbuf.h \
|
||||
include/pfk_net.h \
|
||||
include/pfk_if.h \
|
||||
@@ -1820,13 +1823,11 @@ deps_pfsrc/pf_ioctl.o := \
|
||||
include/compat/net/toeplitz.h \
|
||||
include/net/pfvar.h \
|
||||
include/compat/sys/syslimits.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/compat/net/radix.h \
|
||||
include/net/pfvar_priv.h \
|
||||
include/compat/sys/rwlock.h \
|
||||
include/compat/sys/mutex.h \
|
||||
include/compat/sys/pclock.h \
|
||||
include/compat/sys/percpu.h \
|
||||
|
||||
pfsrc/pf_ioctl.o: $(deps_pfsrc/pf_ioctl.o)
|
||||
|
||||
|
||||
@@ -1811,6 +1811,9 @@ deps_pfsrc/pf_lb.o := \
|
||||
include/compat/net/if_types.h \
|
||||
include/compat/net/if_var.h \
|
||||
include/compat/net/ifq.h \
|
||||
include/compat/net/rtable.h \
|
||||
include/compat/sys/percpu.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/pfk_mbuf.h \
|
||||
include/pfk_net.h \
|
||||
include/pfk_if.h \
|
||||
@@ -1820,13 +1823,11 @@ deps_pfsrc/pf_lb.o := \
|
||||
include/compat/net/toeplitz.h \
|
||||
include/net/pfvar.h \
|
||||
include/compat/sys/syslimits.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/compat/net/radix.h \
|
||||
include/net/pfvar_priv.h \
|
||||
include/compat/sys/rwlock.h \
|
||||
include/compat/sys/mutex.h \
|
||||
include/compat/sys/pclock.h \
|
||||
include/compat/sys/percpu.h \
|
||||
|
||||
pfsrc/pf_lb.o: $(deps_pfsrc/pf_lb.o)
|
||||
|
||||
|
||||
@@ -1811,6 +1811,9 @@ deps_pfsrc/pf_norm.o := \
|
||||
include/compat/net/if_types.h \
|
||||
include/compat/net/if_var.h \
|
||||
include/compat/net/ifq.h \
|
||||
include/compat/net/rtable.h \
|
||||
include/compat/sys/percpu.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/pfk_mbuf.h \
|
||||
include/pfk_net.h \
|
||||
include/pfk_if.h \
|
||||
@@ -1820,13 +1823,11 @@ deps_pfsrc/pf_norm.o := \
|
||||
include/compat/net/toeplitz.h \
|
||||
include/net/pfvar.h \
|
||||
include/compat/sys/syslimits.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/compat/net/radix.h \
|
||||
include/net/pfvar_priv.h \
|
||||
include/compat/sys/rwlock.h \
|
||||
include/compat/sys/mutex.h \
|
||||
include/compat/sys/pclock.h \
|
||||
include/compat/sys/percpu.h \
|
||||
|
||||
pfsrc/pf_norm.o: $(deps_pfsrc/pf_norm.o)
|
||||
|
||||
|
||||
@@ -1811,6 +1811,9 @@ deps_pfsrc/pf_osfp.o := \
|
||||
include/compat/net/if_types.h \
|
||||
include/compat/net/if_var.h \
|
||||
include/compat/net/ifq.h \
|
||||
include/compat/net/rtable.h \
|
||||
include/compat/sys/percpu.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/pfk_mbuf.h \
|
||||
include/pfk_net.h \
|
||||
include/pfk_if.h \
|
||||
@@ -1820,13 +1823,11 @@ deps_pfsrc/pf_osfp.o := \
|
||||
include/compat/net/toeplitz.h \
|
||||
include/net/pfvar.h \
|
||||
include/compat/sys/syslimits.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/compat/net/radix.h \
|
||||
include/net/pfvar_priv.h \
|
||||
include/compat/sys/rwlock.h \
|
||||
include/compat/sys/mutex.h \
|
||||
include/compat/sys/pclock.h \
|
||||
include/compat/sys/percpu.h \
|
||||
|
||||
pfsrc/pf_osfp.o: $(deps_pfsrc/pf_osfp.o)
|
||||
|
||||
|
||||
@@ -1811,6 +1811,9 @@ deps_pfsrc/pf_ruleset.o := \
|
||||
include/compat/net/if_types.h \
|
||||
include/compat/net/if_var.h \
|
||||
include/compat/net/ifq.h \
|
||||
include/compat/net/rtable.h \
|
||||
include/compat/sys/percpu.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/pfk_mbuf.h \
|
||||
include/pfk_net.h \
|
||||
include/pfk_if.h \
|
||||
@@ -1820,13 +1823,11 @@ deps_pfsrc/pf_ruleset.o := \
|
||||
include/compat/net/toeplitz.h \
|
||||
include/net/pfvar.h \
|
||||
include/compat/sys/syslimits.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/compat/net/radix.h \
|
||||
include/net/pfvar_priv.h \
|
||||
include/compat/sys/rwlock.h \
|
||||
include/compat/sys/mutex.h \
|
||||
include/compat/sys/pclock.h \
|
||||
include/compat/sys/percpu.h \
|
||||
|
||||
pfsrc/pf_ruleset.o: $(deps_pfsrc/pf_ruleset.o)
|
||||
|
||||
|
||||
@@ -1811,6 +1811,9 @@ deps_pfsrc/pf_syncookies.o := \
|
||||
include/compat/net/if_types.h \
|
||||
include/compat/net/if_var.h \
|
||||
include/compat/net/ifq.h \
|
||||
include/compat/net/rtable.h \
|
||||
include/compat/sys/percpu.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/pfk_mbuf.h \
|
||||
include/pfk_net.h \
|
||||
include/pfk_if.h \
|
||||
@@ -1820,13 +1823,11 @@ deps_pfsrc/pf_syncookies.o := \
|
||||
include/compat/net/toeplitz.h \
|
||||
include/net/pfvar.h \
|
||||
include/compat/sys/syslimits.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/compat/net/radix.h \
|
||||
include/net/pfvar_priv.h \
|
||||
include/compat/sys/rwlock.h \
|
||||
include/compat/sys/mutex.h \
|
||||
include/compat/sys/pclock.h \
|
||||
include/compat/sys/percpu.h \
|
||||
|
||||
pfsrc/pf_syncookies.o: $(deps_pfsrc/pf_syncookies.o)
|
||||
|
||||
|
||||
@@ -1811,6 +1811,9 @@ deps_pfsrc/pf_table.o := \
|
||||
include/compat/net/if_types.h \
|
||||
include/compat/net/if_var.h \
|
||||
include/compat/net/ifq.h \
|
||||
include/compat/net/rtable.h \
|
||||
include/compat/sys/percpu.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/pfk_mbuf.h \
|
||||
include/pfk_net.h \
|
||||
include/pfk_if.h \
|
||||
@@ -1820,13 +1823,11 @@ deps_pfsrc/pf_table.o := \
|
||||
include/compat/net/toeplitz.h \
|
||||
include/net/pfvar.h \
|
||||
include/compat/sys/syslimits.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/compat/net/radix.h \
|
||||
include/net/pfvar_priv.h \
|
||||
include/compat/sys/rwlock.h \
|
||||
include/compat/sys/mutex.h \
|
||||
include/compat/sys/pclock.h \
|
||||
include/compat/sys/percpu.h \
|
||||
|
||||
pfsrc/pf_table.o: $(deps_pfsrc/pf_table.o)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
savedcmd_pfsrc/pfk_hooks.o := gcc -Wp,-MMD,pfsrc/.pfk_hooks.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -Wno-declaration-after-statement -DMODULE -DKBUILD_BASENAME='"pfk_hooks"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o pfsrc/pfk_hooks.o pfsrc/pfk_hooks.c
|
||||
savedcmd_pfsrc/pfk_hooks.o := gcc -Wp,-MMD,pfsrc/.pfk_hooks.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -D_KERNEL=1 -Wno-declaration-after-statement -Wno-implicit-fallthrough -Wno-frame-larger-than -DMODULE -DKBUILD_BASENAME='"pfk_hooks"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o pfsrc/pfk_hooks.o pfsrc/pfk_hooks.c
|
||||
|
||||
source_pfsrc/pfk_hooks.o := pfsrc/pfk_hooks.c
|
||||
|
||||
@@ -1108,6 +1108,11 @@ deps_pfsrc/pfk_hooks.o := \
|
||||
$(wildcard include/config/UNWINDER_ORC) \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/module.h \
|
||||
$(wildcard include/config/HAVE_MOD_ARCH_SPECIFIC) \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
|
||||
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
|
||||
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/prandom.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/once.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/net.h \
|
||||
@@ -1153,7 +1158,6 @@ deps_pfsrc/pfk_hooks.o := \
|
||||
$(wildcard include/config/ARCH_HAS_HW_PTE_YOUNG) \
|
||||
$(wildcard include/config/GUP_GET_PXX_LOW_HIGH) \
|
||||
$(wildcard include/config/ARCH_WANT_PMD_MKWRITE) \
|
||||
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
|
||||
$(wildcard include/config/X86_ESPFIX64) \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/memremap.h \
|
||||
$(wildcard include/config/DEVICE_PRIVATE) \
|
||||
@@ -1754,10 +1758,6 @@ deps_pfsrc/pfk_hooks.o := \
|
||||
$(wildcard include/config/HAVE_ARCH_BITREVERSE) \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/bitops/__bitrev.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/if_vlan.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
|
||||
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/sch_generic.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/gen_stats.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/gen_stats.h \
|
||||
@@ -1810,6 +1810,10 @@ deps_pfsrc/pfk_hooks.o := \
|
||||
include/compat/sys/socket.h \
|
||||
include/compat/net/if_types.h \
|
||||
include/compat/net/if_var.h \
|
||||
include/compat/net/ifq.h \
|
||||
include/compat/net/rtable.h \
|
||||
include/compat/sys/percpu.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/pfk_mbuf.h \
|
||||
include/pfk_net.h \
|
||||
include/pfk_if.h \
|
||||
@@ -1817,12 +1821,14 @@ deps_pfsrc/pfk_hooks.o := \
|
||||
include/compat/crypto/md5.h \
|
||||
include/compat/crypto/siphash.h \
|
||||
include/compat/net/toeplitz.h \
|
||||
include/pfk_api.h \
|
||||
include/net/pfvar.h \
|
||||
include/compat/sys/syslimits.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/compat/net/radix.h \
|
||||
include/net/pfvar_priv.h \
|
||||
include/compat/sys/rwlock.h \
|
||||
include/compat/sys/mutex.h \
|
||||
include/compat/sys/pclock.h \
|
||||
include/pfk_api.h \
|
||||
|
||||
pfsrc/pfk_hooks.o: $(deps_pfsrc/pfk_hooks.o)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
savedcmd_pfsrc/pfk_mod.o := gcc -Wp,-MMD,pfsrc/.pfk_mod.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -Wno-declaration-after-statement -DMODULE -DKBUILD_BASENAME='"pfk_mod"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o pfsrc/pfk_mod.o pfsrc/pfk_mod.c
|
||||
savedcmd_pfsrc/pfk_mod.o := gcc -Wp,-MMD,pfsrc/.pfk_mod.o.d -nostdinc -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/generated/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi -I/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/generated/uapi -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler-version.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/kconfig.h -include /home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/compiler_types.h -D__KERNEL__ -Werror -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -std=gnu11 -fms-extensions -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mno-sse4a -fcf-protection=branch -fno-jump-tables -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=x86-64 -mtune=generic -mno-red-zone -mcmodel=kernel -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__ref_stack_chk_guard -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -fomit-frame-pointer -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -fdiagnostics-show-context=2 -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-type-limits -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -I././include -I././include/compat -DPFLINUX=1 -D_KERNEL=1 -Wno-declaration-after-statement -Wno-implicit-fallthrough -Wno-frame-larger-than -DMODULE -DKBUILD_BASENAME='"pfk_mod"' -DKBUILD_MODNAME='"pf"' -D__KBUILD_MODNAME=pf -c -o pfsrc/pfk_mod.o pfsrc/pfk_mod.c
|
||||
|
||||
source_pfsrc/pfk_mod.o := pfsrc/pfk_mod.c
|
||||
|
||||
@@ -1108,6 +1108,11 @@ deps_pfsrc/pfk_mod.o := \
|
||||
$(wildcard include/config/UNWINDER_ORC) \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/module.h \
|
||||
$(wildcard include/config/HAVE_MOD_ARCH_SPECIFIC) \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
|
||||
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
|
||||
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/prandom.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/once.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/net.h \
|
||||
@@ -1153,7 +1158,6 @@ deps_pfsrc/pfk_mod.o := \
|
||||
$(wildcard include/config/ARCH_HAS_HW_PTE_YOUNG) \
|
||||
$(wildcard include/config/GUP_GET_PXX_LOW_HIGH) \
|
||||
$(wildcard include/config/ARCH_WANT_PMD_MKWRITE) \
|
||||
$(wildcard include/config/HAVE_ARCH_HUGE_VMAP) \
|
||||
$(wildcard include/config/X86_ESPFIX64) \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/memremap.h \
|
||||
$(wildcard include/config/DEVICE_PRIVATE) \
|
||||
@@ -1754,10 +1758,6 @@ deps_pfsrc/pfk_mod.o := \
|
||||
$(wildcard include/config/HAVE_ARCH_BITREVERSE) \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/asm-generic/bitops/__bitrev.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/if_vlan.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/linux/vmalloc.h \
|
||||
$(wildcard include/config/HAVE_ARCH_HUGE_VMALLOC) \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/vmalloc.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/arch/x86/include/asm/pgtable_areas.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/sch_generic.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/net/gen_stats.h \
|
||||
/home/lgcosta/lab/linux_kernel/linux-7.3.4/include/uapi/linux/gen_stats.h \
|
||||
@@ -1810,6 +1810,10 @@ deps_pfsrc/pfk_mod.o := \
|
||||
include/compat/sys/socket.h \
|
||||
include/compat/net/if_types.h \
|
||||
include/compat/net/if_var.h \
|
||||
include/compat/net/ifq.h \
|
||||
include/compat/net/rtable.h \
|
||||
include/compat/sys/percpu.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/pfk_mbuf.h \
|
||||
include/pfk_net.h \
|
||||
include/pfk_if.h \
|
||||
@@ -1817,12 +1821,14 @@ deps_pfsrc/pfk_mod.o := \
|
||||
include/compat/crypto/md5.h \
|
||||
include/compat/crypto/siphash.h \
|
||||
include/compat/net/toeplitz.h \
|
||||
include/pfk_api.h \
|
||||
include/net/pfvar.h \
|
||||
include/compat/sys/syslimits.h \
|
||||
include/compat/netinet/in.h \
|
||||
include/compat/net/radix.h \
|
||||
include/net/pfvar_priv.h \
|
||||
include/compat/sys/rwlock.h \
|
||||
include/compat/sys/mutex.h \
|
||||
include/compat/sys/pclock.h \
|
||||
include/pfk_api.h \
|
||||
|
||||
pfsrc/pfk_mod.o: $(deps_pfsrc/pfk_mod.o)
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* PF-on-Linux divert entry points used by pf.c (ISC 2026).
|
||||
*
|
||||
* BSD semantics (OpenBSD netinet/ip_divert.c): divert_packet()/divert6_packet()
|
||||
* find the AF_DIVERT pcb bound to `divert_port`, queue the packet to it and
|
||||
* consume the mbuf; when NO divert socket is attached, OpenBSD drops the
|
||||
* packet (m_freem) — that is exactly the observable behaviour implemented
|
||||
* here until the pfdiv socket layer is instantiated for Linux (milestone
|
||||
* M6); a rate-limited kernel log records the event so drops are never
|
||||
* silent.
|
||||
*
|
||||
* The upstream BSD socket layer is staged in pfsrc/ip_divert.c and becomes
|
||||
* the real back end in M6; these wrappers keep the same call signature
|
||||
* (struct mbuf *, int dir, u_int16_t divert_port).
|
||||
*/
|
||||
#include <pfk.h>
|
||||
#include <net/pfvar.h>
|
||||
|
||||
void
|
||||
divert_packet(struct mbuf *m, int dir, u_int16_t divert_port)
|
||||
{
|
||||
pr_warn_ratelimited("pfk: divert v4 port %u: no divert socket layer (M6 pending), dropping\n",
|
||||
ntohs(divert_port));
|
||||
m_freem(m);
|
||||
}
|
||||
|
||||
void
|
||||
divert6_packet(struct mbuf *m, int dir, u_int16_t divert_port)
|
||||
{
|
||||
pr_warn_ratelimited("pfk: divert v6 port %u: no divert socket layer (M6 pending), dropping\n",
|
||||
ntohs(divert_port));
|
||||
m_freem(m);
|
||||
}
|
||||
+14
-14
@@ -152,7 +152,7 @@ static __inline int pf_create_state(struct pf_pdesc *, struct pf_rule *,
|
||||
struct pf_state_key **, struct pf_state_key **,
|
||||
int *, struct pf_state **, int,
|
||||
struct pf_rule_slist *, struct pf_rule_actions *,
|
||||
struct pf_src_node **, struct pf_test_ctx *);
|
||||
struct pf_src_node *[PF_SN_MAX], struct pf_test_ctx *);
|
||||
static __inline int pf_state_key_addr_setup(struct pf_pdesc *, void *,
|
||||
int, struct pf_addr *, int, struct pf_addr *,
|
||||
int, int);
|
||||
@@ -4315,7 +4315,7 @@ pf_calc_mss(struct pf_addr *addr, sa_family_t af, int rtableid, uint16_t offer,
|
||||
hlen = sizeof(struct pf_ip);
|
||||
dst = (struct sockaddr_in *)&ss;
|
||||
dst->sin_family = AF_INET;
|
||||
dst->sin_len = sizeof(*dst);
|
||||
;
|
||||
dst->sin_addr = addr->v4;
|
||||
rt = rtalloc(sintosa(dst), 0, rtableid);
|
||||
break;
|
||||
@@ -4324,7 +4324,7 @@ pf_calc_mss(struct pf_addr *addr, sa_family_t af, int rtableid, uint16_t offer,
|
||||
hlen = sizeof(struct pf_ip6_hdr);
|
||||
dst6 = (struct sockaddr_in6 *)&ss;
|
||||
dst6->sin6_family = AF_INET6;
|
||||
dst6->sin6_len = sizeof(*dst6);
|
||||
;
|
||||
dst6->sin6_addr = addr->v6;
|
||||
rt = rtalloc(sin6tosa(dst6), 0, rtableid);
|
||||
break;
|
||||
@@ -5389,7 +5389,7 @@ pf_create_state(struct pf_pdesc *pd, struct pf_rule *r, struct pf_rule *a,
|
||||
pf_set_protostate(st, PF_PEER_SRC, PF_TCPS_PROXY_SRC);
|
||||
st->src.seqhi = arc4random();
|
||||
/* Find mss option */
|
||||
mssdflt = atomic_load_int(&tcp_mssdflt);
|
||||
mssdflt = atomic_load_int(&pfk_tcp_mssdflt);
|
||||
mss = pf_get_mss(pd, mssdflt);
|
||||
mss = pf_calc_mss(pd->src, pd->af, rtid, mss, mssdflt);
|
||||
mss = pf_calc_mss(pd->dst, pd->af, rtid, mss, mssdflt);
|
||||
@@ -6066,7 +6066,7 @@ pf_synproxy_ack(struct pf_rule *r, struct pf_pdesc *pd, struct pf_state **sm,
|
||||
pf_set_protostate(s, PF_PEER_SRC, PF_TCPS_PROXY_SRC);
|
||||
s->src.seqhi = arc4random();
|
||||
/* Find mss option */
|
||||
mssdflt = atomic_load_int(&tcp_mssdflt);
|
||||
mssdflt = atomic_load_int(&pfk_tcp_mssdflt);
|
||||
mss = pf_get_mss(pd, mssdflt);
|
||||
mss = pf_calc_mss(pd->src, pd->af, rtid, mss, mssdflt);
|
||||
mss = pf_calc_mss(pd->dst, pd->af, rtid, mss, mssdflt);
|
||||
@@ -7185,7 +7185,7 @@ pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif,
|
||||
case AF_INET:
|
||||
dst = (struct sockaddr_in *)&ss;
|
||||
dst->sin_family = AF_INET;
|
||||
dst->sin_len = sizeof(*dst);
|
||||
;
|
||||
dst->sin_addr = addr->v4;
|
||||
if (atomic_load_int(&ipmultipath))
|
||||
check_mpath = 1;
|
||||
@@ -7200,7 +7200,7 @@ pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif,
|
||||
goto out;
|
||||
dst6 = (struct sockaddr_in6 *)&ss;
|
||||
dst6->sin6_family = AF_INET6;
|
||||
dst6->sin6_len = sizeof(*dst6);
|
||||
;
|
||||
dst6->sin6_addr = addr->v6;
|
||||
if (atomic_load_int(&ip6_multipath))
|
||||
check_mpath = 1;
|
||||
@@ -7268,14 +7268,14 @@ pf_rtlabel_match(struct pf_addr *addr, sa_family_t af, struct pf_addr_wrap *aw,
|
||||
case AF_INET:
|
||||
dst = (struct sockaddr_in *)&ss;
|
||||
dst->sin_family = AF_INET;
|
||||
dst->sin_len = sizeof(*dst);
|
||||
;
|
||||
dst->sin_addr = addr->v4;
|
||||
break;
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
dst6 = (struct sockaddr_in6 *)&ss;
|
||||
dst6->sin6_family = AF_INET6;
|
||||
dst6->sin6_len = sizeof(*dst6);
|
||||
;
|
||||
dst6->sin6_addr = addr->v6;
|
||||
break;
|
||||
#endif /* INET6 */
|
||||
@@ -7342,7 +7342,7 @@ pf_route(struct pf_pdesc *pd, struct pf_state *st)
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
dst = &sin;
|
||||
dst->sin_family = AF_INET;
|
||||
dst->sin_len = sizeof(*dst);
|
||||
;
|
||||
dst->sin_addr = st->rt_addr.v4;
|
||||
rtableid = m0->m_pkthdr.ph_rtableid;
|
||||
|
||||
@@ -7460,7 +7460,7 @@ pf_route6(struct pf_pdesc *pd, struct pf_state *st)
|
||||
memset(&sin6, 0, sizeof(sin6));
|
||||
dst = &sin6;
|
||||
dst->sin6_family = AF_INET6;
|
||||
dst->sin6_len = sizeof(*dst);
|
||||
;
|
||||
dst->sin6_addr = st->rt_addr.v6;
|
||||
rtableid = m0->m_pkthdr.ph_rtableid;
|
||||
|
||||
@@ -8723,9 +8723,9 @@ done:
|
||||
}
|
||||
if (atomic_load_int(&ip_directedbcast))
|
||||
SET(flags, IP_ALLOWBROADCAST);
|
||||
ip_forward(pd.m, ifp, NULL, flags);
|
||||
pfk_ip_forward(pd.m, ifp, NULL, flags);
|
||||
} else
|
||||
ip_output(pd.m, NULL, NULL, 0, NULL, NULL, 0);
|
||||
pfk_ip_output(pd.m, NULL, NULL, 0, NULL, NULL, 0);
|
||||
break;
|
||||
case AF_INET6:
|
||||
if (pd.dir == PF_IN) {
|
||||
@@ -8745,7 +8745,7 @@ done:
|
||||
}
|
||||
pfk_ip6_forward(pd.m, NULL, flags);
|
||||
} else
|
||||
ip6_output(pd.m, NULL, NULL, 0, NULL, NULL);
|
||||
pfk_ip6_output(pd.m, NULL, NULL, 0, NULL, NULL);
|
||||
break;
|
||||
}
|
||||
pd.m = NULL;
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* PF-on-Linux netfilter hook registration + engine status surface.
|
||||
* The verdict path is staged pf.c (pf_test()); hook→pf_test wiring with
|
||||
* mbuf ingress is milestone M2's data-path task — until then the hooks
|
||||
* accept so the module is inert once loaded (never silent: pr_info at
|
||||
* registration says so). (ISC 2026)
|
||||
*/
|
||||
#include <pfk.h>
|
||||
#include <pfk_api.h>
|
||||
#include <net/pfvar.h>
|
||||
#include <net/pfvar_priv.h>
|
||||
|
||||
static int pfk_enabled = 1; /* like pf_defaultwise/pf_enable on boot */
|
||||
static struct pf_status pfk_stat;
|
||||
|
||||
void pfk_status(struct pf_status *s)
|
||||
{
|
||||
if (s)
|
||||
*s = pfk_stat;
|
||||
}
|
||||
|
||||
int pfk_enable(int on)
|
||||
{
|
||||
pfk_enabled = on ? 1 : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* --- netfilter hooks: ingress/egress plumbing --- */
|
||||
static unsigned int
|
||||
pfk_ipv4_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *st)
|
||||
{
|
||||
/* PFLINUX M1: pf_test() routing arrives with the M2 data-path task;
|
||||
* until then the hooks accept (module inert). */
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
|
||||
static struct nf_hook_ops pfk_hooks[] = {
|
||||
{ .hook = pfk_ipv4_hook, .pf = NFPROTO_IPV4, .hooknum = NF_INET_PRE_ROUTING,
|
||||
.priority = NF_IP_PRI_FIRST },
|
||||
{ .hook = pfk_ipv4_hook, .pf = NFPROTO_IPV4, .hooknum = NF_INET_LOCAL_IN,
|
||||
.priority = NF_IP_PRI_FIRST + 1 },
|
||||
{ .hook = pfk_ipv4_hook, .pf = NFPROTO_IPV4, .hooknum = NF_INET_FORWARD,
|
||||
.priority = NF_IP_PRI_FIRST },
|
||||
{ .hook = pfk_ipv4_hook, .pf = NFPROTO_IPV4, .hooknum = NF_INET_LOCAL_OUT,
|
||||
.priority = NF_IP_PRI_CONNTRACK + 1 },
|
||||
{ .hook = pfk_ipv4_hook, .pf = NFPROTO_IPV4, .hooknum = NF_INET_POST_ROUTING,
|
||||
.priority = NF_IP_PRI_LAST - 1 },
|
||||
};
|
||||
#define PFK_NHOOKS ARRAY_SIZE(pfk_hooks)
|
||||
|
||||
int
|
||||
pfk_hooks_register(void)
|
||||
{
|
||||
int i, err;
|
||||
|
||||
pr_info("pfk: netfilter hooks registered (verdict path inert until M2)\n");
|
||||
for (i = 0; i < PFK_NHOOKS; i++) {
|
||||
pfk_hooks[i].priv = NULL;
|
||||
err = nf_register_net_hook(&init_net, &pfk_hooks[i]);
|
||||
if (err)
|
||||
goto fail;
|
||||
}
|
||||
return 0;
|
||||
fail:
|
||||
while (--i >= 0)
|
||||
nf_unregister_net_hook(&init_net, &pfk_hooks[i]);
|
||||
return err;
|
||||
}
|
||||
|
||||
void
|
||||
pfk_hooks_unregister(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < PFK_NHOOKS; i++)
|
||||
nf_unregister_net_hook(&init_net, &pfk_hooks[i]);
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* PF-on-Linux: pfk module core — load/exit, /dev/pf misc device,
|
||||
* NET_LOCK bring-up, engine ioctl dispatch. (ISC 2026)
|
||||
*
|
||||
* Restored during the M1 compile-loop: this file had been dropped from
|
||||
* the tree by commit 1fcd7b3 while its objects still linked from stale
|
||||
* build artifacts; the /dev/pf path now dispatches into the staged
|
||||
* pf_ioctl.c (pfioctl()) instead of the old minimal placeholder.
|
||||
*/
|
||||
#include <pfk.h>
|
||||
#include <pfk_api.h>
|
||||
#include <net/pfvar.h>
|
||||
#include <net/pfvar_priv.h>
|
||||
|
||||
extern void pfk_mbuf_exit(void);
|
||||
extern int pfk_if_init(void);
|
||||
extern void pfk_if_exit(void);
|
||||
extern int pfk_pcb_init(void);
|
||||
extern void pfk_pcb_exit(void);
|
||||
int pfk_hooks_register(void);
|
||||
void pfk_hooks_unregister(void);
|
||||
|
||||
extern int pfioctl(dev_t, u_long, caddr_t, int, struct proc *);
|
||||
|
||||
static int pfk_open(struct inode *inode, struct file *filp)
|
||||
{
|
||||
if (filp->f_mode & FMODE_WRITE)
|
||||
return capable(CAP_NET_ADMIN) ? 0 : -EPERM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* PFLINUX: OpenBSD's kernel ioctl layer copies the parameter structure
|
||||
* (size taken from the command encoding) before dispatching to pfioctl();
|
||||
* the port does the same here, using the OpenBSD _IOR/_IOW size field
|
||||
* that pfk.h preserves bit-for-bit.
|
||||
*/
|
||||
static long
|
||||
pfk_ioctl_io(struct file *filp, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
size_t sz = PFKIOC_SIZE(cmd);
|
||||
unsigned int dir = PFKIOC_DIR(cmd);
|
||||
void __user *uarg = (void __user *)arg;
|
||||
struct pfk_ucred cred;
|
||||
struct pfk_proc_p pp;
|
||||
struct proc p;
|
||||
caddr_t kdata;
|
||||
int err, err2;
|
||||
|
||||
cred.uid = from_kuid(&init_user_ns, current_euid());
|
||||
cred.gid = from_kgid(&init_user_ns, current_egid());
|
||||
pp.pid = task_pid_nr(current);
|
||||
p.p_flags = 0;
|
||||
p.p_ucred = &cred;
|
||||
p.p_p = &pp;
|
||||
|
||||
kdata = kzalloc(sz ? sz : sizeof(long), GFP_KERNEL);
|
||||
if (!kdata)
|
||||
return -ENOMEM;
|
||||
|
||||
if ((dir & PFKXIOC_WRITE) && sz) {
|
||||
if (copy_from_user(kdata, uarg, sz)) {
|
||||
kfree(kdata);
|
||||
return -EFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
err = pfioctl(0, (u_long)cmd, kdata,
|
||||
(filp->f_mode & FMODE_WRITE) ? FWRITE : 0, &p);
|
||||
|
||||
err2 = 0;
|
||||
if (!err && (dir & PFKXIOC_READ) && sz) {
|
||||
if (copy_to_user(uarg, kdata, sz))
|
||||
err2 = EFAULT;
|
||||
}
|
||||
kfree(kdata);
|
||||
return err ? -err : (err2 ? -err2 : 0);
|
||||
}
|
||||
|
||||
static const struct file_operations pfk_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = pfk_open,
|
||||
.unlocked_ioctl = pfk_ioctl_io,
|
||||
.compat_ioctl = compat_ptr_ioctl,
|
||||
};
|
||||
|
||||
static struct miscdevice pfk_dev = {
|
||||
.minor = MISC_DYNAMIC_MINOR,
|
||||
.name = "pf",
|
||||
.fops = &pfk_fops,
|
||||
.mode = 0600,
|
||||
};
|
||||
|
||||
static int __init pfk_init(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
pfk_net_lock_init();
|
||||
err = pfk_mbuf_init();
|
||||
if (err)
|
||||
return err;
|
||||
err = pfk_pcb_init();
|
||||
if (err)
|
||||
goto err_mbuf;
|
||||
err = pfk_if_init();
|
||||
if (err)
|
||||
goto err_pcb;
|
||||
err = pfk_hooks_register();
|
||||
if (err)
|
||||
goto err_if;
|
||||
err = misc_register(&pfk_dev);
|
||||
if (err)
|
||||
goto err_hooks;
|
||||
pr_info("pfk: PF-on-Linux engine loaded (OpenBSD 8.0 base)\n");
|
||||
return 0;
|
||||
err_hooks:
|
||||
pfk_hooks_unregister();
|
||||
err_if:
|
||||
pfk_if_exit();
|
||||
err_pcb:
|
||||
pfk_pcb_exit();
|
||||
err_mbuf:
|
||||
pfk_mbuf_exit();
|
||||
return err;
|
||||
}
|
||||
|
||||
static void __exit pfk_exit(void)
|
||||
{
|
||||
misc_deregister(&pfk_dev);
|
||||
pfk_hooks_unregister();
|
||||
pfk_if_exit();
|
||||
pfk_pcb_exit();
|
||||
pfk_mbuf_exit();
|
||||
pr_info("pfk: unloaded\n");
|
||||
}
|
||||
|
||||
module_init(pfk_init);
|
||||
module_exit(pfk_exit);
|
||||
MODULE_LICENSE("Dual MIT/GPL"); /* ISC/BSD code; Dual MIT/GPL is the kernel-
|
||||
* recognised tag for permissive BSD-licensed
|
||||
* modules linking GPL exports (see LICENSE). */
|
||||
MODULE_DESCRIPTION("PF packet filter (ported from OpenBSD 8.0) for Linux");
|
||||
MODULE_AUTHOR("PF-on-Linux contributors");
|
||||
Reference in new issue
Block a user