Thread (24 messages) 24 messages, 3 authors, 2021-05-18

Re: [Patch bpf-next v3 02/10] af_unix: implement ->read_sock() for sockmap

From: John Fastabend <john.fastabend@gmail.com>
Date: 2021-05-18 05:11:32
Also in: netdev

Cong Wang wrote:
On Mon, May 10, 2021 at 10:34 PM John Fastabend
[off-list ref] wrote:
quoted
quoted
+static int unix_read_sock(struct sock *sk, read_descriptor_t *desc,
+                       sk_read_actor_t recv_actor)
+{
+     int copied = 0;
+
+     while (1) {
+             struct unix_sock *u = unix_sk(sk);
+             struct sk_buff *skb;
+             int used, err;
+
+             mutex_lock(&u->iolock);
+             skb = skb_recv_datagram(sk, 0, 1, &err);
+             if (!skb) {
+                     mutex_unlock(&u->iolock);
+                     return err;
Here we should check copied and break if copied is >0. Sure the caller here
has desc.count = 1 but its still fairly fragile.
Technically, sockmap does not even care about what we return
here, so I am sure what you suggest here even makes a difference.
Also, desc->count is always 1 and never changes here.
Right, so either don't wrap it in a while() loop so its obviously
not workable or fix it so that it returns the correct copied value if
we ever did pass it count > 1.. 
Thanks.
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help