mirror of
https://github.com/osrg/gobgp.git
synced 2024-05-11 05:55:10 +00:00
cli: delete duplicated code
Signed-off-by: FUJITA Tomonori <[email protected]>
This commit is contained in:
@@ -219,20 +219,6 @@ func ApiStruct2Path(p *gobgpapi.Path) ([]*Path, error) {
|
||||
return paths, nil
|
||||
}
|
||||
|
||||
type pathAttrs []bgp.PathAttributeInterface
|
||||
|
||||
func (p pathAttrs) Len() int {
|
||||
return len(p)
|
||||
}
|
||||
|
||||
func (p pathAttrs) Swap(i, j int) {
|
||||
p[i], p[j] = p[j], p[i]
|
||||
}
|
||||
|
||||
func (p pathAttrs) Less(i, j int) bool {
|
||||
return p[i].GetType() < p[j].GetType()
|
||||
}
|
||||
|
||||
type paths []*Path
|
||||
|
||||
func (p paths) Len() int {
|
||||
|
||||
+1
-1
@@ -498,7 +498,7 @@ func ParsePath(rf bgp.RouteFamily, args []string) (*api.Path, error) {
|
||||
var nlri bgp.AddrPrefixInterface
|
||||
var extcomms []string
|
||||
var err error
|
||||
attrs := pathAttrs(make([]bgp.PathAttributeInterface, 0, 1))
|
||||
attrs := table.PathAttrs(make([]bgp.PathAttributeInterface, 0, 1))
|
||||
|
||||
path := &api.Path{
|
||||
Pattrs: make([][]byte, 0),
|
||||
|
||||
+6
-8
@@ -398,17 +398,17 @@ func (path *Path) GetNlri() bgp.AddrPrefixInterface {
|
||||
return path.OriginInfo().nlri
|
||||
}
|
||||
|
||||
type attrs []bgp.PathAttributeInterface
|
||||
type PathAttrs []bgp.PathAttributeInterface
|
||||
|
||||
func (a attrs) Len() int {
|
||||
func (a PathAttrs) Len() int {
|
||||
return len(a)
|
||||
}
|
||||
|
||||
func (a attrs) Swap(i, j int) {
|
||||
func (a PathAttrs) Swap(i, j int) {
|
||||
a[i], a[j] = a[j], a[i]
|
||||
}
|
||||
|
||||
func (a attrs) Less(i, j int) bool {
|
||||
func (a PathAttrs) Less(i, j int) bool {
|
||||
return a[i].GetType() < a[j].GetType()
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ func (path *Path) GetPathAttrs() []bgp.PathAttributeInterface {
|
||||
deleted.Flag(uint(t))
|
||||
}
|
||||
if p.parent == nil {
|
||||
list := make([]bgp.PathAttributeInterface, 0, len(p.pathAttrs))
|
||||
list := PathAttrs(make([]bgp.PathAttributeInterface, 0, len(p.pathAttrs)))
|
||||
// we assume that the original pathAttrs are
|
||||
// in order, that is, other bgp speakers send
|
||||
// attributes in order.
|
||||
@@ -440,9 +440,7 @@ func (path *Path) GetPathAttrs() []bgp.PathAttributeInterface {
|
||||
for _, m := range modified {
|
||||
list = append(list, m)
|
||||
}
|
||||
var sorted attrs
|
||||
sorted = list
|
||||
sort.Sort(sorted)
|
||||
sort.Sort(list)
|
||||
}
|
||||
return list
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user