summaryrefslogtreecommitdiffhomepage
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/default.go21
-rw-r--r--config/serve.go7
2 files changed, 24 insertions, 4 deletions
diff --git a/config/default.go b/config/default.go
index df57103b..5820ef01 100644
--- a/config/default.go
+++ b/config/default.go
@@ -2,6 +2,7 @@ package config
import (
"github.com/BurntSushi/toml"
+ "github.com/osrg/gobgp/packet"
"strings"
)
@@ -14,7 +15,7 @@ type neighbor struct {
attributes map[string]bool
}
-func SetDefaultConfigValues(md toml.MetaData, bt *Bgp) {
+func SetDefaultConfigValues(md toml.MetaData, bt *Bgp) error {
neighbors := []neighbor{}
nidx := 0
@@ -40,5 +41,23 @@ func SetDefaultConfigValues(md toml.MetaData, bt *Bgp) {
if _, ok := n.attributes["NeighborList.Timers.IdleHoldTimeAfterReset"]; !ok {
bt.NeighborList[i].Timers.IdleHoldTimeAfterReset = float64(DEFAULT_IDLE_HOLDTIME_AFTER_RESET)
}
+
+ if _, ok := n.attributes["NeighborList.AfiSafiList"]; !ok {
+ if bt.NeighborList[i].NeighborAddress.To4() != nil {
+ bt.NeighborList[i].AfiSafiList = []AfiSafi{
+ AfiSafi{AfiSafiName: "ipv4-unicast"}}
+ } else {
+ bt.NeighborList[i].AfiSafiList = []AfiSafi{
+ AfiSafi{AfiSafiName: "ipv6-unicast"}}
+ }
+ } else {
+ for _, rf := range bt.NeighborList[i].AfiSafiList {
+ _, err := bgp.GetRouteFamily(rf.AfiSafiName)
+ if err != nil {
+ return err
+ }
+ }
+ }
}
+ return nil
}
diff --git a/config/serve.go b/config/serve.go
index c4aabdec..6832f6b4 100644
--- a/config/serve.go
+++ b/config/serve.go
@@ -11,10 +11,11 @@ func ReadConfigfileServe(path string, configCh chan Bgp, reloadCh chan bool) {
b := Bgp{}
md, err := toml.DecodeFile(path, &b)
+ if err == nil {
+ err = SetDefaultConfigValues(md, &b)
+ }
if err != nil {
- log.Fatal("can't read config file ", path, err)
- } else {
- SetDefaultConfigValues(md, &b)
+ log.Fatal("can't read config file ", path, ", ", err)
}
configCh <- b