diff options
Diffstat (limited to 'table')
-rw-r--r-- | table/path.go | 62 | ||||
-rw-r--r-- | table/table.go | 22 |
2 files changed, 2 insertions, 82 deletions
diff --git a/table/path.go b/table/path.go index fa26f2e3..1cb81a91 100644 --- a/table/path.go +++ b/table/path.go @@ -22,8 +22,6 @@ import ( "math" "net" "sort" - "strconv" - "strings" "time" log "github.com/sirupsen/logrus" @@ -610,39 +608,7 @@ func (path *Path) GetAsPathLen() int { func (path *Path) GetAsString() string { s := bytes.NewBuffer(make([]byte, 0, 64)) if aspath := path.GetAsPath(); aspath != nil { - for i, param := range aspath.Value { - segType := param.GetType() - asList := param.GetAS() - if i != 0 { - s.WriteString(" ") - } - - sep := " " - switch segType { - case bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SEQ: - s.WriteString("(") - case bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SET: - s.WriteString("[") - sep = "," - case bgp.BGP_ASPATH_ATTR_TYPE_SET: - s.WriteString("{") - sep = "," - } - for j, as := range asList { - s.WriteString(fmt.Sprintf("%d", as)) - if j != len(asList)-1 { - s.WriteString(sep) - } - } - switch segType { - case bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SEQ: - s.WriteString(")") - case bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SET: - s.WriteString("]") - case bgp.BGP_ASPATH_ATTR_TYPE_SET: - s.WriteString("}") - } - } + return bgp.AsPathString(aspath) } return s.String() } @@ -677,31 +643,7 @@ func (path *Path) getAsListOfSpecificType(getAsSeq, getAsSet bool) []uint32 { } func (path *Path) GetLabelString() string { - label := "" - switch n := path.GetNlri().(type) { - case *bgp.LabeledIPAddrPrefix: - label = n.Labels.String() - case *bgp.LabeledIPv6AddrPrefix: - label = n.Labels.String() - case *bgp.LabeledVPNIPAddrPrefix: - label = n.Labels.String() - case *bgp.LabeledVPNIPv6AddrPrefix: - label = n.Labels.String() - case *bgp.EVPNNLRI: - switch route := n.RouteTypeData.(type) { - case *bgp.EVPNEthernetAutoDiscoveryRoute: - label = fmt.Sprintf("[%d]", route.Label) - case *bgp.EVPNMacIPAdvertisementRoute: - var l []string - for _, i := range route.Labels { - l = append(l, strconv.Itoa(int(i))) - } - label = fmt.Sprintf("[%s]", strings.Join(l, ",")) - case *bgp.EVPNIPPrefixRoute: - label = fmt.Sprintf("[%d]", route.Label) - } - } - return label + return bgp.LabelString(path.GetNlri()) } // PrependAsn prepends AS number. diff --git a/table/table.go b/table/table.go index 9d8edf40..82259b0f 100644 --- a/table/table.go +++ b/table/table.go @@ -18,7 +18,6 @@ package table import ( "fmt" "net" - "sort" "strings" "unsafe" @@ -190,27 +189,6 @@ func (t *Table) getOrCreateDest(nlri bgp.AddrPrefixInterface) *Destination { return dest } -func (t *Table) GetSortedDestinations() []*Destination { - results := make([]*Destination, 0, len(t.GetDestinations())) - switch t.routeFamily { - case bgp.RF_IPv4_UC, bgp.RF_IPv6_UC: - r := radix.New() - for _, dst := range t.GetDestinations() { - r.Insert(AddrToRadixkey(dst.nlri), dst) - } - r.Walk(func(s string, v interface{}) bool { - results = append(results, v.(*Destination)) - return false - }) - default: - for _, dst := range t.GetDestinations() { - results = append(results, dst) - } - sort.Sort(destinations(results)) - } - return results -} - func (t *Table) GetDestinations() map[string]*Destination { return t.destinations } |