Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/pkg/table/adj.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ func (adj *AdjRib) Drop(rfList []bgp.Family) []*Path {
l := make([]*Path, 0, adj.Count(rfList))
adj.walk(rfList, func(d *destination) bool {
for _, p := range d.knownPathList {
// Rejected paths were never installed in the local RIB; do not
// emit withdrawals for them (avoids "No matching path for withdraw").
if p.IsRejected() {
continue
}
w := p.Clone(true)
w.SetDropped(true)
l = append(l, w)
Expand Down
26 changes: 26 additions & 0 deletions internal/pkg/table/adj_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,32 @@ func TestStale(t *testing.T) {
assert.Equal(t, 1, len(adj.table[family].GetDestinations()))
}

func TestDropSkipsRejected(t *testing.T) {
pi := &PeerInfo{}
attrs := []bgp.PathAttributeInterface{bgp.NewPathAttributeOrigin(0)}

nlri1, _ := bgp.NewIPAddrPrefix(netip.MustParsePrefix("20.20.10.0/24"))
p1 := NewPath(bgp.RF_IPv4_UC, pi, bgp.PathNLRI{NLRI: nlri1}, false, attrs, time.Now(), false)
nlri2, _ := bgp.NewIPAddrPrefix(netip.MustParsePrefix("20.20.20.0/24"))
p2 := NewPath(bgp.RF_IPv4_UC, pi, bgp.PathNLRI{NLRI: nlri2}, false, attrs, time.Now(), false)
p2.SetRejected(true)

family := p1.GetFamily()
families := []bgp.Family{family}

adj := NewAdjRib(slog.Default(), families)
adj.Update([]*Path{p1, p2})
assert.Equal(t, 2, adj.Count(families))
assert.Equal(t, 1, adj.Accepted(families))

// Drop must not emit withdrawals for rejected paths that never entered the RIB.
dropped := adj.Drop(families)
assert.Equal(t, 1, len(dropped))
assert.False(t, dropped[0].IsRejected())
assert.Equal(t, 0, adj.Count(families))
assert.Equal(t, 0, adj.Accepted(families))
}

func TestLLGRStale(t *testing.T) {
pi := &PeerInfo{}
attrs := []bgp.PathAttributeInterface{bgp.NewPathAttributeOrigin(0)}
Expand Down