Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F136758986
D46413.id143202.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D46413.id143202.diff
View Options
diff --git a/usr.bin/sockstat/sockstat.1 b/usr.bin/sockstat/sockstat.1
--- a/usr.bin/sockstat/sockstat.1
+++ b/usr.bin/sockstat/sockstat.1
@@ -25,7 +25,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd June 6, 2022
+.Dd July 9, 2024
.Dt SOCKSTAT 1
.Os
.Sh NAME
@@ -33,7 +33,7 @@
.Nd list open sockets
.Sh SYNOPSIS
.Nm
-.Op Fl 46CciLlnqSsUuvw
+.Op Fl 46CcIiLlnqSsUuvw
.Op Fl j Ar jail
.Op Fl p Ar ports
.Op Fl P Ar protocols
@@ -59,6 +59,13 @@
This is currently only implemented for TCP.
.It Fl c
Show connected sockets.
+.It Fl I
+Show the local address of the socket to which the current socket is spliced, if
+any.
+See the
+.Xr setsockopt 2
+.Dv SO_SPLICE
+option for more information.
.It Fl i
Display the
.Dv inp_gencnt .
diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c
--- a/usr.bin/sockstat/sockstat.c
+++ b/usr.bin/sockstat/sockstat.c
@@ -82,6 +82,7 @@
static int opt_6; /* Show IPv6 sockets */
static int opt_C; /* Show congestion control */
static int opt_c; /* Show connected sockets */
+static int opt_I; /* Show spliced socket addresses */
static int opt_i; /* Show inp_gencnt */
static int opt_j; /* Show specified jail */
static int opt_L; /* Don't show IPv4 or IPv6 loopback sockets */
@@ -132,6 +133,7 @@
RB_ENTRY(sock) pcb_tree;
kvaddr_t socket;
kvaddr_t pcb;
+ kvaddr_t splice_socket;
uint64_t inp_gencnt;
int shown;
int vflag;
@@ -766,6 +768,7 @@
if ((faddr = calloc(1, sizeof *faddr)) == NULL)
err(1, "malloc()");
sock->socket = so->xso_so;
+ sock->splice_socket = so->so_splice_so;
sock->proto = proto;
sock->inp_gencnt = xip->inp_gencnt;
if (xip->inp_vflag & INP_IPV4) {
@@ -1201,6 +1204,25 @@
default:
abort();
}
+ if (opt_I) {
+ if (s->splice_socket != 0) {
+ struct sock *sp;
+
+ sp = RB_FIND(socks_t, &socks, &(struct sock)
+ { .socket = s->splice_socket });
+ if (sp != NULL) {
+ while (pos < offset)
+ pos += xprintf(" ");
+ pos += printaddr(&sp->laddr->address);
+ } else {
+ while (pos < offset)
+ pos += xprintf(" ");
+ pos += xprintf("??");
+ offset += opt_w ? 46 : 22;
+ }
+ }
+ offset += opt_w ? 46 : 22;
+ }
if (opt_i) {
if (s->proto == IPPROTO_TCP ||
s->proto == IPPROTO_UDP) {
@@ -1307,6 +1329,8 @@
"USER", "COMMAND", "PID", "FD", "PROTO",
opt_w ? 45 : 21, "LOCAL ADDRESS",
opt_w ? 45 : 21, "FOREIGN ADDRESS");
+ if (opt_I)
+ printf(" %-*s", opt_w ? 45 : 21, "SPLICE ADDRESS");
if (opt_i)
printf(" %-8s", "ID");
if (opt_U)
@@ -1430,7 +1454,7 @@
usage(void)
{
fprintf(stderr,
- "usage: sockstat [-46CciLlnqSsUuvw] [-j jid] [-p ports] [-P protocols]\n");
+ "usage: sockstat [-46CcIiLlnqSsUuvw] [-j jid] [-p ports] [-P protocols]\n");
exit(1);
}
@@ -1445,7 +1469,7 @@
int o, i;
opt_j = -1;
- while ((o = getopt(argc, argv, "46Ccij:Llnp:P:qSsUuvw")) != -1)
+ while ((o = getopt(argc, argv, "46CcIij:Llnp:P:qSsUuvw")) != -1)
switch (o) {
case '4':
opt_4 = 1;
@@ -1459,6 +1483,9 @@
case 'c':
opt_c = 1;
break;
+ case 'I':
+ opt_I = 1;
+ break;
case 'i':
opt_i = 1;
break;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 20, 8:02 AM (7 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25715771
Default Alt Text
D46413.id143202.diff (3 KB)
Attached To
Mode
D46413: sockstat: Show the address of the spliced socket when -I is specified
Attached
Detach File
Event Timeline
Log In to Comment