diff options
author | Damjan Marion <damarion@cisco.com> | 2020-12-13 21:47:40 +0100 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2020-12-14 12:14:21 +0000 |
commit | b2c31b685fd2cf28436ca32bc93e23eb24c74878 (patch) | |
tree | dc0a1b1ff784445b2cbb0f9b2c07b5bcb4f5a5d0 /src/plugins/nat | |
parent | 62c25abaa3e93be5815172d391295a6ab0390122 (diff) |
misc: move to new pool_foreach macros
Type: refactor
Change-Id: Ie67dc579e88132ddb1ee4a34cb69f96920101772
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins/nat')
-rw-r--r-- | src/plugins/nat/det44/det44.c | 28 | ||||
-rw-r--r-- | src/plugins/nat/det44/det44.h | 12 | ||||
-rw-r--r-- | src/plugins/nat/det44/det44_api.c | 6 | ||||
-rw-r--r-- | src/plugins/nat/det44/det44_cli.c | 18 | ||||
-rw-r--r-- | src/plugins/nat/det44/det44_inlines.h | 4 | ||||
-rw-r--r-- | src/plugins/nat/dslite/dslite_cli.c | 6 | ||||
-rw-r--r-- | src/plugins/nat/in2out.c | 6 | ||||
-rw-r--r-- | src/plugins/nat/in2out_ed.c | 10 | ||||
-rw-r--r-- | src/plugins/nat/nat.c | 154 | ||||
-rw-r--r-- | src/plugins/nat/nat44_api.c | 60 | ||||
-rw-r--r-- | src/plugins/nat/nat44_cli.c | 42 | ||||
-rw-r--r-- | src/plugins/nat/nat44_hairpinning.c | 6 | ||||
-rw-r--r-- | src/plugins/nat/nat64/nat64.c | 36 | ||||
-rw-r--r-- | src/plugins/nat/nat64/nat64_db.c | 54 | ||||
-rw-r--r-- | src/plugins/nat/nat66/nat66.c | 18 | ||||
-rw-r--r-- | src/plugins/nat/nat66/nat66_in2out.c | 6 | ||||
-rw-r--r-- | src/plugins/nat/nat_format.c | 12 | ||||
-rw-r--r-- | src/plugins/nat/nat_inlines.h | 4 |
18 files changed, 241 insertions, 241 deletions
diff --git a/src/plugins/nat/det44/det44.c b/src/plugins/nat/det44/det44.c index 582fd20cd5d..1dbbfdfdebe 100644 --- a/src/plugins/nat/det44/det44.c +++ b/src/plugins/nat/det44/det44.c @@ -151,12 +151,12 @@ snat_det_add_map (ip4_address_t * in_addr, u8 in_plen, /* Add/del external address range to FIB */ /* *INDENT-OFF* */ - pool_foreach (i, dm->interfaces, ({ + pool_foreach (i, dm->interfaces) { if (det44_interface_is_inside(i)) continue; det44_add_del_addr_to_fib(out_addr, out_plen, i->sw_if_index, is_add); goto out; - })); + } /* *INDENT-ON* */ out: return 0; @@ -204,13 +204,13 @@ det44_interface_add_del (u32 sw_if_index, u8 is_inside, int is_del) // then register nodes /* *INDENT-OFF* */ - pool_foreach (tmp, dm->interfaces, ({ + pool_foreach (tmp, dm->interfaces) { if (tmp->sw_if_index == sw_if_index) { i = tmp; goto out; } - })); + } /* *INDENT-ON* */ out: @@ -302,10 +302,10 @@ out: // add/del outside address to FIB snat_det_map_t *mp; /* *INDENT-OFF* */ - pool_foreach (mp, dm->det_maps, ({ + pool_foreach (mp, dm->det_maps) { det44_add_del_addr_to_fib(&mp->out_addr, mp->out_plen, sw_if_index, !is_del); - })); + } /* *INDENT-ON* */ } return 0; @@ -328,14 +328,14 @@ det44_expire_walk_fn (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_process_get_events (vm, NULL); u32 now = (u32) vlib_time_now (vm); /* *INDENT-OFF* */ - pool_foreach (mp, dm->det_maps, ({ + pool_foreach (mp, dm->det_maps) { vec_foreach(ses, mp->sessions) { /* Delete if session expired */ if (ses->in_port && (ses->expire < now)) snat_det_ses_close (mp, ses); } - })); + } /* *INDENT-ON* */ return 0; } @@ -429,10 +429,10 @@ det44_plugin_disable () vec_free (interfaces); /* *INDENT-OFF* */ - pool_foreach (mp, dm->det_maps, - ({ + pool_foreach (mp, dm->det_maps) + { vec_free (mp->sessions); - })); + } /* *INDENT-ON* */ det44_reset_timeouts (); @@ -468,15 +468,15 @@ det44_update_outside_fib (ip4_main_t * im, return; /* *INDENT-OFF* */ - pool_foreach (i, dm->interfaces, - ({ + pool_foreach (i, dm->interfaces) + { if (i->sw_if_index == sw_if_index) { if (!(det44_interface_is_outside (i))) return; match = 1; } - })); + } /* *INDENT-ON* */ if (!match) diff --git a/src/plugins/nat/det44/det44.h b/src/plugins/nat/det44/det44.h index 84d570bfd56..02b0fa7e81d 100644 --- a/src/plugins/nat/det44/det44.h +++ b/src/plugins/nat/det44/det44.h @@ -279,11 +279,11 @@ snat_det_map_by_user (ip4_address_t * user_addr) det44_main_t *dm = &det44_main; snat_det_map_t *mp; /* *INDENT-OFF* */ - pool_foreach (mp, dm->det_maps, - ({ + pool_foreach (mp, dm->det_maps) + { if (is_addr_in_net(user_addr, &mp->in_addr, mp->in_plen)) return mp; - })); + } /* *INDENT-ON* */ return 0; } @@ -294,11 +294,11 @@ snat_det_map_by_out (ip4_address_t * out_addr) det44_main_t *dm = &det44_main; snat_det_map_t *mp; /* *INDENT-OFF* */ - pool_foreach (mp, dm->det_maps, - ({ + pool_foreach (mp, dm->det_maps) + { if (is_addr_in_net(out_addr, &mp->out_addr, mp->out_plen)) return mp; - })); + } /* *INDENT-ON* */ return 0; } diff --git a/src/plugins/nat/det44/det44_api.c b/src/plugins/nat/det44/det44_api.c index 7c7b1788009..1486180aa99 100644 --- a/src/plugins/nat/det44/det44_api.c +++ b/src/plugins/nat/det44/det44_api.c @@ -329,10 +329,10 @@ vl_api_det44_interface_dump_t_handler (vl_api_det44_interface_dump_t * mp) return; /* *INDENT-OFF* */ - pool_foreach (i, dm->interfaces, - ({ + pool_foreach (i, dm->interfaces) + { det44_send_interface_details(i, reg, mp->context); - })); + } /* *INDENT-ON* */ } diff --git a/src/plugins/nat/det44/det44_cli.c b/src/plugins/nat/det44/det44_cli.c index 933784f17c6..28569c7b82d 100644 --- a/src/plugins/nat/det44/det44_cli.c +++ b/src/plugins/nat/det44/det44_cli.c @@ -75,8 +75,8 @@ det44_show_mappings_command_fn (vlib_main_t * vm, snat_det_map_t *mp; vlib_cli_output (vm, "NAT44 deterministic mappings:"); /* *INDENT-OFF* */ - pool_foreach (mp, dm->det_maps, - ({ + pool_foreach (mp, dm->det_maps) + { vlib_cli_output (vm, " in %U/%d out %U/%d\n", format_ip4_address, &mp->in_addr, mp->in_plen, format_ip4_address, &mp->out_addr, mp->out_plen); @@ -85,7 +85,7 @@ det44_show_mappings_command_fn (vlib_main_t * vm, vlib_cli_output (vm, " number of ports per inside host: %d\n", mp->ports_per_host); vlib_cli_output (vm, " sessions number: %d\n", mp->ses_num); - })); + } /* *INDENT-ON* */ return 0; } @@ -188,8 +188,8 @@ det44_show_sessions_command_fn (vlib_main_t * vm, snat_det_map_t *mp; vlib_cli_output (vm, "NAT44 deterministic sessions:"); /* *INDENT-OFF* */ - pool_foreach (mp, dm->det_maps, - ({ + pool_foreach (mp, dm->det_maps) + { int i; vec_foreach_index (i, mp->sessions) { @@ -197,7 +197,7 @@ det44_show_sessions_command_fn (vlib_main_t * vm, if (ses->in_port) vlib_cli_output (vm, " %U", format_det_map_ses, mp, ses, &i); } - })); + } /* *INDENT-ON* */ return 0; } @@ -487,14 +487,14 @@ det44_show_interfaces_command_fn (vlib_main_t * vm, unformat_input_t * input, det44_interface_t *i; vlib_cli_output (vm, "DET44 interfaces:"); /* *INDENT-OFF* */ - pool_foreach (i, dm->interfaces, - ({ + pool_foreach (i, dm->interfaces) + { vlib_cli_output (vm, " %U %s", format_vnet_sw_if_index_name, vnm, i->sw_if_index, (det44_interface_is_inside(i) && det44_interface_is_outside(i)) ? "in out" : (det44_interface_is_inside(i) ? "in" : "out")); - })); + } /* *INDENT-ON* */ return 0; } diff --git a/src/plugins/nat/det44/det44_inlines.h b/src/plugins/nat/det44/det44_inlines.h index e4be469562c..aeb55b385d3 100644 --- a/src/plugins/nat/det44/det44_inlines.h +++ b/src/plugins/nat/det44/det44_inlines.h @@ -108,11 +108,11 @@ det44_translate (vlib_node_runtime_t * node, u32 sw_if_index0, { det44_interface_t *i; /* *INDENT-OFF* */ - pool_foreach (i, dm->interfaces, ({ + pool_foreach (i, dm->interfaces) { /* NAT packet aimed at outside interface */ if ((det44_interface_is_outside (i)) && (sw_if_index == i->sw_if_index)) return 0; - })); + } /* *INDENT-ON* */ } } diff --git a/src/plugins/nat/dslite/dslite_cli.c b/src/plugins/nat/dslite/dslite_cli.c index 0819f95261a..25fcd01d523 100644 --- a/src/plugins/nat/dslite/dslite_cli.c +++ b/src/plugins/nat/dslite/dslite_cli.c @@ -287,10 +287,10 @@ dslite_show_sessions_command_fn (vlib_main_t * vm, /* *INDENT-OFF* */ vec_foreach (td, dm->per_thread_data) { - pool_foreach (b4, td->b4s, - ({ + pool_foreach (b4, td->b4s) + { vlib_cli_output (vm, "%U", format_dslite_b4, td, b4); - })); + } } /* *INDENT-ON* */ diff --git a/src/plugins/nat/in2out.c b/src/plugins/nat/in2out.c index 85df078dfd2..309329f12d9 100644 --- a/src/plugins/nat/in2out.c +++ b/src/plugins/nat/in2out.c @@ -171,11 +171,11 @@ nat_not_translate_output_feature (snat_main_t * sm, ip4_header_t * ip0, { /* hairpinning */ /* *INDENT-OFF* */ - pool_foreach (i, sm->output_feature_interfaces, - ({ + pool_foreach (i, sm->output_feature_interfaces) + { if ((nat_interface_is_inside(i)) && (sw_if_index == i->sw_if_index)) return 0; - })); + } /* *INDENT-ON* */ return 1; } diff --git a/src/plugins/nat/in2out_ed.c b/src/plugins/nat/in2out_ed.c index d9a45dc1398..776efdf1395 100644 --- a/src/plugins/nat/in2out_ed.c +++ b/src/plugins/nat/in2out_ed.c @@ -627,11 +627,11 @@ nat44_ed_not_translate_output_feature (snat_main_t * sm, ip4_header_t * ip, /* hairpinning */ /* *INDENT-OFF* */ - pool_foreach (i, sm->output_feature_interfaces, - ({ + pool_foreach (i, sm->output_feature_interfaces) + { if ((nat_interface_is_inside (i)) && (rx_sw_if_index == i->sw_if_index)) return 0; - })); + } /* *INDENT-ON* */ return 1; } @@ -826,7 +826,7 @@ nat44_ed_in2out_unknown_proto (snat_main_t * sm, else { /* *INDENT-OFF* */ - pool_foreach (s, tsm->sessions, { + pool_foreach (s, tsm->sessions) { if (s->ext_host_addr.as_u32 == ip->dst_address.as_u32) { new_addr = ip->src_address.as_u32 = s->out2in.addr.as_u32; @@ -837,7 +837,7 @@ nat44_ed_in2out_unknown_proto (snat_main_t * sm, break; } - }); + } /* *INDENT-ON* */ for (i = 0; i < vec_len (sm->addresses); i++) diff --git a/src/plugins/nat/nat.c b/src/plugins/nat/nat.c index 91f14d682f4..0694c348c12 100644 --- a/src/plugins/nat/nat.c +++ b/src/plugins/nat/nat.c @@ -730,22 +730,22 @@ snat_add_address (snat_main_t * sm, ip4_address_t * addr, u32 vrf_id, /* Add external address to FIB */ /* *INDENT-OFF* */ - pool_foreach (i, sm->interfaces, - ({ + pool_foreach (i, sm->interfaces) + { if (nat_interface_is_inside(i) || sm->out2in_dpo) continue; snat_add_del_addr_to_fib(addr, 32, i->sw_if_index, 1); break; - })); - pool_foreach (i, sm->output_feature_interfaces, - ({ + } + pool_foreach (i, sm->output_feature_interfaces) + { if (nat_interface_is_inside(i) || sm->out2in_dpo) continue; snat_add_del_addr_to_fib(addr, 32, i->sw_if_index, 1); break; - })); + } /* *INDENT-ON* */ return 0; @@ -756,15 +756,15 @@ is_snat_address_used_in_static_mapping (snat_main_t * sm, ip4_address_t addr) { snat_static_mapping_t *m; /* *INDENT-OFF* */ - pool_foreach (m, sm->static_mappings, - ({ + pool_foreach (m, sm->static_mappings) + { if (is_addr_only_static_mapping (m) || is_out2in_only_static_mapping (m) || is_identity_static_mapping (m)) continue; if (m->external_addr.as_u32 == addr.as_u32) return 1; - })); + } /* *INDENT-ON* */ return 0; @@ -882,7 +882,7 @@ nat_ed_static_mapping_del_sessions (snat_main_t * sm, snat_session_t *s; u32 *indexes_to_free = NULL; /* *INDENT-OFF* */ - pool_foreach (s, tsm->sessions, { + pool_foreach (s, tsm->sessions) { if (s->in2out.fib_index != fib_index || s->in2out.addr.as_u32 != l_addr.as_u32) { @@ -905,7 +905,7 @@ nat_ed_static_mapping_del_sessions (snat_main_t * sm, vec_add1 (indexes_to_free, s - tsm->sessions); if (!addr_only) break; - }); + } /* *INDENT-ON* */ u32 *ses_index; vec_foreach (ses_index, indexes_to_free) @@ -1031,11 +1031,11 @@ snat_add_static_mapping (ip4_address_t l_addr, ip4_address_t e_addr, if (is_identity_static_mapping (m)) { /* *INDENT-OFF* */ - pool_foreach (local, m->locals, - ({ + pool_foreach (local, m->locals) + { if (local->vrf_id == vrf_id) return VNET_API_ERROR_VALUE_EXIST; - })); + } /* *INDENT-ON* */ pool_get (m->locals, local); local->vrf_id = vrf_id; @@ -1246,11 +1246,11 @@ snat_add_static_mapping (ip4_address_t l_addr, ip4_address_t e_addr, vrf_id = sm->inside_vrf_id; /* *INDENT-OFF* */ - pool_foreach (local, m->locals, - ({ + pool_foreach (local, m->locals) + { if (local->vrf_id == vrf_id) find = local - m->locals; - })); + } /* *INDENT-ON* */ if (find == ~0) return VNET_API_ERROR_NO_SUCH_ENTRY; @@ -1340,22 +1340,22 @@ snat_add_static_mapping (ip4_address_t l_addr, ip4_address_t e_addr, /* Add/delete external address to FIB */ /* *INDENT-OFF* */ - pool_foreach (interface, sm->interfaces, - ({ + pool_foreach (interface, sm->interfaces) + { if (nat_interface_is_inside(interface) || sm->out2in_dpo) continue; snat_add_del_addr_to_fib(&e_addr, 32, interface->sw_if_index, is_add); break; - })); - pool_foreach (interface, sm->output_feature_interfaces, - ({ + } + pool_foreach (interface, sm->output_feature_interfaces) + { if (nat_interface_is_inside(interface) || sm->out2in_dpo) continue; snat_add_del_addr_to_fib(&e_addr, 32, interface->sw_if_index, is_add); break; - })); + } /* *INDENT-ON* */ return 0; @@ -1544,8 +1544,8 @@ nat44_add_del_lb_static_mapping (ip4_address_t e_addr, u16 e_port, } /* *INDENT-OFF* */ - pool_foreach (local, m->locals, - ({ + pool_foreach (local, m->locals) + { fib_table_unlock (local->fib_index, FIB_PROTOCOL_IP4, sm->fib_src_low); if (!out2in_only) @@ -1570,7 +1570,7 @@ init_nat_k(& kv, local->addr, local->port, local->fib_index, m->pro tsm = vec_elt_at_index (sm->per_thread_data, sm->num_workers); /* Delete sessions */ - pool_foreach (s, tsm->sessions, { + pool_foreach (s, tsm->sessions) { if (!(is_lb_session (s))) continue; @@ -1580,8 +1580,8 @@ init_nat_k(& kv, local->addr, local->port, local->fib_index, m->pro nat_free_session_data (sm, s, tsm - sm->per_thread_data, 0); nat_ed_session_delete (sm, s, tsm - sm->per_thread_data, 1); - }); - })); + } + } /* *INDENT-ON* */ if (m->affinity) nat_affinity_flush_service (m->affinity_per_service_list_head_index); @@ -1625,15 +1625,15 @@ nat44_lb_static_mapping_add_del_local (ip4_address_t e_addr, u16 e_port, return VNET_API_ERROR_INVALID_VALUE; /* *INDENT-OFF* */ - pool_foreach (local, m->locals, - ({ + pool_foreach (local, m->locals) + { if ((local->addr.as_u32 == l_addr.as_u32) && (local->port == l_port) && (local->vrf_id == vrf_id)) { match_local = local; break; } - })); + } /* *INDENT-ON* */ if (is_add) @@ -1691,7 +1691,7 @@ nat44_lb_static_mapping_add_del_local (ip4_address_t e_addr, u16 e_port, /* Delete sessions */ /* *INDENT-OFF* */ - pool_foreach (s, tsm->sessions, { + pool_foreach (s, tsm->sessions) { if (!(is_lb_session (s))) continue; @@ -1701,7 +1701,7 @@ nat44_lb_static_mapping_add_del_local (ip4_address_t e_addr, u16 e_port, nat_free_session_data (sm, s, tsm - sm->per_thread_data, 0); nat_ed_session_delete (sm, s, tsm - sm->per_thread_data, 1); - }); + } /* *INDENT-ON* */ pool_put (m->locals, match_local); @@ -1710,8 +1710,8 @@ nat44_lb_static_mapping_add_del_local (ip4_address_t e_addr, u16 e_port, vec_free (m->workers); /* *INDENT-OFF* */ - pool_foreach (local, m->locals, - ({ + pool_foreach (local, m->locals) + { vec_add1 (locals, local - m->locals); if (sm->num_workers > 1) { @@ -1721,7 +1721,7 @@ nat44_lb_static_mapping_add_del_local (ip4_address_t e_addr, u16 e_port, sm->worker_in2out_cb (&ip, local->fib_index, 0), 1); } - })); + } /* *INDENT-ON* */ ASSERT (vec_len (locals) > 1); @@ -1779,8 +1779,8 @@ snat_del_address (snat_main_t * sm, ip4_address_t addr, u8 delete_sm, { ip4_address_t pool_addr = { 0 }; /* *INDENT-OFF* */ - pool_foreach (m, sm->static_mappings, - ({ + pool_foreach (m, sm->static_mappings) + { if (m->external_addr.as_u32 == addr.as_u32) (void) snat_add_static_mapping (m->local_addr, m->external_addr, m->local_port, m->external_port, @@ -1792,7 +1792,7 @@ snat_del_address (snat_main_t * sm, ip4_address_t addr, u8 delete_sm, m->tag, is_identity_static_mapping(m), pool_addr, 0); - })); + } /* *INDENT-ON* */ } else @@ -1814,13 +1814,13 @@ snat_del_address (snat_main_t * sm, ip4_address_t addr, u8 delete_sm, vec_foreach (tsm, sm->per_thread_data) { /* *INDENT-OFF* */ - pool_foreach (ses, tsm->sessions, ({ + pool_foreach (ses, tsm->sessions) { if (ses->out2in.addr.as_u32 == addr.as_u32) { nat_free_session_data (sm, ses, tsm - sm->per_thread_data, 0); vec_add1 (ses_to_be_removed, ses - tsm->sessions); } - })); + } /* *INDENT-ON* */ if (sm->endpoint_dependent) @@ -1858,22 +1858,22 @@ snat_del_address (snat_main_t * sm, ip4_address_t addr, u8 delete_sm, /* Delete external address from FIB */ /* *INDENT-OFF* */ - pool_foreach (interface, sm->interfaces, - ({ + pool_foreach (interface, sm->interfaces) + { if (nat_interface_is_inside(interface) || sm->out2in_dpo) continue; snat_add_del_addr_to_fib(&addr, 32, interface->sw_if_index, 0); break; - })); - pool_foreach (interface, sm->output_feature_interfaces, - ({ + } + pool_foreach (interface, sm->output_feature_interfaces) + { if (nat_interface_is_inside(interface) || sm->out2in_dpo) continue; snat_add_del_addr_to_fib(&addr, 32, interface->sw_if_index, 0); break; - })); + } /* *INDENT-ON* */ return 0; @@ -1997,14 +1997,14 @@ snat_interface_add_del (u32 sw_if_index, u8 is_inside, int is_del) } /* *INDENT-OFF* */ - pool_foreach (i, sm->output_feature_interfaces, - ({ + pool_foreach (i, sm->output_feature_interfaces) + { if (i->sw_if_index == sw_if_index) { nat_log_err ("error interface already configured"); return VNET_API_ERROR_VALUE_EXIST; } - })); + } /* *INDENT-ON* */ if (sm->static_mapping_only && !(sm->static_mapping_connection_tracking)) @@ -2063,8 +2063,8 @@ snat_interface_add_del (u32 sw_if_index, u8 is_inside, int is_del) feature_set: /* *INDENT-OFF* */ - pool_foreach (i, sm->interfaces, - ({ + pool_foreach (i, sm->interfaces) + { if (i->sw_if_index == sw_if_index) { if (is_del) @@ -2180,7 +2180,7 @@ feature_set: goto fib; } - })); + } /* *INDENT-ON* */ if (is_del) @@ -2226,13 +2226,13 @@ fib: vec_foreach (ap, sm->addresses) snat_add_del_addr_to_fib(&ap->addr, 32, sw_if_index, !is_del); - pool_foreach (m, sm->static_mappings, - ({ + pool_foreach (m, sm->static_mappings) + { if (!(is_addr_only_static_mapping(m)) || (m->local_addr.as_u32 == m->external_addr.as_u32)) continue; snat_add_del_addr_to_fib(&m->external_addr, 32, sw_if_index, !is_del); - })); + } /* *INDENT-ON* */ return 0; @@ -2263,14 +2263,14 @@ snat_interface_add_del_output_feature (u32 sw_if_index, } /* *INDENT-OFF* */ - pool_foreach (i, sm->interfaces, - ({ + pool_foreach (i, sm->interfaces) + { if (i->sw_if_index == sw_if_index) { nat_log_err ("error interface already configured"); return VNET_API_ERROR_VALUE_EXIST; } - })); + } /* *INDENT-ON* */ if (sm->endpoint_dependent) @@ -2403,8 +2403,8 @@ fq: vlib_frame_queue_main_init (sm->out2in_node_index, 0); /* *INDENT-OFF* */ - pool_foreach (i, sm->output_feature_interfaces, - ({ + pool_foreach (i, sm->output_feature_interfaces) + { if (i->sw_if_index == sw_if_index) { if (is_del) @@ -2414,7 +2414,7 @@ fq: goto fib; } - })); + } /* *INDENT-ON* */ if (is_del) @@ -2441,13 +2441,13 @@ fib: vec_foreach (ap, sm->addresses) snat_add_del_addr_to_fib(&ap->addr, 32, sw_if_index, !is_del); - pool_foreach (m, sm->static_mappings, - ({ + pool_foreach (m, sm->static_mappings) + { if (!((is_addr_only_static_mapping(m))) || (m->local_addr.as_u32 == m->external_addr.as_u32)) continue; snat_add_del_addr_to_fib(&m->external_addr, 32, sw_if_index, !is_del); - })); + } /* *INDENT-ON* */ return 0; @@ -2499,25 +2499,25 @@ snat_update_outside_fib (ip4_main_t * im, uword opaque, } /* *INDENT-OFF* */ - pool_foreach (i, sm->interfaces, - ({ + pool_foreach (i, sm->interfaces) + { if (i->sw_if_index == sw_if_index) { if (!(nat_interface_is_outside (i))) return; match = 1; } - })); + } - pool_foreach (i, sm->output_feature_interfaces, - ({ + pool_foreach (i, sm->output_feature_interfaces) + { if (i->sw_if_index == sw_if_index) { if (!(nat_interface_is_outside (i))) return; match = 1; } - })); + } /* *INDENT-ON* */ if (!match) @@ -3251,8 +3251,8 @@ snat_static_mapping_match (snat_main_t * sm, { u32 thread_index = vlib_get_thread_index (); /* *INDENT-OFF* */ - pool_foreach_index (i, m->locals, - ({ + pool_foreach_index (i, m->locals) + { local = pool_elt_at_index (m->locals, i); ip4_header_t ip = { @@ -3264,17 +3264,17 @@ snat_static_mapping_match (snat_main_t * sm, { vec_add1 (tmp, i); } - })); + } /* *INDENT-ON* */ ASSERT (vec_len (tmp) != 0); } else { /* *INDENT-OFF* */ - pool_foreach_index (i, m->locals, - ({ + pool_foreach_index (i, m->locals) + { vec_add1 (tmp, i); - })); + } /* *INDENT-ON* */ } hi = vec_len (tmp) - 1; diff --git a/src/plugins/nat/nat44_api.c b/src/plugins/nat/nat44_api.c index 4600645d402..5bc4b4cb4e6 100644 --- a/src/plugins/nat/nat44_api.c +++ b/src/plugins/nat/nat44_api.c @@ -725,10 +725,10 @@ vl_api_nat44_interface_dump_t_handler (vl_api_nat44_interface_dump_t * mp) return; /* *INDENT-OFF* */ - pool_foreach (i, sm->interfaces, - ({ + pool_foreach (i, sm->interfaces) + { send_nat44_interface_details(i, reg, mp->context); - })); + } /* *INDENT-ON* */ } @@ -785,10 +785,10 @@ static void return; /* *INDENT-OFF* */ - pool_foreach (i, sm->output_feature_interfaces, - ({ + pool_foreach (i, sm->output_feature_interfaces) + { send_nat44_interface_output_feature_details(i, reg, mp->context); - })); + } /* *INDENT-ON* */ } @@ -982,11 +982,11 @@ vl_api_nat44_static_mapping_dump_t_handler (vl_api_nat44_static_mapping_dump_t return; /* *INDENT-OFF* */ - pool_foreach (m, sm->static_mappings, - ({ + pool_foreach (m, sm->static_mappings) + { if (!is_identity_static_mapping(m) && !is_lb_static_mapping (m)) send_nat44_static_mapping_details (m, reg, mp->context); - })); + } /* *INDENT-ON* */ for (j = 0; j < vec_len (sm->to_resolve); j++) @@ -1104,16 +1104,16 @@ static void return; /* *INDENT-OFF* */ - pool_foreach (m, sm->static_mappings, - ({ + pool_foreach (m, sm->static_mappings) + { if (is_identity_static_mapping(m) && !is_lb_static_mapping (m)) { - pool_foreach_index (j, m->locals, - ({ + 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++) @@ -1251,7 +1251,7 @@ nat_ed_users_create (snat_main_per_thread_data_t * tsm) { snat_session_t *s; /* *INDENT-OFF* */ - pool_foreach (s, tsm->sessions, { nat_ed_user_create_helper (tsm, s); }); + pool_foreach (s, tsm->sessions) { nat_ed_user_create_helper (tsm, s); } /* *INDENT-ON* */ } @@ -1286,10 +1286,10 @@ vl_api_nat44_user_dump_t_handler (vl_api_nat44_user_dump_t * mp) { nat_ed_users_create (tsm); } - pool_foreach (u, tsm->users, - ({ + pool_foreach (u, tsm->users) + { send_nat44_user_details (u, reg, mp->context); - })); + } if (sm->endpoint_dependent) { nat_ed_users_destroy (tsm); @@ -1407,12 +1407,12 @@ vl_api_nat44_user_session_dump_t_handler (vl_api_nat44_user_session_dump_t * else { /* *INDENT-OFF* */ - pool_foreach (s, tsm->sessions, { + pool_foreach (s, tsm->sessions) { if (s->in2out.addr.as_u32 == ukey.addr.as_u32) { send_nat44_user_session_details (s, reg, mp->context); } - }); + } /* *INDENT-ON* */ } } @@ -1556,15 +1556,15 @@ send_nat44_lb_static_mapping_details (snat_static_mapping_t * m, locals = (vl_api_nat44_lb_addr_port_t *) rmp->locals; /* *INDENT-OFF* */ - pool_foreach (ap, m->locals, - ({ + pool_foreach (ap, m->locals) + { clib_memcpy (locals->addr, &(ap->addr), 4); locals->port = ap->port; locals->probability = ap->probability; locals->vrf_id = ntohl (ap->vrf_id); locals++; local_num++; - })); + } /* *INDENT-ON* */ rmp->local_num = ntohl (local_num); @@ -1587,11 +1587,11 @@ static void return; /* *INDENT-OFF* */ - pool_foreach (m, sm->static_mappings, - ({ + pool_foreach (m, sm->static_mappings) + { if (is_lb_static_mapping(m)) send_nat44_lb_static_mapping_details (m, reg, mp->context); - })); + } /* *INDENT-ON* */ } @@ -1644,13 +1644,13 @@ static void /* *INDENT-OFF* */ vec_foreach (tsm, sm->per_thread_data) { - pool_foreach (s, tsm->sessions, - ({ + pool_foreach (s, tsm->sessions) + { if (is_fwd_bypass_session(s)) { vec_add1 (ses_to_be_removed, s - tsm->sessions); } - })); + } if(sm->endpoint_dependent){ vec_foreach (ses_index, ses_to_be_removed) { diff --git a/src/plugins/nat/nat44_cli.c b/src/plugins/nat/nat44_cli.c index 29807649ff8..ca396fd22fe 100644 --- a/src/plugins/nat/nat44_cli.c +++ b/src/plugins/nat/nat44_cli.c @@ -773,8 +773,8 @@ nat44_show_summary_command_fn (vlib_main_t * vm, unformat_input_t * input, /* *INDENT-OFF* */ vec_foreach (tsm, sm->per_thread_data) { - pool_foreach (s, tsm->sessions, - ({ + pool_foreach (s, tsm->sessions) + { sess_timeout_time = s->last_heard + (f64) nat44_session_get_timeout (sm, s); if (now >= sess_timeout_time) @@ -810,7 +810,7 @@ nat44_show_summary_command_fn (vlib_main_t * vm, unformat_input_t * input, udp_sessions++; break; } - })); + } nat44_show_lru_summary (vm, tsm, now, sess_timeout_time); count += pool_elts (tsm->sessions); } @@ -820,8 +820,8 @@ nat44_show_summary_command_fn (vlib_main_t * vm, unformat_input_t * input, { tsm = vec_elt_at_index (sm->per_thread_data, sm->num_workers); /* *INDENT-OFF* */ - pool_foreach (s, tsm->sessions, - ({ + pool_foreach (s, tsm->sessions) + { sess_timeout_time = s->last_heard + (f64) nat44_session_get_timeout (sm, s); if (now >= sess_timeout_time) @@ -857,7 +857,7 @@ nat44_show_summary_command_fn (vlib_main_t * vm, unformat_input_t * input, udp_sessions++; break; } - })); + } /* *INDENT-ON* */ nat44_show_lru_summary (vm, tsm, now, sess_timeout_time); count = pool_elts (tsm->sessions); @@ -1037,24 +1037,24 @@ nat44_show_interfaces_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_output (vm, "NAT44 interfaces:"); /* *INDENT-OFF* */ - pool_foreach (i, sm->interfaces, - ({ + pool_foreach (i, sm->interfaces) + { vlib_cli_output (vm, " %U %s", format_vnet_sw_if_index_name, vnm, i->sw_if_index, (nat_interface_is_inside(i) && nat_interface_is_outside(i)) ? "in out" : (nat_interface_is_inside(i) ? "in" : "out")); - })); + } - pool_foreach (i, sm->output_feature_interfaces, - ({ + pool_foreach (i, sm->output_feature_interfaces) + { vlib_cli_output (vm, " %U output-feature %s", format_vnet_sw_if_index_name, vnm, i->sw_if_index, (nat_interface_is_inside(i) && nat_interface_is_outside(i)) ? "in out" : (nat_interface_is_inside(i) ? "in" : "out")); - })); + } /* *INDENT-ON* */ return 0; @@ -1473,10 +1473,10 @@ nat44_show_static_mappings_command_fn (vlib_main_t * vm, vlib_cli_output (vm, "NAT44 static mappings:"); /* *INDENT-OFF* */ - pool_foreach (m, sm->static_mappings, - ({ + pool_foreach (m, sm->static_mappings) + { vlib_cli_output (vm, " %U", format_snat_static_mapping, m); - })); + } vec_foreach (rp, sm->to_resolve) vlib_cli_output (vm, " %U", format_snat_static_map_to_resolve, rp); /* *INDENT-ON* */ @@ -1611,18 +1611,18 @@ print: if (!sm->endpoint_dependent) { snat_user_t *u; - pool_foreach (u, tsm->users, - ({ + pool_foreach (u, tsm->users) + { vlib_cli_output (vm, " %U", format_snat_user, tsm, u, detail); - })); + } } else { snat_session_t *s; - pool_foreach (s, tsm->sessions, - ({ + pool_foreach (s, tsm->sessions) + { vlib_cli_output (vm, " %U\n", format_snat_session, tsm, s); - })); + } } } /* *INDENT-ON* */ diff --git a/src/plugins/nat/nat44_hairpinning.c b/src/plugins/nat/nat44_hairpinning.c index 2859046ae05..9432f554246 100644 --- a/src/plugins/nat/nat44_hairpinning.c +++ b/src/plugins/nat/nat44_hairpinning.c @@ -746,8 +746,8 @@ snat_hairpin_src_fn_inline (vlib_main_t * vm, vnet_feature_next (&next0, b0); /* *INDENT-OFF* */ - pool_foreach (i, sm->output_feature_interfaces, - ({ + pool_foreach (i, sm->output_feature_interfaces) + { /* Only packets from NAT inside interface */ if ((nat_interface_is_inside(i)) && (sw_if_index0 == i->sw_if_index)) { @@ -761,7 +761,7 @@ snat_hairpin_src_fn_inline (vlib_main_t * vm, } break; } - })); + } /* *INDENT-ON* */ if (next0 != SNAT_HAIRPIN_SRC_NEXT_DROP) diff --git a/src/plugins/nat/nat64/nat64.c b/src/plugins/nat/nat64/nat64.c index 240f3ef0fba..ae7bb350436 100644 --- a/src/plugins/nat/nat64/nat64.c +++ b/src/plugins/nat/nat64/nat64.c @@ -423,14 +423,14 @@ nat64_add_del_pool_addr (u32 thread_index, /* Add/del external address to FIB */ /* *INDENT-OFF* */ - pool_foreach (interface, nm->interfaces, - ({ + pool_foreach (interface, nm->interfaces) + { if (nat64_interface_is_inside(interface)) continue; nat64_add_del_addr_to_fib (addr, 32, interface->sw_if_index, is_add); break; - })); + } /* *INDENT-ON* */ return 0; @@ -547,14 +547,14 @@ nat64_interface_add_del (u32 sw_if_index, u8 is_inside, u8 is_add) /* Check if interface already exists */ /* *INDENT-OFF* */ - pool_foreach (i, nm->interfaces, - ({ + pool_foreach (i, nm->interfaces) + { if (i->sw_if_index == sw_if_index) { interface = i; break; } - })); + } /* *INDENT-ON* */ if (is_add) @@ -642,11 +642,11 @@ nat64_interfaces_walk (nat64_interface_walk_fn_t fn, void *ctx) nat64_interface_t *i = 0; /* *INDENT-OFF* */ - pool_foreach (i, nm->interfaces, - ({ + pool_foreach (i, nm->interfaces) + { if (fn (i, ctx)) break; - })); + } /* *INDENT-ON* */ } @@ -823,8 +823,8 @@ nat64_static_bib_worker_fn (vlib_main_t * vm, vlib_node_runtime_t * rt, ip46_address_t addr; /* *INDENT-OFF* */ - pool_foreach (static_bib, nm->static_bibs, - ({ + pool_foreach (static_bib, nm->static_bibs) + { if ((static_bib->thread_index != thread_index) || (static_bib->done)) continue; @@ -858,7 +858,7 @@ nat64_static_bib_worker_fn (vlib_main_t * vm, vlib_node_runtime_t * rt, } static_bib->done = 1; - })); + } /* *INDENT-ON* */ return 0; @@ -978,11 +978,11 @@ nat64_add_del_static_bib_entry (ip6_address_t * in_addr, if (nm->num_workers) { /* *INDENT-OFF* */ - pool_foreach (static_bib, nm->static_bibs, - ({ + pool_foreach (static_bib, nm->static_bibs) + { if (static_bib->done) vec_add1 (to_be_free, static_bib - nm->static_bibs); - })); + } vec_foreach (index, to_be_free) pool_put_index (nm->static_bibs, index[0]); /* *INDENT-ON* */ @@ -1567,10 +1567,10 @@ nat64_plugin_disable () nm->enabled = 0; /* *INDENT-OFF* */ - pool_foreach (i, nm->interfaces, - ({ + pool_foreach (i, nm->interfaces) + { vec_add1 (interfaces, *i); - })); + } /* *INDENT-ON* */ vec_foreach (i, interfaces) { diff --git a/src/plugins/nat/nat64/nat64_db.c b/src/plugins/nat/nat64/nat64_db.c index 49909fdfeb6..82ef70de5cf 100644 --- a/src/plugins/nat/nat64/nat64_db.c +++ b/src/plugins/nat/nat64/nat64_db.c @@ -177,11 +177,11 @@ nat64_db_bib_entry_free (u32 thread_index, nat64_db_t * db, /* delete ST entries for static BIB entry */ if (bibe->is_static) { - pool_foreach (ste, st, ( - { - if (ste->bibe_index == bibe_index) - vec_add1 (ste_to_be_free, ste - st);} - )); + pool_foreach (ste, st) + { + if (ste->bibe_index == bibe_index) + vec_add1 (ste_to_be_free, ste - st); + } vec_foreach (ste_index, ste_to_be_free) nat64_db_st_entry_free (thread_index, db, pool_elt_at_index (st, ste_index[0])); @@ -274,17 +274,17 @@ nat64_db_bib_walk (nat64_db_t * db, u8 proto, /* *INDENT-OFF* */ #define _(N, i, n, s) \ bib = db->bib._##n##_bib; \ - pool_foreach (bibe, bib, ({ \ + pool_foreach (bibe, bib) { \ if (fn (bibe, ctx)) \ return; \ - })); + } foreach_nat_protocol #undef _ bib = db->bib._unk_proto_bib; - pool_foreach (bibe, bib, ({ + pool_foreach (bibe, bib) { if (fn (bibe, ctx)) return; - })); + } /* *INDENT-ON* */ } else @@ -305,11 +305,11 @@ nat64_db_bib_walk (nat64_db_t * db, u8 proto, } /* *INDENT-OFF* */ - pool_foreach (bibe, bib, - ({ + pool_foreach (bibe, bib) + { if (fn (bibe, ctx)) return; - })); + } /* *INDENT-ON* */ } } @@ -348,17 +348,17 @@ nat64_db_st_walk (nat64_db_t * db, u8 proto, /* *INDENT-OFF* */ #define _(N, i, n, s) \ st = db->st._##n##_st; \ - pool_foreach (ste, st, ({ \ + pool_foreach (ste, st) { \ if (fn (ste, ctx)) \ return; \ - })); + } foreach_nat_protocol #undef _ st = db->st._unk_proto_st; - pool_foreach (ste, st, ({ + pool_foreach (ste, st) { if (fn (ste, ctx)) return; - })); + } /* *INDENT-ON* */ } else @@ -379,11 +379,11 @@ nat64_db_st_walk (nat64_db_t * db, u8 proto, } /* *INDENT-OFF* */ - pool_foreach (ste, st, - ({ + pool_foreach (ste, st) + { if (fn (ste, ctx)) return; - })); + } /* *INDENT-ON* */ } } @@ -670,12 +670,12 @@ nad64_db_st_free_expired (u32 thread_index, nat64_db_t * db, u32 now) /* *INDENT-OFF* */ #define _(N, i, n, s) \ st = db->st._##n##_st; \ - pool_foreach (ste, st, ({\ + pool_foreach (ste, st) {\ if (i == NAT_PROTOCOL_TCP && !ste->tcp_state) \ continue; \ if (ste->expire < now) \ vec_add1 (ste_to_be_free, ste - st); \ - })); \ + } \ vec_foreach (ste_index, ste_to_be_free) \ nat64_db_st_entry_free (thread_index, db, \ pool_elt_at_index(st, ste_index[0])); \ @@ -684,10 +684,10 @@ nad64_db_st_free_expired (u32 thread_index, nat64_db_t * db, u32 now) foreach_nat_protocol #undef _ st = db->st._unk_proto_st; - pool_foreach (ste, st, ({ + pool_foreach (ste, st) { if (ste->expire < now) vec_add1 (ste_to_be_free, ste - st); - })); + } vec_foreach (ste_index, ste_to_be_free) nat64_db_st_entry_free (thread_index, db, pool_elt_at_index(st, ste_index[0])); @@ -707,11 +707,11 @@ nat64_db_free_out_addr (u32 thread_index, /* *INDENT-OFF* */ #define _(N, i, n, s) \ st = db->st._##n##_st; \ - pool_foreach (ste, st, ({ \ + pool_foreach (ste, st) { \ bibe = pool_elt_at_index (db->bib._##n##_bib, ste->bibe_index); \ if (bibe->out_addr.as_u32 == out_addr->as_u32) \ vec_add1 (ste_to_be_free, ste - st); \ - })); \ + } \ vec_foreach (ste_index, ste_to_be_free) \ nat64_db_st_entry_free (thread_index, db, \ pool_elt_at_index(st, ste_index[0])); \ @@ -720,11 +720,11 @@ nat64_db_free_out_addr (u32 thread_index, foreach_nat_protocol #undef _ st = db->st._unk_proto_st; - pool_foreach (ste, st, ({ + pool_foreach (ste, st) { bibe = pool_elt_at_index (db->bib._unk_proto_bib, ste->bibe_index); if (bibe->out_addr.as_u32 == out_addr->as_u32) vec_add1 (ste_to_be_free, ste - st); - })); + } vec_foreach (ste_index, ste_to_be_free) nat64_db_st_entry_free (thread_index, db, pool_elt_at_index(st, ste_index[0])); diff --git a/src/plugins/nat/nat66/nat66.c b/src/plugins/nat/nat66/nat66.c index 0a90f732b95..a8de3f6e0fa 100644 --- a/src/plugins/nat/nat66/nat66.c +++ b/src/plugins/nat/nat66/nat66.c @@ -94,14 +94,14 @@ nat66_interface_add_del (u32 sw_if_index, u8 is_inside, u8 is_add) const char *feature_name; /* *INDENT-OFF* */ - pool_foreach (i, nm->interfaces, - ({ + pool_foreach (i, nm->interfaces) + { if (i->sw_if_index == sw_if_index) { interface = i; break; } - })); + } /* *INDENT-ON* */ if (is_add) @@ -139,11 +139,11 @@ nat66_interfaces_walk (nat66_interface_walk_fn_t fn, void *ctx) nat66_interface_t *i = 0; /* *INDENT-OFF* */ - pool_foreach (i, nm->interfaces, - ({ + pool_foreach (i, nm->interfaces) + { if (fn (i, ctx)) break; - })); + } /* *INDENT-ON* */ } @@ -257,11 +257,11 @@ nat66_static_mappings_walk (nat66_static_mapping_walk_fn_t fn, void *ctx) nat66_static_mapping_t *sm = 0; /* *INDENT-OFF* */ - pool_foreach (sm, nm->sm, - ({ + pool_foreach (sm, nm->sm) + { if (fn (sm, ctx)) break; - })); + } /* *INDENT-ON* */ } diff --git a/src/plugins/nat/nat66/nat66_in2out.c b/src/plugins/nat/nat66/nat66_in2out.c index 4c4d3ab0299..356100f89ef 100644 --- a/src/plugins/nat/nat66/nat66_in2out.c +++ b/src/plugins/nat/nat66/nat66_in2out.c @@ -95,12 +95,12 @@ nat66_not_translate (u32 rx_fib_index, ip6_address_t ip6_addr) } /* *INDENT-OFF* */ - pool_foreach (i, nm->interfaces, - ({ + pool_foreach (i, nm->interfaces) + { /* NAT packet aimed at outside interface */ if (nat66_interface_is_outside (i) && sw_if_index == i->sw_if_index) return 0; - })); + } /* *INDENT-ON* */ return 1; diff --git a/src/plugins/nat/nat_format.c b/src/plugins/nat/nat_format.c index f0e7a5d5cd0..90faeb96e9b 100644 --- a/src/plugins/nat/nat_format.c +++ b/src/plugins/nat/nat_format.c @@ -234,10 +234,10 @@ format_snat_static_mapping (u8 * s, va_list * args) clib_net_to_host_u16 (m->local_port)); /* *INDENT-OFF* */ - pool_foreach (local, m->locals, - ({ + pool_foreach (local, m->locals) + { s = format (s, " vrf %d", local->vrf_id); - })); + } /* *INDENT-ON* */ return s; @@ -264,13 +264,13 @@ format_snat_static_mapping (u8 * s, va_list * args) is_out2in_only_static_mapping (m) ? "out2in-only" : ""); /* *INDENT-OFF* */ - pool_foreach (local, m->locals, - ({ + pool_foreach (local, m->locals) + { s = format (s, "\n local %U:%d vrf %d probability %d\%", format_ip4_address, &local->addr, clib_net_to_host_u16 (local->port), local->vrf_id, local->probability); - })); + } /* *INDENT-ON* */ } diff --git a/src/plugins/nat/nat_inlines.h b/src/plugins/nat/nat_inlines.h index 3d0f5ba05c4..ccb9cdf1221 100644 --- a/src/plugins/nat/nat_inlines.h +++ b/src/plugins/nat/nat_inlines.h @@ -713,11 +713,11 @@ snat_not_translate_fast (snat_main_t * sm, vlib_node_runtime_t * node, snat_interface_t *i; /* *INDENT-OFF* */ - pool_foreach (i, sm->interfaces, ({ + pool_foreach (i, sm->interfaces) { /* NAT packet aimed at outside interface */ if ((nat_interface_is_outside (i)) && (sw_if_index == i->sw_if_index)) return 0; - })); + } /* *INDENT-ON* */ } |