From nobody Sat Jun 25 05:02:04 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7426585DEC2; Sat, 25 Jun 2022 05:02:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LVMKn1PZGz4Zg6; Sat, 25 Jun 2022 05:02:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656133325; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7B8brCP4XK0jX4kLQ0lPRK3VyiBhs4HgY4IGTKu6UjE=; b=E6f1dByzZEaNpWxTF3JtlKTfUxBmT5xfSon4GmSqQkl+ooyzlyO+kAn48qF+zZdSyJIvv6 TKXK4sJefiSzs/Czo8/y6Eo7AGICLxEer7J8CDfonwvAXIzpht8GLCRKUE9tmRjvQ/K0f5 L+V0tmfmIosDSvVHOz2o2bXAmnUp5rCabezAMvxr/CBLGb1kq+xMwc0NXl82IFp+e99P5Q RoypAU84LTyqKCuDLN2x89rab2GX+1yhLi7PRcn5e7YkuZ0wQwOyo5bm8TQk9r3oJQCDBm DAFZItEmIHfLYD51QlHjG4Ws8E7z904A6s27IlXihFGK6KELqVsAxBP/9PH9qQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0718D1E490; Sat, 25 Jun 2022 05:02:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25P524ao061125; Sat, 25 Jun 2022 05:02:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25P524MC061124; Sat, 25 Jun 2022 05:02:04 GMT (envelope-from git) Date: Sat, 25 Jun 2022 05:02:04 GMT Message-Id: <202206250502.25P524MC061124@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: db8710e2196c - stable/13 - struct kinfo_file changes needed for lsof to work using only usermode APIs` List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: db8710e2196c90a6310eada3b9cdd36d10689f74 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656133325; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7B8brCP4XK0jX4kLQ0lPRK3VyiBhs4HgY4IGTKu6UjE=; b=thr1pW/B/EmguUZZ1ne1LYnyzsvFtFIPWqTZn6Bra7rE/hfyaepWMrTH6IjjEjKup3sJWm cJ52419BS3KirmdVTeMo20ujqDQzH0utZuQl03hQ3DUbrpGk3/5StS5154h0gYayILlgtJ RPNigRaISujUuatRxC+LHDEvCrUyvXHWH7WB+FRIyCYEGGaJRQAKPdpN+82/bfoQ9jvCmV JZ1etIM+pPo5C7ESPJ7d5ZidGaWWVvCRktjiCdArj91CMRa/MmHEUUdqZmZTarx9Zpi02y XfNRThA/5hiFz9oROoS6uHFs6hUhCWzBAGWvN15Tq2XTMh0bdKp/rPMH2zmeNQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656133325; a=rsa-sha256; cv=none; b=Hl+7tqA9xNby6p1w5Dg9scUM57AxwH03HCbMg4AS/cCqkJNhtssAKUNsJWshOtjH1qnJ4K EL423e7OHU9gEwRw4OXwiDvnDE+W3my28gMCDFifxRU5HYOVJia0jL2Mqx5AQznLTK+c1i +vrhF/7V9voTodutO0qGK2Zeysxa88xtzoLEbJwdW0cBvNJxj/ftXp5Ak7lSJNqqNFb3N1 hubpxA+3mgDxZNigITrR4WlHM6JeWKAw0m8P6bUPd3iOtMLY1AVuLl8zJCa17sRJGHXuqF nGir2BysZ8O3q8Jk8kiK+nqZ1sxlNYTv1voVp3lJ4EJq+Ci/ATE3DcIq6fSoBA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=db8710e2196c90a6310eada3b9cdd36d10689f74 commit db8710e2196c90a6310eada3b9cdd36d10689f74 Author: Damjan Jovanovic AuthorDate: 2022-06-17 13:37:40 +0000 Commit: Konstantin Belousov CommitDate: 2022-06-24 19:37:33 +0000 struct kinfo_file changes needed for lsof to work using only usermode APIs` (cherry picked from commit 8c309d48aabf1cb469334c7716033f177a2715c0) --- sys/kern/kern_event.c | 4 ++++ sys/kern/sys_eventfd.c | 1 + sys/kern/sys_pipe.c | 3 +++ sys/kern/sys_socket.c | 22 ++++++++++++---------- sys/sys/user.h | 12 ++++++++++-- 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 10959685fdbd..90a725b6e0f0 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -2317,8 +2317,12 @@ kqueue_close(struct file *fp, struct thread *td) static int kqueue_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) { + struct kqueue *kq = fp->f_data; kif->kf_type = KF_TYPE_KQUEUE; + kif->kf_un.kf_kqueue.kf_kqueue_addr = (uintptr_t)kq; + kif->kf_un.kf_kqueue.kf_kqueue_count = kq->kq_count; + kif->kf_un.kf_kqueue.kf_kqueue_state = kq->kq_state; return (0); } diff --git a/sys/kern/sys_eventfd.c b/sys/kern/sys_eventfd.c index 91c045e85faf..d4aab88ab09d 100644 --- a/sys/kern/sys_eventfd.c +++ b/sys/kern/sys_eventfd.c @@ -342,6 +342,7 @@ eventfd_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp mtx_lock(&efd->efd_lock); kif->kf_un.kf_eventfd.kf_eventfd_value = efd->efd_count; kif->kf_un.kf_eventfd.kf_eventfd_flags = efd->efd_flags; + kif->kf_un.kf_eventfd.kf_eventfd_addr = (uintptr_t)efd; mtx_unlock(&efd->efd_lock); return (0); } diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index b19fe8dbc0c0..0e19bf8ae7b4 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -1591,6 +1591,9 @@ pipe_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) kif->kf_un.kf_pipe.kf_pipe_addr = (uintptr_t)pi; kif->kf_un.kf_pipe.kf_pipe_peer = (uintptr_t)pi->pipe_peer; kif->kf_un.kf_pipe.kf_pipe_buffer_cnt = pi->pipe_buffer.cnt; + kif->kf_un.kf_pipe.kf_pipe_buffer_in = pi->pipe_buffer.in; + kif->kf_un.kf_pipe.kf_pipe_buffer_out = pi->pipe_buffer.out; + kif->kf_un.kf_pipe.kf_pipe_buffer_size = pi->pipe_buffer.size; return (0); } diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index 8ac24a048093..f8857d3953d4 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -382,17 +382,19 @@ soo_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp) switch (kif->kf_un.kf_sock.kf_sock_domain0) { case AF_INET: case AF_INET6: - if (kif->kf_un.kf_sock.kf_sock_protocol0 == IPPROTO_TCP) { - if (so->so_pcb != NULL) { - inpcb = (struct inpcb *)(so->so_pcb); - kif->kf_un.kf_sock.kf_sock_inpcb = - (uintptr_t)inpcb->inp_ppcb; - kif->kf_un.kf_sock.kf_sock_sendq = - sbused(&so->so_snd); - kif->kf_un.kf_sock.kf_sock_recvq = - sbused(&so->so_rcv); - } + if (so->so_pcb != NULL) { + inpcb = (struct inpcb *)(so->so_pcb); + kif->kf_un.kf_sock.kf_sock_inpcb = + (uintptr_t)inpcb->inp_ppcb; } + kif->kf_un.kf_sock.kf_sock_rcv_sb_state = + so->so_rcv.sb_state; + kif->kf_un.kf_sock.kf_sock_snd_sb_state = + so->so_snd.sb_state; + kif->kf_un.kf_sock.kf_sock_sendq = + sbused(&so->so_snd); + kif->kf_un.kf_sock.kf_sock_recvq = + sbused(&so->so_rcv); break; case AF_UNIX: if (so->so_pcb != NULL) { diff --git a/sys/sys/user.h b/sys/sys/user.h index aa1b02ad6192..433e44c0f19e 100644 --- a/sys/sys/user.h +++ b/sys/sys/user.h @@ -420,8 +420,9 @@ struct kinfo_file { uint64_t kf_pipe_addr; uint64_t kf_pipe_peer; uint32_t kf_pipe_buffer_cnt; - /* Round to 64 bit alignment. */ - uint32_t kf_pipe_pad0[3]; + uint32_t kf_pipe_buffer_in; + uint32_t kf_pipe_buffer_out; + uint32_t kf_pipe_buffer_size; } kf_pipe; struct { uint32_t kf_spareint[4]; @@ -440,7 +441,14 @@ struct kinfo_file { struct { uint64_t kf_eventfd_value; uint32_t kf_eventfd_flags; + uint32_t kf_eventfd_spareint[3]; + uint64_t kf_eventfd_addr; } kf_eventfd; + struct { + uint64_t kf_kqueue_addr; + int32_t kf_kqueue_count; + int32_t kf_kqueue_state; + } kf_kqueue; } kf_un; }; uint16_t kf_status; /* Status flags. */