diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2018-04-27 11:28:32 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-05-10 21:12:30 +0900 |
commit | 32f7faa8e7f83c20e50a37e44ba01a498939f574 (patch) | |
tree | 014b7755fb5cd873f2ea7bfd9ece4c9f846475ad /gobgpd/main.go | |
parent | 0f88373949e2eed7a9dbcd1ebac64d76e54f6d40 (diff) |
config: Enable to configure VRF via config file
This patch enables to configure VRF tables by using config file. This
feature is useful when using VRF-Neighbor feature.
Example of Usage:
```toml
[[vrfs]]
[vrfs.config]
name = "vrf1"
id = 1
rd = "65000:100"
both-rt-list = ["65000:100"]
```
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'gobgpd/main.go')
-rw-r--r-- | gobgpd/main.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gobgpd/main.go b/gobgpd/main.go index fdfb8cca..9b504441 100644 --- a/gobgpd/main.go +++ b/gobgpd/main.go @@ -188,6 +188,31 @@ func main() { log.Fatalf("failed to set bmp config: %s", err) } } + for _, vrf := range newConfig.Vrfs { + rd, err := bgp.ParseRouteDistinguisher(vrf.Config.Rd) + if err != nil { + log.Fatalf("failed to load vrf rd config: %s", err) + } + importRtList := make([]bgp.ExtendedCommunityInterface, 0, len(vrf.Config.ImportRtList)) + for _, rtString := range vrf.Config.ImportRtList { + rt, err := bgp.ParseRouteTarget(rtString) + if err != nil { + log.Fatalf("failed to load vrf import rt config: %s", err) + } + importRtList = append(importRtList, rt) + } + exportRtList := make([]bgp.ExtendedCommunityInterface, 0, len(vrf.Config.ExportRtList)) + for _, rtString := range vrf.Config.ExportRtList { + rt, err := bgp.ParseRouteTarget(rtString) + if err != nil { + log.Fatalf("failed to load vrf export rt config: %s", err) + } + exportRtList = append(exportRtList, rt) + } + if err := bgpServer.AddVrf(vrf.Config.Name, vrf.Config.Id, rd, importRtList, exportRtList); err != nil { + log.Fatalf("failed to set vrf config: %s", err) + } + } for i, _ := range newConfig.MrtDump { if len(newConfig.MrtDump[i].Config.FileName) == 0 { continue |