19 #include <vpp/app/version.h> 29 #include <openssl/sha.h> 32 #define IKEV2_LIVENESS_RETRIES 3 33 #define IKEV2_LIVENESS_PERIOD_CHECK 30 41 #define ikev2_set_state(sa, v, ...) do { \ 43 ikev2_elog_sa_state("ispi %lx SA state changed to " #v __VA_ARGS__, sa->ispi); \ 59 s =
format (s,
"ikev2: sw_if_index %d, next index %d",
64 #define IKEV2_GENERATE_SA_INIT_OK_str "" 65 #define IKEV2_GENERATE_SA_INIT_OK_ERR_NO_DH_STR \ 66 "no DH group configured for IKE proposals!" 67 #define IKEV2_GENERATE_SA_INIT_OK_ERR_UNSUPP_STR \ 68 "DH group not supported!" 95 #define foreach_ikev2_error \ 96 _(PROCESSED, "IKEv2 packets processed") \ 97 _(IKE_SA_INIT_RETRANSMIT, "IKE_SA_INIT retransmit ") \ 98 _(IKE_SA_INIT_IGNORE, "IKE_SA_INIT ignore (IKE SA already auth)") \ 99 _(IKE_REQ_RETRANSMIT, "IKE request retransmit") \ 100 _(IKE_REQ_IGNORE, "IKE request ignore (old msgid)") \ 101 _(NOT_IKEV2, "Non IKEv2 packets received") \ 102 _(BAD_LENGTH, "Bad packet length") \ 103 _(MALFORMED_PACKET, "Malformed packet") \ 104 _(NO_BUFF_SPACE, "No buffer space") 108 #define _(sym,str) IKEV2_ERROR_##sym, 115 #define _(sym,string) string, 164 if (td->
type == IKEV2_TRANSFORM_TYPE_ENCR)
167 || t->
attrs[1] != 14)
185 u8 mandatory_bitmap, optional_bitmap;
189 mandatory_bitmap = (1 << IKEV2_TRANSFORM_TYPE_ENCR) |
190 (1 << IKEV2_TRANSFORM_TYPE_PRF) | (1 << IKEV2_TRANSFORM_TYPE_DH);
191 optional_bitmap = mandatory_bitmap | (1 << IKEV2_TRANSFORM_TYPE_INTEG);
195 mandatory_bitmap = (1 << IKEV2_TRANSFORM_TYPE_ENCR) |
196 (1 << IKEV2_TRANSFORM_TYPE_ESN);
197 optional_bitmap = mandatory_bitmap |
198 (1 << IKEV2_TRANSFORM_TYPE_INTEG) | (1 << IKEV2_TRANSFORM_TYPE_DH);
202 mandatory_bitmap = (1 << IKEV2_TRANSFORM_TYPE_INTEG) |
203 (1 << IKEV2_TRANSFORM_TYPE_ESN);
204 optional_bitmap = mandatory_bitmap | (1 << IKEV2_TRANSFORM_TYPE_DH);
219 if ((1 << transform->
type) & bitmap)
224 bitmap |= 1 << transform->
type;
231 if ((bitmap & mandatory_bitmap) == mandatory_bitmap &&
232 (bitmap & ~optional_bitmap) == 0)
236 RAND_bytes ((
u8 *) & rv->
spi, sizeof (rv->
spi));
276 if (proposal && proposal->
spi == spi && proposal->
protocol_id == prot_id)
397 if (sa->
dh_group == IKEV2_TRANSFORM_DH_TYPE_NONE)
403 if (t2->type == IKEV2_TRANSFORM_TYPE_DH && sa->
dh_group == t2->dh_type)
412 sa->
dh_group = IKEV2_TRANSFORM_DH_TYPE_NONE;
419 RAND_bytes ((
u8 *) & sa->
ispi, 8);
428 RAND_bytes ((
u8 *) & sa->
rspi, 8);
448 #define _(A) ({void* __tmp__ = (A); (A) = 0; __tmp__;}) 478 if (sa->
dh_group == IKEV2_TRANSFORM_DH_TYPE_NONE)
486 if (t2->type == IKEV2_TRANSFORM_TYPE_DH && sa->
dh_group == t2->dh_type)
495 sa->
dh_group = IKEV2_TRANSFORM_DH_TYPE_NONE;
512 u16 integ_key_len = 0, salt_len = 0;
522 integ_key_len = tr_integ->
key_len;
524 salt_len =
sizeof (
u32);
532 vec_add2 (s, tmp, 2 *
sizeof (*spi));
534 spi[0] = clib_host_to_net_u64 (sa->
ispi);
535 spi[1] = clib_host_to_net_u64 (sa->
rspi);
561 pos += integ_key_len;
566 pos += integ_key_len;
572 pos += tr_encr->
key_len + salt_len;
577 pos += tr_encr->
key_len + salt_len;
597 u16 integ_key_len = 0;
609 integ_key_len = ctr_integ->
key_len;
611 salt_len =
sizeof (
u32);
617 int len = ctr_encr->
key_len * 2 + integ_key_len * 2 + salt_len * 2;
651 pos += integ_key_len;
667 const u32 max_buf_size =
668 sizeof (
ispi) +
sizeof (rspi) +
sizeof (ip6_address_t) +
sizeof (
u16);
669 u8 buf[max_buf_size];
676 SHA1 (buf, 2 *
sizeof (ispi) +
sizeof (port) +
ip_address_size (ia), res);
684 const ike_ke_payload_header_t *ke = p;
685 u16 plen = clib_net_to_host_u16 (ke->length);
686 ASSERT (plen >=
sizeof (*ke) && plen <= rlen);
687 if (
sizeof (*ke) > rlen)
690 sa->
dh_group = clib_net_to_host_u16 (ke->dh_group);
692 vec_add (ke_data[0], ke->payload, plen - sizeof (*ke));
699 const ike_payload_header_t *ikep = p;
700 u16 plen = clib_net_to_host_u16 (ikep->length);
701 ASSERT (plen >=
sizeof (*ikep) && plen <= rlen);
710 if (
sizeof (*ikep) > rlen)
712 *plen = clib_net_to_host_u16 (ikep->length);
713 if (*plen <
sizeof (*ikep) || *plen > rlen)
725 u8 payload = ike->nextpayload;
726 ike_payload_header_t *ikep;
730 "from ", clib_net_to_host_u64 (ike->ispi),
731 clib_net_to_host_u64 (ike->rspi),
735 sa->
ispi = clib_net_to_host_u64 (ike->ispi);
741 if (len <
sizeof (*ike))
744 len -=
sizeof (*ike);
747 ikep = (ike_payload_header_t *) & ike->payload[p];
748 int current_length = len - p;
773 if (n->
msg_type == IKEV2_NOTIFY_MSG_NAT_DETECTION_SOURCE_IP)
782 " behind NAT", sa->
ispi);
787 IKEV2_NOTIFY_MSG_NAT_DETECTION_DESTINATION_IP)
796 " (self) behind NAT", sa->
ispi);
818 payload = ikep->nextpayload;
833 u8 payload = ike->nextpayload;
834 ike_payload_header_t *ikep;
837 sa->
ispi = clib_net_to_host_u64 (ike->ispi);
838 sa->
rspi = clib_net_to_host_u64 (ike->rspi);
849 if (
sizeof (*ike) > len)
852 len -=
sizeof (*ike);
855 int current_length = len - p;
856 ikep = (ike_payload_header_t *) & ike->payload[p];
868 clib_host_to_net_u32 (clib_net_to_host_u32 (ike->msgid) + 1);
887 if (n->
msg_type == IKEV2_NOTIFY_MSG_NAT_DETECTION_SOURCE_IP)
895 " behind NAT, unsupported", sa->
ispi);
900 IKEV2_NOTIFY_MSG_NAT_DETECTION_DESTINATION_IP)
910 " (self) behind NAT", sa->
ispi);
932 payload = ikep->nextpayload;
939 u8 * payload,
u32 rlen,
u32 * out_len)
944 ike_payload_header_t *ikep = 0;
953 int is_aead = tr_encr->
encr_type == IKEV2_TRANSFORM_ENCR_TYPE_AES_GCM_16;
958 if (rlen <=
sizeof (*ike))
961 int len = rlen -
sizeof (*ike);
965 ikep = (ike_payload_header_t *) & ike->payload[p];
966 int current_length = len - p;
972 last_payload = *payload;
985 *payload = ikep->nextpayload;
1001 u8 *aad = (
u8 *) ike;
1002 u32 aad_len = ikep->payload - aad;
1003 u8 *tag = ikep->payload + plen;
1006 plen, aad, aad_len, tag, &dlen);
1022 if (plen <
sizeof (*ikep) + tr_integ->
key_trunc)
1025 plen = plen -
sizeof (*ikep) - tr_integ->
key_trunc;
1083 for (i = 0; i <
vec_len (
delete); i++)
1121 const ike_id_payload_header_t *
id = p;
1122 u16 plen = clib_net_to_host_u16 (id->length);
1123 if (plen <
sizeof (*
id) || plen > rlen)
1126 sa_id->
type =
id->id_type;
1128 vec_add (sa_id->
data, id->payload, plen - sizeof (*
id));
1136 const ike_auth_payload_header_t *ah = p;
1137 u16 plen = clib_net_to_host_u16 (ah->length);
1139 a->
method = ah->auth_method;
1141 vec_add (a->
data, ah->payload, plen - sizeof (*ah));
1147 ike_header_t * ike,
u32 len)
1151 u8 payload = ike->nextpayload;
1153 ike_payload_header_t *ikep;
1158 "from ", clib_host_to_net_u64 (ike->ispi),
1159 clib_host_to_net_u64 (ike->rspi),
1182 first_child_sa = &sa->
childs[0];
1194 ikep = (ike_payload_header_t *) & plaintext[p];
1195 int current_length = dlen - p;
1243 if (n->
msg_type == IKEV2_NOTIFY_MSG_INITIAL_CONTACT)
1276 payload = ikep->nextpayload;
1292 u8 payload = ike->nextpayload;
1294 ike_payload_header_t *ikep;
1300 "from ", clib_host_to_net_u64 (ike->ispi),
1301 clib_host_to_net_u64 (ike->rspi),
1314 u32 current_length = dlen - p;
1315 if (p +
sizeof (*ikep) > dlen)
1318 ikep = (ike_payload_header_t *) & plaintext[p];
1319 u16 plen = clib_net_to_host_u16 (ikep->length);
1321 if (plen <
sizeof (*ikep) || plen > current_length)
1329 if (n->
msg_type == IKEV2_NOTIFY_MSG_AUTHENTICATION_FAILED)
1351 payload = ikep->nextpayload;
1363 u8 payload = ike->nextpayload;
1368 ike_payload_header_t *ikep;
1378 "from ", clib_host_to_net_u64 (ike->ispi),
1379 clib_host_to_net_u64 (ike->rspi),
1386 goto cleanup_and_exit;
1392 ikep = (ike_payload_header_t *) & plaintext[p];
1393 int current_length = dlen - p;
1395 goto cleanup_and_exit;
1404 if (n->
msg_type == IKEV2_NOTIFY_MSG_REKEY_SA)
1436 goto cleanup_and_exit;
1439 payload = ikep->nextpayload;
1448 goto cleanup_and_exit;
1473 goto cleanup_and_exit;
1491 goto cleanup_and_exit;
1563 ikev2_ts_t *ts, *p_tsi, *p_tsr, *tsi = 0, *tsr = 0;
1633 u8 *authmsg, *key_pad, *psk = 0, *
auth = 0;
1640 if (!(sa->
i_auth.
method == IKEV2_AUTH_METHOD_SHARED_KEY_MIC ||
1644 "unsupported authentication method %u",
1677 if (sa_auth->
method == IKEV2_AUTH_METHOD_SHARED_KEY_MIC)
1680 p->
auth.
method != IKEV2_AUTH_METHOD_SHARED_KEY_MIC)
1695 else if (sa_auth->
method == IKEV2_AUTH_METHOD_RSA_SIG)
1697 if (p->
auth.
method != IKEV2_AUTH_METHOD_RSA_SIG)
1732 if (sel_p->
auth.
method == IKEV2_AUTH_METHOD_SHARED_KEY_MIC)
1738 else if (sel_p->
auth.
method == IKEV2_AUTH_METHOD_RSA_SIG)
1761 ikev2_elog_uint (IKEV2_LOG_ERROR,
"authentication failed, no matching " 1762 "profile found! ispi %lx", sa->
ispi);
1774 u8 *authmsg, *key_pad, *psk = 0;
1781 if (!(sa->
i_auth.
method == IKEV2_AUTH_METHOD_SHARED_KEY_MIC ||
1785 "unsupported authentication method %u",
1795 if (sa->
i_auth.
method == IKEV2_AUTH_METHOD_SHARED_KEY_MIC)
1801 else if (sa->
i_auth.
method == IKEV2_AUTH_METHOD_RSA_SIG)
1816 return (0x80000000 | (ti << 24) | (sai << 12) | ci);
1822 return (0xc0000000 | (ti << 24) | (sai << 12) | ci);
1859 TUNNEL_ENCAP_DECAP_FLAG_NONE, IP_DSCP_CS0,
1860 TUNNEL_MODE_P2P, &sw_if_index);
1862 if (rv == VNET_API_ERROR_IF_ALREADY_EXISTS)
1879 "installing ipip tunnel failed! local spi: %x",
1902 &a->
remote_ip, TUNNEL_ENCAP_DECAP_FLAG_NONE,
1910 (a->
flags | IPSEC_SA_FLAG_IS_INBOUND), 0,
1912 &a->
local_ip, TUNNEL_ENCAP_DECAP_FLAG_NONE,
1936 u32 child_index,
u8 is_rekey)
1940 ipsec_crypto_alg_t encr_type;
1941 ipsec_integ_alg_t integ_type;
1973 a.
flags = IPSEC_SA_FLAG_USE_ANTI_REPLAY;
1976 a.
flags |= IPSEC_SA_FLAG_IS_TUNNEL;
1977 a.
flags |= IPSEC_SA_FLAG_UDP_ENCAP;
1980 a.
flags |= IPSEC_SA_FLAG_UDP_ENCAP;
1985 a.
flags |= IPSEC_SA_FLAG_USE_ESN;
1995 encr_type = IPSEC_CRYPTO_ALG_AES_CBC_128;
1998 encr_type = IPSEC_CRYPTO_ALG_AES_CBC_192;
2001 encr_type = IPSEC_CRYPTO_ALG_AES_CBC_256;
2009 else if (tr->
encr_type == IKEV2_TRANSFORM_ENCR_TYPE_AES_GCM_16
2015 encr_type = IPSEC_CRYPTO_ALG_AES_GCM_128;
2018 encr_type = IPSEC_CRYPTO_ALG_AES_GCM_192;
2021 encr_type = IPSEC_CRYPTO_ALG_AES_GCM_256;
2050 case IKEV2_TRANSFORM_INTEG_TYPE_AUTH_HMAC_SHA2_256_128:
2051 integ_type = IPSEC_INTEG_ALG_SHA_256_128;
2053 case IKEV2_TRANSFORM_INTEG_TYPE_AUTH_HMAC_SHA2_384_192:
2054 integ_type = IPSEC_INTEG_ALG_SHA_384_192;
2056 case IKEV2_TRANSFORM_INTEG_TYPE_AUTH_HMAC_SHA2_512_256:
2057 integ_type = IPSEC_INTEG_ALG_SHA_512_256;
2059 case IKEV2_TRANSFORM_INTEG_TYPE_AUTH_HMAC_SHA1_96:
2060 integ_type = IPSEC_INTEG_ALG_SHA1_96;
2075 integ_type = IPSEC_INTEG_ALG_NONE;
2130 if (thread_index & 0xffffffc0)
2133 if (child_index & 0xfffff000 || sa_index & 0xfffff000)
2159 remote_sa_id |=
mask;
2171 (
u8 *) & a,
sizeof (a));
2203 ipip_tunnel_key_t
key = {
2227 if (~0 != sw_if_index)
2273 ike_payload_header_t *
ph;
2291 IKEV2_NOTIFY_MSG_NO_PROPOSAL_CHOSEN, 0);
2294 else if (sa->
dh_group == IKEV2_TRANSFORM_DH_TYPE_NONE)
2300 IKEV2_TRANSFORM_TYPE_DH);
2303 data[0] = (tr_dh->
dh_type >> 8) & 0xff;
2304 data[1] = (tr_dh->
dh_type) & 0xff;
2307 IKEV2_NOTIFY_MSG_INVALID_KE_PAYLOAD,
2318 IKEV2_NOTIFY_MSG_UNSUPPORTED_CRITICAL_PAYLOAD,
2326 ike->rspi = clib_host_to_net_u64 (sa->
rspi);
2331 u8 *nat_detection_sha1 =
2333 clib_host_to_net_u64 (sa->
rspi),
2336 IKEV2_NOTIFY_MSG_NAT_DETECTION_SOURCE_IP,
2337 nat_detection_sha1);
2339 nat_detection_sha1 =
2341 clib_host_to_net_u64 (sa->
rspi),
2344 IKEV2_NOTIFY_MSG_NAT_DETECTION_DESTINATION_IP,
2345 nat_detection_sha1);
2363 IKEV2_NOTIFY_MSG_AUTHENTICATION_FAILED,
2377 IKEV2_NOTIFY_MSG_NO_PROPOSAL_CHOSEN, 0);
2389 IKEV2_NOTIFY_MSG_UNSUPPORTED_CRITICAL_PAYLOAD,
2446 IKEV2_NOTIFY_MSG_UNSUPPORTED_CRITICAL_PAYLOAD,
2464 *(
u32 *) data = clib_host_to_net_u32 (notify.
spi);
2493 IKEV2_NOTIFY_MSG_UNSUPPORTED_CRITICAL_PAYLOAD,
2501 IKEV2_NOTIFY_MSG_NO_ADDITIONAL_SAS,
2510 tlen =
sizeof (*ike);
2519 ike->length = clib_host_to_net_u32 (tlen);
2539 plen =
sizeof (*ph);
2540 ph = (ike_payload_header_t *) & ike->payload[0];
2544 tr_encr->
encr_type == IKEV2_TRANSFORM_ENCR_TYPE_AES_GCM_16;
2562 ph->length = clib_host_to_net_u16 (plen);
2563 ike->length = clib_host_to_net_u32 (tlen);
2568 ph->payload, (
u8 *) ike,
2569 sizeof (*ike) +
sizeof (*ph),
2570 ph->payload + plen - sizeof (*ph) -
2580 (ptd, sa, tr_encr, chain->
data, ph->payload))
2590 sizeof (*ike), integ, tr_integ->
key_trunc);
2611 u8 payload = ike->nextpayload;
2613 if (sa->
ispi != clib_net_to_host_u64 (ike->ispi) ||
2622 ike_payload_header_t *ikep = (ike_payload_header_t *) & ike->payload[p];
2623 u32 plen = clib_net_to_host_u16 (ikep->length);
2625 if (plen <
sizeof (ike_payload_header_t))
2635 u32 slen = clib_net_to_host_u32 (tmp->length);
2636 ike->ispi = tmp->ispi;
2637 ike->rspi = tmp->rspi;
2638 ike->nextpayload = tmp->nextpayload;
2639 ike->version = tmp->version;
2640 ike->exchange = tmp->exchange;
2641 ike->flags = tmp->flags;
2642 ike->msgid = tmp->msgid;
2643 ike->length = tmp->length;
2645 slen - sizeof (*ike));
2647 "ispi %lx IKE_SA_INIT retransmit " 2648 "from %d.%d.%d.%d to %d.%d.%d.%d",
2658 "ispi %lx IKE_SA_INIT ignore " 2659 "from %d.%d.%d.%d to %d.%d.%d.%d",
2666 payload = ikep->nextpayload;
2699 u32 msg_id = clib_net_to_host_u32 (ike->msgid);
2712 u32 slen = clib_net_to_host_u32 (tmp->length);
2713 ike->ispi = tmp->ispi;
2714 ike->rspi = tmp->rspi;
2715 ike->nextpayload = tmp->nextpayload;
2716 ike->version = tmp->version;
2717 ike->exchange = tmp->exchange;
2718 ike->flags = tmp->flags;
2719 ike->msgid = tmp->msgid;
2720 ike->length = tmp->length;
2796 const void *
raddr,
const int af)
2818 "received from %d.%d.%d.%d to %d.%d.%d.%d",
2819 exchange, src, dst);
2865 int is_req = 0, has_non_esp_marker = 0;
2877 ptr +=
sizeof (*ip40);
2879 ptr +=
sizeof (*udp0);
2880 ike0 = (ike_header_t *) ptr;
2881 ip_hdr_sz =
sizeof (*ip40);
2893 ip_hdr_sz =
sizeof (*ip40);
2898 ip_hdr_sz =
sizeof (*ip60);
2906 if (*((
u32 *) ike0) == 0)
2911 has_non_esp_marker = 1;
2914 if (clib_net_to_host_u32 (ike0->length) != rlen)
2917 IKEV2_ERROR_BAD_LENGTH, 1);
2924 IKEV2_ERROR_NOT_IKEV2, 1);
2935 if (ike0->rspi == 0)
2954 IKEV2_ERROR_IKE_SA_INIT_IGNORE
2956 IKEV2_ERROR_IKE_SA_INIT_RETRANSMIT,
2964 IKEV2_ERROR_MALFORMED_PACKET,
2983 IKEV2_ERROR_NO_BUFF_SPACE,
3036 IKEV2_ERROR_NO_BUFF_SPACE,
3073 IKEV2_ERROR_IKE_REQ_IGNORE
3075 IKEV2_ERROR_IKE_REQ_RETRANSMIT,
3086 IKEV2_ERROR_MALFORMED_PACKET, 1);
3107 IKEV2_ERROR_NO_BUFF_SPACE,
3125 IKEV2_ERROR_IKE_REQ_IGNORE
3127 IKEV2_ERROR_IKE_REQ_RETRANSMIT,
3136 IKEV2_ERROR_MALFORMED_PACKET,
3179 IKEV2_ERROR_NO_BUFF_SPACE,
3197 IKEV2_ERROR_IKE_REQ_IGNORE
3199 IKEV2_ERROR_IKE_REQ_RETRANSMIT,
3208 IKEV2_ERROR_MALFORMED_PACKET,
3240 IKEV2_ERROR_NO_BUFF_SPACE,
3253 if (slen && ~0 != slen)
3274 if (!has_non_esp_marker)
3280 if (has_non_esp_marker)
3314 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
3327 IKEV2_ERROR_PROCESSED, frame->
n_vectors);
3347 .name =
"ikev2-ip4",
3348 .vector_size =
sizeof (
u32),
3364 .name =
"ikev2-ip6",
3365 .vector_size =
sizeof (
u32),
3389 vec_add2 (*proposals, proposal, 1);
3397 if (td->
type == IKEV2_TRANSFORM_TYPE_ENCR
3402 attr[0] = clib_host_to_net_u16 (14 | (1 << 15));
3403 attr[1] = clib_host_to_net_u16 (td->
key_len << 3);
3418 if (IKEV2_TRANSFORM_INTEG_TYPE_NONE != ts->
integ_alg)
3424 if (td->
type == IKEV2_TRANSFORM_TYPE_INTEG
3435 (
"Didn't find any supported algorithm for IKEV2_TRANSFORM_TYPE_INTEG");
3447 if (td->
type == IKEV2_TRANSFORM_TYPE_PRF
3448 && td->
prf_type == IKEV2_TRANSFORM_PRF_TYPE_PRF_HMAC_SHA2_256)
3491 if (td->
type == IKEV2_TRANSFORM_TYPE_ESN)
3536 udp0->
dst_port = clib_host_to_net_u16 (dst_port);
3537 udp0->
src_port = clib_host_to_net_u16 (src_port);
3565 clib_host_to_net_u32 (0x6 << 28);
3576 b0->
flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
3611 EVP_PKEY_free (km->
pkey);
3613 if (km->
pkey == NULL)
3637 return VNET_API_ERROR_UDP_PORT_TAKEN;
3690 if (send_notification)
3701 ike0->ispi = clib_host_to_net_u64 (sa->
ispi);
3702 ike0->rspi = clib_host_to_net_u64 (sa->
rspi);
3840 u8 * auth_data,
u8 data_hex_format)
3859 p->
auth.
hex = data_hex_format;
3861 if (auth_method == IKEV2_AUTH_METHOD_RSA_SIG)
3875 return (id_type == IKEV2_ID_TYPE_ID_IPV4_ADDR ||
3876 id_type == IKEV2_ID_TYPE_ID_IPV6_ADDR ||
3877 id_type == IKEV2_ID_TYPE_ID_RFC822_ADDR ||
3878 id_type == IKEV2_ID_TYPE_ID_FQDN);
4075 return VNET_API_ERROR_INVALID_VALUE;
4080 return VNET_API_ERROR_VALUE_EXIST;
4088 return VNET_API_ERROR_IKE_NO_PORT;
4091 return VNET_API_ERROR_INVALID_VALUE;
4142 ip6_address_t *if_ip6;
4174 int len =
sizeof (ike_header_t), valid_ip = 0;
4247 u8 *nat_detection_sha1 =
4249 clib_host_to_net_u64 (sa.
rspi),
4253 nat_detection_sha1);
4255 nat_detection_sha1 =
4257 clib_host_to_net_u64 (sa.
rspi),
4259 clib_host_to_net_u16 (sa.
dst_port));
4261 IKEV2_NOTIFY_MSG_NAT_DETECTION_DESTINATION_IP,
4262 nat_detection_sha1);
4266 u64 tmpsig = clib_host_to_net_u64 (0x0001000200030004);
4269 IKEV2_NOTIFY_MSG_SIGNATURE_HASH_ALGORITHMS,
4278 char *errmsg =
"buffer alloc failure";
4287 ike0->length = clib_host_to_net_u32 (len);
4294 ike0->ispi = clib_host_to_net_u64 (sa.
ispi);
4331 (
"ispi %lx rspi %lx IKEV2_EXCHANGE_SA_INIT sent to ",
4332 clib_host_to_net_u64 (sa0->
ispi), 0,
4368 ike0->ispi = clib_host_to_net_u64 (sa->
ispi);
4369 ike0->rspi = clib_host_to_net_u64 (sa->
rspi);
4417 if (!fchild || !fsa)
4447 if (sa->
ispi == ispi)
4488 ike0->ispi = clib_host_to_net_u64 (sa->
ispi);
4489 ike0->rspi = clib_host_to_net_u64 (sa->
rspi);
4499 RAND_bytes ((
u8 *) & proposals[0].
spi,
sizeof (proposals[0].spi));
4500 rekey->
spi = proposals[0].
spi;
4540 if (!fchild || !fsa)
4640 for (thread_id = 0; thread_id < tm->
n_vlib_mains; thread_id++)
4647 #if OPENSSL_VERSION_NUMBER >= 0x10100000L 4648 ptd->
evp_ctx = EVP_CIPHER_CTX_new ();
4651 EVP_CIPHER_CTX_init (&ptd->_evp_ctx);
4652 ptd->
evp_ctx = &ptd->_evp_ctx;
4653 HMAC_CTX_init (&(ptd->_hmac_ctx));
4680 .runs_after =
VLIB_INITS(
"ipsec_init",
"ipsec_punt_init"),
4734 if (~0 == sw_if_index)
4736 ip46_address_t local_ip;
4737 ip46_address_t remote_ip;
4754 ipip_tunnel_key_t
key = {
4804 if (period == 0 || max_retries == 0)
4886 IKEV2_NOTIFY_MSG_NAT_DETECTION_SOURCE_IP);
4891 clib_host_to_net_u64 (sa->
rspi),
4922 sa = pool_elt_at_index (km->sais, sai);
4923 if (sa->init_response_received)
4926 ikev2_process_pending_sa_init_one (km, sa);
4951 ike0->ispi = clib_host_to_net_u64 (sa->
ispi);
4952 ike0->rspi = clib_host_to_net_u64 (sa->
rspi);
5029 u32 *to_be_deleted = 0;
5103 "ikev2-manager-process",
5107 .version = VPP_BUILD_VER,
5108 .description =
"Internet Key Exchange (IKEv2) Protocol",
ikev2_main_per_thread_data_t * per_thread_data
ipip_tunnel_t * ipip_tunnel_db_find(const ipip_tunnel_key_t *key)
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
void udp_unregister_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u8 is_ip4)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
clib_error_t * ikev2_profile_natt_disable(u8 *name)
vl_api_address_t end_addr
void ikev2_payload_add_nonce(ikev2_payload_chain_t *c, u8 *nonce)
static ikev2_generate_sa_error_t ikev2_generate_sa_init_data(ikev2_sa_t *sa)
static u8 * format_ikev2_trace(u8 *s, va_list *args)
#define hash_set(h, key, value)
int ipsec_sa_add_and_lock(u32 id, u32 spi, ipsec_protocol_t proto, ipsec_crypto_alg_t crypto_alg, const ipsec_key_t *ck, ipsec_integ_alg_t integ_alg, const ipsec_key_t *ik, ipsec_sa_flags_t flags, u32 tx_table_id, u32 salt, const ip46_address_t *tun_src, const ip46_address_t *tun_dst, tunnel_encap_decap_flags_t tunnel_flags, ip_dscp_t dscp, u32 *sa_out_index, u16 src_port, u16 dst_port)
#define IKEV2_PAYLOAD_NONCE
void ikev2_payload_add_notify(ikev2_payload_chain_t *c, u16 msg_type, u8 *data)
ikev2_transforms_set ike_ts
static int ikev2_delete_tunnel_interface(vnet_main_t *vnm, ikev2_sa_t *sa, ikev2_child_sa_t *child)
static uword ikev2_ip4(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static u8 ikev2_mngr_process_child_sa(ikev2_sa_t *sa, ikev2_child_sa_t *csa, u8 del_old_ids)
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
ikev2_transform_integ_type_t
#define hash_unset(h, key)
#define ike_hdr_is_response(_h)
static void ikev2_del_sa_init(u64 ispi)
ikev2_natt_state_t natt_state
void ip_address_set(ip_address_t *dst, const void *src, u8 version)
clib_error_t * ikev2_add_del_profile(vlib_main_t *vm, u8 *name, int is_add)
int ikev2_encrypt_data(ikev2_main_per_thread_data_t *ptd, ikev2_sa_t *sa, ikev2_sa_transform_t *tr_encr, v8 *src, u8 *dst)
A representation of a IPIP tunnel.
void ikev2_payload_add_sa(ikev2_payload_chain_t *c, ikev2_sa_proposal_t *proposals)
vnet_main_t * vnet_get_main(void)
static void ikev2_elog_uint_peers_addr(u32 exchange, ip4_header_t *ip4, ip6_header_t *ip6, u8 is_ip4)
ikev2_traffic_selector_type_t ts_type
clib_error_t * ikev2_set_profile_udp_encap(vlib_main_t *vm, u8 *name)
static void ikev2_profile_free(ikev2_profile_t *p)
static void ikev2_calc_keys(ikev2_sa_t *sa)
#define pool_foreach(VAR, POOL)
Iterate through pool.
#define IKEV2_PAYLOAD_NONE
ikev2_profile_t * profiles
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
vl_api_ip_port_and_mask_t dst_port
clib_error_t * ikev2_initiate_delete_ike_sa(vlib_main_t *vm, u64 ispi)
vl_api_address_t start_addr
static void ikev2_initial_contact_cleanup(ikev2_main_per_thread_data_t *ptd, ikev2_sa_t *sa)
#define clib_memcpy_fast(a, b, c)
u32 current_remote_id_mask
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static void ikev2_sa_free_child_sa(ikev2_child_sa_t *c)
ip4_address_t * ip4_interface_first_address(ip4_main_t *im, u32 sw_if_index, ip_interface_address_t **result_ia)
v8 * ikev2_calc_prf(ikev2_sa_transform_t *tr, v8 *key, v8 *data)
static f64 vlib_time_now(vlib_main_t *vm)
static void ikev2_complete_sa_data(ikev2_sa_t *sa, ikev2_sa_t *sai)
#define ikev2_elog_error(_msg)
static int ikev2_get_if_address(u32 sw_if_index, ip_address_family_t af, ip_address_t *out_addr)
#define IKEV2_GENERATE_SA_INIT_OK_ERR_NO_DH_STR
#define IKEV2_EXCHANGE_SA_INIT
static void ikev2_delete_child_sa_internal(vlib_main_t *vm, ikev2_sa_t *sa, ikev2_child_sa_t *csa)
static u32 ikev2_get_new_ike_header_buff(vlib_main_t *vm, vlib_buffer_t **b)
u16 current_length
Nbytes between current data and the end of this buffer.
#define IKEV2_PAYLOAD_VENDOR
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
ip6_address_t * ip6_interface_first_address(ip6_main_t *im, u32 sw_if_index)
get first IPv6 interface address
void vnet_sw_interface_admin_down(vnet_main_t *vnm, u32 sw_if_index)
Combined counter to hold both packets and byte differences.
u16 ip_address_size(const ip_address_t *a)
clib_error_t * ikev2_set_profile_tunnel_interface(vlib_main_t *vm, u8 *name, u32 sw_if_index)
int vlib_punt_hdl_t
Typedef for a client handle.
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static int ikev2_process_sa_init_req(vlib_main_t *vm, ikev2_sa_t *sa, ike_header_t *ike, udp_header_t *udp, u32 len)
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
static clib_error_t * ikev2_sw_interface_add_del(vnet_main_t *vnm, u32 sw_if_index, u32 is_add)
static void mhash_init_vec_string(mhash_t *h, uword n_value_bytes)
static udp_dst_port_info_t * udp_get_dst_port_info(udp_main_t *um, udp_dst_port_t dst_port, u8 is_ip4)
#define IKEV2_GCM_ICV_SIZE
clib_error_t * ikev2_set_profile_sa_lifetime(vlib_main_t *vm, u8 *name, u64 lifetime, u32 jitter, u32 handover, u64 maxdata)
void ikev2_payload_add_ke(ikev2_payload_chain_t *c, u16 dh_group, u8 *dh_data)
clib_error_t * ikev2_set_liveness_params(u32 period, u32 max_retries)
#define IKEV2_PAYLOAD_TSR
static int ikev2_parse_id_payload(const void *p, u16 rlen, ikev2_id_t *sa_id)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
int ipip_add_tunnel(ipip_transport_t transport, u32 instance, ip46_address_t *src, ip46_address_t *dst, u32 fib_index, tunnel_encap_decap_flags_t flags, ip_dscp_t dscp, tunnel_mode_t tmode, u32 *sw_if_indexp)
static_always_inline int ikev2_mngr_process_responder_sas(ikev2_sa_t *sa)
static u8 * format_ikev2_gen_sa_error(u8 *s, va_list *args)
#define ip_addr_version(_a)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
void ipsec_mk_key(ipsec_key_t *key, const u8 *data, u8 len)
u8 * last_sa_init_res_packet_data
format_function_t format_vnet_sw_if_index_name
vnet_api_error_t ikev2_set_profile_ipsec_udp_port(vlib_main_t *vm, u8 *name, u16 port, u8 is_set)
u8 init_response_received
static void ikev2_cleanup_profile_sessions(ikev2_main_t *km, ikev2_profile_t *p)
ikev2_sa_transform_t * ikev2_sa_get_td_for_type(ikev2_sa_proposal_t *p, ikev2_transform_type_t type)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define vlib_worker_thread_barrier_sync(X)
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
#define clib_memcpy(d, s, n)
static void ikev2_mngr_process_ipsec_sa(ipsec_sa_t *ipsec_sa)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
ikev2_transform_dh_type_t
static int ikev2_sa_sw_if_match(ikev2_sa_t *sa, u32 sw_if_index)
ikev2_child_sa_t * ikev2_sa_get_child(ikev2_sa_t *sa, u32 spi, ikev2_protocol_id_t prot_id, int by_initiator)
static u32 ikev2_retransmit_resp(ikev2_sa_t *sa, ike_header_t *ike)
static_always_inline void ikev2_rewrite_v6_addrs(ikev2_sa_t *sa, ip6_header_t *ih)
#define static_always_inline
#define IKEV2_PAYLOAD_DELETE
ikev2_sa_proposal_t * r_proposals
#define ip_address_initializer
void ikev2_generate_dh(ikev2_sa_t *sa, ikev2_sa_transform_t *t)
#define VLIB_INIT_FUNCTION(x)
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
EVP_PKEY * ikev2_load_cert_file(u8 *file)
clib_error_t * ikev2_initiate_sa_init(vlib_main_t *vm, u8 *name)
#define IKEV2_LIVENESS_PERIOD_CHECK
int ipsec_tun_protect_del(u32 sw_if_index, const ip_address_t *nh)
static ikev2_sa_transform_t * ikev2_find_transform_data(ikev2_sa_transform_t *t)
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
EVP_PKEY * ikev2_load_key_file(u8 *file)
clib_error_t * ikev2_set_profile_auth(vlib_main_t *vm, u8 *name, u8 auth_method, u8 *auth_data, u8 data_hex_format)
ipsec_crypto_alg_t encr_type
void ikev2_parse_vendor_payload(ike_payload_header_t *ikep)
description fragment has unexpected format
#define hash_foreach(key_var, value_var, h, body)
static vlib_node_registration_t ikev2_mngr_process_node
(constructor) VLIB_REGISTER_NODE (ikev2_mngr_process_node)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
ipsec_integ_alg_t integ_type
void vnet_sw_interface_admin_up(vnet_main_t *vnm, u32 sw_if_index)
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
#define clib_error_return(e, args...)
int ipsec_sa_unlock_id(u32 id)
void ikev2_payload_add_id(ikev2_payload_chain_t *c, ikev2_id_t *id, u8 type)
#define IKEV2_PAYLOAD_NOTIFY
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
static void ikev2_sa_match_ts(ikev2_sa_t *sa)
static u32 ikev2_retransmit_sa_init_one(ikev2_sa_t *sa, ike_header_t *ike, ip_address_t iaddr, ip_address_t raddr, u32 rlen)
static void ikev2_initiate_delete_ike_sa_internal(vlib_main_t *vm, ikev2_main_per_thread_data_t *tkm, ikev2_sa_t *sa, u8 send_notification)
static void ikev2_send_ike(vlib_main_t *vm, ip_address_t *src, ip_address_t *dst, u32 bi0, u32 len, u16 src_port, u16 dst_port, u32 sw_if_index)
ikev2_sa_proposal_t * i_proposals
static void ikev2_sa_auth(ikev2_sa_t *sa)
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
static u8 * ikev2_decrypt_sk_payload(ikev2_sa_t *sa, ike_header_t *ike, u8 *payload, u32 rlen, u32 *out_len)
#define ikev2_payload_destroy_chain(V)
clib_error_t * ikev2_set_profile_esp_transforms(vlib_main_t *vm, u8 *name, ikev2_transform_encr_type_t crypto_alg, ikev2_transform_integ_type_t integ_alg, u32 crypto_key_size)
static void ikev2_del_sa_init_from_main(u64 *ispi)
ikev2_sa_transform_t * transforms
vlib_punt_hdl_t vlib_punt_client_register(const char *who)
Register a new clinet.
static void ikev2_process_pending_sa_init_one(ikev2_main_t *km, ikev2_sa_t *sa)
#define IKEV2_EXCHANGE_CREATE_CHILD_SA
pool_header_t * ph(void *p)
GDB callable function: ph - call pool_header - get pool header.
void ip_address_copy_addr(void *dst, const ip_address_t *src)
ikev2_responder_t responder
vl_api_fib_path_type_t type
int ikev2_set_log_level(ikev2_log_level_t log_level)
#define ikev2_set_state(sa, v,...)
static ikev2_profile_t * ikev2_profile_index_by_name(u8 *name)
static vlib_node_registration_t ikev2_node_ip6
(constructor) VLIB_REGISTER_NODE (ikev2_node_ip6)
clib_error_t * ikev2_set_profile_id(vlib_main_t *vm, u8 *name, u8 id_type, u8 *data, int is_local)
u8 * ikev2_calc_prfplus(ikev2_sa_transform_t *tr, u8 *key, u8 *seed, int len)
static u32 ikev2_mk_local_sa_id(u32 sai, u32 ci, u32 ti)
static clib_error_t * ikev2_set_initiator_proposals(vlib_main_t *vm, ikev2_sa_t *sa, ikev2_transforms_set *ts, ikev2_sa_proposal_t **proposals, int is_ike)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define ikev2_elog_exchange(_fmt, _ispi, _rspi, _addr, _v4)
void ikev2_cli_reference(void)
u8 * last_sa_init_req_packet_data
#define IKEV2_PAYLOAD_IDR
static_always_inline u32 ikev2_flip_alternate_sa_bit(u32 id)
#define ikev2_log_debug(...)
VNET_SW_INTERFACE_ADD_DEL_FUNCTION(ikev2_sw_interface_add_del)
static __clib_warn_unused_result u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
ikev2_sa_proposal_t * i_proposals
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
#define IKEV2_HDR_FLAG_RESPONSE
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
mhash_t profile_index_by_name
ikev2_sa_transform_t * supported_transforms
static uword ikev2_ip6(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define pool_put(P, E)
Free an object E in pool P.
#define vec_dup(V)
Return copy of vector (no header, no alignment)
clib_error_t * ikev2_initiate_delete_child_sa(vlib_main_t *vm, u32 ispi)
static_always_inline int ikev2_insert_non_esp_marker(ike_header_t *ike, int len)
static void ikev2_rekey_child_sa_internal(vlib_main_t *vm, ikev2_sa_t *sa, ikev2_child_sa_t *csa)
bool ip_address_is_zero(const ip_address_t *ip)
int ikev2_decrypt_data(ikev2_main_per_thread_data_t *ptd, ikev2_sa_t *sa, ikev2_sa_transform_t *tr_encr, u8 *data, int len, u32 *out_len)
#define vec_del1(v, i)
Delete the element at index I.
static_always_inline void ikev2_set_ts_type(ikev2_ts_t *ts, const ip_address_t *addr)
#define IKEV2_PAYLOAD_FLAG_CRITICAL
int ikev2_verify_sign(EVP_PKEY *pkey, u8 *sigbuf, u8 *data)
static void ikev2_sa_auth_init(ikev2_sa_t *sa)
static_always_inline ikev2_main_per_thread_data_t * ikev2_get_per_thread_data()
static int ikev2_parse_nonce_payload(const void *p, u32 rlen, u8 *nonce)
fib_protocol_t ip_address_to_46(const ip_address_t *addr, ip46_address_t *a)
u32 node_index
Node index.
#define ikev2_natt_active(_sa)
static void ikev2_sa_del(ikev2_profile_t *p, u32 sw_if_index)
static int ikev2_process_informational_req(vlib_main_t *vm, ikev2_sa_t *sa, ike_header_t *ike, u32 len)
clib_error_t * ikev2_set_local_key(vlib_main_t *vm, u8 *file)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static void ikev2_process_pending_sa_init(ikev2_main_t *km)
#define IKEV2_EXCHANGE_INFORMATIONAL
void ikev2_payload_add_delete(ikev2_payload_chain_t *c, ikev2_delete_t *d)
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
static u32 ikev2_mk_remote_sa_id(u32 sai, u32 ci, u32 ti)
vl_api_ip_port_and_mask_t src_port
#define IKEV2_HDR_FLAG_INITIATOR
static void ikev2_add_tunnel_from_main(ikev2_add_ipsec_tunnel_args_t *a)
static uword ikev2_mngr_process_fn(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
clib_error_t * ikev2_initiate_rekey_child_sa(vlib_main_t *vm, u32 ispi)
vlib_punt_reason_t ipsec_punt_reason[IPSEC_PUNT_N_REASONS]
#define VLIB_REGISTER_NODE(x,...)
#define ikev2_elog_uint(_level, _format, _val)
static_always_inline uword vlib_get_thread_index(void)
static void vlib_get_combined_counter(const vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thr...
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
static void ikev2_sa_del_child_sa(ikev2_sa_t *sa, ikev2_child_sa_t *child)
ikev2_auth_method_t method
ikev2_transform_encr_type_t
#define clib_memcmp(s1, s2, m1)
sll srl srl sll sra u16x4 i
ikev2_sa_proposal_t * ikev2_parse_sa_payload(ike_payload_header_t *ikep, u32 rlen)
static vlib_punt_hdl_t punt_hdl
#define vec_free(V)
Free vector's memory (no header).
static_always_inline vnet_api_error_t ikev2_register_udp_port(ikev2_profile_t *p, u16 port)
#define IKEV2_LIVENESS_RETRIES
static void ikev2_generate_sa_init_data_and_log(ikev2_sa_t *sa)
enum ipsec_sad_flags_t_ ipsec_sa_flags_t
static void ikev2_initial_contact_cleanup_internal(ikev2_main_per_thread_data_t *ptd, ikev2_sa_t *sa)
static_always_inline u16 ikev2_get_port(ikev2_sa_t *sa)
static_always_inline void ikev2_unregister_udp_port(ikev2_profile_t *p)
static int ikev2_create_tunnel_interface(vlib_main_t *vm, ikev2_sa_t *sa, ikev2_child_sa_t *child, u32 sa_index, u32 child_index, u8 is_rekey)
static_always_inline uword ikev2_node_internal(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u8 is_ip4)
static_always_inline void ikev2_set_ip_address(ikev2_sa_t *sa, const void *iaddr, const void *raddr, const int af)
#define ikev2_log_error(...)
ikev2_sa_proposal_t * r_proposals
static u32 ikev2_generate_message(vlib_buffer_t *b, ikev2_sa_t *sa, ike_header_t *ike, void *user, udp_header_t *udp)
vlib_main_t vlib_node_runtime_t * node
static u8 * ikev2_sa_generate_authmsg(ikev2_sa_t *sa, int is_responder)
static void ikev2_calc_child_keys(ikev2_sa_t *sa, ikev2_child_sa_t *child)
static int ikev2_parse_auth_payload(const void *p, u32 rlen, ikev2_auth_t *a)
#define hash_set1(h, key)
enum ikev2_log_level_t_ ikev2_log_level_t
vlib_node_registration_t ip6_lookup_node
(constructor) VLIB_REGISTER_NODE (ip6_lookup_node)
#define hash_create(elts, value_bytes)
void ikev2_payload_add_auth(ikev2_payload_chain_t *c, ikev2_auth_t *auth)
ikev2_protocol_id_t protocol_id
vlib_combined_counter_main_t ipsec_sa_counters
SA packet & bytes counters.
ikev2_notify_t * ikev2_parse_notify_payload(ike_payload_header_t *ikep, u32 rlen)
static_always_inline int ikev2_is_id_equal(ikev2_id_t *i1, ikev2_id_t *i2)
static_always_inline u8 * ikev2_compute_nat_sha1(u64 ispi, u64 rspi, ip_address_t *ia, u16 port)
static_always_inline void ikev2_set_ts_addrs(ikev2_ts_t *ts, const ip_address_t *start, const ip_address_t *end)
static_always_inline void ikev2_rewrite_v4_addrs(ikev2_sa_t *sa, ip4_header_t *ih)
int ikev2_decrypt_aead_data(ikev2_main_per_thread_data_t *ptd, ikev2_sa_t *sa, ikev2_sa_transform_t *tr_encr, u8 *data, int data_len, u8 *aad, u32 aad_len, u8 *tag, u32 *out_len)
static uword * mhash_get(mhash_t *h, const void *key)
#define ike_hdr_is_request(_h)
f64 liveness_period_check
void ikev2_sa_free_proposal_vector(ikev2_sa_proposal_t **v)
#define IKEV2_PAYLOAD_AUTH
#define ikev2_payload_new_chain(V)
static vlib_node_registration_t ikev2_node_ip4
(constructor) VLIB_REGISTER_NODE (ikev2_node_ip4)
ikev2_sa_proposal_t * r_proposal
static void ikev2_process_sa_init_resp(vlib_main_t *vm, ikev2_sa_t *sa, ike_header_t *ike, udp_header_t *udp, u32 len)
void ikev2_complete_dh(ikev2_sa_t *sa, ikev2_sa_transform_t *t)
#define vec_append(v1, v2)
Append v2 after v1.
int ikev2_encrypt_aead_data(ikev2_main_per_thread_data_t *ptd, ikev2_sa_t *sa, ikev2_sa_transform_t *tr_encr, v8 *src, u8 *dst, u8 *aad, u32 aad_len, u8 *tag)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
int ip_address_cmp(const ip_address_t *ip1, const ip_address_t *ip2)
ikev2_log_level_t log_level
ikev2_sa_proposal_t * i_proposal
vlib_node_registration_t ipsec4_tun_input_node
(constructor) VLIB_REGISTER_NODE (ipsec4_tun_input_node)
#define IKEV2_PAYLOAD_TSI
enum ip_address_family_t_ ip_address_family_t
__clib_export uword mhash_unset(mhash_t *h, void *key, uword *old_value)
u8 * last_res_packet_data
counter_t bytes
byte counter
ikev2_delete_t * ikev2_parse_delete_payload(ike_payload_header_t *ikep, u32 rlen)
static char * ikev2_error_strings[]
#define clib_atomic_bool_cmp_and_swap(addr, old, new)
int vlib_punt_register(vlib_punt_hdl_t client, vlib_punt_reason_t reason, const char *node_name)
Register a node to receive particular punted buffers.
static ip46_address_t to_ip46(u32 is_ipv6, u8 *buf)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * ikev2_set_profile_responder(vlib_main_t *vm, u8 *name, u32 sw_if_index, ip_address_t addr)
void ikev2_payload_chain_add_padding(ikev2_payload_chain_t *c, int bs)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
static int ikev2_is_id_supported(u8 id_type)
VLIB buffer representation.
static int ikev2_parse_ke_payload(const void *p, u32 rlen, ikev2_sa_t *sa, u8 **ke_data)
#define IKEV2_PAYLOAD_IDI
clib_error_t * ikev2_set_profile_ike_transforms(vlib_main_t *vm, u8 *name, ikev2_transform_encr_type_t crypto_alg, ikev2_transform_integ_type_t integ_alg, ikev2_transform_dh_type_t dh_type, u32 crypto_key_size)
#define ikev2_elog_uint_peers(_level, _format, _val, _ip1, _ip2)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static u32 ikev2_retransmit_sa_init(ike_header_t *ike, ip_address_t iaddr, ip_address_t raddr, u32 rlen)
#define IKEV2_GENERATE_SA_INIT_OK_ERR_UNSUPP_STR
static int ikev2_check_payload_length(const ike_payload_header_t *ikep, int rlen, u16 *plen)
ikev2_child_sa_t * childs
vlib_log_class_t log_class
#define clib_error_free(e)
int ipip_del_tunnel(u32 sw_if_index)
Linear Congruential Random Number Generator.
#define IKEV2_EXCHANGE_IKE_AUTH
static int ikev2_process_create_child_sa_req(vlib_main_t *vm, ikev2_sa_t *sa, ike_header_t *ike, u32 len)
static int ikev2_ts_cmp(ikev2_ts_t *ts1, ikev2_ts_t *ts2)
clib_error_t * ikev2_init(vlib_main_t *vm)
static u32 random_u32(u32 *seed)
32-bit random number generator
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
void ip_address_copy(ip_address_t *dst, const ip_address_t *src)
#define ike_hdr_is_initiator(_h)
ip4_main_t ip4_main
Global ip4 main structure.
ikev2_ts_t * ikev2_parse_ts_payload(ike_payload_header_t *ikep, u32 rlen)
static vlib_thread_main_t * vlib_get_thread_main()
#define vec_foreach(var, vec)
Vector iterator.
f64 end
end of the time range
static void ikev2_sa_free_all_child_sa(ikev2_child_sa_t **childs)
u16 flags
Copy of main node flags.
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static ikev2_sa_proposal_t * ikev2_select_proposal(ikev2_sa_proposal_t *proposals, ikev2_protocol_id_t prot_id)
ikev2_generate_sa_error_t
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
ikev2_transforms_set esp_ts
#define VLIB_NODE_FLAG_TRACE
void ikev2_crypto_init(ikev2_main_t *km)
static void ikev2_del_tunnel_from_main(ikev2_del_ipsec_tunnel_args_t *a)
#define CLIB_CACHE_LINE_BYTES
u8 * ip_addr_bytes(ip_address_t *ip)
void ikev2_payload_add_ts(ikev2_payload_chain_t *c, ikev2_ts_t *ts, u8 type)
clib_error_t * ikev2_set_profile_ts(vlib_main_t *vm, u8 *name, u8 protocol_id, u16 start_port, u16 end_port, ip_address_t start_addr, ip_address_t end_addr, int is_local)
static void ikev2_sa_free_all_vec(ikev2_sa_t *sa)
__clib_export u8 * format_clib_error(u8 *s, va_list *va)
static void ikev2_send_informational_request(ikev2_sa_t *sa)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
#define IPSEC_UDP_PORT_NONE
static void ikev2_delete_sa(ikev2_main_per_thread_data_t *ptd, ikev2_sa_t *sa)
static u16 ip4_header_checksum(ip4_header_t *i)
__clib_export uword mhash_set_mem(mhash_t *h, void *key, uword *new_value, uword *old_value)
u8 * ikev2_calc_sign(EVP_PKEY *pkey, u8 *data)
v8 * ikev2_calc_integr(ikev2_sa_transform_t *tr, v8 *key, u8 *data, int len)
vl_api_interface_index_t sw_if_index
u8 * ikev2_find_ike_notify_payload(ike_header_t *ike, u32 msg_type)
u8 * format_ikev2_id_type(u8 *s, va_list *args)
#define foreach_ikev2_error
void ikev2_disable_dpd(void)
static void ikev2_init_sa(vlib_main_t *vm, ikev2_sa_t *sa)
#define IKEV2_GCM_IV_SIZE
static int ikev2_process_auth_req(vlib_main_t *vm, ikev2_sa_t *sa, ike_header_t *ike, u32 len)
int ipsec_tun_protect_update(u32 sw_if_index, const ip_address_t *nh, u32 sa_out, u32 *sas_in)
void ikev2_payload_add_notify_2(ikev2_payload_chain_t *c, u16 msg_type, u8 *data, ikev2_notify_t *notify)