From 5f317e778f548fa696bfd57e314306d87a593fdb Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Thu, 3 Mar 2016 09:38:33 -0800 Subject: [PATCH] packet: make multiple flow spec fragmentation flags ORed match instead of ANDed Signed-off-by: FUJITA Tomonori --- packet/bgp.go | 15 ++++++++------- 1 file 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<