diff options
author | Satoshi Fujimoto <satoshi.fujimoto7@gmail.com> | 2017-12-11 16:19:50 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-12-16 20:27:06 +0900 |
commit | b2ca825f6d55fb316a01909aedab44e865d6f53d (patch) | |
tree | 516e66df230ba6aca3a6d4745b7add2c6ea79fc0 /api/grpc_server.go | |
parent | 694d364d09ae9d272a7cacefc23b7fcefcf05617 (diff) |
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 <satoshi.fujimoto7@gmail.com>
Diffstat (limited to 'api/grpc_server.go')
-rw-r--r-- | api/grpc_server.go | 10 |
1 files changed, 5 insertions, 5 deletions
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: |