summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--config/bgp_configs.go61
-rw-r--r--config/default.go8
-rw-r--r--docs/sources/configuration.md16
-rw-r--r--server/server.go18
-rw-r--r--tools/pyang_plugins/gobgp.yang22
5 files changed, 64 insertions, 61 deletions
diff --git a/config/bgp_configs.go b/config/bgp_configs.go
index d69995d1..96967bbc 100644
--- a/config/bgp_configs.go
+++ b/config/bgp_configs.go
@@ -2482,32 +2482,6 @@ func (lhs *Neighbor) Equal(rhs *Neighbor) bool {
return true
}
-//struct for container gobgp:listen-config
-type ListenConfig struct {
- // original -> gobgp:port
- Port int32 `mapstructure:"port"`
- // original -> gobgp:local-address
- LocalAddressList []string `mapstructure:"local-address-list"`
-}
-
-func (lhs *ListenConfig) Equal(rhs *ListenConfig) bool {
- if lhs == nil || rhs == nil {
- return false
- }
- if lhs.Port != rhs.Port {
- return false
- }
- if len(lhs.LocalAddressList) != len(rhs.LocalAddressList) {
- return false
- }
- for idx, l := range lhs.LocalAddressList {
- if l != rhs.LocalAddressList[idx] {
- return false
- }
- }
- return true
-}
-
//struct for container gobgp:mpls-label-range
type MplsLabelRange struct {
// original -> gobgp:min-label
@@ -3888,6 +3862,10 @@ type GlobalState struct {
TotalPaths uint32 `mapstructure:"total-paths"`
// original -> bgp-op:total-prefixes
TotalPrefixes uint32 `mapstructure:"total-prefixes"`
+ // original -> gobgp:port
+ Port int32 `mapstructure:"port"`
+ // original -> gobgp:local-address
+ LocalAddressList []string `mapstructure:"local-address-list"`
}
func (lhs *GlobalState) Equal(rhs *GlobalState) bool {
@@ -3906,6 +3884,17 @@ func (lhs *GlobalState) Equal(rhs *GlobalState) bool {
if lhs.TotalPrefixes != rhs.TotalPrefixes {
return false
}
+ if lhs.Port != rhs.Port {
+ return false
+ }
+ if len(lhs.LocalAddressList) != len(rhs.LocalAddressList) {
+ return false
+ }
+ for idx, l := range lhs.LocalAddressList {
+ if l != rhs.LocalAddressList[idx] {
+ return false
+ }
+ }
return true
}
@@ -3917,6 +3906,10 @@ type GlobalConfig struct {
// original -> bgp:router-id
//bgp:router-id's original type is inet:ipv4-address
RouterId string `mapstructure:"router-id"`
+ // original -> gobgp:port
+ Port int32 `mapstructure:"port"`
+ // original -> gobgp:local-address
+ LocalAddressList []string `mapstructure:"local-address-list"`
}
func (lhs *GlobalConfig) Equal(rhs *GlobalConfig) bool {
@@ -3929,6 +3922,17 @@ func (lhs *GlobalConfig) Equal(rhs *GlobalConfig) bool {
if lhs.RouterId != rhs.RouterId {
return false
}
+ if lhs.Port != rhs.Port {
+ return false
+ }
+ if len(lhs.LocalAddressList) != len(rhs.LocalAddressList) {
+ return false
+ }
+ for idx, l := range lhs.LocalAddressList {
+ if l != rhs.LocalAddressList[idx] {
+ return false
+ }
+ }
return true
}
@@ -3956,8 +3960,6 @@ type Global struct {
Zebra Zebra `mapstructure:"zebra"`
// original -> gobgp:mpls-label-range
MplsLabelRange MplsLabelRange `mapstructure:"mpls-label-range"`
- // original -> gobgp:listen-config
- ListenConfig ListenConfig `mapstructure:"listen-config"`
}
func (lhs *Global) Equal(rhs *Global) bool {
@@ -4010,9 +4012,6 @@ func (lhs *Global) Equal(rhs *Global) bool {
if !lhs.MplsLabelRange.Equal(&(rhs.MplsLabelRange)) {
return false
}
- if !lhs.ListenConfig.Equal(&(rhs.ListenConfig)) {
- return false
- }
return true
}
diff --git a/config/default.go b/config/default.go
index 613b0880..e6402ff7 100644
--- a/config/default.go
+++ b/config/default.go
@@ -45,12 +45,12 @@ func SetDefaultConfigValues(v *viper.Viper, b *BgpConfigSet) error {
}
}
- if b.Global.ListenConfig.Port == 0 {
- b.Global.ListenConfig.Port = bgp.BGP_PORT
+ if b.Global.Config.Port == 0 {
+ b.Global.Config.Port = bgp.BGP_PORT
}
- if len(b.Global.ListenConfig.LocalAddressList) == 0 {
- b.Global.ListenConfig.LocalAddressList = []string{"0.0.0.0", "::"}
+ if len(b.Global.Config.LocalAddressList) == 0 {
+ b.Global.Config.LocalAddressList = []string{"0.0.0.0", "::"}
}
for idx, server := range b.BmpServers {
diff --git a/docs/sources/configuration.md b/docs/sources/configuration.md
index c082d56b..9f50bae5 100644
--- a/docs/sources/configuration.md
+++ b/docs/sources/configuration.md
@@ -4,6 +4,14 @@
[global.config]
as = 1
router-id = "1.1.1.1"
+ # listen port (by default 179)
+ port = 1790
+ # to disable listening
+ # port = -1
+
+ # listen address list (by default "0.0.0.0" and "::")
+ local-address-list = ["192.168.10.1", "2001:db8::1"]
+
[global.apply-policy.config]
import-policy-list = ["policy1"]
default-import-policy = "reject-route"
@@ -16,14 +24,6 @@
[global.mpls-label-range]
min-label = 1000
max-label = 2000
- [global.listen-config]
- # listen port (by default 179)
- port = 1790
- # to disable listening
- # port = -1
-
- # listen address list (by default "0.0.0.0" and "::")
- local-address-list = ["192.168.10.1", "2001:db8::1"]
[[rpki-servers]]
[rpki-servers.config]
diff --git a/server/server.go b/server/server.go
index bed5029f..4d0d5308 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1590,10 +1590,8 @@ func (server *BgpServer) handleModConfig(grpcReq *GrpcRequest) error {
b := &config.BgpConfigSet{
Global: config.Global{
Config: config.GlobalConfig{
- As: g.As,
- RouterId: g.RouterId,
- },
- ListenConfig: config.ListenConfig{
+ As: g.As,
+ RouterId: g.RouterId,
Port: g.ListenPort,
LocalAddressList: g.ListenAddresses,
},
@@ -1620,10 +1618,10 @@ func (server *BgpServer) handleModConfig(grpcReq *GrpcRequest) error {
return fmt.Errorf("gobgp is already started")
}
- if c.ListenConfig.Port > 0 {
+ if c.Config.Port > 0 {
acceptCh := make(chan *net.TCPConn, 4096)
- for _, addr := range c.ListenConfig.LocalAddressList {
- l, err := NewTCPListener(addr, uint32(c.ListenConfig.Port), acceptCh)
+ for _, addr := range c.Config.LocalAddressList {
+ l, err := NewTCPListener(addr, uint32(c.Config.Port), acceptCh)
if err != nil {
return err
}
@@ -1733,8 +1731,8 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg {
Data: &api.Global{
As: g.Config.As,
RouterId: g.Config.RouterId,
- ListenPort: g.ListenConfig.Port,
- ListenAddresses: g.ListenConfig.LocalAddressList,
+ ListenPort: g.Config.Port,
+ ListenAddresses: g.Config.LocalAddressList,
MplsLabelMin: g.MplsLabelRange.MinLabel,
MplsLabelMax: g.MplsLabelRange.MaxLabel,
},
@@ -2312,7 +2310,7 @@ func (server *BgpServer) handleAddNeighbor(c *config.Neighbor) ([]*SenderMsg, er
return nil, fmt.Errorf("Can't overwrite the exising peer: %s", addr)
}
- if server.bgpConfig.Global.ListenConfig.Port > 0 {
+ if server.bgpConfig.Global.Config.Port > 0 {
for _, l := range server.Listeners(addr) {
SetTcpMD5SigSockopts(l, addr, c.Config.AuthPassword)
}
diff --git a/tools/pyang_plugins/gobgp.yang b/tools/pyang_plugins/gobgp.yang
index 9ca5f78d..480bca9b 100644
--- a/tools/pyang_plugins/gobgp.yang
+++ b/tools/pyang_plugins/gobgp.yang
@@ -801,17 +801,23 @@ module gobgp {
}
}
- augment "/bgp:bgp/bgp:global" {
- container listen-config {
- leaf port {
- type int32;
- }
- leaf-list local-address {
- type string;
- }
+ grouping listen-config {
+ leaf port {
+ type int32;
+ }
+ leaf-list local-address {
+ type string;
}
}
+ augment "/bgp:bgp/bgp:global/bgp:config" {
+ uses listen-config;
+ }
+
+ augment "/bgp:bgp/bgp:global/bgp:state" {
+ uses listen-config;
+ }
+
augment "/bgp:bgp/bgp:global/bgp:afi-safis/bgp:afi-safi" {
uses bgp-mp:all-afi-safi-common;
}