diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-10-08 01:40:36 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-10-08 01:46:11 +0900 |
commit | eb08d749cd4e2e624bfa222912a4b1d9d8546689 (patch) | |
tree | e987feed2a803473f70e832ff6fdc968d6b18374 /packet | |
parent | 64d2821d8bc27494dab0bf36418cb60ba9814e9c (diff) |
cli: enable to flag match/not for tcp-flag when adding flowspec path
$ gobgp global rib -a ipv4-flowspec add match tcp-flags not match rst then accept
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'packet')
-rw-r--r-- | packet/bgp.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/packet/bgp.go b/packet/bgp.go index 86fde0a2..022dcbd5 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -2107,18 +2107,25 @@ func flowSpecTcpFlagParser(rf RouteFamily, args []string) (FlowSpecComponentInte ss = append(ss, v) } protos := strings.Join(ss, "|") - exp := regexp.MustCompile(fmt.Sprintf("^%s ((((%s)\\&)*(%s) )*(((%s)\\&)*(%s)))$", FlowSpecNameMap[FLOW_SPEC_TYPE_TCP_FLAG], protos, protos, protos, protos)) + exp := regexp.MustCompile(fmt.Sprintf("^%s (not )?(match )?((((%s)\\&)*(%s) )*(((%s)\\&)*(%s)))$", FlowSpecNameMap[FLOW_SPEC_TYPE_TCP_FLAG], protos, protos, protos, protos)) elems := exp.FindStringSubmatch(strings.Join(args, " ")) if len(elems) < 1 { return nil, fmt.Errorf("invalid flag format") } items := make([]*FlowSpecComponentItem, 0) - for _, v := range strings.Split(elems[1], " ") { + op := 0 + if elems[2] != "" { + op |= 0x1 + } + if elems[1] != "" { + op |= 0x2 + } + for _, v := range strings.Split(elems[3], " ") { flag := 0 for _, e := range strings.Split(v, "&") { flag |= int(TCPFlagValueMap[e]) } - items = append(items, NewFlowSpecComponentItem(0, flag)) + items = append(items, NewFlowSpecComponentItem(op, flag)) } return NewFlowSpecComponent(FLOW_SPEC_TYPE_TCP_FLAG, items), nil } |