Adj-Rib: fix leak memory on withdraw unknown path#3310
Adj-Rib: fix leak memory on withdraw unknown path#3310taitov wants to merge 1 commit intoosrg:masterfrom
Conversation
|
Hi @fujita ! Please take a look at this little fix. |
There was a problem hiding this comment.
Pull request overview
Fixes an Adj-RIB destination retention issue where processing a withdraw for an unknown path could create/retain an empty destination entry until the Adj-RIB is cleared.
Changes:
- Delete the destination when handling a withdraw that results in an empty
knownPathList, even if the withdrawn path wasn’t previously present. - Add a regression test covering “withdraw unknown path” behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
internal/pkg/table/adj.go |
Ensures empty destinations are removed after withdraw processing regardless of whether a matching path was found. |
internal/pkg/table/adj_test.go |
Adds a test to confirm no destination entry remains after withdrawing an unknown path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| adj := NewAdjRib(logger, families) | ||
| adj.Update([]*Path{p1}) | ||
| assert.Equal(t, len(adj.table[family].destinations), 0) |
There was a problem hiding this comment.
This test reaches into the Table's unexported destinations field. Since the behavior being verified is “no destination was created/retained”, this can be asserted via the existing GetDestinations() accessor instead, which keeps the test resilient to internal representation changes while still failing in the pre-fix case (destination leaked with 0 paths).
| assert.Equal(t, len(adj.table[family].destinations), 0) | |
| assert.Equal(t, len(adj.table[family].GetDestinations()), 0) |
|
Nice catch! The Copilot comment is reasonable but trivial. So I pushed this fix. |
If you try to delete an unknown path from adj-rib, a key with an empty slice will be created, which will live until you delete adj-rib.