mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 05:18:47 +00:00
lib, bgpd, ospfd, pimd, zebra, rip, ripng, bfd: change if_update_to_new_vrf() api
vrf_id parameter is replaced with struct vrf * parameter. It is needed to create vrf structure before entering in the fuction. an error is generated in case the vrf parameter is missing. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
921a85ba8c
commit
da85f5e038
@ -698,13 +698,14 @@ static int bfdd_interface_update(ZAPI_CALLBACK_ARGS)
|
|||||||
static int bfdd_interface_vrf_update(ZAPI_CALLBACK_ARGS)
|
static int bfdd_interface_vrf_update(ZAPI_CALLBACK_ARGS)
|
||||||
{
|
{
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
|
struct vrf *nvrf;
|
||||||
vrf_id_t nvrfid;
|
vrf_id_t nvrfid;
|
||||||
|
|
||||||
ifp = zebra_interface_vrf_update_read(zclient->ibuf, vrf_id, &nvrfid);
|
ifp = zebra_interface_vrf_update_read(zclient->ibuf, vrf_id, &nvrfid);
|
||||||
if (ifp == NULL)
|
if (ifp == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
nvrf = vrf_lookup_by_id(nvrfid);
|
||||||
if_update_to_new_vrf(ifp, nvrfid);
|
if_update_to_new_vrf(ifp, nvrf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -503,7 +503,7 @@ static int bgp_interface_vrf_update(ZAPI_CALLBACK_ARGS)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if_update_to_new_vrf(ifp, new_vrf_id);
|
if_update_to_new_vrf(ifp, vrf_lookup_by_id(new_vrf_id));
|
||||||
|
|
||||||
bgp = bgp_lookup_by_vrf_id(new_vrf_id);
|
bgp = bgp_lookup_by_vrf_id(new_vrf_id);
|
||||||
if (!bgp)
|
if (!bgp)
|
||||||
|
18
lib/if.c
18
lib/if.c
@ -157,11 +157,18 @@ struct interface *if_create(const char *name, struct vrf *vrf)
|
|||||||
return ifp;
|
return ifp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create new interface structure. */
|
/* Create new interface structure.
|
||||||
void if_update_to_new_vrf(struct interface *ifp, vrf_id_t vrf_id)
|
* vrf must be created outside of this routing
|
||||||
|
*/
|
||||||
|
void if_update_to_new_vrf(struct interface *ifp, struct vrf *vrf)
|
||||||
{
|
{
|
||||||
struct vrf *old_vrf, *vrf;
|
struct vrf *old_vrf;
|
||||||
|
|
||||||
|
if (!vrf) {
|
||||||
|
flog_err(EC_LIB_INTERFACE, "interface %s. Unknown VRF",
|
||||||
|
ifp->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
/* remove interface from old master vrf list */
|
/* remove interface from old master vrf list */
|
||||||
old_vrf = vrf_lookup_by_id(ifp->vrf_id);
|
old_vrf = vrf_lookup_by_id(ifp->vrf_id);
|
||||||
if (old_vrf) {
|
if (old_vrf) {
|
||||||
@ -170,8 +177,7 @@ void if_update_to_new_vrf(struct interface *ifp, vrf_id_t vrf_id)
|
|||||||
IFINDEX_RB_REMOVE(old_vrf, ifp);
|
IFINDEX_RB_REMOVE(old_vrf, ifp);
|
||||||
}
|
}
|
||||||
|
|
||||||
ifp->vrf_id = vrf_id;
|
ifp->vrf_id = vrf->vrf_id;
|
||||||
vrf = vrf_get(ifp->vrf_id, NULL);
|
|
||||||
|
|
||||||
IFNAME_RB_INSERT(vrf, ifp);
|
IFNAME_RB_INSERT(vrf, ifp);
|
||||||
if (ifp->ifindex != IFINDEX_INTERNAL)
|
if (ifp->ifindex != IFINDEX_INTERNAL)
|
||||||
@ -439,7 +445,7 @@ struct interface *if_get_by_name(const char *name, struct vrf *vrf)
|
|||||||
/* If it came from the kernel or by way of zclient,
|
/* If it came from the kernel or by way of zclient,
|
||||||
* believe it and update the ifp accordingly.
|
* believe it and update the ifp accordingly.
|
||||||
*/
|
*/
|
||||||
if_update_to_new_vrf(ifp, vrf->vrf_id);
|
if_update_to_new_vrf(ifp, vrf);
|
||||||
return ifp;
|
return ifp;
|
||||||
}
|
}
|
||||||
return if_create(name, vrf);
|
return if_create(name, vrf);
|
||||||
|
2
lib/if.h
2
lib/if.h
@ -479,7 +479,7 @@ extern int if_cmp_name_func(const char *p1, const char *p2);
|
|||||||
* This is useful for vrf route-leaking. So more than anything
|
* This is useful for vrf route-leaking. So more than anything
|
||||||
* else think before you use VRF_UNKNOWN
|
* else think before you use VRF_UNKNOWN
|
||||||
*/
|
*/
|
||||||
extern void if_update_to_new_vrf(struct interface *, vrf_id_t vrf_id);
|
extern void if_update_to_new_vrf(struct interface *, struct vrf *vrf);
|
||||||
extern struct interface *if_create(const char *name, struct vrf *vrf);
|
extern struct interface *if_create(const char *name, struct vrf *vrf);
|
||||||
extern struct interface *if_lookup_by_index(ifindex_t, vrf_id_t vrf_id);
|
extern struct interface *if_lookup_by_index(ifindex_t, vrf_id_t vrf_id);
|
||||||
extern struct interface *if_lookup_exact_address(void *matchaddr, int family,
|
extern struct interface *if_lookup_exact_address(void *matchaddr, int family,
|
||||||
|
@ -366,7 +366,7 @@ static int ospf_interface_vrf_update(ZAPI_CALLBACK_ARGS)
|
|||||||
ospf_vrf_id_to_name(new_vrf_id), new_vrf_id);
|
ospf_vrf_id_to_name(new_vrf_id), new_vrf_id);
|
||||||
|
|
||||||
/*if_update(ifp, ifp->name, strlen(ifp->name), new_vrf_id);*/
|
/*if_update(ifp, ifp->name, strlen(ifp->name), new_vrf_id);*/
|
||||||
if_update_to_new_vrf(ifp, new_vrf_id);
|
if_update_to_new_vrf(ifp, vrf_lookup_by_id(new_vrf_id));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ static int pim_zebra_interface_vrf_update(ZAPI_CALLBACK_ARGS)
|
|||||||
__PRETTY_FUNCTION__,
|
__PRETTY_FUNCTION__,
|
||||||
ifp->name, vrf_id, new_vrf_id);
|
ifp->name, vrf_id, new_vrf_id);
|
||||||
|
|
||||||
if_update_to_new_vrf(ifp, new_vrf_id);
|
if_update_to_new_vrf(ifp, vrf_lookup_by_id(new_vrf_id));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -468,17 +468,20 @@ int rip_interface_vrf_update(ZAPI_CALLBACK_ARGS)
|
|||||||
{
|
{
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
vrf_id_t new_vrf_id;
|
vrf_id_t new_vrf_id;
|
||||||
|
struct vrf *new_vrf;
|
||||||
|
|
||||||
ifp = zebra_interface_vrf_update_read(zclient->ibuf, vrf_id,
|
ifp = zebra_interface_vrf_update_read(zclient->ibuf, vrf_id,
|
||||||
&new_vrf_id);
|
&new_vrf_id);
|
||||||
if (!ifp)
|
if (!ifp)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
new_vrf = vrf_lookup_by_id(new_vrf_id);
|
||||||
|
|
||||||
if (IS_RIP_DEBUG_ZEBRA)
|
if (IS_RIP_DEBUG_ZEBRA)
|
||||||
zlog_debug("interface %s VRF change vrf_id %u new vrf id %u",
|
zlog_debug("interface %s VRF change vrf_id %u new vrf id %u",
|
||||||
ifp->name, vrf_id, new_vrf_id);
|
ifp->name, vrf_id, new_vrf_id);
|
||||||
|
|
||||||
if_update_to_new_vrf(ifp, new_vrf_id);
|
if_update_to_new_vrf(ifp, new_vrf);
|
||||||
rip_interface_sync(ifp);
|
rip_interface_sync(ifp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -314,17 +314,20 @@ int ripng_interface_vrf_update(ZAPI_CALLBACK_ARGS)
|
|||||||
{
|
{
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
vrf_id_t new_vrf_id;
|
vrf_id_t new_vrf_id;
|
||||||
|
struct vrf *new_vrf;
|
||||||
|
|
||||||
ifp = zebra_interface_vrf_update_read(zclient->ibuf, vrf_id,
|
ifp = zebra_interface_vrf_update_read(zclient->ibuf, vrf_id,
|
||||||
&new_vrf_id);
|
&new_vrf_id);
|
||||||
if (!ifp)
|
if (!ifp)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
new_vrf = vrf_lookup_by_id(new_vrf_id);
|
||||||
|
|
||||||
if (IS_RIPNG_DEBUG_ZEBRA)
|
if (IS_RIPNG_DEBUG_ZEBRA)
|
||||||
zlog_debug("interface %s VRF change vrf_id %u new vrf id %u",
|
zlog_debug("interface %s VRF change vrf_id %u new vrf id %u",
|
||||||
ifp->name, vrf_id, new_vrf_id);
|
ifp->name, vrf_id, new_vrf_id);
|
||||||
|
|
||||||
if_update_to_new_vrf(ifp, new_vrf_id);
|
if_update_to_new_vrf(ifp, new_vrf);
|
||||||
ripng_interface_sync(ifp);
|
ripng_interface_sync(ifp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1233,7 +1233,7 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
|
|||||||
} else {
|
} else {
|
||||||
/* pre-configured interface, learnt now */
|
/* pre-configured interface, learnt now */
|
||||||
if (ifp->vrf_id != vrf_id)
|
if (ifp->vrf_id != vrf_id)
|
||||||
if_update_to_new_vrf(ifp, vrf_id);
|
if_update_to_new_vrf(ifp, vrf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update interface information. */
|
/* Update interface information. */
|
||||||
|
@ -768,6 +768,7 @@ void if_delete_update(struct interface *ifp)
|
|||||||
void if_handle_vrf_change(struct interface *ifp, vrf_id_t vrf_id)
|
void if_handle_vrf_change(struct interface *ifp, vrf_id_t vrf_id)
|
||||||
{
|
{
|
||||||
vrf_id_t old_vrf_id;
|
vrf_id_t old_vrf_id;
|
||||||
|
struct vrf *vrf = vrf_lookup_by_id(vrf_id);
|
||||||
|
|
||||||
old_vrf_id = ifp->vrf_id;
|
old_vrf_id = ifp->vrf_id;
|
||||||
|
|
||||||
@ -785,7 +786,7 @@ void if_handle_vrf_change(struct interface *ifp, vrf_id_t vrf_id)
|
|||||||
zebra_interface_vrf_update_del(ifp, vrf_id);
|
zebra_interface_vrf_update_del(ifp, vrf_id);
|
||||||
|
|
||||||
/* update VRF */
|
/* update VRF */
|
||||||
if_update_to_new_vrf(ifp, vrf_id);
|
if_update_to_new_vrf(ifp, vrf);
|
||||||
|
|
||||||
/* Send out notification on interface VRF change. */
|
/* Send out notification on interface VRF change. */
|
||||||
/* This is to issue an ADD, if needed. */
|
/* This is to issue an ADD, if needed. */
|
||||||
|
Loading…
Reference in New Issue
Block a user