-static clib_error_t *
-nat_ha_failover_command_fn (vlib_main_t * vm, unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- unformat_input_t _line_input, *line_input = &_line_input;
- ip4_address_t addr;
- u32 port, session_refresh_interval = 10;
- int rv;
- clib_error_t *error = 0;
-
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "%U:%u", unformat_ip4_address, &addr, &port))
- ;
- else
- if (unformat
- (line_input, "refresh-interval %u", &session_refresh_interval))
- ;
- else
- {
- error = clib_error_return (0, "unknown input '%U'",
- format_unformat_error, line_input);
- goto done;
- }
- }
-
- rv = nat_ha_set_failover (&addr, (u16) port, session_refresh_interval);
- if (rv)
- error = clib_error_return (0, "set HA failover failed");
-
-done:
- unformat_free (line_input);
-
- return error;
-}
-
-static clib_error_t *
-nat_ha_listener_command_fn (vlib_main_t * vm, unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- unformat_input_t _line_input, *line_input = &_line_input;
- ip4_address_t addr;
- u32 port, path_mtu = 512;
- int rv;
- clib_error_t *error = 0;
-
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "%U:%u", unformat_ip4_address, &addr, &port))
- ;
- else if (unformat (line_input, "path-mtu %u", &path_mtu))
- ;
- else
- {
- error = clib_error_return (0, "unknown input '%U'",
- format_unformat_error, line_input);
- goto done;
- }
- }
-
- rv = nat_ha_set_listener (&addr, (u16) port, path_mtu);
- if (rv)
- error = clib_error_return (0, "set HA listener failed");
-
-done:
- unformat_free (line_input);
-
- return error;
-}
-
-static clib_error_t *
-nat_show_ha_command_fn (vlib_main_t * vm, unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- ip4_address_t addr;
- u16 port;
- u32 path_mtu, session_refresh_interval, resync_ack_missed;
- u8 in_resync;
-
- nat_ha_get_listener (&addr, &port, &path_mtu);
- if (!port)
- {
- vlib_cli_output (vm, "NAT HA disabled\n");
- return 0;
- }
-
- vlib_cli_output (vm, "LISTENER:\n");
- vlib_cli_output (vm, " %U:%u path-mtu %u\n",
- format_ip4_address, &addr, port, path_mtu);
-
- nat_ha_get_failover (&addr, &port, &session_refresh_interval);
- vlib_cli_output (vm, "FAILOVER:\n");
- if (port)
- vlib_cli_output (vm, " %U:%u refresh-interval %usec\n",
- format_ip4_address, &addr, port,
- session_refresh_interval);
- else
- vlib_cli_output (vm, " NA\n");
-
- nat_ha_get_resync_status (&in_resync, &resync_ack_missed);
- vlib_cli_output (vm, "RESYNC:\n");
- if (in_resync)
- vlib_cli_output (vm, " in progress\n");
- else
- vlib_cli_output (vm, " completed (%d ACK missed)\n", resync_ack_missed);
-
- return 0;
-}
-
-static clib_error_t *
-nat_ha_flush_command_fn (vlib_main_t * vm, unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- nat_ha_flush (0);
- return 0;
-}
-
-static clib_error_t *
-nat_ha_resync_command_fn (vlib_main_t * vm, unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- clib_error_t *error = 0;
-
- if (nat_ha_resync (0, 0, 0))
- error = clib_error_return (0, "NAT HA resync already running");
-
- return error;
-}
-