旧的 43BSD 和 netstat 输出

旧的 43BSD 和 netstat 输出

在旧的 43BSD 上...

netstat -f unix
Active UNIX domain sockets
Address  Type   Recv-Q Send-Q    Inode     Conn     Refs  Nextref Addr
801ca38c dgram       0      0 8008b5c0        0        0        0 /dev/log
801cc10c stream      0      0 8008e690        0        0        0 /dev/printer

Address                 #socket address
type                    #type: stream or dgram
Inode                   #Inode?
Conn                    #sockets connections
Refs                    #?
Nextref                 #?
Addr                    #socket file

任何人都知道“Refs”和“Nextref”是什么意思。据我所知,Refs 指的是路由,但据我所知,在套接字中没有路由。

答案1

根据netstat/unix.c这些字段来自unp->unp_refsunp->unp_nextref定义在系统/unpcb.h:

/*
 * A socket may be referenced by a number of sockets (e.g. several
 * sockets may be connected to a datagram socket.)  These sockets
 * are in a linked list starting with unp_refs, linked through
 * unp_nextref and null-terminated.  Note that a socket may be referenced
 * by a number of other sockets and may also reference a socket (not
 * necessarily one which is referencing it).  This generates
 * the need for unp_refs and unp_nextref to be separate fields.
 *\
        struct  unpcb *unp_refs;        /* referencing socket linked list */
        struct  unpcb *unp_nextref;     /* link in unp_refs list */

相关内容