summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--config/bgp_configs.go72
-rw-r--r--config/default.go4
-rw-r--r--config/serve.go18
-rw-r--r--docs/sources/bmp.md6
-rw-r--r--docs/sources/configuration.md14
-rw-r--r--gobgpd/main.go6
-rw-r--r--server/server.go63
-rw-r--r--tools/pyang_plugins/gobgp.yang4
8 files changed, 103 insertions, 84 deletions
diff --git a/config/bgp_configs.go b/config/bgp_configs.go
index d6c68782..eda8ce98 100644
--- a/config/bgp_configs.go
+++ b/config/bgp_configs.go
@@ -828,6 +828,38 @@ func (v RpkiValidationResultType) Validate() error {
return nil
}
+//struct for container gobgp:mrt
+type Mrt struct {
+ // original -> gobgp:file-name
+ FileName string `mapstructure:"file-name"`
+}
+
+//struct for container gobgp:state
+type BmpServerState struct {
+}
+
+//struct for container gobgp:config
+type BmpServerConfig struct {
+ // original -> gobgp:address
+ //gobgp:address's original type is inet:ip-address
+ Address string `mapstructure:"address"`
+ // original -> gobgp:port
+ Port uint32 `mapstructure:"port"`
+ // original -> gobgp:route-monitoring-policy
+ RouteMonitoringPolicy BmpRouteMonitoringPolicyType `mapstructure:"route-monitoring-policy"`
+}
+
+//struct for container gobgp:bmp-server
+type BmpServer struct {
+ // original -> gobgp:address
+ //gobgp:address's original type is inet:ip-address
+ Address string `mapstructure:"address"`
+ // original -> gobgp:bmp-server-config
+ Config BmpServerConfig `mapstructure:"config"`
+ // original -> gobgp:bmp-server-state
+ State BmpServerState `mapstructure:"state"`
+}
+
//struct for container gobgp:rpki-received
type RpkiReceived struct {
// original -> gobgp:serial-notify
@@ -1471,38 +1503,6 @@ type Zebra struct {
RedistributeRouteTypeList []InstallProtocolType `mapstructure:"redistribute-route-type-list"`
}
-//struct for container gobgp:mrt
-type Mrt struct {
- // original -> gobgp:file-name
- FileName string `mapstructure:"file-name"`
-}
-
-//struct for container gobgp:state
-type BmpServerState struct {
-}
-
-//struct for container gobgp:config
-type BmpServerConfig struct {
- // original -> gobgp:address
- //gobgp:address's original type is inet:ip-address
- Address string `mapstructure:"address"`
- // original -> gobgp:port
- Port uint32 `mapstructure:"port"`
- // original -> gobgp:route-monitoring-policy
- RouteMonitoringPolicy BmpRouteMonitoringPolicyType `mapstructure:"route-monitoring-policy"`
-}
-
-//struct for container gobgp:bmp-server
-type BmpServer struct {
- // original -> gobgp:address
- //gobgp:address's original type is inet:ip-address
- Address string `mapstructure:"address"`
- // original -> gobgp:bmp-server-config
- Config BmpServerConfig `mapstructure:"config"`
- // original -> gobgp:bmp-server-state
- State BmpServerState `mapstructure:"state"`
-}
-
//struct for container gobgp:collector
type Collector struct {
// original -> gobgp:enabled
@@ -2050,10 +2050,6 @@ type Global struct {
ApplyPolicy ApplyPolicy `mapstructure:"apply-policy"`
// original -> gobgp:collector
Collector Collector `mapstructure:"collector"`
- // original -> gobgp:bmp-servers
- BmpServers []BmpServer `mapstructure:"bmp-servers"`
- // original -> gobgp:mrt
- Mrt Mrt `mapstructure:"mrt"`
// original -> gobgp:zebra
Zebra Zebra `mapstructure:"zebra"`
// original -> gobgp:mpls-label-range
@@ -2072,6 +2068,10 @@ type Bgp struct {
PeerGroups []PeerGroup `mapstructure:"peer-groups"`
// original -> gobgp:rpki-servers
RpkiServers []RpkiServer `mapstructure:"rpki-servers"`
+ // original -> gobgp:bmp-servers
+ BmpServers []BmpServer `mapstructure:"bmp-servers"`
+ // original -> gobgp:mrt
+ Mrt Mrt `mapstructure:"mrt"`
}
//struct for container bgp-pol:set-ext-community-method
diff --git a/config/default.go b/config/default.go
index 536b7a1e..cdd2ee54 100644
--- a/config/default.go
+++ b/config/default.go
@@ -48,11 +48,11 @@ func SetDefaultConfigValues(v *viper.Viper, b *Bgp) error {
b.Global.ListenConfig.Port = bgp.BGP_PORT
}
- for idx, server := range b.Global.BmpServers {
+ for idx, server := range b.BmpServers {
if server.Config.Port == 0 {
server.Config.Port = bgp.BMP_DEFAULT_PORT
}
- b.Global.BmpServers[idx] = server
+ b.BmpServers[idx] = server
}
if !v.IsSet("global.mpls-label-range.min-label") {
diff --git a/config/serve.go b/config/serve.go
index 4b5fbbe9..9cb3b31e 100644
--- a/config/serve.go
+++ b/config/serve.go
@@ -20,7 +20,7 @@ func ReadConfigfileServe(path, format string, configCh chan BgpConfigSet) {
cnt := 0
for {
- b := Bgp{}
+ var b *Bgp
v := viper.New()
v.SetConfigFile(path)
v.SetConfigType(format)
@@ -29,6 +29,8 @@ func ReadConfigfileServe(path, format string, configCh chan BgpConfigSet) {
Global Global `mapstructure:"global"`
Neighbors []Neighbor `mapstructure:"neighbors"`
RpkiServers []RpkiServer `mapstructure:"rpki-servers"`
+ BmpServers []BmpServer `mapstructure:"bmp-servers"`
+ Mrt Mrt `mapstructure:"mrt"`
DefinedSets DefinedSets `mapstructure:"defined-sets"`
PolicyDefinitions []PolicyDefinition `mapstructure:"policy-definitions"`
}{}
@@ -39,10 +41,14 @@ func ReadConfigfileServe(path, format string, configCh chan BgpConfigSet) {
if err != nil {
goto ERROR
}
- b.Global = c.Global
- b.Neighbors = c.Neighbors
- b.RpkiServers = c.RpkiServers
- err = SetDefaultConfigValues(v, &b)
+ b = &Bgp{
+ Global: c.Global,
+ Neighbors: c.Neighbors,
+ RpkiServers: c.RpkiServers,
+ BmpServers: c.BmpServers,
+ Mrt: c.Mrt,
+ }
+ err = SetDefaultConfigValues(v, b)
if err != nil {
goto ERROR
}
@@ -51,7 +57,7 @@ func ReadConfigfileServe(path, format string, configCh chan BgpConfigSet) {
}
cnt++
configCh <- BgpConfigSet{
- Bgp: b,
+ Bgp: *b,
Policy: RoutingPolicy{
DefinedSets: c.DefinedSets,
PolicyDefinitions: c.PolicyDefinitions,
diff --git a/docs/sources/bmp.md b/docs/sources/bmp.md
index bd9759c1..17c79fe4 100644
--- a/docs/sources/bmp.md
+++ b/docs/sources/bmp.md
@@ -12,15 +12,15 @@ Assume you finished [Getting Started](https://github.com/osrg/gobgp/blob/master/
## <a name="config"> Configuration
-Add `[bmp-servers]` section under `[global]` to enable BMP like below.
+Add `[bmp-servers]` session to enable BMP like below.
```toml
[global.config]
as = 64512
router-id = "192.168.255.1"
-[[global.bmp-servers]]
- [global.bmp-servers.config]
+[[bmp-servers]]
+ [bmp-servers.config]
address = "127.0.0.1"
port=11019
```
diff --git a/docs/sources/configuration.md b/docs/sources/configuration.md
index 894dacfe..24a10508 100644
--- a/docs/sources/configuration.md
+++ b/docs/sources/configuration.md
@@ -9,12 +9,6 @@
default-import-policy = "reject-route"
export-policy-list = ["policy2"]
default-export-policy = "accept-route"
- [[global.bmp-servers]]
- [global.bmp-servers.config]
- address = "127.0.0.1"
- port = 11019
- [global.mrt]
- file-name = "/var/log/mrt.dump"
[global.zebra]
enabled = true
url = "unix:/var/run/quagga/zserv.api"
@@ -38,6 +32,14 @@
address = "210.173.170.254"
port = 323
+[[bmp-servers]]
+ [bmp-servers.config]
+ address = "127.0.0.1"
+ port = 11019
+
+[mrt]
+ file-name = "/var/log/mrt.dump"
+
[[neighbors]]
[neighbors.config]
peer-as = 2
diff --git a/gobgpd/main.go b/gobgpd/main.go
index 1f64c76b..a5f1a559 100644
--- a/gobgpd/main.go
+++ b/gobgpd/main.go
@@ -206,6 +206,12 @@ func main() {
}
bgpConfig = &newConfig.Bgp
bgpServer.SetRpkiConfig(newConfig.Bgp.RpkiServers)
+ if err := bgpServer.SetBmpConfig(newConfig.Bgp.BmpServers); err != nil {
+ log.Fatalf("failed to set global config: %s", err)
+ }
+ if err := bgpServer.SetMrtConfig(newConfig.Bgp.Mrt); err != nil {
+ log.Fatalf("failed to set global config: %s", err)
+ }
added = newConfig.Bgp.Neighbors
if opts.GracefulRestart {
for i, n := range added {
diff --git a/server/server.go b/server/server.go
index c93bc55b..d5cc8882 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1102,24 +1102,53 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) []*SenderMsg {
}
func (server *BgpServer) SetGlobalType(g config.Global) error {
- {
+ ch := make(chan *GrpcResponse)
+ server.GrpcReqCh <- &GrpcRequest{
+ RequestType: REQ_MOD_GLOBAL_CONFIG,
+ Data: &g,
+ ResponseCh: ch,
+ }
+ if err := (<-ch).Err(); err != nil {
+ return err
+ }
+ if g.Zebra.Enabled {
+ cli, err := NewZclient(g.Zebra.Url, g.Zebra.RedistributeRouteTypeList)
+ if err != nil {
+ return err
+ }
+ server.zclient = cli
+ server.zapiMsgCh = server.zclient.Receive()
+ }
+ return nil
+}
+
+func (server *BgpServer) SetRpkiConfig(c []config.RpkiServer) {
+ server.rpkiConfigCh <- c
+}
+
+func (server *BgpServer) SetBmpConfig(c []config.BmpServer) error {
+ for _, s := range c {
ch := make(chan *GrpcResponse)
server.GrpcReqCh <- &GrpcRequest{
- RequestType: REQ_MOD_GLOBAL_CONFIG,
- Data: &g,
+ RequestType: REQ_MOD_BMP,
+ Data: &s.Config,
ResponseCh: ch,
}
if err := (<-ch).Err(); err != nil {
return err
}
}
- if g.Mrt.FileName != "" {
+ return nil
+}
+
+func (server *BgpServer) SetMrtConfig(c config.Mrt) error {
+ if c.FileName != "" {
ch := make(chan *GrpcResponse)
server.GrpcReqCh <- &GrpcRequest{
RequestType: REQ_MOD_MRT,
Data: &api.ModMrtArguments{
Operation: api.Operation_ADD,
- Filename: g.Mrt.FileName,
+ Filename: c.FileName,
},
ResponseCh: ch,
}
@@ -1127,33 +1156,9 @@ func (server *BgpServer) SetGlobalType(g config.Global) error {
return err
}
}
- for _, s := range g.BmpServers {
- ch := make(chan *GrpcResponse)
- server.GrpcReqCh <- &GrpcRequest{
- RequestType: REQ_MOD_BMP,
- Data: &s.Config,
- ResponseCh: ch,
- }
- if err := (<-ch).Err(); err != nil {
- return err
- }
- }
-
- if g.Zebra.Enabled {
- cli, err := NewZclient(g.Zebra.Url, g.Zebra.RedistributeRouteTypeList)
- if err != nil {
- return err
- }
- server.zclient = cli
- server.zapiMsgCh = server.zclient.Receive()
- }
return nil
}
-func (server *BgpServer) SetRpkiConfig(c []config.RpkiServer) {
- server.rpkiConfigCh <- c
-}
-
func (server *BgpServer) PeerAdd(peer config.Neighbor) {
server.addedPeerCh <- peer
}
diff --git a/tools/pyang_plugins/gobgp.yang b/tools/pyang_plugins/gobgp.yang
index 092a2908..16ad5f40 100644
--- a/tools/pyang_plugins/gobgp.yang
+++ b/tools/pyang_plugins/gobgp.yang
@@ -703,12 +703,12 @@ module gobgp {
}
}
- augment "/bgp:bgp/bgp:global" {
+ augment "/bgp:bgp" {
description "additional bmp configuration";
uses gobgp-bmp-servers;
}
- augment "/bgp:bgp/bgp:global" {
+ augment "/bgp:bgp" {
description "additional mrt configuration";
container mrt {
description