summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--table/path.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/table/path.go b/table/path.go
index 9ed5b78b..6c8ba87a 100644
--- a/table/path.go
+++ b/table/path.go
@@ -24,6 +24,7 @@ import (
"github.com/osrg/gobgp/packet"
"math"
"net"
+ "sort"
"time"
)
@@ -59,6 +60,20 @@ type originInfo struct {
stale bool
}
+type components []bgp.FlowSpecComponentInterface
+
+func (c components) Len() int {
+ return len(c)
+}
+
+func (c components) Swap(i, j int) {
+ c[i], c[j] = c[j], c[i]
+}
+
+func (c components) Less(i, j int) bool {
+ return c[i].Type() < c[j].Type()
+}
+
type Path struct {
info *originInfo
IsWithdraw bool
@@ -79,6 +94,25 @@ func NewPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, pa
return nil
}
+ if nlri != nil && (nlri.SAFI() == bgp.SAFI_FLOW_SPEC_UNICAST || nlri.SAFI() == bgp.SAFI_FLOW_SPEC_VPN) {
+ var coms components
+ var f *bgp.FlowSpecNLRI
+ switch nlri.(type) {
+ case *bgp.FlowSpecIPv4Unicast:
+ f = &nlri.(*bgp.FlowSpecIPv4Unicast).FlowSpecNLRI
+ case *bgp.FlowSpecIPv4VPN:
+ f = &nlri.(*bgp.FlowSpecIPv4VPN).FlowSpecNLRI
+ case *bgp.FlowSpecIPv6Unicast:
+ f = &nlri.(*bgp.FlowSpecIPv6Unicast).FlowSpecNLRI
+ case *bgp.FlowSpecIPv6VPN:
+ f = &nlri.(*bgp.FlowSpecIPv6VPN).FlowSpecNLRI
+ }
+ if f != nil {
+ coms = f.Value
+ sort.Sort(coms)
+ }
+ }
+
return &Path{
info: &originInfo{
nlri: nlri,