ipsec: manually binding an SA to a worker
[vpp.git] / src / vnet / ipsec / ipsec.api
1 /* Hey Emacs use -*- mode: C -*- */
2 /*
3  * Copyright (c) 2015-2016 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 option version = "5.0.2";
18
19 import "vnet/ipsec/ipsec_types.api";
20 import "vnet/interface_types.api";
21 import "vnet/ip/ip_types.api";
22 import "vnet/interface_types.api";
23 import "vnet/tunnel/tunnel_types.api";
24
25 /** \brief IPsec: Add/delete Security Policy Database
26     @param client_index - opaque cookie to identify the sender
27     @param context - sender context, to match reply w/ request
28     @param is_add - add SPD if non-zero, else delete
29     @param spd_id - SPD instance id (control plane allocated)
30 */
31
32 autoreply define ipsec_spd_add_del
33 {
34   u32 client_index;
35   u32 context;
36   bool is_add;
37   u32 spd_id;
38 };
39
40 /** \brief IPsec: Add/delete SPD from interface
41
42     @param client_index - opaque cookie to identify the sender
43     @param context - sender context, to match reply w/ request
44     @param is_add - add security mode if non-zero, else delete
45     @param sw_if_index - index of the interface
46     @param spd_id - SPD instance id to use for lookups
47 */
48
49
50 autoreply define ipsec_interface_add_del_spd
51 {
52   u32 client_index;
53   u32 context;
54
55   bool is_add;
56   vl_api_interface_index_t sw_if_index;
57   u32 spd_id;
58 };
59
60 /** \brief IPsec: Add/delete Security Policy Database entry
61
62     @param client_index - opaque cookie to identify the sender
63     @param context - sender context, to match reply w/ request
64     @param is_add - add SPD if non-zero, else delete
65     @param entry - Description of the entry to add/dell
66 */
67 define ipsec_spd_entry_add_del
68 {
69   option deprecated;
70   u32 client_index;
71   u32 context;
72   bool is_add;
73   vl_api_ipsec_spd_entry_t entry;
74 };
75
76 /** \brief IPsec: Add/delete Security Policy Database entry v2
77
78     @param client_index - opaque cookie to identify the sender
79     @param context - sender context, to match reply w/ request
80     @param is_add - add SPD if non-zero, else delete
81     @param entry - Description of the entry to add/dell
82 */
83 define ipsec_spd_entry_add_del_v2
84 {
85   u32 client_index;
86   u32 context;
87   bool is_add;
88   vl_api_ipsec_spd_entry_v2_t entry;
89 };
90
91 /** \brief IPsec: Reply Add/delete Security Policy Database entry
92
93     @param context - sender context, to match reply w/ request
94     @param retval - success/fail rutrun code
95     @param stat_index - An index for the policy in the stats segment @ /net/ipec/policy
96 */
97 define ipsec_spd_entry_add_del_reply
98 {
99   option deprecated;
100   u32 context;
101   i32 retval;
102   u32 stat_index;
103 };
104
105 /** \brief IPsec: Reply Add/delete Security Policy Database entry v2
106
107     @param context - sender context, to match reply w/ request
108     @param retval - success/fail rutrun code
109     @param stat_index - An index for the policy in the stats segment @ /net/ipec/policy
110 */
111 define ipsec_spd_entry_add_del_v2_reply
112 {
113   u32 context;
114   i32 retval;
115   u32 stat_index;
116 };
117
118 /** \brief Dump IPsec all SPD IDs
119     @param client_index - opaque cookie to identify the sender
120     @param context - sender context, to match reply w/ request
121 */
122 define ipsec_spds_dump {
123   u32 client_index;
124   u32 context;
125 };
126
127 /** \brief Dump IPsec all SPD IDs response
128     @param client_index - opaque cookie to identify the sender
129     @param spd_id - SPD instance id (control plane allocated)
130     @param npolicies - number of policies in SPD
131 */
132 define ipsec_spds_details {
133   u32 context;
134   u32 spd_id;
135   u32 npolicies;
136 };
137
138 /** \brief Dump ipsec policy database data
139     @param client_index - opaque cookie to identify the sender
140     @param context - sender context, to match reply w/ request
141     @param spd_id - SPD instance id
142     @param sa_id - SA id, optional, set to ~0 to see all policies in SPD
143 */
144 define ipsec_spd_dump {
145     u32 client_index;
146     u32 context;
147     u32 spd_id;
148     u32 sa_id;
149 };
150
151 /** \brief IPsec policy database response
152     @param context - sender context which was passed in the request
153     â‚¬param entry - The SPD entry.
154     @param bytes - byte count of packets matching this policy
155     @param packets - count of packets matching this policy
156 */
157 define ipsec_spd_details {
158     u32 context;
159     vl_api_ipsec_spd_entry_t entry;
160 };
161
162 /** \brief IPsec: Add/delete Security Association Database entry
163     @param client_index - opaque cookie to identify the sender
164     @param context - sender context, to match reply w/ request
165     @param entry - Entry to add or delete
166  */
167 define ipsec_sad_entry_add_del
168 {
169   option deprecated;
170   u32 client_index;
171   u32 context;
172   bool is_add;
173   vl_api_ipsec_sad_entry_t entry;
174 };
175
176 define ipsec_sad_entry_add_del_v2
177 {
178   u32 client_index;
179   u32 context;
180   bool is_add;
181   vl_api_ipsec_sad_entry_v2_t entry;
182 };
183
184 define ipsec_sad_entry_add_del_v3
185 {
186   u32 client_index;
187   u32 context;
188   bool is_add;
189   vl_api_ipsec_sad_entry_v3_t entry;
190 };
191 define ipsec_sad_entry_add
192 {
193   u32 client_index;
194   u32 context;
195   vl_api_ipsec_sad_entry_v3_t entry;
196 };
197 autoreply define ipsec_sad_entry_del
198 {
199   u32 client_index;
200   u32 context;
201   u32 id;
202 };
203
204
205 /** \brief An API to bind an SAD entry to a specific worker
206
207     @param client_index - opaque cookie to identify the sender
208     @param context - sender context, to match reply w/ request
209     @param sa_id - the id of the SA to bind
210     @param worker - the worker's index to which the SA will be bound to
211  */
212 autoreply define ipsec_sad_bind
213 {
214   u32 client_index;
215   u32 context;
216   u32 sa_id;
217   u32 worker;
218 };
219
220 autoreply define ipsec_sad_unbind
221 {
222   u32 client_index;
223   u32 context;
224   u32 sa_id;
225 };
226
227 /** \brief An API to update the tunnel parameters and the ports associated with an SA
228
229     Used in the NAT-T case when the NAT data changes
230     @param client_index - opaque cookie to identify the sender
231     @param context - sender context, to match reply w/ request
232     @param sa_id - the id of the SA to update
233     @param is_tun - update the tunnel if non-zero, else update only the ports
234     @param tunnel - sender context, to match reply w/ request
235     @param udp_src_port - new src port for NAT-T. Used if different from 0xffff
236     @param udp_dst_port - new dst port for NAT-T. Used if different from 0xffff
237  */
238 autoreply define ipsec_sad_entry_update
239 {
240   u32 client_index;
241   u32 context;
242   u32 sad_id;
243   bool is_tun;
244   vl_api_tunnel_t tunnel;
245   u16 udp_src_port [default=0xffff];
246   u16 udp_dst_port [default=0xffff];
247 };
248
249 define ipsec_sad_entry_add_del_reply
250 {
251   option deprecated;
252   u32 context;
253   i32 retval;
254   u32 stat_index;
255 };
256
257 define ipsec_sad_entry_add_del_v2_reply
258 {
259   u32 context;
260   i32 retval;
261   u32 stat_index;
262 };
263
264 define ipsec_sad_entry_add_del_v3_reply
265 {
266   u32 context;
267   i32 retval;
268   u32 stat_index;
269 };
270 define ipsec_sad_entry_add_reply
271 {
272   u32 context;
273   i32 retval;
274   u32 stat_index;
275 };
276
277 /** \brief Add or Update Protection for a tunnel with IPSEC
278
279     Tunnel protection directly associates an SA with all packets
280     ingress and egress on the tunnel. This could also be achieved by
281     assigning an SPD to the tunnel, but that would incur an unnessccary
282     SPD entry lookup.
283
284     For tunnels the ESP acts on the post-encapsulated packet. So if this
285     packet:
286       +---------+------+
287       | Payload | O-IP |
288       +---------+------+
289     where O-IP is the overlay IP addrees that was routed into the tunnel,
290     the resulting encapsulated packet will be:
291       +---------+------+------+
292       | Payload | O-IP | T-IP |
293       +---------+------+------+
294     where T-IP is the tunnel's src.dst IP addresses.
295     If the SAs used for protection are in transport mode then the ESP is
296     inserted before T-IP, i.e.:
297       +---------+------+-----+------+
298       | Payload | O-IP | ESP | T-IP |
299       +---------+------+-----+------+
300     If the SAs used for protection are in tunnel mode then another
301     encapsulation occurs, i.e.:
302       +---------+------+------+-----+------+
303       | Payload | O-IP | T-IP | ESP | C-IP |
304       +---------+------+------+-----+------+
305     where C-IP are the crypto endpoint IP addresses defined as the tunnel
306     endpoints in the SA.
307     The mode for the inbound and outbound SA must be the same.
308
309     @param client_index - opaque cookie to identify the sender
310     @param context - sender context, to match reply w/ request
311     @param sw_id_index - Tunnel interface to protect
312     @param nh - The peer/next-hop on the tunnel to which the traffic
313                 should be protected. For a P2P interface set this to the
314                 all 0s address.
315     @param sa_in - The ID [set] of inbound SAs
316     @param sa_out - The ID of outbound SA
317 */
318 typedef ipsec_tunnel_protect
319 {
320   vl_api_interface_index_t sw_if_index;
321   vl_api_address_t nh;
322   u32 sa_out;
323   u8 n_sa_in;
324   u32 sa_in[n_sa_in];
325 };
326
327 autoreply define ipsec_tunnel_protect_update
328 {
329   u32 client_index;
330   u32 context;
331
332   vl_api_ipsec_tunnel_protect_t tunnel;
333 };
334
335 autoreply define ipsec_tunnel_protect_del
336 {
337   u32 client_index;
338   u32 context;
339
340   vl_api_interface_index_t sw_if_index;
341   vl_api_address_t nh;
342 };
343
344 /**
345  * @brief Dump all tunnel protections
346  */
347 define ipsec_tunnel_protect_dump
348 {
349   u32 client_index;
350   u32 context;
351   vl_api_interface_index_t sw_if_index;
352 };
353
354 define ipsec_tunnel_protect_details
355 {
356   u32 context;
357   vl_api_ipsec_tunnel_protect_t tun;
358 };
359
360 /** \brief IPsec: Get SPD interfaces
361     @param client_index - opaque cookie to identify the sender
362     @param context - sender context, to match reply w/ request
363     @param spd_index - SPD index
364     @param spd_index_valid - if 1 spd_index is used to filter
365       spd_index's, if 0 no filtering is done
366 */
367 define ipsec_spd_interface_dump {
368     u32 client_index;
369     u32 context;
370     u32 spd_index;
371     u8 spd_index_valid;
372 };
373
374 /** \brief IPsec: SPD interface response
375     @param context - sender context which was passed in the request
376     @param spd_index - SPD index
377     @param sw_if_index - index of the interface
378 */
379 define ipsec_spd_interface_details {
380     u32 context;
381     u32 spd_index;
382     vl_api_interface_index_t sw_if_index;
383 };
384
385 typedef ipsec_itf
386 {
387   u32 user_instance [default=0xffffffff];
388   vl_api_tunnel_mode_t mode;
389   vl_api_interface_index_t sw_if_index;
390 };
391
392 /** \brief Create an IPSec interface
393  */
394 define ipsec_itf_create {
395   u32 client_index;
396   u32 context;
397   vl_api_ipsec_itf_t itf;
398 };
399
400 /** \brief Add IPsec interface interface response
401     @param context - sender context, to match reply w/ request
402     @param retval - return status
403     @param sw_if_index - sw_if_index of new interface (for successful add)
404 */
405 define ipsec_itf_create_reply
406 {
407   u32 context;
408   i32 retval;
409   vl_api_interface_index_t sw_if_index;
410 };
411
412 autoreply define ipsec_itf_delete
413 {
414   u32 client_index;
415   u32 context;
416   vl_api_interface_index_t sw_if_index;
417 };
418
419 define ipsec_itf_dump
420 {
421   u32 client_index;
422   u32 context;
423   vl_api_interface_index_t sw_if_index;
424 };
425
426 define ipsec_itf_details
427 {
428   u32 context;
429   vl_api_ipsec_itf_t itf;
430 };
431
432 /** \brief Dump IPsec security association
433     @param client_index - opaque cookie to identify the sender
434     @param context - sender context, to match reply w/ request
435     @param sa_id - optional ID of an SA to dump, if ~0 dump all SAs in SAD
436 */
437 define ipsec_sa_dump
438 {
439   option deprecated;
440   u32 client_index;
441   u32 context;
442   u32 sa_id;
443 };
444 define ipsec_sa_v2_dump
445 {
446   u32 client_index;
447   u32 context;
448   u32 sa_id;
449 };
450 define ipsec_sa_v3_dump
451 {
452   u32 client_index;
453   u32 context;
454   u32 sa_id;
455 };
456 define ipsec_sa_v4_dump
457 {
458   u32 client_index;
459   u32 context;
460   u32 sa_id;
461 };
462
463 /** \brief IPsec security association database response
464     @param context - sender context which was passed in the request
465     @param entry - The SA details
466     @param sw_if_index - sw_if_index of tunnel interface, policy-based SAs = ~0
467     @param salt - 4 byte salt
468     @param seq - current sequence number for outbound
469     @param seq_hi - high 32 bits of ESN for outbound
470     @param last_seq - highest sequence number received inbound
471     @param last_seq_hi - high 32 bits of highest ESN received inbound
472     @param replay_window - bit map of seq nums received relative to last_seq if using anti-replay
473     @param stat_index - index for the SA in the stats segment @ /net/ipsec/sa
474 */
475 define ipsec_sa_details {
476   option deprecated;
477   u32 context;
478   vl_api_ipsec_sad_entry_t entry;
479
480   vl_api_interface_index_t sw_if_index;
481   u32 salt;
482   u64 seq_outbound;
483   u64 last_seq_inbound;
484   u64 replay_window;
485
486   u32 stat_index;
487 };
488 define ipsec_sa_v2_details {
489   u32 context;
490   vl_api_ipsec_sad_entry_v2_t entry;
491
492   vl_api_interface_index_t sw_if_index;
493   u32 salt;
494   u64 seq_outbound;
495   u64 last_seq_inbound;
496   u64 replay_window;
497
498   u32 stat_index;
499 };
500 define ipsec_sa_v3_details {
501   u32 context;
502   vl_api_ipsec_sad_entry_v3_t entry;
503
504   vl_api_interface_index_t sw_if_index;
505   u64 seq_outbound;
506   u64 last_seq_inbound;
507   u64 replay_window;
508
509   u32 stat_index;
510 };
511 define ipsec_sa_v4_details {
512   u32 context;
513   vl_api_ipsec_sad_entry_v3_t entry;
514
515   vl_api_interface_index_t sw_if_index;
516   u64 seq_outbound;
517   u64 last_seq_inbound;
518   u64 replay_window;
519
520   u32 thread_index;
521   u32 stat_index;
522 };
523
524 /** \brief Dump IPsec backends
525     @param client_index - opaque cookie to identify the sender
526     @param context - sender context, to match reply w/ request
527 */
528 define ipsec_backend_dump {
529   u32 client_index;
530   u32 context;
531 };
532
533 /** \brief IPsec backend details
534     @param name - name of the backend
535     @param protocol - IPsec protocol (value from ipsec_protocol_t)
536     @param index - backend index
537     @param active - set to 1 if the backend is active, otherwise 0
538 */
539 define ipsec_backend_details {
540   u32 context;
541   string name[128];
542   vl_api_ipsec_proto_t protocol;
543   u8 index;
544   bool active;
545 };
546
547 /** \brief Select IPsec backend
548     @param client_index - opaque cookie to identify the sender
549     @param context - sender context, to match reply w/ request
550     @param protocol - IPsec protocol (value from ipsec_protocol_t)
551     @param index - backend index
552 */
553 autoreply define ipsec_select_backend {
554   u32 client_index;
555   u32 context;
556   vl_api_ipsec_proto_t protocol;
557   u8 index;
558 };
559
560
561 /** \brief IPsec Set Async mode
562     @param client_index - opaque cookie to identify the sender
563     @param context - sender context, to match reply w/ request
564     @param async_enable - ipsec async mode on or off
565 */
566 autoreply define ipsec_set_async_mode {
567   u32 client_index;
568   u32 context;
569   bool async_enable;
570 };
571
572 counters esp_decrypt {
573   rx_pkts {
574     severity info;
575     type counter64;
576     units "packets";
577     description "ESP pkts received";
578   };
579   rx_post_pkts {
580     severity info;
581     type counter64;
582     units "packets";
583     description "ESP-POST pkts received";
584   };
585   handoff {
586     severity info;
587     type counter64;
588     units "packets";
589     description "hand-off";
590   };
591   decryption_failed {
592     severity error;
593     type counter64;
594     units "packets";
595     description "ESP decryption failed";
596   };
597   integ_error {
598     severity error;
599     type counter64;
600     units "packets";
601     description "integrity check failed";
602   };
603   crypto_engine_error {
604     severity error;
605     type counter64;
606     units "packets";
607     description "crypto engine error (packet dropped)";
608   };
609   replay {
610     severity error;
611     type counter64;
612     units "packets";
613     description "SA replayed packet";
614   };
615   runt {
616     severity error;
617     type counter64;
618     units "packets";
619     description "undersized packet";
620   };
621   no_buffers {
622     severity error;
623     type counter64;
624     units "packets";
625     description "no buffers (packet dropped)";
626   };
627   oversized_header {
628     severity error;
629     type counter64;
630     units "packets";
631     description "buffer with oversized header (dropped)";
632   };
633   no_tail_space {
634     severity error;
635     type counter64;
636     units "packets";
637     description "no enough buffer tail space (dropped)";
638   };
639   tun_no_proto {
640     severity error;
641     type counter64;
642     units "packets";
643     description "no tunnel protocol";
644   };
645   unsup_payload {
646     severity error;
647     type counter64;
648     units "packets";
649     description "unsupported payload";
650   };
651   no_avail_frame {
652   severity error;
653   type counter64;
654   units "packets";
655   description "no available frame (packet dropped)";
656   };
657 };
658
659 counters esp_encrypt {
660   rx_pkts {
661     severity info;
662     type counter64;
663     units "packets";
664     description "ESP pkts received";
665   };
666   post_rx_pkts {
667     severity info;
668     type counter64;
669     units "packets";
670     description "ESP-post pkts received";
671   };
672   handoff {
673     severity info;
674     type counter64;
675     units "packets";
676     description "Hand-off";
677   };
678   seq_cycled {
679     severity error;
680     type counter64;
681     units "packets";
682     description "sequence number cycled (packet dropped)";
683   };
684   crypto_engine_error {
685     severity error;
686     type counter64;
687     units "packets";
688     description "crypto engine error (packet dropped)";
689   };
690   crypto_queue_full {
691     severity error;
692     type counter64;
693     units "packets";
694     description "crypto queue full (packet dropped)";
695   };
696   no_buffers {
697     severity error;
698     type counter64;
699     units "packets";
700     description "no buffers (packet dropped)";
701   };
702   no_protection {
703     severity error;
704     type counter64;
705     units "packets";
706     description "no protecting SA (packet dropped)";
707   };
708   no_encryption {
709     severity error;
710     type counter64;
711     units "packets";
712     description "no Encrypting SA (packet dropped)";
713   };
714   no_avail_frame {
715   severity error;
716   type counter64;
717   units "packets";
718   description "no available frame (packet dropped)";
719   };
720 };
721
722 counters ah_encrypt {
723   rx_pkts {
724     severity info;
725     type counter64;
726     units "packets";
727     description "AH pkts received";
728   };
729   crypto_engine_error {
730     severity error;
731     type counter64;
732     units "packets";
733     description "crypto engine error (packet dropped)";
734   };
735   seq_cycled {
736     severity error;
737     type counter64;
738     units "packets";
739     description "sequence number cycled (packet dropped)";
740   };
741 };
742
743 counters ah_decrypt {
744   rx_pkts {
745     severity info;
746     type counter64;
747     units "packets";
748     description "AH pkts received";
749   };
750   decryption_failed {
751     severity error;
752     type counter64;
753     units "packets";
754     description "AH decryption failed";
755   };
756   integ_error {
757     severity error;
758     type counter64;
759     units "packets";
760     description "Integrity check failed";
761   };
762   no_tail_space {
763     severity error;
764     type counter64;
765     units "packets";
766     description "not enough buffer tail space (dropped)";
767   };
768   drop_fragments {
769     severity error;
770     type counter64;
771     units "packets";
772     description "IP fragments drop";
773   };
774   replay {
775     severity error;
776     type counter64;
777     units "packets";
778     description "SA replayed packet";
779   };
780 };
781
782 counters ipsec_tun {
783   rx {
784     severity info;
785     type counter64;
786     units "packets";
787     description "good packets received";
788   };
789   disabled {
790     severity error;
791     type counter64;
792     units "packets";
793     description "ipsec packets received on disabled interface";
794   };
795   no_tunnel {
796     severity error;
797     type counter64;
798     units "packets";
799     description "no matching tunnel";
800   };
801   tunnel_mismatch {
802     severity error;
803     type counter64;
804     units "packets";
805     description "SPI-tunnel mismatch";
806   };
807   nat_keepalive {
808     severity info;
809     type counter64;
810     units "packets";
811     description "NAT Keepalive";
812   };
813   too_short {
814     severity error;
815     type counter64;
816     units "packets";
817     description "Too Short";
818   };
819   spi_0 {
820     severity info;
821     type counter64;
822     units "packets";
823     description "SPI 0";
824   };
825 };
826
827 paths {
828   "/err/esp4-encrypt" "esp_encrypt";
829   "/err/esp4-encrypt-post" "esp_encrypt";
830   "/err/esp4-encrypt-tun" "esp_encrypt";
831   "/err/esp4-encrypt-tun-post" "esp_encrypt";
832   "/err/esp6-encrypt" "esp_encrypt";
833   "/err/esp6-encrypt-post" "esp_encrypt";
834   "/err/esp6-encrypt-tun" "esp_encrypt";
835   "/err/esp6-encrypt-tun-post" "esp_encrypt";
836   "/err/esp-mpls-encrypt-tun" "esp_encrypt";
837   "/err/esp-mpls-encrypt-tun-post" "esp_encrypt";
838   "/err/esp4-decrypt" "esp_decrypt";
839   "/err/esp4-decrypt-post" "esp_decrypt";
840   "/err/esp4-decrypt-tun" "esp_decrypt";
841   "/err/esp4-decrypt-tun-post" "esp_decrypt";
842   "/err/esp6-decrypt" "esp_decrypt";
843   "/err/esp6-decrypt-post" "esp_decrypt";
844   "/err/esp6-decrypt-tun" "esp_decrypt";
845   "/err/esp6-decrypt-tun-post" "esp_decrypt";
846   "/err/ah4-encrypt" "ah_encrypt";
847   "/err/ah6-encrypt" "ah_encrypt";
848   "/err/ipsec4-tun-input" "ipsec_tun";
849   "/err/ipsec6-tun-input" "ipsec_tun";
850 };
851
852 /*
853  * Local Variables:
854  * eval: (c-set-style "gnu")
855  * End:
856  */