diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-02-24 14:13:22 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-02-24 14:13:22 +0900 |
commit | 00a592ef3a852c7fe5ac0c1ccac1f0c7345e5537 (patch) | |
tree | cef17628210926984814ae46d137b0c735f8be50 /table | |
parent | 61bf5455d8edbbf700bd6303599cc686a2676663 (diff) |
table: sort Flowspec components
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r-- | table/path.go | 34 |
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, |