summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gobgp/cmd/global.go2
-rw-r--r--packet/bgp.go13
2 files changed, 11 insertions, 4 deletions
diff --git a/gobgp/cmd/global.go b/gobgp/cmd/global.go
index 08dc2249..bfc18adb 100644
--- a/gobgp/cmd/global.go
+++ b/gobgp/cmd/global.go
@@ -530,7 +530,7 @@ func modPath(resource api.Resource, name, modtype string, args []string) error {
fsHelpMsgFmt := fmt.Sprintf(`err: %s
usage: %s rib %s match <MATCH_EXPR> then <THEN_EXPR> -a %%s
<MATCH_EXPR> : { %s <PREFIX> [<OFFSET>] | %s <PREFIX> [<OFFSET>] |
- %s <PROTO>... | %s <FRAGMENT_TYPE> | %s <TCPFLAG>... |
+ %s <PROTO>... | %s <FRAGMENT_TYPE> | %s [not] [match] <TCPFLAG>... |
{ %s | %s | %s | %s | %s | %s | %s | %s } <ITEM>... }...
<PROTO> : %s
<FRAGMENT_TYPE> : not-a-fragment, is-a-fragment, first-fragment, last-fragment
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
}