Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

兼容 4.17 以上内核 #3

Merged
merged 1 commit into from
Feb 6, 2023
Merged

Conversation

dongzerun
Copy link
Contributor

@dongzerun dongzerun commented Jan 29, 2019

4.17.0 以上内核的 inet_getname 与 inet6_getname 参数个数及返回值均发生变化,增加条件编绎来适配

@spielkind
Copy link

@geanv any chance to get this merged?

Also even with this patch applied TOA is currently not compiling with kernel 5.11:

make CONFIG_TOA=m  -C /lib/modules/`uname -r`/build M=`pwd` modules
make[1]: Entering directory '/usr/lib/modules/5.11.11-arch1-1/build'
  CC [M]  /home/user/TCP_option_address/src/toa.o
/home/user/TCP_option_address/src/toa.c: In function ‘toa_init’:
/home/user/TCP_option_address/src/toa.c:468:49: error: passing argument 4 of ‘proc_create’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  468 |  proc_create("toa_stats", 0, init_net.proc_net, &toa_stats_fops);
      |                                                 ^~~~~~~~~~~~~~~
      |                                                 |
      |                                                 const struct file_operations *
In file included from /home/user/TCP_option_address/src/toa.h:18,
                 from /home/user/TCP_option_address/src/toa.c:1:
./include/linux/proc_fs.h:109:122: note: expected ‘const struct proc_ops *’ but argument is of type ‘const struct file_operations *’
  109 | struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct proc_ops *proc_ops);
      |                                                                                                   ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:279: /home/user/TCP_option_address/src/toa.o] Error 1
make[1]: *** [Makefile:1809: /home/user/TCP_option_address/src] Error 2
make[1]: Leaving directory '/usr/lib/modules/5.11.11-arch1-1/build'
make: *** [Makefile:8: default] Error 2

@402test
Copy link

402test commented Sep 9, 2021

Linux version 4.19.90-23.8.v2101.ky10.aarch64 ([email protected]) (gcc version 7.3.0 (GCC)) #1 SMP Mon May 17 17:07:38 CST 2021
上面是系统内核,使用 <兼容 4.17> 的还是有点问题

**make CONFIG_TOA=m -C /lib/modules/uname -r/build M=pwd modules
make[1]: 进入目录“/usr/src/kernels/4.19.90-23.8.v2101.ky10.aarch64”
CC [M] /root/hcw/TCP_option_address-master/src/toa.o
/root/hcw/TCP_option_address-master/src/toa.c: 在函数‘hook_toa_functions’中:
/root/hcw/TCP_option_address-master/src/toa.c:316:8: 错误:implicit declaration of function ‘lookup_address’; did you mean ‘lookup_bdev’? [-Werror=implicit-function-declaration]
pte = lookup_address((unsigned long )inet_stream_ops_p, &level);
^~~~~~~~~~~~~~
lookup_bdev
/root/hcw/TCP_option_address-master/src/toa.c:316:6: 警告:赋值时将整数赋给指针,未作类型转换 [-Wint-conversion]
pte = lookup_address((unsigned long )inet_stream_ops_p, &level);
^
/root/hcw/TCP_option_address-master/src/toa.c:319:18: 错误:‘_PAGE_RW’ undeclared (first use in this function); did you mean ‘PAGE_S2’?
if (pte->pte & ~_PAGE_RW) {
^~~~~~~~
PAGE_S2
/root/hcw/TCP_option_address-master/src/toa.c:319:18: 附注:每个未声明的标识符在其出现的函数内只报告一次
/root/hcw/TCP_option_address-master/src/toa.c:345:6: 警告:赋值时将整数赋给指针,未作类型转换 [-Wint-conversion]
pte = lookup_address((unsigned long )inet_stream_ops_p, &level);
^
/root/hcw/TCP_option_address-master/src/toa.c: 在函数‘unhook_toa_functions’中:
/root/hcw/TCP_option_address-master/src/toa.c:376:6: 警告:赋值时将整数赋给指针,未作类型转换 [-Wint-conversion]
pte = lookup_address((unsigned long )inet_stream_ops_p, &level);
^
/root/hcw/TCP_option_address-master/src/toa.c:379:18: 错误:‘_PAGE_RW’ undeclared (first use in this function); did you mean ‘PAGE_S2’?
if (pte->pte & ~_PAGE_RW) {
^~~~~~~~
PAGE_S2
/root/hcw/TCP_option_address-master/src/toa.c:403:6: 警告:赋值时将整数赋给指针,未作类型转换 [-Wint-conversion]
pte = lookup_address((unsigned long )inet_stream_ops_p, &level);
^
cc1:有些警告被当作是错误
make[2]: *** [scripts/Makefile.build:310:/root/hcw/TCP_option_address-master/src/toa.o] 错误 1
make[1]: *** [Makefile:1541:module/root/hcw/TCP_option_address-master/src] 错误 2
make[1]: 离开目录“/usr/src/kernels/4.19.90-23.8.v2101.ky10.aarch64”
make: *** [Makefile:8:default] 错误 2
**

@rysinal
Copy link

rysinal commented Sep 14, 2021

Linux version 4.19.90-23.8.v2101.ky10.aarch64 ([email protected]) (gcc version 7.3.0 (GCC)) #1 SMP Mon May 17 17:07:38 CST 2021
上面是系统内核,使用 <兼容 4.17> 的还是有点问题

**make CONFIG_TOA=m -C /lib/modules/uname -r/build M=pwd modules
make[1]: 进入目录“/usr/src/kernels/4.19.90-23.8.v2101.ky10.aarch64”
CC [M] /root/hcw/TCP_option_address-master/src/toa.o
/root/hcw/TCP_option_address-master/src/toa.c: 在函数‘hook_toa_functions’中:
/root/hcw/TCP_option_address-master/src/toa.c:316:8: 错误:implicit declaration of function ‘lookup_address’; did you mean ‘lookup_bdev’? [-Werror=implicit-function-declaration]
pte = lookup_address((unsigned long )inet_stream_ops_p, &level);
^~~~~~~~~~~~~~
lookup_bdev
/root/hcw/TCP_option_address-master/src/toa.c:316:6: 警告:赋值时将整数赋给指针,未作类型转换 [-Wint-conversion]
pte = lookup_address((unsigned long )inet_stream_ops_p, &level);
^
/root/hcw/TCP_option_address-master/src/toa.c:319:18: 错误:‘_PAGE_RW’ undeclared (first use in this function); did you mean ‘PAGE_S2’?
if (pte->pte & ~_PAGE_RW) {
^~~~~~~~
PAGE_S2
/root/hcw/TCP_option_address-master/src/toa.c:319:18: 附注:每个未声明的标识符在其出现的函数内只报告一次
/root/hcw/TCP_option_address-master/src/toa.c:345:6: 警告:赋值时将整数赋给指针,未作类型转换 [-Wint-conversion]
pte = lookup_address((unsigned long )inet_stream_ops_p, &level);
^
/root/hcw/TCP_option_address-master/src/toa.c: 在函数‘unhook_toa_functions’中:
/root/hcw/TCP_option_address-master/src/toa.c:376:6: 警告:赋值时将整数赋给指针,未作类型转换 [-Wint-conversion]
pte = lookup_address((unsigned long )inet_stream_ops_p, &level);
^
/root/hcw/TCP_option_address-master/src/toa.c:379:18: 错误:‘_PAGE_RW’ undeclared (first use in this function); did you mean ‘PAGE_S2’?
if (pte->pte & ~_PAGE_RW) {
^~~~~~~~
PAGE_S2
/root/hcw/TCP_option_address-master/src/toa.c:403:6: 警告:赋值时将整数赋给指针,未作类型转换 [-Wint-conversion]
pte = lookup_address((unsigned long )inet_stream_ops_p, &level);
^
cc1:有些警告被当作是错误
make[2]: *** [scripts/Makefile.build:310:/root/hcw/TCP_option_address-master/src/toa.o] 错误 1
make[1]: *** [Makefile:1541:module/root/hcw/TCP_option_address-master/src] 错误 2
make[1]: 离开目录“/usr/src/kernels/4.19.90-23.8.v2101.ky10.aarch64”
make: *** [Makefile:8:default] 错误 2
**

你好,请问大佬后面怎么解决的呢

@spielkind
Copy link

spielkind commented Sep 14, 2021

error: passing argument 4 of ‘proc_create’ from incompatible pointer type [-Werror=incompatible-pointer-types] can be fixed with using proc_ops instead of file_operations
https://stackoverflow.com/questions/64931555/how-to-fix-error-passing-argument-4-of-proc-create-from-incompatible-pointer

Anyway since kernel 5.7 kallsyms_lookup_name is not longer exported and the module won't compile.

@huaweicloud-elb huaweicloud-elb merged commit 487c25b into Huawei:master Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants