diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-06-27 08:52:29 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-06-27 08:52:29 +0900 |
commit | 35bb5694a9be788c651119f5913c6fef2d08c5c2 (patch) | |
tree | e398fed52eb563eab03e51f2349eda73c3b9b612 | |
parent | 52f36b683c2759c994ab0739dbf935b2985d89f9 (diff) |
gobgp: add aggregator path attribute support
$gobgp global rib add -a ipv4 10.0.0.0/24 nexthop 20.20.20.20 aggregator 3000:10.0.0.1
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | gobgp/cmd/global.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gobgp/cmd/global.go b/gobgp/cmd/global.go index bcf55ff2..9b9bd4af 100644 --- a/gobgp/cmd/global.go +++ b/gobgp/cmd/global.go @@ -536,6 +536,27 @@ func extractAigp(args []string) ([]string, bgp.PathAttributeInterface, error) { return args, nil, nil } +func extractAggregator(args []string) ([]string, bgp.PathAttributeInterface, error) { + for idx, arg := range args { + if arg == "aggregator" { + if len(args) < (idx + 1) { + return nil, nil, fmt.Errorf("invalid aggregator format") + } + v := strings.SplitN(args[idx+1], ":", 2) + if len(v) != 2 { + return nil, nil, fmt.Errorf("invalid aggregator format") + } + as, err := strconv.ParseUint(v[0], 10, 32) + if err != nil { + return nil, nil, fmt.Errorf("invalid aggregator format") + } + attr := bgp.NewPathAttributeAggregator(uint32(as), net.ParseIP(v[1]).String()) + return append(args[:idx], args[idx+2:]...), attr, nil + } + } + return args, nil, nil +} + func ParsePath(rf bgp.RouteFamily, args []string) (*api.Path, error) { var nlri bgp.AddrPrefixInterface var extcomms []string @@ -552,6 +573,7 @@ func ParsePath(rf bgp.RouteFamily, args []string) (*api.Path, error) { extractLocalPref, extractCommunity, extractAigp, + extractAggregator, } for _, fn := range fns { |