mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-14 13:29:12 +00:00
bgpd: modify bmp_bgp_update_vrf_status() API
The bgpbmp parameter is not used. Instead the bgp pointer, and the vrf state are used. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
3e63abfc95
commit
b68b4aa70e
@ -658,7 +658,7 @@ static int bmp_send_peerup_vrf(struct bmp *bmp)
|
|||||||
/* send unconditionally because state may has been set before the
|
/* send unconditionally because state may has been set before the
|
||||||
* session was up. and in this case the peer up has not been sent.
|
* session was up. and in this case the peer up has not been sent.
|
||||||
*/
|
*/
|
||||||
bmp_bgp_update_vrf_status(bmpbgp, vrf_state_unknown);
|
bmp_bgp_update_vrf_status(&bmpbgp->vrf_state, bmpbgp->bgp, vrf_state_unknown);
|
||||||
|
|
||||||
s = bmp_peerstate(bmpbgp->bgp->peer_self, bmpbgp->vrf_state == vrf_state_down);
|
s = bmp_peerstate(bmpbgp->bgp->peer_self, bmpbgp->vrf_state == vrf_state_down);
|
||||||
if (s) {
|
if (s) {
|
||||||
@ -2115,30 +2115,29 @@ static void bmp_bgp_peer_vrf(struct bmp_bgp_peer *bbpeer, struct bgp *bgp)
|
|||||||
*
|
*
|
||||||
* returns true if state has changed
|
* returns true if state has changed
|
||||||
*/
|
*/
|
||||||
bool bmp_bgp_update_vrf_status(struct bmp_bgp *bmpbgp, enum bmp_vrf_state force)
|
bool bmp_bgp_update_vrf_status(enum bmp_vrf_state *vrf_state, struct bgp *bgp,
|
||||||
|
enum bmp_vrf_state force)
|
||||||
{
|
{
|
||||||
enum bmp_vrf_state old_state;
|
enum bmp_vrf_state old_state;
|
||||||
struct bmp_bgp_peer *bbpeer;
|
struct bmp_bgp_peer *bbpeer;
|
||||||
struct peer *peer;
|
struct peer *peer;
|
||||||
struct vrf *vrf;
|
struct vrf *vrf;
|
||||||
struct bgp *bgp;
|
|
||||||
bool changed;
|
bool changed;
|
||||||
|
|
||||||
if (!bmpbgp || !bmpbgp->bgp)
|
if (!vrf_state || !bgp)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bgp = bmpbgp->bgp;
|
old_state = *vrf_state;
|
||||||
old_state = bmpbgp->vrf_state;
|
|
||||||
|
|
||||||
vrf = bgp_vrf_lookup_by_instance_type(bgp);
|
vrf = bgp_vrf_lookup_by_instance_type(bgp);
|
||||||
bmpbgp->vrf_state = force != vrf_state_unknown ? force
|
*vrf_state = force != vrf_state_unknown ? force
|
||||||
: vrf_is_enabled(vrf) ? vrf_state_up
|
: vrf_is_enabled(vrf) ? vrf_state_up
|
||||||
: vrf_state_down;
|
: vrf_state_down;
|
||||||
|
|
||||||
changed = old_state != bmpbgp->vrf_state;
|
changed = old_state != *vrf_state;
|
||||||
if (changed) {
|
if (changed) {
|
||||||
peer = bmpbgp->bgp->peer_self;
|
peer = bgp->peer_self;
|
||||||
if (bmpbgp->vrf_state == vrf_state_up) {
|
if (*vrf_state == vrf_state_up) {
|
||||||
bbpeer = bmp_bgp_peer_get(peer);
|
bbpeer = bmp_bgp_peer_get(peer);
|
||||||
bmp_bgp_peer_vrf(bbpeer, bgp);
|
bmp_bgp_peer_vrf(bbpeer, bgp);
|
||||||
} else {
|
} else {
|
||||||
@ -3383,7 +3382,7 @@ static int bmp_bgp_attribute_updated(struct bgp *bgp, bool withdraw)
|
|||||||
if (!bmpbgp)
|
if (!bmpbgp)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bmp_bgp_update_vrf_status(bmpbgp, vrf_state_unknown);
|
bmp_bgp_update_vrf_status(&bmpbgp->vrf_state, bgp, vrf_state_unknown);
|
||||||
|
|
||||||
if (bmpbgp->vrf_state == vrf_state_down)
|
if (bmpbgp->vrf_state == vrf_state_down)
|
||||||
/* do not send peer events, router id will not be enough to set state to up
|
/* do not send peer events, router id will not be enough to set state to up
|
||||||
@ -3413,7 +3412,10 @@ static int bmp_vrf_state_changed(struct bgp *bgp)
|
|||||||
{
|
{
|
||||||
struct bmp_bgp *bmpbgp = bmp_bgp_find(bgp);
|
struct bmp_bgp *bmpbgp = bmp_bgp_find(bgp);
|
||||||
|
|
||||||
if (!bmp_bgp_update_vrf_status(bmpbgp, vrf_state_unknown))
|
if (!bmpbgp)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!bmp_bgp_update_vrf_status(&bmpbgp->vrf_state, bgp, vrf_state_unknown))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
bmp_send_all_safe(bmpbgp,
|
bmp_send_all_safe(bmpbgp,
|
||||||
@ -3438,7 +3440,7 @@ static int bmp_vrf_itf_state_changed(struct bgp *bgp, struct interface *itf)
|
|||||||
|
|
||||||
bmpbgp = bmp_bgp_find(bgp);
|
bmpbgp = bmp_bgp_find(bgp);
|
||||||
new_state = if_is_up(itf) ? vrf_state_up : vrf_state_down;
|
new_state = if_is_up(itf) ? vrf_state_up : vrf_state_down;
|
||||||
if (bmp_bgp_update_vrf_status(bmpbgp, new_state))
|
if (bmpbgp && bmp_bgp_update_vrf_status(&bmpbgp->vrf_state, bgp, new_state))
|
||||||
bmp_send_all(bmpbgp, bmp_peerstate(bgp->peer_self, new_state == vrf_state_down));
|
bmp_send_all(bmpbgp, bmp_peerstate(bgp->peer_self, new_state == vrf_state_down));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -300,7 +300,8 @@ struct bmp_bgp {
|
|||||||
size_t mirror_qsizelimit;
|
size_t mirror_qsizelimit;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern bool bmp_bgp_update_vrf_status(struct bmp_bgp *bmpbgp, enum bmp_vrf_state force);
|
extern bool bmp_bgp_update_vrf_status(enum bmp_vrf_state *vrf_state, struct bgp *bgp,
|
||||||
|
enum bmp_vrf_state force);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
/* RFC7854 - 10.8 */
|
/* RFC7854 - 10.8 */
|
||||||
|
Loading…
Reference in New Issue
Block a user