mptcp: add SIOCINQ, OUTQ and OUTQNSD ioctls
A message that is not in the archive (sent off-list or not yet received): [email protected]
Whoops, I omitted the ML in my reply, sorry...
@Florian: sorry for the dups! please reply to this one, if needed, to re-include properly the ML into the thread.
Quoted 13 lines · Florian Westphal
Quoted 11 lines · Paolo Abeni
Review
Quoted 7 lines
(quoted diff) +7
-0+ if (sk->sk_state == TCP_LISTEN) + return -EINVAL; + + if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) + return 0; + + delta = READ_ONCE(msk->write_seq) - v;This is under the msk socket lock and
write_seqis protected by the full/plain msk socket lock soREAD_ONCEshould not be necessary, I think. The same for 'snd_nxt' below.
Quoted 1 line
Then why is
write_sequpdated withWRITE_ONCEin lots of places?
'write_seq' is read outside the msk socket lock scope in a few places.
My understanding is that to avoid reces and ubsan splat we need to mark each write with WRITE_ONCE, and read outside the socket lock with READ_ONCE.
If all the write happens under the socket lock, read under the socket lock don't need the _ONCE annotation. My reference is:
https://marc.info/?l=linux-netdev&m=161198643714502&w=2
Feel free to correct me if I'm wrong!
BTW this always reports '1' on fallback sockets after shutdown, as after shutdown write_seq is incremented by 1, but snd_una/snd_nxt are not incremented when receiving the TCP fin. I guess the fix not strictly related to this patch.
Cheers,
Paolo
Quoted 19 lines · Paolo Abeni
Whoops, I omitted the ML in my reply, sorry...
@Florian: sorry for the dups! please reply to this one, if needed, to re-include properly the ML into the thread.
Quoted 13 lines · Florian Westphal
Quoted 11 lines · Paolo Abeni
Review
Quoted 7 lines
(quoted diff) +7
-0+ if (sk->sk_state == TCP_LISTEN) + return -EINVAL; + + if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) + return 0; + + delta = READ_ONCE(msk->write_seq) - v;This is under the msk socket lock and
write_seqis protected by the full/plain msk socket lock soREAD_ONCEshould not be necessary, I think. The same for 'snd_nxt' below.
Quoted 3 lines
Quoted 1 line
Then why is
write_sequpdated withWRITE_ONCEin lots of places?'
write_seq' is read outside the msk socket lock scope in a few places.
Bah. You are right. TBH I do not understand READ|WRITE_ONCE usage in mptcp anymore. Maybe its correct, who knows.
The different locking schemes are not easy to follow for me.
Quoted 4 lines
BTW this always reports '1' on fallback sockets after shutdown, as after shutdown
write_seqis incremented by 1, but snd_una/snd_nxt are not incremented when receiving the TCP fin. I guess the fix not strictly related to this patch.
That should be ok, we should return nonzero inq hint when next read() would indicate EOF.
Quoted 20 lines · Florian Westphal
Quoted 19 lines · Paolo Abeni
Whoops, I omitted the ML in my reply, sorry...
@Florian: sorry for the dups! please reply to this one, if needed, to re-include properly the ML into the thread.
Quoted 13 lines · Florian Westphal
Quoted 11 lines · Paolo Abeni
Review
Quoted 7 lines
(quoted diff) +7
-0+ if (sk->sk_state == TCP_LISTEN) + return -EINVAL; + + if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) + return 0; + + delta = READ_ONCE(msk->write_seq) - v;This is under the msk socket lock and
write_seqis protected by the full/plain msk socket lock soREAD_ONCEshould not be necessary, I think. The same for 'snd_nxt' below.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Then why is
write_sequpdated withWRITE_ONCEin lots of places?'
write_seq' is read outside the msk socket lock scope in a few places.Bah. You are right. TBH I do not understand READ|WRITE_ONCE usage in mptcp anymore. Maybe its correct, who knows.
The different locking schemes are not easy to follow for me.
Indeed I agreed!
I *think* (mostly guess) some _ONCE() annotation are now obsoleted/made unnecessary by the several re-factors.
For sure we need to document clarely the locking schema (where? how? would comments on the protectect fields suffice?) and possibly/likely review the current annotations.
Quoted 7 lines
Quoted 4 lines
BTW this always reports '1' on fallback sockets after shutdown, as after shutdown
write_seqis incremented by 1, but snd_una/snd_nxt are not incremented when receiving the TCP fin. I guess the fix not strictly related to this patch.That should be ok, we should return nonzero inq hint when next
read()would indicate EOF.
This is for the outq ?!? I think it should be 0 after all outstanding data is acked ?!?
Thanks!
Paolo
Quoted 5 lines · Paolo Abeni
Quoted 4 lines
Bah. You are right. TBH I do not understand READ|WRITE_ONCE usage in mptcp anymore. Maybe its correct, who knows.
The different locking schemes are not easy to follow for me.
Quoted 8 lines
Indeed I agreed!
I *think* (mostly guess) some
_ONCE()annotation are now obsoleted/made unnecessary by the several re-factors.For sure we need to document clarely the locking schema (where? how? would comments on the protectect fields suffice?) and possibly/likely review the current annotations.
I think adding comments in the mptcp_sock struct would be a great start.
Quoted 10 lines
Quoted 7 lines
Quoted 4 lines
BTW this always reports '1' on fallback sockets after shutdown, as after shutdown
write_seqis incremented by 1, but snd_una/snd_nxt are not incremented when receiving the TCP fin. I guess the fix not strictly related to this patch.That should be ok, we should return nonzero inq hint when next
read()would indicate EOF.This is for the outq ?!? I think it should be 0 after all outstanding data is acked ?!?
Oh, I misread it as inq.