summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gobgp/cmd/neighbor.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/gobgp/cmd/neighbor.go b/gobgp/cmd/neighbor.go
index 6952f282..eb31050c 100644
--- a/gobgp/cmd/neighbor.go
+++ b/gobgp/cmd/neighbor.go
@@ -500,6 +500,18 @@ func showRibInfo(r, name string) error {
}
+func parseCIDRorIP(str string) (net.IP, *net.IPNet, error) {
+ ip, n, err := net.ParseCIDR(str)
+ if err == nil {
+ return ip, n, nil
+ }
+ ip = net.ParseIP(str)
+ if ip == nil {
+ return ip, nil, fmt.Errorf("invalid CIDR/IP")
+ }
+ return ip, nil, nil
+}
+
func showNeighborRib(r string, name string, args []string) error {
showBest := false
showAge := true
@@ -527,6 +539,9 @@ func showNeighborRib(r string, name string, args []string) error {
var filter []*table.LookupPrefix
if len(args) > 0 {
+ if _, _, err = parseCIDRorIP(args[0]); err != nil {
+ return err
+ }
var option table.LookupOption
if len(args) > 1 {
if args[1] == "longer-prefixes" {