summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gobgp/cmd/global.go8
-rw-r--r--table/path.go10
2 files changed, 13 insertions, 5 deletions
diff --git a/gobgp/cmd/global.go b/gobgp/cmd/global.go
index 3ef1f64a..8f257b4b 100644
--- a/gobgp/cmd/global.go
+++ b/gobgp/cmd/global.go
@@ -19,10 +19,12 @@ import (
"fmt"
api "github.com/osrg/gobgp/api"
"github.com/osrg/gobgp/packet"
+ "github.com/osrg/gobgp/table"
"github.com/spf13/cobra"
"golang.org/x/net/context"
"net"
"regexp"
+ "sort"
"strconv"
"strings"
)
@@ -284,14 +286,20 @@ func ParseFlowSpecArgs(rf bgp.RouteFamily, args []string) (bgp.AddrPrefixInterfa
return nil, nil, err
}
var nlri bgp.AddrPrefixInterface
+ var fnlri *bgp.FlowSpecNLRI
switch rf {
case bgp.RF_FS_IPv4_UC:
nlri = bgp.NewFlowSpecIPv4Unicast(cmp)
+ fnlri = &nlri.(*bgp.FlowSpecIPv4Unicast).FlowSpecNLRI
case bgp.RF_FS_IPv6_UC:
nlri = bgp.NewFlowSpecIPv6Unicast(cmp)
+ fnlri = &nlri.(*bgp.FlowSpecIPv6Unicast).FlowSpecNLRI
default:
return nil, nil, fmt.Errorf("invalid route family")
}
+ var comms table.FlowSpecComponents
+ comms = fnlri.Value
+ sort.Sort(comms)
return nlri, args[thenPos:], nil
}
diff --git a/table/path.go b/table/path.go
index 6c8ba87a..e54b9a03 100644
--- a/table/path.go
+++ b/table/path.go
@@ -60,17 +60,17 @@ type originInfo struct {
stale bool
}
-type components []bgp.FlowSpecComponentInterface
+type FlowSpecComponents []bgp.FlowSpecComponentInterface
-func (c components) Len() int {
+func (c FlowSpecComponents) Len() int {
return len(c)
}
-func (c components) Swap(i, j int) {
+func (c FlowSpecComponents) Swap(i, j int) {
c[i], c[j] = c[j], c[i]
}
-func (c components) Less(i, j int) bool {
+func (c FlowSpecComponents) Less(i, j int) bool {
return c[i].Type() < c[j].Type()
}
@@ -95,7 +95,7 @@ func NewPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, pa
}
if nlri != nil && (nlri.SAFI() == bgp.SAFI_FLOW_SPEC_UNICAST || nlri.SAFI() == bgp.SAFI_FLOW_SPEC_VPN) {
- var coms components
+ var coms FlowSpecComponents
var f *bgp.FlowSpecNLRI
switch nlri.(type) {
case *bgp.FlowSpecIPv4Unicast: