summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp/validate_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/validate_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/validate_test.go')
-rw-r--r--packet/bgp/validate_test.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/packet/bgp/validate_test.go b/packet/bgp/validate_test.go
index 3bb60639..12f81e03 100644
--- a/packet/bgp/validate_test.go
+++ b/packet/bgp/validate_test.go
@@ -388,8 +388,8 @@ func Test_Validate_flowspec(t *testing.T) {
cmp = append(cmp, NewFlowSpecComponent(FLOW_SPEC_TYPE_TCP_FLAG, []*FlowSpecComponentItem{item5, item6}))
cmp = append(cmp, NewFlowSpecComponent(FLOW_SPEC_TYPE_PKT_LEN, []*FlowSpecComponentItem{item2, item3, item4}))
cmp = append(cmp, NewFlowSpecComponent(FLOW_SPEC_TYPE_DSCP, []*FlowSpecComponentItem{item2, item3, item4}))
- isFlagment := 0x02
- item7 := NewFlowSpecComponentItem(isFlagment, 0)
+ isFragment := 0x02
+ item7 := NewFlowSpecComponentItem(isFragment, 0)
cmp = append(cmp, NewFlowSpecComponent(FLOW_SPEC_TYPE_FRAGMENT, []*FlowSpecComponentItem{item7}))
n1 := NewFlowSpecIPv4Unicast(cmp)
a := NewPathAttributeMpReachNLRI("", []AddrPrefixInterface{n1})
@@ -402,6 +402,8 @@ func Test_Validate_flowspec(t *testing.T) {
cmp = append(cmp, NewFlowSpecDestinationPrefix(NewIPAddrPrefix(24, "10.0.0.0")))
n1 = NewFlowSpecIPv4Unicast(cmp)
a = NewPathAttributeMpReachNLRI("", []AddrPrefixInterface{n1})
+ // Swaps components order to reproduce the rules order violation.
+ n1.Value[0], n1.Value[1] = n1.Value[1], n1.Value[0]
_, err = ValidateAttribute(a, m, false, false)
assert.NotNil(err)
}