diff mbox series

[bpf-next,v3,1/2] bpf: support TCP_RTO_MAX_MS for bpf_setsockopt

Message ID 20250219081333.56378-2-kerneljasonxing@gmail.com (mailing list archive)
State Accepted
Commit 6810c771d3165e6320f991220f0c92519e6bace7
Delegated to: BPF
Headers show
Series bpf: support setting max RTO for bpf_setsockopt | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for bpf-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 0 this patch: 7
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: horms@kernel.org
netdev/build_clang fail Errors and warnings before: 43 this patch: 50
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 25 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 6 this patch: 6
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-0 success Logs for Lint
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Unittests
bpf/vmtest-bpf-next-VM_Test-3 success Logs for Validate matrix.py
bpf/vmtest-bpf-next-VM_Test-5 fail Logs for aarch64-gcc / build / build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-4 success Logs for aarch64-gcc / GCC BPF
bpf/vmtest-bpf-next-VM_Test-6 success Logs for aarch64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-9 success Logs for aarch64-gcc / veristat-meta
bpf/vmtest-bpf-next-VM_Test-7 success Logs for aarch64-gcc / test
bpf/vmtest-bpf-next-VM_Test-8 success Logs for aarch64-gcc / veristat-kernel
bpf/vmtest-bpf-next-PR fail PR summary
bpf/vmtest-bpf-next-VM_Test-11 fail Logs for s390x-gcc / build / build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for s390x-gcc / GCC BPF
bpf/vmtest-bpf-next-VM_Test-12 success Logs for s390x-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-14 success Logs for s390x-gcc / veristat-kernel
bpf/vmtest-bpf-next-VM_Test-13 success Logs for s390x-gcc / test
bpf/vmtest-bpf-next-VM_Test-16 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-15 success Logs for s390x-gcc / veristat-meta
bpf/vmtest-bpf-next-VM_Test-17 success Logs for x86_64-gcc / GCC BPF
bpf/vmtest-bpf-next-VM_Test-18 fail Logs for x86_64-gcc / build / build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for x86_64-gcc / test
bpf/vmtest-bpf-next-VM_Test-19 success Logs for x86_64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-21 success Logs for x86_64-gcc / veristat-kernel
bpf/vmtest-bpf-next-VM_Test-22 success Logs for x86_64-gcc / veristat-meta
bpf/vmtest-bpf-next-VM_Test-23 success Logs for x86_64-llvm-17 / GCC BPF
bpf/vmtest-bpf-next-VM_Test-24 fail Logs for x86_64-llvm-17 / build / build for x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-26 success Logs for x86_64-llvm-17 / test
bpf/vmtest-bpf-next-VM_Test-27 success Logs for x86_64-llvm-17 / veristat-kernel
bpf/vmtest-bpf-next-VM_Test-28 success Logs for x86_64-llvm-17 / veristat-meta
bpf/vmtest-bpf-next-VM_Test-29 success Logs for x86_64-llvm-18 / GCC BPF
bpf/vmtest-bpf-next-VM_Test-25 fail Logs for x86_64-llvm-17 / build-release / build for x86_64 with llvm-17-O2
bpf/vmtest-bpf-next-VM_Test-32 success Logs for x86_64-llvm-18 / test
bpf/vmtest-bpf-next-VM_Test-30 fail Logs for x86_64-llvm-18 / build / build for x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-31 fail Logs for x86_64-llvm-18 / build-release / build for x86_64 with llvm-18-O2
bpf/vmtest-bpf-next-VM_Test-33 success Logs for x86_64-llvm-18 / veristat-kernel
bpf/vmtest-bpf-next-VM_Test-34 success Logs for x86_64-llvm-18 / veristat-meta

Commit Message

Jason Xing Feb. 19, 2025, 8:13 a.m. UTC
Some applications don't want to wait for too long because the
time of retransmission increases exponentially and can reach more
than 10 seconds, for example. Eric implements the core logic
on supporting rto max feature in the stack previously. Based on that,
we can support it for BPF use.

This patch reuses the same logic of TCP_RTO_MAX_MS in do_tcp_setsockopt()
and do_tcp_getsockopt(). BPF program can call bpf_{set/get}sockopt()
to set/get the maximum value of RTO.

Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Jason Xing <kerneljasonxing@gmail.com>
---
 net/core/filter.c | 1 +
 1 file changed, 1 insertion(+)

Comments

kernel test robot Feb. 20, 2025, 8:51 a.m. UTC | #1
Hi Jason,

kernel test robot noticed the following build errors:

[auto build test ERROR on bpf-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Jason-Xing/bpf-support-TCP_RTO_MAX_MS-for-bpf_setsockopt/20250219-161637
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link:    https://lore.kernel.org/r/20250219081333.56378-2-kerneljasonxing%40gmail.com
patch subject: [PATCH bpf-next v3 1/2] bpf: support TCP_RTO_MAX_MS for bpf_setsockopt
config: x86_64-buildonly-randconfig-002-20250220 (https://download.01.org/0day-ci/archive/20250220/202502201843.xA1qZbKX-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250220/202502201843.xA1qZbKX-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/202502201843.xA1qZbKX-lkp@intel.com/

All errors (new ones prefixed by >>):

   net/core/filter.c: In function 'sol_tcp_sockopt':
>> net/core/filter.c:5385:14: error: 'TCP_RTO_MAX_MS' undeclared (first use in this function); did you mean 'TCP_RTO_MAX'?
    5385 |         case TCP_RTO_MAX_MS:
         |              ^~~~~~~~~~~~~~
         |              TCP_RTO_MAX
   net/core/filter.c:5385:14: note: each undeclared identifier is reported only once for each function it appears in


vim +5385 net/core/filter.c

  5365	
  5366	static int sol_tcp_sockopt(struct sock *sk, int optname,
  5367				   char *optval, int *optlen,
  5368				   bool getopt)
  5369	{
  5370		if (sk->sk_protocol != IPPROTO_TCP)
  5371			return -EINVAL;
  5372	
  5373		switch (optname) {
  5374		case TCP_NODELAY:
  5375		case TCP_MAXSEG:
  5376		case TCP_KEEPIDLE:
  5377		case TCP_KEEPINTVL:
  5378		case TCP_KEEPCNT:
  5379		case TCP_SYNCNT:
  5380		case TCP_WINDOW_CLAMP:
  5381		case TCP_THIN_LINEAR_TIMEOUTS:
  5382		case TCP_USER_TIMEOUT:
  5383		case TCP_NOTSENT_LOWAT:
  5384		case TCP_SAVE_SYN:
> 5385		case TCP_RTO_MAX_MS:
  5386			if (*optlen != sizeof(int))
  5387				return -EINVAL;
  5388			break;
  5389		case TCP_CONGESTION:
  5390			return sol_tcp_sockopt_congestion(sk, optval, optlen, getopt);
  5391		case TCP_SAVED_SYN:
  5392			if (*optlen < 1)
  5393				return -EINVAL;
  5394			break;
  5395		case TCP_BPF_SOCK_OPS_CB_FLAGS:
  5396			if (*optlen != sizeof(int))
  5397				return -EINVAL;
  5398			if (getopt) {
  5399				struct tcp_sock *tp = tcp_sk(sk);
  5400				int cb_flags = tp->bpf_sock_ops_cb_flags;
  5401	
  5402				memcpy(optval, &cb_flags, *optlen);
  5403				return 0;
  5404			}
  5405			return bpf_sol_tcp_setsockopt(sk, optname, optval, *optlen);
  5406		default:
  5407			if (getopt)
  5408				return -EINVAL;
  5409			return bpf_sol_tcp_setsockopt(sk, optname, optval, *optlen);
  5410		}
  5411	
  5412		if (getopt) {
  5413			if (optname == TCP_SAVED_SYN) {
  5414				struct tcp_sock *tp = tcp_sk(sk);
  5415	
  5416				if (!tp->saved_syn ||
  5417				    *optlen > tcp_saved_syn_len(tp->saved_syn))
  5418					return -EINVAL;
  5419				memcpy(optval, tp->saved_syn->data, *optlen);
  5420				/* It cannot free tp->saved_syn here because it
  5421				 * does not know if the user space still needs it.
  5422				 */
  5423				return 0;
  5424			}
  5425	
  5426			return do_tcp_getsockopt(sk, SOL_TCP, optname,
  5427						 KERNEL_SOCKPTR(optval),
  5428						 KERNEL_SOCKPTR(optlen));
  5429		}
  5430	
  5431		return do_tcp_setsockopt(sk, SOL_TCP, optname,
  5432					 KERNEL_SOCKPTR(optval), *optlen);
  5433	}
  5434
Jason Xing Feb. 20, 2025, 8:57 a.m. UTC | #2
On Thu, Feb 20, 2025 at 4:52 PM kernel test robot <lkp@intel.com> wrote:
>
> Hi Jason,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on bpf-next/master]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Jason-Xing/bpf-support-TCP_RTO_MAX_MS-for-bpf_setsockopt/20250219-161637
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
> patch link:    https://lore.kernel.org/r/20250219081333.56378-2-kerneljasonxing%40gmail.com
> patch subject: [PATCH bpf-next v3 1/2] bpf: support TCP_RTO_MAX_MS for bpf_setsockopt
> config: x86_64-buildonly-randconfig-002-20250220 (https://download.01.org/0day-ci/archive/20250220/202502201843.xA1qZbKX-lkp@intel.com/config)
> compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250220/202502201843.xA1qZbKX-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/202502201843.xA1qZbKX-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
>    net/core/filter.c: In function 'sol_tcp_sockopt':
> >> net/core/filter.c:5385:14: error: 'TCP_RTO_MAX_MS' undeclared (first use in this function); did you mean 'TCP_RTO_MAX'?
>     5385 |         case TCP_RTO_MAX_MS:
>          |              ^~~~~~~~~~~~~~
>          |              TCP_RTO_MAX
>    net/core/filter.c:5385:14: note: each undeclared identifier is reported only once for each function it appears in

We've discussed this a few hours ago. It turned out to be the wrong
branch which this series applied to. Please try bpf-next net branch
instead :)

Thanks,
Jason
diff mbox series

Patch

diff --git a/net/core/filter.c b/net/core/filter.c
index 2ec162dd83c4..ffec7b4357f9 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -5382,6 +5382,7 @@  static int sol_tcp_sockopt(struct sock *sk, int optname,
 	case TCP_USER_TIMEOUT:
 	case TCP_NOTSENT_LOWAT:
 	case TCP_SAVE_SYN:
+	case TCP_RTO_MAX_MS:
 		if (*optlen != sizeof(int))
 			return -EINVAL;
 		break;