summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp/bgp_test.go
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-11-17 14:35:58 +0900
committerIWASE Yusuke <iwase.yusuke0@gmail.com>2017-11-24 11:45:20 +0900
commit412548f7e5363c502d26434bbc68ffa03e99c75e (patch)
treeed801e9247f263f38dd12e6ab96b05cdcb804fce /packet/bgp/bgp_test.go
parentd3adb6d680a409d00791f95445f75689338f56af (diff)
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 <iwase.yusuke0@gmail.com>
Diffstat (limited to 'packet/bgp/bgp_test.go')
-rw-r--r--packet/bgp/bgp_test.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/packet/bgp/bgp_test.go b/packet/bgp/bgp_test.go
index c3833fa8..d3e2719f 100644
--- a/packet/bgp/bgp_test.go
+++ b/packet/bgp/bgp_test.go
@@ -787,20 +787,21 @@ func Test_CompareFlowSpecNLRI(t *testing.T) {
assert := assert.New(t)
cmp, err := ParseFlowSpecComponents(RF_FS_IPv4_UC, "destination 10.0.0.2/32 source 10.0.0.1/32 destination-port ==3128 protocol tcp")
assert.Nil(err)
- n1 := &FlowSpecNLRI{Value: cmp, rf: RF_FS_IPv4_UC}
+ // Note: Use NewFlowSpecIPv4Unicast() for the consistent ordered rules.
+ n1 := NewFlowSpecIPv4Unicast(cmp).FlowSpecNLRI
cmp, err = ParseFlowSpecComponents(RF_FS_IPv4_UC, "source 10.0.0.0/24 destination-port ==3128 protocol tcp")
assert.Nil(err)
- n2 := &FlowSpecNLRI{Value: cmp, rf: RF_FS_IPv4_UC}
+ n2 := NewFlowSpecIPv4Unicast(cmp).FlowSpecNLRI
+ r, err := CompareFlowSpecNLRI(&n1, &n2)
+ assert.Nil(err)
+ assert.True(r > 0)
cmp, err = ParseFlowSpecComponents(RF_FS_IPv4_UC, "source 10.0.0.9/32 port ==80 ==8080 destination-port >8080&<8080 ==3128 source-port >1024 protocol ==udp ==tcp")
- n3 := &FlowSpecNLRI{Value: cmp, rf: RF_FS_IPv4_UC}
+ n3 := NewFlowSpecIPv4Unicast(cmp).FlowSpecNLRI
assert.Nil(err)
cmp, err = ParseFlowSpecComponents(RF_FS_IPv4_UC, "destination 192.168.0.2/32")
- n4 := &FlowSpecNLRI{Value: cmp, rf: RF_FS_IPv4_UC}
+ n4 := NewFlowSpecIPv4Unicast(cmp).FlowSpecNLRI
assert.Nil(err)
- r, err := CompareFlowSpecNLRI(n1, n2)
- assert.Nil(err)
- assert.True(r > 0)
- r, err = CompareFlowSpecNLRI(n3, n4)
+ r, err = CompareFlowSpecNLRI(&n3, &n4)
assert.Nil(err)
assert.True(r < 0)
}