diff options
author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2019-02-01 12:22:00 +0100 |
---|---|---|
committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2019-02-14 17:17:29 +0100 |
commit | b333abc2959e492ee2c5ae903aaa6d857fdb7cdd (patch) | |
tree | 7bd5b7538907177400de1fb3f636b384dadcf4cf /bfdd/ptm_adapter.c | |
parent | bfdd: slow down on peer connection loss (diff) | |
download | frr-b333abc2959e492ee2c5ae903aaa6d857fdb7cdd.tar.xz frr-b333abc2959e492ee2c5ae903aaa6d857fdb7cdd.zip |
bfdd: refactor session lookup
Use internal data to lookup sessions. This approach has two main
advantages:
* it uses less memory because it doesn't use strings for interface /
vrf, it uses OS indexes instead;
* prepares code to support VRF;
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'bfdd/ptm_adapter.c')
-rw-r--r-- | bfdd/ptm_adapter.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/bfdd/ptm_adapter.c b/bfdd/ptm_adapter.c index a57167376..8ce33e527 100644 --- a/bfdd/ptm_adapter.c +++ b/bfdd/ptm_adapter.c @@ -618,6 +618,24 @@ static int bfdd_interface_update(int cmd, struct zclient *zc, uint16_t len, return 0; } +static int bfdd_interface_vrf_update(int command __attribute__((__unused__)), + struct zclient *zclient, + zebra_size_t length + __attribute__((__unused__)), + vrf_id_t vrfid) +{ + struct interface *ifp; + vrf_id_t nvrfid; + + ifp = zebra_interface_vrf_update_read(zclient->ibuf, vrfid, &nvrfid); + if (ifp == NULL) + return 0; + + if_update_to_new_vrf(ifp, nvrfid); + + return 0; +} + void bfdd_zclient_init(struct zebra_privs_t *bfdd_priv) { zclient = zclient_new(master, &zclient_options_default); @@ -637,6 +655,9 @@ void bfdd_zclient_init(struct zebra_privs_t *bfdd_priv) /* Learn interfaces from zebra instead of the OS. */ zclient->interface_add = bfdd_interface_update; zclient->interface_delete = bfdd_interface_update; + + /* Learn about interface VRF. */ + zclient->interface_vrf_update = bfdd_interface_vrf_update; } void bfdd_zclient_stop(void) |