summaryrefslogtreecommitdiffhomepage
path: root/gobgpd
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2018-06-19 10:25:50 +0900
committerIWASE Yusuke <iwase.yusuke0@gmail.com>2018-06-19 12:01:48 +0900
commitb992c538652580cb4150524328dc2c3b13425863 (patch)
tree9911930f2771d7cfb815c9f3624fa13c46766626 /gobgpd
parentb73933c4b20e15f468944edd7012a7cc90adf0e7 (diff)
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 <iwase.yusuke0@gmail.com>
Diffstat (limited to 'gobgpd')
-rw-r--r--gobgpd/main.go16
1 files changed, 8 insertions, 8 deletions
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,