diff options
author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2019-10-11 21:13:24 +0200 |
---|---|---|
committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2019-10-11 21:13:24 +0200 |
commit | ced291deb79f04ba7f6e17a0bbbc88fd95c47598 (patch) | |
tree | b15e7813f6f602ece09618ffb5dc96782939cb83 /bfdd | |
parent | bfdd: set session down after disabling it (diff) | |
download | frr-ced291deb79f04ba7f6e17a0bbbc88fd95c47598.tar.xz frr-ced291deb79f04ba7f6e17a0bbbc88fd95c47598.zip |
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>
Diffstat (limited to 'bfdd')
-rw-r--r-- | bfdd/bfd.c | 15 | ||||
-rw-r--r-- | bfdd/bfd.h | 8 | ||||
-rw-r--r-- | bfdd/ptm_adapter.c | 13 |
3 files changed, 5 insertions, 31 deletions
diff --git a/bfdd/bfd.c b/bfdd/bfd.c index 072f44dc3..90287114f 100644 --- a/bfdd/bfd.c +++ b/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); diff --git a/bfdd/bfd.h b/bfdd/bfd.h index cdec78d12..a9c8bd183 100644 --- a/bfdd/bfd.h +++ b/bfdd/bfd.h @@ -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; }; diff --git a/bfdd/ptm_adapter.c b/bfdd/ptm_adapter.c index 1b3219c23..df48bc2af 100644 --- a/bfdd/ptm_adapter.c +++ b/bfdd/ptm_adapter.c @@ -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) |