mbox series

[net-next,0/3] sctp: add support for sk_reuseport

Message ID cover.1540095102.git.lucien.xin@gmail.com
Headers show
Series sctp: add support for sk_reuseport | expand

Message

Xin Long Oct. 21, 2018, 4:43 a.m. UTC
sctp sk_reuseport allows multiple socks to listen on the same port and
addresses, as long as these socks have the same uid. This works pretty
much as TCP/UDP does, the only difference is that sctp is multi-homing
and all the bind_addrs in these socks will have to completely matched,
otherwise listen() will return err.

The below is when 5 sockets are listening on 172.16.254.254:6400 on a
server, 26 sockets on a client connect to 172.16.254.254:6400 and each
may be processed by a different socket on the server which is selected
by hash(lport, pport, paddr) in reuseport_select_sock():

 # ss --sctp -nn
   State      Recv-Q Send-Q        Local Address:Port     Peer Address:Port
   LISTEN     0      10           172.16.254.254:6400                *:*
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.2.1:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.2.4:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.3.3:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.3.4:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.5.2:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.5.3:1234
   LISTEN     0      10           172.16.254.254:6400                *:*
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.1.3:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.1.4:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.3.2:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.4.1:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.4.2:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.4.3:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.4.4:1234
   LISTEN     0      10           172.16.254.254:6400                *:*
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.1.2:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.3.5:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.4.5:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400   172.16.253.253:1234
   LISTEN     0      10           172.16.254.254:6400                *:*
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.2.2:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.2.3:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.5.4:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.5.5:1234
   LISTEN     0      10           172.16.254.254:6400                *:*
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.1.1:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.1.5:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.2.5:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.3.1:1234
   `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.5.1:1234

Xin Long (3):
  sctp: do reuseport_select_sock in __sctp_rcv_lookup_endpoint
  sctp: add sock_reuseport for the sock in __sctp_hash_endpoint
  sctp: process sk_reuseport in sctp_get_port_local

 include/net/sctp/sctp.h    |   2 +-
 include/net/sctp/structs.h |   6 ++-
 net/core/sock_reuseport.c  |   1 +
 net/sctp/bind_addr.c       |  28 ++++++++++
 net/sctp/input.c           | 129 ++++++++++++++++++++++++++++++++-------------
 net/sctp/socket.c          |  49 +++++++++++------
 6 files changed, 162 insertions(+), 53 deletions(-)

Comments

Xin Long Oct. 21, 2018, 6:58 a.m. UTC | #1
On Sun, Oct 21, 2018 at 1:43 PM Xin Long <lucien.xin@gmail.com> wrote:
>
> sctp sk_reuseport allows multiple socks to listen on the same port and
> addresses, as long as these socks have the same uid. This works pretty
> much as TCP/UDP does, the only difference is that sctp is multi-homing
> and all the bind_addrs in these socks will have to completely matched,
> otherwise listen() will return err.
>
> The below is when 5 sockets are listening on 172.16.254.254:6400 on a
> server, 26 sockets on a client connect to 172.16.254.254:6400 and each
> may be processed by a different socket on the server which is selected
> by hash(lport, pport, paddr) in reuseport_select_sock():
>
>  # ss --sctp -nn
>    State      Recv-Q Send-Q        Local Address:Port     Peer Address:Port
>    LISTEN     0      10           172.16.254.254:6400                *:*
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.2.1:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.2.4:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.3.3:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.3.4:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.5.2:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.5.3:1234
>    LISTEN     0      10           172.16.254.254:6400                *:*
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.1.3:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.1.4:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.3.2:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.4.1:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.4.2:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.4.3:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.4.4:1234
>    LISTEN     0      10           172.16.254.254:6400                *:*
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.1.2:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.3.5:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.4.5:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400   172.16.253.253:1234
>    LISTEN     0      10           172.16.254.254:6400                *:*
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.2.2:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.2.3:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.5.4:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.5.5:1234
>    LISTEN     0      10           172.16.254.254:6400                *:*
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.1.1:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.1.5:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.2.5:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.3.1:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.5.1:1234
Attached is the testcase based on sctp-tests.git.

>
> Xin Long (3):
>   sctp: do reuseport_select_sock in __sctp_rcv_lookup_endpoint
>   sctp: add sock_reuseport for the sock in __sctp_hash_endpoint
>   sctp: process sk_reuseport in sctp_get_port_local
>
>  include/net/sctp/sctp.h    |   2 +-
>  include/net/sctp/structs.h |   6 ++-
>  net/core/sock_reuseport.c  |   1 +
>  net/sctp/bind_addr.c       |  28 ++++++++++
>  net/sctp/input.c           | 129 ++++++++++++++++++++++++++++++++-------------
>  net/sctp/socket.c          |  49 +++++++++++------
>  6 files changed, 162 insertions(+), 53 deletions(-)
>
> --
> 2.1.0
>
Neil Horman Oct. 22, 2018, 11:40 a.m. UTC | #2
On Sun, Oct 21, 2018 at 12:43:35PM +0800, Xin Long wrote:
> sctp sk_reuseport allows multiple socks to listen on the same port and
> addresses, as long as these socks have the same uid. This works pretty
> much as TCP/UDP does, the only difference is that sctp is multi-homing
> and all the bind_addrs in these socks will have to completely matched,
> otherwise listen() will return err.
> 
> The below is when 5 sockets are listening on 172.16.254.254:6400 on a
> server, 26 sockets on a client connect to 172.16.254.254:6400 and each
> may be processed by a different socket on the server which is selected
> by hash(lport, pport, paddr) in reuseport_select_sock():
> 
>  # ss --sctp -nn
>    State      Recv-Q Send-Q        Local Address:Port     Peer Address:Port
>    LISTEN     0      10           172.16.254.254:6400                *:*
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.2.1:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.2.4:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.3.3:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.3.4:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.5.2:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.5.3:1234
>    LISTEN     0      10           172.16.254.254:6400                *:*
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.1.3:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.1.4:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.3.2:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.4.1:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.4.2:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.4.3:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.4.4:1234
>    LISTEN     0      10           172.16.254.254:6400                *:*
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.1.2:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.3.5:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.4.5:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400   172.16.253.253:1234
>    LISTEN     0      10           172.16.254.254:6400                *:*
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.2.2:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.2.3:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.5.4:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.5.5:1234
>    LISTEN     0      10           172.16.254.254:6400                *:*
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.1.1:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.1.5:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.2.5:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.3.1:1234
>    `- ESTAB   0      0       172.16.254.254%eth1:6400       172.16.5.1:1234
> 
> Xin Long (3):
>   sctp: do reuseport_select_sock in __sctp_rcv_lookup_endpoint
>   sctp: add sock_reuseport for the sock in __sctp_hash_endpoint
>   sctp: process sk_reuseport in sctp_get_port_local
> 
>  include/net/sctp/sctp.h    |   2 +-
>  include/net/sctp/structs.h |   6 ++-
>  net/core/sock_reuseport.c  |   1 +
>  net/sctp/bind_addr.c       |  28 ++++++++++
>  net/sctp/input.c           | 129 ++++++++++++++++++++++++++++++++-------------
>  net/sctp/socket.c          |  49 +++++++++++------
>  6 files changed, 162 insertions(+), 53 deletions(-)
> 
> -- 
> 2.1.0
> 
> 
Series
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Marcelo Ricardo Leitner Oct. 22, 2018, 2:20 p.m. UTC | #3
On Sun, Oct 21, 2018 at 12:43:35PM +0800, Xin Long wrote:
> sctp sk_reuseport allows multiple socks to listen on the same port and
> addresses, as long as these socks have the same uid. This works pretty
> much as TCP/UDP does, the only difference is that sctp is multi-homing
> and all the bind_addrs in these socks will have to completely matched,
> otherwise listen() will return err.
> 

FWIW, I won't be able to review this patchset thoroughly. The 2 small
comments that I sent are all I have.

Thanks,
Marcelo