bpfilter: allow to build bpfilter_umh as a module without static library
Subsystems (4)
PATCH 1/1 bpfilter: allow to build bpfilter_umh as a module without static library
Originally, bpfilter_umh was linked with -static only when CONFIG_BPFILTER_UMH=y.
Commit 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build bpfilter_umh") silently, accidentally dropped the CONFIG_BPFILTER_UMH=y test in the Makefile. Revive it in order to link it dynamically when CONFIG_BPFILTER_UMH=m.
Since commit b1183b6dca3e ("bpfilter: check if $(CC) can link static libc in Kconfig"), the compiler must be capable of static linking to enable CONFIG_BPFILTER_UMH, but it requires more than needed.
To loosen the compiler requirement, I changed the dependency as follows:
depends on CC_CAN_LINK
depends on m || CC_CAN_LINK_STATIC
If CONFIG_CC_CAN_LINK_STATIC in unset, CONFIG_BPFILTER_UMH is restricted to 'm' or 'n'.
In theory, CONFIG_CC_CAN_LINK is not required for CONFIG_BPFILTER_UMH=y, but I did not come up with a good way to describe it.
---
net/bpfilter/Kconfig | 10 ++++++---- net/bpfilter/Makefile | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-)
net/bpfilter/Kconfig +6 -4
@@ -9,12 +9,14 @@ menuconfig BPFILTER if BPFILTER config BPFILTER_UMH tristate "bpfilter kernel module with user mode helper" - depends on CC_CAN_LINK_STATIC + depends on CC_CAN_LINK + depends on m || CC_CAN_LINK_STATIC default m help This builds bpfilter kernel module with embedded user mode helper - Note: your toolchain must support building static binaries, since - rootfs isn't mounted at the time when __init functions are called - and do_execv won't be able to find the elf interpreter. + Note: To compile this as built-in, your toolchain must support + building static binaries, since rootfs isn't mounted at the time + when __init functions are called and do_execv won't be able to find + the elf interpreter. endif
net/bpfilter/Makefile +2 -0
@@ -7,10 +7,12 @@ userprogs := bpfilter_umh bpfilter_umh-objs := main.o userccflags += -I $(srctree)/tools/include/ -I $(srctree)/tools/include/uapi +ifeq ($(CONFIG_BPFILTER_UMH), y) # builtin bpfilter_umh should be linked with -static # since rootfs isn't mounted at the time of __init # function is called and do_execv won't find elf interpreter userldflags += -static +endif $(obj)/bpfilter_umh_blob.o: $(obj)/bpfilter_umh
Signature · 1 line
2.25.1
Quoted 20 lines · Masahiro Yamada
Originally,
bpfilter_umhwas linked with -static only whenCONFIG_BPFILTER_UMH=y.Commit
8a2cc0505cc4("bpfilter: use 'userprogs' syntax to buildbpfilter_umh") silently, accidentally dropped theCONFIG_BPFILTER_UMH=ytest in theMakefile. Revive it in order to link it dynamically whenCONFIG_BPFILTER_UMH=m.Since commit
b1183b6dca3e("bpfilter: check if $(CC) can link static libc inKconfig"), the compiler must be capable of static linking to enableCONFIG_BPFILTER_UMH, but it requires more than needed.To loosen the compiler requirement, I changed the dependency as follows:
depends on
CC_CAN_LINK
depends on m ||CC_CAN_LINK_STATICIf
CONFIG_CC_CAN_LINK_STATICin unset,CONFIG_BPFILTER_UMHis restricted to 'm' or 'n'.
Quoted 6 lines
In theory,
CONFIG_CC_CAN_LINKis not required forCONFIG_BPFILTER_UMH=y, but I did not come up with a good way to describe it.Fixes 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build bpfilter_umh")Reported-by Michal Kubecek <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>
Thank you,
Michal
Quoted 49 lines
---
net/bpfilter/Kconfig | 10 ++++++---- net/bpfilter/Makefile | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-)net/bpfilter/Kconfig +6
-4@@ -9,12 +9,14 @@ menuconfig BPFILTER if BPFILTER config BPFILTER_UMH tristate "bpfilter kernel module with user mode helper" - depends on CC_CAN_LINK_STATIC + depends on CC_CAN_LINK + depends on m || CC_CAN_LINK_STATIC default m help This builds bpfilter kernel module with embedded user mode helper - Note: your toolchain must support building static binaries, since - rootfs isn't mounted at the time when __init functions are called - and do_execv won't be able to find the elf interpreter. + Note: To compile this as built-in, your toolchain must support + building static binaries, since rootfs isn't mounted at the time + when __init functions are called and do_execv won't be able to find + the elf interpreter. endifnet/bpfilter/Makefile +2
-0@@ -7,10 +7,12 @@ userprogs := bpfilter_umh bpfilter_umh-objs := main.o userccflags += -I $(srctree)/tools/include/ -I $(srctree)/tools/include/uapi +ifeq ($(CONFIG_BPFILTER_UMH), y) # builtin bpfilter_umh should be linked with -static # since rootfs isn't mounted at the time of __init # function is called and do_execv won't find elf interpreter userldflags += -static +endif $(obj)/bpfilter_umh_blob.o: $(obj)/bpfilter_umhSignature · 1 line
2.25.1
Quoted 20 lines · Masahiro Yamada
Originally,
bpfilter_umhwas linked with -static only whenCONFIG_BPFILTER_UMH=y.Commit
8a2cc0505cc4("bpfilter: use 'userprogs' syntax to buildbpfilter_umh") silently, accidentally dropped theCONFIG_BPFILTER_UMH=ytest in theMakefile. Revive it in order to link it dynamically whenCONFIG_BPFILTER_UMH=m.Since commit
b1183b6dca3e("bpfilter: check if $(CC) can link static libc inKconfig"), the compiler must be capable of static linking to enableCONFIG_BPFILTER_UMH, but it requires more than needed.To loosen the compiler requirement, I changed the dependency as follows:
depends on
CC_CAN_LINK
depends on m ||CC_CAN_LINK_STATICIf
CONFIG_CC_CAN_LINK_STATICin unset,CONFIG_BPFILTER_UMHis restricted to 'm' or 'n'.
Quoted 6 lines
In theory,
CONFIG_CC_CAN_LINKis not required forCONFIG_BPFILTER_UMH=y, but I did not come up with a good way to describe it.Fixes 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build bpfilter_umh")Reported-by Michal Kubecek <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>
lgtm
Do you mind I'll take it into bpf-next tree?
Eric is working on a bunch of patches in this area. I'll take his set into bpf-next as well and then can apply this patch.
Just to make sure there are no conflicts.
Quoted 29 lines · Alexei Starovoitov
Quoted 20 lines · Masahiro Yamada
Originally,
bpfilter_umhwas linked with -static only whenCONFIG_BPFILTER_UMH=y.Commit
8a2cc0505cc4("bpfilter: use 'userprogs' syntax to buildbpfilter_umh") silently, accidentally dropped theCONFIG_BPFILTER_UMH=ytest in theMakefile. Revive it in order to link it dynamically whenCONFIG_BPFILTER_UMH=m.Since commit
b1183b6dca3e("bpfilter: check if $(CC) can link static libc inKconfig"), the compiler must be capable of static linking to enableCONFIG_BPFILTER_UMH, but it requires more than needed.To loosen the compiler requirement, I changed the dependency as follows:
depends on
CC_CAN_LINK
depends on m ||CC_CAN_LINK_STATICIf
CONFIG_CC_CAN_LINK_STATICin unset,CONFIG_BPFILTER_UMHis restricted to 'm' or 'n'.Quoted 6 lines
In theory,
CONFIG_CC_CAN_LINKis not required forCONFIG_BPFILTER_UMH=y, but I did not come up with a good way to describe it.Fixes 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build bpfilter_umh")Reported-by Michal Kubecek <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>
Quoted 5 lines
lgtm
Do you mind I'll take it into bpf-next tree?
Eric is working on a bunch of patches in this area. I'll take his set into bpf-next as well and then can apply this patch.
Just to make sure there are no conflicts.
Please go ahead.
Thank you.
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 32 lines · Masahiro Yamada
Quoted 29 lines · Alexei Starovoitov
Quoted 26 lines · Masahiro Yamada
Originally,
bpfilter_umhwas linked with -static only whenCONFIG_BPFILTER_UMH=y.Commit
8a2cc0505cc4("bpfilter: use 'userprogs' syntax to buildbpfilter_umh") silently, accidentally dropped theCONFIG_BPFILTER_UMH=ytest in theMakefile. Revive it in order to link it dynamically whenCONFIG_BPFILTER_UMH=m.Since commit
b1183b6dca3e("bpfilter: check if $(CC) can link static libc inKconfig"), the compiler must be capable of static linking to enableCONFIG_BPFILTER_UMH, but it requires more than needed.To loosen the compiler requirement, I changed the dependency as follows:
depends on
CC_CAN_LINK
depends on m ||CC_CAN_LINK_STATICIf
CONFIG_CC_CAN_LINK_STATICin unset,CONFIG_BPFILTER_UMHis restricted to 'm' or 'n'.In theory,
CONFIG_CC_CAN_LINKis not required forCONFIG_BPFILTER_UMH=y, but I did not come up with a good way to describe it.Fixes 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build bpfilter_umh")Reported-by Michal Kubecek <[email protected]>Signed-off-by Masahiro Yamada <[email protected]>
Quoted 7 lines
Quoted 5 lines
lgtm
Do you mind I'll take it into bpf-next tree?
Eric is working on a bunch of patches in this area. I'll take his set into bpf-next as well and then can apply this patch.
Just to make sure there are no conflicts.Please go ahead.
I've merged Eric's set and applied yours on top.
Thanks