diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-03-27 15:37:26 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-03-27 15:37:26 +0900 |
commit | 428435556811567e2b6f79febcec98f654fce1c0 (patch) | |
tree | 864ec1a83c597756d4ae02698c7a7ae77ad81bcc /table/table.go | |
parent | 2005945db0ef0ff805072f78cbe45a9650009034 (diff) |
server: fix table query with shorter-prefixes option
$ gobgp g r 168.181.21.128/25 shorter-prefixes
Network not in table
$ gobgp g r 168.181.21.0/25 shorter-prefixes
Network Next Hop AS_PATH Age Attrs
*> 168.181.21.0/24 187.16.221.202 61580 04:17:41 [{Origin: i}]
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/table.go')
-rw-r--r-- | table/table.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/table/table.go b/table/table.go index 486f0894..6c5d4da8 100644 --- a/table/table.go +++ b/table/table.go @@ -371,13 +371,13 @@ func (t *Table) Select(option ...TableSelectOption) (*Table, error) { } } case LOOKUP_SHORTER: - _, prefix, err := net.ParseCIDR(key) + addr, prefix, err := net.ParseCIDR(key) if err != nil { return nil, err } - ones, bits := prefix.Mask.Size() + ones, _ := prefix.Mask.Size() for i := ones; i > 0; i-- { - prefix.Mask = net.CIDRMask(i, bits) + _, prefix, _ := net.ParseCIDR(fmt.Sprintf("%s/%d", addr.String(), i)) f(prefix.String()) } default: |