config: Option to enable Dynamic Neighbor

Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
This commit is contained in:
Satoshi Fujimoto
2017-06-15 08:55:16 +09:00
parent be2524ee3e
commit 369626d222
2 changed files with 105 additions and 0 deletions
+66
View File
@@ -965,6 +965,54 @@ func (v RpkiValidationResultType) Validate() error {
return nil
}
//struct for container gobgp:state
type DynamicNeighborState struct {
// original -> gobgp:prefix
Prefix string `mapstructure:"prefix" json:"prefix,omitempty"`
// original -> gobgp:peer-group
PeerGroup string `mapstructure:"peer-group" json:"peer-group,omitempty"`
}
//struct for container gobgp:config
type DynamicNeighborConfig struct {
// original -> gobgp:prefix
Prefix string `mapstructure:"prefix" json:"prefix,omitempty"`
// original -> gobgp:peer-group
PeerGroup string `mapstructure:"peer-group" json:"peer-group,omitempty"`
}
func (lhs *DynamicNeighborConfig) Equal(rhs *DynamicNeighborConfig) bool {
if lhs == nil || rhs == nil {
return false
}
if lhs.Prefix != rhs.Prefix {
return false
}
if lhs.PeerGroup != rhs.PeerGroup {
return false
}
return true
}
//struct for container gobgp:dynamic-neighbor
type DynamicNeighbor struct {
// original -> gobgp:prefix
// original -> gobgp:dynamic-neighbor-config
Config DynamicNeighborConfig `mapstructure:"config" json:"config,omitempty"`
// original -> gobgp:dynamic-neighbor-state
State DynamicNeighborState `mapstructure:"state" json:"state,omitempty"`
}
func (lhs *DynamicNeighbor) Equal(rhs *DynamicNeighbor) bool {
if lhs == nil || rhs == nil {
return false
}
if !lhs.Config.Equal(&(rhs.Config)) {
return false
}
return true
}
//struct for container gobgp:state
type CollectorState struct {
// original -> gobgp:url
@@ -3778,6 +3826,8 @@ type Bgp struct {
Zebra Zebra `mapstructure:"zebra" json:"zebra,omitempty"`
// original -> gobgp:collector
Collector Collector `mapstructure:"collector" json:"collector,omitempty"`
// original -> gobgp:dynamic-neighbors
DynamicNeighbors []DynamicNeighbor `mapstructure:"dynamic-neighbors" json:"dynamic-neighbors,omitempty"`
}
func (lhs *Bgp) Equal(rhs *Bgp) bool {
@@ -3873,6 +3923,22 @@ func (lhs *Bgp) Equal(rhs *Bgp) bool {
if !lhs.Collector.Equal(&(rhs.Collector)) {
return false
}
if len(lhs.DynamicNeighbors) != len(rhs.DynamicNeighbors) {
return false
}
{
lmap := make(map[string]*DynamicNeighbor)
for i, l := range lhs.DynamicNeighbors {
lmap[mapkey(i, string(l.Config.Prefix))] = &lhs.DynamicNeighbors[i]
}
for i, r := range rhs.DynamicNeighbors {
if l, y := lmap[mapkey(i, string(r.Config.Prefix))]; !y {
return false
} else if !r.Equal(l) {
return false
}
}
}
return true
}
+39
View File
@@ -1126,6 +1126,45 @@ module gobgp {
uses listen-config;
}
grouping dynamic-neighbors {
container dynamic-neighbors {
list dynamic-neighbor {
key "prefix";
leaf prefix {
type leafref {
path "../config/prefix";
}
}
container config {
uses bgp-global-dynamic-neighbor-config;
}
container state {
config false;
uses bgp-global-dynamic-neighbor-config;
}
}
}
}
grouping bgp-global-dynamic-neighbor-config {
description "A dynamic neighbor belongs to a peer group.
This configuration structure was taken from the latest openconfig.";
leaf prefix {
type string;
}
leaf peer-group {
type string;
}
}
augment "/bgp:bgp" {
uses dynamic-neighbors;
}
augment "/bgp:bgp/bgp:global/bgp:afi-safis/bgp:afi-safi" {
uses bgp-mp:all-afi-safi-common;
}