mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-16 02:30:52 +00:00
Merge pull request #8101 from idryzhov/staticd-fixes
multiple staticd fixes
This commit is contained in:
commit
09145e272b
@ -140,7 +140,7 @@ static bool static_nexthop_create(struct nb_cb_create_args *args,
|
|||||||
pn = nb_running_get_entry(args->dnode, NULL, true);
|
pn = nb_running_get_entry(args->dnode, NULL, true);
|
||||||
rn = nb_running_get_entry(rn_dnode, NULL, true);
|
rn = nb_running_get_entry(rn_dnode, NULL, true);
|
||||||
|
|
||||||
if (!static_add_nexthop_validate(info->svrf, nh_type, &ipaddr))
|
if (!static_add_nexthop_validate(nh_vrf, nh_type, &ipaddr))
|
||||||
flog_warn(
|
flog_warn(
|
||||||
EC_LIB_NB_CB_CONFIG_VALIDATE,
|
EC_LIB_NB_CB_CONFIG_VALIDATE,
|
||||||
"Warning!! Local connected address is configured as Gateway IP((%s))",
|
"Warning!! Local connected address is configured as Gateway IP((%s))",
|
||||||
@ -148,18 +148,6 @@ static bool static_nexthop_create(struct nb_cb_create_args *args,
|
|||||||
"./gateway"));
|
"./gateway"));
|
||||||
nh = static_add_nexthop(rn, pn, info->safi, info->svrf, nh_type,
|
nh = static_add_nexthop(rn, pn, info->safi, info->svrf, nh_type,
|
||||||
&ipaddr, ifname, nh_vrf, 0);
|
&ipaddr, ifname, nh_vrf, 0);
|
||||||
if (!nh) {
|
|
||||||
char buf[SRCDEST2STR_BUFFER];
|
|
||||||
|
|
||||||
flog_warn(
|
|
||||||
EC_LIB_NB_CB_CONFIG_APPLY,
|
|
||||||
"%s : nh [%d:%s:%s:%s] nexthop creation failed",
|
|
||||||
srcdest_rnode2str(rn, buf, sizeof(buf)),
|
|
||||||
nh_type, ifname,
|
|
||||||
yang_dnode_get_string(args->dnode, "./gateway"),
|
|
||||||
nh_vrf);
|
|
||||||
return NB_ERR;
|
|
||||||
}
|
|
||||||
nb_running_set_entry(args->dnode, nh);
|
nb_running_set_entry(args->dnode, nh);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -138,20 +138,26 @@ void static_del_route(struct route_node *rn, safi_t safi,
|
|||||||
vrf_reset_user_cfged(svrf->vrf);
|
vrf_reset_user_cfged(svrf->vrf);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool static_add_nexthop_validate(struct static_vrf *svrf, static_types type,
|
bool static_add_nexthop_validate(const char *nh_vrf_name, static_types type,
|
||||||
struct ipaddr *ipaddr)
|
struct ipaddr *ipaddr)
|
||||||
{
|
{
|
||||||
|
struct vrf *vrf;
|
||||||
|
|
||||||
|
vrf = vrf_lookup_by_name(nh_vrf_name);
|
||||||
|
if (!vrf)
|
||||||
|
return true;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case STATIC_IPV4_GATEWAY:
|
case STATIC_IPV4_GATEWAY:
|
||||||
case STATIC_IPV4_GATEWAY_IFNAME:
|
case STATIC_IPV4_GATEWAY_IFNAME:
|
||||||
if (if_lookup_exact_address(&ipaddr->ipaddr_v4, AF_INET,
|
if (if_lookup_exact_address(&ipaddr->ipaddr_v4, AF_INET,
|
||||||
svrf->vrf->vrf_id))
|
vrf->vrf_id))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case STATIC_IPV6_GATEWAY:
|
case STATIC_IPV6_GATEWAY:
|
||||||
case STATIC_IPV6_GATEWAY_IFNAME:
|
case STATIC_IPV6_GATEWAY_IFNAME:
|
||||||
if (if_lookup_exact_address(&ipaddr->ipaddr_v6, AF_INET6,
|
if (if_lookup_exact_address(&ipaddr->ipaddr_v6, AF_INET6,
|
||||||
svrf->vrf->vrf_id))
|
vrf->vrf_id))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -214,10 +220,7 @@ static_add_nexthop(struct route_node *rn, struct static_path *pn, safi_t safi,
|
|||||||
|
|
||||||
route_lock_node(rn);
|
route_lock_node(rn);
|
||||||
|
|
||||||
nh_svrf = static_vty_get_unknown_vrf(nh_vrf);
|
nh_svrf = static_vrf_lookup_by_name(nh_vrf);
|
||||||
|
|
||||||
if (!nh_svrf)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* Make new static route structure. */
|
/* Make new static route structure. */
|
||||||
nh = XCALLOC(MTYPE_STATIC_NEXTHOP, sizeof(struct static_nexthop));
|
nh = XCALLOC(MTYPE_STATIC_NEXTHOP, sizeof(struct static_nexthop));
|
||||||
@ -225,8 +228,8 @@ static_add_nexthop(struct route_node *rn, struct static_path *pn, safi_t safi,
|
|||||||
nh->type = type;
|
nh->type = type;
|
||||||
nh->color = color;
|
nh->color = color;
|
||||||
|
|
||||||
nh->nh_vrf_id = nh_svrf->vrf->vrf_id;
|
nh->nh_vrf_id = nh_svrf ? nh_svrf->vrf->vrf_id : VRF_UNKNOWN;
|
||||||
strlcpy(nh->nh_vrfname, nh_svrf->vrf->name, sizeof(nh->nh_vrfname));
|
strlcpy(nh->nh_vrfname, nh_vrf, sizeof(nh->nh_vrfname));
|
||||||
|
|
||||||
if (ifname)
|
if (ifname)
|
||||||
strlcpy(nh->ifname, ifname, sizeof(nh->ifname));
|
strlcpy(nh->ifname, ifname, sizeof(nh->ifname));
|
||||||
@ -261,7 +264,7 @@ 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->nh_vrf_id == VRF_UNKNOWN) {
|
||||||
zlog_warn(
|
zlog_warn(
|
||||||
"Static Route to %pFX not installed currently because dependent config not fully available",
|
"Static Route to %pFX not installed currently because dependent config not fully available",
|
||||||
&rn->p);
|
&rn->p);
|
||||||
@ -275,7 +278,7 @@ static_add_nexthop(struct route_node *rn, struct static_path *pn, safi_t safi,
|
|||||||
break;
|
break;
|
||||||
case STATIC_IPV4_GATEWAY_IFNAME:
|
case STATIC_IPV4_GATEWAY_IFNAME:
|
||||||
case STATIC_IPV6_GATEWAY_IFNAME:
|
case STATIC_IPV6_GATEWAY_IFNAME:
|
||||||
ifp = if_lookup_by_name(ifname, nh_svrf->vrf->vrf_id);
|
ifp = if_lookup_by_name(ifname, nh->nh_vrf_id);
|
||||||
if (ifp && ifp->ifindex != IFINDEX_INTERNAL)
|
if (ifp && ifp->ifindex != IFINDEX_INTERNAL)
|
||||||
nh->ifindex = ifp->ifindex;
|
nh->ifindex = ifp->ifindex;
|
||||||
else
|
else
|
||||||
@ -288,7 +291,7 @@ static_add_nexthop(struct route_node *rn, struct static_path *pn, safi_t safi,
|
|||||||
nh->bh_type = STATIC_BLACKHOLE_NULL;
|
nh->bh_type = STATIC_BLACKHOLE_NULL;
|
||||||
break;
|
break;
|
||||||
case STATIC_IFNAME:
|
case STATIC_IFNAME:
|
||||||
ifp = if_lookup_by_name(ifname, nh_svrf->vrf->vrf_id);
|
ifp = if_lookup_by_name(ifname, nh->nh_vrf_id);
|
||||||
if (ifp && ifp->ifindex != IFINDEX_INTERNAL) {
|
if (ifp && ifp->ifindex != IFINDEX_INTERNAL) {
|
||||||
nh->ifindex = ifp->ifindex;
|
nh->ifindex = ifp->ifindex;
|
||||||
} else
|
} else
|
||||||
@ -306,28 +309,15 @@ void static_install_nexthop(struct route_node *rn, struct static_path *pn,
|
|||||||
struct static_vrf *svrf, const char *ifname,
|
struct static_vrf *svrf, const char *ifname,
|
||||||
static_types type, const char *nh_vrf)
|
static_types type, const char *nh_vrf)
|
||||||
{
|
{
|
||||||
struct static_vrf *nh_svrf;
|
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
|
|
||||||
nh_svrf = static_vty_get_unknown_vrf(nh_vrf);
|
if (nh->nh_vrf_id == VRF_UNKNOWN) {
|
||||||
|
|
||||||
if (!nh_svrf) {
|
|
||||||
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 not ready",
|
|
||||||
&rn->p, nexthop_str, nh_vrf);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nh_svrf->vrf->vrf_id == VRF_UNKNOWN) {
|
|
||||||
char nexthop_str[NEXTHOP_STR];
|
char nexthop_str[NEXTHOP_STR];
|
||||||
|
|
||||||
static_get_nh_str(nh, nexthop_str, sizeof(nexthop_str));
|
static_get_nh_str(nh, nexthop_str, sizeof(nexthop_str));
|
||||||
DEBUGD(&static_dbg_route,
|
DEBUGD(&static_dbg_route,
|
||||||
"Static Route %pFX not installed for %s vrf %s is unknown",
|
"Static Route %pFX not installed for %s vrf %s is unknown",
|
||||||
&rn->p, nexthop_str, nh_vrf);
|
&rn->p, nexthop_str, nh->nh_vrfname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +337,7 @@ void static_install_nexthop(struct route_node *rn, struct static_path *pn,
|
|||||||
static_install_path(rn, pn, safi, svrf);
|
static_install_path(rn, pn, safi, svrf);
|
||||||
break;
|
break;
|
||||||
case STATIC_IFNAME:
|
case STATIC_IFNAME:
|
||||||
ifp = if_lookup_by_name(ifname, nh_svrf->vrf->vrf_id);
|
ifp = if_lookup_by_name(ifname, nh->nh_vrf_id);
|
||||||
if (ifp && ifp->ifindex != IFINDEX_INTERNAL)
|
if (ifp && ifp->ifindex != IFINDEX_INTERNAL)
|
||||||
static_install_path(rn, pn, safi, svrf);
|
static_install_path(rn, pn, safi, svrf);
|
||||||
|
|
||||||
@ -359,13 +349,9 @@ int static_delete_nexthop(struct route_node *rn, struct static_path *pn,
|
|||||||
safi_t safi, struct static_vrf *svrf,
|
safi_t safi, struct static_vrf *svrf,
|
||||||
struct static_nexthop *nh)
|
struct static_nexthop *nh)
|
||||||
{
|
{
|
||||||
struct static_vrf *nh_svrf;
|
|
||||||
|
|
||||||
nh_svrf = static_vrf_lookup_by_name(nh->nh_vrfname);
|
|
||||||
|
|
||||||
static_nexthop_list_del(&(pn->nexthop_list), nh);
|
static_nexthop_list_del(&(pn->nexthop_list), nh);
|
||||||
|
|
||||||
if (nh_svrf->vrf->vrf_id == VRF_UNKNOWN)
|
if (nh->nh_vrf_id == VRF_UNKNOWN)
|
||||||
goto EXIT;
|
goto EXIT;
|
||||||
|
|
||||||
static_zebra_nht_register(rn, nh, false);
|
static_zebra_nht_register(rn, nh, false);
|
||||||
@ -523,6 +509,8 @@ static void static_enable_vrf(struct static_vrf *svrf,
|
|||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (nh->nh_vrf_id == VRF_UNKNOWN)
|
||||||
|
continue;
|
||||||
static_install_path(rn, pn, safi, svrf);
|
static_install_path(rn, pn, safi, svrf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ extern void static_del_path(struct route_node *rn, struct static_path *pn,
|
|||||||
safi_t safi, struct static_vrf *svrf);
|
safi_t safi, struct static_vrf *svrf);
|
||||||
|
|
||||||
extern void static_get_nh_type(static_types stype, char *type, size_t size);
|
extern void static_get_nh_type(static_types stype, char *type, size_t size);
|
||||||
extern bool static_add_nexthop_validate(struct static_vrf *svrf,
|
extern bool static_add_nexthop_validate(const char *nh_vrf_name,
|
||||||
static_types type,
|
static_types type,
|
||||||
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);
|
||||||
|
@ -261,25 +261,3 @@ void static_vrf_terminate(void)
|
|||||||
{
|
{
|
||||||
vrf_terminate();
|
vrf_terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct static_vrf *static_vty_get_unknown_vrf(const char *vrf_name)
|
|
||||||
{
|
|
||||||
struct static_vrf *svrf;
|
|
||||||
struct vrf *vrf;
|
|
||||||
|
|
||||||
svrf = static_vrf_lookup_by_name(vrf_name);
|
|
||||||
|
|
||||||
if (svrf)
|
|
||||||
return svrf;
|
|
||||||
|
|
||||||
vrf = vrf_get(VRF_UNKNOWN, vrf_name);
|
|
||||||
if (!vrf)
|
|
||||||
return NULL;
|
|
||||||
svrf = vrf->info;
|
|
||||||
if (!svrf)
|
|
||||||
return NULL;
|
|
||||||
/* Mark as having FRR configuration */
|
|
||||||
vrf_set_user_cfged(vrf);
|
|
||||||
|
|
||||||
return svrf;
|
|
||||||
}
|
|
||||||
|
@ -45,5 +45,4 @@ struct route_table *static_vrf_static_table(afi_t afi, safi_t safi,
|
|||||||
struct static_vrf *svrf);
|
struct static_vrf *svrf);
|
||||||
extern void static_vrf_terminate(void);
|
extern void static_vrf_terminate(void);
|
||||||
|
|
||||||
struct static_vrf *static_vty_get_unknown_vrf(const char *vrf_name);
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user