diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-07-26 07:58:18 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-07-26 08:09:02 +0900 |
commit | d712de0dc604aafd609a6bfecdef867f7d43e46e (patch) | |
tree | 320e8a57abd8c62b0ac753c06c910388d3077639 | |
parent | 22772c0e62ab215a9872761ca01d103e297f98bd (diff) |
api: add addpath support to AddPath API and cli
$gobgp global rib add 10.0.0.0/24 identifier 20
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | api/grpc_server.go | 1 | ||||
-rw-r--r-- | api/util.go | 1 | ||||
-rw-r--r-- | gobgp/cmd/global.go | 11 |
3 files changed, 12 insertions, 1 deletions
diff --git a/api/grpc_server.go b/api/grpc_server.go index 419fd2b6..3101fb2f 100644 --- a/api/grpc_server.go +++ b/api/grpc_server.go @@ -651,6 +651,7 @@ func (s *Server) api2PathList(resource Resource, ApiPathList []*Path) ([]*table. if err != nil { return nil, err } + nlri.SetPathIdentifier(path.Identifier) } for _, attr := range path.Pattrs { diff --git a/api/util.go b/api/util.go index 53d4f1df..4f37309f 100644 --- a/api/util.go +++ b/api/util.go @@ -120,6 +120,7 @@ func (p *Path) ToNativePath(option ...ToNativeOption) (*table.Path, error) { } t := time.Unix(p.Age, 0) nlri.SetPathIdentifier(p.Identifier) + nlri.SetPathLocalIdentifier(p.LocalIdentifier) path := table.NewPath(info, nlri, p.IsWithdraw, pattr, t, false) path.SetValidation(&table.Validation{ Status: config.IntToRpkiValidationResultTypeMap[int(p.Validation)], diff --git a/gobgp/cmd/global.go b/gobgp/cmd/global.go index a53ce0c7..550f9586 100644 --- a/gobgp/cmd/global.go +++ b/gobgp/cmd/global.go @@ -713,7 +713,16 @@ func ParsePath(rf bgp.RouteFamily, args []string) (*table.Path, error) { nlri = bgp.NewIPv6AddrPrefix(uint8(ones), ip.String()) } - extcomms = args[1:] + if len(args) > 2 && args[1] == "identifier" { + if id, err := strconv.Atoi(args[2]); err != nil { + return nil, fmt.Errorf("invalid format") + } else { + nlri.SetPathIdentifier(uint32(id)) + } + extcomms = args[3:] + } else { + extcomms = args[1:] + } case bgp.RF_IPv4_VPN, bgp.RF_IPv6_VPN: if len(args) < 5 || args[1] != "label" || args[3] != "rd" { |