From 412548f7e5363c502d26434bbc68ffa03e99c75e Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Fri, 17 Nov 2017 14:35:58 +0900 Subject: packet/bgp: Sort FlowSpec rules when decoding/creating Currently, we sort the FlowSpec rules when creating a new path containing the FlowSpec NLRI and when parsing CLI arguments for the FlowSpec rules. This patch moves sorting the rules into the inside of the "packet" module and sorts them when decoding binary and creating new NLRI. Signed-off-by: IWASE Yusuke --- table/path.go | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'table') diff --git a/table/path.go b/table/path.go index cf4603f2..9f041786 100644 --- a/table/path.go +++ b/table/path.go @@ -136,20 +136,6 @@ type Validation struct { UnmatchedLength []*ROA } -type FlowSpecComponents []bgp.FlowSpecComponentInterface - -func (c FlowSpecComponents) Len() int { - return len(c) -} - -func (c FlowSpecComponents) Swap(i, j int) { - c[i], c[j] = c[j], c[i] -} - -func (c FlowSpecComponents) Less(i, j int) bool { - return c[i].Type() < c[j].Type() -} - type Path struct { info *originInfo IsWithdraw bool @@ -173,25 +159,6 @@ 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 FlowSpecComponents - 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, -- cgit v1.2.3