#include "static_memory.h"
#include "static_vty.h"
#include "static_routes.h"
+#include "static_debug.h"
#ifndef VTYSH_EXTRACT_PL
#include "staticd/static_vty_clippy.c"
#endif
+#define STATICD_STR "Static route daemon\n"
+
static struct static_vrf *static_vty_get_unknown_vrf(struct vty *vty,
const char *vrf_name)
{
static void static_list_delete(struct static_hold_route *shr)
{
- if (shr->vrf_name)
- XFREE(MTYPE_STATIC_ROUTE, shr->vrf_name);
- if (shr->nhvrf_name)
- XFREE(MTYPE_STATIC_ROUTE, shr->nhvrf_name);
- if (shr->dest_str)
- XFREE(MTYPE_STATIC_ROUTE, shr->dest_str);
- if (shr->mask_str)
- XFREE(MTYPE_STATIC_ROUTE, shr->mask_str);
- if (shr->src_str)
- XFREE(MTYPE_STATIC_ROUTE, shr->src_str);
- if (shr->gate_str)
- XFREE(MTYPE_STATIC_ROUTE, shr->gate_str);
- if (shr->ifname)
- XFREE(MTYPE_STATIC_ROUTE, shr->ifname);
- if (shr->flag_str)
- XFREE(MTYPE_STATIC_ROUTE, shr->flag_str);
- if (shr->tag_str)
- XFREE(MTYPE_STATIC_ROUTE, shr->tag_str);
- if (shr->distance_str)
- XFREE(MTYPE_STATIC_ROUTE, shr->distance_str);
- if (shr->label_str)
- XFREE(MTYPE_STATIC_ROUTE, shr->label_str);
- if (shr->table_str)
- XFREE(MTYPE_STATIC_ROUTE, shr->table_str);
+ XFREE(MTYPE_STATIC_ROUTE, shr->vrf_name);
+ XFREE(MTYPE_STATIC_ROUTE, shr->nhvrf_name);
+ XFREE(MTYPE_STATIC_ROUTE, shr->dest_str);
+ XFREE(MTYPE_STATIC_ROUTE, shr->mask_str);
+ XFREE(MTYPE_STATIC_ROUTE, shr->src_str);
+ XFREE(MTYPE_STATIC_ROUTE, shr->gate_str);
+ XFREE(MTYPE_STATIC_ROUTE, shr->ifname);
+ XFREE(MTYPE_STATIC_ROUTE, shr->flag_str);
+ XFREE(MTYPE_STATIC_ROUTE, shr->tag_str);
+ XFREE(MTYPE_STATIC_ROUTE, shr->distance_str);
+ XFREE(MTYPE_STATIC_ROUTE, shr->label_str);
+ XFREE(MTYPE_STATIC_ROUTE, shr->table_str);
XFREE(MTYPE_STATIC_ROUTE, shr);
}
if (vty)
vty_out(vty, "%% Malformed address\n");
else
- zlog_warn("%s: Malformed address: %s",
- __PRETTY_FUNCTION__, dest_str);
+ zlog_warn("%s: Malformed address: %s", __func__,
+ dest_str);
return CMD_WARNING_CONFIG_FAILED;
}
vty_out(vty, "%% Malformed address\n");
else
zlog_warn("%s: Malformed address: %s",
- __PRETTY_FUNCTION__,
- mask_str);
+ __func__, mask_str);
return CMD_WARNING_CONFIG_FAILED;
}
p.prefixlen = ip_masklen(mask);
else
zlog_warn(
"%s: Malformed source address: %s",
- __PRETTY_FUNCTION__, src_str);
+ __func__, src_str);
return CMD_WARNING_CONFIG_FAILED;
}
src_p = (struct prefix_ipv6 *)&src;
"%% Table %s overlaps vrf table %u\n",
table_str, svrf->vrf->data.l.table_id);
else
- zlog_warn(
- "%s: Table %s overlaps vrf table %u",
- __PRETTY_FUNCTION__,
- table_str, svrf->vrf->data.l.table_id);
+ zlog_warn("%s: Table %s overlaps vrf table %u",
+ __func__, table_str,
+ svrf->vrf->data.l.table_id);
return CMD_WARNING_CONFIG_FAILED;
}
}
else
zlog_warn(
"%s: MPLS not turned on in kernel ignoring static route to %s",
- __PRETTY_FUNCTION__, dest_str);
+ __func__, dest_str);
return CMD_WARNING_CONFIG_FAILED;
}
int rc = mpls_str2label(label_str, &snh_label.num_labels,
else
zlog_warn(
"%s: Malformed labels specified for route %s",
- __PRETTY_FUNCTION__, dest_str);
+ __func__, dest_str);
break;
case -2:
if (vty)
else
zlog_warn(
"%s: Cannot use reserved labels (%d-%d) for %s",
- __PRETTY_FUNCTION__,
+ __func__,
MPLS_LABEL_RESERVED_MIN,
MPLS_LABEL_RESERVED_MAX,
dest_str);
else
zlog_warn(
"%s: Too many labels, Enter %d or fewer for %s",
- __PRETTY_FUNCTION__,
- MPLS_MAX_LABELS, dest_str);
+ __func__, MPLS_MAX_LABELS,
+ dest_str);
break;
}
return CMD_WARNING_CONFIG_FAILED;
/* Null0 static route. */
if (ifname != NULL) {
- if (strncasecmp(ifname, "Null0", strlen(ifname)) == 0
- || strncasecmp(ifname, "reject", strlen(ifname)) == 0
- || strncasecmp(ifname, "blackhole", strlen(ifname)) == 0) {
+ if (strcasecmp(ifname, "Null0") == 0
+ || strcasecmp(ifname, "reject") == 0
+ || strcasecmp(ifname, "blackhole") == 0) {
if (vty)
vty_out(vty,
- "%% Nexthop interface cannot be Null0, reject or blackhole\n");
+ "%% Nexthop interface name can not be from reserved keywords (Null0, reject, blackhole)\n");
else
zlog_warn(
- "%s: Nexthop interface cannot be Null0, reject or blackhole for %s",
- __PRETTY_FUNCTION__, dest_str);
+ "%s: %s: Nexthop interface name can not be from reserved keywords (Null0, reject, blackhole)",
+ __func__, dest_str);
return CMD_WARNING_CONFIG_FAILED;
}
}
flag_str);
else
zlog_warn("%s: Malformed flag %s for %s",
- __PRETTY_FUNCTION__, flag_str,
- dest_str);
+ __func__, flag_str, dest_str);
return CMD_WARNING_CONFIG_FAILED;
}
}
else
zlog_warn(
"%s: Malformed nexthop address %s for %s",
- __PRETTY_FUNCTION__, gate_str,
- dest_str);
+ __func__, gate_str, dest_str);
return CMD_WARNING_CONFIG_FAILED;
}
gatep = &gate;
+
+ if (afi == AFI_IP && !negate) {
+ if (if_lookup_exact_address(&gatep->ipv4, AF_INET,
+ svrf->vrf->vrf_id))
+ if (vty)
+ vty_out(vty,
+ "%% Warning!! Local connected address is configured as Gateway IP(%s)\n",
+ gate_str);
+ } else if (afi == AFI_IP6 && !negate) {
+ if (if_lookup_exact_address(&gatep->ipv6, AF_INET6,
+ svrf->vrf->vrf_id))
+ if (vty)
+ vty_out(vty,
+ "%% Warning!! Local connected address is configured as Gateway IPv6(%s)\n",
+ gate_str);
+ }
+
}
if (gate_str == NULL && ifname == NULL)
"Table to configure\n"
"The table number to configure\n")
{
- if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) {
+ if (table_str && vrf && !vrf_is_backend_netns()) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
VTY_DECLVAR_CONTEXT(vrf, vrf);
struct static_vrf *svrf = vrf->info;
- if (table_str && !vrf_is_mapped_on_netns(vrf)) {
+ if (table_str && !vrf_is_backend_netns()) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
return CMD_WARNING_CONFIG_FAILED;
}
- if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) {
+ if (table_str && vrf && !vrf_is_backend_netns()) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
struct static_vrf *svrf = vrf->info;
struct static_vrf *nh_svrf;
- if (table_str && !vrf_is_mapped_on_netns(vrf)) {
+ if (table_str && !vrf_is_backend_netns()) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
struct static_vrf *nh_svrf;
const char *flag = NULL;
- if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) {
+ if (table_str && vrf && !vrf_is_backend_netns()) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
struct static_vrf *nh_svrf;
const char *flag = NULL;
- if (table_str && !vrf_is_mapped_on_netns(vrf)) {
+ if (table_str && !vrf_is_backend_netns()) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
"Table to configure\n"
"The table number to configure\n")
{
- if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) {
+ if (table_str && vrf && !vrf_is_backend_netns()) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
VTY_DECLVAR_CONTEXT(vrf, vrf);
struct static_vrf *svrf = vrf->info;
- if (table_str && !vrf_is_mapped_on_netns(vrf)) {
+ if (table_str && !vrf_is_backend_netns()) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
struct static_vrf *nh_svrf;
const char *flag = NULL;
- if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) {
+ if (table_str && vrf && !vrf_is_backend_netns()) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
struct static_vrf *nh_svrf;
const char *flag = NULL;
- if (table_str && !vrf_is_mapped_on_netns(vrf)) {
+ if (table_str && !vrf_is_backend_netns()) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
struct static_vrf *nh_svrf;
const char *flag = NULL;
- if (table_str && vrf && !vrf_is_mapped_on_netns(vrf_lookup_by_name(vrf))) {
+ if (table_str && vrf && !vrf_is_backend_netns()) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
struct static_vrf *nh_svrf;
const char *flag = NULL;
- if (table_str && !vrf_is_mapped_on_netns(vrf)) {
+ if (table_str && !vrf_is_backend_netns()) {
vty_out(vty,
"%% table param only available when running on netns-based vrfs\n");
return CMD_WARNING_CONFIG_FAILED;
from_str, gate_str, ifname, flag, tag_str, distance_str, label,
table_str, false);
}
+DEFPY(debug_staticd,
+ debug_staticd_cmd,
+ "[no] debug static [{events$events}]",
+ NO_STR
+ DEBUG_STR
+ STATICD_STR
+ "Debug events\n")
+{
+ /* If no specific category, change all */
+ if (strmatch(argv[argc - 1]->text, "static"))
+ static_debug_set(vty->node, !no, true);
+ else
+ static_debug_set(vty->node, !no, !!events);
-DEFUN_NOSH (show_debugging_staticd,
- show_debugging_staticd_cmd,
+ return CMD_SUCCESS;
+}
+
+DEFUN_NOSH (show_debugging_static,
+ show_debugging_static_cmd,
"show debugging [static]",
SHOW_STR
DEBUG_STR
"Static Information\n")
{
- vty_out(vty, "Static debugging status\n");
+ vty_out(vty, "Staticd debugging status\n");
+
+ static_debug_status_write(vty);
return CMD_SUCCESS;
}
+static struct cmd_node debug_node = {DEBUG_NODE, "", 1};
+
void static_vty_init(void)
{
+ install_node(&debug_node, static_config_write_debug);
+
install_element(CONFIG_NODE, &ip_mroute_dist_cmd);
install_element(CONFIG_NODE, &ip_route_blackhole_cmd);
install_element(CONFIG_NODE, &ipv6_route_cmd);
install_element(VRF_NODE, &ipv6_route_vrf_cmd);
- install_element(VIEW_NODE, &show_debugging_staticd_cmd);
+ install_element(VIEW_NODE, &show_debugging_static_cmd);
+ install_element(VIEW_NODE, &debug_staticd_cmd);
+ install_element(CONFIG_NODE, &debug_staticd_cmd);
static_list = list_new();
static_list->cmp = (int (*)(void *, void *))static_list_compare;