summaryrefslogtreecommitdiffhomepage
path: root/config
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-05-17 08:50:55 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-05-17 08:52:28 +0900
commit8fd25af4ce9ab902e24eb06644ef2e9c42cee7e0 (patch)
treefca38cf5df338ca0abae36c4579fb551fef2a66d /config
parent949c58fbf6d5ccb79ee87a5105968d3fe591a3a9 (diff)
zebra: make zebra config consistent with the rests
- split config and state - move to Bgp structure (aligned with Rpki, Bmp, and Mrt) Also makes zebra configured via GRPC channel. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'config')
-rw-r--r--config/bgp_configs.go124
-rw-r--r--config/default.go4
-rw-r--r--config/serve.go1
3 files changed, 90 insertions, 39 deletions
diff --git a/config/bgp_configs.go b/config/bgp_configs.go
index 57866339..2054efec 100644
--- a/config/bgp_configs.go
+++ b/config/bgp_configs.go
@@ -870,6 +870,88 @@ func (v RpkiValidationResultType) Validate() error {
return nil
}
+//struct for container gobgp:state
+type ZebraState struct {
+ // original -> gobgp:enabled
+ //gobgp:enabled's original type is boolean
+ Enabled bool `mapstructure:"enabled"`
+ // original -> gobgp:url
+ Url string `mapstructure:"url"`
+ // original -> gobgp:redistribute-route-type
+ RedistributeRouteTypeList []InstallProtocolType `mapstructure:"redistribute-route-type-list"`
+}
+
+func (lhs *ZebraState) Equal(rhs *ZebraState) bool {
+ if lhs == nil || rhs == nil {
+ return false
+ }
+ if lhs.Enabled != rhs.Enabled {
+ return false
+ }
+ if lhs.Url != rhs.Url {
+ return false
+ }
+ if len(lhs.RedistributeRouteTypeList) != len(rhs.RedistributeRouteTypeList) {
+ return false
+ }
+ for idx, l := range lhs.RedistributeRouteTypeList {
+ if l != rhs.RedistributeRouteTypeList[idx] {
+ return false
+ }
+ }
+ return true
+}
+
+//struct for container gobgp:config
+type ZebraConfig struct {
+ // original -> gobgp:enabled
+ //gobgp:enabled's original type is boolean
+ Enabled bool `mapstructure:"enabled"`
+ // original -> gobgp:url
+ Url string `mapstructure:"url"`
+ // original -> gobgp:redistribute-route-type
+ RedistributeRouteTypeList []InstallProtocolType `mapstructure:"redistribute-route-type-list"`
+}
+
+func (lhs *ZebraConfig) Equal(rhs *ZebraConfig) bool {
+ if lhs == nil || rhs == nil {
+ return false
+ }
+ if lhs.Enabled != rhs.Enabled {
+ return false
+ }
+ if lhs.Url != rhs.Url {
+ return false
+ }
+ if len(lhs.RedistributeRouteTypeList) != len(rhs.RedistributeRouteTypeList) {
+ return false
+ }
+ for idx, l := range lhs.RedistributeRouteTypeList {
+ if l != rhs.RedistributeRouteTypeList[idx] {
+ return false
+ }
+ }
+ return true
+}
+
+//struct for container gobgp:zebra
+type Zebra struct {
+ // original -> gobgp:zebra-config
+ Config ZebraConfig `mapstructure:"config"`
+ // original -> gobgp:zebra-state
+ State ZebraState `mapstructure:"state"`
+}
+
+func (lhs *Zebra) Equal(rhs *Zebra) bool {
+ if lhs == nil || rhs == nil {
+ return false
+ }
+ if !lhs.Config.Equal(&(rhs.Config)) {
+ return false
+ }
+ return true
+}
+
//struct for container gobgp:mrt
type Mrt struct {
// original -> gobgp:dump-type
@@ -2470,38 +2552,6 @@ func (lhs *MplsLabelRange) Equal(rhs *MplsLabelRange) bool {
return true
}
-//struct for container gobgp:zebra
-type Zebra struct {
- // original -> gobgp:enabled
- //gobgp:enabled's original type is boolean
- Enabled bool `mapstructure:"enabled"`
- // original -> gobgp:url
- Url string `mapstructure:"url"`
- // original -> gobgp:redistribute-route-type
- RedistributeRouteTypeList []InstallProtocolType `mapstructure:"redistribute-route-type-list"`
-}
-
-func (lhs *Zebra) Equal(rhs *Zebra) bool {
- if lhs == nil || rhs == nil {
- return false
- }
- if lhs.Enabled != rhs.Enabled {
- return false
- }
- if lhs.Url != rhs.Url {
- return false
- }
- if len(lhs.RedistributeRouteTypeList) != len(rhs.RedistributeRouteTypeList) {
- return false
- }
- for idx, l := range lhs.RedistributeRouteTypeList {
- if l != rhs.RedistributeRouteTypeList[idx] {
- return false
- }
- }
- return true
-}
-
//struct for container gobgp:state
type RouteTargetMembershipState struct {
// original -> gobgp:deferral-time
@@ -3881,8 +3931,6 @@ type Global struct {
AfiSafis []AfiSafi `mapstructure:"afi-safis"`
// original -> rpol:apply-policy
ApplyPolicy ApplyPolicy `mapstructure:"apply-policy"`
- // original -> gobgp:zebra
- Zebra Zebra `mapstructure:"zebra"`
// original -> gobgp:mpls-label-range
MplsLabelRange MplsLabelRange `mapstructure:"mpls-label-range"`
}
@@ -3928,9 +3976,6 @@ func (lhs *Global) Equal(rhs *Global) bool {
if !lhs.ApplyPolicy.Equal(&(rhs.ApplyPolicy)) {
return false
}
- if !lhs.Zebra.Equal(&(rhs.Zebra)) {
- return false
- }
if !lhs.MplsLabelRange.Equal(&(rhs.MplsLabelRange)) {
return false
}
@@ -3951,6 +3996,8 @@ type Bgp struct {
BmpServers []BmpServer `mapstructure:"bmp-servers"`
// original -> gobgp:mrt-dump
MrtDump []Mrt `mapstructure:"mrt-dump"`
+ // original -> gobgp:zebra
+ Zebra Zebra `mapstructure:"zebra"`
}
func (lhs *Bgp) Equal(rhs *Bgp) bool {
@@ -4040,6 +4087,9 @@ func (lhs *Bgp) Equal(rhs *Bgp) bool {
}
}
}
+ if !lhs.Zebra.Equal(&(rhs.Zebra)) {
+ return false
+ }
return true
}
diff --git a/config/default.go b/config/default.go
index 24dc08c7..02ec5784 100644
--- a/config/default.go
+++ b/config/default.go
@@ -34,8 +34,8 @@ func SetDefaultConfigValues(v *viper.Viper, b *BgpConfigSet) error {
}
}
- if b.Global.Zebra.Url == "" {
- b.Global.Zebra.Url = "unix:/var/run/quagga/zserv.api"
+ if b.Zebra.Config.Url == "" {
+ b.Zebra.Config.Url = "unix:/var/run/quagga/zserv.api"
}
if len(b.Global.AfiSafis) == 0 {
diff --git a/config/serve.go b/config/serve.go
index 70a4e896..a8f67725 100644
--- a/config/serve.go
+++ b/config/serve.go
@@ -15,6 +15,7 @@ type BgpConfigSet struct {
RpkiServers []RpkiServer `mapstructure:"rpki-servers"`
BmpServers []BmpServer `mapstructure:"bmp-servers"`
MrtDump []Mrt `mapstructure:"mrt-dump"`
+ Zebra Zebra `mapstructure:"zebra"`
DefinedSets DefinedSets `mapstructure:"defined-sets"`
PolicyDefinitions []PolicyDefinition `mapstructure:"policy-definitions"`
}