Skip to content

Commit

Permalink
Fix routeregexp ipv6 (#2395)
Browse files Browse the repository at this point in the history
* Update ovn-nbctl-legacy.go

* Update ovn-nbctl-legacy_test.go

* Update ovn-nbctl-legacy.go

(cherry picked from commit db435dc)
  • Loading branch information
dcasier authored and oilbeater committed Feb 28, 2023
1 parent 8f045d7 commit 489d245
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/ovs/ovn-nbctl-legacy.go
Expand Up @@ -1083,7 +1083,7 @@ func (c LegacyClient) GetStaticRouteList(router string) (routeList []*StaticRout
return parseLrRouteListOutput(output)
}

var routeRegexp = regexp.MustCompile(`^\s*((\d+(\.\d+){3})|(([a-f0-9:]*:+)+[a-f0-9]?))(/\d+)?\s+((\d+(\.\d+){3})|(([a-f0-9:]*:+)+[a-f0-9]?))\s+(dst-ip|src-ip)(\s+.+)?$`)
var routeRegexp = regexp.MustCompile(`^\s*((\d+(\.\d+){3})|(([a-f0-9:]*:+)+[a-f0-9]*?))(/\d+)?\s+((\d+(\.\d+){3})|(([a-f0-9:]*:+)+[a-f0-9]*?))\s+(dst-ip|src-ip)(\s+.+)?$`)

func parseLrRouteListOutput(output string) (routeList []*StaticRoute, err error) {
lines := strings.Split(output, "\n")
Expand Down
3 changes: 2 additions & 1 deletion pkg/ovs/ovn-nbctl-legacy_test.go
Expand Up @@ -21,13 +21,14 @@ func Test_parseLrRouteListOutput(t *testing.T) {
output = `IPv6 Routes
fc00:f853:ccd:e793::2 fd00:100:64::2 dst-ip
fc00:f853:ccd:e793::3 fd00:100:64::3 dst-ip
fc00:f853:ccd:e793::4 fd00:100:64::4444 dst-ip
fd00:10:16::2 fd00:100:64::3 src-ip
fd00:10:16::d fd00:100:64::2 src-ip
fd00:11:15::/112 fd00:100:64::2 src-ip ecmp
fd00:11:15::/112 fd00:100:64::3 src-ip ecmp`
routeList, err = parseLrRouteListOutput(output)
ast.Nil(err)
ast.Equal(6, len(routeList))
ast.Equal(7, len(routeList))
}

func Test_parseLrPolicyRouteListOutput(t *testing.T) {
Expand Down

0 comments on commit 489d245

Please sign in to comment.