mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 16:42:32 +00:00
Merge pull request #6882 from vishaldhingra/static
staticd : Added the warning log for route when VRF is not ready.
This commit is contained in:
commit
4b40d5ffb0
@ -34,13 +34,16 @@
|
|||||||
|
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
struct debug static_dbg_events = {0, "Staticd events"};
|
struct debug static_dbg_events = {0, "Staticd events"};
|
||||||
|
struct debug static_dbg_route = {0, "Staticd route"};
|
||||||
|
|
||||||
struct debug *static_debug_arr[] = {
|
struct debug *static_debug_arr[] = {
|
||||||
&static_dbg_events
|
&static_dbg_events,
|
||||||
|
&static_dbg_route
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *static_debugs_conflines[] = {
|
const char *static_debugs_conflines[] = {
|
||||||
"debug static events"
|
"debug static events",
|
||||||
|
"debug static route"
|
||||||
};
|
};
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
@ -102,12 +105,14 @@ int static_debug_status_write(struct vty *vty)
|
|||||||
* Debug general internal events
|
* Debug general internal events
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void static_debug_set(int vtynode, bool onoff, bool events)
|
void static_debug_set(int vtynode, bool onoff, bool events, bool route)
|
||||||
{
|
{
|
||||||
uint32_t mode = DEBUG_NODE2MODE(vtynode);
|
uint32_t mode = DEBUG_NODE2MODE(vtynode);
|
||||||
|
|
||||||
if (events)
|
if (events)
|
||||||
DEBUG_MODE_SET(&static_dbg_events, mode, onoff);
|
DEBUG_MODE_SET(&static_dbg_events, mode, onoff);
|
||||||
|
if (route)
|
||||||
|
DEBUG_MODE_SET(&static_dbg_route, mode, onoff);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
/* staticd debugging records */
|
/* staticd debugging records */
|
||||||
extern struct debug static_dbg_events;
|
extern struct debug static_dbg_events;
|
||||||
|
extern struct debug static_dbg_route;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize staticd debugging.
|
* Initialize staticd debugging.
|
||||||
@ -67,7 +68,7 @@ int static_debug_status_write(struct vty *vty);
|
|||||||
* Debug general internal events
|
* Debug general internal events
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void static_debug_set(int vtynode, bool onoff, bool events);
|
void static_debug_set(int vtynode, bool onoff, bool events, bool route);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _STATIC_DEBUG_H */
|
#endif /* _STATIC_DEBUG_H */
|
||||||
|
@ -222,6 +222,13 @@ static int nexthop_mpls_label_stack_entry_create(struct nb_cb_create_args *args)
|
|||||||
|
|
||||||
switch (args->event) {
|
switch (args->event) {
|
||||||
case NB_EV_VALIDATE:
|
case NB_EV_VALIDATE:
|
||||||
|
if (!mpls_enabled) {
|
||||||
|
snprintf(
|
||||||
|
args->errmsg, args->errmsg_len,
|
||||||
|
"%% MPLS not turned on in kernel ignoring static route");
|
||||||
|
return NB_ERR_VALIDATION;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case NB_EV_PREPARE:
|
case NB_EV_PREPARE:
|
||||||
case NB_EV_ABORT:
|
case NB_EV_ABORT:
|
||||||
break;
|
break;
|
||||||
@ -481,6 +488,11 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_cr
|
|||||||
yang_dnode_get_string(args->dnode, "./prefix"));
|
yang_dnode_get_string(args->dnode, "./prefix"));
|
||||||
return NB_ERR;
|
return NB_ERR;
|
||||||
}
|
}
|
||||||
|
if (vrf->vrf_id == VRF_UNKNOWN)
|
||||||
|
snprintf(
|
||||||
|
args->errmsg, args->errmsg_len,
|
||||||
|
"Static Route to %s not installed currently because dependent config not fully available",
|
||||||
|
yang_dnode_get_string(args->dnode, "./prefix"));
|
||||||
nb_running_set_entry(args->dnode, rn);
|
nb_running_set_entry(args->dnode, rn);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -47,4 +47,10 @@ extern void static_nht_reset_start(struct prefix *nhp, afi_t afi,
|
|||||||
*/
|
*/
|
||||||
extern void static_nht_mark_state(struct prefix *sp, vrf_id_t vrf_id,
|
extern void static_nht_mark_state(struct prefix *sp, vrf_id_t vrf_id,
|
||||||
enum static_install_states state);
|
enum static_install_states state);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For the given nexthop, returns the string
|
||||||
|
*/
|
||||||
|
extern void static_get_nh_str(struct static_nexthop *nh, char *nexthop,
|
||||||
|
size_t size);
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,10 +27,13 @@
|
|||||||
#include <lib/vrf.h>
|
#include <lib/vrf.h>
|
||||||
#include <lib/memory.h>
|
#include <lib/memory.h>
|
||||||
|
|
||||||
|
#include "printfrr.h"
|
||||||
|
|
||||||
#include "static_vrf.h"
|
#include "static_vrf.h"
|
||||||
#include "static_routes.h"
|
#include "static_routes.h"
|
||||||
#include "static_memory.h"
|
#include "static_memory.h"
|
||||||
#include "static_zebra.h"
|
#include "static_zebra.h"
|
||||||
|
#include "static_debug.h"
|
||||||
|
|
||||||
DEFINE_MTYPE_STATIC(STATIC, STATIC_ROUTE, "Static Route Info");
|
DEFINE_MTYPE_STATIC(STATIC, STATIC_ROUTE, "Static Route Info");
|
||||||
DEFINE_MTYPE(STATIC, STATIC_PATH, "Static Path");
|
DEFINE_MTYPE(STATIC, STATIC_PATH, "Static Path");
|
||||||
@ -256,8 +259,12 @@ static_add_nexthop(struct route_node *rn, struct static_path *pn, safi_t safi,
|
|||||||
}
|
}
|
||||||
static_nexthop_list_add_after(&(pn->nexthop_list), cp, nh);
|
static_nexthop_list_add_after(&(pn->nexthop_list), cp, nh);
|
||||||
|
|
||||||
if (nh_svrf->vrf->vrf_id == VRF_UNKNOWN)
|
if (nh_svrf->vrf->vrf_id == VRF_UNKNOWN) {
|
||||||
|
zlog_warn(
|
||||||
|
"Static Route to %pFX not installed currently because dependent config not fully available",
|
||||||
|
&rn->p);
|
||||||
return nh;
|
return nh;
|
||||||
|
}
|
||||||
|
|
||||||
/* check whether interface exists in system & install if it does */
|
/* check whether interface exists in system & install if it does */
|
||||||
switch (nh->type) {
|
switch (nh->type) {
|
||||||
@ -301,11 +308,25 @@ void static_install_nexthop(struct route_node *rn, struct static_path *pn,
|
|||||||
|
|
||||||
nh_svrf = static_vty_get_unknown_vrf(nh_vrf);
|
nh_svrf = static_vty_get_unknown_vrf(nh_vrf);
|
||||||
|
|
||||||
if (!nh_svrf)
|
if (!nh_svrf) {
|
||||||
return;
|
char nexthop_str[NEXTHOP_STR];
|
||||||
|
|
||||||
if (nh_svrf->vrf->vrf_id == VRF_UNKNOWN)
|
static_get_nh_str(nh, nexthop_str, sizeof(nexthop_str));
|
||||||
|
DEBUGD(&static_dbg_route,
|
||||||
|
"Static Route %pFX not installed for %s vrf %s not ready",
|
||||||
|
&rn->p, nexthop_str, nh_vrf);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nh_svrf->vrf->vrf_id == VRF_UNKNOWN) {
|
||||||
|
char nexthop_str[NEXTHOP_STR];
|
||||||
|
|
||||||
|
static_get_nh_str(nh, nexthop_str, sizeof(nexthop_str));
|
||||||
|
DEBUGD(&static_dbg_route,
|
||||||
|
"Static Route %pFX not installed for %s vrf %s is unknown",
|
||||||
|
&rn->p, nexthop_str, nh_vrf);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* check whether interface exists in system & install if it does */
|
/* check whether interface exists in system & install if it does */
|
||||||
switch (nh->type) {
|
switch (nh->type) {
|
||||||
@ -760,3 +781,30 @@ void static_route_info_init(struct static_route_info *si)
|
|||||||
{
|
{
|
||||||
static_path_list_init(&(si->path_list));
|
static_path_list_init(&(si->path_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void static_get_nh_str(struct static_nexthop *nh, char *nexthop, size_t size)
|
||||||
|
{
|
||||||
|
switch (nh->type) {
|
||||||
|
case STATIC_IFNAME:
|
||||||
|
snprintfrr(nexthop, size, "ifindex : %s", nh->ifname);
|
||||||
|
break;
|
||||||
|
case STATIC_IPV4_GATEWAY:
|
||||||
|
snprintfrr(nexthop, size, "ip4 : %pI4", &nh->addr.ipv4);
|
||||||
|
break;
|
||||||
|
case STATIC_IPV4_GATEWAY_IFNAME:
|
||||||
|
snprintfrr(nexthop, size, "ip4-ifindex : %pI4 : %s",
|
||||||
|
&nh->addr.ipv4, nh->ifname);
|
||||||
|
break;
|
||||||
|
case STATIC_BLACKHOLE:
|
||||||
|
snprintfrr(nexthop, size, "blackhole : %d", nh->bh_type);
|
||||||
|
break;
|
||||||
|
case STATIC_IPV6_GATEWAY:
|
||||||
|
snprintfrr(nexthop, size, "ip6 : %pI6", &nh->addr.ipv6);
|
||||||
|
break;
|
||||||
|
case STATIC_IPV6_GATEWAY_IFNAME:
|
||||||
|
snprintfrr(nexthop, size, "ip6-ifindex : %pI6 : %s",
|
||||||
|
&nh->addr.ipv6, nh->ifname);
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@ -197,4 +197,17 @@ extern bool static_add_nexthop_validate(struct static_vrf *svrf,
|
|||||||
struct ipaddr *ipaddr);
|
struct ipaddr *ipaddr);
|
||||||
extern struct stable_info *static_get_stable_info(struct route_node *rn);
|
extern struct stable_info *static_get_stable_info(struct route_node *rn);
|
||||||
extern void static_route_info_init(struct static_route_info *si);
|
extern void static_route_info_init(struct static_route_info *si);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Max string return via API static_get_nh_str in size_t
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define NEXTHOP_STR (INET6_ADDRSTRLEN + INTERFACE_NAMSIZ + 25)
|
||||||
|
/*
|
||||||
|
* For the given nexthop, returns the string
|
||||||
|
* nexthop : returns the formatted string in nexthop
|
||||||
|
* size : max size of formatted string
|
||||||
|
*/
|
||||||
|
extern void static_get_nh_str(struct static_nexthop *nh, char *nexthop,
|
||||||
|
size_t size);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1111,19 +1111,17 @@ DEFPY_YANG(ipv6_route_vrf,
|
|||||||
ifname, flag, tag_str, distance_str, label,
|
ifname, flag, tag_str, distance_str, label,
|
||||||
table_str, false, color_str);
|
table_str, false, color_str);
|
||||||
}
|
}
|
||||||
DEFPY_YANG(debug_staticd,
|
DEFPY_YANG(debug_staticd, debug_staticd_cmd,
|
||||||
debug_staticd_cmd,
|
"[no] debug static [{events$events|route$route}]",
|
||||||
"[no] debug static [{events$events}]",
|
NO_STR DEBUG_STR STATICD_STR
|
||||||
NO_STR
|
"Debug events\n"
|
||||||
DEBUG_STR
|
"Debug route\n")
|
||||||
STATICD_STR
|
|
||||||
"Debug events\n")
|
|
||||||
{
|
{
|
||||||
/* If no specific category, change all */
|
/* If no specific category, change all */
|
||||||
if (strmatch(argv[argc - 1]->text, "static"))
|
if (strmatch(argv[argc - 1]->text, "static"))
|
||||||
static_debug_set(vty->node, !no, true);
|
static_debug_set(vty->node, !no, true, true);
|
||||||
else
|
else
|
||||||
static_debug_set(vty->node, !no, !!events);
|
static_debug_set(vty->node, !no, !!events, !!route);
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,7 @@
|
|||||||
#include "static_zebra.h"
|
#include "static_zebra.h"
|
||||||
#include "static_nht.h"
|
#include "static_nht.h"
|
||||||
#include "static_vty.h"
|
#include "static_vty.h"
|
||||||
|
#include "static_debug.h"
|
||||||
bool debug;
|
|
||||||
|
|
||||||
/* Zebra structure to hold current status. */
|
/* Zebra structure to hold current status. */
|
||||||
struct zclient *zclient;
|
struct zclient *zclient;
|
||||||
@ -313,9 +312,9 @@ void static_zebra_nht_register(struct route_node *rn, struct static_nexthop *nh,
|
|||||||
static_nht_hash_alloc);
|
static_nht_hash_alloc);
|
||||||
nhtd->refcount++;
|
nhtd->refcount++;
|
||||||
|
|
||||||
if (debug)
|
DEBUGD(&static_dbg_route,
|
||||||
zlog_debug("Registered nexthop(%pFX) for %pRN %d", &p,
|
"Registered nexthop(%pFX) for %pRN %d", &p, rn,
|
||||||
rn, nhtd->nh_num);
|
nhtd->nh_num);
|
||||||
if (nhtd->refcount > 1 && nhtd->nh_num) {
|
if (nhtd->refcount > 1 && nhtd->nh_num) {
|
||||||
static_nht_update(&rn->p, nhtd->nh, nhtd->nh_num, afi,
|
static_nht_update(&rn->p, nhtd->nh, nhtd->nh_num, afi,
|
||||||
nh->nh_vrf_id);
|
nh->nh_vrf_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user