From 2bad24a07764ff413b9222581c282ab12a16fdf1 Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Thu, 3 Aug 2017 11:12:31 +0900 Subject: config/default: Validation for "afi-safi-name" Signed-off-by: IWASE Yusuke --- config/default.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'config') diff --git a/config/default.go b/config/default.go index 03a2479c..91194284 100644 --- a/config/default.go +++ b/config/default.go @@ -205,17 +205,19 @@ func setDefaultNeighborConfigValuesWithViper(v *viper.Viper, n *Neighbor, asn ui if err != nil { return err } - for i, af := range n.AfiSafis { + for i := range n.AfiSafis { vv := viper.New() if len(afs) > i { vv.Set("afi-safi", afs[i]) } - af.State.AfiSafiName = af.Config.AfiSafiName + if _, err := bgp.GetRouteFamily(string(n.AfiSafis[i].Config.AfiSafiName)); err != nil { + return err + } + n.AfiSafis[i].State.AfiSafiName = n.AfiSafis[i].Config.AfiSafiName if !vv.IsSet("afi-safi.config.enabled") { - af.Config.Enabled = true + n.AfiSafis[i].Config.Enabled = true } - af.MpGracefulRestart.State.Enabled = af.MpGracefulRestart.Config.Enabled - n.AfiSafis[i] = af + n.AfiSafis[i].MpGracefulRestart.State.Enabled = n.AfiSafis[i].MpGracefulRestart.Config.Enabled } } -- cgit v1.2.3