1. 17 Apr, 2016 15 commits
  2. 16 Apr, 2016 17 commits
  3. 15 Apr, 2016 8 commits
    • David S. Miller's avatar
      Merge branch 'sctp-diag' · 4e811b1e
      David S. Miller authored
      Xin Long says:
      
      ====================
      sctp: support sctp_diag in kernel
      
      This patchset will add sctp_diag module to implement diag interface on
      sctp in kernel.
      
      For a listening sctp endpoint, we will just dump it's ep info.
      For a sctp connection, we will the assoc info and it's ep info.
      
      The ss dump will looks like:
      
      [iproute2]# ./misc/ss --sctp  -n -l
      State      Recv-Q Send-Q   Local Address:Port       Peer Address:Port
      LISTEN     0      128      172.16.254.254:8888      *:*
      LISTEN     0      5        127.0.0.1:1234           *:*
      LISTEN     0      5        127.0.0.1:1234           *:*
        - ESTAB  0      0        127.0.0.1%lo:1234        127.0.0.1:4321
      LISTEN     0      128      172.16.254.254:8888      *:*
        - ESTAB  0      0        172.16.254.254%eth1:8888 172.16.253.253:8888
        - ESTAB  0      0        172.16.254.254%eth1:8888 172.16.1.1:8888
        - ESTAB  0      0        172.16.254.254%eth1:8888 172.16.1.2:8888
        - ESTAB  0      0        172.16.254.254%eth1:8888 172.16.2.1:8888
        - ESTAB  0      0        172.16.254.254%eth1:8888 172.16.2.2:8888
        - ESTAB  0      0        172.16.254.254%eth1:8888 172.16.3.1:8888
        - ESTAB  0      0        172.16.254.254%eth1:8888 172.16.3.2:8888
      LISTEN     0      0        127.0.0.1:4321           *:*
        - ESTAB  0      0        127.0.0.1%lo:4321        127.0.0.1:1234
      
      The entries with '- ESTAB' are the assocs, some of them may belong to
      the same endpoint. So we will dump the parent endpoint first, like the
      entry with 'LISTEN'. then dump the assocs. ep and assocs entries will
      be dumped in right order so that ss can show them in tree format easily.
      
      Besides, this patchset also simplifies sctp proc codes, cause it has
      some similar codes with sctp diag in sctp transport traversal.
      
      v1->v2:
        1. inet_diag_get_handler needs to return it as const.
        2. merge 5/7 into 2/7 of v1.
      
      v2->v3:
        do some improvements and fixes in patch 1-4, see the details in
        each patch's comment.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4e811b1e
    • Xin Long's avatar
      sctp: fix some rhashtable functions using in sctp proc/diag · 53fa1036
      Xin Long authored
      When rhashtable_walk_init return err, no release function should be
      called, and when rhashtable_walk_start return err, we should only invoke
      rhashtable_walk_exit to release the source.
      
      But now when sctp_transport_walk_start return err, we just call
      rhashtable_walk_stop/exit, and never care about if rhashtable_walk_init
      or start return err, which is so bad.
      
      We will fix it by calling rhashtable_walk_exit if rhashtable_walk_start
      return err in sctp_transport_walk_start, and if sctp_transport_walk_start
      return err, we do not need to call sctp_transport_walk_stop any more.
      
      For sctp proc, we will use 'iter->start_fail' to decide if we will call
      rhashtable_walk_stop/exit.
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      53fa1036
    • Xin Long's avatar
      sctp: merge the seq_start/next/exits in remaddrs and assocs · b5e2f4e6
      Xin Long authored
      In sctp proc, these three functions in remaddrs and assocs are the
      same. we should merge them into one.
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b5e2f4e6
    • Xin Long's avatar
      sctp: add the sctp_diag.c file · 8f840e47
      Xin Long authored
      This one will implement all the interface of inet_diag, inet_diag_handler.
      which includes sctp_diag_dump, sctp_diag_dump_one and sctp_diag_get_info.
      
      It will work as a module, and register inet_diag_handler when loading.
      
      v2->v3:
      - fix the mistake in inet_assoc_attr_size().
      
      - change inet_diag_msg_laddrs_fill() name to inet_diag_msg_sctpladdrs_fill.
      
      - change inet_diag_msg_paddrs_fill() name to inet_diag_msg_sctpaddrs_fill.
      
      - add inet_diag_msg_sctpinfo_fill() to make asoc/ep fill code clearer.
      
      - add inet_diag_msg_sctpasoc_fill() to make asoc fill code clearer.
      
      - merge inet_asoc_diag_fill() and inet_ep_diag_fill() to
        inet_sctp_diag_fill().
      
      - call sctp_diag_get_info() directly, instead by handler, cause the caller
        is in the same file with it.
      
      - call lock_sock in sctp_tsp_dump_one() to make sure we call get sctp info
        safely.
      
      - after lock_sock(sk), we should check sk != assoc->base.sk.
      
      - change mem[SK_MEMINFO_WMEM_ALLOC] to asoc->sndbuf_used for asoc dump when
        asoc->ep->sndbuf_policy is set. don't use INET_DIAG_MEMINFO attr any more.
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8f840e47
    • Xin Long's avatar
      sctp: export some functions for sctp_diag in inet_diag · cb2050a7
      Xin Long authored
      inet_diag_msg_common_fill is used to fill the diag msg common info,
      we need to use it in sctp_diag as well, so export it.
      
      inet_diag_msg_attrs_fill is used to fill some common attrs info between
      sctp diag and tcp diag.
      
      v2->v3:
      - do not need to define and export inet_diag_get_handler any more.
        cause all the functions in it are in sctp_diag.ko, we just call
        them in sctp_diag.ko.
      
      - add inet_diag_msg_attrs_fill to make codes clear.
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      cb2050a7
    • Xin Long's avatar
      sctp: export some apis or variables for sctp_diag and reuse some for proc · 626d16f5
      Xin Long authored
      For some main variables in sctp.ko, we couldn't export it to other modules,
      so we have to define some api to access them.
      
      It will include sctp transport and endpoint's traversal.
      
      There are some transport traversal functions for sctp_diag, we can also
      use it for sctp_proc. cause they have the similar situation to traversal
      transport.
      
      v2->v3:
      - rhashtable_walk_init need the parameter gfp, because of recent upstrem
        update
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      626d16f5
    • Xin Long's avatar
      sctp: add sctp_info dump api for sctp_diag · 52c52a61
      Xin Long authored
      sctp_diag will dump some important details of sctp's assoc or ep, we use
      sctp_info to describe them,  sctp_get_sctp_info to get them, and export
      it to sctp_diag.ko.
      
      v2->v3:
      - we will not use list_for_each_safe in sctp_get_sctp_info, cause
        all the callers of it will use lock_sock.
      
      - fix the holes in struct sctp_info with __reserved* field.
        because sctp_diag is a new feature, and sctp_info is just for now,
        it may be changed in the future.
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      52c52a61
    • Marcelo Ricardo Leitner's avatar
      sctp: simplify sk_receive_queue locking · 311b2177
      Marcelo Ricardo Leitner authored
      SCTP already serializes access to rcvbuf through its sock lock:
      sctp_recvmsg takes it right in the start and release at the end, while
      rx path will also take the lock before doing any socket processing. On
      sctp_rcv() it will check if there is an user using the socket and, if
      there is, it will queue incoming packets to the backlog. The backlog
      processing will do the same. Even timers will do such check and
      re-schedule if an user is using the socket.
      
      Simplifying this will allow us to remove sctp_skb_list_tail and get ride
      of some expensive lockings.  The lists that it is used on are also
      mangled with functions like __skb_queue_tail and __skb_unlink in the
      same context, like on sctp_ulpq_tail_event() and sctp_clear_pd().
      sctp_close() will also purge those while using only the sock lock.
      
      Therefore the lockings performed by sctp_skb_list_tail() are not
      necessary. This patch removes this function and replaces its calls with
      just skb_queue_splice_tail_init() instead.
      
      The biggest gain is at sctp_ulpq_tail_event(), because the events always
      contain a list, even if it's queueing a single skb and this was
      triggering expensive calls to spin_lock_irqsave/_irqrestore for every
      data chunk received.
      
      As SCTP will deliver each data chunk on a corresponding recvmsg, the
      more effective the change will be.
      Before this patch, with chunks with 30 bytes:
      netperf -t SCTP_STREAM -H 192.168.1.2 -cC -l 60 -- -m 30 -S 400000
      400000 -s 400000 400000
      on a 10Gbit link with 1500 MTU:
      
      SCTP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.1.1 () port 0 AF_INET
      Recv   Send    Send                          Utilization       Service Demand
      Socket Socket  Message  Elapsed              Send     Recv     Send    Recv
      Size   Size    Size     Time     Throughput  local    remote   local   remote
      bytes  bytes   bytes    secs.    10^6bits/s  % S      % S      us/KB   us/KB
      
      425984 425984     30    60.00       137.45   7.34     7.36     52.504  52.608
      
      With it:
      
      SCTP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.1.1 () port 0 AF_INET
      Recv   Send    Send                          Utilization       Service Demand
      Socket Socket  Message  Elapsed              Send     Recv     Send    Recv
      Size   Size    Size     Time     Throughput  local    remote   local   remote
      bytes  bytes   bytes    secs.    10^6bits/s  % S      % S      us/KB   us/KB
      
      425984 425984     30    60.00       179.10   7.97     6.70     43.740  36.788
      Signed-off-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      311b2177