support BMP sysName and sysDescr configuration

This commit is contained in:
JieJhih Jhang
2019-03-25 20:11:44 +09:00
committed by FUJITA Tomonori
parent a611916041
commit 80ff3a325c
9 changed files with 52 additions and 2 deletions
+2
View File
@@ -2370,6 +2370,8 @@ type AddBmpRequest struct {
Port uint32 `protobuf:"varint,2,opt,name=port" json:"port,omitempty"`
Policy AddBmpRequest_MonitoringPolicy `protobuf:"varint,3,opt,name=policy,enum=gobgpapi.AddBmpRequest_MonitoringPolicy" json:"policy,omitempty"`
StatisticsTimeout int32 `protobuf:"varint,4,opt,name=StatisticsTimeout,json=statisticsTimeout" json:"StatisticsTimeout,omitempty"`
SysName string `protobuf:"bytes,5,opt,name=SysName,proto3" json:"SysName,omitempty"`
SysDescr string `protobuf:"bytes,6,opt,name=SysDescr,proto3" json:"SysDescr,omitempty"`
}
func (m *AddBmpRequest) Reset() { *m = AddBmpRequest{} }
+2
View File
@@ -439,6 +439,8 @@ message AddBmpRequest {
}
MonitoringPolicy policy = 3;
int32 StatisticsTimeout = 4;
string SysName = 5;
string SysDescr = 6;
}
message DeleteBmpRequest {
+2
View File
@@ -279,6 +279,8 @@ func main() {
if err := bgpServer.AddBmp(context.Background(), &api.AddBmpRequest{
Address: c.Config.Address,
Port: c.Config.Port,
SysName: c.Config.SysName,
SysDescr: c.Config.SysDescr,
Policy: api.AddBmpRequest_MonitoringPolicy(c.Config.RouteMonitoringPolicy.ToInt()),
StatisticsTimeout: int32(c.Config.StatisticsTimeout),
}); err != nil {
+18
View File
@@ -1394,6 +1394,12 @@ type BmpServerState struct {
// Enable feature for mirroring of received BGP messages
// mainly for debugging purpose.
RouteMirroringEnabled bool `mapstructure:"route-mirroring-enabled" json:"route-mirroring-enabled,omitempty"`
// original -> gobgp:sys-name
// Reference to the SysName of the BMP server.
SysName string `mapstructure:"sys-name" json:"sys-name,omitempty"`
// original -> gobgp:sys-descr
// Reference to the SysDescr of the BMP server.
SysDescr string `mapstructure:"sys-descr" json:"sys-descr,omitempty"`
}
// struct for container gobgp:config.
@@ -1417,6 +1423,12 @@ type BmpServerConfig struct {
// Enable feature for mirroring of received BGP messages
// mainly for debugging purpose.
RouteMirroringEnabled bool `mapstructure:"route-mirroring-enabled" json:"route-mirroring-enabled,omitempty"`
// original -> gobgp:sys-name
// Reference to the SysName of the BMP server.
SysName string `mapstructure:"sys-name" json:"sys-name,omitempty"`
// original -> gobgp:sys-descr
// Reference to the SysDescr of the BMP server.
SysDescr string `mapstructure:"sys-descr" json:"sys-descr,omitempty"`
}
func (lhs *BmpServerConfig) Equal(rhs *BmpServerConfig) bool {
@@ -1438,6 +1450,12 @@ func (lhs *BmpServerConfig) Equal(rhs *BmpServerConfig) bool {
if lhs.RouteMirroringEnabled != rhs.RouteMirroringEnabled {
return false
}
if lhs.SysName != rhs.SysName {
return false
}
if lhs.SysDescr != rhs.SysDescr {
return false
}
return true
}
+7
View File
@@ -349,7 +349,14 @@ func setDefaultConfigValuesWithViper(v *viper.Viper, b *BgpConfigSet) error {
return err
}
bmpSysPrefix := "Gobgp-R"
for idx, server := range b.BmpServers {
if server.Config.SysName == "" {
server.Config.SysName = bmpSysPrefix + strconv.Itoa(idx)
}
if server.Config.SysDescr == "" {
server.Config.SysDescr = "Gobgp Version: master"
}
if server.Config.Port == 0 {
server.Config.Port = bmp.BMP_DEFAULT_PORT
}
+6 -1
View File
@@ -154,7 +154,12 @@ func (b *bmpClient) loop() {
return err
}
if err := write(bmp.NewBMPInitiation([]bmp.BMPInfoTLVInterface{})); err != nil {
tlv := []bmp.BMPInfoTLVInterface{
bmp.NewBMPInfoTLVString(bmp.BMP_INIT_TLV_TYPE_SYS_NAME, b.c.SysName),
bmp.NewBMPInfoTLVString(bmp.BMP_INIT_TLV_TYPE_SYS_DESCR, b.c.SysDescr),
}
if err := write(bmp.NewBMPInitiation(tlv)); err != nil {
return false
}
+2
View File
@@ -1639,6 +1639,8 @@ func (s *BgpServer) AddBmp(ctx context.Context, r *api.AddBmpRequest) error {
return s.bmpManager.addServer(&config.BmpServerConfig{
Address: r.Address,
Port: r.Port,
SysName: r.SysName,
SysDescr: r.SysDescr,
RouteMonitoringPolicy: config.IntToBmpRouteMonitoringPolicyTypeMap[int(r.Policy)],
StatisticsTimeout: uint16(r.StatisticsTimeout),
})
+1 -1
View File
@@ -37,4 +37,4 @@ Generate config/bgp_configs.go from yang files::
$HOME/public/release/models/bgp/openconfig-bgp.yang \
$HOME/public/release/models/policy/openconfig-routing-policy.yang \
$GOBGP_PATH/tools/pyang_plugins/gobgp.yang \
| gofmt > $GOBGP_PATH/config/bgp_configs.go
| gofmt > $GOBGP_PATH/internal/pkg/config/bgp_configs.go
+12
View File
@@ -590,6 +590,18 @@ module gobgp {
"Enable feature for mirroring of received BGP messages
mainly for debugging purpose";
}
leaf sys-name {
type string;
description
"Reference to the SysName of the BMP server";
}
leaf sys-descr {
type string;
description
"Reference to the SysDescr of the BMP server";
}
}
grouping gobgp-bmp-server-set {