summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-09-11 11:02:03 +0900
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-09-11 11:06:00 +0900
commitb610280192e89fbab5f996c6fa0baa152584f993 (patch)
treec1d076b8e2a1c6d07f5ee5de57233edbafb8c057 /packet/bgp.go
parentba3a7ddb02855ffdf799a65c4cad7d75909a1371 (diff)
packet: bug fix of flowspec numeric parser
handle failure of regexp matching also add support of the syntax below // added syntax $ gobgp rib add -a ipv4-flowspec match port 8080 then discard // original syntax (still supported) $ gobgp rib add -a ipv4-flowspec match port '=8080' then discard Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'packet/bgp.go')
-rw-r--r--packet/bgp.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/packet/bgp.go b/packet/bgp.go
index 01de6a62..c3e3c045 100644
--- a/packet/bgp.go
+++ b/packet/bgp.go
@@ -1959,7 +1959,7 @@ func flowSpecTcpFlagParser(args []string) (FlowSpecComponentInterface, error) {
}
func flowSpecNumericParser(args []string) (FlowSpecComponentInterface, error) {
- exp := regexp.MustCompile("^((<=|>=|[<>=])(\\d+)&)?(<=|>=|[<>=])(\\d+)$")
+ exp := regexp.MustCompile("^((<=|>=|[<>=])(\\d+)&)?(<=|>=|[<>=])?(\\d+)$")
items := make([]*FlowSpecComponentItem, 0)
f := func(and bool, o, v string) *FlowSpecComponentItem {
@@ -1967,6 +1967,9 @@ func flowSpecNumericParser(args []string) (FlowSpecComponentInterface, error) {
if and {
op |= 0x40
}
+ if len(o) == 0 {
+ op |= 0x1
+ }
for _, oo := range o {
switch oo {
case '>':
@@ -1987,6 +1990,9 @@ func flowSpecNumericParser(args []string) (FlowSpecComponentInterface, error) {
for _, arg := range args[1:] {
var and bool
elems := exp.FindStringSubmatch(arg)
+ if len(elems) == 0 {
+ return nil, fmt.Errorf("invalid flowspec numeric item")
+ }
if elems[1] != "" {
and = true
items = append(items, f(false, elems[2], elems[3]))