1. 17 Oct, 2018 2 commits
    • John Fastabend's avatar
      bpf: skmsg, improve sk_msg_used_element to work in cork context · 8734a162
      John Fastabend authored
      Currently sk_msg_used_element is only called in zerocopy context where
      cork is not possible and if this case happens we fallback to copy
      mode. However the helper is more useful if it works in all contexts.
      
      This patch resolved the case where if end == head indicating a full
      or empty ring the helper always reports an empty ring. To fix this
      add a test for the full ring case to avoid reporting a full ring
      has 0 elements. This additional functionality will be used in the
      next patches from recvmsg context where end = head with a full ring
      is a valid case.
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      8734a162
    • John Fastabend's avatar
      bpf: sockmap, fix skmsg recvmsg handler to track size correctly · 3f4c3127
      John Fastabend authored
      When converting sockmap to new skmsg generic data structures we missed
      that the recvmsg handler did not correctly use sg.size and instead was
      using individual elements length. The result is if a sock is closed
      with outstanding data we omit the call to sk_mem_uncharge() and can
      get the warning below.
      
      [   66.728282] WARNING: CPU: 6 PID: 5783 at net/core/stream.c:206 sk_stream_kill_queues+0x1fa/0x210
      
      To fix this correct the redirect handler to xfer the size along with
      the scatterlist and also decrement the size from the recvmsg handler.
      Now when a sock is closed the remaining 'size' will be decremented
      with sk_mem_uncharge().
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      3f4c3127
  2. 16 Oct, 2018 38 commits