4 * Copyright (C)2004 USAGI/WIDE Project
6 * 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.
11 * 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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses>.
24 * Masahide NAKAMURA @USAGI
33 #include "ip_common.h"
35 /* #define NLMSG_DELETEALL_BUF_SIZE (4096-512) */
36 #define NLMSG_DELETEALL_BUF_SIZE 8192
39 * Receiving buffer defines:
41 * data = struct xfrm_usersa_info
44 * ... (max count of rtattr is XFRM_MAX+1
46 * each rtattr data = struct xfrm_algo(dynamic size) or xfrm_address_t
48 #define NLMSG_BUF_SIZE 4096
49 #define RTA_BUF_SIZE 2048
50 #define XFRM_ALGO_KEY_BUF_SIZE 512
51 #define CTX_BUF_SIZE 256
53 static void usage(void) __attribute__((noreturn
));
55 static void usage(void)
58 "Usage: ip xfrm state { add | update } ID [ ALGO-LIST ] [ mode MODE ]\n"
59 " [ mark MARK [ mask MASK ] ] [ reqid REQID ] [ seq SEQ ]\n"
60 " [ replay-window SIZE ] [ replay-seq SEQ ] [ replay-oseq SEQ ]\n"
61 " [ replay-seq-hi SEQ ] [ replay-oseq-hi SEQ ]\n"
62 " [ flag FLAG-LIST ] [ sel SELECTOR ] [ LIMIT-LIST ] [ encap ENCAP ]\n"
63 " [ coa ADDR[/PLEN] ] [ ctx CTX ] [ extra-flag EXTRA-FLAG-LIST ]\n"
64 " [ offload [dev DEV] dir DIR ]\n"
65 " [ output-mark OUTPUT-MARK ]\n"
67 "Usage: ip xfrm state allocspi ID [ mode MODE ] [ mark MARK [ mask MASK ] ]\n"
68 " [ reqid REQID ] [ seq SEQ ] [ min SPI max SPI ]\n"
69 "Usage: ip xfrm state { delete | get } ID [ mark MARK [ mask MASK ] ]\n"
70 "Usage: ip xfrm state deleteall [ ID ] [ mode MODE ] [ reqid REQID ]\n"
71 " [ flag FLAG-LIST ]\n"
72 "Usage: ip xfrm state list [ nokeys ] [ ID ] [ mode MODE ] [ reqid REQID ]\n"
73 " [ flag FLAG-LIST ]\n"
74 "Usage: ip xfrm state flush [ proto XFRM-PROTO ]\n"
75 "Usage: ip xfrm state count\n"
76 "ID := [ src ADDR ] [ dst ADDR ] [ proto XFRM-PROTO ] [ spi SPI ]\n"
79 "%s | %s | %s | %s | %s\n",
80 strxf_xfrmproto(IPPROTO_ESP
),
81 strxf_xfrmproto(IPPROTO_AH
),
82 strxf_xfrmproto(IPPROTO_COMP
),
83 strxf_xfrmproto(IPPROTO_ROUTING
),
84 strxf_xfrmproto(IPPROTO_DSTOPTS
));
86 "ALGO-LIST := [ ALGO-LIST ] ALGO\n"
90 strxf_algotype(XFRMA_ALG_CRYPT
),
91 strxf_algotype(XFRMA_ALG_AUTH
));
93 " } ALGO-NAME ALGO-KEYMAT |\n"
94 " %s", strxf_algotype(XFRMA_ALG_AUTH_TRUNC
));
96 " ALGO-NAME ALGO-KEYMAT ALGO-TRUNC-LEN |\n"
97 " %s", strxf_algotype(XFRMA_ALG_AEAD
));
99 " ALGO-NAME ALGO-KEYMAT ALGO-ICV-LEN |\n"
100 " %s", strxf_algotype(XFRMA_ALG_COMP
));
103 "MODE := transport | tunnel | beet | ro | in_trigger\n"
104 "FLAG-LIST := [ FLAG-LIST ] FLAG\n"
105 "FLAG := noecn | decap-dscp | nopmtudisc | wildrecv | icmp | af-unspec | align4 | esn\n"
106 "EXTRA-FLAG-LIST := [ EXTRA-FLAG-LIST ] EXTRA-FLAG\n"
107 "EXTRA-FLAG := dont-encap-dscp\n"
108 "SELECTOR := [ src ADDR[/PLEN] ] [ dst ADDR[/PLEN] ] [ dev DEV ] [ UPSPEC ]\n"
109 "UPSPEC := proto { { ");
112 strxf_proto(IPPROTO_TCP
),
113 strxf_proto(IPPROTO_UDP
),
114 strxf_proto(IPPROTO_SCTP
),
115 strxf_proto(IPPROTO_DCCP
));
117 " } [ sport PORT ] [ dport PORT ] |\n"
121 strxf_proto(IPPROTO_ICMP
),
122 strxf_proto(IPPROTO_ICMPV6
),
123 strxf_proto(IPPROTO_MH
));
125 " } [ type NUMBER ] [ code NUMBER ] |\n");
127 " %s", strxf_proto(IPPROTO_GRE
));
129 " [ key { DOTTED-QUAD | NUMBER } ] | PROTO }\n"
130 "LIMIT-LIST := [ LIMIT-LIST ] limit LIMIT\n"
131 "LIMIT := { time-soft | time-hard | time-use-soft | time-use-hard } SECONDS |\n"
132 " { byte-soft | byte-hard } SIZE | { packet-soft | packet-hard } COUNT\n"
133 "ENCAP := { espinudp | espinudp-nonike } SPORT DPORT OADDR\n"
134 "DIR := in | out\n");
139 static int xfrm_algo_parse(struct xfrm_algo
*alg
, enum xfrm_attr_type_t type
,
140 char *name
, char *key
, char *buf
, int max
)
143 int slen
= strlen(key
);
146 /* XXX: verifying both name and key is required! */
147 fprintf(stderr
, "warning: ALGO-NAME/ALGO-KEYMAT values will be sent to the kernel promiscuously! (verifying them isn't implemented yet)\n");
150 strlcpy(alg
->alg_name
, name
, sizeof(alg
->alg_name
));
152 if (slen
> 2 && strncmp(key
, "0x", 2) == 0) {
153 /* split two chars "0x" from the top */
159 /* Converting hexadecimal numbered string into real key;
160 * Convert each two chars into one char(value). If number
161 * of the length is odd, add zero on the top for rounding.
164 /* calculate length of the converted values(real key) */
165 len
= (plen
+ 1) / 2;
167 invarg("ALGO-KEYMAT value makes buffer overflow\n", key
);
169 for (i
= -(plen
% 2), j
= 0; j
< len
; i
+= 2, j
++) {
173 vbuf
[0] = i
>= 0 ? p
[i
] : '0';
177 if (get_u8(&val
, vbuf
, 16))
178 invarg("ALGO-KEYMAT value is invalid", key
);
186 invarg("ALGO-KEYMAT value makes buffer overflow\n", key
);
188 memcpy(buf
, key
, len
);
192 alg
->alg_key_len
= len
* 8;
197 static int xfrm_seq_parse(__u32
*seq
, int *argcp
, char ***argvp
)
200 char **argv
= *argvp
;
202 if (get_be32(seq
, *argv
, 0))
203 invarg("SEQ value is invalid", *argv
);
211 static int xfrm_state_flag_parse(__u8
*flags
, int *argcp
, char ***argvp
)
214 char **argv
= *argvp
;
215 int len
= strlen(*argv
);
217 if (len
> 2 && strncmp(*argv
, "0x", 2) == 0) {
220 if (get_u8(&val
, *argv
, 16))
221 invarg("FLAG value is invalid", *argv
);
225 if (strcmp(*argv
, "noecn") == 0)
226 *flags
|= XFRM_STATE_NOECN
;
227 else if (strcmp(*argv
, "decap-dscp") == 0)
228 *flags
|= XFRM_STATE_DECAP_DSCP
;
229 else if (strcmp(*argv
, "nopmtudisc") == 0)
230 *flags
|= XFRM_STATE_NOPMTUDISC
;
231 else if (strcmp(*argv
, "wildrecv") == 0)
232 *flags
|= XFRM_STATE_WILDRECV
;
233 else if (strcmp(*argv
, "icmp") == 0)
234 *flags
|= XFRM_STATE_ICMP
;
235 else if (strcmp(*argv
, "af-unspec") == 0)
236 *flags
|= XFRM_STATE_AF_UNSPEC
;
237 else if (strcmp(*argv
, "align4") == 0)
238 *flags
|= XFRM_STATE_ALIGN4
;
239 else if (strcmp(*argv
, "esn") == 0)
240 *flags
|= XFRM_STATE_ESN
;
242 PREV_ARG(); /* back track */
258 static int xfrm_state_extra_flag_parse(__u32
*extra_flags
, int *argcp
, char ***argvp
)
261 char **argv
= *argvp
;
262 int len
= strlen(*argv
);
264 if (len
> 2 && strncmp(*argv
, "0x", 2) == 0) {
267 if (get_u32(&val
, *argv
, 16))
268 invarg("\"EXTRA-FLAG\" is invalid", *argv
);
272 if (strcmp(*argv
, "dont-encap-dscp") == 0)
273 *extra_flags
|= XFRM_SA_XFLAG_DONT_ENCAP_DSCP
;
275 PREV_ARG(); /* back track */
291 static int xfrm_offload_dir_parse(__u8
*dir
, int *argcp
, char ***argvp
)
294 char **argv
= *argvp
;
296 if (strcmp(*argv
, "in") == 0)
297 *dir
= XFRM_OFFLOAD_INBOUND
;
298 else if (strcmp(*argv
, "out") == 0)
301 invarg("DIR value is invalid", *argv
);
309 static int xfrm_state_modify(int cmd
, unsigned int flags
, int argc
, char **argv
)
311 struct rtnl_handle rth
;
314 struct xfrm_usersa_info xsinfo
;
315 char buf
[RTA_BUF_SIZE
];
317 .n
.nlmsg_len
= NLMSG_LENGTH(sizeof(req
.xsinfo
)),
318 .n
.nlmsg_flags
= NLM_F_REQUEST
| flags
,
320 .xsinfo
.family
= preferred_family
,
321 .xsinfo
.lft
.soft_byte_limit
= XFRM_INF
,
322 .xsinfo
.lft
.hard_byte_limit
= XFRM_INF
,
323 .xsinfo
.lft
.soft_packet_limit
= XFRM_INF
,
324 .xsinfo
.lft
.hard_packet_limit
= XFRM_INF
,
326 struct xfrm_replay_state replay
= {};
327 struct xfrm_replay_state_esn replay_esn
= {};
328 struct xfrm_user_offload xuo
= {};
329 unsigned int ifindex
= 0;
331 bool is_offload
= false;
332 __u32 replay_window
= 0;
333 __u32 seq
= 0, oseq
= 0, seq_hi
= 0, oseq_hi
= 0;
341 __u32 extra_flags
= 0;
342 struct xfrm_mark mark
= {0, 0};
344 struct xfrm_user_sec_ctx sctx
;
345 char str
[CTX_BUF_SIZE
];
347 __u32 output_mark
= 0;
348 bool is_if_id_set
= false;
352 if (strcmp(*argv
, "mode") == 0) {
354 xfrm_mode_parse(&req
.xsinfo
.mode
, &argc
, &argv
);
355 } else if (strcmp(*argv
, "mark") == 0) {
356 xfrm_parse_mark(&mark
, &argc
, &argv
);
357 } else if (strcmp(*argv
, "reqid") == 0) {
359 xfrm_reqid_parse(&req
.xsinfo
.reqid
, &argc
, &argv
);
360 } else if (strcmp(*argv
, "seq") == 0) {
362 xfrm_seq_parse(&req
.xsinfo
.seq
, &argc
, &argv
);
363 } else if (strcmp(*argv
, "replay-window") == 0) {
365 if (get_u32(&replay_window
, *argv
, 0))
366 invarg("value after \"replay-window\" is invalid", *argv
);
367 } else if (strcmp(*argv
, "replay-seq") == 0) {
369 if (get_u32(&seq
, *argv
, 0))
370 invarg("value after \"replay-seq\" is invalid", *argv
);
371 } else if (strcmp(*argv
, "replay-seq-hi") == 0) {
373 if (get_u32(&seq_hi
, *argv
, 0))
374 invarg("value after \"replay-seq-hi\" is invalid", *argv
);
375 } else if (strcmp(*argv
, "replay-oseq") == 0) {
377 if (get_u32(&oseq
, *argv
, 0))
378 invarg("value after \"replay-oseq\" is invalid", *argv
);
379 } else if (strcmp(*argv
, "replay-oseq-hi") == 0) {
381 if (get_u32(&oseq_hi
, *argv
, 0))
382 invarg("value after \"replay-oseq-hi\" is invalid", *argv
);
383 } else if (strcmp(*argv
, "flag") == 0) {
385 xfrm_state_flag_parse(&req
.xsinfo
.flags
, &argc
, &argv
);
386 } else if (strcmp(*argv
, "extra-flag") == 0) {
388 xfrm_state_extra_flag_parse(&extra_flags
, &argc
, &argv
);
389 } else if (strcmp(*argv
, "sel") == 0) {
391 preferred_family
= AF_UNSPEC
;
392 xfrm_selector_parse(&req
.xsinfo
.sel
, &argc
, &argv
);
393 preferred_family
= req
.xsinfo
.sel
.family
;
394 } else if (strcmp(*argv
, "limit") == 0) {
396 xfrm_lifetime_cfg_parse(&req
.xsinfo
.lft
, &argc
, &argv
);
397 } else if (strcmp(*argv
, "encap") == 0) {
398 struct xfrm_encap_tmpl encap
;
401 xfrm_encap_type_parse(&encap
.encap_type
, &argc
, &argv
);
403 if (get_be16(&encap
.encap_sport
, *argv
, 0))
404 invarg("SPORT value after \"encap\" is invalid", *argv
);
406 if (get_be16(&encap
.encap_dport
, *argv
, 0))
407 invarg("DPORT value after \"encap\" is invalid", *argv
);
409 get_addr(&oa
, *argv
, AF_UNSPEC
);
410 memcpy(&encap
.encap_oa
, &oa
.data
, sizeof(encap
.encap_oa
));
411 addattr_l(&req
.n
, sizeof(req
.buf
), XFRMA_ENCAP
,
412 (void *)&encap
, sizeof(encap
));
413 } else if (strcmp(*argv
, "coa") == 0) {
415 xfrm_address_t xcoa
= {};
418 duparg("coa", *argv
);
423 get_prefix(&coa
, *argv
, preferred_family
);
424 if (coa
.family
== AF_UNSPEC
)
425 invarg("value after \"coa\" has an unrecognized address family", *argv
);
426 if (coa
.bytelen
> sizeof(xcoa
))
427 invarg("value after \"coa\" is too large", *argv
);
429 memcpy(&xcoa
, &coa
.data
, coa
.bytelen
);
431 addattr_l(&req
.n
, sizeof(req
.buf
), XFRMA_COADDR
,
432 (void *)&xcoa
, sizeof(xcoa
));
433 } else if (strcmp(*argv
, "ctx") == 0) {
437 duparg("ctx", *argv
);
443 xfrm_sctx_parse((char *)&ctx
.str
, context
, &ctx
.sctx
);
444 addattr_l(&req
.n
, sizeof(req
.buf
), XFRMA_SEC_CTX
,
445 (void *)&ctx
, ctx
.sctx
.len
);
446 } else if (strcmp(*argv
, "offload") == 0) {
449 if (strcmp(*argv
, "dev") == 0) {
451 ifindex
= ll_name_to_index(*argv
);
453 invarg("value after \"offload dev\" is invalid", *argv
);
458 if (strcmp(*argv
, "dir") == 0) {
460 xfrm_offload_dir_parse(&dir
, &argc
, &argv
);
462 invarg("value after \"offload dir\" is invalid", *argv
);
465 } else if (strcmp(*argv
, "output-mark") == 0) {
467 if (get_u32(&output_mark
, *argv
, 0))
468 invarg("value after \"output-mark\" is invalid", *argv
);
469 } else if (strcmp(*argv
, "if_id") == 0) {
471 if (get_u32(&if_id
, *argv
, 0))
472 invarg("value after \"if_id\" is invalid", *argv
);
475 /* try to assume ALGO */
476 int type
= xfrm_algotype_getbyname(*argv
);
480 case XFRMA_ALG_CRYPT
:
482 case XFRMA_ALG_AUTH_TRUNC
:
488 struct xfrm_algo alg
;
489 struct xfrm_algo_aead aead
;
490 struct xfrm_algo_auth auth
;
492 char buf
[XFRM_ALGO_KEY_BUF_SIZE
];
495 __u32 icvlen
, trunclen
;
502 if (ealgop
|| aalgop
|| aeadop
)
503 duparg("ALGO-TYPE", *argv
);
506 case XFRMA_ALG_CRYPT
:
507 if (ealgop
|| aeadop
)
508 duparg("ALGO-TYPE", *argv
);
512 case XFRMA_ALG_AUTH_TRUNC
:
513 if (aalgop
|| aeadop
)
514 duparg("ALGO-TYPE", *argv
);
519 duparg("ALGO-TYPE", *argv
);
524 invarg("ALGO-TYPE value is invalid\n", *argv
);
528 missarg("ALGO-NAME");
534 case XFRMA_ALG_CRYPT
:
536 case XFRMA_ALG_AUTH_TRUNC
:
538 missarg("ALGO-KEYMAT");
544 buf
= alg
.u
.alg
.alg_key
;
545 len
= sizeof(alg
.u
.alg
);
550 missarg("ALGO-ICV-LEN");
552 if (get_u32(&icvlen
, *argv
, 0))
553 invarg("ALGO-ICV-LEN value is invalid",
555 alg
.u
.aead
.alg_icv_len
= icvlen
;
557 buf
= alg
.u
.aead
.alg_key
;
558 len
= sizeof(alg
.u
.aead
);
560 case XFRMA_ALG_AUTH_TRUNC
:
562 missarg("ALGO-TRUNC-LEN");
564 if (get_u32(&trunclen
, *argv
, 0))
565 invarg("ALGO-TRUNC-LEN value is invalid",
567 alg
.u
.auth
.alg_trunc_len
= trunclen
;
569 buf
= alg
.u
.auth
.alg_key
;
570 len
= sizeof(alg
.u
.auth
);
574 xfrm_algo_parse((void *)&alg
, type
, name
, key
,
575 buf
, sizeof(alg
.buf
));
576 len
+= alg
.u
.alg
.alg_key_len
/ 8;
578 addattr_l(&req
.n
, sizeof(req
.buf
), type
,
583 /* try to assume ID */
585 invarg("unknown", *argv
);
589 xfrm_id_parse(&req
.xsinfo
.saddr
, &req
.xsinfo
.id
,
590 &req
.xsinfo
.family
, 0, &argc
, &argv
);
591 if (preferred_family
== AF_UNSPEC
)
592 preferred_family
= req
.xsinfo
.family
;
598 if (req
.xsinfo
.flags
& XFRM_STATE_ESN
&&
599 replay_window
== 0) {
600 fprintf(stderr
, "Error: esn flag set without replay-window.\n");
604 if (replay_window
> XFRMA_REPLAY_ESN_MAX
) {
606 "Error: replay-window (%u) > XFRMA_REPLAY_ESN_MAX (%u).\n",
607 replay_window
, XFRMA_REPLAY_ESN_MAX
);
612 xuo
.ifindex
= ifindex
;
614 addattr_l(&req
.n
, sizeof(req
.buf
), XFRMA_OFFLOAD_DEV
, &xuo
,
617 if (req
.xsinfo
.flags
& XFRM_STATE_ESN
||
618 replay_window
> (sizeof(replay
.bitmap
) * 8)) {
619 replay_esn
.seq
= seq
;
620 replay_esn
.oseq
= oseq
;
621 replay_esn
.seq_hi
= seq_hi
;
622 replay_esn
.oseq_hi
= oseq_hi
;
623 replay_esn
.replay_window
= replay_window
;
624 replay_esn
.bmp_len
= (replay_window
+ sizeof(__u32
) * 8 - 1) /
626 addattr_l(&req
.n
, sizeof(req
.buf
), XFRMA_REPLAY_ESN_VAL
,
627 &replay_esn
, sizeof(replay_esn
));
632 addattr_l(&req
.n
, sizeof(req
.buf
), XFRMA_REPLAY_VAL
,
633 &replay
, sizeof(replay
));
635 req
.xsinfo
.replay_window
= replay_window
;
639 addattr32(&req
.n
, sizeof(req
.buf
), XFRMA_SA_EXTRA_FLAGS
,
643 fprintf(stderr
, "Not enough information: ID is required\n");
648 int r
= addattr_l(&req
.n
, sizeof(req
.buf
), XFRMA_MARK
,
649 (void *)&mark
, sizeof(mark
));
651 fprintf(stderr
, "XFRMA_MARK failed\n");
657 addattr32(&req
.n
, sizeof(req
.buf
), XFRMA_IF_ID
, if_id
);
659 if (xfrm_xfrmproto_is_ipsec(req
.xsinfo
.id
.proto
)) {
660 switch (req
.xsinfo
.mode
) {
661 case XFRM_MODE_TRANSPORT
:
662 case XFRM_MODE_TUNNEL
:
665 if (req
.xsinfo
.id
.proto
== IPPROTO_ESP
)
668 fprintf(stderr
, "MODE value is invalid with XFRM-PROTO value \"%s\"\n",
669 strxf_xfrmproto(req
.xsinfo
.id
.proto
));
673 switch (req
.xsinfo
.id
.proto
) {
676 fprintf(stderr
, "ALGO-TYPE value \"%s\" is invalid with XFRM-PROTO value \"%s\"\n",
677 strxf_algotype(XFRMA_ALG_COMP
),
678 strxf_xfrmproto(req
.xsinfo
.id
.proto
));
681 if (!ealgop
&& !aeadop
) {
682 fprintf(stderr
, "ALGO-TYPE value \"%s\" or \"%s\" is required with XFRM-PROTO value \"%s\"\n",
683 strxf_algotype(XFRMA_ALG_CRYPT
),
684 strxf_algotype(XFRMA_ALG_AEAD
),
685 strxf_xfrmproto(req
.xsinfo
.id
.proto
));
690 if (ealgop
|| aeadop
|| calgop
) {
691 fprintf(stderr
, "ALGO-TYPE values \"%s\", \"%s\", and \"%s\" are invalid with XFRM-PROTO value \"%s\"\n",
692 strxf_algotype(XFRMA_ALG_CRYPT
),
693 strxf_algotype(XFRMA_ALG_AEAD
),
694 strxf_algotype(XFRMA_ALG_COMP
),
695 strxf_xfrmproto(req
.xsinfo
.id
.proto
));
699 fprintf(stderr
, "ALGO-TYPE value \"%s\" or \"%s\" is required with XFRM-PROTO value \"%s\"\n",
700 strxf_algotype(XFRMA_ALG_AUTH
),
701 strxf_algotype(XFRMA_ALG_AUTH_TRUNC
),
702 strxf_xfrmproto(req
.xsinfo
.id
.proto
));
707 if (ealgop
|| aalgop
|| aeadop
) {
708 fprintf(stderr
, "ALGO-TYPE values \"%s\", \"%s\", \"%s\", and \"%s\" are invalid with XFRM-PROTO value \"%s\"\n",
709 strxf_algotype(XFRMA_ALG_CRYPT
),
710 strxf_algotype(XFRMA_ALG_AUTH
),
711 strxf_algotype(XFRMA_ALG_AUTH_TRUNC
),
712 strxf_algotype(XFRMA_ALG_AEAD
),
713 strxf_xfrmproto(req
.xsinfo
.id
.proto
));
717 fprintf(stderr
, "ALGO-TYPE value \"%s\" is required with XFRM-PROTO value \"%s\"\n",
718 strxf_algotype(XFRMA_ALG_COMP
),
719 strxf_xfrmproto(req
.xsinfo
.id
.proto
));
725 if (ealgop
|| aalgop
|| aeadop
|| calgop
) {
726 fprintf(stderr
, "ALGO is invalid with XFRM-PROTO value \"%s\"\n",
727 strxf_xfrmproto(req
.xsinfo
.id
.proto
));
732 if (xfrm_xfrmproto_is_ro(req
.xsinfo
.id
.proto
)) {
733 switch (req
.xsinfo
.mode
) {
734 case XFRM_MODE_ROUTEOPTIMIZATION
:
735 case XFRM_MODE_IN_TRIGGER
:
738 fprintf(stderr
, "\"mode\" is required with XFRM-PROTO value \"%s\"\n",
739 strxf_xfrmproto(req
.xsinfo
.id
.proto
));
742 fprintf(stderr
, "MODE value is invalid with XFRM-PROTO value \"%s\"\n",
743 strxf_xfrmproto(req
.xsinfo
.id
.proto
));
748 fprintf(stderr
, "\"coa\" is required with XFRM-PROTO value \"%s\"\n",
749 strxf_xfrmproto(req
.xsinfo
.id
.proto
));
754 fprintf(stderr
, "\"coa\" is invalid with XFRM-PROTO value \"%s\"\n",
755 strxf_xfrmproto(req
.xsinfo
.id
.proto
));
761 addattr32(&req
.n
, sizeof(req
.buf
), XFRMA_OUTPUT_MARK
, output_mark
);
763 if (rtnl_open_byproto(&rth
, 0, NETLINK_XFRM
) < 0)
766 if (req
.xsinfo
.family
== AF_UNSPEC
)
767 req
.xsinfo
.family
= AF_INET
;
769 if (rtnl_talk(&rth
, &req
.n
, NULL
) < 0)
777 static int xfrm_state_allocspi(int argc
, char **argv
)
779 struct rtnl_handle rth
;
782 struct xfrm_userspi_info xspi
;
783 char buf
[RTA_BUF_SIZE
];
785 .n
.nlmsg_len
= NLMSG_LENGTH(sizeof(req
.xspi
)),
786 .n
.nlmsg_flags
= NLM_F_REQUEST
,
787 .n
.nlmsg_type
= XFRM_MSG_ALLOCSPI
,
788 .xspi
.info
.family
= preferred_family
,
790 .xspi
.lft
.soft_byte_limit
= XFRM_INF
,
791 .xspi
.lft
.hard_byte_limit
= XFRM_INF
,
792 .xspi
.lft
.soft_packet_limit
= XFRM_INF
,
793 .xspi
.lft
.hard_packet_limit
= XFRM_INF
,
799 struct xfrm_mark mark
= {0, 0};
800 struct nlmsghdr
*answer
;
803 if (strcmp(*argv
, "mode") == 0) {
805 xfrm_mode_parse(&req
.xspi
.info
.mode
, &argc
, &argv
);
806 } else if (strcmp(*argv
, "mark") == 0) {
807 xfrm_parse_mark(&mark
, &argc
, &argv
);
808 } else if (strcmp(*argv
, "reqid") == 0) {
810 xfrm_reqid_parse(&req
.xspi
.info
.reqid
, &argc
, &argv
);
811 } else if (strcmp(*argv
, "seq") == 0) {
813 xfrm_seq_parse(&req
.xspi
.info
.seq
, &argc
, &argv
);
814 } else if (strcmp(*argv
, "min") == 0) {
816 duparg("min", *argv
);
821 if (get_u32(&req
.xspi
.min
, *argv
, 0))
822 invarg("value after \"min\" is invalid", *argv
);
823 } else if (strcmp(*argv
, "max") == 0) {
825 duparg("max", *argv
);
830 if (get_u32(&req
.xspi
.max
, *argv
, 0))
831 invarg("value after \"max\" is invalid", *argv
);
833 /* try to assume ID */
835 invarg("unknown", *argv
);
839 xfrm_id_parse(&req
.xspi
.info
.saddr
, &req
.xspi
.info
.id
,
840 &req
.xspi
.info
.family
, 0, &argc
, &argv
);
841 if (req
.xspi
.info
.id
.spi
) {
842 fprintf(stderr
, "\"spi\" is invalid\n");
845 if (preferred_family
== AF_UNSPEC
)
846 preferred_family
= req
.xspi
.info
.family
;
852 fprintf(stderr
, "Not enough information: ID is required\n");
858 fprintf(stderr
, "\"max\" is missing\n");
861 if (req
.xspi
.min
> req
.xspi
.max
) {
862 fprintf(stderr
, "value after \"min\" is larger than value after \"max\"\n");
867 fprintf(stderr
, "\"min\" is missing\n");
871 /* XXX: Default value defined in PF_KEY;
872 * See kernel's net/key/af_key.c(pfkey_getspi).
874 req
.xspi
.min
= 0x100;
875 req
.xspi
.max
= 0x0fffffff;
877 /* XXX: IPCOMP spi is 16-bits;
878 * See kernel's net/xfrm/xfrm_user(verify_userspi_info).
880 if (req
.xspi
.info
.id
.proto
== IPPROTO_COMP
)
881 req
.xspi
.max
= 0xffff;
884 if (mark
.m
& mark
.v
) {
885 int r
= addattr_l(&req
.n
, sizeof(req
.buf
), XFRMA_MARK
,
886 (void *)&mark
, sizeof(mark
));
888 fprintf(stderr
, "XFRMA_MARK failed\n");
893 if (rtnl_open_byproto(&rth
, 0, NETLINK_XFRM
) < 0)
896 if (req
.xspi
.info
.family
== AF_UNSPEC
)
897 req
.xspi
.info
.family
= AF_INET
;
900 if (rtnl_talk(&rth
, &req
.n
, &answer
) < 0)
903 if (xfrm_state_print(answer
, (void *)stdout
) < 0) {
904 fprintf(stderr
, "An error :-)\n");
914 static int xfrm_state_filter_match(struct xfrm_usersa_info
*xsinfo
)
919 if (filter
.xsinfo
.family
!= AF_UNSPEC
&&
920 filter
.xsinfo
.family
!= xsinfo
->family
)
923 if (filter
.id_src_mask
)
924 if (xfrm_addr_match(&xsinfo
->saddr
, &filter
.xsinfo
.saddr
,
927 if (filter
.id_dst_mask
)
928 if (xfrm_addr_match(&xsinfo
->id
.daddr
, &filter
.xsinfo
.id
.daddr
,
931 if ((xsinfo
->id
.proto
^filter
.xsinfo
.id
.proto
)&filter
.id_proto_mask
)
933 if ((xsinfo
->id
.spi
^filter
.xsinfo
.id
.spi
)&filter
.id_spi_mask
)
935 if ((xsinfo
->mode
^filter
.xsinfo
.mode
)&filter
.mode_mask
)
937 if ((xsinfo
->reqid
^filter
.xsinfo
.reqid
)&filter
.reqid_mask
)
939 if (filter
.state_flags_mask
)
940 if ((xsinfo
->flags
& filter
.xsinfo
.flags
) == 0)
946 static int __do_xfrm_state_print(struct nlmsghdr
*n
, void *arg
, bool nokeys
)
948 FILE *fp
= (FILE *)arg
;
949 struct rtattr
*tb
[XFRMA_MAX
+1];
951 struct xfrm_usersa_info
*xsinfo
= NULL
;
952 struct xfrm_user_expire
*xexp
= NULL
;
953 struct xfrm_usersa_id
*xsid
= NULL
;
954 int len
= n
->nlmsg_len
;
956 if (n
->nlmsg_type
!= XFRM_MSG_NEWSA
&&
957 n
->nlmsg_type
!= XFRM_MSG_DELSA
&&
958 n
->nlmsg_type
!= XFRM_MSG_UPDSA
&&
959 n
->nlmsg_type
!= XFRM_MSG_EXPIRE
) {
960 fprintf(stderr
, "Not a state: %08x %08x %08x\n",
961 n
->nlmsg_len
, n
->nlmsg_type
, n
->nlmsg_flags
);
965 if (n
->nlmsg_type
== XFRM_MSG_DELSA
) {
966 /* Don't blame me for this .. Herbert made me do it */
967 xsid
= NLMSG_DATA(n
);
968 len
-= NLMSG_SPACE(sizeof(*xsid
));
969 } else if (n
->nlmsg_type
== XFRM_MSG_EXPIRE
) {
970 xexp
= NLMSG_DATA(n
);
971 xsinfo
= &xexp
->state
;
972 len
-= NLMSG_SPACE(sizeof(*xexp
));
975 xsinfo
= NLMSG_DATA(n
);
976 len
-= NLMSG_SPACE(sizeof(*xsinfo
));
980 fprintf(stderr
, "BUG: wrong nlmsg len %d\n", len
);
984 if (xsinfo
&& !xfrm_state_filter_match(xsinfo
))
987 if (n
->nlmsg_type
== XFRM_MSG_DELSA
)
988 fprintf(fp
, "Deleted ");
989 else if (n
->nlmsg_type
== XFRM_MSG_UPDSA
)
990 fprintf(fp
, "Updated ");
991 else if (n
->nlmsg_type
== XFRM_MSG_EXPIRE
)
992 fprintf(fp
, "Expired ");
994 if (n
->nlmsg_type
== XFRM_MSG_DELSA
)
995 rta
= XFRMSID_RTA(xsid
);
996 else if (n
->nlmsg_type
== XFRM_MSG_EXPIRE
)
997 rta
= XFRMEXP_RTA(xexp
);
999 rta
= XFRMS_RTA(xsinfo
);
1001 parse_rtattr(tb
, XFRMA_MAX
, rta
, len
);
1003 if (n
->nlmsg_type
== XFRM_MSG_DELSA
) {
1004 /* xfrm_policy_id_print(); */
1006 if (!tb
[XFRMA_SA
]) {
1007 fprintf(stderr
, "Buggy XFRM_MSG_DELSA: no XFRMA_SA\n");
1010 if (RTA_PAYLOAD(tb
[XFRMA_SA
]) < sizeof(*xsinfo
)) {
1011 fprintf(stderr
, "Buggy XFRM_MSG_DELPOLICY: too short XFRMA_POLICY len\n");
1014 xsinfo
= RTA_DATA(tb
[XFRMA_SA
]);
1017 xfrm_state_info_print(xsinfo
, tb
, fp
, NULL
, NULL
, nokeys
);
1019 if (n
->nlmsg_type
== XFRM_MSG_EXPIRE
) {
1021 fprintf(fp
, "hard %u", xexp
->hard
);
1022 fprintf(fp
, "%s", _SL_
);
1032 int xfrm_state_print(struct nlmsghdr
*n
, void *arg
)
1034 return __do_xfrm_state_print(n
, arg
, false);
1037 int xfrm_state_print_nokeys(struct nlmsghdr
*n
, void *arg
)
1039 return __do_xfrm_state_print(n
, arg
, true);
1042 static int xfrm_state_get_or_delete(int argc
, char **argv
, int delete)
1044 struct rtnl_handle rth
;
1047 struct xfrm_usersa_id xsid
;
1048 char buf
[RTA_BUF_SIZE
];
1050 .n
.nlmsg_len
= NLMSG_LENGTH(sizeof(req
.xsid
)),
1051 .n
.nlmsg_flags
= NLM_F_REQUEST
,
1052 .n
.nlmsg_type
= delete ? XFRM_MSG_DELSA
: XFRM_MSG_GETSA
,
1053 .xsid
.family
= preferred_family
,
1057 struct xfrm_mark mark
= {0, 0};
1060 xfrm_address_t saddr
;
1062 if (strcmp(*argv
, "mark") == 0) {
1063 xfrm_parse_mark(&mark
, &argc
, &argv
);
1066 invarg("unknown", *argv
);
1070 memset(&id
, 0, sizeof(id
));
1071 memset(&saddr
, 0, sizeof(saddr
));
1072 xfrm_id_parse(&saddr
, &id
, &req
.xsid
.family
, 0,
1075 memcpy(&req
.xsid
.daddr
, &id
.daddr
, sizeof(req
.xsid
.daddr
));
1076 req
.xsid
.spi
= id
.spi
;
1077 req
.xsid
.proto
= id
.proto
;
1079 addattr_l(&req
.n
, sizeof(req
.buf
), XFRMA_SRCADDR
,
1080 (void *)&saddr
, sizeof(saddr
));
1086 if (mark
.m
& mark
.v
) {
1087 int r
= addattr_l(&req
.n
, sizeof(req
.buf
), XFRMA_MARK
,
1088 (void *)&mark
, sizeof(mark
));
1090 fprintf(stderr
, "XFRMA_MARK failed\n");
1095 if (rtnl_open_byproto(&rth
, 0, NETLINK_XFRM
) < 0)
1098 if (req
.xsid
.family
== AF_UNSPEC
)
1099 req
.xsid
.family
= AF_INET
;
1102 if (rtnl_talk(&rth
, &req
.n
, NULL
) < 0)
1105 struct nlmsghdr
*answer
;
1107 if (rtnl_talk(&rth
, &req
.n
, &answer
) < 0)
1110 if (xfrm_state_print(answer
, (void *)stdout
) < 0) {
1111 fprintf(stderr
, "An error :-)\n");
1124 * With an existing state of nlmsg, make new nlmsg for deleting the state
1125 * and store it to buffer.
1127 static int xfrm_state_keep(struct nlmsghdr
*n
, void *arg
)
1129 struct xfrm_buffer
*xb
= (struct xfrm_buffer
*)arg
;
1130 struct rtnl_handle
*rth
= xb
->rth
;
1131 struct xfrm_usersa_info
*xsinfo
= NLMSG_DATA(n
);
1132 int len
= n
->nlmsg_len
;
1133 struct nlmsghdr
*new_n
;
1134 struct xfrm_usersa_id
*xsid
;
1135 struct rtattr
*tb
[XFRMA_MAX
+1];
1137 if (n
->nlmsg_type
!= XFRM_MSG_NEWSA
) {
1138 fprintf(stderr
, "Not a state: %08x %08x %08x\n",
1139 n
->nlmsg_len
, n
->nlmsg_type
, n
->nlmsg_flags
);
1143 len
-= NLMSG_LENGTH(sizeof(*xsinfo
));
1145 fprintf(stderr
, "BUG: wrong nlmsg len %d\n", len
);
1149 if (!xfrm_state_filter_match(xsinfo
))
1152 if (xb
->offset
> xb
->size
) {
1153 fprintf(stderr
, "State buffer overflow\n");
1157 new_n
= (struct nlmsghdr
*)(xb
->buf
+ xb
->offset
);
1158 new_n
->nlmsg_len
= NLMSG_LENGTH(sizeof(*xsid
));
1159 new_n
->nlmsg_flags
= NLM_F_REQUEST
;
1160 new_n
->nlmsg_type
= XFRM_MSG_DELSA
;
1161 new_n
->nlmsg_seq
= ++rth
->seq
;
1163 xsid
= NLMSG_DATA(new_n
);
1164 xsid
->family
= xsinfo
->family
;
1165 memcpy(&xsid
->daddr
, &xsinfo
->id
.daddr
, sizeof(xsid
->daddr
));
1166 xsid
->spi
= xsinfo
->id
.spi
;
1167 xsid
->proto
= xsinfo
->id
.proto
;
1169 addattr_l(new_n
, xb
->size
, XFRMA_SRCADDR
, &xsinfo
->saddr
,
1170 sizeof(xsid
->daddr
));
1172 parse_rtattr(tb
, XFRMA_MAX
, XFRMS_RTA(xsinfo
), len
);
1174 if (tb
[XFRMA_MARK
]) {
1175 int r
= addattr_l(new_n
, xb
->size
, XFRMA_MARK
,
1176 (void *)RTA_DATA(tb
[XFRMA_MARK
]), tb
[XFRMA_MARK
]->rta_len
);
1178 fprintf(stderr
, "%s: XFRMA_MARK failed\n", __func__
);
1183 xb
->offset
+= new_n
->nlmsg_len
;
1189 static int xfrm_state_list_or_deleteall(int argc
, char **argv
, int deleteall
)
1192 struct rtnl_handle rth
;
1193 bool nokeys
= false;
1195 if (argc
> 0 || preferred_family
!= AF_UNSPEC
)
1197 filter
.xsinfo
.family
= preferred_family
;
1200 if (strcmp(*argv
, "nokeys") == 0) {
1202 } else if (strcmp(*argv
, "mode") == 0) {
1204 xfrm_mode_parse(&filter
.xsinfo
.mode
, &argc
, &argv
);
1206 filter
.mode_mask
= XFRM_FILTER_MASK_FULL
;
1208 } else if (strcmp(*argv
, "reqid") == 0) {
1210 xfrm_reqid_parse(&filter
.xsinfo
.reqid
, &argc
, &argv
);
1212 filter
.reqid_mask
= XFRM_FILTER_MASK_FULL
;
1214 } else if (strcmp(*argv
, "flag") == 0) {
1216 xfrm_state_flag_parse(&filter
.xsinfo
.flags
, &argc
, &argv
);
1218 filter
.state_flags_mask
= XFRM_FILTER_MASK_FULL
;
1222 invarg("unknown", *argv
);
1226 xfrm_id_parse(&filter
.xsinfo
.saddr
, &filter
.xsinfo
.id
,
1227 &filter
.xsinfo
.family
, 1, &argc
, &argv
);
1228 if (preferred_family
== AF_UNSPEC
)
1229 preferred_family
= filter
.xsinfo
.family
;
1234 if (rtnl_open_byproto(&rth
, 0, NETLINK_XFRM
) < 0)
1238 struct xfrm_buffer xb
;
1239 char buf
[NLMSG_DELETEALL_BUF_SIZE
];
1243 xb
.size
= sizeof(buf
);
1246 for (i
= 0; ; i
++) {
1249 char buf
[NLMSG_BUF_SIZE
];
1251 .n
.nlmsg_len
= NLMSG_HDRLEN
,
1252 .n
.nlmsg_flags
= NLM_F_DUMP
| NLM_F_REQUEST
,
1253 .n
.nlmsg_type
= XFRM_MSG_GETSA
,
1254 .n
.nlmsg_seq
= rth
.dump
= ++rth
.seq
,
1261 fprintf(stderr
, "Delete-all round = %d\n", i
);
1263 if (rtnl_send(&rth
, (void *)&req
, req
.n
.nlmsg_len
) < 0) {
1264 perror("Cannot send dump request");
1268 if (rtnl_dump_filter(&rth
, xfrm_state_keep
, &xb
) < 0) {
1269 fprintf(stderr
, "Delete-all terminated\n");
1272 if (xb
.nlmsg_count
== 0) {
1274 fprintf(stderr
, "Delete-all completed\n");
1278 if (rtnl_send_check(&rth
, xb
.buf
, xb
.offset
) < 0) {
1279 perror("Failed to send delete-all request\n");
1283 fprintf(stderr
, "Delete-all nlmsg count = %d\n", xb
.nlmsg_count
);
1290 struct xfrm_address_filter addrfilter
= {
1291 .saddr
= filter
.xsinfo
.saddr
,
1292 .daddr
= filter
.xsinfo
.id
.daddr
,
1293 .family
= filter
.xsinfo
.family
,
1294 .splen
= filter
.id_src_mask
,
1295 .dplen
= filter
.id_dst_mask
,
1299 char buf
[NLMSG_BUF_SIZE
];
1301 .n
.nlmsg_len
= NLMSG_HDRLEN
,
1302 .n
.nlmsg_flags
= NLM_F_DUMP
| NLM_F_REQUEST
,
1303 .n
.nlmsg_type
= XFRM_MSG_GETSA
,
1304 .n
.nlmsg_seq
= rth
.dump
= ++rth
.seq
,
1307 if (filter
.xsinfo
.id
.proto
)
1308 addattr8(&req
.n
, sizeof(req
), XFRMA_PROTO
,
1309 filter
.xsinfo
.id
.proto
);
1310 addattr_l(&req
.n
, sizeof(req
), XFRMA_ADDRESS_FILTER
,
1311 &addrfilter
, sizeof(addrfilter
));
1313 if (rtnl_send(&rth
, (void *)&req
, req
.n
.nlmsg_len
) < 0) {
1314 perror("Cannot send dump request");
1318 rtnl_filter_t filter
= nokeys
?
1319 xfrm_state_print_nokeys
: xfrm_state_print
;
1320 if (rtnl_dump_filter(&rth
, filter
, stdout
) < 0) {
1321 fprintf(stderr
, "Dump terminated\n");
1331 static int print_sadinfo(struct nlmsghdr
*n
, void *arg
)
1333 FILE *fp
= (FILE *)arg
;
1334 __u32
*f
= NLMSG_DATA(n
);
1335 struct rtattr
*tb
[XFRMA_SAD_MAX
+1];
1337 int len
= n
->nlmsg_len
;
1339 len
-= NLMSG_LENGTH(sizeof(__u32
));
1341 fprintf(stderr
, "SADinfo: Wrong len %d\n", len
);
1345 rta
= XFRMSAPD_RTA(f
);
1346 parse_rtattr(tb
, XFRMA_SAD_MAX
, rta
, len
);
1348 if (tb
[XFRMA_SAD_CNT
]) {
1351 fprintf(fp
, "\t SAD");
1352 cnt
= rta_getattr_u32(tb
[XFRMA_SAD_CNT
]);
1353 fprintf(fp
, " count %u", cnt
);
1355 fprintf(fp
, "BAD SAD info returned\n");
1360 if (tb
[XFRMA_SAD_HINFO
]) {
1361 struct xfrmu_sadhinfo
*si
;
1363 if (RTA_PAYLOAD(tb
[XFRMA_SAD_HINFO
]) < sizeof(*si
)) {
1364 fprintf(fp
, "BAD SAD length returned\n");
1368 si
= RTA_DATA(tb
[XFRMA_SAD_HINFO
]);
1369 fprintf(fp
, " (buckets ");
1370 fprintf(fp
, "count %d", si
->sadhcnt
);
1371 fprintf(fp
, " Max %d", si
->sadhmcnt
);
1380 static int xfrm_sad_getinfo(int argc
, char **argv
)
1382 struct rtnl_handle rth
;
1387 .n
.nlmsg_len
= NLMSG_LENGTH(sizeof(req
.flags
)),
1388 .n
.nlmsg_flags
= NLM_F_REQUEST
,
1389 .n
.nlmsg_type
= XFRM_MSG_GETSADINFO
,
1390 .flags
= 0XFFFFFFFF,
1392 struct nlmsghdr
*answer
;
1394 if (rtnl_open_byproto(&rth
, 0, NETLINK_XFRM
) < 0)
1397 if (rtnl_talk(&rth
, &req
.n
, &answer
) < 0)
1400 print_sadinfo(answer
, (void *)stdout
);
1408 static int xfrm_state_flush(int argc
, char **argv
)
1410 struct rtnl_handle rth
;
1413 struct xfrm_usersa_flush xsf
;
1415 .n
.nlmsg_len
= NLMSG_LENGTH(sizeof(req
.xsf
)),
1416 .n
.nlmsg_flags
= NLM_F_REQUEST
,
1417 .n
.nlmsg_type
= XFRM_MSG_FLUSHSA
,
1419 char *protop
= NULL
;
1422 if (strcmp(*argv
, "proto") == 0) {
1426 duparg("proto", *argv
);
1431 ret
= xfrm_xfrmproto_getbyname(*argv
);
1433 invarg("XFRM-PROTO value is invalid", *argv
);
1435 req
.xsf
.proto
= (__u8
)ret
;
1437 invarg("unknown", *argv
);
1442 if (rtnl_open_byproto(&rth
, 0, NETLINK_XFRM
) < 0)
1446 fprintf(stderr
, "Flush state with XFRM-PROTO value \"%s\"\n",
1447 strxf_xfrmproto(req
.xsf
.proto
));
1449 if (rtnl_talk(&rth
, &req
.n
, NULL
) < 0)
1457 int do_xfrm_state(int argc
, char **argv
)
1460 return xfrm_state_list_or_deleteall(0, NULL
, 0);
1462 if (matches(*argv
, "add") == 0)
1463 return xfrm_state_modify(XFRM_MSG_NEWSA
, 0,
1465 if (matches(*argv
, "update") == 0)
1466 return xfrm_state_modify(XFRM_MSG_UPDSA
, 0,
1468 if (matches(*argv
, "allocspi") == 0)
1469 return xfrm_state_allocspi(argc
-1, argv
+1);
1470 if (matches(*argv
, "delete") == 0)
1471 return xfrm_state_get_or_delete(argc
-1, argv
+1, 1);
1472 if (matches(*argv
, "deleteall") == 0 || matches(*argv
, "delall") == 0)
1473 return xfrm_state_list_or_deleteall(argc
-1, argv
+1, 1);
1474 if (matches(*argv
, "list") == 0 || matches(*argv
, "show") == 0
1475 || matches(*argv
, "lst") == 0)
1476 return xfrm_state_list_or_deleteall(argc
-1, argv
+1, 0);
1477 if (matches(*argv
, "get") == 0)
1478 return xfrm_state_get_or_delete(argc
-1, argv
+1, 0);
1479 if (matches(*argv
, "flush") == 0)
1480 return xfrm_state_flush(argc
-1, argv
+1);
1481 if (matches(*argv
, "count") == 0) {
1482 return xfrm_sad_getinfo(argc
, argv
);
1484 if (matches(*argv
, "help") == 0)
1486 fprintf(stderr
, "Command \"%s\" is unknown, try \"ip xfrm state help\".\n", *argv
);