From patchwork Tue Oct 3 15:39:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 820921 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3y63BK0BJTz9sMN for ; Wed, 4 Oct 2017 02:39:53 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752418AbdJCPjv (ORCPT ); Tue, 3 Oct 2017 11:39:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19500 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752029AbdJCPju (ORCPT ); Tue, 3 Oct 2017 11:39:50 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC9F480480; Tue, 3 Oct 2017 15:39:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EC9F480480 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com Received: from localhost (ovpn-117-57.ams2.redhat.com [10.36.117.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id D251060E3A; Tue, 3 Oct 2017 15:39:46 +0000 (UTC) From: Stefan Hajnoczi To: netdev@vger.kernel.org Cc: Jorgen Hansen , Dexuan Cui , Stefan Hajnoczi Subject: [PATCH 0/5] VSOCK: add sock_diag interface Date: Tue, 3 Oct 2017 11:39:38 -0400 Message-Id: <20171003153943.23159-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 03 Oct 2017 15:39:50 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There is currently no way for userspace to query open AF_VSOCK sockets. This means ss(8), netstat(8), and other utilities cannot display AF_VSOCK sockets. This patch series adds the netlink sock_diag interface for AF_VSOCK. Userspace programs sent a DUMP request including an sk_state bitmap to filter sockets based on their state (connected, listening, etc). The vsock_diag.ko module replies with information about matching sockets. This userspace ABI is defined in . The final patch adds a test suite that exercises the basic cases. Jorgen and Dexuan: I have only tested the virtio transport but this should also work for VMCI and Hyper-V. Please give it a shot if you have time. Stefan Hajnoczi (5): VSOCK: export socket tables for sock_diag interface VSOCK: export __vsock_in_bound/connected_table() VSOCK: use TCP state constants for sk_state VSOCK: add sock_diag interface VSOCK: add tools/vsock/vsock_diag_test MAINTAINERS | 3 + net/vmw_vsock/Makefile | 3 + tools/vsock/Makefile | 9 + include/net/af_vsock.h | 10 +- include/uapi/linux/vm_sockets_diag.h | 33 ++ tools/vsock/control.h | 13 + tools/vsock/timeout.h | 14 + net/vmw_vsock/af_vsock.c | 62 ++- net/vmw_vsock/diag.c | 186 ++++++++ net/vmw_vsock/virtio_transport.c | 2 +- net/vmw_vsock/virtio_transport_common.c | 22 +- net/vmw_vsock/vmci_transport.c | 34 +- net/vmw_vsock/vmci_transport_notify.c | 2 +- net/vmw_vsock/vmci_transport_notify_qstate.c | 2 +- tools/vsock/control.c | 219 +++++++++ tools/vsock/timeout.c | 64 +++ tools/vsock/vsock_diag_test.c | 681 +++++++++++++++++++++++++++ net/vmw_vsock/Kconfig | 10 + tools/vsock/.gitignore | 2 + 19 files changed, 1312 insertions(+), 59 deletions(-) create mode 100644 tools/vsock/Makefile create mode 100644 include/uapi/linux/vm_sockets_diag.h create mode 100644 tools/vsock/control.h create mode 100644 tools/vsock/timeout.h create mode 100644 net/vmw_vsock/diag.c create mode 100644 tools/vsock/control.c create mode 100644 tools/vsock/timeout.c create mode 100644 tools/vsock/vsock_diag_test.c create mode 100644 tools/vsock/.gitignore