“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 1 | /* |
| 2 | * ah_encrypt.c : IPSec AH encrypt node |
| 3 | * |
| 4 | * Copyright (c) 2015 Cisco and/or its affiliates. |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #include <vnet/vnet.h> |
| 19 | #include <vnet/api_errno.h> |
| 20 | #include <vnet/ip/ip.h> |
| 21 | |
| 22 | #include <vnet/ipsec/ipsec.h> |
| 23 | #include <vnet/ipsec/esp.h> |
| 24 | #include <vnet/ipsec/ah.h> |
| 25 | |
Klement Sekera | be5a5dd | 2018-10-09 16:05:48 +0200 | [diff] [blame] | 26 | #define foreach_ah_encrypt_next \ |
| 27 | _ (DROP, "error-drop") \ |
| 28 | _ (IP4_LOOKUP, "ip4-lookup") \ |
| 29 | _ (IP6_LOOKUP, "ip6-lookup") \ |
| 30 | _ (INTERFACE_OUTPUT, "interface-output") |
| 31 | |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 32 | |
| 33 | #define _(v, s) AH_ENCRYPT_NEXT_##v, |
| 34 | typedef enum |
| 35 | { |
| 36 | foreach_ah_encrypt_next |
| 37 | #undef _ |
| 38 | AH_ENCRYPT_N_NEXT, |
| 39 | } ah_encrypt_next_t; |
| 40 | |
| 41 | #define foreach_ah_encrypt_error \ |
| 42 | _(RX_PKTS, "AH pkts received") \ |
| 43 | _(SEQ_CYCLED, "sequence number cycled") |
| 44 | |
| 45 | |
| 46 | typedef enum |
| 47 | { |
| 48 | #define _(sym,str) AH_ENCRYPT_ERROR_##sym, |
| 49 | foreach_ah_encrypt_error |
| 50 | #undef _ |
| 51 | AH_ENCRYPT_N_ERROR, |
| 52 | } ah_encrypt_error_t; |
| 53 | |
| 54 | static char *ah_encrypt_error_strings[] = { |
| 55 | #define _(sym,string) string, |
| 56 | foreach_ah_encrypt_error |
| 57 | #undef _ |
| 58 | }; |
| 59 | |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 60 | typedef struct |
| 61 | { |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 62 | u32 sa_index; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 63 | u32 spi; |
Neale Ranns | 3833ffd | 2019-03-21 14:34:09 +0000 | [diff] [blame] | 64 | u32 seq_lo; |
| 65 | u32 seq_hi; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 66 | ipsec_integ_alg_t integ_alg; |
| 67 | } ah_encrypt_trace_t; |
| 68 | |
| 69 | /* packet trace format function */ |
| 70 | static u8 * |
| 71 | format_ah_encrypt_trace (u8 * s, va_list * args) |
| 72 | { |
| 73 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); |
| 74 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); |
| 75 | ah_encrypt_trace_t *t = va_arg (*args, ah_encrypt_trace_t *); |
| 76 | |
Neale Ranns | 3833ffd | 2019-03-21 14:34:09 +0000 | [diff] [blame] | 77 | s = format (s, "ah: sa-index %d spi %u seq %u:%u integrity %U", |
| 78 | t->sa_index, t->spi, t->seq_hi, t->seq_lo, |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 79 | format_ipsec_integ_alg, t->integ_alg); |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 80 | return s; |
| 81 | } |
| 82 | |
Klement Sekera | be5a5dd | 2018-10-09 16:05:48 +0200 | [diff] [blame] | 83 | always_inline uword |
| 84 | ah_encrypt_inline (vlib_main_t * vm, |
| 85 | vlib_node_runtime_t * node, vlib_frame_t * from_frame, |
| 86 | int is_ip6) |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 87 | { |
Neale Ranns | eba31ec | 2019-02-17 18:04:27 +0000 | [diff] [blame] | 88 | u32 n_left_from, *from, *to_next = 0, next_index, thread_index; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 89 | int icv_size = 0; |
| 90 | from = vlib_frame_vector_args (from_frame); |
| 91 | n_left_from = from_frame->n_vectors; |
| 92 | ipsec_main_t *im = &ipsec_main; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 93 | next_index = node->cached_next_index; |
Neale Ranns | eba31ec | 2019-02-17 18:04:27 +0000 | [diff] [blame] | 94 | thread_index = vm->thread_index; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 95 | |
| 96 | while (n_left_from > 0) |
| 97 | { |
| 98 | u32 n_left_to_next; |
| 99 | |
| 100 | vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); |
| 101 | |
| 102 | while (n_left_from > 0 && n_left_to_next > 0) |
| 103 | { |
| 104 | u32 i_bi0, next0; |
| 105 | vlib_buffer_t *i_b0 = 0; |
| 106 | u32 sa_index0; |
| 107 | ipsec_sa_t *sa0; |
| 108 | ip4_and_ah_header_t *ih0, *oh0 = 0; |
| 109 | ip6_and_ah_header_t *ih6_0, *oh6_0 = 0; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 110 | u8 ip_hdr_size; |
| 111 | u8 next_hdr_type; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 112 | u8 tos = 0; |
| 113 | u8 ttl = 0; |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 114 | u8 hop_limit = 0; |
| 115 | u32 ip_version_traffic_class_and_flow_label = 0; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 116 | |
| 117 | i_bi0 = from[0]; |
| 118 | from += 1; |
| 119 | n_left_from -= 1; |
| 120 | n_left_to_next -= 1; |
| 121 | next0 = AH_ENCRYPT_NEXT_DROP; |
| 122 | |
| 123 | i_b0 = vlib_get_buffer (vm, i_bi0); |
| 124 | to_next[0] = i_bi0; |
| 125 | to_next += 1; |
| 126 | sa_index0 = vnet_buffer (i_b0)->ipsec.sad_index; |
| 127 | sa0 = pool_elt_at_index (im->sad, sa_index0); |
| 128 | |
| 129 | if (PREDICT_FALSE (esp_seq_advance (sa0))) |
| 130 | { |
Neale Ranns | 3833ffd | 2019-03-21 14:34:09 +0000 | [diff] [blame] | 131 | i_b0->error = node->errors[AH_ENCRYPT_ERROR_SEQ_CYCLED]; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 132 | goto trace; |
| 133 | } |
Neale Ranns | eba31ec | 2019-02-17 18:04:27 +0000 | [diff] [blame] | 134 | vlib_increment_combined_counter |
| 135 | (&ipsec_sa_counters, thread_index, sa_index0, |
| 136 | 1, i_b0->current_length); |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 137 | |
| 138 | ssize_t adv; |
| 139 | ih0 = vlib_buffer_get_current (i_b0); |
| 140 | ttl = ih0->ip4.ttl; |
| 141 | tos = ih0->ip4.tos; |
| 142 | |
Damjan Marion | d709cbc | 2019-03-26 13:16:42 +0100 | [diff] [blame] | 143 | if (PREDICT_TRUE (ipsec_sa_is_set_IS_TUNNEL (sa0))) |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 144 | { |
Klement Sekera | be5a5dd | 2018-10-09 16:05:48 +0200 | [diff] [blame] | 145 | if (is_ip6) |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 146 | adv = -sizeof (ip6_and_ah_header_t); |
Klement Sekera | be5a5dd | 2018-10-09 16:05:48 +0200 | [diff] [blame] | 147 | else |
| 148 | adv = -sizeof (ip4_and_ah_header_t); |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 149 | } |
| 150 | else |
| 151 | { |
| 152 | adv = -sizeof (ah_header_t); |
| 153 | } |
| 154 | |
Damjan Marion | 7c22ff7 | 2019-04-04 12:25:44 +0200 | [diff] [blame] | 155 | icv_size = sa0->integ_icv_size; |
Klement Sekera | be5a5dd | 2018-10-09 16:05:48 +0200 | [diff] [blame] | 156 | const u8 padding_len = ah_calc_icv_padding_len (icv_size, is_ip6); |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 157 | adv -= padding_len; |
Klement Sekera | be5a5dd | 2018-10-09 16:05:48 +0200 | [diff] [blame] | 158 | /* transport mode save the eth header before it is overwritten */ |
Damjan Marion | d709cbc | 2019-03-26 13:16:42 +0100 | [diff] [blame] | 159 | if (PREDICT_FALSE (!ipsec_sa_is_set_IS_TUNNEL (sa0))) |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 160 | { |
| 161 | ethernet_header_t *ieh0 = (ethernet_header_t *) |
| 162 | ((u8 *) vlib_buffer_get_current (i_b0) - |
| 163 | sizeof (ethernet_header_t)); |
| 164 | ethernet_header_t *oeh0 = |
| 165 | (ethernet_header_t *) ((u8 *) ieh0 + (adv - icv_size)); |
Dave Barach | 178cf49 | 2018-11-13 16:34:13 -0500 | [diff] [blame] | 166 | clib_memcpy_fast (oeh0, ieh0, sizeof (ethernet_header_t)); |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | vlib_buffer_advance (i_b0, adv - icv_size); |
| 170 | |
Klement Sekera | be5a5dd | 2018-10-09 16:05:48 +0200 | [diff] [blame] | 171 | if (is_ip6) |
| 172 | { |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 173 | ih6_0 = (ip6_and_ah_header_t *) ih0; |
| 174 | ip_hdr_size = sizeof (ip6_header_t); |
| 175 | oh6_0 = vlib_buffer_get_current (i_b0); |
| 176 | |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 177 | hop_limit = ih6_0->ip6.hop_limit; |
| 178 | ip_version_traffic_class_and_flow_label = |
| 179 | ih6_0->ip6.ip_version_traffic_class_and_flow_label; |
Damjan Marion | d709cbc | 2019-03-26 13:16:42 +0100 | [diff] [blame] | 180 | if (PREDICT_TRUE (ipsec_sa_is_set_IS_TUNNEL (sa0))) |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 181 | { |
| 182 | next_hdr_type = IP_PROTOCOL_IPV6; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 183 | } |
| 184 | else |
| 185 | { |
| 186 | next_hdr_type = ih6_0->ip6.protocol; |
| 187 | memmove (oh6_0, ih6_0, sizeof (ip6_header_t)); |
| 188 | } |
| 189 | |
| 190 | oh6_0->ip6.protocol = IP_PROTOCOL_IPSEC_AH; |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 191 | oh6_0->ip6.hop_limit = 0; |
| 192 | oh6_0->ip6.ip_version_traffic_class_and_flow_label = 0x60; |
| 193 | oh6_0->ah.reserved = 0; |
| 194 | oh6_0->ah.nexthdr = next_hdr_type; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 195 | oh6_0->ah.spi = clib_net_to_host_u32 (sa0->spi); |
| 196 | oh6_0->ah.seq_no = clib_net_to_host_u32 (sa0->seq); |
| 197 | oh6_0->ip6.payload_length = |
| 198 | clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, i_b0) - |
| 199 | sizeof (ip6_header_t)); |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 200 | oh6_0->ah.hdrlen = |
| 201 | (sizeof (ah_header_t) + icv_size + padding_len) / 4 - 2; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 202 | } |
| 203 | else |
| 204 | { |
| 205 | ip_hdr_size = sizeof (ip4_header_t); |
| 206 | oh0 = vlib_buffer_get_current (i_b0); |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 207 | clib_memset (oh0, 0, sizeof (ip4_and_ah_header_t)); |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 208 | |
Damjan Marion | d709cbc | 2019-03-26 13:16:42 +0100 | [diff] [blame] | 209 | if (PREDICT_TRUE (ipsec_sa_is_set_IS_TUNNEL (sa0))) |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 210 | { |
| 211 | next_hdr_type = IP_PROTOCOL_IP_IN_IP; |
| 212 | } |
| 213 | else |
| 214 | { |
| 215 | next_hdr_type = ih0->ip4.protocol; |
| 216 | memmove (oh0, ih0, sizeof (ip4_header_t)); |
| 217 | } |
| 218 | |
| 219 | oh0->ip4.length = |
| 220 | clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, i_b0)); |
| 221 | oh0->ip4.ip_version_and_header_length = 0x45; |
| 222 | oh0->ip4.fragment_id = 0; |
| 223 | oh0->ip4.flags_and_fragment_offset = 0; |
| 224 | oh0->ip4.ttl = 0; |
| 225 | oh0->ip4.tos = 0; |
| 226 | oh0->ip4.protocol = IP_PROTOCOL_IPSEC_AH; |
| 227 | oh0->ah.spi = clib_net_to_host_u32 (sa0->spi); |
| 228 | oh0->ah.seq_no = clib_net_to_host_u32 (sa0->seq); |
| 229 | oh0->ip4.checksum = 0; |
| 230 | oh0->ah.nexthdr = next_hdr_type; |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 231 | oh0->ah.hdrlen = |
| 232 | (sizeof (ah_header_t) + icv_size + padding_len) / 4 - 2; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | |
Damjan Marion | d709cbc | 2019-03-26 13:16:42 +0100 | [diff] [blame] | 236 | if (PREDICT_TRUE (!is_ip6 && ipsec_sa_is_set_IS_TUNNEL (sa0) && |
| 237 | !ipsec_sa_is_set_IS_TUNNEL_V6 (sa0))) |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 238 | { |
| 239 | oh0->ip4.src_address.as_u32 = sa0->tunnel_src_addr.ip4.as_u32; |
| 240 | oh0->ip4.dst_address.as_u32 = sa0->tunnel_dst_addr.ip4.as_u32; |
| 241 | |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 242 | next0 = sa0->dpo[IPSEC_PROTOCOL_AH].dpoi_next_node; |
| 243 | vnet_buffer (i_b0)->ip.adj_index[VLIB_TX] = |
| 244 | sa0->dpo[IPSEC_PROTOCOL_AH].dpoi_index; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 245 | } |
Damjan Marion | d709cbc | 2019-03-26 13:16:42 +0100 | [diff] [blame] | 246 | else if (is_ip6 && ipsec_sa_is_set_IS_TUNNEL (sa0) && |
| 247 | ipsec_sa_is_set_IS_TUNNEL_V6 (sa0)) |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 248 | { |
| 249 | oh6_0->ip6.src_address.as_u64[0] = |
| 250 | sa0->tunnel_src_addr.ip6.as_u64[0]; |
| 251 | oh6_0->ip6.src_address.as_u64[1] = |
| 252 | sa0->tunnel_src_addr.ip6.as_u64[1]; |
| 253 | oh6_0->ip6.dst_address.as_u64[0] = |
| 254 | sa0->tunnel_dst_addr.ip6.as_u64[0]; |
| 255 | oh6_0->ip6.dst_address.as_u64[1] = |
| 256 | sa0->tunnel_dst_addr.ip6.as_u64[1]; |
| 257 | |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 258 | next0 = sa0->dpo[IPSEC_PROTOCOL_AH].dpoi_next_node; |
| 259 | vnet_buffer (i_b0)->ip.adj_index[VLIB_TX] = |
| 260 | sa0->dpo[IPSEC_PROTOCOL_AH].dpoi_index; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 261 | } |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 262 | |
| 263 | u8 sig[64]; |
Kingwel Xie | 561d1ca | 2019-03-05 22:56:17 -0500 | [diff] [blame] | 264 | |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 265 | u8 *digest = |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 266 | vlib_buffer_get_current (i_b0) + ip_hdr_size + |
| 267 | sizeof (ah_header_t); |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 268 | clib_memset (digest, 0, icv_size); |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 269 | |
Damjan Marion | b966e8b | 2019-03-20 16:07:09 +0100 | [diff] [blame] | 270 | unsigned size = hmac_calc (vm, sa0, vlib_buffer_get_current (i_b0), |
| 271 | i_b0->current_length, sig); |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 272 | |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 273 | memcpy (digest, sig, size); |
Klement Sekera | be5a5dd | 2018-10-09 16:05:48 +0200 | [diff] [blame] | 274 | if (is_ip6) |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 275 | { |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 276 | oh6_0->ip6.hop_limit = hop_limit; |
| 277 | oh6_0->ip6.ip_version_traffic_class_and_flow_label = |
| 278 | ip_version_traffic_class_and_flow_label; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 279 | } |
| 280 | else |
| 281 | { |
| 282 | oh0->ip4.ttl = ttl; |
| 283 | oh0->ip4.tos = tos; |
| 284 | oh0->ip4.checksum = ip4_header_checksum (&oh0->ip4); |
| 285 | } |
| 286 | |
Damjan Marion | d709cbc | 2019-03-26 13:16:42 +0100 | [diff] [blame] | 287 | if (!ipsec_sa_is_set_IS_TUNNEL (sa0)) |
Klement Sekera | be5a5dd | 2018-10-09 16:05:48 +0200 | [diff] [blame] | 288 | { |
| 289 | next0 = AH_ENCRYPT_NEXT_INTERFACE_OUTPUT; |
| 290 | vlib_buffer_advance (i_b0, -sizeof (ethernet_header_t)); |
| 291 | } |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 292 | |
| 293 | trace: |
| 294 | if (PREDICT_FALSE (i_b0->flags & VLIB_BUFFER_IS_TRACED)) |
| 295 | { |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 296 | ah_encrypt_trace_t *tr = |
| 297 | vlib_add_trace (vm, node, i_b0, sizeof (*tr)); |
| 298 | tr->spi = sa0->spi; |
Neale Ranns | 3833ffd | 2019-03-21 14:34:09 +0000 | [diff] [blame] | 299 | tr->seq_lo = sa0->seq; |
| 300 | tr->seq_hi = sa0->seq_hi; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 301 | tr->integ_alg = sa0->integ_alg; |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 302 | tr->sa_index = sa_index0; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | vlib_validate_buffer_enqueue_x1 (vm, node, next_index, |
| 306 | to_next, n_left_to_next, i_bi0, |
| 307 | next0); |
| 308 | } |
| 309 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
| 310 | } |
Klement Sekera | 2e02ba0 | 2018-11-30 14:37:03 +0100 | [diff] [blame] | 311 | vlib_node_increment_counter (vm, node->node_index, |
| 312 | AH_ENCRYPT_ERROR_RX_PKTS, |
| 313 | from_frame->n_vectors); |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 314 | |
| 315 | return from_frame->n_vectors; |
| 316 | } |
| 317 | |
Klement Sekera | b8f3544 | 2018-10-29 13:38:19 +0100 | [diff] [blame] | 318 | VLIB_NODE_FN (ah4_encrypt_node) (vlib_main_t * vm, |
| 319 | vlib_node_runtime_t * node, |
| 320 | vlib_frame_t * from_frame) |
Klement Sekera | be5a5dd | 2018-10-09 16:05:48 +0200 | [diff] [blame] | 321 | { |
| 322 | return ah_encrypt_inline (vm, node, from_frame, 0 /* is_ip6 */ ); |
| 323 | } |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 324 | |
| 325 | /* *INDENT-OFF* */ |
Klement Sekera | be5a5dd | 2018-10-09 16:05:48 +0200 | [diff] [blame] | 326 | VLIB_REGISTER_NODE (ah4_encrypt_node) = { |
Klement Sekera | be5a5dd | 2018-10-09 16:05:48 +0200 | [diff] [blame] | 327 | .name = "ah4-encrypt", |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 328 | .vector_size = sizeof (u32), |
| 329 | .format_trace = format_ah_encrypt_trace, |
| 330 | .type = VLIB_NODE_TYPE_INTERNAL, |
| 331 | |
| 332 | .n_errors = ARRAY_LEN(ah_encrypt_error_strings), |
| 333 | .error_strings = ah_encrypt_error_strings, |
| 334 | |
| 335 | .n_next_nodes = AH_ENCRYPT_N_NEXT, |
| 336 | .next_nodes = { |
| 337 | #define _(s,n) [AH_ENCRYPT_NEXT_##s] = n, |
| 338 | foreach_ah_encrypt_next |
| 339 | #undef _ |
| 340 | }, |
| 341 | }; |
| 342 | /* *INDENT-ON* */ |
| 343 | |
Klement Sekera | b8f3544 | 2018-10-29 13:38:19 +0100 | [diff] [blame] | 344 | VLIB_NODE_FN (ah6_encrypt_node) (vlib_main_t * vm, |
| 345 | vlib_node_runtime_t * node, |
| 346 | vlib_frame_t * from_frame) |
Klement Sekera | be5a5dd | 2018-10-09 16:05:48 +0200 | [diff] [blame] | 347 | { |
| 348 | return ah_encrypt_inline (vm, node, from_frame, 1 /* is_ip6 */ ); |
| 349 | } |
| 350 | |
| 351 | /* *INDENT-OFF* */ |
| 352 | VLIB_REGISTER_NODE (ah6_encrypt_node) = { |
Klement Sekera | be5a5dd | 2018-10-09 16:05:48 +0200 | [diff] [blame] | 353 | .name = "ah6-encrypt", |
| 354 | .vector_size = sizeof (u32), |
| 355 | .format_trace = format_ah_encrypt_trace, |
| 356 | .type = VLIB_NODE_TYPE_INTERNAL, |
| 357 | |
| 358 | .n_errors = ARRAY_LEN(ah_encrypt_error_strings), |
| 359 | .error_strings = ah_encrypt_error_strings, |
| 360 | |
| 361 | .n_next_nodes = AH_ENCRYPT_N_NEXT, |
| 362 | .next_nodes = { |
| 363 | #define _(s,n) [AH_ENCRYPT_NEXT_##s] = n, |
| 364 | foreach_ah_encrypt_next |
| 365 | #undef _ |
| 366 | }, |
| 367 | }; |
| 368 | /* *INDENT-ON* */ |
| 369 | |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 370 | /* |
| 371 | * fd.io coding-style-patch-verification: ON |
| 372 | * |
| 373 | * Local Variables: |
| 374 | * eval: (c-set-style "gnu") |
| 375 | * End: |
| 376 | */ |