blob: 9d01a2aab5018f8a262b90d5b3ac05ee4544eb45 [file] [log] [blame]
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +00001/* $USAGI: $ */
2
3/*
4 * Copyright (C)2005 USAGI/WIDE Project
Stephen Hemmingerae665a52006-12-05 10:10:22 -08005 *
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +00006 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
Stephen Hemmingerae665a52006-12-05 10:10:22 -080010 *
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +000011 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Stephen Hemmingerae665a52006-12-05 10:10:22 -080015 *
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +000016 * You should have received a copy of the GNU General Public License
Stephen Hemminger4d98ab02013-12-06 15:05:07 -080017 * along with this program; if not, see <http://www.gnu.org/licenses>.
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +000018 */
19/*
20 * based on ipmonitor.c
21 */
22/*
23 * Authors:
24 * Masahide NAKAMURA @USAGI
25 */
26
27#include <stdio.h>
28#include <stdlib.h>
29#include <string.h>
Stephen Hemminger93390772015-04-10 13:17:54 -070030#include <netinet/in.h>
Stephen Hemminger93390772015-04-10 13:17:54 -070031
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +000032#include "utils.h"
33#include "xfrm.h"
34#include "ip_common.h"
35
36static void usage(void) __attribute__((noreturn));
Nicolas Dichtelb6ec53e2015-05-20 16:20:01 +020037int listen_all_nsid;
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +000038
39static void usage(void)
40{
Nicolas Dichtelb6ec53e2015-05-20 16:20:01 +020041 fprintf(stderr, "Usage: ip xfrm monitor [all-nsid] [ all | OBJECTS | help ]\n");
Vadim Kochanc16298b2015-02-14 20:07:44 +020042 fprintf(stderr, "OBJECTS := { acquire | expire | SA | aevent | policy | report }\n");
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +000043 exit(-1);
44}
45
46static int xfrm_acquire_print(const struct sockaddr_nl *who,
47 struct nlmsghdr *n, void *arg)
48{
Stephen Hemminger56f5daa2016-03-21 11:52:19 -070049 FILE *fp = (FILE *)arg;
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +000050 struct xfrm_user_acquire *xacq = NLMSG_DATA(n);
51 int len = n->nlmsg_len;
Stephen Hemminger56f5daa2016-03-21 11:52:19 -070052 struct rtattr *tb[XFRMA_MAX+1];
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +000053 __u16 family;
54
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +000055 len -= NLMSG_LENGTH(sizeof(*xacq));
56 if (len < 0) {
57 fprintf(stderr, "BUG: wrong nlmsg len %d\n", len);
58 return -1;
59 }
60
61 parse_rtattr(tb, XFRMA_MAX, XFRMACQ_RTA(xacq), len);
shemminger90f93022005-06-07 21:55:55 +000062
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +000063 family = xacq->sel.family;
64 if (family == AF_UNSPEC)
65 family = xacq->policy.sel.family;
66 if (family == AF_UNSPEC)
67 family = preferred_family;
68
69 fprintf(fp, "acquire ");
70
71 fprintf(fp, "proto %s ", strxf_xfrmproto(xacq->id.proto));
72 if (show_stats > 0 || xacq->id.spi) {
73 __u32 spi = ntohl(xacq->id.spi);
Stephen Hemminger56f5daa2016-03-21 11:52:19 -070074
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +000075 fprintf(fp, "spi 0x%08x", spi);
76 if (show_stats > 0)
77 fprintf(fp, "(%u)", spi);
78 fprintf(fp, " ");
79 }
80 fprintf(fp, "%s", _SL_);
81
82 xfrm_selector_print(&xacq->sel, family, fp, " sel ");
83
84 xfrm_policy_info_print(&xacq->policy, tb, fp, " ", " policy ");
85
86 if (show_stats > 0)
87 fprintf(fp, " seq 0x%08u ", xacq->seq);
88 if (show_stats > 0) {
89 fprintf(fp, "%s-mask %s ",
90 strxf_algotype(XFRMA_ALG_CRYPT),
91 strxf_mask32(xacq->ealgos));
92 fprintf(fp, "%s-mask %s ",
93 strxf_algotype(XFRMA_ALG_AUTH),
94 strxf_mask32(xacq->aalgos));
95 fprintf(fp, "%s-mask %s",
96 strxf_algotype(XFRMA_ALG_COMP),
97 strxf_mask32(xacq->calgos));
98 }
99 fprintf(fp, "%s", _SL_);
100
101 if (oneline)
102 fprintf(fp, "\n");
shemminger669ae742005-11-07 18:39:30 +0000103 fflush(fp);
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000104
105 return 0;
106}
107
Masahide NAKAMURAefe69c12007-08-24 11:05:24 +0900108static int xfrm_state_flush_print(const struct sockaddr_nl *who,
109 struct nlmsghdr *n, void *arg)
110{
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700111 FILE *fp = (FILE *)arg;
Masahide NAKAMURAefe69c12007-08-24 11:05:24 +0900112 struct xfrm_usersa_flush *xsf = NLMSG_DATA(n);
113 int len = n->nlmsg_len;
114 const char *str;
115
116 len -= NLMSG_SPACE(sizeof(*xsf));
117 if (len < 0) {
118 fprintf(stderr, "BUG: wrong nlmsg len %d\n", len);
119 return -1;
120 }
121
122 fprintf(fp, "Flushed state ");
123
124 str = strxf_xfrmproto(xsf->proto);
125 if (str)
126 fprintf(fp, "proto %s", str);
127 else
128 fprintf(fp, "proto %u", xsf->proto);
129 fprintf(fp, "%s", _SL_);
130
131 if (oneline)
132 fprintf(fp, "\n");
133 fflush(fp);
134
135 return 0;
136}
137
138static int xfrm_policy_flush_print(const struct sockaddr_nl *who,
139 struct nlmsghdr *n, void *arg)
140{
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700141 struct rtattr *tb[XFRMA_MAX+1];
142 FILE *fp = (FILE *)arg;
Masahide NAKAMURAefe69c12007-08-24 11:05:24 +0900143 int len = n->nlmsg_len;
144
145 len -= NLMSG_SPACE(0);
146 if (len < 0) {
147 fprintf(stderr, "BUG: wrong nlmsg len %d\n", len);
148 return -1;
149 }
150
151 fprintf(fp, "Flushed policy ");
152
153 parse_rtattr(tb, XFRMA_MAX, NLMSG_DATA(n), len);
154
155 if (tb[XFRMA_POLICY_TYPE]) {
156 struct xfrm_userpolicy_type *upt;
157
158 fprintf(fp, "ptype ");
159
160 if (RTA_PAYLOAD(tb[XFRMA_POLICY_TYPE]) < sizeof(*upt))
161 fprintf(fp, "(ERROR truncated)");
162
163 upt = (struct xfrm_userpolicy_type *)RTA_DATA(tb[XFRMA_POLICY_TYPE]);
164 fprintf(fp, "%s ", strxf_ptype(upt->type));
165 }
166
167 fprintf(fp, "%s", _SL_);
168
169 if (oneline)
170 fprintf(fp, "\n");
171 fflush(fp);
172
173 return 0;
174}
175
Masahide NAKAMURAc54f31e2006-12-05 19:16:05 +0900176static int xfrm_report_print(const struct sockaddr_nl *who,
177 struct nlmsghdr *n, void *arg)
178{
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700179 FILE *fp = (FILE *)arg;
Masahide NAKAMURAc54f31e2006-12-05 19:16:05 +0900180 struct xfrm_user_report *xrep = NLMSG_DATA(n);
181 int len = n->nlmsg_len;
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700182 struct rtattr *tb[XFRMA_MAX+1];
Masahide NAKAMURAc54f31e2006-12-05 19:16:05 +0900183 __u16 family;
184
Masahide NAKAMURAc54f31e2006-12-05 19:16:05 +0900185 len -= NLMSG_LENGTH(sizeof(*xrep));
186 if (len < 0) {
187 fprintf(stderr, "BUG: wrong nlmsg len %d\n", len);
188 return -1;
189 }
190
191 family = xrep->sel.family;
192 if (family == AF_UNSPEC)
193 family = preferred_family;
194
195 fprintf(fp, "report ");
196
197 fprintf(fp, "proto %s ", strxf_xfrmproto(xrep->proto));
198 fprintf(fp, "%s", _SL_);
199
200 xfrm_selector_print(&xrep->sel, family, fp, " sel ");
201
202 parse_rtattr(tb, XFRMA_MAX, XFRMREP_RTA(xrep), len);
203
204 xfrm_xfrma_print(tb, family, fp, " ");
205
206 if (oneline)
207 fprintf(fp, "\n");
208
209 return 0;
210}
211
Stephen Hemmingerd1f28cf2013-02-12 11:09:03 -0800212static void xfrm_ae_flags_print(__u32 flags, void *arg)
jamalc9fd9742006-12-07 20:31:14 -0500213{
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700214 FILE *fp = (FILE *)arg;
215
jamalc9fd9742006-12-07 20:31:14 -0500216 fprintf(fp, " (0x%x) ", flags);
217 if (!flags)
218 return;
219 if (flags & XFRM_AE_CR)
220 fprintf(fp, " replay update ");
221 if (flags & XFRM_AE_CE)
222 fprintf(fp, " timer expired ");
223 if (flags & XFRM_AE_CU)
224 fprintf(fp, " policy updated ");
225
226}
227
Florian Westphal598a42c2012-03-13 12:35:25 +0000228static void xfrm_usersa_print(const struct xfrm_usersa_id *sa_id, __u32 reqid, FILE *fp)
229{
Stephen Hemminger656111b2014-08-04 10:30:35 -0700230 fprintf(fp, "dst %s ",
Phil Sutter2e96d2c2016-03-22 19:35:16 +0100231 rt_addr_n2a(sa_id->family, sizeof(sa_id->daddr), &sa_id->daddr));
Florian Westphal598a42c2012-03-13 12:35:25 +0000232
233 fprintf(fp, " reqid 0x%x", reqid);
234
235 fprintf(fp, " protocol %s ", strxf_proto(sa_id->proto));
236 fprintf(fp, " SPI 0x%x", ntohl(sa_id->spi));
237}
238
jamalc9fd9742006-12-07 20:31:14 -0500239static int xfrm_ae_print(const struct sockaddr_nl *who,
240 struct nlmsghdr *n, void *arg)
241{
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700242 FILE *fp = (FILE *)arg;
jamalc9fd9742006-12-07 20:31:14 -0500243 struct xfrm_aevent_id *id = NLMSG_DATA(n);
jamalc9fd9742006-12-07 20:31:14 -0500244
245 fprintf(fp, "Async event ");
246 xfrm_ae_flags_print(id->flags, arg);
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700247 fprintf(fp, "\n\t");
Eric W. Biederman26dcdf32015-03-15 14:48:32 -0500248 fprintf(fp, "src %s ", rt_addr_n2a(id->sa_id.family,
Phil Sutter2e96d2c2016-03-22 19:35:16 +0100249 sizeof(id->saddr), &id->saddr));
Florian Westphal598a42c2012-03-13 12:35:25 +0000250
251 xfrm_usersa_print(&id->sa_id, id->reqid, fp);
jamalc9fd9742006-12-07 20:31:14 -0500252
253 fprintf(fp, "\n");
254 fflush(fp);
255
256 return 0;
257}
258
Stephen Hemminger656111b2014-08-04 10:30:35 -0700259static void xfrm_print_addr(FILE *fp, int family, xfrm_address_t *a)
Florian Westphal598a42c2012-03-13 12:35:25 +0000260{
Phil Sutter2e96d2c2016-03-22 19:35:16 +0100261 fprintf(fp, "%s", rt_addr_n2a(family, sizeof(*a), a));
Florian Westphal598a42c2012-03-13 12:35:25 +0000262}
263
264static int xfrm_mapping_print(const struct sockaddr_nl *who,
265 struct nlmsghdr *n, void *arg)
266{
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700267 FILE *fp = (FILE *)arg;
Florian Westphal598a42c2012-03-13 12:35:25 +0000268 struct xfrm_user_mapping *map = NLMSG_DATA(n);
269
270 fprintf(fp, "Mapping change ");
Stephen Hemminger656111b2014-08-04 10:30:35 -0700271 xfrm_print_addr(fp, map->id.family, &map->old_saddr);
Florian Westphal598a42c2012-03-13 12:35:25 +0000272
273 fprintf(fp, ":%d -> ", ntohs(map->old_sport));
Stephen Hemminger656111b2014-08-04 10:30:35 -0700274 xfrm_print_addr(fp, map->id.family, &map->new_saddr);
Florian Westphal598a42c2012-03-13 12:35:25 +0000275 fprintf(fp, ":%d\n\t", ntohs(map->new_sport));
276
277 xfrm_usersa_print(&map->id, map->reqid, fp);
278
279 fprintf(fp, "\n");
280 fflush(fp);
281 return 0;
282}
283
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000284static int xfrm_accept_msg(const struct sockaddr_nl *who,
Nicolas Dichtel0628cdd2015-05-20 16:19:58 +0200285 struct rtnl_ctrl_data *ctrl,
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000286 struct nlmsghdr *n, void *arg)
287{
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700288 FILE *fp = (FILE *)arg;
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000289
shemminger90f93022005-06-07 21:55:55 +0000290 if (timestamp)
291 print_timestamp(fp);
292
Nicolas Dichtelb6ec53e2015-05-20 16:20:01 +0200293 if (listen_all_nsid) {
294 if (ctrl == NULL || ctrl->nsid < 0)
295 fprintf(fp, "[nsid current]");
296 else
297 fprintf(fp, "[nsid %d]", ctrl->nsid);
298 }
299
Masahide NAKAMURAefe69c12007-08-24 11:05:24 +0900300 switch (n->nlmsg_type) {
301 case XFRM_MSG_NEWSA:
302 case XFRM_MSG_DELSA:
303 case XFRM_MSG_UPDSA:
304 case XFRM_MSG_EXPIRE:
shemmingerc595c792005-11-01 23:03:03 +0000305 xfrm_state_print(who, n, arg);
306 return 0;
Masahide NAKAMURAefe69c12007-08-24 11:05:24 +0900307 case XFRM_MSG_NEWPOLICY:
308 case XFRM_MSG_DELPOLICY:
309 case XFRM_MSG_UPDPOLICY:
310 case XFRM_MSG_POLEXPIRE:
shemmingerc595c792005-11-01 23:03:03 +0000311 xfrm_policy_print(who, n, arg);
312 return 0;
Masahide NAKAMURAefe69c12007-08-24 11:05:24 +0900313 case XFRM_MSG_ACQUIRE:
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000314 xfrm_acquire_print(who, n, arg);
315 return 0;
Masahide NAKAMURAefe69c12007-08-24 11:05:24 +0900316 case XFRM_MSG_FLUSHSA:
317 xfrm_state_flush_print(who, n, arg);
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000318 return 0;
Masahide NAKAMURAefe69c12007-08-24 11:05:24 +0900319 case XFRM_MSG_FLUSHPOLICY:
320 xfrm_policy_flush_print(who, n, arg);
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000321 return 0;
Masahide NAKAMURAefe69c12007-08-24 11:05:24 +0900322 case XFRM_MSG_REPORT:
Masahide NAKAMURAc54f31e2006-12-05 19:16:05 +0900323 xfrm_report_print(who, n, arg);
324 return 0;
Masahide NAKAMURAefe69c12007-08-24 11:05:24 +0900325 case XFRM_MSG_NEWAE:
jamalc9fd9742006-12-07 20:31:14 -0500326 xfrm_ae_print(who, n, arg);
327 return 0;
Florian Westphal598a42c2012-03-13 12:35:25 +0000328 case XFRM_MSG_MAPPING:
329 xfrm_mapping_print(who, n, arg);
330 return 0;
Masahide NAKAMURAefe69c12007-08-24 11:05:24 +0900331 default:
332 break;
jamalc9fd9742006-12-07 20:31:14 -0500333 }
Masahide NAKAMURAefe69c12007-08-24 11:05:24 +0900334
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000335 if (n->nlmsg_type != NLMSG_ERROR && n->nlmsg_type != NLMSG_NOOP &&
336 n->nlmsg_type != NLMSG_DONE) {
shemmingerc595c792005-11-01 23:03:03 +0000337 fprintf(fp, "Unknown message: %08d 0x%08x 0x%08x\n",
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000338 n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags);
339 }
340 return 0;
341}
342
Stephen Hemminger77219712006-09-25 17:27:37 -0700343extern struct rtnl_handle rth;
344
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000345int do_xfrm_monitor(int argc, char **argv)
346{
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000347 char *file = NULL;
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700348 unsigned int groups = ~((unsigned)0); /* XXX */
349 int lacquire = 0;
350 int lexpire = 0;
351 int laevent = 0;
352 int lpolicy = 0;
353 int lsa = 0;
354 int lreport = 0;
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000355
Stephen Hemminger77219712006-09-25 17:27:37 -0700356 rtnl_close(&rth);
357
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000358 while (argc > 0) {
359 if (matches(*argv, "file") == 0) {
360 NEXT_ARG();
361 file = *argv;
Nicolas Dichtelb6ec53e2015-05-20 16:20:01 +0200362 } else if (matches(*argv, "all-nsid") == 0) {
363 listen_all_nsid = 1;
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000364 } else if (matches(*argv, "acquire") == 0) {
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700365 lacquire = 1;
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000366 groups = 0;
367 } else if (matches(*argv, "expire") == 0) {
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700368 lexpire = 1;
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000369 groups = 0;
shemmingerc595c792005-11-01 23:03:03 +0000370 } else if (matches(*argv, "SA") == 0) {
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700371 lsa = 1;
shemmingerc595c792005-11-01 23:03:03 +0000372 groups = 0;
jamalc9fd9742006-12-07 20:31:14 -0500373 } else if (matches(*argv, "aevent") == 0) {
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700374 laevent = 1;
jamalc9fd9742006-12-07 20:31:14 -0500375 groups = 0;
shemmingerc595c792005-11-01 23:03:03 +0000376 } else if (matches(*argv, "policy") == 0) {
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700377 lpolicy = 1;
shemmingerc595c792005-11-01 23:03:03 +0000378 groups = 0;
Masahide NAKAMURAc54f31e2006-12-05 19:16:05 +0900379 } else if (matches(*argv, "report") == 0) {
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700380 lreport = 1;
Masahide NAKAMURAc54f31e2006-12-05 19:16:05 +0900381 groups = 0;
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000382 } else if (matches(*argv, "help") == 0) {
383 usage();
Vadim Kochan5bf9f5c2015-02-14 19:45:04 +0200384 } else if (strcmp(*argv, "all")) {
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000385 fprintf(stderr, "Argument \"%s\" is unknown, try \"ip xfrm monitor help\".\n", *argv);
386 exit(-1);
387 }
388 argc--; argv++;
389 }
390
391 if (lacquire)
jamal7b822512006-12-07 20:58:23 -0500392 groups |= nl_mgrp(XFRMNLGRP_ACQUIRE);
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000393 if (lexpire)
jamal7b822512006-12-07 20:58:23 -0500394 groups |= nl_mgrp(XFRMNLGRP_EXPIRE);
shemmingerc595c792005-11-01 23:03:03 +0000395 if (lsa)
jamal7b822512006-12-07 20:58:23 -0500396 groups |= nl_mgrp(XFRMNLGRP_SA);
shemmingerc595c792005-11-01 23:03:03 +0000397 if (lpolicy)
jamal7b822512006-12-07 20:58:23 -0500398 groups |= nl_mgrp(XFRMNLGRP_POLICY);
jamalc9fd9742006-12-07 20:31:14 -0500399 if (laevent)
jamal7b822512006-12-07 20:58:23 -0500400 groups |= nl_mgrp(XFRMNLGRP_AEVENTS);
Masahide NAKAMURAc54f31e2006-12-05 19:16:05 +0900401 if (lreport)
jamal7b822512006-12-07 20:58:23 -0500402 groups |= nl_mgrp(XFRMNLGRP_REPORT);
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000403
404 if (file) {
405 FILE *fp;
Stephen Hemmingere49b51d2015-12-30 17:19:04 -0800406 int err;
407
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000408 fp = fopen(file, "r");
409 if (fp == NULL) {
410 perror("Cannot fopen");
411 exit(-1);
412 }
Stephen Hemmingere49b51d2015-12-30 17:19:04 -0800413 err = rtnl_from_file(fp, xfrm_accept_msg, stdout);
414 fclose(fp);
415 return err;
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000416 }
417
shemmingerc595c792005-11-01 23:03:03 +0000418 if (rtnl_open_byproto(&rth, groups, NETLINK_XFRM) < 0)
419 exit(1);
Nicolas Dichtelb6ec53e2015-05-20 16:20:01 +0200420 if (listen_all_nsid && rtnl_listen_all_nsid(&rth) < 0)
421 exit(1);
shemmingerc595c792005-11-01 23:03:03 +0000422
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700423 if (rtnl_listen(&rth, xfrm_accept_msg, (void *)stdout) < 0)
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000424 exit(2);
425
shemminger351efcd2005-09-01 19:21:50 +0000426 return 0;
linux-ipv6.org!nakamf9cb3a22005-03-22 16:13:21 +0000427}