From b992c538652580cb4150524328dc2c3b13425863 Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Tue, 19 Jun 2018 10:25:50 +0900 Subject: api: Use attribute.proto struct in message Vrf The current formats of the RD and import/export RTs in message Vrf are the binary type representation, this patch fixes to use the structures defined in attribute.proto file. Signed-off-by: IWASE Yusuke --- gobgpd/main.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'gobgpd/main.go') diff --git a/gobgpd/main.go b/gobgpd/main.go index 17fcbf81..2fc89424 100644 --- a/gobgpd/main.go +++ b/gobgpd/main.go @@ -26,6 +26,7 @@ import ( "runtime" "syscall" + "github.com/golang/protobuf/ptypes/any" "github.com/jessevdk/go-flags" "github.com/kr/pretty" log "github.com/sirupsen/logrus" @@ -42,16 +43,16 @@ import ( var version = "master" -func serializeRouteTargets(l []string) ([][]byte, error) { - rtList := make([]bgp.ExtendedCommunityInterface, 0, len(l)) +func marshalRouteTargets(l []string) ([]*any.Any, error) { + rtList := make([]*any.Any, 0, len(l)) for _, rtString := range l { rt, err := bgp.ParseRouteTarget(rtString) if err != nil { return nil, err } - rtList = append(rtList, rt) + rtList = append(rtList, api.MarshalRT(rt)) } - return bgp.SerializeExtendedCommunities(rtList) + return rtList, nil } func main() { @@ -234,13 +235,12 @@ func main() { if err != nil { log.Fatalf("failed to load vrf rd config: %s", err) } - rdbuf, _ := rd.Serialize() - importRtList, err := serializeRouteTargets(vrf.Config.ImportRtList) + importRtList, err := marshalRouteTargets(vrf.Config.ImportRtList) if err != nil { log.Fatalf("failed to load vrf import rt config: %s", err) } - exportRtList, err := serializeRouteTargets(vrf.Config.ExportRtList) + exportRtList, err := marshalRouteTargets(vrf.Config.ExportRtList) if err != nil { log.Fatalf("failed to load vrf export rt config: %s", err) } @@ -248,7 +248,7 @@ func main() { if _, err := apiServer.AddVrf(context.Background(), &api.AddVrfRequest{ Vrf: &api.Vrf{ Name: vrf.Config.Name, - Rd: rdbuf, + Rd: api.MarshalRD(rd), Id: uint32(vrf.Config.Id), ImportRt: importRtList, ExportRt: exportRtList, -- cgit v1.2.3