mirror of
https://github.com/osrg/gobgp.git
synced 2024-05-11 05:55:10 +00:00
config: Change "RedistributeRouteTypeList" to []string
RedistributeRouteTypeList is []InstallProtocolType, but InstallProtocolType only defines limited number of protocols, And currently, EnableZebra() in gRPC API validates its request with the protocols defined by InstallProtocolType, so the protocols such as "babel" or "lldp" could not be configured to Zebra, via gRPC API. This patch fixes RedistributeRouteTypeList to be []string, and fixes EnableZebra() to validate with the protocols defined in zapi.go. Signed-off-by: Satoshi Fujimoto <[email protected]>
This commit is contained in:
committed by
FUJITA Tomonori
parent
f6d62322eb
commit
4c63ed5d87
+3
-5
@@ -37,6 +37,7 @@ import (
|
||||
"github.com/osrg/gobgp/packet/bgp"
|
||||
"github.com/osrg/gobgp/server"
|
||||
"github.com/osrg/gobgp/table"
|
||||
"github.com/osrg/gobgp/zebra"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
@@ -970,17 +971,14 @@ func (s *Server) GetRoa(ctx context.Context, arg *GetRoaRequest) (*GetRoaRespons
|
||||
}
|
||||
|
||||
func (s *Server) EnableZebra(ctx context.Context, arg *EnableZebraRequest) (*EnableZebraResponse, error) {
|
||||
l := make([]config.InstallProtocolType, 0, len(arg.RouteTypes))
|
||||
for _, p := range arg.RouteTypes {
|
||||
if err := config.InstallProtocolType(p).Validate(); err != nil {
|
||||
if _, err := zebra.RouteTypeFromString(p); err != nil {
|
||||
return &EnableZebraResponse{}, err
|
||||
} else {
|
||||
l = append(l, config.InstallProtocolType(p))
|
||||
}
|
||||
}
|
||||
return &EnableZebraResponse{}, s.bgpServer.StartZebraClient(&config.ZebraConfig{
|
||||
Url: arg.Url,
|
||||
RedistributeRouteTypeList: l,
|
||||
RedistributeRouteTypeList: arg.RouteTypes,
|
||||
Version: uint8(arg.Version),
|
||||
NexthopTriggerEnable: arg.NexthopTriggerEnable,
|
||||
NexthopTriggerDelay: uint8(arg.NexthopTriggerDelay),
|
||||
|
||||
@@ -1114,7 +1114,7 @@ type ZebraState struct {
|
||||
// Configure url for zebra.
|
||||
Url string `mapstructure:"url" json:"url,omitempty"`
|
||||
// original -> gobgp:redistribute-route-type
|
||||
RedistributeRouteTypeList []InstallProtocolType `mapstructure:"redistribute-route-type-list" json:"redistribute-route-type-list,omitempty"`
|
||||
RedistributeRouteTypeList []string `mapstructure:"redistribute-route-type-list" json:"redistribute-route-type-list,omitempty"`
|
||||
// original -> gobgp:version
|
||||
// Configure version of zebra protocol. Default is 2. Supported up to 3.
|
||||
Version uint8 `mapstructure:"version" json:"version,omitempty"`
|
||||
@@ -1135,7 +1135,7 @@ type ZebraConfig struct {
|
||||
// Configure url for zebra.
|
||||
Url string `mapstructure:"url" json:"url,omitempty"`
|
||||
// original -> gobgp:redistribute-route-type
|
||||
RedistributeRouteTypeList []InstallProtocolType `mapstructure:"redistribute-route-type-list" json:"redistribute-route-type-list,omitempty"`
|
||||
RedistributeRouteTypeList []string `mapstructure:"redistribute-route-type-list" json:"redistribute-route-type-list,omitempty"`
|
||||
// original -> gobgp:version
|
||||
// Configure version of zebra protocol. Default is 2. Supported up to 3.
|
||||
Version uint8 `mapstructure:"version" json:"version,omitempty"`
|
||||
|
||||
@@ -1191,9 +1191,7 @@ module gobgp {
|
||||
"Configure url for zebra.";
|
||||
}
|
||||
leaf-list redistribute-route-type {
|
||||
type identityref {
|
||||
base ptypes:install-protocol-type;
|
||||
}
|
||||
type string;
|
||||
}
|
||||
leaf version {
|
||||
type uint8;
|
||||
|
||||
Reference in New Issue
Block a user