diff options
author | Satoshi Fujimoto <satoshi.fujimoto7@gmail.com> | 2017-05-18 15:34:35 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-06-05 14:24:45 +0900 |
commit | 6e9d5b56c41904fbc63928888d3437f88f05f473 (patch) | |
tree | 624e993941e6e032ba1d33d47466d95f4de0a4ba /gobgpd | |
parent | 8fd9530ff9602912c57c18faf86e4144533c1f05 (diff) |
*: Support Peer-Group Configuration
This patch enables to create peer-groups,
also supports dynamic configuration to peer-groups.
Manually set fields in neighbor configs have priority over its peer-group's config,
except some fields, like "peer-as", or "minimum-advertisement-interval" and so on.
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Diffstat (limited to 'gobgpd')
-rw-r--r-- | gobgpd/main.go | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/gobgpd/main.go b/gobgpd/main.go index 91e98f6c..c80faa84 100644 --- a/gobgpd/main.go +++ b/gobgpd/main.go @@ -149,6 +149,7 @@ func main() { select { case newConfig := <-configCh: var added, deleted, updated []config.Neighbor + var addedPg, deletedPg, updatedPg []config.PeerGroup var updatePolicy bool if c == nil { @@ -190,6 +191,7 @@ func main() { } added = newConfig.Neighbors + addedPg = newConfig.PeerGroups if opts.GracefulRestart { for i, n := range added { if n.GracefulRestart.Config.Enabled { @@ -199,7 +201,10 @@ func main() { } } else { - added, deleted, updated, updatePolicy = config.UpdateConfig(c, newConfig) + addedPg, deletedPg, updatedPg = config.UpdatePeerGroupConfig(c, newConfig) + added, deleted, updated = config.UpdateNeighborConfig(c, newConfig) + updatePolicy = config.CheckPolicyDifference(config.ConfigSetToRoutingPolicy(c), config.ConfigSetToRoutingPolicy(newConfig)) + if updatePolicy { log.Info("Policy config is updated") p := config.ConfigSetToRoutingPolicy(newConfig) @@ -241,7 +246,26 @@ func main() { } c = newConfig } - + for i, pg := range addedPg { + log.Infof("PeerGroup %s is added", pg.Config.PeerGroupName) + if err := bgpServer.AddPeerGroup(&addedPg[i]); err != nil { + log.Warn(err) + } + } + for i, pg := range deletedPg { + log.Infof("PeerGroup %s is deleted", pg.Config.PeerGroupName) + if err := bgpServer.DeletePeerGroup(&deletedPg[i]); err != nil { + log.Warn(err) + } + } + for i, pg := range updatedPg { + log.Infof("PeerGroup %s is updated", pg.Config.PeerGroupName) + u, err := bgpServer.UpdatePeerGroup(&updatedPg[i]) + if err != nil { + log.Warn(err) + } + updatePolicy = updatePolicy || u + } for i, p := range added { log.Infof("Peer %v is added", p.Config.NeighborAddress) if err := bgpServer.AddNeighbor(&added[i]); err != nil { |