X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fnat%2Fnat_api.c;h=4727826049bf96b9425b55d47412b6c1200f2c3b;hb=82b4ceb8e66020f41fd6faf9765614f9dc5a3163;hp=e642eddb95aa879d967b048eebe5aba712931d48;hpb=5d64c7868f67749a6c99eb4ee5998b518ab6c71c;p=vpp.git diff --git a/src/plugins/nat/nat_api.c b/src/plugins/nat/nat_api.c index e642eddb95a..4727826049b 100644 --- a/src/plugins/nat/nat_api.c +++ b/src/plugins/nat/nat_api.c @@ -980,7 +980,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); @@ -1027,7 +1027,7 @@ send_nat44_static_mapping_details (snat_static_mapping_t * m, 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 +1037,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); @@ -1100,9 +1100,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 +1108,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 +1160,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,17 +1181,17 @@ 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; @@ -1203,11 +1201,11 @@ send_nat44_identity_mapping_details (snat_static_mapping_t * m, 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 (m->locals[index].vrf_id); rmp->protocol = snat_proto_to_ip_proto (m->proto); rmp->context = context; if (m->tag) @@ -1260,16 +1258,18 @@ 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)) + { + for (j = 0; j < vec_len (m->locals); j++) + 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); } } @@ -1656,7 +1656,7 @@ 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)); @@ -1692,7 +1692,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* */