Message ID | 6f4baef54a7631cdc1460138bc7e52f2c432c69b.1701180777.git.geliang.tang@suse.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | add MPTCP_MIB_CURRESTAB | expand |
Context | Check | Description |
---|---|---|
matttbe/build | warning | Build error with: make C=1 net/mptcp/trace.o |
matttbe/checkpatch | warning | total: 0 errors, 1 warnings, 0 checks, 72 lines checked |
Hi Geliang, kernel test robot noticed the following build errors: [auto build test ERROR on mptcp/export] [also build test ERROR on mptcp/export-net linus/master v6.7-rc3 next-20231128] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Geliang-Tang/mptcp-add-mib-counter-dec-helper/20231128-221604 base: https://github.com/multipath-tcp/mptcp_net-next.git export patch link: https://lore.kernel.org/r/6f4baef54a7631cdc1460138bc7e52f2c432c69b.1701180777.git.geliang.tang%40suse.com patch subject: [PATCH mptcp-next 3/4] mptcp: add ftrace callback of tcp_set_state config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20231129/202311290844.drzx9Vmn-lkp@intel.com/config) compiler: sh4-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231129/202311290844.drzx9Vmn-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202311290844.drzx9Vmn-lkp@intel.com/ All errors (new ones prefixed by >>): net/mptcp/trace.c: In function 'mptcp_state_callback': >> net/mptcp/trace.c:44:29: error: implicit declaration of function 'regs_get_kernel_argument'; did you mean 'regs_get_kernel_stack_nth'? [-Werror=implicit-function-declaration] 44 | sk = (struct sock *)regs_get_kernel_argument(regs, 0); | ^~~~~~~~~~~~~~~~~~~~~~~~ | regs_get_kernel_stack_nth cc1: some warnings being treated as errors vim +44 net/mptcp/trace.c 30 31 static void notrace mptcp_state_callback(unsigned long ip, 32 unsigned long parent_ip, 33 struct ftrace_ops *op, 34 struct ftrace_regs *fregs) 35 { 36 struct pt_regs *regs; 37 int oldstate, state; 38 struct sock *sk; 39 40 regs = ftrace_get_regs(fregs); 41 if (!regs) 42 return; 43 > 44 sk = (struct sock *)regs_get_kernel_argument(regs, 0); 45 if (!sk) 46 return; 47 48 oldstate = sk->sk_state; 49 state = regs_get_kernel_argument(regs, 1); 50 51 if (sk_is_mptcp(sk)) 52 mptcp_check_state(sk, oldstate, state); 53 } 54
Hi Geliang, kernel test robot noticed the following build warnings: [auto build test WARNING on mptcp/export] [also build test WARNING on mptcp/export-net linus/master v6.7-rc3 next-20231128] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Geliang-Tang/mptcp-add-mib-counter-dec-helper/20231128-221604 base: https://github.com/multipath-tcp/mptcp_net-next.git export patch link: https://lore.kernel.org/r/6f4baef54a7631cdc1460138bc7e52f2c432c69b.1701180777.git.geliang.tang%40suse.com patch subject: [PATCH mptcp-next 3/4] mptcp: add ftrace callback of tcp_set_state config: sparc-allmodconfig (https://download.01.org/0day-ci/archive/20231129/202311290855.aEWX2Ohy-lkp@intel.com/config) compiler: sparc64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231129/202311290855.aEWX2Ohy-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202311290855.aEWX2Ohy-lkp@intel.com/ All warnings (new ones prefixed by >>): net/mptcp/trace.c: In function 'mptcp_state_callback': net/mptcp/trace.c:44:29: error: implicit declaration of function 'regs_get_kernel_argument'; did you mean 'regs_get_kernel_stack_nth'? [-Werror=implicit-function-declaration] 44 | sk = (struct sock *)regs_get_kernel_argument(regs, 0); | ^~~~~~~~~~~~~~~~~~~~~~~~ | regs_get_kernel_stack_nth >> net/mptcp/trace.c:44:14: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 44 | sk = (struct sock *)regs_get_kernel_argument(regs, 0); | ^ cc1: some warnings being treated as errors vim +44 net/mptcp/trace.c 30 31 static void notrace mptcp_state_callback(unsigned long ip, 32 unsigned long parent_ip, 33 struct ftrace_ops *op, 34 struct ftrace_regs *fregs) 35 { 36 struct pt_regs *regs; 37 int oldstate, state; 38 struct sock *sk; 39 40 regs = ftrace_get_regs(fregs); 41 if (!regs) 42 return; 43 > 44 sk = (struct sock *)regs_get_kernel_argument(regs, 0); 45 if (!sk) 46 return; 47 48 oldstate = sk->sk_state; 49 state = regs_get_kernel_argument(regs, 1); 50 51 if (sk_is_mptcp(sk)) 52 mptcp_check_state(sk, oldstate, state); 53 } 54
diff --git a/net/mptcp/Makefile b/net/mptcp/Makefile index 67cd565bb321..bf88bdb222b3 100644 --- a/net/mptcp/Makefile +++ b/net/mptcp/Makefile @@ -14,3 +14,4 @@ mptcp_token_test-objs := token_test.o obj-$(CONFIG_MPTCP_KUNIT_TEST) += mptcp_crypto_test.o mptcp_token_test.o obj-$(CONFIG_BPF_SYSCALL) += bpf.o +obj-$(CONFIG_FUNCTION_TRACER) += trace.o diff --git a/net/mptcp/trace.c b/net/mptcp/trace.c new file mode 100644 index 000000000000..a930e1b50d56 --- /dev/null +++ b/net/mptcp/trace.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Multipath TCP + * + * Copyright (c) 2023, SUSE. + */ + +#define pr_fmt(fmt) "MPTCP: " fmt + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/ftrace.h> +#include <net/sock.h> +#include <net/mptcp.h> +#include "protocol.h" +#include "mib.h" + +static void mptcp_check_state(struct sock *sk, int oldstate, int state) +{ + switch (state) { + case TCP_ESTABLISHED: + if (oldstate != TCP_ESTABLISHED) + MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_CURRESTAB); + break; + + default: + if (oldstate == TCP_ESTABLISHED) + MPTCP_DEC_STATS(sock_net(sk), MPTCP_MIB_CURRESTAB); + } +} + +static void notrace mptcp_state_callback(unsigned long ip, + unsigned long parent_ip, + struct ftrace_ops *op, + struct ftrace_regs *fregs) +{ + struct pt_regs *regs; + int oldstate, state; + struct sock *sk; + + regs = ftrace_get_regs(fregs); + if (!regs) + return; + + sk = (struct sock *)regs_get_kernel_argument(regs, 0); + if (!sk) + return; + + oldstate = sk->sk_state; + state = regs_get_kernel_argument(regs, 1); + + if (sk_is_mptcp(sk)) + mptcp_check_state(sk, oldstate, state); +} + +static struct ftrace_ops mptcp_state_ops __read_mostly = { + .func = mptcp_state_callback, + .flags = FTRACE_OPS_FL_SAVE_REGS, +}; + +static __init int mptcp_ftrace_init(void) +{ + int ret; + + ret = ftrace_set_filter(&mptcp_state_ops, "tcp_set_state", + strlen("tcp_set_state"), 0); + return ret ?: register_ftrace_function(&mptcp_state_ops); +} +late_initcall(mptcp_ftrace_init);
This patch adds a new function mptcp_check_state(), in it if switch from or to ESTABLISH state, increment or decrement the newly added counter MPTCP_MIB_CURRESTAB. Instead of invoking mptcp_check_state() in tcp_set_state() directly, here add a new file trace.c, in it use ftrace to hook a callback function to tcp_set_state(), named mptcp_state_callback(). mptcp_check_state() is invoked in the callback function. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/460 Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- net/mptcp/Makefile | 1 + net/mptcp/trace.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 net/mptcp/trace.c