12 Dec, 2019

1 commit


15 Nov, 2019

7 commits

  • This patch adds 'module' member in the 'struct vsock_transport'
    in order to get/put the transport module. This prevents the
    module unloading while sockets are assigned to it.

    We increase the module refcnt when a socket is assigned to a
    transport, and we decrease the module refcnt when the socket
    is destructed.

    Reviewed-by: Stefan Hajnoczi
    Reviewed-by: Jorgen Hansen
    Signed-off-by: Stefano Garzarella
    Signed-off-by: David S. Miller

    Stefano Garzarella
     
  • This patch adds the support of multiple transports in the
    VSOCK core.

    With the multi-transports support, we can use vsock with nested VMs
    (using also different hypervisors) loading both guest->host and
    host->guest transports at the same time.

    Major changes:
    - vsock core module can be loaded regardless of the transports
    - vsock_core_init() and vsock_core_exit() are renamed to
    vsock_core_register() and vsock_core_unregister()
    - vsock_core_register() has a feature parameter (H2G, G2H, DGRAM)
    to identify which directions the transport can handle and if it's
    support DGRAM (only vmci)
    - each stream socket is assigned to a transport when the remote CID
    is set (during the connect() or when we receive a connection request
    on a listener socket).
    The remote CID is used to decide which transport to use:
    - remote CID host transport;
    - remote CID == local_cid (guest->host transport) will use guest->host
    transport for loopback (host->guest transports don't support loopback);
    - remote CID > VMADDR_CID_HOST will use host->guest transport;
    - listener sockets are not bound to any transports since no transport
    operations are done on it. In this way we can create a listener
    socket, also if the transports are not loaded or with VMADDR_CID_ANY
    to listen on all transports.
    - DGRAM sockets are handled as before, since only the vmci_transport
    provides this feature.

    Signed-off-by: Stefano Garzarella
    Signed-off-by: David S. Miller

    Stefano Garzarella
     
  • All transports call __vsock_create() with the same parameters,
    most of them depending on the parent socket. In order to simplify
    the VSOCK core APIs exposed to the transports, this patch adds
    the vsock_create_connected() callable from transports to create
    a new socket when a connection request is received.
    We also unexported the __vsock_create().

    Suggested-by: Stefan Hajnoczi
    Reviewed-by: Stefan Hajnoczi
    Reviewed-by: Jorgen Hansen
    Signed-off-by: Stefano Garzarella
    Signed-off-by: David S. Miller

    Stefano Garzarella
     
  • virtio_transport and vmci_transport handle the buffer_size
    sockopts in a very similar way.

    In order to support multiple transports, this patch moves this
    handling in the core to allow the user to change the options
    also if the socket is not yet assigned to any transport.

    This patch also adds the '.notify_buffer_size' callback in the
    'struct virtio_transport' in order to inform the transport,
    when the buffer_size is changed by the user. It is also useful
    to limit the 'buffer_size' requested (e.g. virtio transports).

    Acked-by: Dexuan Cui
    Reviewed-by: Stefan Hajnoczi
    Reviewed-by: Jorgen Hansen
    Signed-off-by: Stefano Garzarella
    Signed-off-by: David S. Miller

    Stefano Garzarella
     
  • Since now the 'struct vsock_sock' object contains a pointer to
    the transport, this patch adds a parameter to the
    vsock_core_get_transport() to return the right transport
    assigned to the socket.

    This patch modifies also the virtio_transport_get_ops(), that
    uses the vsock_core_get_transport(), adding the
    'struct vsock_sock *' parameter.

    Reviewed-by: Stefan Hajnoczi
    Reviewed-by: Jorgen Hansen
    Signed-off-by: Stefano Garzarella
    Signed-off-by: David S. Miller

    Stefano Garzarella
     
  • As a preparation to support multiple transports, this patch adds
    the 'transport' member at the 'struct vsock_sock'.
    This new field is initialized during the creation in the
    __vsock_create() function.

    This patch also renames the global 'transport' pointer to
    'transport_single', since for now we're only supporting a single
    transport registered at run-time.

    Reviewed-by: Stefan Hajnoczi
    Reviewed-by: Jorgen Hansen
    Signed-off-by: Stefano Garzarella
    Signed-off-by: David S. Miller

    Stefano Garzarella
     
  • This header file now only includes the "uapi/linux/vm_sockets.h".
    We can include directly it when needed.

    Reviewed-by: Stefan Hajnoczi
    Reviewed-by: Jorgen Hansen
    Signed-off-by: Stefano Garzarella
    Signed-off-by: David S. Miller

    Stefano Garzarella
     

05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation version 2 and no later version this
    program is distributed in the hope that it will be useful but
    without any warranty without even the implied warranty of
    merchantability or fitness for a particular purpose see the gnu
    general public license for more details

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 33 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Kate Stewart
    Reviewed-by: Alexios Zavras
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190530000435.345978407@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

08 Aug, 2018

1 commit

  • syzbot reported that we reinitialize an active delayed
    work in vsock_stream_connect():

    ODEBUG: init active (active state 0) object type: timer_list hint:
    delayed_work_timer_fn+0x0/0x90 kernel/workqueue.c:1414
    WARNING: CPU: 1 PID: 11518 at lib/debugobjects.c:329
    debug_print_object+0x16a/0x210 lib/debugobjects.c:326

    The pattern is apparently wrong, we should only initialize
    the dealyed work once and could repeatly schedule it. So we
    have to move out the initializations to allocation side.
    And to avoid confusion, we can split the shared dwork
    into two, instead of re-using the same one.

    Fixes: d021c344051a ("VSOCK: Introduce VM Sockets")
    Reported-by:
    Cc: Andy king
    Cc: Stefan Hajnoczi
    Cc: Jorgen Hansen
    Signed-off-by: Cong Wang
    Signed-off-by: David S. Miller

    Cong Wang
     

06 Oct, 2017

3 commits

  • There are two state fields: socket->state and sock->sk_state. The
    socket->state field uses SS_UNCONNECTED, SS_CONNECTED, etc while the
    sock->sk_state typically uses values that match TCP state constants
    (TCP_CLOSE, TCP_ESTABLISHED). AF_VSOCK does not follow this convention
    and instead uses SS_* constants for both fields.

    The sk_state field will be exposed to userspace through the vsock_diag
    interface for ss(8), netstat(8), and other programs.

    This patch switches sk_state to TCP state constants so that the meaning
    of this field is consistent with other address families. Not just
    AF_INET and AF_INET6 use the TCP constants, AF_UNIX and others do too.

    The following mapping was used to convert the code:

    SS_FREE -> TCP_CLOSE
    SS_UNCONNECTED -> TCP_CLOSE
    SS_CONNECTING -> TCP_SYN_SENT
    SS_CONNECTED -> TCP_ESTABLISHED
    SS_DISCONNECTING -> TCP_CLOSING
    VSOCK_SS_LISTEN -> TCP_LISTEN

    In __vsock_create() the sk_state initialization was dropped because
    sock_init_data() already initializes sk_state to TCP_CLOSE.

    Signed-off-by: Stefan Hajnoczi
    Signed-off-by: David S. Miller

    Stefan Hajnoczi
     
  • The vsock_diag.ko module will need to check socket table membership.

    Signed-off-by: Stefan Hajnoczi
    Signed-off-by: David S. Miller

    Stefan Hajnoczi
     
  • The socket table symbols need to be exported from vsock.ko so that the
    vsock_diag.ko module will be able to traverse sockets.

    Signed-off-by: Stefan Hajnoczi
    Signed-off-by: David S. Miller

    Stefan Hajnoczi
     

25 Apr, 2017

1 commit

  • Add tap functions that can be used by the vsock transports to
    deliver packets to vsockmon virtual network devices.

    Signed-off-by: Gerard Garcia
    Signed-off-by: Stefan Hajnoczi
    Reviewed-by: Jorgen Hansen
    Signed-off-by: David S. Miller

    Gerard Garcia
     

22 Mar, 2017

1 commit


02 Aug, 2016

3 commits

  • This module contains the common code and header files for the following
    virtio_transporto and vhost_vsock kernel modules.

    Signed-off-by: Asias He
    Signed-off-by: Claudio Imbrenda
    Signed-off-by: Stefan Hajnoczi
    Signed-off-by: Michael S. Tsirkin

    Asias He
     
  • The virtio transport will implement graceful shutdown and the related
    SO_LINGER socket option. This requires orphaning the sock but keeping
    it in the table of connections after .release().

    This patch adds the vsock_remove_sock() function and leaves it up to the
    transport when to remove the sock.

    Signed-off-by: Stefan Hajnoczi
    Signed-off-by: Michael S. Tsirkin

    Stefan Hajnoczi
     
  • struct vsock_transport contains function pointers called by AF_VSOCK
    core code. The transport may want its own transport-specific function
    pointers and they can be added after struct vsock_transport.

    Allow the transport to fetch vsock_transport. It can downcast it to
    access transport-specific function pointers.

    The virtio transport will use this.

    Signed-off-by: Stefan Hajnoczi
    Signed-off-by: Michael S. Tsirkin

    Stefan Hajnoczi
     

02 Nov, 2015

1 commit

  • The SS_LISTEN socket state is defined by both af_vsock.c and
    vmci_transport.c. This is risky since the value could be changed in one
    file and the other would be out of sync.

    Rename from SS_LISTEN to VSOCK_SS_LISTEN since the constant is not part
    of enum socket_state (SS_CONNECTED, ...). This way it is clear that the
    constant is vsock-specific.

    The big text reflow in af_vsock.c was necessary to keep to the maximum
    line length. Text is unchanged except for s/SS_LISTEN/VSOCK_SS_LISTEN/.

    Signed-off-by: Stefan Hajnoczi
    Signed-off-by: David S. Miller

    Stefan Hajnoczi
     

11 May, 2015

1 commit


03 Mar, 2015

1 commit

  • After TIPC doesn't depend on iocb argument in its internal
    implementations of sendmsg() and recvmsg() hooks defined in proto
    structure, no any user is using iocb argument in them at all now.
    Then we can drop the redundant iocb argument completely from kinds of
    implementations of both sendmsg() and recvmsg() in the entire
    networking stack.

    Cc: Christoph Hellwig
    Suggested-by: Al Viro
    Signed-off-by: Ying Xue
    Signed-off-by: David S. Miller

    Ying Xue
     

24 Nov, 2014

1 commit


06 May, 2014

1 commit

  • Right now the core vsock module is the owner of the proto family. This
    means there's nothing preventing the transport module from unloading if
    there are open sockets, which results in a panic. Fix that by allowing
    the transport to be the owner, which will refcount it properly.

    Includes version bump to 1.0.1.0-k

    Passes checkpatch this time, I swear...

    Acked-by: Dmitry Torokhov
    Signed-off-by: Andy King
    Signed-off-by: David S. Miller

    Andy King
     

28 Jul, 2013

1 commit