mbox series

[bpf-next,v2,0/3] skmsg: Add the data length in skmsg to SIOCINQ ioctl and rx_queue

Message ID 1700565725-2706-1-git-send-email-yangpc@wangsu.com (mailing list archive)
Headers show
Series skmsg: Add the data length in skmsg to SIOCINQ ioctl and rx_queue | expand

Message

Pengcheng Yang Nov. 21, 2023, 11:22 a.m. UTC
When using skmsg redirect, the msg is queued in psock->ingress_msg,
and the application calling SIOCINQ ioctl will return a readable
length of 0, and we cannot track the data length of ingress_msg with
the ss tool.

In this patch set, we added the data length in ingress_msg to the 
SIOCINQ ioctl and the rx_queue of tcp_diag.

v2:
- Add READ_ONCE()/WRITE_ONCE() on accesses to psock->msg_len
- Mask out the increment msg_len where its not needed

Pengcheng Yang (3):
  skmsg: Support to get the data length in ingress_msg
  tcp: Add the data length in skmsg to SIOCINQ ioctl
  tcp_diag: Add the data length in skmsg to rx_queue

 include/linux/skmsg.h | 26 ++++++++++++++++++++++++--
 net/core/skmsg.c      | 10 +++++++++-
 net/ipv4/tcp.c        |  3 ++-
 net/ipv4/tcp_diag.c   |  2 ++
 4 files changed, 37 insertions(+), 4 deletions(-)

Comments

Daniel Borkmann Nov. 22, 2023, 3:16 p.m. UTC | #1
On 11/21/23 12:22 PM, Pengcheng Yang wrote:
> When using skmsg redirect, the msg is queued in psock->ingress_msg,
> and the application calling SIOCINQ ioctl will return a readable
> length of 0, and we cannot track the data length of ingress_msg with
> the ss tool.
> 
> In this patch set, we added the data length in ingress_msg to the
> SIOCINQ ioctl and the rx_queue of tcp_diag.
> 
> v2:
> - Add READ_ONCE()/WRITE_ONCE() on accesses to psock->msg_len
> - Mask out the increment msg_len where its not needed

Please double check BPF CI, this series might be breaking sockmap selftests :

https://github.com/kernel-patches/bpf/actions/runs/6922624338/job/18829650043

[...]
Notice: Success: 501/13458, Skipped: 57, Failed: 1
Error: #281 sockmap_basic
Error: #281/16 sockmap_basic/sockmap skb_verdict fionread
   Error: #281/16 sockmap_basic/sockmap skb_verdict fionread
   test_sockmap_skb_verdict_fionread:PASS:open_and_load 0 nsec
   test_sockmap_skb_verdict_fionread:PASS:bpf_prog_attach 0 nsec
   test_sockmap_skb_verdict_fionread:PASS:socket_loopback(s) 0 nsec
   test_sockmap_skb_verdict_fionread:PASS:create_socket_pairs(s) 0 nsec
   test_sockmap_skb_verdict_fionread:PASS:bpf_map_update_elem(c1) 0 nsec
   test_sockmap_skb_verdict_fionread:PASS:xsend(p0) 0 nsec
   test_sockmap_skb_verdict_fionread:PASS:ioctl(FIONREAD) error 0 nsec
   test_sockmap_skb_verdict_fionread:FAIL:ioctl(FIONREAD) unexpected ioctl(FIONREAD): actual 512 != expected 256
   test_sockmap_skb_verdict_fionread:PASS:recv_timeout(c0) 0 nsec
Error: #281/18 sockmap_basic/sockmap skb_verdict msg_f_peek
   Error: #281/18 sockmap_basic/sockmap skb_verdict msg_f_peek
   test_sockmap_skb_verdict_peek:PASS:open_and_load 0 nsec
   test_sockmap_skb_verdict_peek:PASS:bpf_prog_attach 0 nsec
   test_sockmap_skb_verdict_peek:PASS:socket_loopback(s) 0 nsec
   test_sockmap_skb_verdict_peek:PASS:create_pairs(s) 0 nsec
   test_sockmap_skb_verdict_peek:PASS:bpf_map_update_elem(c1) 0 nsec
   test_sockmap_skb_verdict_peek:PASS:xsend(p1) 0 nsec
   test_sockmap_skb_verdict_peek:PASS:recv(c1) 0 nsec
   test_sockmap_skb_verdict_peek:PASS:ioctl(FIONREAD) error 0 nsec
   test_sockmap_skb_verdict_peek:FAIL:after peek ioctl(FIONREAD) unexpected after peek ioctl(FIONREAD): actual 512 != expected 256
   test_sockmap_skb_verdict_peek:PASS:recv(p0) 0 nsec
   test_sockmap_skb_verdict_peek:PASS:ioctl(FIONREAD) error 0 nsec
   test_sockmap_skb_verdict_peek:PASS:after read ioctl(FIONREAD) 0 nsec
Test Results:
              bpftool: PASS
  test_progs-no_alu32: FAIL (returned 1)
             shutdown: CLEAN
Error: Process completed with exit code 1.
Pengcheng Yang Nov. 23, 2023, 11:20 a.m. UTC | #2
Daniel Borkmann <daniel@iogearbox.net> wrote:
> On 11/21/23 12:22 PM, Pengcheng Yang wrote:
> > When using skmsg redirect, the msg is queued in psock->ingress_msg,
> > and the application calling SIOCINQ ioctl will return a readable
> > length of 0, and we cannot track the data length of ingress_msg with
> > the ss tool.
> >
> > In this patch set, we added the data length in ingress_msg to the
> > SIOCINQ ioctl and the rx_queue of tcp_diag.
> >
> > v2:
> > - Add READ_ONCE()/WRITE_ONCE() on accesses to psock->msg_len
> > - Mask out the increment msg_len where its not needed
> 
> Please double check BPF CI, this series might be breaking sockmap selftests :
> 
> https://github.com/kernel-patches/bpf/actions/runs/6922624338/job/18829650043
> 

Is this a misunderstanding?
The selftests failure above were run on patch set v1 4 days ago, and this patch v2
is the fix for this case.

> [...]
> Notice: Success: 501/13458, Skipped: 57, Failed: 1
> Error: #281 sockmap_basic
> Error: #281/16 sockmap_basic/sockmap skb_verdict fionread
>    Error: #281/16 sockmap_basic/sockmap skb_verdict fionread
>    test_sockmap_skb_verdict_fionread:PASS:open_and_load 0 nsec
>    test_sockmap_skb_verdict_fionread:PASS:bpf_prog_attach 0 nsec
>    test_sockmap_skb_verdict_fionread:PASS:socket_loopback(s) 0 nsec
>    test_sockmap_skb_verdict_fionread:PASS:create_socket_pairs(s) 0 nsec
>    test_sockmap_skb_verdict_fionread:PASS:bpf_map_update_elem(c1) 0 nsec
>    test_sockmap_skb_verdict_fionread:PASS:xsend(p0) 0 nsec
>    test_sockmap_skb_verdict_fionread:PASS:ioctl(FIONREAD) error 0 nsec
>    test_sockmap_skb_verdict_fionread:FAIL:ioctl(FIONREAD) unexpected ioctl(FIONREAD): actual 512 != expected 256
>    test_sockmap_skb_verdict_fionread:PASS:recv_timeout(c0) 0 nsec
> Error: #281/18 sockmap_basic/sockmap skb_verdict msg_f_peek
>    Error: #281/18 sockmap_basic/sockmap skb_verdict msg_f_peek
>    test_sockmap_skb_verdict_peek:PASS:open_and_load 0 nsec
>    test_sockmap_skb_verdict_peek:PASS:bpf_prog_attach 0 nsec
>    test_sockmap_skb_verdict_peek:PASS:socket_loopback(s) 0 nsec
>    test_sockmap_skb_verdict_peek:PASS:create_pairs(s) 0 nsec
>    test_sockmap_skb_verdict_peek:PASS:bpf_map_update_elem(c1) 0 nsec
>    test_sockmap_skb_verdict_peek:PASS:xsend(p1) 0 nsec
>    test_sockmap_skb_verdict_peek:PASS:recv(c1) 0 nsec
>    test_sockmap_skb_verdict_peek:PASS:ioctl(FIONREAD) error 0 nsec
>    test_sockmap_skb_verdict_peek:FAIL:after peek ioctl(FIONREAD) unexpected after peek ioctl(FIONREAD): actual 512 != expected 256
>    test_sockmap_skb_verdict_peek:PASS:recv(p0) 0 nsec
>    test_sockmap_skb_verdict_peek:PASS:ioctl(FIONREAD) error 0 nsec
>    test_sockmap_skb_verdict_peek:PASS:after read ioctl(FIONREAD) 0 nsec
> Test Results:
>               bpftool: PASS
>   test_progs-no_alu32: FAIL (returned 1)
>              shutdown: CLEAN
> Error: Process completed with exit code 1.
Daniel Borkmann Nov. 23, 2023, 1:31 p.m. UTC | #3
On 11/23/23 12:20 PM, Pengcheng Yang wrote:
> Daniel Borkmann <daniel@iogearbox.net> wrote:
>> On 11/21/23 12:22 PM, Pengcheng Yang wrote:
>>> When using skmsg redirect, the msg is queued in psock->ingress_msg,
>>> and the application calling SIOCINQ ioctl will return a readable
>>> length of 0, and we cannot track the data length of ingress_msg with
>>> the ss tool.
>>>
>>> In this patch set, we added the data length in ingress_msg to the
>>> SIOCINQ ioctl and the rx_queue of tcp_diag.
>>>
>>> v2:
>>> - Add READ_ONCE()/WRITE_ONCE() on accesses to psock->msg_len
>>> - Mask out the increment msg_len where its not needed
>>
>> Please double check BPF CI, this series might be breaking sockmap selftests :
>>
>> https://github.com/kernel-patches/bpf/actions/runs/6922624338/job/18829650043
> 
> Is this a misunderstanding?
> The selftests failure above were run on patch set v1 4 days ago, and this patch v2
> is the fix for this case.

Indeed looks like there were two CI emails on v2 as well, one pointing to
failure (which was also linked from patchwork), and one to success, both
pointing to:
https://patchwork.kernel.org/project/netdevbpf/list/?series=802821&state=*
Let me rerun, meanwhile, I placed it back to 'under review'.