1. 24 Aug, 2018 1 commit
    • David S. Miller's avatar
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf · ff0fadff
      David S. Miller authored
      Daniel Borkmann says:
      
      ====================
      pull-request: bpf 2018-08-24
      
      The following pull-request contains BPF updates for your *net* tree.
      
      The main changes are:
      
      1) Fix BPF sockmap and tls where we get a hang in do_tcp_sendpages()
         when sndbuf is full due to missing calls into underlying socket's
         sk_write_space(), from John.
      
      2) Two BPF sockmap fixes to reject invalid parameters on map creation
         and to fix a map element miscount on allocation failure. Another fix
         for BPF hash tables to use per hash table salt for jhash(), from Daniel.
      
      3) Fix for bpftool's command line parsing in order to terminate on bad
         arguments instead of keeping looping in some border cases, from Quentin.
      
      4) Fix error value of xdp_umem_assign_dev() in order to comply with
         expected bind ops error codes, from Prashant.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ff0fadff
  2. 23 Aug, 2018 36 commits
  3. 22 Aug, 2018 3 commits
    • John Fastabend's avatar
      bpf: sockmap: write_space events need to be passed to TCP handler · 9b2e0388
      John Fastabend authored
      When sockmap code is using the stream parser it also handles the write
      space events in order to handle the case where (a) verdict redirects
      skb to another socket and (b) the sockmap then sends the skb but due
      to memory constraints (or other EAGAIN errors) needs to do a retry.
      
      But the initial code missed a third case where the
      skb_send_sock_locked() triggers an sk_wait_event(). A typically case
      would be when sndbuf size is exceeded. If this happens because we
      do not pass the write_space event to the lower layers we never wake
      up the event and it will wait for sndtimeo. Which as noted in ktls
      fix may be rather large and look like a hang to the user.
      
      To reproduce the best test is to reduce the sndbuf size and send
      1B data chunks to stress the memory handling. To fix this pass the
      event from the upper layer to the lower layer.
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      9b2e0388
    • John Fastabend's avatar
      tls: possible hang when do_tcp_sendpages hits sndbuf is full case · 67db7cd2
      John Fastabend authored
      Currently, the lower protocols sk_write_space handler is not called if
      TLS is sending a scatterlist via  tls_push_sg. However, normally
      tls_push_sg calls do_tcp_sendpage, which may be under memory pressure,
      that in turn may trigger a wait via sk_wait_event. Typically, this
      happens when the in-flight bytes exceed the sdnbuf size. In the normal
      case when enough ACKs are received sk_write_space() will be called and
      the sk_wait_event will be woken up allowing it to send more data
      and/or return to the user.
      
      But, in the TLS case because the sk_write_space() handler does not
      wake up the events the above send will wait until the sndtimeo is
      exceeded. By default this is MAX_SCHEDULE_TIMEOUT so it look like a
      hang to the user (especially this impatient user). To fix this pass
      the sk_write_space event to the lower layers sk_write_space event
      which in the TCP case will wake any pending events.
      
      I observed the above while integrating sockmap and ktls. It
      initially appeared as test_sockmap (modified to use ktls) occasionally
      hanging. To reliably reproduce this reduce the sndbuf size and stress
      the tls layer by sending many 1B sends. This results in every byte
      needing a header and each byte individually being sent to the crypto
      layer.
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: default avatarDave Watson <davejwatson@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      67db7cd2
    • Daniel Borkmann's avatar
      bpf, sockmap: fix sock hash count in alloc_sock_hash_elem · eb29429d
      Daniel Borkmann authored
      When we try to allocate a new sock hash entry and the allocation
      fails, then sock hash map fails to reduce the map element counter,
      meaning we keep accounting this element although it was never used.
      Fix it by dropping the element counter on error.
      
      Fixes: 81110384 ("bpf: sockmap, add hash map support")
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      eb29429d