summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--api/gobgp.pb.go5
-rw-r--r--api/gobgp.proto5
-rw-r--r--api/grpc_server.go72
3 files changed, 59 insertions, 23 deletions
diff --git a/api/gobgp.pb.go b/api/gobgp.pb.go
index 61cfd2fc..5e0c3461 100644
--- a/api/gobgp.pb.go
+++ b/api/gobgp.pb.go
@@ -2769,6 +2769,9 @@ func (*ValidateRibResponse) ProtoMessage() {}
func (*ValidateRibResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{104} }
type Peer struct {
+ // Note: Regarding to the consistency with OpenConfig model, a list of
+ // address family should be removed from here, and should be configured with
+ // the list of AfiSafi instead.
Families []uint32 `protobuf:"varint,1,rep,packed,name=families" json:"families,omitempty"`
ApplyPolicy *ApplyPolicy `protobuf:"bytes,2,opt,name=apply_policy,json=applyPolicy" json:"apply_policy,omitempty"`
Conf *PeerConf `protobuf:"bytes,3,opt,name=conf" json:"conf,omitempty"`
@@ -2950,7 +2953,7 @@ type PeerConf struct {
RemoteCap [][]byte `protobuf:"bytes,11,rep,name=remote_cap,json=remoteCap,proto3" json:"remote_cap,omitempty"`
LocalCap [][]byte `protobuf:"bytes,12,rep,name=local_cap,json=localCap,proto3" json:"local_cap,omitempty"`
Id string `protobuf:"bytes,13,opt,name=id" json:"id,omitempty"`
- // Note: Regarding to the consistency with OpenConfig mode, list of
+ // Note: Regarding to the consistency with OpenConfig model, list of
// PrefixLimit should be removed from here, and list of PrefixLimit in
// AfiSafi should be used instead.
PrefixLimits []*PrefixLimit `protobuf:"bytes,14,rep,name=prefix_limits,json=prefixLimits" json:"prefix_limits,omitempty"`
diff --git a/api/gobgp.proto b/api/gobgp.proto
index dd58e003..39dc1b52 100644
--- a/api/gobgp.proto
+++ b/api/gobgp.proto
@@ -623,6 +623,9 @@ message ValidateRibResponse {
}
message Peer {
+ // Note: Regarding to the consistency with OpenConfig model, a list of
+ // address family should be removed from here, and should be configured with
+ // the list of AfiSafi instead.
repeated uint32 families = 1;
ApplyPolicy apply_policy = 2;
PeerConf conf = 3;
@@ -668,7 +671,7 @@ message PeerConf {
repeated bytes remote_cap = 11;
repeated bytes local_cap = 12;
string id = 13;
- // Note: Regarding to the consistency with OpenConfig mode, list of
+ // Note: Regarding to the consistency with OpenConfig model, list of
// PrefixLimit should be removed from here, and list of PrefixLimit in
// AfiSafi should be used instead.
repeated PrefixLimit prefix_limits = 14;
diff --git a/api/grpc_server.go b/api/grpc_server.go
index 21b9d260..18e4e4d4 100644
--- a/api/grpc_server.go
+++ b/api/grpc_server.go
@@ -1033,9 +1033,18 @@ func ReadAfiSafiConfigFromAPIStruct(c *config.AfiSafiConfig, a *AfiSafiConfig) {
if c == nil || a == nil {
return
}
+ c.AfiSafiName = config.AfiSafiType(bgp.RouteFamily(a.Family).String())
c.Enabled = a.Enabled
}
+func ReadAfiSafiStateFromAPIStruct(s *config.AfiSafiState, a *AfiSafiConfig) {
+ if s == nil || a == nil {
+ return
+ }
+ // Store only address family value for the convenience
+ s.Family = bgp.RouteFamily(a.Family)
+}
+
func ReadPrefixLimitFromAPIStruct(c *config.PrefixLimit, a *PrefixLimit) {
if c == nil || a == nil {
return
@@ -1182,32 +1191,53 @@ func NewNeighborFromAPIStruct(a *Peer) (*config.Neighbor, error) {
pconf.State.RemoteRouterId = a.Conf.Id
+ for _, af := range a.AfiSafis {
+ afiSafi := config.AfiSafi{}
+ ReadMpGracefulRestartFromAPIStruct(&afiSafi.MpGracefulRestart, af.MpGracefulRestart)
+ ReadAfiSafiConfigFromAPIStruct(&afiSafi.Config, af.Config)
+ ReadAfiSafiStateFromAPIStruct(&afiSafi.State, af.Config)
+ ReadApplyPolicyFromAPIStruct(&afiSafi.ApplyPolicy, af.ApplyPolicy)
+ ReadRouteSelectionOptionsFromAPIStruct(&afiSafi.RouteSelectionOptions, af.RouteSelectionOptions)
+ ReadUseMultiplePathsFromAPIStruct(&afiSafi.UseMultiplePaths, af.UseMultiplePaths)
+ ReadPrefixLimitFromAPIStruct(&afiSafi.PrefixLimit, af.PrefixLimits)
+ ReadRouteTargetMembershipFromAPIStruct(&afiSafi.RouteTargetMembership, af.RouteTargetMembership)
+ ReadLongLivedGracefulRestartFromAPIStruct(&afiSafi.LongLivedGracefulRestart, af.LongLivedGracefulRestart)
+ ReadAddPathsFromAPIStruct(&afiSafi.AddPaths, af.AddPaths)
+ pconf.AfiSafis = append(pconf.AfiSafis, afiSafi)
+ }
+ // For the backward compatibility, we override AfiSafi configurations
+ // with Peer.Families.
for _, family := range a.Families {
- afiSafi := config.AfiSafi{
- Config: config.AfiSafiConfig{
- AfiSafiName: config.AfiSafiType(bgp.RouteFamily(family).String()),
- Enabled: true,
- },
- }
- for _, pl := range a.Conf.PrefixLimits {
- if family == pl.Family {
- ReadPrefixLimitFromAPIStruct(&afiSafi.PrefixLimit, pl)
+ found := false
+ for _, afiSafi := range pconf.AfiSafis {
+ if uint32(afiSafi.State.Family) == family {
+ // If Peer.Families contains the same address family,
+ // we enable this address family.
+ afiSafi.Config.Enabled = true
+ found = true
}
}
- for _, a := range a.AfiSafis {
- if a.Config != nil && family == a.Config.Family {
- ReadMpGracefulRestartFromAPIStruct(&afiSafi.MpGracefulRestart, a.MpGracefulRestart)
- ReadAfiSafiConfigFromAPIStruct(&afiSafi.Config, a.Config)
- ReadApplyPolicyFromAPIStruct(&afiSafi.ApplyPolicy, a.ApplyPolicy)
- ReadRouteSelectionOptionsFromAPIStruct(&afiSafi.RouteSelectionOptions, a.RouteSelectionOptions)
- ReadUseMultiplePathsFromAPIStruct(&afiSafi.UseMultiplePaths, a.UseMultiplePaths)
- ReadPrefixLimitFromAPIStruct(&afiSafi.PrefixLimit, a.PrefixLimits)
- ReadRouteTargetMembershipFromAPIStruct(&afiSafi.RouteTargetMembership, a.RouteTargetMembership)
- ReadLongLivedGracefulRestartFromAPIStruct(&afiSafi.LongLivedGracefulRestart, a.LongLivedGracefulRestart)
- ReadAddPathsFromAPIStruct(&afiSafi.AddPaths, a.AddPaths)
+ if !found {
+ // If Peer.Families does not contain the same address family,
+ // we append AfiSafi structure with the default value.
+ pconf.AfiSafis = append(pconf.AfiSafis, config.AfiSafi{
+ Config: config.AfiSafiConfig{
+ AfiSafiName: config.AfiSafiType(bgp.RouteFamily(family).String()),
+ Enabled: true,
+ },
+ })
+ }
+ }
+ // For the backward compatibility, we override AfiSafi configurations
+ // with Peer.Conf.PrefixLimits.
+ for _, prefixLimit := range a.Conf.PrefixLimits {
+ for _, afiSafi := range pconf.AfiSafis {
+ // If Peer.Conf.PrefixLimits contains the configuration for
+ // the same address family, we override AfiSafi.PrefixLimit.
+ if uint32(afiSafi.State.Family) == prefixLimit.Family {
+ ReadPrefixLimitFromAPIStruct(&afiSafi.PrefixLimit, prefixLimit)
}
}
- pconf.AfiSafis = append(pconf.AfiSafis, afiSafi)
}
}