]> git.puffer.fish Git - mirror/frr.git/commit
bfdd: fix session lookup 8006/head
authorIgor Ryzhov <iryzhov@nfware.com>
Tue, 2 Feb 2021 22:02:15 +0000 (01:02 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Wed, 3 Feb 2021 22:22:29 +0000 (01:22 +0300)
commit6cfcb775ef5d6004857b3d68e2bf757cf2a7a871
tree82ca006f97002907ab56b4a26f3cb4a6fa16e9a5
parentcc73a06499cc31b29e96e6b04ab6e7b181f09e28
bfdd: fix session lookup

BFD key has optional fields "local" and "ifname" which can be empty when
the BFD session is created. In this case, the hash key will be calculated
with these fields filled with zeroes.

Later, when we're looking for the BFD session using the key with fields
"local" and "ifname" populated with actual values, the hash key will be
different. To work around this issue, we're doing multiple hash lookups,
first with full key, then with fields "local" and "ifname" filled with
zeroes.

But there may be another case when the initial key has the actual values
for "local" and "ifname", but the key we're using for lookup has empty
values. This case is covered for IPv4 by using additional hash walk with
bfd_key_lookup_ignore_partial_walker function but is not covered for IPv6.

Instead of introducing more hacks and workarounds, the following solution
is proposed:
- the hash key is always calculated in bfd_key_hash_do using only
  required fields
- the hash data is compared in bfd_key_hash_cmp, taking into account the
  fact that fields "local" and "ifname" may be empty

Using this solution, it's enough to make only one hash lookup.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
bfdd/bfd.c