From b2ca825f6d55fb316a01909aedab44e865d6f53d Mon Sep 17 00:00:00 2001 From: Satoshi Fujimoto Date: Mon, 11 Dec 2017 16:19:50 +0900 Subject: table/policy: Support prefix representation in NeighborSet Currently, "neighbor-set" supports only IP address representation and IP prefix representation(such as "192.168.0.0/24") is not supported. This commit enables to accept the prefix representation for "neighbor-set" to allow neighbors to be specified as range. Signed-off-by: Satoshi Fujimoto --- api/grpc_server.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'api') diff --git a/api/grpc_server.go b/api/grpc_server.go index 15bf769f..b7c1eb74 100644 --- a/api/grpc_server.go +++ b/api/grpc_server.go @@ -1440,13 +1440,13 @@ func NewDefinedSetFromApiStruct(a *DefinedSet) (table.DefinedSet, error) { } return table.NewPrefixSetFromApiStruct(a.Name, prefixes) case table.DEFINED_TYPE_NEIGHBOR: - list := make([]net.IP, 0, len(a.List)) + list := make([]net.IPNet, 0, len(a.List)) for _, x := range a.List { - addr := net.ParseIP(x) - if addr == nil { - return nil, fmt.Errorf("invalid ip address format: %s", x) + _, addr, err := net.ParseCIDR(x) + if err != nil { + return nil, fmt.Errorf("invalid address or prefix: %s", x) } - list = append(list, addr) + list = append(list, *addr) } return table.NewNeighborSetFromApiStruct(a.Name, list) case table.DEFINED_TYPE_AS_PATH: -- cgit v1.2.3