mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-13 06:49:13 +00:00
bfdd: simplify session observers code
Don't be selective about what to observe, always observe all possible aspects of the session that may change on run-time (i.e. bind address, interface and VRF existence). Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
parent
8ee0862e80
commit
ced291deb7
15
bfdd/bfd.c
15
bfdd/bfd.c
@ -1217,19 +1217,10 @@ int bs_observer_add(struct bfd_session *bs)
|
||||
struct bfd_session_observer *bso;
|
||||
|
||||
bso = XCALLOC(MTYPE_BFDD_SESSION_OBSERVER, sizeof(*bso));
|
||||
bso->bso_isaddress = false;
|
||||
bso->bso_bs = bs;
|
||||
bso->bso_isinterface = !BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_MH);
|
||||
if (bso->bso_isinterface)
|
||||
strlcpy(bso->bso_entryname, bs->key.ifname,
|
||||
sizeof(bso->bso_entryname));
|
||||
/* Handle socket binding failures caused by missing local addresses. */
|
||||
if (bs->sock == -1) {
|
||||
bso->bso_isaddress = true;
|
||||
bso->bso_addr.family = bs->key.family;
|
||||
memcpy(&bso->bso_addr.u.prefix, &bs->key.local,
|
||||
sizeof(bs->key.local));
|
||||
}
|
||||
bso->bso_addr.family = bs->key.family;
|
||||
memcpy(&bso->bso_addr.u.prefix, &bs->key.local,
|
||||
sizeof(bs->key.local));
|
||||
|
||||
TAILQ_INSERT_TAIL(&bglobal.bg_obslist, bso, bso_entry);
|
||||
|
||||
|
@ -274,12 +274,8 @@ struct bfd_state_str_list {
|
||||
|
||||
struct bfd_session_observer {
|
||||
struct bfd_session *bso_bs;
|
||||
bool bso_isinterface;
|
||||
bool bso_isaddress;
|
||||
union {
|
||||
char bso_entryname[MAXNAMELEN];
|
||||
struct prefix bso_addr;
|
||||
};
|
||||
char bso_entryname[MAXNAMELEN];
|
||||
struct prefix bso_addr;
|
||||
|
||||
TAILQ_ENTRY(bfd_session_observer) bso_entry;
|
||||
};
|
||||
|
@ -579,8 +579,6 @@ static void bfdd_sessions_enable_interface(struct interface *ifp)
|
||||
|
||||
TAILQ_FOREACH(bso, &bglobal.bg_obslist, bso_entry) {
|
||||
bs = bso->bso_bs;
|
||||
if (bso->bso_isinterface == false)
|
||||
continue;
|
||||
/* Interface name mismatch. */
|
||||
if (strcmp(ifp->name, bs->key.ifname))
|
||||
continue;
|
||||
@ -605,10 +603,6 @@ static void bfdd_sessions_disable_interface(struct interface *ifp)
|
||||
struct bfd_session *bs;
|
||||
|
||||
TAILQ_FOREACH(bso, &bglobal.bg_obslist, bso_entry) {
|
||||
if (bso->bso_isinterface == false)
|
||||
continue;
|
||||
|
||||
/* Interface name mismatch. */
|
||||
bs = bso->bso_bs;
|
||||
if (strcmp(ifp->name, bs->key.ifname))
|
||||
continue;
|
||||
@ -616,7 +610,6 @@ static void bfdd_sessions_disable_interface(struct interface *ifp)
|
||||
if (bs->sock == -1)
|
||||
continue;
|
||||
|
||||
/* Try to enable it. */
|
||||
bfd_session_disable(bs);
|
||||
|
||||
}
|
||||
@ -658,8 +651,6 @@ void bfdd_sessions_disable_vrf(struct vrf *vrf)
|
||||
struct bfd_session *bs;
|
||||
|
||||
TAILQ_FOREACH(bso, &bglobal.bg_obslist, bso_entry) {
|
||||
if (bso->bso_isinterface)
|
||||
continue;
|
||||
bs = bso->bso_bs;
|
||||
if (bs->key.vrfname[0] &&
|
||||
strcmp(vrf->name, bs->key.vrfname))
|
||||
@ -668,7 +659,6 @@ void bfdd_sessions_disable_vrf(struct vrf *vrf)
|
||||
if (bs->sock == -1)
|
||||
continue;
|
||||
|
||||
/* Try to enable it. */
|
||||
bfd_session_disable(bs);
|
||||
}
|
||||
}
|
||||
@ -701,9 +691,6 @@ static void bfdd_sessions_enable_address(struct connected *ifc)
|
||||
struct prefix prefix;
|
||||
|
||||
TAILQ_FOREACH(bso, &bglobal.bg_obslist, bso_entry) {
|
||||
if (bso->bso_isaddress == false)
|
||||
continue;
|
||||
|
||||
/* Skip enabled sessions. */
|
||||
bs = bso->bso_bs;
|
||||
if (bs->sock != -1)
|
||||
|
Loading…
Reference in New Issue
Block a user