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
4 changes: 4 additions & 0 deletions internal/pkg/table/table_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ func ProcessMessage(m *bgp.BGPMessage, peerInfo *PeerInfo, timestamp time.Time,
nexthop := reach.Nexthop
family := bgp.NewFamily(reach.AFI, reach.SAFI)

if nexthop.IsUnspecified() && reach.LinkLocalNexthop.IsValid() && !reach.LinkLocalNexthop.IsUnspecified() {
nexthop = reach.LinkLocalNexthop
}

for _, nlri := range reach.Value {
// when build path from reach
// reachAttrs might not contain next_hop if `attrs` does not have one
Expand Down
23 changes: 23 additions & 0 deletions internal/pkg/table/table_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,29 @@ func TestProcessBGPUpdate_8_mpunreach_path_ipv6(t *testing.T) {
assert.Equal(t, expectedNexthop, path.GetNexthop().String())
}

func TestProcessBGPUpdate_select_linklocal_nexthop_over_unspecified_global(t *testing.T) {
tm := NewTableManager(logger, []bgp.Family{bgp.RF_IPv6_UC})

origin1 := bgp.NewPathAttributeOrigin(0)
aspath1 := createAsPathAttribute([]uint32{65000})
nlri1, _ := bgp.NewIPAddrPrefix(netip.MustParsePrefix("2001:123:123:1::/64"))
mpReach1, _ := bgp.NewPathAttributeMpReachNLRI(bgp.RF_IPv6_UC, []bgp.PathNLRI{{NLRI: nlri1}}, netip.MustParseAddr("::"), netip.MustParseAddr("fe80::ade0"))
med1 := bgp.NewPathAttributeMultiExitDisc(200)
localpref1 := bgp.NewPathAttributeLocalPref(100)

pathAttributes1 := []bgp.PathAttributeInterface{
mpReach1, origin1, aspath1, med1, localpref1,
}

bgpMessage1 := bgp.NewBGPUpdateMessage(nil, pathAttributes1, nil)

peer1 := peerR1()
pList, err := tm.ProcessUpdate(peer1, bgpMessage1)
assert.Equal(t, 1, len(pList))
assert.Equal(t, pList[0].GetNexthop(), netip.MustParseAddr("fe80::ade0"))
assert.NoError(t, err)
}

// handle bestpath lost
func TestProcessBGPUpdate_bestpath_lost_ipv4(t *testing.T) {
tm := NewTableManager(logger, []bgp.Family{bgp.RF_IPv4_UC})
Expand Down