X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fnat%2Fnat_api.c;h=516b27fb6f5ba8f7d88d2436714909e55584c41a;hb=34931eb47;hp=4c532ed7e2bb15d28be6bcfe2a4f431626c6b0c6;hpb=bb4e022502dd7f76d4f1cd705a7bac628d8c098c;p=vpp.git diff --git a/src/plugins/nat/nat_api.c b/src/plugins/nat/nat_api.c index 4c532ed7e2b..516b27fb6f5 100644 --- a/src/plugins/nat/nat_api.c +++ b/src/plugins/nat/nat_api.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -202,11 +203,11 @@ send_nat_worker_details (u32 worker_index, vl_api_registration_t * reg, vlib_worker_threads + worker_index + sm->first_worker_index; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT_WORKER_DETAILS + sm->msg_id_base); rmp->context = context; rmp->worker_index = htonl (worker_index); - rmp->lcore_id = htonl (w->lcore_id); + rmp->lcore_id = htonl (w->cpu_id); strncpy ((char *) rmp->name, (char *) w->name, ARRAY_LEN (rmp->name) - 1); vl_api_send_msg (reg, (u8 *) rmp); @@ -350,7 +351,7 @@ nat_ip4_reass_walk_api (nat_reass_ip4_t * reass, void *arg) nat_api_walk_ctx_t *ctx = arg; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT_REASS_DETAILS + sm->msg_id_base); rmp->context = ctx->context; clib_memcpy (rmp->src_addr, &(reass->key.src), 4); @@ -373,7 +374,7 @@ nat_ip6_reass_walk_api (nat_reass_ip6_t * reass, void *arg) nat_api_walk_ctx_t *ctx = arg; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT_REASS_DETAILS + sm->msg_id_base); rmp->context = ctx->context; clib_memcpy (rmp->src_addr, &(reass->key.src), 16); @@ -630,6 +631,203 @@ vl_api_nat_get_mss_clamping_t_print (vl_api_nat_get_mss_clamping_t * mp, FINISH; } +static void +vl_api_nat_ha_set_listener_t_handler (vl_api_nat_ha_set_listener_t * mp) +{ + snat_main_t *sm = &snat_main; + vl_api_nat_ha_set_listener_reply_t *rmp; + ip4_address_t addr; + int rv; + + memcpy (&addr, &mp->ip_address, sizeof (addr)); + rv = + nat_ha_set_listener (&addr, clib_net_to_host_u16 (mp->port), + clib_net_to_host_u32 (mp->path_mtu)); + + REPLY_MACRO (VL_API_NAT_HA_SET_LISTENER_REPLY); +} + +static void * +vl_api_nat_ha_set_listener_t_print (vl_api_nat_ha_set_listener_t * mp, + void *handle) +{ + u8 *s; + + s = format (0, "SCRIPT: nat_ha_set_listener "); + s = format (s, "ip_address %U ", format_ip4_address, mp->ip_address); + s = format (s, "port %d ", clib_net_to_host_u16 (mp->port)); + s = format (s, "path_mtu %d", clib_net_to_host_u32 (mp->path_mtu)); + + FINISH; +} + +static void +vl_api_nat_ha_get_listener_t_handler (vl_api_nat_ha_get_listener_t * mp) +{ + snat_main_t *sm = &snat_main; + vl_api_nat_ha_get_listener_reply_t *rmp; + int rv = 0; + ip4_address_t addr; + u16 port; + u32 path_mtu; + + nat_ha_get_listener (&addr, &port, &path_mtu); + + /* *INDENT-OFF* */ + REPLY_MACRO2 (VL_API_NAT_HA_GET_LISTENER_REPLY, + ({ + clib_memcpy (rmp->ip_address, &addr, sizeof (ip4_address_t)); + rmp->port = clib_host_to_net_u16 (port); + rmp->path_mtu = clib_host_to_net_u32 (path_mtu); + })) + /* *INDENT-ON* */ +} + +static void * +vl_api_nat_ha_get_listener_t_print (vl_api_nat_ha_get_listener_t * mp, + void *handle) +{ + u8 *s; + + s = format (0, "SCRIPT: nat_ha_get_listener"); + + FINISH; +} + +static void +vl_api_nat_ha_set_failover_t_handler (vl_api_nat_ha_set_failover_t * mp) +{ + snat_main_t *sm = &snat_main; + vl_api_nat_ha_set_failover_reply_t *rmp; + ip4_address_t addr; + int rv; + + memcpy (&addr, &mp->ip_address, sizeof (addr)); + rv = + nat_ha_set_failover (&addr, clib_net_to_host_u16 (mp->port), + clib_net_to_host_u32 (mp->session_refresh_interval)); + + REPLY_MACRO (VL_API_NAT_HA_SET_FAILOVER_REPLY); +} + +static void * +vl_api_nat_ha_set_failover_t_print (vl_api_nat_ha_set_failover_t * mp, + void *handle) +{ + u8 *s; + + s = format (0, "SCRIPT: nat_ha_set_failover "); + s = format (s, "ip_address %U ", format_ip4_address, mp->ip_address); + s = format (s, "port %d ", clib_net_to_host_u16 (mp->port)); + + FINISH; +} + +static void +vl_api_nat_ha_get_failover_t_handler (vl_api_nat_ha_get_failover_t * mp) +{ + snat_main_t *sm = &snat_main; + vl_api_nat_ha_get_failover_reply_t *rmp; + int rv = 0; + ip4_address_t addr; + u16 port; + u32 session_refresh_interval; + + nat_ha_get_failover (&addr, &port, &session_refresh_interval); + + /* *INDENT-OFF* */ + REPLY_MACRO2 (VL_API_NAT_HA_GET_FAILOVER_REPLY, + ({ + clib_memcpy (rmp->ip_address, &addr, sizeof (ip4_address_t)); + rmp->port = clib_host_to_net_u16 (port); + rmp->session_refresh_interval = clib_host_to_net_u32 (session_refresh_interval); + })) + /* *INDENT-ON* */ +} + +static void * +vl_api_nat_ha_get_failover_t_print (vl_api_nat_ha_get_failover_t * mp, + void *handle) +{ + u8 *s; + + s = format (0, "SCRIPT: nat_ha_get_failover"); + + FINISH; +} + +static void +vl_api_nat_ha_flush_t_handler (vl_api_nat_ha_flush_t * mp) +{ + snat_main_t *sm = &snat_main; + vl_api_nat_ha_flush_reply_t *rmp; + int rv = 0; + + nat_ha_flush (0); + + REPLY_MACRO (VL_API_NAT_HA_FLUSH_REPLY); +} + +static void * +vl_api_nat_ha_flush_t_print (vl_api_nat_ha_flush_t * mp, void *handle) +{ + u8 *s; + + s = format (0, "SCRIPT: nat_ha_flush "); + + FINISH; +} + +static void +nat_ha_resync_completed_event_cb (u32 client_index, u32 pid, u32 missed_count) +{ + snat_main_t *sm = &snat_main; + vl_api_registration_t *reg; + vl_api_nat_ha_resync_completed_event_t *mp; + + reg = vl_api_client_index_to_registration (client_index); + if (!reg) + return; + + mp = vl_msg_api_alloc (sizeof (*mp)); + clib_memset (mp, 0, sizeof (*mp)); + mp->client_index = client_index; + mp->pid = pid; + mp->missed_count = clib_host_to_net_u32 (missed_count); + mp->_vl_msg_id = + ntohs (VL_API_NAT_HA_RESYNC_COMPLETED_EVENT + sm->msg_id_base); + + vl_api_send_msg (reg, (u8 *) mp); +} + +static void +vl_api_nat_ha_resync_t_handler (vl_api_nat_ha_resync_t * mp) +{ + snat_main_t *sm = &snat_main; + vl_api_nat_ha_resync_reply_t *rmp; + int rv; + + rv = + nat_ha_resync (mp->client_index, mp->pid, + mp->want_resync_event ? nat_ha_resync_completed_event_cb : + NULL); + + REPLY_MACRO (VL_API_NAT_HA_RESYNC_REPLY); +} + +static void * +vl_api_nat_ha_resync_t_print (vl_api_nat_ha_resync_t * mp, void *handle) +{ + u8 *s; + + s = format (0, "SCRIPT: nat_ha_resync "); + s = + format (s, "want_resync_event %d pid %d", mp->want_resync_event, + clib_host_to_net_u32 (mp->pid)); + + FINISH; +} + /*************/ /*** NAT44 ***/ /*************/ @@ -718,7 +916,7 @@ send_nat44_address_details (snat_address_t * a, snat_main_t *sm = &snat_main; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT44_ADDRESS_DETAILS + sm->msg_id_base); clib_memcpy (rmp->ip_address, &(a->addr), 4); if (a->fib_index != ~0) @@ -807,7 +1005,7 @@ send_nat44_interface_details (snat_interface_t * i, snat_main_t *sm = &snat_main; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT44_INTERFACE_DETAILS + sm->msg_id_base); rmp->sw_if_index = ntohl (i->sw_if_index); rmp->is_inside = (nat_interface_is_inside (i) @@ -896,7 +1094,7 @@ send_nat44_interface_output_feature_details (snat_interface_t * i, snat_main_t *sm = &snat_main; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT44_INTERFACE_OUTPUT_FEATURE_DETAILS + sm->msg_id_base); rmp->sw_if_index = ntohl (i->sw_if_index); @@ -980,7 +1178,7 @@ static void rv = snat_add_static_mapping (local_addr, external_addr, local_port, external_port, vrf_id, mp->addr_only, external_sw_if_index, proto, mp->is_add, - twice_nat, mp->out2in_only, tag); + twice_nat, mp->out2in_only, tag, 0); vec_free (tag); @@ -1024,10 +1222,10 @@ send_nat44_static_mapping_details (snat_static_mapping_t * m, snat_main_t *sm = &snat_main; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT44_STATIC_MAPPING_DETAILS + sm->msg_id_base); - rmp->addr_only = m->addr_only; + rmp->addr_only = is_addr_only_static_mapping (m); clib_memcpy (rmp->local_ip_address, &(m->local_addr), 4); clib_memcpy (rmp->external_ip_address, &(m->external_addr), 4); rmp->external_sw_if_index = ~0; @@ -1037,8 +1235,8 @@ send_nat44_static_mapping_details (snat_static_mapping_t * m, rmp->twice_nat = 1; else if (m->twice_nat == TWICE_NAT_SELF) rmp->self_twice_nat = 1; - rmp->out2in_only = m->out2in_only; - if (m->addr_only == 0) + rmp->out2in_only = is_out2in_only_static_mapping (m); + if (rmp->addr_only == 0) { rmp->protocol = snat_proto_to_ip_proto (m->proto); rmp->external_port = htons (m->external_port); @@ -1059,7 +1257,7 @@ send_nat44_static_map_resolve_details (snat_static_map_resolve_t * m, snat_main_t *sm = &snat_main; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT44_STATIC_MAPPING_DETAILS + sm->msg_id_base); rmp->addr_only = m->addr_only; @@ -1100,9 +1298,7 @@ vl_api_nat44_static_mapping_dump_t_handler (vl_api_nat44_static_mapping_dump_t /* *INDENT-OFF* */ pool_foreach (m, sm->static_mappings, ({ - if (!vec_len (m->locals) && - ((m->local_port != m->external_port) - || (m->local_addr.as_u32 != m->external_addr.as_u32))) + if (!is_identity_static_mapping(m) && !is_lb_static_mapping (m)) send_nat44_static_mapping_details (m, reg, mp->context); })); /* *INDENT-ON* */ @@ -1110,7 +1306,7 @@ vl_api_nat44_static_mapping_dump_t_handler (vl_api_nat44_static_mapping_dump_t for (j = 0; j < vec_len (sm->to_resolve); j++) { rp = sm->to_resolve + j; - if (rp->l_addr.as_u32 != 0) + if (!rp->identity_nat) send_nat44_static_map_resolve_details (rp, reg, mp->context); } } @@ -1162,7 +1358,7 @@ static void rv = snat_add_static_mapping (addr, addr, port, port, vrf_id, mp->addr_only, - sw_if_index, proto, mp->is_add, 0, 0, tag); + sw_if_index, proto, mp->is_add, 0, 0, tag, 1); vec_free (tag); @@ -1183,31 +1379,32 @@ static void *vl_api_nat44_add_del_identity_mapping_t_print if (mp->addr_only == 0) s = - format (s, "protocol %d port %d", mp->protocol, + format (s, " protocol %d port %d", mp->protocol, clib_net_to_host_u16 (mp->port)); if (mp->vrf_id != ~0) - s = format (s, "vrf %d", clib_net_to_host_u32 (mp->vrf_id)); + s = format (s, " vrf %d", clib_net_to_host_u32 (mp->vrf_id)); FINISH; } static void -send_nat44_identity_mapping_details (snat_static_mapping_t * m, +send_nat44_identity_mapping_details (snat_static_mapping_t * m, int index, vl_api_registration_t * reg, u32 context) { vl_api_nat44_identity_mapping_details_t *rmp; snat_main_t *sm = &snat_main; + nat44_lb_addr_port_t *local = pool_elt_at_index (m->locals, index); rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT44_IDENTITY_MAPPING_DETAILS + sm->msg_id_base); - rmp->addr_only = m->addr_only; + rmp->addr_only = is_addr_only_static_mapping (m); clib_memcpy (rmp->ip_address, &(m->local_addr), 4); rmp->port = htons (m->local_port); rmp->sw_if_index = ~0; - rmp->vrf_id = htonl (m->vrf_id); + rmp->vrf_id = htonl (local->vrf_id); rmp->protocol = snat_proto_to_ip_proto (m->proto); rmp->context = context; if (m->tag) @@ -1225,7 +1422,7 @@ send_nat44_identity_map_resolve_details (snat_static_map_resolve_t * m, snat_main_t *sm = &snat_main; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT44_IDENTITY_MAPPING_DETAILS + sm->msg_id_base); rmp->addr_only = m->addr_only; @@ -1260,16 +1457,20 @@ static void /* *INDENT-OFF* */ pool_foreach (m, sm->static_mappings, ({ - if (!vec_len (m->locals) && (m->local_port == m->external_port) - && (m->local_addr.as_u32 == m->external_addr.as_u32)) - send_nat44_identity_mapping_details (m, reg, mp->context); + if (is_identity_static_mapping(m) && !is_lb_static_mapping (m)) + { + pool_foreach_index (j, m->locals, + ({ + send_nat44_identity_mapping_details (m, j, reg, mp->context); + })); + } })); /* *INDENT-ON* */ for (j = 0; j < vec_len (sm->to_resolve); j++) { rp = sm->to_resolve + j; - if (rp->l_addr.as_u32 == 0) + if (rp->identity_nat) send_nat44_identity_map_resolve_details (rp, reg, mp->context); } } @@ -1331,7 +1532,7 @@ send_nat44_interface_addr_details (u32 sw_if_index, snat_main_t *sm = &snat_main; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT44_INTERFACE_ADDR_DETAILS + sm->msg_id_base); rmp->sw_if_index = ntohl (sw_if_index); @@ -1384,7 +1585,7 @@ send_nat44_user_details (snat_user_t * u, vl_api_registration_t * reg, ip4_main_t *im = &ip4_main; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT44_USER_DETAILS + sm->msg_id_base); if (!pool_is_free_index (im->fibs, u->fib_index)) @@ -1445,7 +1646,7 @@ send_nat44_user_session_details (snat_session_t * s, snat_main_t *sm = &snat_main; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT44_USER_SESSION_DETAILS + sm->msg_id_base); clib_memcpy (rmp->outside_ip_address, (&s->out2in.addr), 4); @@ -1555,7 +1756,7 @@ vl_api_nat44_user_session_dump_t_print (vl_api_nat44_user_session_dump_t * mp, static nat44_lb_addr_port_t * unformat_nat44_lb_addr_port (vl_api_nat44_lb_addr_port_t * addr_port_pairs, - u8 addr_port_pair_num) + u32 addr_port_pair_num) { u8 i; nat44_lb_addr_port_t *lb_addr_port_pairs = 0, lb_addr_port; @@ -1564,7 +1765,7 @@ unformat_nat44_lb_addr_port (vl_api_nat44_lb_addr_port_t * addr_port_pairs, for (i = 0; i < addr_port_pair_num; i++) { ap = &addr_port_pairs[i]; - memset (&lb_addr_port, 0, sizeof (lb_addr_port)); + clib_memset (&lb_addr_port, 0, sizeof (lb_addr_port)); clib_memcpy (&lb_addr_port.addr, ap->addr, 4); lb_addr_port.port = clib_net_to_host_u16 (ap->port); lb_addr_port.probability = ap->probability; @@ -1594,7 +1795,9 @@ static void goto send_reply; } - locals = unformat_nat44_lb_addr_port (mp->locals, mp->local_num); + locals = + unformat_nat44_lb_addr_port (mp->locals, + clib_net_to_host_u32 (mp->local_num)); clib_memcpy (&e_addr, mp->external_addr, 4); proto = ip_proto_to_snat_proto (mp->protocol); if (mp->twice_nat) @@ -1631,6 +1834,52 @@ static void *vl_api_nat44_add_del_lb_static_mapping_t_print FINISH; } +static void + vl_api_nat44_lb_static_mapping_add_del_local_t_handler + (vl_api_nat44_lb_static_mapping_add_del_local_t * mp) +{ + snat_main_t *sm = &snat_main; + vl_api_nat44_lb_static_mapping_add_del_local_reply_t *rmp; + int rv = 0; + ip4_address_t e_addr, l_addr; + snat_protocol_t proto; + + if (!sm->endpoint_dependent) + { + rv = VNET_API_ERROR_UNSUPPORTED; + goto send_reply; + } + + clib_memcpy (&e_addr, mp->external_addr, 4); + clib_memcpy (&l_addr, mp->local.addr, 4); + proto = ip_proto_to_snat_proto (mp->protocol); + + rv = + nat44_lb_static_mapping_add_del_local (e_addr, + clib_net_to_host_u16 + (mp->external_port), l_addr, + clib_net_to_host_u16 (mp-> + local.port), + proto, + clib_net_to_host_u32 (mp-> + local.vrf_id), + mp->local.probability, mp->is_add); + +send_reply: + REPLY_MACRO (VL_API_NAT44_LB_STATIC_MAPPING_ADD_DEL_LOCAL_REPLY); +} + +static void *vl_api_nat44_lb_static_mapping_add_del_local_t_print + (vl_api_nat44_lb_static_mapping_add_del_local_t * mp, void *handle) +{ + u8 *s; + + s = format (0, "SCRIPT: nat44_lb_static_mapping_add_del_local "); + s = format (s, "is_add %d", mp->is_add); + + FINISH; +} + static void send_nat44_lb_static_mapping_details (snat_static_mapping_t * m, vl_api_registration_t * reg, @@ -1640,11 +1889,13 @@ send_nat44_lb_static_mapping_details (snat_static_mapping_t * m, snat_main_t *sm = &snat_main; nat44_lb_addr_port_t *ap; vl_api_nat44_lb_addr_port_t *locals; + u32 local_num = 0; rmp = vl_msg_api_alloc (sizeof (*rmp) + - (vec_len (m->locals) * sizeof (nat44_lb_addr_port_t))); - memset (rmp, 0, sizeof (*rmp)); + (pool_elts (m->locals) * + sizeof (nat44_lb_addr_port_t))); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT44_LB_STATIC_MAPPING_DETAILS + sm->msg_id_base); @@ -1656,20 +1907,23 @@ send_nat44_lb_static_mapping_details (snat_static_mapping_t * m, rmp->twice_nat = 1; else if (m->twice_nat == TWICE_NAT_SELF) rmp->self_twice_nat = 1; - rmp->out2in_only = m->out2in_only; + rmp->out2in_only = is_out2in_only_static_mapping (m); if (m->tag) strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag)); locals = (vl_api_nat44_lb_addr_port_t *) rmp->locals; - vec_foreach (ap, m->locals) - { + /* *INDENT-OFF* */ + pool_foreach (ap, m->locals, + ({ clib_memcpy (locals->addr, &(ap->addr), 4); locals->port = htons (ap->port); locals->probability = ap->probability; locals->vrf_id = ntohl (ap->vrf_id); locals++; - rmp->local_num++; - } + local_num++; + })); + /* *INDENT-ON* */ + rmp->local_num = ntohl (local_num); vl_api_send_msg (reg, (u8 *) rmp); } @@ -1692,7 +1946,7 @@ static void /* *INDENT-OFF* */ pool_foreach (m, sm->static_mappings, ({ - if (vec_len(m->locals)) + if (is_lb_static_mapping(m)) send_nat44_lb_static_mapping_details (m, reg, mp->context); })); /* *INDENT-ON* */ @@ -1790,7 +2044,7 @@ static void vec_foreach (ses_index, ses_to_be_removed) { s = pool_elt_at_index(tsm->sessions, ses_index[0]); - nat_free_session_data (sm, s, tsm - sm->per_thread_data); + nat_free_session_data (sm, s, tsm - sm->per_thread_data, 0); nat44_delete_session (sm, s, tsm - sm->per_thread_data); } vec_free (ses_to_be_removed); @@ -1825,7 +2079,7 @@ static void return; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT44_FORWARDING_IS_ENABLED_REPLY + sm->msg_id_base); rmp->context = mp->context; @@ -1982,7 +2236,7 @@ send_reply: REPLY_MACRO2 (VL_API_NAT_DET_REVERSE_REPLY, ({ rmp->is_nat44 = 1; - memset (rmp->in_addr, 0, 16); + clib_memset (rmp->in_addr, 0, 16); clib_memcpy (rmp->in_addr, &in_addr, 4); })) /* *INDENT-ON* */ @@ -2008,7 +2262,7 @@ sent_nat_det_map_details (snat_det_map_t * m, vl_api_registration_t * reg, snat_main_t *sm = &snat_main; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT_DET_MAP_DETAILS + sm->msg_id_base); rmp->is_nat44 = 1; clib_memcpy (rmp->in_addr, &m->in_addr, 4); @@ -2179,7 +2433,7 @@ send_nat_det_session_details (snat_det_session_t * s, snat_main_t *sm = &snat_main; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT_DET_SESSION_DETAILS + sm->msg_id_base); rmp->in_port = s->in_port; clib_memcpy (rmp->ext_addr, &s->out.ext_host_addr, 4); @@ -2211,7 +2465,7 @@ vl_api_nat_det_session_dump_t_handler (vl_api_nat_det_session_dump_t * mp) if (!mp->is_nat44) return; - memset (&empty_ses, 0, sizeof (empty_ses)); + clib_memset (&empty_ses, 0, sizeof (empty_ses)); clib_memcpy (&user_addr, mp->user_addr, 4); dm = snat_det_map_by_user (sm, &user_addr); if (!dm) @@ -2268,7 +2522,7 @@ static void for (i = 0; i < count; i++) { - if ((rv = nat64_add_del_pool_addr (&this_addr, vrf_id, mp->is_add))) + if ((rv = nat64_add_del_pool_addr (0, &this_addr, vrf_id, mp->is_add))) goto send_reply; increment_v4_address (&this_addr); @@ -2307,7 +2561,7 @@ nat64_api_pool_walk (snat_address_t * a, void *arg) nat64_api_walk_ctx_t *ctx = arg; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT64_POOL_ADDR_DETAILS + sm->msg_id_base); clib_memcpy (rmp->address, &(a->addr), 4); if (a->fib_index != ~0) @@ -2395,7 +2649,7 @@ nat64_api_interface_walk (snat_interface_t * i, void *arg) nat64_api_walk_ctx_t *ctx = arg; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT64_INTERFACE_DETAILS + sm->msg_id_base); rmp->sw_if_index = ntohl (i->sw_if_index); rmp->is_inside = (nat_interface_is_inside (i) @@ -2489,7 +2743,7 @@ nat64_api_bib_walk (nat64_db_bib_entry_t * bibe, void *arg) return -1; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT64_BIB_DETAILS + sm->msg_id_base); rmp->context = ctx->context; clib_memcpy (rmp->i_addr, &(bibe->in_addr), 16); @@ -2556,7 +2810,7 @@ nat64_api_st_walk (nat64_db_st_entry_t * ste, void *arg) return -1; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT64_ST_DETAILS + sm->msg_id_base); rmp->context = ctx->context; clib_memcpy (rmp->il_addr, &(bibe->in_addr), 16); @@ -2646,7 +2900,7 @@ nat64_api_prefix_walk (nat64_prefix_t * p, void *arg) nat64_api_walk_ctx_t *ctx = arg; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT64_PREFIX_DETAILS + sm->msg_id_base); clib_memcpy (rmp->prefix, &(p->prefix), 16); rmp->prefix_len = p->plen; @@ -2826,7 +3080,7 @@ vl_api_dslite_get_b4_addr_t_handler (vl_api_dslite_get_b4_addr_t * mp) int rv = 0; /* *INDENT-OFF* */ - REPLY_MACRO2 (VL_API_DSLITE_GET_AFTR_ADDR_REPLY, + REPLY_MACRO2 (VL_API_DSLITE_GET_B4_ADDR_REPLY, ({ memcpy (rmp->ip4_addr, &dm->b4_ip4_addr.as_u8, 4); memcpy (rmp->ip6_addr, &dm->b4_ip6_addr.as_u8, 16); @@ -2887,7 +3141,7 @@ send_dslite_address_details (snat_address_t * ap, rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_DSLITE_ADDRESS_DETAILS + sm->msg_id_base); clib_memcpy (rmp->ip_address, &(ap->addr), 4); @@ -3025,7 +3279,7 @@ nat66_api_interface_walk (snat_interface_t * i, void *arg) nat66_api_walk_ctx_t *ctx = arg; rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT66_INTERFACE_DETAILS + sm->msg_id_base); rmp->sw_if_index = ntohl (i->sw_if_index); rmp->is_inside = nat_interface_is_inside (i); @@ -3081,7 +3335,7 @@ nat66_api_static_mapping_walk (nat66_static_mapping_t * m, void *arg) vlib_get_combined_counter (&nm->session_counters, m - nm->sm, &vc); rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); + clib_memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_NAT66_STATIC_MAPPING_DETAILS + sm->msg_id_base); clib_memcpy (rmp->local_ip_address, &m->l_addr, 16); @@ -3142,6 +3396,12 @@ _(NAT_SET_ADDR_AND_PORT_ALLOC_ALG, nat_set_addr_and_port_alloc_alg) \ _(NAT_GET_ADDR_AND_PORT_ALLOC_ALG, nat_get_addr_and_port_alloc_alg) \ _(NAT_SET_MSS_CLAMPING, nat_set_mss_clamping) \ _(NAT_GET_MSS_CLAMPING, nat_get_mss_clamping) \ +_(NAT_HA_SET_LISTENER, nat_ha_set_listener) \ +_(NAT_HA_SET_FAILOVER, nat_ha_set_failover) \ +_(NAT_HA_GET_LISTENER, nat_ha_get_listener) \ +_(NAT_HA_GET_FAILOVER, nat_ha_get_failover) \ +_(NAT_HA_FLUSH, nat_ha_flush) \ +_(NAT_HA_RESYNC, nat_ha_resync) \ _(NAT44_ADD_DEL_ADDRESS_RANGE, nat44_add_del_address_range) \ _(NAT44_INTERFACE_ADD_DEL_FEATURE, nat44_interface_add_del_feature) \ _(NAT44_ADD_DEL_STATIC_MAPPING, nat44_add_del_static_mapping) \ @@ -3159,6 +3419,8 @@ _(NAT44_INTERFACE_ADD_DEL_OUTPUT_FEATURE, \ _(NAT44_INTERFACE_OUTPUT_FEATURE_DUMP, \ nat44_interface_output_feature_dump) \ _(NAT44_ADD_DEL_LB_STATIC_MAPPING, nat44_add_del_lb_static_mapping) \ +_(NAT44_LB_STATIC_MAPPING_ADD_DEL_LOCAL, \ + nat44_lb_static_mapping_add_del_local) \ _(NAT44_LB_STATIC_MAPPING_DUMP, nat44_lb_static_mapping_dump) \ _(NAT44_DEL_SESSION, nat44_del_session) \ _(NAT44_FORWARDING_ENABLE_DISABLE, nat44_forwarding_enable_disable) \