diff mbox series

bpf, sockmap: Use sk_rmem_schedule in bpf_tcp_ingress

Message ID ae2569fa-f34a-40d6-9a03-33a455fbb9ea@chinatelecom.cn (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series bpf, sockmap: Use sk_rmem_schedule in bpf_tcp_ingress | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-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: 842 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 4 maintainers not CCed: dsahern@kernel.org kuba@kernel.org edumazet@google.com pabeni@redhat.com
netdev/build_clang fail Errors and warnings before: 849 this patch: 16
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: 851 this patch: 16
netdev/checkpatch warning WARNING: From:/Signed-off-by: email name mismatch: 'From: zhengguoyong <zhenggy@chinatelecom.cn>' != 'Signed-off-by: GuoYong Zheng <zhenggy@chinatelecom.cn>'
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

zhengguoyong July 4, 2024, 4:39 a.m. UTC
In sockmap redirect mode, when msg send to redir sk,
we use sk_wrmem_schedule to check memory is enough,

    tcp_bpf_sendmsg
        tcp_bpf_send_verdict
            bpf_tcp_ingress
                sk_wmem_schedule

but in bpf_tcp_ingress, the parameter sk means receiver,
so use sk_rmem_schedule here is more suitability.

Signed-off-by: GuoYong Zheng <zhenggy@chinatelecom.cn>
---
 net/ipv4/tcp_bpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michal Kubiak July 4, 2024, 2:38 p.m. UTC | #1
On Thu, Jul 04, 2024 at 12:39:01PM +0800, zhengguoyong wrote:
> In sockmap redirect mode, when msg send to redir sk,
> we use sk_wrmem_schedule to check memory is enough,
> 
>     tcp_bpf_sendmsg
>         tcp_bpf_send_verdict
>             bpf_tcp_ingress
>                 sk_wmem_schedule
> 
> but in bpf_tcp_ingress, the parameter sk means receiver,
> so use sk_rmem_schedule here is more suitability.
> 
> Signed-off-by: GuoYong Zheng <zhenggy@chinatelecom.cn>
> ---
>  net/ipv4/tcp_bpf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
> index 53b0d62..88c58b5 100644
> --- a/net/ipv4/tcp_bpf.c
> +++ b/net/ipv4/tcp_bpf.c
> @@ -49,7 +49,7 @@ static int bpf_tcp_ingress(struct sock *sk, struct sk_psock *psock,
>  		sge = sk_msg_elem(msg, i);
>  		size = (apply && apply_bytes < sge->length) ?
>  			apply_bytes : sge->length;
> -		if (!sk_wmem_schedule(sk, size)) {
> +		if (!sk_rmem_schedule(sk, size)) {
>  			if (!copied)
>  				ret = -ENOMEM;
>  			break;
> -- 
> 1.8.3.1
> 
> 

From the commit message I'm not really sure about the intention of this
patch, however it seems the existing kernel implementation is correct.
Changing sk_wmem_schedule -> sk_rmem_schedule breaks the kernel compilation
because those 2 functions even have different input parameters.

Please see the Patchwork results for details:
https://patchwork.kernel.org/project/netdevbpf/patch/ae2569fa-f34a-40d6-9a03-33a455fbb9ea@chinatelecom.cn/

Thanks,
Michal

Nacked-by: Michal Kubiak <michal.kubiak@intel.com>
diff mbox series

Patch

diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index 53b0d62..88c58b5 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -49,7 +49,7 @@  static int bpf_tcp_ingress(struct sock *sk, struct sk_psock *psock,
 		sge = sk_msg_elem(msg, i);
 		size = (apply && apply_bytes < sge->length) ?
 			apply_bytes : sge->length;
-		if (!sk_wmem_schedule(sk, size)) {
+		if (!sk_rmem_schedule(sk, size)) {
 			if (!copied)
 				ret = -ENOMEM;
 			break;