From b2c31b685fd2cf28436ca32bc93e23eb24c74878 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Sun, 13 Dec 2020 21:47:40 +0100 Subject: misc: move to new pool_foreach macros Type: refactor Change-Id: Ie67dc579e88132ddb1ee4a34cb69f96920101772 Signed-off-by: Damjan Marion --- src/plugins/nat/nat64/nat64.c | 36 +++++++++++++-------------- src/plugins/nat/nat64/nat64_db.c | 54 ++++++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 45 deletions(-) (limited to 'src/plugins/nat/nat64') 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])); -- cgit 1.2.3-korg