det44_main_t det44_main;
-/* *INDENT-OFF* */
VNET_FEATURE_INIT (ip4_det44_in2out, static) = {
.arc_name = "ip4-unicast",
.node_name = "det44-in2out",
.version = VPP_BUILD_VER,
.description = "Deterministic NAT (CGN)",
};
-/* *INDENT-ON* */
void
det44_add_del_addr_to_fib (ip4_address_t * addr, u8 p_len, u32 sw_if_index,
}
/* 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;
}
// rather make a structure and when enable call is used
// 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:
feature_name = is_inside ? "det44-in2out" : "det44-out2in";
// add/del outside interface fib to registry
u8 found = 0;
det44_fib_t *outside_fib;
- /* *INDENT-OFF* */
vec_foreach (outside_fib, dm->outside_fibs)
{
if (outside_fib->fib_index == fib_index)
break;
}
}
- /* *INDENT-ON* */
if (!is_del && !found)
{
vec_add2 (dm->outside_fibs, outside_fib, 1);
}
// 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;
}
snat_det_session_t *ses;
snat_det_map_t *mp;
- vlib_process_wait_for_event_or_clock (vm, 10.0);
- vlib_process_get_events (vm, NULL);
- u32 now = (u32) vlib_time_now (vm);
- /* *INDENT-OFF* */
- 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* */
+ while (1)
+ {
+ vlib_process_wait_for_event_or_clock (vm, 10.0);
+ vlib_process_get_events (vm, NULL);
+ u32 now = (u32) vlib_time_now (vm);
+
+ if (!plugin_enabled ())
+ {
+ continue;
+ }
+
+ pool_foreach (mp, dm->det_maps)
+ {
+ vec_foreach (ses, mp->sessions)
+ {
+ // close expired sessions
+ if (ses->in_port && (ses->expire < now))
+ {
+ snat_det_ses_close (mp, ses);
+ }
+ }
+ }
+ }
return 0;
}
c.inside_vrf_id,
dm->fib_src_hi);
- det44_create_expire_walk_process ();
dm->mss_clamping = 0;
dm->config = c;
dm->enabled = 1;
+
+ det44_create_expire_walk_process ();
return 0;
}
return 1;
}
+ dm->enabled = 0;
+
// DET44 cleanup (order dependent)
// 1) remove interfaces (det44_interface_add_del) removes map ranges from fib
// 2) free sessions
}
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 ();
- dm->enabled = 0;
pool_free (dm->interfaces);
pool_free (dm->det_maps);
if (!vec_len (dm->outside_fibs))
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)
return;