summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--config/bgp_configs.go108
-rw-r--r--config/default.go24
-rw-r--r--config/serve.go2
-rw-r--r--config/util.go8
-rw-r--r--docs/sources/bmp.md4
-rw-r--r--docs/sources/cli-operations.md16
-rw-r--r--docs/sources/evpn.md6
-rw-r--r--docs/sources/flowspec.md4
-rw-r--r--docs/sources/getting-started.md6
-rw-r--r--docs/sources/mrt.md6
-rw-r--r--docs/sources/policy.md20
-rw-r--r--docs/sources/route-reflector.md14
-rw-r--r--docs/sources/route-server.md14
-rw-r--r--docs/sources/rpki.md26
-rw-r--r--gobgpd/main.go6
-rw-r--r--server/bmp.go4
-rw-r--r--server/fsm.go122
-rw-r--r--server/fsm_test.go6
-rw-r--r--server/peer.go68
-rw-r--r--server/rpki.go2
-rw-r--r--server/server.go156
-rw-r--r--server/zclient.go4
-rw-r--r--table/destination.go12
-rw-r--r--table/path.go18
-rw-r--r--table/policy.go2
-rw-r--r--test/lib/gobgp.py26
-rw-r--r--test/performance_test/main.go15
-rw-r--r--tools/config/example_toml.go21
-rw-r--r--tools/pyang_plugins/bgpyang2golang.py7
-rw-r--r--tools/route-server/quagga-rsconfig.go16
30 files changed, 373 insertions, 370 deletions
diff --git a/config/bgp_configs.go b/config/bgp_configs.go
index 6302d867..fbe829db 100644
--- a/config/bgp_configs.go
+++ b/config/bgp_configs.go
@@ -158,9 +158,9 @@ type BmpServerConfig struct {
//struct for container gobgp:bmp-server
type BmpServer struct {
// original -> gobgp:bmp-server-config
- BmpServerConfig BmpServerConfig
+ Config BmpServerConfig
// original -> gobgp:bmp-server-state
- BmpServerState BmpServerState
+ State BmpServerState
}
//struct for container gobgp:bmp-servers
@@ -237,9 +237,9 @@ type RpkiServerConfig struct {
//struct for container gobgp:rpki-server
type RpkiServer struct {
// original -> gobgp:rpki-server-config
- RpkiServerConfig RpkiServerConfig
+ Config RpkiServerConfig
// original -> gobgp:rpki-server-state
- RpkiServerState RpkiServerState
+ State RpkiServerState
}
//struct for container gobgp:rpki-servers
@@ -307,9 +307,9 @@ type PeerGroup struct {
// original -> bgp:peer-group-name
PeerGroupName string
// original -> bgp:peer-group-config
- PeerGroupConfig PeerGroupConfig
+ Config PeerGroupConfig
// original -> bgp:peer-group-state
- PeerGroupState PeerGroupState
+ State PeerGroupState
// original -> bgp:timers
Timers Timers
// original -> bgp:transport
@@ -361,9 +361,9 @@ type RouteServerConfig struct {
//struct for container gobgp:route-server
type RouteServer struct {
// original -> gobgp:route-server-config
- RouteServerConfig RouteServerConfig
+ Config RouteServerConfig
// original -> gobgp:route-server-state
- RouteServerState RouteServerState
+ State RouteServerState
}
//struct for container bgp-op:prefixes
@@ -397,9 +397,9 @@ type AddPathsConfig struct {
//struct for container bgp:add-paths
type AddPaths struct {
// original -> bgp:add-paths-config
- AddPathsConfig AddPathsConfig
+ Config AddPathsConfig
// original -> bgp:add-paths-state
- AddPathsState AddPathsState
+ State AddPathsState
}
//struct for container bgp:state
@@ -423,9 +423,9 @@ type AsPathOptionsConfig struct {
//struct for container bgp:as-path-options
type AsPathOptions struct {
// original -> bgp:as-path-options-config
- AsPathOptionsConfig AsPathOptionsConfig
+ Config AsPathOptionsConfig
// original -> bgp:as-path-options-state
- AsPathOptionsState AsPathOptionsState
+ State AsPathOptionsState
}
//struct for container bgp:state
@@ -449,9 +449,9 @@ type RouteReflectorConfig struct {
//struct for container bgp:route-reflector
type RouteReflector struct {
// original -> bgp:route-reflector-config
- RouteReflectorConfig RouteReflectorConfig
+ Config RouteReflectorConfig
// original -> bgp:route-reflector-state
- RouteReflectorState RouteReflectorState
+ State RouteReflectorState
}
//struct for container bgp:state
@@ -475,9 +475,9 @@ type EbgpMultihopConfig struct {
//struct for container bgp:ebgp-multihop
type EbgpMultihop struct {
// original -> bgp:ebgp-multihop-config
- EbgpMultihopConfig EbgpMultihopConfig
+ Config EbgpMultihopConfig
// original -> bgp:ebgp-multihop-state
- EbgpMultihopState EbgpMultihopState
+ State EbgpMultihopState
}
//struct for container bgp:state
@@ -497,9 +497,9 @@ type LoggingOptionsConfig struct {
//struct for container bgp:logging-options
type LoggingOptions struct {
// original -> bgp:logging-options-config
- LoggingOptionsConfig LoggingOptionsConfig
+ Config LoggingOptionsConfig
// original -> bgp:logging-options-state
- LoggingOptionsState LoggingOptionsState
+ State LoggingOptionsState
}
//struct for container bgp:state
@@ -521,9 +521,9 @@ type ErrorHandlingConfig struct {
//struct for container bgp:error-handling
type ErrorHandling struct {
// original -> bgp:error-handling-config
- ErrorHandlingConfig ErrorHandlingConfig
+ Config ErrorHandlingConfig
// original -> bgp:error-handling-state
- ErrorHandlingState ErrorHandlingState
+ State ErrorHandlingState
}
//struct for container bgp:state
@@ -568,9 +568,9 @@ type TransportConfig struct {
//struct for container bgp:transport
type Transport struct {
// original -> bgp:transport-config
- TransportConfig TransportConfig
+ Config TransportConfig
// original -> bgp:transport-state
- TransportState TransportState
+ State TransportState
}
//struct for container bgp:state
@@ -625,9 +625,9 @@ type TimersConfig struct {
//struct for container bgp:timers
type Timers struct {
// original -> bgp:timers-config
- TimersConfig TimersConfig
+ Config TimersConfig
// original -> bgp:timers-state
- TimersState TimersState
+ State TimersState
}
//struct for container bgp:queues
@@ -765,9 +765,9 @@ type Neighbor struct {
//bgp:neighbor-address's original type is inet:ip-address
NeighborAddress net.IP
// original -> bgp:neighbor-config
- NeighborConfig NeighborConfig
+ Config NeighborConfig
// original -> bgp:neighbor-state
- NeighborState NeighborState
+ State NeighborState
// original -> bgp:timers
Timers Timers
// original -> bgp:transport
@@ -907,9 +907,9 @@ type Ipv6Unicast struct {
// original -> bgp-mp:prefix-limit
PrefixLimit PrefixLimit
// original -> bgp-mp:ipv6-unicast-config
- Ipv6UnicastConfig Ipv6UnicastConfig
+ Config Ipv6UnicastConfig
// original -> bgp-mp:ipv6-unicast-state
- Ipv6UnicastState Ipv6UnicastState
+ State Ipv6UnicastState
}
//struct for container bgp-mp:state
@@ -951,9 +951,9 @@ type PrefixLimitConfig struct {
//struct for container bgp-mp:prefix-limit
type PrefixLimit struct {
// original -> bgp-mp:prefix-limit-config
- PrefixLimitConfig PrefixLimitConfig
+ Config PrefixLimitConfig
// original -> bgp-mp:prefix-limit-state
- PrefixLimitState PrefixLimitState
+ State PrefixLimitState
}
//struct for container bgp-mp:ipv4-unicast
@@ -961,9 +961,9 @@ type Ipv4Unicast struct {
// original -> bgp-mp:prefix-limit
PrefixLimit PrefixLimit
// original -> bgp-mp:ipv4-unicast-config
- Ipv4UnicastConfig Ipv4UnicastConfig
+ Config Ipv4UnicastConfig
// original -> bgp-mp:ipv4-unicast-state
- Ipv4UnicastState Ipv4UnicastState
+ State Ipv4UnicastState
}
//struct for container rpol:state
@@ -1001,9 +1001,9 @@ type ApplyPolicyConfig struct {
//struct for container rpol:apply-policy
type ApplyPolicy struct {
// original -> rpol:apply-policy-config
- ApplyPolicyConfig ApplyPolicyConfig
+ Config ApplyPolicyConfig
// original -> rpol:apply-policy-state
- ApplyPolicyState ApplyPolicyState
+ State ApplyPolicyState
}
//struct for container bgp-mp:state
@@ -1051,9 +1051,9 @@ type MpGracefulRestartConfig struct {
//struct for container bgp-mp:graceful-restart
type MpGracefulRestart struct {
// original -> bgp-mp:mp-graceful-restart-config
- MpGracefulRestartConfig MpGracefulRestartConfig
+ Config MpGracefulRestartConfig
// original -> bgp-mp:mp-graceful-restart-state
- MpGracefulRestartState MpGracefulRestartState
+ State MpGracefulRestartState
}
//struct for container bgp-mp:afi-safi
@@ -1064,9 +1064,9 @@ type AfiSafi struct {
// original -> bgp-mp:mp-graceful-restart
MpGracefulRestart MpGracefulRestart
// original -> bgp-mp:afi-safi-config
- AfiSafiConfig AfiSafiConfig
+ Config AfiSafiConfig
// original -> bgp-mp:afi-safi-state
- AfiSafiState AfiSafiState
+ State AfiSafiState
// original -> rpol:apply-policy
ApplyPolicy ApplyPolicy
// original -> bgp-mp:ipv4-unicast
@@ -1145,9 +1145,9 @@ type GracefulRestartConfig struct {
//struct for container bgp:graceful-restart
type GracefulRestart struct {
// original -> bgp:graceful-restart-config
- GracefulRestartConfig GracefulRestartConfig
+ Config GracefulRestartConfig
// original -> bgp:graceful-restart-state
- GracefulRestartState GracefulRestartState
+ State GracefulRestartState
}
//struct for container bgp-mp:state
@@ -1165,9 +1165,9 @@ type IbgpConfig struct {
//struct for container bgp-mp:ibgp
type Ibgp struct {
// original -> bgp-mp:ibgp-config
- IbgpConfig IbgpConfig
+ Config IbgpConfig
// original -> bgp-mp:ibgp-state
- IbgpState IbgpState
+ State IbgpState
}
//struct for container bgp-mp:state
@@ -1191,9 +1191,9 @@ type EbgpConfig struct {
//struct for container bgp-mp:ebgp
type Ebgp struct {
// original -> bgp-mp:ebgp-config
- EbgpConfig EbgpConfig
+ Config EbgpConfig
// original -> bgp-mp:ebgp-state
- EbgpState EbgpState
+ State EbgpState
}
//struct for container bgp-mp:state
@@ -1213,9 +1213,9 @@ type UseMultiplePathsConfig struct {
//struct for container bgp-mp:use-multiple-paths
type UseMultiplePaths struct {
// original -> bgp-mp:use-multiple-paths-config
- UseMultiplePathsConfig UseMultiplePathsConfig
+ Config UseMultiplePathsConfig
// original -> bgp-mp:use-multiple-paths-state
- UseMultiplePathsState UseMultiplePathsState
+ State UseMultiplePathsState
// original -> bgp-mp:ebgp
Ebgp Ebgp
// original -> bgp-mp:ibgp
@@ -1251,9 +1251,9 @@ type ConfederationConfig struct {
//struct for container bgp:confederation
type Confederation struct {
// original -> bgp:confederation-config
- ConfederationConfig ConfederationConfig
+ Config ConfederationConfig
// original -> bgp:confederation-state
- ConfederationState ConfederationState
+ State ConfederationState
}
//struct for container bgp:state
@@ -1275,9 +1275,9 @@ type DefaultRouteDistanceConfig struct {
//struct for container bgp:default-route-distance
type DefaultRouteDistance struct {
// original -> bgp:default-route-distance-config
- DefaultRouteDistanceConfig DefaultRouteDistanceConfig
+ Config DefaultRouteDistanceConfig
// original -> bgp:default-route-distance-state
- DefaultRouteDistanceState DefaultRouteDistanceState
+ State DefaultRouteDistanceState
}
//struct for container bgp-mp:state
@@ -1327,9 +1327,9 @@ type RouteSelectionOptionsConfig struct {
//struct for container bgp-mp:route-selection-options
type RouteSelectionOptions struct {
// original -> bgp-mp:route-selection-options-config
- RouteSelectionOptionsConfig RouteSelectionOptionsConfig
+ Config RouteSelectionOptionsConfig
// original -> bgp-mp:route-selection-options-state
- RouteSelectionOptionsState RouteSelectionOptionsState
+ State RouteSelectionOptionsState
}
//struct for container bgp:state
@@ -1359,9 +1359,9 @@ type GlobalConfig struct {
//struct for container bgp:global
type Global struct {
// original -> bgp:global-config
- GlobalConfig GlobalConfig
+ Config GlobalConfig
// original -> bgp:global-state
- GlobalState GlobalState
+ State GlobalState
// original -> bgp-mp:route-selection-options
RouteSelectionOptions RouteSelectionOptions
// original -> bgp:default-route-distance
diff --git a/config/default.go b/config/default.go
index 9f58a9b8..5e5c8a53 100644
--- a/config/default.go
+++ b/config/default.go
@@ -73,24 +73,24 @@ func SetDefaultConfigValues(md toml.MetaData, bt *Bgp) error {
}
for i, n := range neighbors {
neighbor := &bt.Neighbors.NeighborList[i]
- timerConfig := &neighbor.Timers.TimersConfig
+ timerConfig := &neighbor.Timers.Config
- if _, ok := n.attributes["Neighbors.NeighborList.Timers.TimersConfig.ConnectRetry"]; !ok {
+ if _, ok := n.attributes["Neighbors.NeighborList.Timers.Config.ConnectRetry"]; !ok {
timerConfig.HoldTime = float64(DEFAULT_CONNECT_RETRY)
}
- if _, ok := n.attributes["Neighbors.NeighborList.Timers.TimersConfig.HoldTime"]; !ok {
+ if _, ok := n.attributes["Neighbors.NeighborList.Timers.Config.HoldTime"]; !ok {
timerConfig.HoldTime = float64(DEFAULT_HOLDTIME)
}
- if _, ok := n.attributes["Neighbors.NeighborList.Timers.TimersConfig.KeepaliveInterval"]; !ok {
+ if _, ok := n.attributes["Neighbors.NeighborList.Timers.Config.KeepaliveInterval"]; !ok {
timerConfig.KeepaliveInterval = timerConfig.HoldTime / 3
}
- if _, ok := n.attributes["Neighbors.NeighborList.Timers.TimersConfig.IdleHoldTimeAfterReset"]; !ok {
+ if _, ok := n.attributes["Neighbors.NeighborList.Timers.Config.IdleHoldTimeAfterReset"]; !ok {
timerConfig.IdleHoldTimeAfterReset = float64(DEFAULT_IDLE_HOLDTIME_AFTER_RESET)
}
if _, ok := n.attributes["Neighbors.NeighborList.AfiSafis.AfiSafiList"]; !ok {
- if neighbor.NeighborConfig.NeighborAddress.To4() != nil {
+ if neighbor.Config.NeighborAddress.To4() != nil {
neighbor.AfiSafis.AfiSafiList = []AfiSafi{
AfiSafi{AfiSafiName: "ipv4-unicast"}}
} else {
@@ -106,17 +106,17 @@ func SetDefaultConfigValues(md toml.MetaData, bt *Bgp) error {
}
}
- if _, ok := n.attributes["Neighbors.NeighborList.NeighborConfig.PeerType"]; !ok {
- if neighbor.NeighborConfig.PeerAs != bt.Global.GlobalConfig.As {
- neighbor.NeighborConfig.PeerType = PEER_TYPE_EXTERNAL
+ if _, ok := n.attributes["Neighbors.NeighborList.Config.PeerType"]; !ok {
+ if neighbor.Config.PeerAs != bt.Global.Config.As {
+ neighbor.Config.PeerType = PEER_TYPE_EXTERNAL
} else {
- neighbor.NeighborConfig.PeerType = PEER_TYPE_INTERNAL
+ neighbor.Config.PeerType = PEER_TYPE_INTERNAL
}
}
}
for _, r := range bt.RpkiServers.RpkiServerList {
- if r.RpkiServerConfig.Port == 0 {
- r.RpkiServerConfig.Port = bgp.RPKI_DEFAULT_PORT
+ if r.Config.Port == 0 {
+ r.Config.Port = bgp.RPKI_DEFAULT_PORT
}
}
return nil
diff --git a/config/serve.go b/config/serve.go
index 896d154b..ef9b0ae0 100644
--- a/config/serve.go
+++ b/config/serve.go
@@ -45,7 +45,7 @@ func ReadConfigfileServe(path string, configCh chan BgpConfigSet, reloadCh chan
func inSlice(n Neighbor, b []Neighbor) int {
for i, nb := range b {
- if nb.NeighborConfig.NeighborAddress.String() == n.NeighborConfig.NeighborAddress.String() {
+ if nb.Config.NeighborAddress.String() == n.Config.NeighborAddress.String() {
return i
}
}
diff --git a/config/util.go b/config/util.go
index 50d1b833..cc7cbba1 100644
--- a/config/util.go
+++ b/config/util.go
@@ -20,9 +20,9 @@ import (
)
func IsConfederationMember(g *Global, p *Neighbor) bool {
- if p.NeighborConfig.PeerAs != g.GlobalConfig.As {
- for _, member := range g.Confederation.ConfederationConfig.MemberAs {
- if member == p.NeighborConfig.PeerAs {
+ if p.Config.PeerAs != g.Config.As {
+ for _, member := range g.Confederation.Config.MemberAs {
+ if member == p.Config.PeerAs {
return true
}
}
@@ -31,7 +31,7 @@ func IsConfederationMember(g *Global, p *Neighbor) bool {
}
func IsEBGPPeer(g *Global, p *Neighbor) bool {
- return p.NeighborConfig.PeerAs != g.GlobalConfig.As
+ return p.Config.PeerAs != g.Config.As
}
func (c AfiSafis) ToRfList() ([]bgp.RouteFamily, error) {
diff --git a/docs/sources/bmp.md b/docs/sources/bmp.md
index d1515886..495a71d8 100644
--- a/docs/sources/bmp.md
+++ b/docs/sources/bmp.md
@@ -16,13 +16,13 @@ Add `[BmpServers]` section to enable BMP like below.
```toml
[Global]
- [Global.GlobalConfig]
+ [Global.Config]
As = 64512
RouterId = "192.168.255.1"
[BmpServers]
[[BmpServers.BmpServerList]]
- [BmpServers.BmpServerList.BmpServerConfig]
+ [BmpServers.BmpServerList.Config]
Address = "127.0.0.1"
Port=11019
```
diff --git a/docs/sources/cli-operations.md b/docs/sources/cli-operations.md
index 66fbe367..dd1cc560 100644
--- a/docs/sources/cli-operations.md
+++ b/docs/sources/cli-operations.md
@@ -31,33 +31,33 @@ should be like the following.
```
[Global]
- [Global.GlobalConfig]
+ [Global.Config]
As = 64512
RouterId = "192.168.255.1"
[Neighbors]
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "10.0.255.1"
PeerAs = 65001
[Neighbors.NeighborList.RouteServer]
- [Neighbors.NeighborList.RouteServer.RouteServerConfig]
+ [Neighbors.NeighborList.RouteServer.Config]
RouteServerClient = true
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "10.0.255.2"
PeerAs = 65002
[Neighbors.NeighborList.RouteServer]
- [Neighbors.NeighborList.RouteServer.RouteServerConfig]
+ [Neighbors.NeighborList.RouteServer.Config]
RouteServerClient = true
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "10.0.255.3"
PeerAs = 65003
[Neighbors.NeighborList.RouteServer]
- [Neighbors.NeighborList.RouteServer.RouteServerConfig]
+ [Neighbors.NeighborList.RouteServer.Config]
RouteServerClient = true
```
@@ -119,4 +119,4 @@ $ gobgp neighbor 10.0.255.1 softresetout
```
-You can know more about gobgp command syntax [here](https://github.com/osrg/gobgp/blob/master/docs/sources/cli-command-syntax.md). \ No newline at end of file
+You can know more about gobgp command syntax [here](https://github.com/osrg/gobgp/blob/master/docs/sources/cli-command-syntax.md).
diff --git a/docs/sources/evpn.md b/docs/sources/evpn.md
index fb5d156f..71fef620 100644
--- a/docs/sources/evpn.md
+++ b/docs/sources/evpn.md
@@ -20,13 +20,13 @@ implementations can interchange EVPN messages.
```
[Global]
- [Global.GlobalConfig]
+ [Global.Config]
As = 64512
RouterId = "192.168.255.1"
[Neighbors]
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "10.0.255.1"
PeerAs = 64512
[Neighbors.NeighborList.AfiSafis]
@@ -34,7 +34,7 @@ implementations can interchange EVPN messages.
AfiSafiName = "l2vpn-evpn"
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "10.0.255.2"
PeerAs = 64512
[Neighbors.NeighborList.AfiSafis]
diff --git a/docs/sources/flowspec.md b/docs/sources/flowspec.md
index 6fbfb737..a55d68a9 100644
--- a/docs/sources/flowspec.md
+++ b/docs/sources/flowspec.md
@@ -19,13 +19,13 @@ afi-safi-list like below.
```toml
[Global]
- [Global.GlobalConfig]
+ [Global.Config]
As = 64512
RouterId = "192.168.255.1"
[Neighbors]
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "10.0.255.1"
PeerAs = 64512
[Neighbors.NeighborList.AfiSafis]
diff --git a/docs/sources/getting-started.md b/docs/sources/getting-started.md
index 700703fc..d7929146 100644
--- a/docs/sources/getting-started.md
+++ b/docs/sources/getting-started.md
@@ -36,18 +36,18 @@ uses the following very simple configuration file, `gobgpd.conf`:
```
$ cat gobgpd.conf
[Global]
- [Global.GlobalConfig]
+ [Global.Config]
As = 64512
RouterId = "192.168.255.1"
[Neighbors]
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "10.0.255.1"
PeerAs = 65001
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "10.0.255.2"
PeerAs = 65002
```
diff --git a/docs/sources/mrt.md b/docs/sources/mrt.md
index 3a3ac6df..5818a8cc 100644
--- a/docs/sources/mrt.md
+++ b/docs/sources/mrt.md
@@ -93,16 +93,16 @@ Configuration is something like below.
```
$ cat gobgpd.conf
[Global]
- [Global.GlobalConfig]
+ [Global.Config]
As = 64512
RouterId = "192.168.255.1"
[Neighbors]
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "10.0.0.1"
PeerAs = 65001
[Neighbors.NeighborList.RouteServer]
- [Neighbors.NeighborList.RouteServer.RouteServerConfig]
+ [Neighbors.NeighborList.RouteServer.Config]
RouteServerClient = true
```
diff --git a/docs/sources/policy.md b/docs/sources/policy.md
index e48f1bb3..1e97be6b 100644
--- a/docs/sources/policy.md
+++ b/docs/sources/policy.md
@@ -760,14 +760,14 @@ This example attatches *policy1* to Import policy and *policy2* to Export policy
```
[Neighbors]
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "10.0.255.2"
PeerAs = 65002
[Neighbors.NeighborList.RouteServer]
- [Neighbors.NeighborList.RouteServer.RouteServerConfig]
+ [Neighbors.NeighborList.RouteServer.Config]
RouteServerClient = true
[Neighbors.NeighborList.ApplyPolicy]
- [Neighbors.NeighborList.ApplyPolicy.ApplyPolicyConfig]
+ [Neighbors.NeighborList.ApplyPolicy.Config]
ImportPolicy = ["policy1"]
ExportPolicy = ["policy2"]
InPolicy = ["policy3"]
@@ -812,30 +812,30 @@ define an import policy for neighbor 10.0.255.2 that drops
[Neighbors]
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "10.0.255.1"
PeerAs = 65001
[Neighbors.NeighborList.RouteServer]
- [Neighbors.NeighborList.RouteServer.RouteServerConfig]
+ [Neighbors.NeighborList.RouteServer.Config]
RouteServerClient = true
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "10.0.255.2"
PeerAs = 65002
[Neighbors.NeighborList.RouteServer]
- [Neighbors.NeighborList.RouteServer.RouteServerConfig]
+ [Neighbors.NeighborList.RouteServer.Config]
RouteServerClient = true
[Neighbors.NeighborList.ApplyPolicy]
- [Neighbors.NeighborList.ApplyPolicy.ApplyPolicyConfig]
+ [Neighbors.NeighborList.ApplyPolicy.Config]
ImportPolicy = ["pd2"]
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "10.0.255.3"
PeerAs = 65003
[Neighbors.NeighborList.RouteServer]
- [Neighbors.NeighborList.RouteServer.RouteServerConfig]
+ [Neighbors.NeighborList.RouteServer.Config]
RouteServerClient = true
[DefinedSets]
diff --git a/docs/sources/route-reflector.md b/docs/sources/route-reflector.md
index c8fbce50..f640564b 100644
--- a/docs/sources/route-reflector.md
+++ b/docs/sources/route-reflector.md
@@ -13,30 +13,30 @@ The configuration below configures two route reflector clients and two normal iB
```toml
[Global]
- [Global.GlobalConfig]
+ [Global.Config]
RouterId = "192.168.0.1"
As = 65000
[Neighbors]
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "192.168.10.2"
PeerAs = 65000
- [Neighbors.NeighborList.RouteReflector.RouteReflectorConfig]
+ [Neighbors.NeighborList.RouteReflector.Config]
RouteReflectorClient = true
RouteReflectorClusterId = "192.168.0.1"
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "192.168.10.3"
PeerAs = 65000
- [Neighbors.NeighborList.RouteReflector.RouteReflectorConfig]
+ [Neighbors.NeighborList.RouteReflector.Config]
RouteReflectorClient = true
RouteReflectorClusterId = "192.168.0.1"
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "192.168.10.4"
PeerAs = 65000
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "192.168.10.5"
PeerAs = 65000
```
diff --git a/docs/sources/route-server.md b/docs/sources/route-server.md
index 94751c77..f628e02a 100644
--- a/docs/sources/route-server.md
+++ b/docs/sources/route-server.md
@@ -18,33 +18,33 @@ the configuration file used in [Getting Started](https://github.com/osrg/gobgp/b
```
$ cat gobgpd.conf
[Global]
- [Global.GlobalConfig]
+ [Global.Config]
As = 64512
RouterId = "192.168.255.1"
[Neighbors]
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "10.0.255.1"
PeerAs = 65001
AuthPassword = "hoge1"
[Neighbors.NeighborList.Transport]
- [Neighbors.NeighborList.Transport.TransportConfig]
+ [Neighbors.NeighborList.Transport.Config]
PassiveMode = true
[Neighbors.NeighborList.RouteServer]
- [Neighbors.NeighborList.RouteServer.RouteServerConfig]
+ [Neighbors.NeighborList.RouteServer.Config]
RouteServerClient = true
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
NeighborAddress = "10.0.255.2"
PeerAs = 65002
AuthPassword = "hoge2"
[Neighbors.NeighborList.Transport]
- [Neighbors.NeighborList.Transport.TransportConfig]
+ [Neighbors.NeighborList.Transport.Config]
PassiveMode = true
[Neighbors.NeighborList.RouteServer]
- [Neighbors.NeighborList.RouteServer.RouteServerConfig]
+ [Neighbors.NeighborList.RouteServer.Config]
RouteServerClient = true
```
diff --git a/docs/sources/rpki.md b/docs/sources/rpki.md
index 552b0c48..f80098ec 100644
--- a/docs/sources/rpki.md
+++ b/docs/sources/rpki.md
@@ -21,30 +21,30 @@ setup but RPKI can be used with non route server setup.
```toml
[Global]
- [Global.GlobalConfig]
+ [Global.Config]
As = 64512
RouterId = "10.0.255.254"
[Neighbors]
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
PeerAs = 65001
NeighborAddress = "10.0.255.1"
[Neighbors.NeighborList.RouteServer]
- [Neighbors.NeighborList.RouteServer.RouteServerConfig]
+ [Neighbors.NeighborList.RouteServer.Config]
RouteServerClient = true
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
PeerAs = 65002
NeighborAddress = "10.0.255.2"
[Neighbors.NeighborList.RouteServer]
- [Neighbors.NeighborList.RouteServer.RouteServerConfig]
+ [Neighbors.NeighborList.RouteServer.Config]
RouteServerClient = true
[RpkiServers]
[[RpkiServers.RpkiServerList]]
- [RpkiServers.RpkiServerList.RpkiServerConfig]
+ [RpkiServers.RpkiServerList.Config]
Address = "210.173.170.254"
Port = 323
```
@@ -126,33 +126,33 @@ We add a policy to the above configuration.
```toml
[Global]
- [Global.GlobalConfig]
+ [Global.Config]
As = 64512
RouterId = "10.0.255.254"
[Neighbors]
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
PeerAs = 65001
NeighborAddress = "10.0.255.1"
[Neighbors.NeighborList.RouteServer]
- [Neighbors.NeighborList.RouteServer.RouteServerConfig]
+ [Neighbors.NeighborList.RouteServer.Config]
RouteServerClient = true
[[Neighbors.NeighborList]]
- [Neighbors.NeighborList.NeighborConfig]
+ [Neighbors.NeighborList.Config]
PeerAs = 65002
NeighborAddress = "10.0.255.2"
[Neighbors.NeighborList.RouteServer]
- [Neighbors.NeighborList.RouteServer.RouteServerConfig]
+ [Neighbors.NeighborList.RouteServer.Config]
RouteServerClient = true
[Neighbors.NeighborList.ApplyPolicy]
- [Neighbors.NeighborList.ApplyPolicy.ApplyPolicyConfig]
+ [Neighbors.NeighborList.ApplyPolicy.Config]
ImportPolicy = ["AS65002-IMPORT-RPKI"]
[RpkiServers]
[[RpkiServers.RpkiServerList]]
- [RpkiServers.RpkiServerList.RpkiServerConfig]
+ [RpkiServers.RpkiServerList.Config]
Address = "210.173.170.254"
Port = 323
diff --git a/gobgpd/main.go b/gobgpd/main.go
index 50c12a96..32743497 100644
--- a/gobgpd/main.go
+++ b/gobgpd/main.go
@@ -210,15 +210,15 @@ func main() {
}
for _, p := range added {
- log.Infof("Peer %v is added", p.NeighborConfig.NeighborAddress)
+ log.Infof("Peer %v is added", p.Config.NeighborAddress)
bgpServer.PeerAdd(p)
}
for _, p := range deleted {
- log.Infof("Peer %v is deleted", p.NeighborConfig.NeighborAddress)
+ log.Infof("Peer %v is deleted", p.Config.NeighborAddress)
bgpServer.PeerDelete(p)
}
for _, p := range updated {
- log.Infof("Peer %v is updated", p.NeighborConfig.NeighborAddress)
+ log.Infof("Peer %v is updated", p.Config.NeighborAddress)
bgpServer.PeerUpdate(p)
}
case sig := <-sigCh:
diff --git a/server/bmp.go b/server/bmp.go
index 9496236d..2a5b245a 100644
--- a/server/bmp.go
+++ b/server/bmp.go
@@ -71,7 +71,7 @@ func newBMPClient(conf config.BmpServers, connCh chan *bmpConn) (*bmpClient, err
}
for _, c := range conf.BmpServerList {
- b := c.BmpServerConfig
+ b := c.Config
go tryConnect(net.JoinHostPort(b.Address.String(), strconv.Itoa(int(b.Port))))
}
@@ -98,7 +98,7 @@ func newBMPClient(conf config.BmpServers, connCh chan *bmpConn) (*bmpClient, err
if msg.Header.Type == bgp.BMP_MSG_ROUTE_MONITORING {
c := func() *config.BmpServerConfig {
for _, c := range conf.BmpServerList {
- b := &c.BmpServerConfig
+ b := &c.Config
if host == net.JoinHostPort(b.Address.String(), strconv.Itoa(int(b.Port))) {
return b
}
diff --git a/server/fsm.go b/server/fsm.go
index 2d952065..d05e9e23 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -90,7 +90,7 @@ type FSM struct {
}
func (fsm *FSM) bgpMessageStateUpdate(MessageType uint8, isIn bool) {
- state := &fsm.pConf.NeighborState.Messages
+ state := &fsm.pConf.State.Messages
timer := &fsm.pConf.Timers
if isIn {
state.Received.Total++
@@ -107,7 +107,7 @@ func (fsm *FSM) bgpMessageStateUpdate(MessageType uint8, isIn bool) {
case bgp.BGP_MSG_UPDATE:
if isIn {
state.Received.Update++
- timer.TimersState.UpdateRecvTime = time.Now().Unix()
+ timer.State.UpdateRecvTime = time.Now().Unix()
} else {
state.Sent.Update++
}
@@ -140,7 +140,7 @@ func (fsm *FSM) bgpMessageStateUpdate(MessageType uint8, isIn bool) {
func NewFSM(gConf *config.Global, pConf *config.Neighbor, policy *table.RoutingPolicy) *FSM {
adminState := ADMIN_STATE_UP
- if pConf.NeighborState.AdminDown == true {
+ if pConf.State.AdminDown {
adminState = ADMIN_STATE_DOWN
}
fsm := &FSM{
@@ -164,22 +164,22 @@ func NewFSM(gConf *config.Global, pConf *config.Neighbor, policy *table.RoutingP
func (fsm *FSM) StateChange(nextState bgp.FSMState) {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"old": fsm.state.String(),
"new": nextState.String(),
}).Debug("state changed")
fsm.state = nextState
switch nextState {
case bgp.BGP_FSM_ESTABLISHED:
- fsm.pConf.Timers.TimersState.Uptime = time.Now().Unix()
- fsm.pConf.NeighborState.EstablishedCount++
+ fsm.pConf.Timers.State.Uptime = time.Now().Unix()
+ fsm.pConf.State.EstablishedCount++
case bgp.BGP_FSM_ACTIVE:
- if !fsm.pConf.Transport.TransportConfig.PassiveMode {
+ if !fsm.pConf.Transport.Config.PassiveMode {
fsm.getActiveCh <- struct{}{}
}
fallthrough
default:
- fsm.pConf.Timers.TimersState.Downtime = time.Now().Unix()
+ fsm.pConf.Timers.State.Downtime = time.Now().Unix()
}
}
@@ -215,7 +215,7 @@ func (fsm *FSM) sendNotificatonFromErrorMsg(conn net.Conn, e *bgp.MessageError)
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"Data": e,
}).Warn("sent notification")
}
@@ -227,7 +227,7 @@ func (fsm *FSM) sendNotification(conn net.Conn, code, subType uint8, data []byte
func (fsm *FSM) connectLoop() error {
var tick int
- if tick = int(fsm.pConf.Timers.TimersConfig.ConnectRetry); tick < MIN_CONNECT_RETRY {
+ if tick = int(fsm.pConf.Timers.Config.ConnectRetry); tick < MIN_CONNECT_RETRY {
tick = MIN_CONNECT_RETRY
}
@@ -236,17 +236,17 @@ func (fsm *FSM) connectLoop() error {
connect := func() {
if fsm.state == bgp.BGP_FSM_ACTIVE {
- addr := fsm.pConf.NeighborConfig.NeighborAddress
+ addr := fsm.pConf.Config.NeighborAddress
host := net.JoinHostPort(addr.String(), strconv.Itoa(bgp.BGP_PORT))
// check if LocalAddress has been configured
- laddr := fsm.pConf.Transport.TransportConfig.LocalAddress
+ laddr := fsm.pConf.Transport.Config.LocalAddress
if laddr != nil {
lhost := net.JoinHostPort(laddr.String(), "0")
ltcpaddr, err := net.ResolveTCPAddr("tcp", lhost)
if err != nil {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
}).Warnf("failed to resolve ltcpaddr: %s", err)
} else {
d := net.Dialer{LocalAddr: ltcpaddr, Timeout: time.Duration(MIN_CONNECT_RETRY-1) * time.Second}
@@ -255,7 +255,7 @@ func (fsm *FSM) connectLoop() error {
} else {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
}).Debugf("failed to connect from ltcpaddr", err)
}
}
@@ -267,7 +267,7 @@ func (fsm *FSM) connectLoop() error {
} else {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
}).Debugf("failed to connect: %s", err)
}
}
@@ -279,7 +279,7 @@ func (fsm *FSM) connectLoop() error {
case <-fsm.t.Dying():
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
}).Debug("stop connect loop")
ticker.Stop()
return nil
@@ -330,14 +330,14 @@ func (h *FSMHandler) idle() bgp.FSMState {
conn.Close()
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
}).Warn("Closed an accepted connection")
case <-idleHoldTimer.C:
if fsm.adminState == ADMIN_STATE_UP {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"Duration": fsm.idleHoldTime,
}).Debug("IdleHoldTimer expired")
fsm.idleHoldTime = HOLDTIME_IDLE
@@ -375,10 +375,10 @@ func (h *FSMHandler) active() bgp.FSMState {
break
}
fsm.conn = conn
- if fsm.gConf.GlobalConfig.As != fsm.pConf.NeighborConfig.PeerAs {
+ if fsm.gConf.Config.As != fsm.pConf.Config.PeerAs {
ttl := 1
- if fsm.pConf.EbgpMultihop.EbgpMultihopConfig.Enabled == true {
- ttl = int(fsm.pConf.EbgpMultihop.EbgpMultihopConfig.MultihopTtl)
+ if fsm.pConf.EbgpMultihop.Config.Enabled == true {
+ ttl = int(fsm.pConf.EbgpMultihop.Config.MultihopTtl)
}
if ttl != 0 {
SetTcpTTLSockopts(conn.(*net.TCPConn), ttl)
@@ -398,7 +398,7 @@ func (h *FSMHandler) active() bgp.FSMState {
case ADMIN_STATE_UP:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
"AdminState": s.String(),
}).Panic("code logic bug")
@@ -415,19 +415,19 @@ func capabilitiesFromConfig(gConf *config.Global, pConf *config.Neighbor) []bgp.
k, _ := bgp.GetRouteFamily(rf.AfiSafiName)
caps = append(caps, bgp.NewCapMultiProtocol(k))
}
- caps = append(caps, bgp.NewCapFourOctetASNumber(gConf.GlobalConfig.As))
+ caps = append(caps, bgp.NewCapFourOctetASNumber(gConf.Config.As))
return caps
}
func buildopen(gConf *config.Global, pConf *config.Neighbor) *bgp.BGPMessage {
caps := capabilitiesFromConfig(gConf, pConf)
opt := bgp.NewOptionParameterCapability(caps)
- holdTime := uint16(pConf.Timers.TimersConfig.HoldTime)
- as := gConf.GlobalConfig.As
+ holdTime := uint16(pConf.Timers.Config.HoldTime)
+ as := gConf.Config.As
if as > (1<<16)-1 {
as = bgp.AS_TRANS
}
- return bgp.NewBGPOpenMessage(uint16(as), holdTime, gConf.GlobalConfig.RouterId.String(),
+ return bgp.NewBGPOpenMessage(uint16(as), holdTime, gConf.Config.RouterId.String(),
[]bgp.OptionParameterInterface{opt})
}
@@ -453,14 +453,14 @@ func (h *FSMHandler) recvMessageWithError() error {
h.fsm.bgpMessageStateUpdate(0, true)
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": h.fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": h.fsm.pConf.Config.NeighborAddress,
"State": h.fsm.state,
"error": err,
}).Warn("malformed BGP Header")
h.msgCh <- &FsmMsg{
MsgType: FSM_MSG_BGP_MESSAGE,
- MsgSrc: h.fsm.pConf.NeighborConfig.NeighborAddress.String(),
- MsgDst: h.fsm.pConf.Transport.TransportConfig.LocalAddress.String(),
+ MsgSrc: h.fsm.pConf.Config.NeighborAddress.String(),
+ MsgDst: h.fsm.pConf.Transport.Config.LocalAddress.String(),
MsgData: err,
}
return err
@@ -482,14 +482,14 @@ func (h *FSMHandler) recvMessageWithError() error {
}
fmsg := &FsmMsg{
MsgType: FSM_MSG_BGP_MESSAGE,
- MsgSrc: h.fsm.pConf.NeighborConfig.NeighborAddress.String(),
- MsgDst: h.fsm.pConf.Transport.TransportConfig.LocalAddress.String(),
+ MsgSrc: h.fsm.pConf.Config.NeighborAddress.String(),
+ MsgDst: h.fsm.pConf.Transport.Config.LocalAddress.String(),
timestamp: now,
}
if err != nil {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": h.fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": h.fsm.pConf.Config.NeighborAddress,
"State": h.fsm.state,
"error": err,
}).Warn("malformed BGP message")
@@ -504,7 +504,7 @@ func (h *FSMHandler) recvMessageWithError() error {
if err != nil {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": h.fsm.pConf.NeighborConfig.NeighborAddress.String(),
+ "Key": h.fsm.pConf.Config.NeighborAddress.String(),
"error": err,
}).Warn("malformed BGP update message")
fmsg.MsgData = err
@@ -512,7 +512,7 @@ func (h *FSMHandler) recvMessageWithError() error {
// FIXME: we should use the original message for bmp/mrt
table.UpdatePathAttrs4ByteAs(body)
fmsg.PathList = table.ProcessMessage(m, h.fsm.peerInfo, fmsg.timestamp)
- id := h.fsm.pConf.NeighborConfig.NeighborAddress.String()
+ id := h.fsm.pConf.Config.NeighborAddress.String()
policyMutex.RLock()
for _, path := range fmsg.PathList {
if h.fsm.policy.ApplyPolicy(id, table.POLICY_DIRECTION_IN, path) == nil {
@@ -576,7 +576,7 @@ func (h *FSMHandler) opensent() bgp.FSMState {
conn.Close()
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
}).Warn("Closed an accepted connection")
case e := <-h.msgCh:
@@ -585,7 +585,7 @@ func (h *FSMHandler) opensent() bgp.FSMState {
m := e.MsgData.(*bgp.BGPMessage)
if m.Header.Type == bgp.BGP_MSG_OPEN {
body := m.Body.(*bgp.BGPOpen)
- err := bgp.ValidateOpenMsg(body, fsm.pConf.NeighborConfig.PeerAs)
+ err := bgp.ValidateOpenMsg(body, fsm.pConf.Config.PeerAs)
if err != nil {
fsm.sendNotificatonFromErrorMsg(h.conn, err.(*bgp.MessageError))
return bgp.BGP_FSM_IDLE
@@ -595,8 +595,8 @@ func (h *FSMHandler) opensent() bgp.FSMState {
e := &FsmMsg{
MsgType: FSM_MSG_BGP_MESSAGE,
- MsgSrc: fsm.pConf.NeighborConfig.NeighborAddress.String(),
- MsgDst: fsm.pConf.Transport.TransportConfig.LocalAddress.String(),
+ MsgSrc: fsm.pConf.Config.NeighborAddress.String(),
+ MsgDst: fsm.pConf.Transport.Config.LocalAddress.String(),
MsgData: m,
}
h.incoming <- e
@@ -616,7 +616,7 @@ func (h *FSMHandler) opensent() bgp.FSMState {
default:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
"Data": e.MsgData,
}).Panic("unknown msg type")
@@ -638,7 +638,7 @@ func (h *FSMHandler) opensent() bgp.FSMState {
case ADMIN_STATE_UP:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
"AdminState": s.String(),
}).Panic("code logic bug")
@@ -652,8 +652,8 @@ func keepaliveTicker(fsm *FSM) *time.Ticker {
if fsm.negotiatedHoldTime == 0 {
return &time.Ticker{}
}
- sec := time.Second * time.Duration(fsm.pConf.Timers.TimersConfig.KeepaliveInterval)
- if fsm.negotiatedHoldTime < fsm.pConf.Timers.TimersConfig.HoldTime {
+ sec := time.Second * time.Duration(fsm.pConf.Timers.Config.KeepaliveInterval)
+ if fsm.negotiatedHoldTime < fsm.pConf.Timers.Config.HoldTime {
sec = time.Second * time.Duration(fsm.negotiatedHoldTime) / 3
}
if sec == 0 {
@@ -691,7 +691,7 @@ func (h *FSMHandler) openconfirm() bgp.FSMState {
conn.Close()
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
}).Warn("Closed an accepted connection")
case <-ticker.C:
@@ -718,7 +718,7 @@ func (h *FSMHandler) openconfirm() bgp.FSMState {
default:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
"Data": e.MsgData,
}).Panic("unknown msg type")
@@ -740,7 +740,7 @@ func (h *FSMHandler) openconfirm() bgp.FSMState {
case ADMIN_STATE_UP:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
"AdminState": s.String(),
}).Panic("code logic bug")
@@ -750,7 +750,7 @@ func (h *FSMHandler) openconfirm() bgp.FSMState {
}
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
}).Panic("code logic bug")
return 0
@@ -765,7 +765,7 @@ func (h *FSMHandler) sendMessageloop() error {
if err != nil {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
"Data": err,
}).Warn("failed to serialize")
@@ -781,7 +781,7 @@ func (h *FSMHandler) sendMessageloop() error {
if err != nil {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
"Data": err,
}).Warn("failed to send")
@@ -794,7 +794,7 @@ func (h *FSMHandler) sendMessageloop() error {
if m.Header.Type == bgp.BGP_MSG_NOTIFICATION {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
"Data": m,
}).Warn("sent notification")
@@ -806,7 +806,7 @@ func (h *FSMHandler) sendMessageloop() error {
} else {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
"data": m,
}).Debug("sent")
@@ -879,7 +879,7 @@ func (h *FSMHandler) established() bgp.FSMState {
conn.Close()
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
}).Warn("Closed an accepted connection")
case <-h.errorCh:
@@ -890,7 +890,7 @@ func (h *FSMHandler) established() bgp.FSMState {
case <-holdTimer.C:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
"data": bgp.BGP_FSM_ESTABLISHED,
}).Warn("hold timer expired")
@@ -950,7 +950,7 @@ func (h *FSMHandler) loop() error {
if nextState == bgp.BGP_FSM_ESTABLISHED && oldState == bgp.BGP_FSM_OPENCONFIRM {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
}).Info("Peer Up")
}
@@ -958,14 +958,14 @@ func (h *FSMHandler) loop() error {
if oldState == bgp.BGP_FSM_ESTABLISHED {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
"Reason": h.reason,
}).Info("Peer Down")
}
e := time.AfterFunc(time.Second*120, func() {
- log.Fatal("failed to free the fsm.h.t for ", fsm.pConf.NeighborConfig.NeighborAddress, oldState, nextState)
+ log.Fatal("failed to free the fsm.h.t for ", fsm.pConf.Config.NeighborAddress, oldState, nextState)
})
h.t.Wait()
e.Stop()
@@ -974,8 +974,8 @@ func (h *FSMHandler) loop() error {
if nextState >= bgp.BGP_FSM_IDLE {
e := &FsmMsg{
MsgType: FSM_MSG_STATE_CHANGE,
- MsgSrc: fsm.pConf.NeighborConfig.NeighborAddress.String(),
- MsgDst: fsm.pConf.Transport.TransportConfig.LocalAddress.String(),
+ MsgSrc: fsm.pConf.Config.NeighborAddress.String(),
+ MsgDst: fsm.pConf.Transport.Config.LocalAddress.String(),
MsgData: nextState,
}
h.incoming <- e
@@ -988,7 +988,7 @@ func (h *FSMHandler) changeAdminState(s AdminState) error {
if fsm.adminState != s {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
"AdminState": s.String(),
}).Debug("admin state changed")
@@ -999,14 +999,14 @@ func (h *FSMHandler) changeAdminState(s AdminState) error {
case ADMIN_STATE_UP:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
}).Info("Administrative start")
case ADMIN_STATE_DOWN:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
}).Info("Administrative shutdown")
}
@@ -1014,7 +1014,7 @@ func (h *FSMHandler) changeAdminState(s AdminState) error {
} else {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": fsm.pConf.NeighborConfig.NeighborAddress,
+ "Key": fsm.pConf.Config.NeighborAddress,
"State": fsm.state,
}).Warn("cannot change to the same state")
diff --git a/server/fsm_test.go b/server/fsm_test.go
index 3b1bedd2..b5618edd 100644
--- a/server/fsm_test.go
+++ b/server/fsm_test.go
@@ -190,7 +190,7 @@ func TestFSMHandlerOpenconfirm_HoldTimerExpired(t *testing.T) {
p.fsm.conn = m
// set up keepalive ticker
- p.fsm.pConf.Timers.TimersConfig.KeepaliveInterval = 1
+ p.fsm.pConf.Timers.Config.KeepaliveInterval = 1
// set holdtime
p.fsm.negotiatedHoldTime = 2
@@ -227,7 +227,7 @@ func TestFSMHandlerEstablish_HoldTimerExpired(t *testing.T) {
}
// set holdtime
- p.fsm.pConf.Timers.TimersConfig.HoldTime = 2
+ p.fsm.pConf.Timers.Config.HoldTime = 2
p.fsm.negotiatedHoldTime = 2
go pushPackets()
@@ -251,7 +251,7 @@ func TestFSMHandlerOpenconfirm_HoldtimeZero(t *testing.T) {
p.fsm.conn = m
// set up keepalive ticker
- p.fsm.pConf.Timers.TimersConfig.KeepaliveInterval = 1
+ p.fsm.pConf.Timers.Config.KeepaliveInterval = 1
// set holdtime
p.fsm.negotiatedHoldTime = 0
go h.openconfirm()
diff --git a/server/peer.go b/server/peer.go
index f1f73580..f7c31fda 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -58,11 +58,11 @@ func NewPeer(g config.Global, conf config.Neighbor, loc *table.TableManager, pol
}
tableId := table.GLOBAL_RIB_NAME
if peer.isRouteServerClient() {
- tableId = conf.NeighborConfig.NeighborAddress.String()
+ tableId = conf.Config.NeighborAddress.String()
}
peer.tableId = tableId
- conf.NeighborState.SessionState = uint32(bgp.BGP_FSM_IDLE)
- conf.Timers.TimersState.Downtime = time.Now().Unix()
+ conf.State.SessionState = uint32(bgp.BGP_FSM_IDLE)
+ conf.Timers.State.Downtime = time.Now().Unix()
rfs, _ := conf.AfiSafis.ToRfList()
peer.adjRibIn = table.NewAdjRib(peer.ID(), rfs)
peer.adjRibOut = table.NewAdjRib(peer.ID(), rfs)
@@ -79,7 +79,7 @@ func (peer *Peer) Outgoing() chan *bgp.BGPMessage {
}
func (peer *Peer) ID() string {
- return peer.conf.NeighborConfig.NeighborAddress.String()
+ return peer.conf.Config.NeighborAddress.String()
}
func (peer *Peer) TableID() string {
@@ -87,15 +87,15 @@ func (peer *Peer) TableID() string {
}
func (peer *Peer) isIBGPPeer() bool {
- return peer.conf.NeighborConfig.PeerAs == peer.gConf.GlobalConfig.As
+ return peer.conf.Config.PeerAs == peer.gConf.Config.As
}
func (peer *Peer) isRouteServerClient() bool {
- return peer.conf.RouteServer.RouteServerConfig.RouteServerClient
+ return peer.conf.RouteServer.Config.RouteServerClient
}
func (peer *Peer) isRouteReflectorClient() bool {
- return peer.conf.RouteReflector.RouteReflectorConfig.RouteReflectorClient
+ return peer.conf.RouteReflector.Config.RouteReflectorClient
}
func (peer *Peer) configuredRFlist() []bgp.RouteFamily {
@@ -157,7 +157,7 @@ func (peer *Peer) handleBGPmessage(e *FsmMsg) ([]*table.Path, []*bgp.BGPMessage)
m := e.MsgData.(*bgp.BGPMessage)
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.conf.NeighborConfig.NeighborAddress,
+ "Key": peer.conf.Config.NeighborAddress,
"data": m,
}).Debug("received")
@@ -173,7 +173,7 @@ func (peer *Peer) handleBGPmessage(e *FsmMsg) ([]*table.Path, []*bgp.BGPMessage)
// by using the smaller of its configured Hold Time and the Hold Time
// received in the OPEN message.
holdTime := float64(body.HoldTime)
- myHoldTime := peer.conf.Timers.TimersConfig.HoldTime
+ myHoldTime := peer.conf.Timers.Config.HoldTime
if holdTime > myHoldTime {
peer.fsm.negotiatedHoldTime = myHoldTime
} else {
@@ -186,7 +186,7 @@ func (peer *Peer) handleBGPmessage(e *FsmMsg) ([]*table.Path, []*bgp.BGPMessage)
if _, ok := peer.rfMap[rf]; !ok {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.conf.NeighborConfig.NeighborAddress,
+ "Key": peer.conf.Config.NeighborAddress,
"Data": rf,
}).Warn("Route family isn't supported")
break
@@ -204,12 +204,12 @@ func (peer *Peer) handleBGPmessage(e *FsmMsg) ([]*table.Path, []*bgp.BGPMessage)
} else {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.conf.NeighborConfig.NeighborAddress,
+ "Key": peer.conf.Config.NeighborAddress,
}).Warn("ROUTE_REFRESH received but the capability wasn't advertised")
}
case bgp.BGP_MSG_UPDATE:
- peer.conf.Timers.TimersState.UpdateRecvTime = time.Now().Unix()
+ peer.conf.Timers.State.UpdateRecvTime = time.Now().Unix()
if len(e.PathList) > 0 {
peer.adjRibIn.Update(e.PathList)
paths := make([]*table.Path, 0, len(e.PathList))
@@ -224,7 +224,7 @@ func (peer *Peer) handleBGPmessage(e *FsmMsg) ([]*table.Path, []*bgp.BGPMessage)
body := m.Body.(*bgp.BGPNotification)
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.conf.NeighborConfig.NeighborAddress,
+ "Key": peer.conf.Config.NeighborAddress,
"Code": body.ErrorCode,
"Subcode": body.ErrorSubcode,
"Data": body.Data,
@@ -244,7 +244,7 @@ func (peer *Peer) PassConn(conn *net.TCPConn) {
conn.Close()
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.conf.NeighborConfig.NeighborAddress,
+ "Key": peer.conf.Config.NeighborAddress,
}).Warn("accepted conn is closed to avoid be blocked")
}
}
@@ -274,23 +274,23 @@ func (peer *Peer) ToApiStruct() *api.Peer {
}
conf := &api.PeerConf{
- NeighborAddress: c.NeighborConfig.NeighborAddress.String(),
+ NeighborAddress: c.Config.NeighborAddress.String(),
Id: peer.fsm.peerInfo.ID.To4().String(),
- PeerAs: c.NeighborConfig.PeerAs,
- LocalAs: c.NeighborConfig.LocalAs,
- PeerType: uint32(c.NeighborConfig.PeerType),
- AuthPassword: c.NeighborConfig.AuthPassword,
- RemovePrivateAs: uint32(c.NeighborConfig.RemovePrivateAs),
- RouteFlapDamping: c.NeighborConfig.RouteFlapDamping,
- SendCommunity: uint32(c.NeighborConfig.SendCommunity),
- Description: c.NeighborConfig.Description,
- PeerGroup: c.NeighborConfig.PeerGroup,
+ PeerAs: c.Config.PeerAs,
+ LocalAs: c.Config.LocalAs,
+ PeerType: uint32(c.Config.PeerType),
+ AuthPassword: c.Config.AuthPassword,
+ RemovePrivateAs: uint32(c.Config.RemovePrivateAs),
+ RouteFlapDamping: c.Config.RouteFlapDamping,
+ SendCommunity: uint32(c.Config.SendCommunity),
+ Description: c.Config.Description,
+ PeerGroup: c.Config.PeerGroup,
RemoteCap: remoteCap,
LocalCap: localCap,
}
timer := &c.Timers
- s := &c.NeighborState
+ s := &c.State
advertized := uint32(0)
received := uint32(0)
@@ -303,28 +303,28 @@ func (peer *Peer) ToApiStruct() *api.Peer {
}
uptime := int64(0)
- if timer.TimersState.Uptime != 0 {
- uptime = int64(time.Now().Sub(time.Unix(timer.TimersState.Uptime, 0)).Seconds())
+ if timer.State.Uptime != 0 {
+ uptime = int64(time.Now().Sub(time.Unix(timer.State.Uptime, 0)).Seconds())
}
downtime := int64(0)
- if timer.TimersState.Downtime != 0 {
- downtime = int64(time.Now().Sub(time.Unix(timer.TimersState.Downtime, 0)).Seconds())
+ if timer.State.Downtime != 0 {
+ downtime = int64(time.Now().Sub(time.Unix(timer.State.Downtime, 0)).Seconds())
}
keepalive := uint32(0)
if f.negotiatedHoldTime != 0 {
- if f.negotiatedHoldTime < timer.TimersConfig.HoldTime {
+ if f.negotiatedHoldTime < timer.Config.HoldTime {
keepalive = uint32(f.negotiatedHoldTime / 3)
} else {
- keepalive = uint32(timer.TimersConfig.KeepaliveInterval)
+ keepalive = uint32(timer.Config.KeepaliveInterval)
}
}
timerconf := &api.TimersConfig{
- ConnectRetry: uint64(timer.TimersConfig.ConnectRetry),
- HoldTime: uint64(timer.TimersConfig.HoldTime),
+ ConnectRetry: uint64(timer.Config.ConnectRetry),
+ HoldTime: uint64(timer.Config.HoldTime),
KeepaliveInterval: uint64(keepalive),
- MinimumAdvertisementInterval: uint64(timer.TimersConfig.MinimumAdvertisementInterval),
+ MinimumAdvertisementInterval: uint64(timer.Config.MinimumAdvertisementInterval),
}
timerstate := &api.TimersState{
diff --git a/server/rpki.go b/server/rpki.go
index cbe6ad6b..a5f5dbee 100644
--- a/server/rpki.go
+++ b/server/rpki.go
@@ -103,7 +103,7 @@ func newROAManager(as uint32, conf config.RpkiServers) (*roaManager, error) {
m.clientMap = make(map[string]*roaClient)
for _, entry := range conf.RpkiServerList {
- c := entry.RpkiServerConfig
+ c := entry.Config
client := &roaClient{
host: net.JoinHostPort(c.Address.String(), strconv.Itoa(int(c.Port))),
eventCh: m.eventCh,
diff --git a/server/server.go b/server/server.go
index 670deee4..a29e7e91 100644
--- a/server/server.go
+++ b/server/server.go
@@ -167,7 +167,7 @@ func (server *BgpServer) Serve() {
}
server.bmpClient, _ = newBMPClient(config.BmpServers{BmpServerList: []config.BmpServer{}}, server.bmpConnCh)
- server.roaManager, _ = newROAManager(g.GlobalConfig.As, config.RpkiServers{})
+ server.roaManager, _ = newROAManager(g.Config.As, config.RpkiServers{})
if g.Mrt.FileName != "" {
w, err := newMrtWatcher(g.Mrt.FileName)
@@ -296,7 +296,7 @@ func (server *BgpServer) Serve() {
return false
}
return true
- }(peer.conf.Transport.TransportConfig.LocalAddress)
+ }(peer.conf.Transport.Config.LocalAddress)
if localAddrValid == false {
conn.Close()
return
@@ -322,7 +322,7 @@ func (server *BgpServer) Serve() {
select {
case c := <-server.rpkiConfigCh:
- server.roaManager, _ = newROAManager(server.bgpConfig.Global.GlobalConfig.As, c)
+ server.roaManager, _ = newROAManager(server.bgpConfig.Global.Config.As, c)
case c := <-server.bmpConfigCh:
server.bmpClient, _ = newBMPClient(c, server.bmpConnCh)
case c := <-server.bmpConnCh:
@@ -360,14 +360,14 @@ func (server *BgpServer) Serve() {
case conn := <-acceptCh:
passConn(conn)
case config := <-server.addedPeerCh:
- addr := config.NeighborConfig.NeighborAddress.String()
+ addr := config.Config.NeighborAddress.String()
_, found := server.neighborMap[addr]
if found {
log.Warn("Can't overwrite the exising peer ", addr)
continue
}
if g.ListenConfig.Port > 0 {
- SetTcpMD5SigSockopts(listener(config.NeighborConfig.NeighborAddress), addr, config.NeighborConfig.AuthPassword)
+ SetTcpMD5SigSockopts(listener(config.Config.NeighborAddress), addr, config.Config.AuthPassword)
}
peer := NewPeer(g, config, server.globalRib, server.policy)
server.setPolicyByConfig(peer.ID(), config.ApplyPolicy)
@@ -389,8 +389,8 @@ func (server *BgpServer) Serve() {
peer.startFSMHandler(server.fsmincomingCh)
server.broadcastPeerState(peer)
case config := <-server.deletedPeerCh:
- addr := config.NeighborConfig.NeighborAddress.String()
- SetTcpMD5SigSockopts(listener(config.NeighborConfig.NeighborAddress), addr, "")
+ addr := config.Config.NeighborAddress.String()
+ SetTcpMD5SigSockopts(listener(config.Config.NeighborAddress), addr, "")
peer, found := server.neighborMap[addr]
if found {
log.Info("Delete a peer configuration for ", addr)
@@ -414,7 +414,7 @@ func (server *BgpServer) Serve() {
log.Info("Can't delete a peer configuration for ", addr)
}
case config := <-server.updatedPeerCh:
- addr := config.NeighborConfig.NeighborAddress.String()
+ addr := config.Config.NeighborAddress.String()
peer := server.neighborMap[addr]
peer.conf = config
server.setPolicyByConfig(peer.ID(), config.ApplyPolicy)
@@ -448,14 +448,14 @@ func newSenderMsg(peer *Peer, messages []*bgp.BGPMessage) *SenderMsg {
return &SenderMsg{
messages: messages,
sendCh: peer.outgoing,
- destination: peer.conf.NeighborConfig.NeighborAddress.String(),
+ destination: peer.conf.Config.NeighborAddress.String(),
twoBytesAs: y,
}
}
func isASLoop(peer *Peer, path *table.Path) bool {
for _, as := range path.GetAsList() {
- if as == peer.conf.NeighborConfig.PeerAs {
+ if as == peer.conf.Config.PeerAs {
return true
}
}
@@ -470,7 +470,7 @@ func filterpath(peer *Peer, path *table.Path) *table.Path {
return nil
}
- remoteAddr := peer.conf.NeighborConfig.NeighborAddress
+ remoteAddr := peer.conf.Config.NeighborAddress
//iBGP handling
if !path.IsLocal() && peer.isIBGPPeer() {
@@ -478,13 +478,13 @@ func filterpath(peer *Peer, path *table.Path) *table.Path {
info := path.GetSource()
//if the path comes from eBGP peer
- if info.AS != peer.conf.NeighborConfig.PeerAs {
+ if info.AS != peer.conf.Config.PeerAs {
ignore = false
}
// RFC4456 8. Avoiding Routing Information Loops
// A router that recognizes the ORIGINATOR_ID attribute SHOULD
// ignore a route received with its BGP Identifier as the ORIGINATOR_ID.
- if id := path.GetOriginatorID(); peer.gConf.GlobalConfig.RouterId.Equal(id) {
+ if id := path.GetOriginatorID(); peer.gConf.Config.RouterId.Equal(id) {
log.WithFields(log.Fields{
"Topic": "Peer",
"Key": remoteAddr,
@@ -652,7 +652,7 @@ func (server *BgpServer) broadcastPeerState(peer *Peer) {
default:
}
ignore := req.RequestType != REQ_MONITOR_NEIGHBOR_PEER_STATE
- ignore = ignore || (req.Name != "" && req.Name != peer.conf.NeighborConfig.NeighborAddress.String())
+ ignore = ignore || (req.Name != "" && req.Name != peer.conf.Config.NeighborAddress.String())
if ignore {
remainReqs = append(remainReqs, req)
continue
@@ -770,21 +770,21 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg, incoming chan *
switch e.MsgType {
case FSM_MSG_STATE_CHANGE:
nextState := e.MsgData.(bgp.FSMState)
- oldState := bgp.FSMState(peer.conf.NeighborState.SessionState)
- peer.conf.NeighborState.SessionState = uint32(nextState)
+ oldState := bgp.FSMState(peer.conf.State.SessionState)
+ peer.conf.State.SessionState = uint32(nextState)
peer.fsm.StateChange(nextState)
if oldState == bgp.BGP_FSM_ESTABLISHED {
if ch := server.bmpClient.send(); ch != nil {
m := &broadcastBMPMsg{
ch: ch,
- msgList: []*bgp.BMPMessage{bmpPeerDown(bgp.BMP_PEER_DOWN_REASON_UNKNOWN, bgp.BMP_PEER_TYPE_GLOBAL, false, 0, peer.fsm.peerInfo, peer.conf.Timers.TimersState.Downtime)},
+ msgList: []*bgp.BMPMessage{bmpPeerDown(bgp.BMP_PEER_DOWN_REASON_UNKNOWN, bgp.BMP_PEER_TYPE_GLOBAL, false, 0, peer.fsm.peerInfo, peer.conf.Timers.State.Downtime)},
}
server.broadcastMsgs = append(server.broadcastMsgs, m)
}
t := time.Now()
- if t.Sub(time.Unix(peer.conf.Timers.TimersState.Uptime, 0)) < FLOP_THRESHOLD {
- peer.conf.NeighborState.Flops++
+ if t.Sub(time.Unix(peer.conf.Timers.State.Uptime, 0)) < FLOP_THRESHOLD {
+ peer.conf.State.Flops++
}
peer.DropAll(peer.configuredRFlist())
@@ -797,12 +797,12 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg, incoming chan *
if nextState == bgp.BGP_FSM_ESTABLISHED {
// update for export policy
laddr, lport := peer.fsm.LocalHostPort()
- peer.conf.Transport.TransportConfig.LocalAddress = net.ParseIP(laddr)
+ peer.conf.Transport.Config.LocalAddress = net.ParseIP(laddr)
if ch := server.bmpClient.send(); ch != nil {
_, rport := peer.fsm.RemoteHostPort()
m := &broadcastBMPMsg{
ch: ch,
- msgList: []*bgp.BMPMessage{bmpPeerUp(laddr, lport, rport, buildopen(peer.fsm.gConf, peer.fsm.pConf), peer.recvOpen, bgp.BMP_PEER_TYPE_GLOBAL, false, 0, peer.fsm.peerInfo, peer.conf.Timers.TimersState.Uptime)},
+ msgList: []*bgp.BMPMessage{bmpPeerUp(laddr, lport, rport, buildopen(peer.fsm.gConf, peer.fsm.pConf), peer.recvOpen, bgp.BMP_PEER_TYPE_GLOBAL, false, 0, peer.fsm.peerInfo, peer.conf.Timers.State.Uptime)},
}
server.broadcastMsgs = append(server.broadcastMsgs, m)
}
@@ -824,12 +824,12 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg, incoming chan *
os.Exit(0)
}
}
- peer.conf.Timers.TimersState.Downtime = time.Now().Unix()
+ peer.conf.Timers.State.Downtime = time.Now().Unix()
}
// clear counter
if peer.fsm.adminState == ADMIN_STATE_DOWN {
- peer.conf.NeighborState = config.NeighborState{}
- peer.conf.Timers.TimersState = config.TimersState{}
+ peer.conf.State = config.NeighborState{}
+ peer.conf.Timers.State = config.TimersState{}
}
peer.startFSMHandler(incoming)
server.broadcastPeerState(peer)
@@ -900,7 +900,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg, incoming chan *
default:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.conf.NeighborConfig.NeighborAddress,
+ "Key": peer.conf.Config.NeighborAddress,
"Data": e.MsgData,
}).Panic("unknown msg type")
}
@@ -981,7 +981,7 @@ func (server *BgpServer) handlePolicy(pl config.RoutingPolicy) error {
for _, peer := range server.neighborMap {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.conf.NeighborConfig.NeighborAddress,
+ "Key": peer.conf.Config.NeighborAddress,
}).Info("call set policy")
server.setPolicyByConfig(peer.ID(), peer.conf.ApplyPolicy)
}
@@ -1092,8 +1092,8 @@ func (server *BgpServer) Api2PathList(resource api.Resource, name string, ApiPat
}
} else {
pi = &table.PeerInfo{
- AS: server.bgpConfig.Global.GlobalConfig.As,
- LocalID: server.bgpConfig.Global.GlobalConfig.RouterId,
+ AS: server.bgpConfig.Global.Config.As,
+ LocalID: server.bgpConfig.Global.Config.RouterId,
}
}
@@ -1303,8 +1303,8 @@ func (server *BgpServer) handleVrfMod(arg *api.ModVrfArguments) ([]*table.Path,
return nil, err
}
pi := &table.PeerInfo{
- AS: server.bgpConfig.Global.GlobalConfig.As,
- LocalID: server.bgpConfig.Global.GlobalConfig.RouterId,
+ AS: server.bgpConfig.Global.Config.As,
+ LocalID: server.bgpConfig.Global.Config.RouterId,
}
msgs, err = rib.AddVrf(arg.Vrf.Name, rd, importRt, exportRt, pi)
if err != nil {
@@ -1389,7 +1389,7 @@ END:
return msgs
}
-func (server *BgpServer) handleModGlobalConfig(grpcReq *GrpcRequest) error {
+func (server *BgpServer) handleModConfig(grpcReq *GrpcRequest) error {
arg := grpcReq.Data.(*api.ModGlobalConfigArguments)
if arg.Operation != api.Operation_ADD {
return fmt.Errorf("invalid operation %s", arg.Operation)
@@ -1404,7 +1404,7 @@ func (server *BgpServer) handleModGlobalConfig(grpcReq *GrpcRequest) error {
}
c := config.Bgp{
Global: config.Global{
- GlobalConfig: config.GlobalConfig{
+ Config: config.GlobalConfig{
As: g.As,
RouterId: net.ParseIP(g.RouterId),
},
@@ -1489,14 +1489,14 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg {
case REQ_GLOBAL_CONFIG:
result := &GrpcResponse{
Data: &api.Global{
- As: server.bgpConfig.Global.GlobalConfig.As,
- RouterId: server.bgpConfig.Global.GlobalConfig.RouterId.String(),
+ As: server.bgpConfig.Global.Config.As,
+ RouterId: server.bgpConfig.Global.Config.RouterId.String(),
},
}
grpcReq.ResponseCh <- result
close(grpcReq.ResponseCh)
case REQ_MOD_GLOBAL_CONFIG:
- err := server.handleModGlobalConfig(grpcReq)
+ err := server.handleModConfig(grpcReq)
grpcReq.ResponseCh <- &GrpcResponse{
ResponseErr: err,
}
@@ -1701,7 +1701,7 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg {
}
logOp(grpcReq.Name, "Neighbor reset")
for _, peer := range peers {
- peer.fsm.idleHoldTime = peer.conf.Timers.TimersConfig.IdleHoldTimeAfterReset
+ peer.fsm.idleHoldTime = peer.conf.Timers.Config.IdleHoldTimeAfterReset
m := bgp.NewBGPNotificationMessage(bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_ADMINISTRATIVE_RESET, nil)
msgs = append(msgs, newSenderMsg(peer, []*bgp.BGPMessage{m}))
}
@@ -1723,7 +1723,7 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg {
pathList := []*table.Path{}
for _, path := range peer.adjRibIn.PathList([]bgp.RouteFamily{grpcReq.RouteFamily}, false) {
if path = server.policy.ApplyPolicy(peer.ID(), table.POLICY_DIRECTION_IN, path); path != nil {
- pathList = append(pathList, path.Clone(peer.conf.NeighborConfig.NeighborAddress, false))
+ pathList = append(pathList, path.Clone(peer.conf.Config.NeighborAddress, false))
}
}
m, _ := server.propagateUpdate(peer, pathList)
@@ -1786,12 +1786,12 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg {
case peer.fsm.adminStateCh <- ADMIN_STATE_UP:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.conf.NeighborConfig.NeighborAddress,
+ "Key": peer.conf.Config.NeighborAddress,
}).Debug("ADMIN_STATE_UP requested")
err.Code = api.Error_SUCCESS
err.Msg = "ADMIN_STATE_UP"
default:
- log.Warning("previous request is still remaining. : ", peer.conf.NeighborConfig.NeighborAddress)
+ log.Warning("previous request is still remaining. : ", peer.conf.Config.NeighborAddress)
err.Code = api.Error_FAIL
err.Msg = "previous request is still remaining"
}
@@ -1800,12 +1800,12 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg {
case peer.fsm.adminStateCh <- ADMIN_STATE_DOWN:
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.conf.NeighborConfig.NeighborAddress,
+ "Key": peer.conf.Config.NeighborAddress,
}).Debug("ADMIN_STATE_DOWN requested")
err.Code = api.Error_SUCCESS
err.Msg = "ADMIN_STATE_DOWN"
default:
- log.Warning("previous request is still remaining. : ", peer.conf.NeighborConfig.NeighborAddress)
+ log.Warning("previous request is still remaining. : ", peer.conf.Config.NeighborAddress)
err.Code = api.Error_FAIL
err.Msg = "previous request is still remaining"
}
@@ -1959,58 +1959,58 @@ func (server *BgpServer) handleGrpcModNeighbor(grpcReq *GrpcRequest) (sMsgs []*S
var pconf config.Neighbor
if a.Conf != nil {
pconf.NeighborAddress = net.ParseIP(a.Conf.NeighborAddress)
- pconf.NeighborConfig.NeighborAddress = net.ParseIP(a.Conf.NeighborAddress)
- pconf.NeighborConfig.PeerAs = a.Conf.PeerAs
- pconf.NeighborConfig.LocalAs = a.Conf.LocalAs
- if pconf.NeighborConfig.PeerAs != server.bgpConfig.Global.GlobalConfig.As {
- pconf.NeighborConfig.PeerType = config.PEER_TYPE_EXTERNAL
+ pconf.Config.NeighborAddress = net.ParseIP(a.Conf.NeighborAddress)
+ pconf.Config.PeerAs = a.Conf.PeerAs
+ pconf.Config.LocalAs = a.Conf.LocalAs
+ if pconf.Config.PeerAs != server.bgpConfig.Global.Config.As {
+ pconf.Config.PeerType = config.PEER_TYPE_EXTERNAL
} else {
- pconf.NeighborConfig.PeerType = config.PEER_TYPE_INTERNAL
+ pconf.Config.PeerType = config.PEER_TYPE_INTERNAL
}
- pconf.NeighborConfig.AuthPassword = a.Conf.AuthPassword
- pconf.NeighborConfig.RemovePrivateAs = config.RemovePrivateAsOption(a.Conf.RemovePrivateAs)
- pconf.NeighborConfig.RouteFlapDamping = a.Conf.RouteFlapDamping
- pconf.NeighborConfig.SendCommunity = config.CommunityType(a.Conf.SendCommunity)
- pconf.NeighborConfig.Description = a.Conf.Description
- pconf.NeighborConfig.PeerGroup = a.Conf.PeerGroup
- pconf.NeighborConfig.NeighborAddress = net.ParseIP(a.Conf.NeighborAddress)
+ pconf.Config.AuthPassword = a.Conf.AuthPassword
+ pconf.Config.RemovePrivateAs = config.RemovePrivateAsOption(a.Conf.RemovePrivateAs)
+ pconf.Config.RouteFlapDamping = a.Conf.RouteFlapDamping
+ pconf.Config.SendCommunity = config.CommunityType(a.Conf.SendCommunity)
+ pconf.Config.Description = a.Conf.Description
+ pconf.Config.PeerGroup = a.Conf.PeerGroup
+ pconf.Config.NeighborAddress = net.ParseIP(a.Conf.NeighborAddress)
}
if a.Timers != nil {
if a.Timers.Config != nil {
- pconf.Timers.TimersConfig.ConnectRetry = float64(a.Timers.Config.ConnectRetry)
- pconf.Timers.TimersConfig.HoldTime = float64(a.Timers.Config.HoldTime)
- pconf.Timers.TimersConfig.KeepaliveInterval = float64(a.Timers.Config.KeepaliveInterval)
- pconf.Timers.TimersConfig.MinimumAdvertisementInterval = float64(a.Timers.Config.MinimumAdvertisementInterval)
+ pconf.Timers.Config.ConnectRetry = float64(a.Timers.Config.ConnectRetry)
+ pconf.Timers.Config.HoldTime = float64(a.Timers.Config.HoldTime)
+ pconf.Timers.Config.KeepaliveInterval = float64(a.Timers.Config.KeepaliveInterval)
+ pconf.Timers.Config.MinimumAdvertisementInterval = float64(a.Timers.Config.MinimumAdvertisementInterval)
}
} else {
- pconf.Timers.TimersConfig.ConnectRetry = float64(config.DEFAULT_CONNECT_RETRY)
- pconf.Timers.TimersConfig.HoldTime = float64(config.DEFAULT_HOLDTIME)
- pconf.Timers.TimersConfig.KeepaliveInterval = float64(config.DEFAULT_HOLDTIME / 3)
+ pconf.Timers.Config.ConnectRetry = float64(config.DEFAULT_CONNECT_RETRY)
+ pconf.Timers.Config.HoldTime = float64(config.DEFAULT_HOLDTIME)
+ pconf.Timers.Config.KeepaliveInterval = float64(config.DEFAULT_HOLDTIME / 3)
}
if a.RouteReflector != nil {
- pconf.RouteReflector.RouteReflectorConfig.RouteReflectorClusterId = config.RrClusterIdType(a.RouteReflector.RouteReflectorClusterId)
- pconf.RouteReflector.RouteReflectorConfig.RouteReflectorClient = a.RouteReflector.RouteReflectorClient
+ pconf.RouteReflector.Config.RouteReflectorClusterId = config.RrClusterIdType(a.RouteReflector.RouteReflectorClusterId)
+ pconf.RouteReflector.Config.RouteReflectorClient = a.RouteReflector.RouteReflectorClient
}
if a.RouteServer != nil {
- pconf.RouteServer.RouteServerConfig.RouteServerClient = a.RouteServer.RouteServerClient
+ pconf.RouteServer.Config.RouteServerClient = a.RouteServer.RouteServerClient
}
if a.ApplyPolicy != nil {
if a.ApplyPolicy.ImportPolicy != nil {
- pconf.ApplyPolicy.ApplyPolicyConfig.DefaultImportPolicy = config.DefaultPolicyType(a.ApplyPolicy.ImportPolicy.Default)
+ pconf.ApplyPolicy.Config.DefaultImportPolicy = config.DefaultPolicyType(a.ApplyPolicy.ImportPolicy.Default)
for _, p := range a.ApplyPolicy.ImportPolicy.Policies {
- pconf.ApplyPolicy.ApplyPolicyConfig.ImportPolicy = append(pconf.ApplyPolicy.ApplyPolicyConfig.ImportPolicy, p.Name)
+ pconf.ApplyPolicy.Config.ImportPolicy = append(pconf.ApplyPolicy.Config.ImportPolicy, p.Name)
}
}
if a.ApplyPolicy.ExportPolicy != nil {
- pconf.ApplyPolicy.ApplyPolicyConfig.DefaultExportPolicy = config.DefaultPolicyType(a.ApplyPolicy.ExportPolicy.Default)
+ pconf.ApplyPolicy.Config.DefaultExportPolicy = config.DefaultPolicyType(a.ApplyPolicy.ExportPolicy.Default)
for _, p := range a.ApplyPolicy.ExportPolicy.Policies {
- pconf.ApplyPolicy.ApplyPolicyConfig.ExportPolicy = append(pconf.ApplyPolicy.ApplyPolicyConfig.ExportPolicy, p.Name)
+ pconf.ApplyPolicy.Config.ExportPolicy = append(pconf.ApplyPolicy.Config.ExportPolicy, p.Name)
}
}
if a.ApplyPolicy.InPolicy != nil {
- pconf.ApplyPolicy.ApplyPolicyConfig.DefaultInPolicy = config.DefaultPolicyType(a.ApplyPolicy.InPolicy.Default)
+ pconf.ApplyPolicy.Config.DefaultInPolicy = config.DefaultPolicyType(a.ApplyPolicy.InPolicy.Default)
for _, p := range a.ApplyPolicy.InPolicy.Policies {
- pconf.ApplyPolicy.ApplyPolicyConfig.InPolicy = append(pconf.ApplyPolicy.ApplyPolicyConfig.InPolicy, p.Name)
+ pconf.ApplyPolicy.Config.InPolicy = append(pconf.ApplyPolicy.Config.InPolicy, p.Name)
}
}
}
@@ -2033,8 +2033,8 @@ func (server *BgpServer) handleGrpcModNeighbor(grpcReq *GrpcRequest) (sMsgs []*S
}
}
if a.Transport != nil {
- pconf.Transport.TransportConfig.LocalAddress = net.ParseIP(a.Transport.LocalAddress)
- pconf.Transport.TransportConfig.PassiveMode = a.Transport.PassiveMode
+ pconf.Transport.Config.LocalAddress = net.ParseIP(a.Transport.LocalAddress)
+ pconf.Transport.Config.PassiveMode = a.Transport.PassiveMode
}
return pconf, nil
}
@@ -2443,10 +2443,10 @@ func (server *BgpServer) handleModRpki(grpcReq *GrpcRequest) {
switch arg.Operation {
case api.Operation_ADD:
r := config.RpkiServer{}
- r.RpkiServerConfig.Address = net.ParseIP(arg.Address)
- r.RpkiServerConfig.Port = arg.Port
+ r.Config.Address = net.ParseIP(arg.Address)
+ r.Config.Port = arg.Port
server.bgpConfig.RpkiServers.RpkiServerList = append(server.bgpConfig.RpkiServers.RpkiServerList, r)
- server.roaManager, _ = newROAManager(server.bgpConfig.Global.GlobalConfig.As, server.bgpConfig.RpkiServers)
+ server.roaManager, _ = newROAManager(server.bgpConfig.Global.Config.As, server.bgpConfig.RpkiServers)
grpcDone(grpcReq, nil)
return
case api.Operation_ENABLE, api.Operation_DISABLE, api.Operation_RESET, api.Operation_SOFTRESET:
@@ -2555,11 +2555,11 @@ func (server *BgpServer) mkMrtPeerIndexTableMsg(t uint32, view string) (*bgp.MRT
peers := make([]*bgp.Peer, 0, len(server.neighborMap))
for _, peer := range server.neighborMap {
id := peer.fsm.peerInfo.ID.To4().String()
- ipaddr := peer.conf.NeighborConfig.NeighborAddress.String()
- asn := peer.conf.NeighborConfig.PeerAs
+ ipaddr := peer.conf.Config.NeighborAddress.String()
+ asn := peer.conf.Config.PeerAs
peers = append(peers, bgp.NewPeer(id, ipaddr, asn, true))
}
- bgpid := server.bgpConfig.Global.GlobalConfig.RouterId.To4().String()
+ bgpid := server.bgpConfig.Global.Config.RouterId.To4().String()
table := bgp.NewPeerIndexTable(bgpid, view, peers)
return bgp.NewMRTMessage(t, bgp.TABLE_DUMPv2, bgp.PEER_INDEX_TABLE, table)
}
diff --git a/server/zclient.go b/server/zclient.go
index fabd4205..33875476 100644
--- a/server/zclient.go
+++ b/server/zclient.go
@@ -151,8 +151,8 @@ func handleZapiMsg(msg *zebra.Message, server *BgpServer) []*SenderMsg {
switch b := msg.Body.(type) {
case *zebra.IPRouteBody:
pi := &table.PeerInfo{
- AS: server.bgpConfig.Global.GlobalConfig.As,
- LocalID: server.bgpConfig.Global.GlobalConfig.RouterId,
+ AS: server.bgpConfig.Global.Config.As,
+ LocalID: server.bgpConfig.Global.Config.RouterId,
}
if b.Prefix != nil && len(b.Nexthops) > 0 && b.Type != zebra.ROUTE_KERNEL {
diff --git a/table/destination.go b/table/destination.go
index f83e92e6..ca3a39f0 100644
--- a/table/destination.go
+++ b/table/destination.go
@@ -99,13 +99,13 @@ func (i *PeerInfo) String() string {
}
func NewPeerInfo(g *config.Global, p *config.Neighbor) *PeerInfo {
- id := net.ParseIP(string(p.RouteReflector.RouteReflectorConfig.RouteReflectorClusterId)).To4()
+ id := net.ParseIP(string(p.RouteReflector.Config.RouteReflectorClusterId)).To4()
return &PeerInfo{
- AS: p.NeighborConfig.PeerAs,
- LocalAS: g.GlobalConfig.As,
- LocalID: g.GlobalConfig.RouterId,
- Address: p.NeighborConfig.NeighborAddress,
- RouteReflectorClient: p.RouteReflector.RouteReflectorConfig.RouteReflectorClient,
+ AS: p.Config.PeerAs,
+ LocalAS: g.Config.As,
+ LocalID: g.Config.RouterId,
+ Address: p.Config.NeighborAddress,
+ RouteReflectorClient: p.RouteReflector.Config.RouteReflectorClient,
RouteReflectorClusterID: id,
}
}
diff --git a/table/path.go b/table/path.go
index df84645a..bfc967d2 100644
--- a/table/path.go
+++ b/table/path.go
@@ -86,17 +86,17 @@ func cloneAsPath(asAttr *bgp.PathAttributeAsPath) *bgp.PathAttributeAsPath {
func (path *Path) UpdatePathAttrs(global *config.Global, peer *config.Neighbor) {
- if peer.RouteServer.RouteServerConfig.RouteServerClient {
+ if peer.RouteServer.Config.RouteServerClient {
return
}
- localAddress := peer.Transport.TransportConfig.LocalAddress
- if peer.NeighborConfig.PeerType == config.PEER_TYPE_EXTERNAL {
+ localAddress := peer.Transport.Config.LocalAddress
+ if peer.Config.PeerType == config.PEER_TYPE_EXTERNAL {
// NEXTHOP handling
path.SetNexthop(localAddress)
// AS_PATH handling
- path.PrependAsn(global.GlobalConfig.As, 1)
+ path.PrependAsn(global.Config.As, 1)
// MED Handling
idx, _ := path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
@@ -110,7 +110,7 @@ func (path *Path) UpdatePathAttrs(global *config.Global, peer *config.Neighbor)
path.pathAttrs = append(path.pathAttrs[:idx], path.pathAttrs[idx+1:]...)
}
- } else if peer.NeighborConfig.PeerType == config.PEER_TYPE_INTERNAL {
+ } else if peer.Config.PeerType == config.PEER_TYPE_INTERNAL {
// NEXTHOP handling for iBGP
// if the path generated locally set local address as nexthop.
// if not, don't modify it.
@@ -142,7 +142,7 @@ func (path *Path) UpdatePathAttrs(global *config.Global, peer *config.Neighbor)
// RFC4456: BGP Route Reflection
// 8. Avoiding Routing Information Loops
info := path.source
- if peer.RouteReflector.RouteReflectorConfig.RouteReflectorClient {
+ if peer.RouteReflector.Config.RouteReflectorClient {
// This attribute will carry the BGP Identifier of the originator of the route in the local AS.
// A BGP speaker SHOULD NOT create an ORIGINATOR_ID attribute if one already exists.
idx, _ = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGINATOR_ID)
@@ -153,7 +153,7 @@ func (path *Path) UpdatePathAttrs(global *config.Global, peer *config.Neighbor)
// When an RR reflects a route, it MUST prepend the local CLUSTER_ID to the CLUSTER_LIST.
// If the CLUSTER_LIST is empty, it MUST create a new one.
idx, _ = path.getPathAttr(bgp.BGP_ATTR_TYPE_CLUSTER_LIST)
- id := string(peer.RouteReflector.RouteReflectorConfig.RouteReflectorClusterId)
+ id := string(peer.RouteReflector.Config.RouteReflectorClusterId)
if idx < 0 {
p := bgp.NewPathAttributeClusterList([]string{id})
path.pathAttrs = append(path.pathAttrs, p)
@@ -170,8 +170,8 @@ func (path *Path) UpdatePathAttrs(global *config.Global, peer *config.Neighbor)
} else {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.NeighborConfig.NeighborAddress,
- }).Warnf("invalid peer type: %d", peer.NeighborConfig.PeerType)
+ "Key": peer.Config.NeighborAddress,
+ }).Warnf("invalid peer type: %d", peer.Config.PeerType)
}
}
diff --git a/table/policy.go b/table/policy.go
index 6e688ba6..52d6900c 100644
--- a/table/policy.go
+++ b/table/policy.go
@@ -2724,7 +2724,7 @@ func (r *RoutingPolicy) GetAssignmentFromConfig(dir PolicyDirection, a config.Ap
var names []string
var cdef config.DefaultPolicyType
def := ROUTE_TYPE_ACCEPT
- c := a.ApplyPolicyConfig
+ c := a.Config
switch dir {
case POLICY_DIRECTION_IN:
names = c.InPolicy
diff --git a/test/lib/gobgp.py b/test/lib/gobgp.py
index 042d6696..f0dcb0fe 100644
--- a/test/lib/gobgp.py
+++ b/test/lib/gobgp.py
@@ -174,7 +174,7 @@ class GoBGPContainer(BGPContainer):
self._create_config_zebra()
def _create_config_bgp(self):
- config = {'Global': {'GlobalConfig': {'As': self.asn, 'RouterId': self.router_id}}}
+ config = {'Global': {'Config': {'As': self.asn, 'RouterId': self.router_id}}}
for peer, info in self.peers.iteritems():
afi_safi_list = []
version = netaddr.IPNetwork(info['neigh_addr']).version
@@ -196,7 +196,7 @@ class GoBGPContainer(BGPContainer):
afi_safi_list.append({'AfiSafiName': 'ipv6-flowspec'})
afi_safi_list.append({'AfiSafiName': 'l3vpn-ipv6-flowspec'})
- n = {'NeighborConfig':
+ n = {'Config':
{'NeighborAddress': info['neigh_addr'].split('/')[0],
'PeerAs': peer.asn,
'AuthPassword': info['passwd'],
@@ -205,17 +205,17 @@ class GoBGPContainer(BGPContainer):
}
if info['passive']:
- n['Transport'] = {'TransportConfig': {'PassiveMode': True}}
+ n['Transport'] = {'Config': {'PassiveMode': True}}
if info['is_rs_client']:
- n['RouteServer'] = {'RouteServerConfig': {'RouteServerClient': True}}
+ n['RouteServer'] = {'Config': {'RouteServerClient': True}}
if info['is_rr_client']:
clusterId = self.router_id
if 'cluster_id' in info and info['cluster_id'] is not None:
clusterId = info['cluster_id']
- n['RouteReflector'] = {'RouteReflectorConfig' : {'RouteReflectorClient': True,
- 'RouteReflectorClusterId': clusterId}}
+ n['RouteReflector'] = {'Config' : {'RouteReflectorClient': True,
+ 'RouteReflectorClusterId': clusterId}}
f = lambda typ: [p for p in info['policies'].itervalues() if p['type'] == typ]
import_policies = f('import')
@@ -228,16 +228,16 @@ class GoBGPContainer(BGPContainer):
if len(import_policies) + len(export_policies) + len(in_policies) + len(default_import_policy) \
+ len(default_export_policy) + len(default_in_policy) > 0:
- n['ApplyPolicy'] = {'ApplyPolicyConfig': {}}
+ n['ApplyPolicy'] = {'Config': {}}
if len(import_policies) > 0:
- n['ApplyPolicy']['ApplyPolicyConfig']['ImportPolicy'] = [p['name'] for p in import_policies]
+ n['ApplyPolicy']['Config']['ImportPolicy'] = [p['name'] for p in import_policies]
if len(export_policies) > 0:
- n['ApplyPolicy']['ApplyPolicyConfig']['ExportPolicy'] = [p['name'] for p in export_policies]
+ n['ApplyPolicy']['Config']['ExportPolicy'] = [p['name'] for p in export_policies]
if len(in_policies) > 0:
- n['ApplyPolicy']['ApplyPolicyConfig']['InPolicy'] = [p['name'] for p in in_policies]
+ n['ApplyPolicy']['Config']['InPolicy'] = [p['name'] for p in in_policies]
def f(v):
if v == 'reject':
@@ -247,13 +247,13 @@ class GoBGPContainer(BGPContainer):
raise Exception('invalid default policy type {0}'.format(v))
if len(default_import_policy) > 0:
- n['ApplyPolicy']['ApplyPolicyConfig']['DefaultImportPolicy'] = f(default_import_policy[0])
+ n['ApplyPolicy']['Config']['DefaultImportPolicy'] = f(default_import_policy[0])
if len(default_export_policy) > 0:
- n['ApplyPolicy']['ApplyPolicyConfig']['DefaultExportPolicy'] = f(default_export_policy[0])
+ n['ApplyPolicy']['Config']['DefaultExportPolicy'] = f(default_export_policy[0])
if len(default_in_policy) > 0:
- n['ApplyPolicy']['ApplyPolicyConfig']['DefaultInPolicy'] = f(default_in_policy[0])
+ n['ApplyPolicy']['Config']['DefaultInPolicy'] = f(default_in_policy[0])
if 'Neighbors' not in config:
config['Neighbors'] = {'NeighborList': []}
diff --git a/test/performance_test/main.go b/test/performance_test/main.go
index b439c9a8..d005bcfa 100644
--- a/test/performance_test/main.go
+++ b/test/performance_test/main.go
@@ -17,7 +17,6 @@ package main
import (
"fmt"
- "net"
"os"
"time"
@@ -56,24 +55,24 @@ func main() {
for i := 0; i < num; i++ {
localAddr := fmt.Sprintf("10.10.%d.%d", (i+2)/255, (i+2)%255)
g := config.Global{
- GlobalConfig: config.GlobalConfig{
+ Config: config.GlobalConfig{
As: uint32(1001 + i),
- RouterId: net.ParseIP(localAddr),
+ RouterId: localAddr,
},
}
p := config.Neighbor{
- NeighborConfig: config.NeighborConfig{
+ Config: config.NeighborConfig{
PeerAs: 1000,
- NeighborAddress: net.ParseIP("10.10.0.1"),
+ NeighborAddress: "10.10.0.1",
},
Transport: config.Transport{
- TransportConfig: config.TransportConfig{
- LocalAddress: net.ParseIP(localAddr),
+ Config: config.TransportConfig{
+ LocalAddress: localAddr,
},
},
}
peer := newPeer(g, p, incoming)
- peerMap[p.Transport.TransportConfig.LocalAddress.String()] = peer
+ peerMap[p.Transport.Config.LocalAddress.String()] = peer
}
established := 0
ticker := time.NewTicker(time.Second * 5)
diff --git a/tools/config/example_toml.go b/tools/config/example_toml.go
index 877f9b51..50abc3cb 100644
--- a/tools/config/example_toml.go
+++ b/tools/config/example_toml.go
@@ -5,24 +5,23 @@ import (
"fmt"
"github.com/BurntSushi/toml"
"github.com/osrg/gobgp/config"
- "net"
)
func main() {
b := config.Bgp{
Global: config.Global{
- GlobalConfig: config.GlobalConfig{
+ Config: config.GlobalConfig{
As: 12332,
- RouterId: net.ParseIP("10.0.0.1"),
+ RouterId: "10.0.0.1",
},
},
Neighbors: config.Neighbors{
NeighborList: []config.Neighbor{
config.Neighbor{
- NeighborConfig: config.NeighborConfig{
+ Config: config.NeighborConfig{
PeerAs: 12333,
AuthPassword: "apple",
- NeighborAddress: net.ParseIP("192.168.177.33"),
+ NeighborAddress: "192.168.177.33",
},
AfiSafis: config.AfiSafis{
@@ -33,7 +32,7 @@ func main() {
},
ApplyPolicy: config.ApplyPolicy{
- ApplyPolicyConfig: config.ApplyPolicyConfig{
+ Config: config.ApplyPolicyConfig{
ImportPolicy: []string{"pd1"},
DefaultImportPolicy: config.DEFAULT_POLICY_TYPE_ACCEPT_ROUTE,
},
@@ -41,18 +40,18 @@ func main() {
},
config.Neighbor{
- NeighborConfig: config.NeighborConfig{
+ Config: config.NeighborConfig{
PeerAs: 12334,
AuthPassword: "orange",
- NeighborAddress: net.ParseIP("192.168.177.32"),
+ NeighborAddress: "192.168.177.32",
},
},
config.Neighbor{
- NeighborConfig: config.NeighborConfig{
+ Config: config.NeighborConfig{
PeerAs: 12335,
AuthPassword: "grape",
- NeighborAddress: net.ParseIP("192.168.177.34"),
+ NeighborAddress: "192.168.177.34",
},
},
},
@@ -88,7 +87,7 @@ func policy() config.RoutingPolicy {
NeighborSetName: "ns1",
NeighborInfoList: []config.NeighborInfo{
config.NeighborInfo{
- Address: net.ParseIP("10.0.0.2"),
+ Address: "10.0.0.2",
}},
}
diff --git a/tools/pyang_plugins/bgpyang2golang.py b/tools/pyang_plugins/bgpyang2golang.py
index d8f619dd..42e4e65e 100644
--- a/tools/pyang_plugins/bgpyang2golang.py
+++ b/tools/pyang_plugins/bgpyang2golang.py
@@ -242,7 +242,12 @@ def emit_class_def(ctx, yang_statement, struct_name, prefix):
emit_type_name = '[]' + t.golang_name
if is_container(child):
- print >> o, ' %s\t%s' % (emit_type_name, emit_type_name)
+ name = emit_type_name
+ if name.startswith(convert_to_golang(struct_name)) and name.endswith("Config"):
+ name = 'Config'
+ elif name.startswith(convert_to_golang(struct_name)) and name.endswith("State"):
+ name = 'State'
+ print >> o, ' %s\t%s' % (name, emit_type_name)
else:
print >> o, ' %s\t%s' % (val_name_go, emit_type_name)
diff --git a/tools/route-server/quagga-rsconfig.go b/tools/route-server/quagga-rsconfig.go
index a58e8601..b104af8a 100644
--- a/tools/route-server/quagga-rsconfig.go
+++ b/tools/route-server/quagga-rsconfig.go
@@ -34,11 +34,11 @@ func (qt *QuaggaConfig) Config() *bytes.Buffer {
buf.WriteString("hostname bgpd\n")
buf.WriteString("password zebra\n")
- buf.WriteString(fmt.Sprintf("router bgp %d\n", qt.config.NeighborConfig.PeerAs))
+ buf.WriteString(fmt.Sprintf("router bgp %d\n", qt.config.Config.PeerAs))
buf.WriteString(fmt.Sprintf("bgp router-id 192.168.0.%d\n", qt.id))
buf.WriteString(fmt.Sprintf("network 192.168.%d.0/24\n", qt.id))
- buf.WriteString(fmt.Sprintf("neighbor %s remote-as %d\n", qt.serverIP, qt.gobgpConfig.GlobalConfig.As))
- buf.WriteString(fmt.Sprintf("neighbor %s password %s\n", qt.serverIP, qt.config.NeighborConfig.AuthPassword))
+ buf.WriteString(fmt.Sprintf("neighbor %s remote-as %d\n", qt.serverIP, qt.gobgpConfig.Config.As))
+ buf.WriteString(fmt.Sprintf("neighbor %s password %s\n", qt.serverIP, qt.config.Config.AuthPassword))
buf.WriteString("log file /var/log/quagga/bgpd.log")
return buf
}
@@ -47,15 +47,15 @@ func create_config_files(nr int, outputDir string) {
quaggaConfigList := make([]*QuaggaConfig, 0)
gobgpConf := config.Bgp{}
- gobgpConf.Global.GlobalConfig.As = 65000
- gobgpConf.Global.GlobalConfig.RouterId = net.ParseIP("192.168.255.1")
+ gobgpConf.Global.Config.As = 65000
+ gobgpConf.Global.Config.RouterId = "192.168.255.1"
for i := 1; i < nr+1; i++ {
c := config.Neighbor{}
- c.NeighborConfig.PeerAs = 65000 + uint32(i)
- c.NeighborConfig.NeighborAddress = net.ParseIP(fmt.Sprintf("10.0.0.%d", i))
- c.NeighborConfig.AuthPassword = fmt.Sprintf("hoge%d", i)
+ c.Config.PeerAs = 65000 + uint32(i)
+ c.Config.NeighborAddress = fmt.Sprintf("10.0.0.%d", i)
+ c.Config.AuthPassword = fmt.Sprintf("hoge%d", i)
gobgpConf.Neighbors.NeighborList = append(gobgpConf.Neighbors.NeighborList, c)
q := NewQuaggaConfig(i, &gobgpConf.Global, &c, net.ParseIP("10.0.255.1"))