xref: /freebsd/usr.bin/netstat/unix.c (revision 5e3934b1)
19b50d902SRodney W. Grimes /*-
28a16b7a1SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
38a16b7a1SPedro F. Giffuni  *
49b50d902SRodney W. Grimes  * Copyright (c) 1983, 1988, 1993
59b50d902SRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
69b50d902SRodney W. Grimes  *
79b50d902SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
89b50d902SRodney W. Grimes  * modification, are permitted provided that the following conditions
99b50d902SRodney W. Grimes  * are met:
109b50d902SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
119b50d902SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
129b50d902SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
139b50d902SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
149b50d902SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
15fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
169b50d902SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
179b50d902SRodney W. Grimes  *    without specific prior written permission.
189b50d902SRodney W. Grimes  *
199b50d902SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
209b50d902SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
219b50d902SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
229b50d902SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
239b50d902SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
249b50d902SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
259b50d902SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
269b50d902SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
279b50d902SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
289b50d902SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
299b50d902SRodney W. Grimes  * SUCH DAMAGE.
309b50d902SRodney W. Grimes  */
319b50d902SRodney W. Grimes 
326cc6f122SPhilippe Charnier #include <sys/cdefs.h>
339b50d902SRodney W. Grimes /*
349b50d902SRodney W. Grimes  * Display protocol blocks in the unix domain.
359b50d902SRodney W. Grimes  */
369b50d902SRodney W. Grimes #include <sys/param.h>
37d8d89152SDavid Greenman #include <sys/queue.h>
389b50d902SRodney W. Grimes #include <sys/protosw.h>
399b50d902SRodney W. Grimes #include <sys/socket.h>
400e229f34SGleb Smirnoff #define	_WANT_SOCKET
419b50d902SRodney W. Grimes #include <sys/socketvar.h>
429b50d902SRodney W. Grimes #include <sys/mbuf.h>
439b50d902SRodney W. Grimes #include <sys/sysctl.h>
449b50d902SRodney W. Grimes #include <sys/un.h>
450e229f34SGleb Smirnoff #define	_WANT_UNPCB
469b50d902SRodney W. Grimes #include <sys/unpcb.h>
479b50d902SRodney W. Grimes 
489b50d902SRodney W. Grimes #include <netinet/in.h>
499b50d902SRodney W. Grimes 
504f81ef50SGarrett Wollman #include <errno.h>
51c6620a13SPoul-Henning Kamp #include <err.h>
528ad9b1a3SGarrett Wollman #include <stddef.h>
537b95a1ebSYaroslav Tykhiy #include <stdint.h>
549b50d902SRodney W. Grimes #include <stdio.h>
559b50d902SRodney W. Grimes #include <stdlib.h>
56ade9ccfeSMarcel Moolenaar #include <stdbool.h>
57feda1a43SJohn Baldwin #include <strings.h>
584f81ef50SGarrett Wollman #include <kvm.h>
59ade9ccfeSMarcel Moolenaar #include <libxo/xo.h>
609b50d902SRodney W. Grimes #include "netstat.h"
619b50d902SRodney W. Grimes 
625e051718SAssar Westerlund static	void unixdomainpr(struct xunpcb *, struct xsocket *);
639b50d902SRodney W. Grimes 
644f81ef50SGarrett Wollman static	const char *const socktype[] =
659b50d902SRodney W. Grimes     { "#0", "stream", "dgram", "raw", "rdm", "seqpacket" };
669b50d902SRodney W. Grimes 
67feda1a43SJohn Baldwin static int
pcblist_sysctl(int type,char ** bufp)68feda1a43SJohn Baldwin pcblist_sysctl(int type, char **bufp)
699b50d902SRodney W. Grimes {
704f81ef50SGarrett Wollman 	char 	*buf;
714f81ef50SGarrett Wollman 	size_t	len;
724f81ef50SGarrett Wollman 	char mibvar[sizeof "net.local.seqpacket.pcblist"];
734f81ef50SGarrett Wollman 
74f193c8ceSXin LI 	snprintf(mibvar, sizeof(mibvar), "net.local.%s.pcblist", socktype[type]);
754f81ef50SGarrett Wollman 
764f81ef50SGarrett Wollman 	len = 0;
774f81ef50SGarrett Wollman 	if (sysctlbyname(mibvar, 0, &len, 0, 0) < 0) {
784f81ef50SGarrett Wollman 		if (errno != ENOENT)
79ade9ccfeSMarcel Moolenaar 			xo_warn("sysctl: %s", mibvar);
80feda1a43SJohn Baldwin 		return (-1);
814f81ef50SGarrett Wollman 	}
82ef1cb629SMarcelo Araujo 	if ((buf = malloc(len)) == NULL) {
83ade9ccfeSMarcel Moolenaar 		xo_warnx("malloc %lu bytes", (u_long)len);
84feda1a43SJohn Baldwin 		return (-2);
854f81ef50SGarrett Wollman 	}
864f81ef50SGarrett Wollman 	if (sysctlbyname(mibvar, buf, &len, 0, 0) < 0) {
87ade9ccfeSMarcel Moolenaar 		xo_warn("sysctl: %s", mibvar);
884f81ef50SGarrett Wollman 		free(buf);
89feda1a43SJohn Baldwin 		return (-2);
904f81ef50SGarrett Wollman 	}
91feda1a43SJohn Baldwin 	*bufp = buf;
92feda1a43SJohn Baldwin 	return (0);
93feda1a43SJohn Baldwin }
94feda1a43SJohn Baldwin 
95feda1a43SJohn Baldwin static int
pcblist_kvm(u_long count_off,u_long gencnt_off,u_long head_off,char ** bufp)96feda1a43SJohn Baldwin pcblist_kvm(u_long count_off, u_long gencnt_off, u_long head_off, char **bufp)
97feda1a43SJohn Baldwin {
98feda1a43SJohn Baldwin 	struct unp_head head;
990e229f34SGleb Smirnoff 	struct unpcb *unp, unp0, unp_conn;
100feda1a43SJohn Baldwin 	u_char sun_len;
101feda1a43SJohn Baldwin 	struct socket so;
102feda1a43SJohn Baldwin 	struct xunpgen xug;
103feda1a43SJohn Baldwin 	struct xunpcb xu;
104feda1a43SJohn Baldwin 	unp_gen_t unp_gencnt;
105feda1a43SJohn Baldwin 	u_int	unp_count;
106feda1a43SJohn Baldwin 	char 	*buf, *p;
107feda1a43SJohn Baldwin 	size_t	len;
108feda1a43SJohn Baldwin 
109feda1a43SJohn Baldwin 	if (count_off == 0 || gencnt_off == 0)
110feda1a43SJohn Baldwin 		return (-2);
111feda1a43SJohn Baldwin 	if (head_off == 0)
112feda1a43SJohn Baldwin 		return (-1);
113feda1a43SJohn Baldwin 	kread(count_off, &unp_count, sizeof(unp_count));
114feda1a43SJohn Baldwin 	len = 2 * sizeof(xug) + (unp_count + unp_count / 8) * sizeof(xu);
115ef1cb629SMarcelo Araujo 	if ((buf = malloc(len)) == NULL) {
116ade9ccfeSMarcel Moolenaar 		xo_warnx("malloc %lu bytes", (u_long)len);
117feda1a43SJohn Baldwin 		return (-2);
118feda1a43SJohn Baldwin 	}
119feda1a43SJohn Baldwin 	p = buf;
120feda1a43SJohn Baldwin 
121feda1a43SJohn Baldwin #define	COPYOUT(obj, size) do {						\
122feda1a43SJohn Baldwin 	if (len < (size)) {						\
123ade9ccfeSMarcel Moolenaar 		xo_warnx("buffer size exceeded");			\
124feda1a43SJohn Baldwin 		goto fail;						\
125feda1a43SJohn Baldwin 	}								\
126feda1a43SJohn Baldwin 	bcopy((obj), p, (size));					\
127feda1a43SJohn Baldwin 	len -= (size);							\
128feda1a43SJohn Baldwin 	p += (size);							\
129feda1a43SJohn Baldwin } while (0)
130feda1a43SJohn Baldwin 
131feda1a43SJohn Baldwin #define	KREAD(off, buf, len) do {					\
132feda1a43SJohn Baldwin 	if (kread((uintptr_t)(off), (buf), (len)) != 0)			\
133feda1a43SJohn Baldwin 		goto fail;						\
134feda1a43SJohn Baldwin } while (0)
135feda1a43SJohn Baldwin 
136feda1a43SJohn Baldwin 	/* Write out header. */
137feda1a43SJohn Baldwin 	kread(gencnt_off, &unp_gencnt, sizeof(unp_gencnt));
138feda1a43SJohn Baldwin 	xug.xug_len = sizeof xug;
139feda1a43SJohn Baldwin 	xug.xug_count = unp_count;
140feda1a43SJohn Baldwin 	xug.xug_gen = unp_gencnt;
141feda1a43SJohn Baldwin 	xug.xug_sogen = 0;
142feda1a43SJohn Baldwin 	COPYOUT(&xug, sizeof xug);
143feda1a43SJohn Baldwin 
144feda1a43SJohn Baldwin 	/* Walk the PCB list. */
145feda1a43SJohn Baldwin 	xu.xu_len = sizeof xu;
146feda1a43SJohn Baldwin 	KREAD(head_off, &head, sizeof(head));
147feda1a43SJohn Baldwin 	LIST_FOREACH(unp, &head, unp_link) {
1483a20f06aSBrooks Davis 		xu.xu_unpp = (uintptr_t)unp;
1490e229f34SGleb Smirnoff 		KREAD(unp, &unp0, sizeof (*unp));
1500e229f34SGleb Smirnoff 		unp = &unp0;
151feda1a43SJohn Baldwin 
152feda1a43SJohn Baldwin 		if (unp->unp_gencnt > unp_gencnt)
153feda1a43SJohn Baldwin 			continue;
154feda1a43SJohn Baldwin 		if (unp->unp_addr != NULL) {
155feda1a43SJohn Baldwin 			KREAD(unp->unp_addr, &sun_len, sizeof(sun_len));
156feda1a43SJohn Baldwin 			KREAD(unp->unp_addr, &xu.xu_addr, sun_len);
157feda1a43SJohn Baldwin 		}
158feda1a43SJohn Baldwin 		if (unp->unp_conn != NULL) {
159feda1a43SJohn Baldwin 			KREAD(unp->unp_conn, &unp_conn, sizeof(unp_conn));
160feda1a43SJohn Baldwin 			if (unp_conn.unp_addr != NULL) {
161feda1a43SJohn Baldwin 				KREAD(unp_conn.unp_addr, &sun_len,
162feda1a43SJohn Baldwin 				    sizeof(sun_len));
163feda1a43SJohn Baldwin 				KREAD(unp_conn.unp_addr, &xu.xu_caddr, sun_len);
164feda1a43SJohn Baldwin 			}
165feda1a43SJohn Baldwin 		}
166feda1a43SJohn Baldwin 		KREAD(unp->unp_socket, &so, sizeof(so));
167feda1a43SJohn Baldwin 		if (sotoxsocket(&so, &xu.xu_socket) != 0)
168feda1a43SJohn Baldwin 			goto fail;
169feda1a43SJohn Baldwin 		COPYOUT(&xu, sizeof(xu));
170feda1a43SJohn Baldwin 	}
171feda1a43SJohn Baldwin 
172feda1a43SJohn Baldwin 	/* Reread the counts and write the footer. */
173feda1a43SJohn Baldwin 	kread(count_off, &unp_count, sizeof(unp_count));
174feda1a43SJohn Baldwin 	kread(gencnt_off, &unp_gencnt, sizeof(unp_gencnt));
175feda1a43SJohn Baldwin 	xug.xug_count = unp_count;
176feda1a43SJohn Baldwin 	xug.xug_gen = unp_gencnt;
177feda1a43SJohn Baldwin 	COPYOUT(&xug, sizeof xug);
178feda1a43SJohn Baldwin 
179feda1a43SJohn Baldwin 	*bufp = buf;
180feda1a43SJohn Baldwin 	return (0);
181feda1a43SJohn Baldwin 
182feda1a43SJohn Baldwin fail:
183feda1a43SJohn Baldwin 	free(buf);
184feda1a43SJohn Baldwin 	return (-1);
185feda1a43SJohn Baldwin #undef COPYOUT
186feda1a43SJohn Baldwin #undef KREAD
187feda1a43SJohn Baldwin }
188feda1a43SJohn Baldwin 
189feda1a43SJohn Baldwin void
unixpr(u_long count_off,u_long gencnt_off,u_long dhead_off,u_long shead_off,u_long sphead_off,bool * first)190963b7ccdSRobert Watson unixpr(u_long count_off, u_long gencnt_off, u_long dhead_off, u_long shead_off,
191ade9ccfeSMarcel Moolenaar     u_long sphead_off, bool *first)
192feda1a43SJohn Baldwin {
193feda1a43SJohn Baldwin 	char 	*buf;
194feda1a43SJohn Baldwin 	int	ret, type;
195feda1a43SJohn Baldwin 	struct	xsocket *so;
196feda1a43SJohn Baldwin 	struct	xunpgen *xug, *oxug;
197feda1a43SJohn Baldwin 	struct	xunpcb *xunp;
198963b7ccdSRobert Watson 	u_long	head_off;
199feda1a43SJohn Baldwin 
200321ae07fSPhilippe Charnier 	buf = NULL;
201feda1a43SJohn Baldwin 	for (type = SOCK_STREAM; type <= SOCK_SEQPACKET; type++) {
202feda1a43SJohn Baldwin 		if (live)
203feda1a43SJohn Baldwin 			ret = pcblist_sysctl(type, &buf);
204963b7ccdSRobert Watson 		else {
205963b7ccdSRobert Watson 			head_off = 0;
206963b7ccdSRobert Watson 			switch (type) {
207963b7ccdSRobert Watson 			case SOCK_STREAM:
208963b7ccdSRobert Watson 				head_off = shead_off;
209963b7ccdSRobert Watson 				break;
210963b7ccdSRobert Watson 
211963b7ccdSRobert Watson 			case SOCK_DGRAM:
212963b7ccdSRobert Watson 				head_off = dhead_off;
213963b7ccdSRobert Watson 				break;
214963b7ccdSRobert Watson 
215963b7ccdSRobert Watson 			case SOCK_SEQPACKET:
216963b7ccdSRobert Watson 				head_off = sphead_off;
217963b7ccdSRobert Watson 				break;
218963b7ccdSRobert Watson 			}
219963b7ccdSRobert Watson 			ret = pcblist_kvm(count_off, gencnt_off, head_off,
220963b7ccdSRobert Watson 			    &buf);
221963b7ccdSRobert Watson 		}
222feda1a43SJohn Baldwin 		if (ret == -1)
223feda1a43SJohn Baldwin 			continue;
224feda1a43SJohn Baldwin 		if (ret < 0)
225feda1a43SJohn Baldwin 			return;
2264f81ef50SGarrett Wollman 
2274f81ef50SGarrett Wollman 		oxug = xug = (struct xunpgen *)buf;
2284f81ef50SGarrett Wollman 		for (xug = (struct xunpgen *)((char *)xug + xug->xug_len);
2294f81ef50SGarrett Wollman 		    xug->xug_len > sizeof(struct xunpgen);
2304f81ef50SGarrett Wollman 		    xug = (struct xunpgen *)((char *)xug + xug->xug_len)) {
2314f81ef50SGarrett Wollman 			xunp = (struct xunpcb *)xug;
2324f81ef50SGarrett Wollman 			so = &xunp->xu_socket;
2334f81ef50SGarrett Wollman 
2344f81ef50SGarrett Wollman 			/* Ignore PCBs which were freed during copyout. */
2350e229f34SGleb Smirnoff 			if (xunp->unp_gencnt > oxug->xug_gen)
2364f81ef50SGarrett Wollman 				continue;
237ade9ccfeSMarcel Moolenaar 			if (*first) {
238ade9ccfeSMarcel Moolenaar 				xo_open_list("socket");
239ade9ccfeSMarcel Moolenaar 				*first = false;
240ade9ccfeSMarcel Moolenaar 			}
241ade9ccfeSMarcel Moolenaar 			xo_open_instance("socket");
2424f81ef50SGarrett Wollman 			unixdomainpr(xunp, so);
243ade9ccfeSMarcel Moolenaar 			xo_close_instance("socket");
2444f81ef50SGarrett Wollman 		}
2454f81ef50SGarrett Wollman 		if (xug != oxug && xug->xug_gen != oxug->xug_gen) {
2464f81ef50SGarrett Wollman 			if (oxug->xug_count > xug->xug_count) {
247ade9ccfeSMarcel Moolenaar 				xo_emit("Some {:type/%s} sockets may have "
248ade9ccfeSMarcel Moolenaar 				    "been {:action/deleted}.\n",
2494f81ef50SGarrett Wollman 				    socktype[type]);
2504f81ef50SGarrett Wollman 			} else if (oxug->xug_count < xug->xug_count) {
251ade9ccfeSMarcel Moolenaar 				xo_emit("Some {:type/%s} sockets may have "
252ade9ccfeSMarcel Moolenaar 				    "been {:action/created}.\n",
2534f81ef50SGarrett Wollman 				    socktype[type]);
2544f81ef50SGarrett Wollman 			} else {
255ade9ccfeSMarcel Moolenaar 				xo_emit("Some {:type/%s} sockets may have "
256ade9ccfeSMarcel Moolenaar 				    "been {:action/created or deleted}",
2574f81ef50SGarrett Wollman 				    socktype[type]);
2584f81ef50SGarrett Wollman 			}
2594f81ef50SGarrett Wollman 		}
2604f81ef50SGarrett Wollman 		free(buf);
2614f81ef50SGarrett Wollman 	}
2624f81ef50SGarrett Wollman }
2634f81ef50SGarrett Wollman 
2644f81ef50SGarrett Wollman static void
unixdomainpr(struct xunpcb * xunp,struct xsocket * so)2655e051718SAssar Westerlund unixdomainpr(struct xunpcb *xunp, struct xsocket *so)
2664f81ef50SGarrett Wollman {
2674f81ef50SGarrett Wollman 	struct sockaddr_un *sa;
2689b50d902SRodney W. Grimes 	static int first = 1;
2697325dfbbSAlfred Perlstein 	char buf1[33];
270ade9ccfeSMarcel Moolenaar 	static const char *titles[2] = {
271ade9ccfeSMarcel Moolenaar 	    "{T:/%-8.8s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%8.8s} "
272ade9ccfeSMarcel Moolenaar 	    "{T:/%8.8s} {T:/%8.8s} {T:/%8.8s} {T:Addr}\n",
273ade9ccfeSMarcel Moolenaar 	    "{T:/%-16.16s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%16.16s} "
274ade9ccfeSMarcel Moolenaar 	    "{T:/%16.16s} {T:/%16.16s} {T:/%16.16s} {T:Addr}\n"
275ade9ccfeSMarcel Moolenaar 	};
276ade9ccfeSMarcel Moolenaar 	static const char *format[2] = {
277ade9ccfeSMarcel Moolenaar 	    "{q:address/%8lx} {t:type/%-6.6s} "
278ade9ccfeSMarcel Moolenaar 	    "{:receive-bytes-waiting/%6u} "
279ade9ccfeSMarcel Moolenaar 	    "{:send-bytes-waiting/%6u} "
280ade9ccfeSMarcel Moolenaar 	    "{q:vnode/%8lx} {q:connection/%8lx} "
281ade9ccfeSMarcel Moolenaar 	    "{q:first-reference/%8lx} {q:next-reference/%8lx}",
282ade9ccfeSMarcel Moolenaar 	    "{q:address/%16lx} {t:type/%-6.6s} "
283ade9ccfeSMarcel Moolenaar 	    "{:receive-bytes-waiting/%6u} "
284ade9ccfeSMarcel Moolenaar 	    "{:send-bytes-waiting/%6u} "
285ade9ccfeSMarcel Moolenaar 	    "{q:vnode/%16lx} {q:connection/%16lx} "
286ade9ccfeSMarcel Moolenaar 	    "{q:first-reference/%16lx} {q:next-reference/%16lx}"
287ade9ccfeSMarcel Moolenaar 	};
288ade9ccfeSMarcel Moolenaar 	int fmt = (sizeof(void *) == 8) ? 1 : 0;
2899b50d902SRodney W. Grimes 
2900e229f34SGleb Smirnoff 	sa = (xunp->xu_addr.sun_family == AF_UNIX) ? &xunp->xu_addr : NULL;
2914f81ef50SGarrett Wollman 
292f1c0a78dSMaxim Konovalov 	if (first && !Lflag) {
293ade9ccfeSMarcel Moolenaar 		xo_emit("{T:Active UNIX domain sockets}\n");
294ade9ccfeSMarcel Moolenaar 		xo_emit(titles[fmt],
2959b50d902SRodney W. Grimes 		    "Address", "Type", "Recv-Q", "Send-Q",
2969b50d902SRodney W. Grimes 		    "Inode", "Conn", "Refs", "Nextref");
2979b50d902SRodney W. Grimes 		first = 0;
2989b50d902SRodney W. Grimes 	}
299f1c0a78dSMaxim Konovalov 
300f1c0a78dSMaxim Konovalov 	if (Lflag && so->so_qlimit == 0)
301f1c0a78dSMaxim Konovalov 		return;
302f1c0a78dSMaxim Konovalov 
303f1c0a78dSMaxim Konovalov 	if (Lflag) {
3047325dfbbSAlfred Perlstein 		snprintf(buf1, sizeof buf1, "%u/%u/%u", so->so_qlen,
305f1c0a78dSMaxim Konovalov 		    so->so_incqlen, so->so_qlimit);
3067325dfbbSAlfred Perlstein 		xo_emit("unix  {d:socket/%-32.32s}{e:queue-length/%u}"
3077325dfbbSAlfred Perlstein 		    "{e:incomplete-queue-length/%u}{e:queue-limit/%u}",
308ade9ccfeSMarcel Moolenaar 		    buf1, so->so_qlen, so->so_incqlen, so->so_qlimit);
309f1c0a78dSMaxim Konovalov 	} else {
310ade9ccfeSMarcel Moolenaar 		xo_emit(format[fmt],
3114f81ef50SGarrett Wollman 		    (long)so->so_pcb, socktype[so->so_type], so->so_rcv.sb_cc,
3120e229f34SGleb Smirnoff 		    so->so_snd.sb_cc, (long)xunp->unp_vnode,
3130e229f34SGleb Smirnoff 		    (long)xunp->unp_conn, (long)xunp->xu_firstref,
3140e229f34SGleb Smirnoff 		    (long)xunp->xu_nextref);
315f1c0a78dSMaxim Konovalov 	}
316e4bb0b9aSGarrett Wollman 	if (sa)
317ade9ccfeSMarcel Moolenaar 		xo_emit(" {:path/%.*s}",
31822694ebaSBruce Evans 		    (int)(sa->sun_len - offsetof(struct sockaddr_un, sun_path)),
319bc6ee716SAndrey A. Chernov 		    sa->sun_path);
320ade9ccfeSMarcel Moolenaar 	xo_emit("\n");
3219b50d902SRodney W. Grimes }
322