-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
lsfd-sock-xinfo.c
738 lines (647 loc) · 17.4 KB
/
lsfd-sock-xinfo.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
/*
* lsfd-sock-xinfo.c - read various information from files under /proc/net/
*
* Copyright (C) 2022 Red Hat, Inc. All rights reserved.
* Written by Masatake YAMATO <yamato@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it would be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <arpa/inet.h> /* inet_ntop */
#include <fcntl.h> /* open(2) */
#include <linux/net.h> /* SS_* */
#include <linux/un.h> /* UNIX_PATH_MAX */
#include <sched.h> /* for setns(2) */
#include <search.h>
#include <stdint.h>
#include <string.h>
#include <sys/socket.h> /* SOCK_* */
#include "xalloc.h"
#include "nls.h"
#include "libsmartcols.h"
#include "procfs.h"
#include "bitops.h"
#include "lsfd.h"
#include "lsfd-sock.h"
static void load_xinfo_from_proc_unix(ino_t netns_inode);
static void load_xinfo_from_proc_tcp(ino_t netns_inode);
static void load_xinfo_from_proc_udp(ino_t netns_inode);
static int self_netns_fd = -1;
struct stat self_netns_sb;
static void *xinfo_tree; /* for tsearch/tfind */
static void *netns_tree;
static int netns_compare(const void *a, const void *b)
{
if (*(ino_t *)a < *(ino_t *)b)
return -1;
else if (*(ino_t *)a > *(ino_t *)b)
return 1;
else
return 0;
}
static bool is_sock_xinfo_loaded(ino_t netns)
{
return tfind(&netns, &netns_tree, netns_compare)? true: false;
}
static void mark_sock_xinfo_loaded(ino_t ino)
{
ino_t *netns = xmalloc(sizeof(ino));
ino_t **tmp;
*netns = ino;
tmp = tsearch(netns, &netns_tree, netns_compare);
if (tmp == NULL)
errx(EXIT_FAILURE, _("failed to allocate memory"));
}
static void load_sock_xinfo_no_nsswitch(ino_t netns)
{
load_xinfo_from_proc_unix(netns);
load_xinfo_from_proc_tcp(netns);
load_xinfo_from_proc_udp(netns);
}
static void load_sock_xinfo_with_fd(int fd, ino_t netns)
{
if (setns(fd, CLONE_NEWNET) == 0) {
load_sock_xinfo_no_nsswitch(netns);
setns(self_netns_fd, CLONE_NEWNET);
}
}
void load_sock_xinfo(struct path_cxt *pc, const char *name, ino_t netns)
{
if (self_netns_fd == -1)
return;
if (!is_sock_xinfo_loaded(netns)) {
int fd;
mark_sock_xinfo_loaded(netns);
fd = ul_path_open(pc, O_RDONLY, name);
if (fd < 0)
return;
load_sock_xinfo_with_fd(fd, netns);
close(fd);
}
}
void initialize_sock_xinfos(void)
{
struct path_cxt *pc;
DIR *dir;
struct dirent *d;
self_netns_fd = open("/proc/self/ns/net", O_RDONLY);
if (self_netns_fd < 0)
load_sock_xinfo_no_nsswitch(0);
else {
if (fstat(self_netns_fd, &self_netns_sb) == 0) {
mark_sock_xinfo_loaded(self_netns_sb.st_ino);
load_sock_xinfo_no_nsswitch(self_netns_sb.st_ino);
}
}
/* Load /proc/net/{unix,...} of the network namespace
* specified with netns files under /var/run/netns/.
*
* `ip netns' command pins a network namespace on
* /var/run/netns.
*/
pc = ul_new_path("/var/run/netns");
if (!pc)
err(EXIT_FAILURE, _("failed to alloc path context for /var/run/netns"));
dir = ul_path_opendir(pc, NULL);
if (dir == NULL) {
ul_unref_path(pc);
return;
}
while ((d = readdir(dir))) {
struct stat sb;
int fd;
if (ul_path_stat(pc, &sb, 0, d->d_name) < 0)
continue;
if (is_sock_xinfo_loaded(sb.st_ino))
continue;
mark_sock_xinfo_loaded(sb.st_ino);
fd = ul_path_open(pc, O_RDONLY, d->d_name);
if (fd < 0)
continue;
load_sock_xinfo_with_fd(fd, sb.st_ino);
close(fd);
}
closedir(dir);
ul_unref_path(pc);
}
static void free_sock_xinfo(void *node)
{
struct sock_xinfo *xinfo = node;
if (xinfo->class->free)
xinfo->class->free(xinfo);
free(node);
}
void finalize_sock_xinfos(void)
{
if (self_netns_fd != -1)
close(self_netns_fd);
tdestroy(netns_tree, free);
tdestroy(xinfo_tree, free_sock_xinfo);
}
static int xinfo_compare(const void *a, const void *b)
{
if (((struct sock_xinfo *)a)->inode < ((struct sock_xinfo *)b)->inode)
return -1;
if (((struct sock_xinfo *)a)->inode > ((struct sock_xinfo *)b)->inode)
return 1;
return 0;
}
static void add_sock_info(struct sock_xinfo *xinfo)
{
struct sock_xinfo **tmp = tsearch(xinfo, &xinfo_tree, xinfo_compare);
if (tmp == NULL)
errx(EXIT_FAILURE, _("failed to allocate memory"));
}
struct sock_xinfo *get_sock_xinfo(ino_t netns_inode)
{
struct sock_xinfo **xinfo = tfind(&netns_inode, &xinfo_tree, xinfo_compare);
if (xinfo)
return *xinfo;
return NULL;
}
bool is_nsfs_dev(dev_t dev)
{
return (dev == self_netns_sb.st_dev);
}
static const char *sock_decode_type(uint16_t type)
{
switch (type) {
case SOCK_STREAM:
return "stream";
case SOCK_DGRAM:
return "dgram";
case SOCK_RAW:
return "raw";
case SOCK_RDM:
return "rdm";
case SOCK_SEQPACKET:
return "seqpacket";
case SOCK_DCCP:
return "dccp";
case SOCK_PACKET:
return "packet";
default:
return "unknown";
}
}
/*
* Protocol specific code
*/
/*
* UNIX
*/
struct unix_xinfo {
struct sock_xinfo sock;
int acceptcon; /* flags */
uint16_t type;
uint8_t st;
char path[
UNIX_PATH_MAX
+ 1 /* for @ */
+ 1 /* \0? */
];
};
static const char *unix_decode_state(uint8_t st)
{
switch (st) {
case SS_FREE:
return "free";
case SS_UNCONNECTED:
return "unconnected";
case SS_CONNECTING:
return "connecting";
case SS_CONNECTED:
return "connected";
case SS_DISCONNECTING:
return "disconnecting";
default:
return "unknown";
}
}
static char *unix_get_name(struct sock_xinfo *sock_xinfo,
struct sock *sock)
{
struct unix_xinfo *ux = (struct unix_xinfo *)sock_xinfo;
const char *state = unix_decode_state(ux->st);
char *str = NULL;
if (sock->protoname && (strcmp(sock->protoname, "UNIX-STREAM") == 0))
xasprintf(&str, "state=%s%s%s",
(ux->acceptcon)? "listen": state,
*(ux->path)? " path=": "",
*(ux->path)? ux->path: "");
else
xasprintf(&str, "state=%s%s%s type=%s",
(ux->acceptcon)? "listen": state,
*(ux->path)? " path=": "",
*(ux->path)? ux->path: "",
sock_decode_type(ux->type));
return str;
}
static char *unix_get_type(struct sock_xinfo *sock_xinfo,
struct sock *sock __attribute__((__unused__)))
{
const char *str;
struct unix_xinfo *ux = (struct unix_xinfo *)sock_xinfo;
str = sock_decode_type(ux->type);
return strdup(str);
}
static char *unix_get_state(struct sock_xinfo *sock_xinfo,
struct sock *sock __attribute__((__unused__)))
{
const char *str;
struct unix_xinfo *ux = (struct unix_xinfo *)sock_xinfo;
if (ux->acceptcon)
return strdup("listen");
str = unix_decode_state(ux->st);
return strdup(str);
}
static bool unix_get_listening(struct sock_xinfo *sock_xinfo,
struct sock *sock __attribute__((__unused__)))
{
struct unix_xinfo *ux = (struct unix_xinfo *)sock_xinfo;
return ux->acceptcon;
}
static bool unix_fill_column(struct proc *proc __attribute__((__unused__)),
struct sock_xinfo *sock_xinfo,
struct sock *sock __attribute__((__unused__)),
struct libscols_line *ln __attribute__((__unused__)),
int column_id,
size_t column_index __attribute__((__unused__)),
char **str)
{
struct unix_xinfo *ux = (struct unix_xinfo *)sock_xinfo;
switch(column_id) {
case COL_UNIX_PATH:
if (*ux->path) {
*str = strdup(ux->path);
return true;
}
break;
}
return false;
}
static struct sock_xinfo_class unix_xinfo_class = {
.class = "unix",
.get_name = unix_get_name,
.get_type = unix_get_type,
.get_state = unix_get_state,
.get_listening = unix_get_listening,
.fill_column = unix_fill_column,
.free = NULL,
};
/* #define UNIX_LINE_LEN 54 + 21 + UNIX_LINE_LEN + 1 */
#define UNIX_LINE_LEN 256
static void load_xinfo_from_proc_unix(ino_t netns_inode)
{
char line[UNIX_LINE_LEN];
FILE *unix_fp;
unix_fp = fopen("/proc/net/unix", "r");
if (!unix_fp)
return;
if (fgets(line, sizeof(line), unix_fp) == NULL)
goto out;
if (!(line[0] == 'N' && line[1] == 'u' && line[2] == 'm'))
/* Unexpected line */
goto out;
while (fgets(line, sizeof(line), unix_fp)) {
uint64_t flags;
uint32_t type;
unsigned int st;
unsigned long inode;
char path[1 + UNIX_PATH_MAX +1];
struct unix_xinfo *ux;
memset(path, 0, sizeof(path));
if (sscanf(line, "%*x: %*x %*x %lx %x %x %lu %s",
&flags, &type, &st, &inode, path) < 4)
continue;
if (inode == 0)
continue;
ux = xmalloc(sizeof(struct unix_xinfo));
ux->sock.class = &unix_xinfo_class;
ux->sock.inode = (ino_t)inode;
ux->sock.netns_inode = netns_inode;
ux->acceptcon = !!flags;
ux->type = type;
ux->st = st;
strcpy(ux->path, path);
add_sock_info((struct sock_xinfo *)ux);
}
out:
fclose(unix_fp);
}
/*
* AF_INET
*/
struct inet_xinfo {
struct sock_xinfo sock;
uint32_t local_addr;
uint32_t remote_addr;
};
static bool inet_fill_column(struct proc *proc __attribute__((__unused__)),
struct inet_xinfo *inet,
struct sock *sock __attribute__((__unused__)),
struct libscols_line *ln __attribute__((__unused__)),
int column_id,
size_t column_index __attribute__((__unused__)),
char **str)
{
struct in_addr n;
struct in_addr *nptr = NULL;
char s[INET_ADDRSTRLEN];
switch(column_id) {
case COL_INET_LADDR:
n.s_addr = inet->local_addr;
nptr = &n;
break;
case COL_INET_RADDR:
n.s_addr = inet->remote_addr;
nptr = &n;
break;
default:
return false;
}
if (nptr && inet_ntop(AF_INET, &n, s, sizeof(s))) {
*str = strdup(s);
return true;
}
return false;
}
/*
* TCP
*/
struct tcp_xinfo {
struct inet_xinfo inet;
uint16_t local_port;
uint16_t remote_port;
unsigned int st;
};
enum tcp_state {
/*
* Taken from linux/include/net/tcp_states.h.
* (GPL-2.0-or-later)
*/
TCP_ESTABLISHED = 1,
TCP_SYN_SENT,
TCP_SYN_RECV,
TCP_FIN_WAIT1,
TCP_FIN_WAIT2,
TCP_TIME_WAIT,
TCP_CLOSE,
TCP_CLOSE_WAIT,
TCP_LAST_ACK,
TCP_LISTEN,
TCP_CLOSING,
TCP_NEW_SYN_RECV,
TCP_MAX_STATES /* Leave at the end! */
};
static const char *tcp_decode_state(unsigned int st)
{
const char * table [] = {
[TCP_ESTABLISHED] = "established",
[TCP_SYN_SENT] = "syn-sent",
[TCP_SYN_RECV] = "syn-recv",
[TCP_FIN_WAIT1] = "fin-wait1",
[TCP_FIN_WAIT2] = "fin-wait2",
[TCP_TIME_WAIT] = "time-wait",
[TCP_CLOSE] = "close",
[TCP_CLOSE_WAIT] = "close-wait",
[TCP_LAST_ACK] = "last-ack",
[TCP_LISTEN] = "listen",
[TCP_CLOSING] = "closing",
[TCP_NEW_SYN_RECV] = "new-syn-recv",
};
if (st < TCP_MAX_STATES)
return table[st];
return "unknown";
}
static char *tcp_get_name(struct sock_xinfo *sock_xinfo,
struct sock *sock __attribute__((__unused__)))
{
char *str = NULL;
struct inet_xinfo *inet = ((struct inet_xinfo *)sock_xinfo);
struct tcp_xinfo *tcp = ((struct tcp_xinfo *)sock_xinfo);
struct in_addr local_n, remote_n;
char local_s[INET_ADDRSTRLEN], remote_s[INET_ADDRSTRLEN];
local_n.s_addr = inet->local_addr;
remote_n.s_addr = inet->remote_addr;
if (!inet_ntop(AF_INET, &local_n, local_s, sizeof(local_s)))
xasprintf(&str, "state=%s", tcp_decode_state(tcp->st));
else if (tcp->st == TCP_LISTEN
|| !inet_ntop(AF_INET, &remote_n, remote_s, sizeof(remote_s)))
xasprintf(&str, "state=%s laddr=%s:%u",
tcp_decode_state(tcp->st),
local_s, tcp->local_port);
else
xasprintf(&str, "state=%s laddr=%s:%u raddr=%s:%u",
tcp_decode_state(tcp->st),
local_s, tcp->local_port,
remote_s, tcp->remote_port);
return str;
}
static char *tcp_get_type(struct sock_xinfo *sock_xinfo __attribute__((__unused__)),
struct sock *sock __attribute__((__unused__)))
{
return strdup("stream");
}
static char *tcp_get_state(struct sock_xinfo *sock_xinfo,
struct sock *sock __attribute__((__unused__)))
{
struct tcp_xinfo *tcp = (struct tcp_xinfo *)sock_xinfo;
return strdup(tcp_decode_state(tcp->st));
}
static bool tcp_get_listening(struct sock_xinfo *sock_xinfo,
struct sock *sock __attribute__((__unused__)))
{
struct tcp_xinfo *tcp = (struct tcp_xinfo *)sock_xinfo;
return tcp->st == TCP_LISTEN;
}
#define define_fill_column_func(l3,L3) \
static bool l3##_fill_column(struct proc *proc, \
struct sock_xinfo *sock_xinfo, \
struct sock *sock, \
struct libscols_line *ln, \
int column_id, \
size_t column_index, \
char **str) \
{ \
struct tcp_xinfo *tcp = (struct tcp_xinfo *)sock_xinfo; \
struct inet_xinfo *inet = (struct inet_xinfo *)sock_xinfo; \
struct in_addr n; \
bool has_laddr = false; \
char s[INET_ADDRSTRLEN]; \
unsigned int p; \
bool has_lport = false; \
\
if (inet_fill_column(proc, (struct inet_xinfo *)sock_xinfo, sock, ln, \
column_id, column_index, str)) \
return true; \
\
switch(column_id) { \
case COL_##L3##_LADDR: \
n.s_addr = inet->local_addr; \
has_laddr = true; \
p = (unsigned int)tcp->local_port; \
/* FALL THROUGH */ \
case COL_##L3##_RADDR: \
if (!has_laddr) { \
n.s_addr = inet->remote_addr; \
p = (unsigned int)tcp->remote_port; \
} \
if (inet_ntop(AF_INET, &n, s, sizeof(s))) \
xasprintf(str, "%s:%u", s, p); \
break; \
case COL_##L3##_LPORT: \
p = (unsigned int)tcp->local_port; \
has_lport = true; \
/* FALL THROUGH */ \
case COL_##L3##_RPORT: \
if (!has_lport) \
p = (unsigned int)tcp->remote_port; \
xasprintf(str, "%u", p); \
break; \
default: \
return false; \
} \
\
return true; \
}
define_fill_column_func(tcp, TCP)
static struct sock_xinfo_class tcp_xinfo_class = {
.class = "tcp",
.get_name = tcp_get_name,
.get_type = tcp_get_type,
.get_state = tcp_get_state,
.get_listening = tcp_get_listening,
.fill_column = tcp_fill_column,
.free = NULL,
};
static bool L3_verify_initial_line(const char *line)
{
/* At least we expect two white spaces. */
if (strncmp (line, " ", 2) != 0)
return false;
line += 2;
/* Skip white spaces. */
while (*line == ' ')
line++;
return (strncmp(line, "sl", 2) == 0);
}
static uint32_t kernel32_to_cpu(enum procfs_byteorder byteorder, uint32_t v)
{
if (byteorder == PROCFS_BYTEORDER_LITTLE)
return le32_to_cpu(v);
else
return be32_to_cpu(v);
}
#define TCP_LINE_LEN 256
static void load_xinfo_from_proc_inet_L3(ino_t netns_inode, const char *proc_file,
struct sock_xinfo_class *class)
{
char line[TCP_LINE_LEN];
FILE *tcp_fp;
tcp_fp = fopen(proc_file, "r");
if (!tcp_fp)
return;
if (fgets(line, sizeof(line), tcp_fp) == NULL)
goto out;
if (!L3_verify_initial_line(line))
/* Unexpected line */
goto out;
enum procfs_byteorder byteorder = procfs_get_byteorder(NULL);
while (fgets(line, sizeof(line), tcp_fp)) {
unsigned long local_addr;
unsigned long local_port;
unsigned long remote_addr;
unsigned long remote_port;
unsigned long st;
unsigned long long inode;
struct tcp_xinfo *tcp;
struct inet_xinfo *inet;
struct sock_xinfo *sock;
if (sscanf(line, "%*d: %lx:%lx %lx:%lx %lx %*x:%*x %*x:%*x %*x %*u %*u %lld",
&local_addr, &local_port, &remote_addr, &remote_port,
&st, &inode) != 6)
continue;
if (inode == 0)
continue;
tcp = xmalloc(sizeof(struct tcp_xinfo));
inet = (struct inet_xinfo *)tcp;
sock = (struct sock_xinfo *)inet;
sock->class = class;
sock->inode = (ino_t)inode;
sock->netns_inode = netns_inode;
inet->local_addr = kernel32_to_cpu(byteorder, local_addr);
tcp->local_port = local_port;
inet->remote_addr = kernel32_to_cpu(byteorder, remote_addr);
tcp->remote_port = remote_port;
tcp->st = st;
add_sock_info(sock);
}
out:
fclose(tcp_fp);
}
static void load_xinfo_from_proc_tcp(ino_t netns_inode)
{
load_xinfo_from_proc_inet_L3(netns_inode,
"/proc/net/tcp",
&tcp_xinfo_class);
}
/*
* UDP
*/
static char *udp_get_name(struct sock_xinfo *sock_xinfo,
struct sock *sock __attribute__((__unused__)))
{
char *str = NULL;
struct inet_xinfo *inet = ((struct inet_xinfo *)sock_xinfo);
struct tcp_xinfo *tcp = ((struct tcp_xinfo *)sock_xinfo);
struct in_addr local_n, remote_n;
char local_s[INET_ADDRSTRLEN], remote_s[INET_ADDRSTRLEN];
local_n.s_addr = inet->local_addr;
remote_n.s_addr = inet->remote_addr;
if (!inet_ntop(AF_INET, &local_n, local_s, sizeof(local_s)))
xasprintf(&str, "state=%s", tcp_decode_state(tcp->st));
else if ((remote_n.s_addr == 0 && tcp->remote_port == 0)
|| !inet_ntop(AF_INET, &remote_n, remote_s, sizeof(remote_s)))
xasprintf(&str, "state=%s laddr=%s:%u",
tcp_decode_state(tcp->st),
local_s, tcp->local_port);
else
xasprintf(&str, "state=%s laddr=%s:%u raddr=%s:%u",
tcp_decode_state(tcp->st),
local_s, tcp->local_port,
remote_s, tcp->remote_port);
return str;
}
static char *udp_get_type(struct sock_xinfo *sock_xinfo __attribute__((__unused__)),
struct sock *sock __attribute__((__unused__)))
{
return strdup("dgram");
}
define_fill_column_func(udp, UDP)
static struct sock_xinfo_class udp_xinfo_class = {
.class = "udp",
.get_name = udp_get_name,
.get_type = udp_get_type,
.get_state = tcp_get_state,
.get_listening = NULL,
.fill_column = udp_fill_column,
.free = NULL,
};
static void load_xinfo_from_proc_udp(ino_t netns_inode)
{
load_xinfo_from_proc_inet_L3(netns_inode,
"/proc/net/udp",
&udp_xinfo_class);
}