[bt][gap] Be resilient to duplicate bonds in store

In some system configuration flows, it is possible for the same
underlying bond (i.e. security information associated with a local
host address - peer address tuple) to be associated with multiple Peer
Ids, and thus added to the Store component multiple times. This can
cause issues, as bt-host fails to restore a bond if it contains an
address already associated with a different PeerId.

To be resilient to this, we check for duplicate local address-peer
address combinations when loading bonds from the store during Stash
initialization. If the underlying security information is the same, we
pick one of the bonds to store in memory and delete the duplicates from
the store. If any of the duplicate address combinations contain
distinct underlying bonds, we fail the stash initialization process, as
this indicates an invalid state in the store.

We choose to handle this at bond-loading time instead of bond-storage
time because it is not as simple to distinguish between the allowed
"replace an old bond associated with this address" flow from "add two
distinct bonds for this address" during bond storage.

Bug: b/193454286
Test: Added `new_stash_filters_duplicate_bonds` and `new_stash_fails_
      loading_same_addrs_different_bond` to `bt-gap-unittests`.
Change-Id: I0099e09c87c7fb9e92a39c2a5da513f3f7db701d
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/560662
Fuchsia-Auto-Submit: Lucas Jenkins <lucasjenkins@google.com>
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Reviewed-by: Xo Wang <xow@google.com>
1 file changed
tree: dc66b30ac46c3da8643fbf40600bf37ee74b1d65
  1. boards/
  2. build/
  3. buildtools/
  4. bundles/
  5. docs/
  6. examples/
  7. garnet/
  8. products/
  9. scripts/
  10. sdk/
  11. src/
  12. third_party/
  13. tools/
  14. zircon/
  15. .clang-format
  16. .clang-tidy
  17. .git-blame-ignore-revs
  18. .gitattributes
  19. .gitignore
  20. .gn
  21. .style.yapf
  22. AUTHORS
  23. BUILD.gn
  24. CODE_OF_CONDUCT.md
  25. CONTRIBUTING.md
  26. LICENSE
  27. OWNERS
  28. PATENTS
  29. README.md
  30. rustfmt.toml
README.md

Fuchsia

Pink + Purple == Fuchsia (a new operating system)

What is Fuchsia?

Fuchsia is a modular, capability-based operating system. Fuchsia runs on modern 64-bit Intel and ARM processors.

Fuchsia is an open source project with a code of conduct that we expect everyone who interacts with the project to respect.

Read more about Fuchsia's principles.

How can I build and run Fuchsia?

See Getting Started.

Where can I learn more about Fuchsia?

See fuchsia.dev.