Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144554650
D52944.1775423030.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D52944.1775423030.diff
View Options
diff --git a/usr.bin/sockstat/main.c b/usr.bin/sockstat/main.c
--- a/usr.bin/sockstat/main.c
+++ b/usr.bin/sockstat/main.c
@@ -51,6 +51,7 @@
#include <netinet/tcp_fsm.h>
#include <netinet/tcp_seq.h>
#include <netinet/tcp_var.h>
+#include <netinet/tcp_log_buf.h>
#include <arpa/inet.h>
#include <capsicum_helpers.h>
@@ -84,6 +85,7 @@
static bool opt_4; /* Show IPv4 sockets */
static bool opt_6; /* Show IPv6 sockets */
static bool opt_A; /* Show kernel address of pcb */
+static bool opt_b; /* Show BBLog state */
static bool opt_C; /* Show congestion control */
static bool opt_c; /* Show connected sockets */
static bool opt_f; /* Show FIB numbers */
@@ -141,6 +143,7 @@
int proto;
int state;
int fibnum;
+ int bblog_state;
const char *protoname;
char stack[TCP_FUNCTION_NAME_LEN_MAX];
char cc[TCP_CA_NAME_MAX];
@@ -738,6 +741,7 @@
sock->vflag = xip->inp_vflag;
if (proto == IPPROTO_TCP) {
sock->state = xtp->t_state;
+ sock->bblog_state = xtp->t_logstate;
memcpy(sock->stack, xtp->xt_stack,
TCP_FUNCTION_NAME_LEN_MAX);
memcpy(sock->cc, xtp->xt_cc, TCP_CA_NAME_MAX);
@@ -1056,6 +1060,37 @@
}
}
+static const char *
+bblog_state(int state)
+{
+ switch (state) {
+ case TCP_LOG_STATE_OFF:
+ return "OFF";
+ break;
+ case TCP_LOG_STATE_TAIL:
+ return "TAIL";
+ break;
+ case TCP_LOG_STATE_HEAD:
+ return "HEAD";
+ break;
+ case TCP_LOG_STATE_HEAD_AUTO:
+ return "HEAD_AUTO";
+ break;
+ case TCP_LOG_STATE_CONTINUAL:
+ return "CONTINUAL";
+ break;
+ case TCP_LOG_STATE_TAIL_AUTO:
+ return "TAIL_AUTO";
+ break;
+ case TCP_LOG_VIA_BBPOINTS:
+ return "BBPOINTS";
+ break;
+ default:
+ return "UNKNOWN";
+ break;
+ }
+}
+
static int
format_unix_faddr(struct addr *faddr, char *buf, size_t bufsize) {
#define SAFEBUF (buf == NULL ? NULL : buf + pos)
@@ -1143,6 +1178,7 @@
int encaps;
int path_state;
int conn_state;
+ int bblog_state;
int stack;
int cc;
};
@@ -1485,6 +1521,15 @@
xo_emit(" {:conn-state/%-*s}",
cw->conn_state, "??");
}
+ if (opt_b) {
+ if (s->proto == IPPROTO_TCP)
+ xo_emit(" {:bblog-state/%-*s}",
+ cw->bblog_state,
+ bblog_state(s->bblog_state));
+ else if (!is_xo_style_encoding)
+ xo_emit(" {:bblog-state/%-*s}",
+ cw->bblog_state, "??");
+ }
if (opt_S) {
if (s->proto == IPPROTO_TCP)
xo_emit(" {:stack/%-*s}",
@@ -1544,6 +1589,7 @@
.encaps = strlen("ENCAPS"),
.path_state = strlen("PATH STATE"),
.conn_state = strlen("CONN STATE"),
+ .bblog_state = strlen("BBLOG STATE"),
.stack = strlen("STACK"),
.cc = strlen("CC"),
};
@@ -1576,6 +1622,8 @@
xo_emit(" {T:/%-*s}", cw.path_state, "PATH STATE");
xo_emit(" {T:/%-*s}", cw.conn_state, "CONN STATE");
}
+ if (opt_b)
+ xo_emit(" {T:/%-*s}", cw.bblog_state, "BBLOG STATE");
if (opt_S)
xo_emit(" {T:/%-*s}", cw.stack, "STACK");
if (opt_C)
@@ -1706,7 +1754,7 @@
usage(void)
{
xo_error(
-"usage: sockstat [--libxo ...] [-46ACcfIiLlnqSsUuvw] [-j jid] [-p ports]\n"
+"usage: sockstat [--libxo ...] [-46AbCcfIiLlnqSsUuvw] [-j jid] [-p ports]\n"
" [-P protocols]\n");
exit(1);
}
@@ -1728,7 +1776,7 @@
xo_get_style(NULL) != XO_STYLE_HTML)
is_xo_style_encoding = true;
opt_j = -1;
- while ((o = getopt(argc, argv, "46ACcfIij:Llnp:P:qSsUuvw")) != -1)
+ while ((o = getopt(argc, argv, "46AbCcfIij:Llnp:P:qSsUuvw")) != -1)
switch (o) {
case '4':
opt_4 = true;
@@ -1739,6 +1787,9 @@
case 'A':
opt_A = true;
break;
+ case 'b':
+ opt_b = true;
+ break;
case 'C':
opt_C = true;
break;
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 July 17, 2025
+.Dd October 7, 2025
.Dt SOCKSTAT 1
.Os
.Sh NAME
@@ -34,7 +34,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl -libxo
-.Op Fl 46ACcfIiLlnqSsUuvw
+.Op Fl 46AbCcfIiLlnqSsUuvw
.Op Fl j Ar jail
.Op Fl p Ar ports
.Op Fl P Ar protocols
@@ -65,6 +65,9 @@
.It Fl A
Show the address of a protocol control block (PCB) associated with a socket;
used for debugging.
+.It Fl b
+Show the BBLog state of the socket.
+This is currently only implemented for TCP.
.It Fl C
Display the congestion control module, if applicable.
This is currently only implemented for TCP.
@@ -206,6 +209,10 @@
The connection state if
.Fl s
is specified (only for SCTP or TCP).
+.It Li BBLOG STATE
+The BBLog state if
+.Fl b
+is specified (only for TCP).
.It Li STACK
The protocol stack if
.Fl S
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 5, 9:03 PM (1 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28269099
Default Alt Text
D52944.1775423030.diff (4 KB)
Attached To
Mode
D52944: sockstat: support reporting of BBLog state
Attached
Detach File
Event Timeline
Log In to Comment