MCPcopy
hub / github.com/osrg/gobgp / setDestination

Method setDestination

internal/pkg/table/table.go:672–701  ·  view source on GitHub ↗
(dst *destination)

Source from the content-addressed store, hash-verified

670}
671
672func (t *Table) setDestination(dst *destination) {
673 if collision := t.destinations.InsertUpdate(dst); collision {
674 // Get the first prefix in this collision bucket
675 shard := t.destinations.getShard(dst.GetNlri())
676 shard.mu.RLock()
677 key := tableKey(dst.GetNlri())
678 firstPrefix := ""
679 if dests, ok := shard.mp[key]; ok && len(dests) > 0 {
680 firstPrefix = dests[0].GetNlri().String()
681 }
682 shard.mu.RUnlock()
683
684 t.logger.Warn("insert collision detected",
685 slog.String("Topic", "Table"),
686 slog.String("Key", t.Family.String()),
687 slog.String("1stPrefix", firstPrefix),
688 slog.String("Prefix", dst.GetNlri().String()),
689 )
690 }
691
692 if nlri, ok := dst.nlri.(*bgp.EVPNNLRI); ok {
693 if macadv, ok := nlri.RouteTypeData.(*bgp.EVPNMacIPAdvertisementRoute); ok {
694 for _, path := range dst.knownPathList {
695 for _, ec := range path.GetRouteTargets() {
696 t.macIndex.Insert(ec, macadv.MacAddress, dst)
697 }
698 }
699 }
700 }
701}
702
703func (t *Table) Bests(id string, as uint32) []*Path {
704 paths := make([]*Path, 0)

Calls 7

tableKeyFunction · 0.85
InsertUpdateMethod · 0.80
getShardMethod · 0.80
GetRouteTargetsMethod · 0.80
InsertMethod · 0.80
StringMethod · 0.65
GetNlriMethod · 0.45

Tested by 14

TestLookupLongerFunction · 0.76
TestTableDeleteDestFunction · 0.76
TestTableSetDestinationsFunction · 0.76
TestTableGetDestinationsFunction · 0.76
TestTableKeyFunction · 0.76
TestTableSelectVPNv4Function · 0.76
TestTableSelectVPNv6Function · 0.76