diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-03-03 09:38:33 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-03-03 09:38:33 -0800 |
commit | 5f317e778f548fa696bfd57e314306d87a593fdb (patch) | |
tree | 2f725715d9a293cbfd33081f89798805f78b621e /packet/bgp.go | |
parent | 199d658c2f01b25d42961f6336a38529660c1b92 (diff) |
packet: make multiple flow spec fragmentation flags ORed match instead of ANDed
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'packet/bgp.go')
-rw-r--r-- | packet/bgp.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/packet/bgp.go b/packet/bgp.go index 1019d74c..56cbfcd2 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -2294,25 +2294,26 @@ func flowSpecFragmentParser(rf RouteFamily, args []string) (FlowSpecComponentInt if len(args) < 2 { return nil, fmt.Errorf("invalid flowspec fragment specifier") } - value := 0 + items := make([]*FlowSpecComponentItem, 0) for _, a := range args[1:] { + value := 0 switch a { case "dont-fragment": if afi, _ := RouteFamilyToAfiSafi(rf); afi == AFI_IP6 { return nil, fmt.Errorf("can't specify dont-fragment for ipv6") } - value |= 0x1 + value = 0x1 case "is-fragment": - value |= 0x2 + value = 0x2 case "first-fragment": - value |= 0x4 + value = 0x4 case "last-fragment": - value |= 0x8 + value = 0x8 default: return nil, fmt.Errorf("invalid flowspec fragment specifier") } + items = append(items, NewFlowSpecComponentItem(0, value)) } - items := []*FlowSpecComponentItem{NewFlowSpecComponentItem(0, value)} return NewFlowSpecComponent(FlowSpecValueMap[args[0]], items), nil } @@ -2541,7 +2542,7 @@ func (v *FlowSpecComponentItem) Serialize() ([]byte, error) { } buf := make([]byte, 1+(1<<order)) - buf[0] = byte(uint32(v.Op) | order << 4) + buf[0] = byte(uint32(v.Op) | order<<4) switch order { case 0: buf[1] = byte(v.Value) |