diff options
author | Thomas Rosenstein <thomas.rosenstein@creamfinance.com> | 2019-02-08 12:31:56 +0100 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2019-02-08 21:59:06 +0900 |
commit | 1b57495ae934b639d103fdb18dd672de69af153c (patch) | |
tree | 94e67d9d38bdf94b7bb8ffa584ad9b0a623dc2dd /cmd | |
parent | f17772298e30146aad394dc7bfb8bb0f56cc9889 (diff) |
Fix listing of prefix set in gobgp cli
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/gobgp/policy.go | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/cmd/gobgp/policy.go b/cmd/gobgp/policy.go index 8c720578..05695878 100644 --- a/cmd/gobgp/policy.go +++ b/cmd/gobgp/policy.go @@ -178,19 +178,35 @@ func formatDefinedSet(head bool, typ string, indent int, list []*api.DefinedSet) buff.WriteString(fmt.Sprintf(format, "NAME", typ)) } for _, s := range list { - l := s.GetList() - if len(l) == 0 { - buff.WriteString(fmt.Sprintf(format, s.GetName(), "")) - } - for i, x := range l { - if typ == "COMMUNITY" || typ == "EXT-COMMUNITY" || typ == "LARGE-COMMUNITY" { - x = _regexpCommunity.ReplaceAllString(x, "$1") + if typ == "PREFIX" { + l := s.GetPrefixes() + if len(l) == 0 { + buff.WriteString(fmt.Sprintf(format, s.GetName(), "")) } - if i == 0 { - buff.WriteString(fmt.Sprintf(format, s.GetName(), x)) - } else { - buff.WriteString(fmt.Sprint(sIndent)) - buff.WriteString(fmt.Sprintf(format, "", x)) + for i, x := range l { + prefix := fmt.Sprintf("%s (%d - %d)", x.GetIpPrefix(), x.GetMaskLengthMin(), x.GetMaskLengthMax()) + if i == 0 { + buff.WriteString(fmt.Sprintf(format, s.GetName(), prefix)) + } else { + buff.WriteString(fmt.Sprint(sIndent)) + buff.WriteString(fmt.Sprintf(format, "", prefix)) + } + } + } else { + l := s.GetList() + if len(l) == 0 { + buff.WriteString(fmt.Sprintf(format, s.GetName(), "")) + } + for i, x := range l { + if typ == "COMMUNITY" || typ == "EXT-COMMUNITY" || typ == "LARGE-COMMUNITY" { + x = _regexpCommunity.ReplaceAllString(x, "$1") + } + if i == 0 { + buff.WriteString(fmt.Sprintf(format, s.GetName(), x)) + } else { + buff.WriteString(fmt.Sprint(sIndent)) + buff.WriteString(fmt.Sprintf(format, "", x)) + } } } } |