netstat: add support for UDP-Lite endpoints
With this patch UDP-Lite endpoints are also shown per default. Reviewed by: Nick Banks MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D53252
This commit is contained in:
+26
-11
@@ -83,7 +83,7 @@ static void inetprint(const char *, struct in_addr *, int, const char *, int,
|
|||||||
const int);
|
const int);
|
||||||
#endif
|
#endif
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
static int udp_done, tcp_done, sdp_done;
|
static int udp_done, udplite_done, tcp_done, sdp_done;
|
||||||
#endif /* INET6 */
|
#endif /* INET6 */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -100,6 +100,9 @@ pcblist_sysctl(int proto, const char *name, char **bufp)
|
|||||||
case IPPROTO_UDP:
|
case IPPROTO_UDP:
|
||||||
mibvar = "net.inet.udp.pcblist";
|
mibvar = "net.inet.udp.pcblist";
|
||||||
break;
|
break;
|
||||||
|
case IPPROTO_UDPLITE:
|
||||||
|
mibvar = "net.inet.udplite.pcblist";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
mibvar = "net.inet.raw.pcblist";
|
mibvar = "net.inet.raw.pcblist";
|
||||||
break;
|
break;
|
||||||
@@ -220,13 +223,20 @@ protopr(u_long off, const char *name, int af1, int proto)
|
|||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
udp_done = 1;
|
udp_done = 1;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case IPPROTO_UDPLITE:
|
||||||
|
#ifdef INET6
|
||||||
|
if (udplite_done != 0)
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
udplite_done = 1;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pcblist_sysctl(proto, name, &buf))
|
if (!pcblist_sysctl(proto, name, &buf))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (istcp && (cflag || Cflag)) {
|
if (istcp && (cflag || Cflag)) {
|
||||||
fnamelen = strlen("Stack");
|
fnamelen = strlen("Stack");
|
||||||
cnamelen = strlen("CC");
|
cnamelen = strlen("CC");
|
||||||
@@ -318,18 +328,18 @@ protopr(u_long off, const char *name, int af1, int proto)
|
|||||||
"Proto", "Listen", "Local Address");
|
"Proto", "Listen", "Local Address");
|
||||||
else if (Tflag)
|
else if (Tflag)
|
||||||
xo_emit((Aflag && !Wflag) ?
|
xo_emit((Aflag && !Wflag) ?
|
||||||
"{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-18.18s} {T:/%s}" :
|
"{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-18.18s} {T:/%s}" :
|
||||||
((!Wflag || af1 == AF_INET) ?
|
((!Wflag || af1 == AF_INET) ?
|
||||||
"{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%s}" :
|
"{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%s}" :
|
||||||
"{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-45.45s} {T:/%s}"),
|
"{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-45.45s} {T:/%s}"),
|
||||||
"Proto", "Rexmit", "OOORcv", "0-win",
|
"Proto", "Rexmit", "OOORcv", "0-win",
|
||||||
"Local Address", "Foreign Address");
|
"Local Address", "Foreign Address");
|
||||||
else {
|
else {
|
||||||
xo_emit((Aflag && !Wflag) ?
|
xo_emit((Aflag && !Wflag) ?
|
||||||
"{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-18.18s} {T:/%-18.18s}" :
|
"{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-18.18s} {T:/%-18.18s}" :
|
||||||
((!Wflag || af1 == AF_INET) ?
|
((!Wflag || af1 == AF_INET) ?
|
||||||
"{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%-22.22s}" :
|
"{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%-22.22s}" :
|
||||||
"{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-45.45s} {T:/%-45.45s}"),
|
"{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-45.45s} {T:/%-45.45s}"),
|
||||||
"Proto", "Recv-Q", "Send-Q",
|
"Proto", "Recv-Q", "Send-Q",
|
||||||
"Local Address", "Foreign Address");
|
"Local Address", "Foreign Address");
|
||||||
if (!xflag && !Rflag)
|
if (!xflag && !Rflag)
|
||||||
@@ -382,9 +392,14 @@ protopr(u_long off, const char *name, int af1, int proto)
|
|||||||
vchar = ((inp->inp_vflag & INP_IPV4) != 0) ?
|
vchar = ((inp->inp_vflag & INP_IPV4) != 0) ?
|
||||||
"4" : "";
|
"4" : "";
|
||||||
if (istcp && (tp->t_flags & TF_TOE) != 0)
|
if (istcp && (tp->t_flags & TF_TOE) != 0)
|
||||||
xo_emit("{:protocol/%-3.3s%-2.2s/%s%s} ", "toe", vchar);
|
xo_emit("{:protocol/%-3.3s%-6.6s/%s%s} ", "toe", vchar);
|
||||||
else
|
else {
|
||||||
xo_emit("{:protocol/%-3.3s%-2.2s/%s%s} ", name, vchar);
|
int len;
|
||||||
|
|
||||||
|
len = max (2, 9 - strlen(name));
|
||||||
|
xo_emit("{:protocol/%.7s%-*.*s/%s%s} ", name, len, len,
|
||||||
|
vchar);
|
||||||
|
}
|
||||||
if (Lflag) {
|
if (Lflag) {
|
||||||
char buf1[33];
|
char buf1[33];
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ static struct protox {
|
|||||||
tcp_stats, NULL, "tcp", 1, IPPROTO_TCP },
|
tcp_stats, NULL, "tcp", 1, IPPROTO_TCP },
|
||||||
{ -1 , N_UDPSTAT, 1, protopr,
|
{ -1 , N_UDPSTAT, 1, protopr,
|
||||||
udp_stats, NULL, "udp", 1, IPPROTO_UDP },
|
udp_stats, NULL, "udp", 1, IPPROTO_UDP },
|
||||||
|
{ -1, -1, 1, protopr,
|
||||||
|
NULL, NULL, "udplite", 1, IPPROTO_UDPLITE },
|
||||||
#ifdef SCTP
|
#ifdef SCTP
|
||||||
{ -1, N_SCTPSTAT, 1, sctp_protopr,
|
{ -1, N_SCTPSTAT, 1, sctp_protopr,
|
||||||
sctp_stats, NULL, "sctp", 1, IPPROTO_SCTP },
|
sctp_stats, NULL, "sctp", 1, IPPROTO_SCTP },
|
||||||
@@ -131,6 +133,8 @@ static struct protox ip6protox[] = {
|
|||||||
tcp_stats, NULL, "tcp", 1, IPPROTO_TCP },
|
tcp_stats, NULL, "tcp", 1, IPPROTO_TCP },
|
||||||
{ -1 , N_UDPSTAT, 1, protopr,
|
{ -1 , N_UDPSTAT, 1, protopr,
|
||||||
udp_stats, NULL, "udp", 1, IPPROTO_UDP },
|
udp_stats, NULL, "udp", 1, IPPROTO_UDP },
|
||||||
|
{ -1, -1, 1, protopr,
|
||||||
|
NULL, NULL, "udplite", 1, IPPROTO_UDPLITE },
|
||||||
{ -1 , N_IP6STAT, 1, protopr,
|
{ -1 , N_IP6STAT, 1, protopr,
|
||||||
ip6_stats, ip6_ifstats, "ip6", 1, IPPROTO_RAW },
|
ip6_stats, ip6_ifstats, "ip6", 1, IPPROTO_RAW },
|
||||||
{ -1 , N_ICMP6STAT, 1, protopr,
|
{ -1 , N_ICMP6STAT, 1, protopr,
|
||||||
|
|||||||
Reference in New Issue
Block a user