This patch fixes two bugs:

* sctp46, tcp46, and udp46 sockets are displayed as such and not as
  sctp4 6, tcp4 6, udp4 6. This bug was introduced in
  http://svnweb.freebsd.org/base?view=revision&revision=187915
* For SCTP sockets, the the -4 and -6 flags are honoured as much as
  possible. This means IPv4 sockets are handled correctly,  IPv6
  sockets are displayed as sctp46, since it is currently not possible
  to distinguish between sctp6 and sctp46.

Approved by:	re (gjb)
MFC after:	1 week
This commit is contained in:
Michael Tuexen 2016-06-25 12:46:18 +00:00
parent 8f73d398ed
commit edc9c7fc7c

View File

@ -338,7 +338,12 @@ gather_sctp(void)
sock->state = SCTP_LISTEN;
if (xinpcb->flags & SCTP_PCB_FLAGS_BOUND_V6) {
sock->family = AF_INET6;
sock->vflag = INP_IPV6;
/*
* Currently there is no way to distinguish between
* IPv6 only sockets or dual family sockets.
* So mark it as dual socket.
*/
sock->vflag = INP_IPV6 | INP_IPV4;
} else {
sock->family = AF_INET;
sock->vflag = INP_IPV4;
@ -406,6 +411,7 @@ gather_sctp(void)
offset += sizeof(struct xsctp_tcb);
if (no_stcb) {
if (opt_l &&
(sock->vflag & vflag) &&
(!opt_L || !local_all_loopback) &&
((xinpcb->flags & SCTP_PCB_FLAGS_UDPTYPE) ||
(xstcb->last == 1))) {
@ -428,7 +434,12 @@ gather_sctp(void)
sock->state = (int)xstcb->state;
if (xinpcb->flags & SCTP_PCB_FLAGS_BOUND_V6) {
sock->family = AF_INET6;
sock->vflag = INP_IPV6;
/*
* Currently there is no way to distinguish
* between IPv6 only sockets or dual family
* sockets. So mark it as dual socket.
*/
sock->vflag = INP_IPV6 | INP_IPV4;
} else {
sock->family = AF_INET;
sock->vflag = INP_IPV4;
@ -519,7 +530,9 @@ gather_sctp(void)
prev_faddr = faddr;
}
if (opt_c) {
if (!opt_L || !(local_all_loopback || foreign_all_loopback)) {
if ((sock->vflag & vflag) &&
(!opt_L ||
!(local_all_loopback || foreign_all_loopback))) {
hash = (int)((uintptr_t)sock->socket % HASHSIZE);
sock->next = sockhash[hash];
sockhash[hash] = sock;
@ -963,9 +976,11 @@ displaysock(struct sock *s, int pos)
pos += xprintf(" ");
pos += xprintf("%s", s->protoname);
if (s->vflag & INP_IPV4)
pos += xprintf("4 ");
pos += xprintf("4");
if (s->vflag & INP_IPV6)
pos += xprintf("6 ");
pos += xprintf("6");
if (s->vflag & (INP_IPV4 | INP_IPV6))
pos += xprintf(" ");
laddr = s->laddr;
faddr = s->faddr;
first = 1;