summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-04-24 16:40:00 +0000
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-04-25 03:16:18 +0000
commit6f95b7dc62b0ce8523e4f6da2e2bff5f4a4d3b78 (patch)
tree3914b8121ce115f86ea1fbbcf92e80cd52fc01f0
parent205063dc8334032ccd250cabee96cd09fea76c68 (diff)
server: issue SOFT_RESET_IN when policy assignment is changed
fix 0c58e348de62bf156582417a6b9d726dd4fe116e Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r--gobgpd/main.go22
-rw-r--r--server/server.go32
2 files changed, 30 insertions, 24 deletions
diff --git a/gobgpd/main.go b/gobgpd/main.go
index 192b85f9..fc0d6e2c 100644
--- a/gobgpd/main.go
+++ b/gobgpd/main.go
@@ -198,6 +198,7 @@ func main() {
select {
case newConfig := <-configCh:
var added, deleted, updated []config.Neighbor
+ var updatePolicy bool
if c == nil {
c = newConfig
@@ -228,7 +229,6 @@ func main() {
}
} else {
- var updatePolicy bool
added, deleted, updated, updatePolicy = config.UpdateConfig(c, newConfig)
if updatePolicy {
log.Info("Policy config is updated")
@@ -248,7 +248,25 @@ func main() {
}
for _, p := range updated {
log.Infof("Peer %v is updated", p.Config.NeighborAddress)
- bgpServer.PeerUpdate(p)
+ u, _ := bgpServer.PeerUpdate(p)
+ updatePolicy = updatePolicy || u
+ }
+
+ if updatePolicy {
+ // TODO: we want to apply the new policies to the existing
+ // routes here. Sending SOFT_RESET_IN to all the peers works
+ // for the change of in and import policies. SOFT_RESET_OUT is
+ // necessary for the export policy but we can't blindly
+ // execute SOFT_RESET_OUT because we unnecessarily advertize
+ // the existing routes. Needs to investigate the changes of
+ // policies and handle only affected peers.
+ ch := make(chan *server.GrpcResponse)
+ bgpServer.GrpcReqCh <- &server.GrpcRequest{
+ RequestType: server.REQ_NEIGHBOR_SOFT_RESET_IN,
+ Name: "all",
+ ResponseCh: ch,
+ }
+ <-ch
}
case sig := <-sigCh:
switch sig {
diff --git a/server/server.go b/server/server.go
index 4fa71651..a021dd84 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1085,14 +1085,15 @@ func (server *BgpServer) PeerDelete(peer config.Neighbor) error {
return (<-ch).Err()
}
-func (server *BgpServer) PeerUpdate(peer config.Neighbor) error {
+func (server *BgpServer) PeerUpdate(peer config.Neighbor) (bool, error) {
ch := make(chan *GrpcResponse)
server.GrpcReqCh <- &GrpcRequest{
RequestType: REQ_UPDATE_NEIGHBOR,
Data: &peer,
ResponseCh: ch,
}
- return (<-ch).Err()
+ res := <-ch
+ return res.Data.(bool), res.Err()
}
func (server *BgpServer) Shutdown() {
@@ -1111,21 +1112,6 @@ func (server *BgpServer) UpdatePolicy(policy config.RoutingPolicy) {
ResponseCh: ch,
}
<-ch
- // TODO: we want to apply the new policies to the existing
- // routes here. Sending SOFT_RESET_IN to all the peers works
- // for the change of in and import policies. SOFT_RESET_OUT is
- // necessary for the export policy but we can't blindly
- // execute SOFT_RESET_OUT because we unnecessarily advertize
- // the existing routes. Needs to investigate the changes of
- // policies and handle only affected peers.
-
- ch = make(chan *GrpcResponse)
- server.GrpcReqCh <- &GrpcRequest{
- RequestType: REQ_NEIGHBOR_SOFT_RESET_IN,
- Name: "all",
- ResponseCh: ch,
- }
- <-ch
}
func (server *BgpServer) setPolicyByConfig(id string, c config.ApplyPolicy) {
@@ -2194,8 +2180,9 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg {
}
close(grpcReq.ResponseCh)
case REQ_UPDATE_NEIGHBOR:
- m, err := server.handleUpdateNeighbor(grpcReq.Data.(*config.Neighbor))
+ m, policyUpdated, err := server.handleUpdateNeighbor(grpcReq.Data.(*config.Neighbor))
grpcReq.ResponseCh <- &GrpcResponse{
+ Data: policyUpdated,
ResponseErr: err,
}
if len(m) > 0 {
@@ -2384,13 +2371,15 @@ func (server *BgpServer) handleDelNeighbor(c *config.Neighbor) ([]*SenderMsg, er
return m, nil
}
-func (server *BgpServer) handleUpdateNeighbor(c *config.Neighbor) ([]*SenderMsg, error) {
+func (server *BgpServer) handleUpdateNeighbor(c *config.Neighbor) ([]*SenderMsg, bool, error) {
addr := c.Config.NeighborAddress
peer := server.neighborMap[addr]
+ policyUpdated := false
if !peer.fsm.pConf.ApplyPolicy.Equal(&c.ApplyPolicy) {
server.setPolicyByConfig(peer.ID(), c.ApplyPolicy)
peer.fsm.pConf.ApplyPolicy = c.ApplyPolicy
+ policyUpdated = true
}
original := peer.fsm.pConf
@@ -2402,10 +2391,9 @@ func (server *BgpServer) handleUpdateNeighbor(c *config.Neighbor) ([]*SenderMsg,
}).Error(err)
// rollback to original state
peer.fsm.pConf = original
- return nil, err
+ return nil, policyUpdated, err
}
- return msgs, nil
-
+ return msgs, policyUpdated, nil
}
func (server *BgpServer) handleGrpcModNeighbor(grpcReq *GrpcRequest) ([]*SenderMsg, error) {