diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-05-24 05:23:49 +0000 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-06-06 12:43:20 +0900 |
commit | 10746e5f4b303aba553c2bb759afe3a8d4ffe3aa (patch) | |
tree | ab9be9c87b0cdd7bdd8f4494edefb8ce6dbd1dfb /server/server.go | |
parent | b13c09baa66eaab822eb42bbf0a02fdbbf532932 (diff) |
server: refactoring for zebra related code use watcher infra
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r-- | server/server.go | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/server/server.go b/server/server.go index 7efc3686..faf4a06c 100644 --- a/server/server.go +++ b/server/server.go @@ -32,7 +32,6 @@ import ( "github.com/osrg/gobgp/packet/bgp" "github.com/osrg/gobgp/packet/bmp" "github.com/osrg/gobgp/table" - "github.com/osrg/gobgp/zebra" "github.com/satori/go.uuid" ) @@ -145,7 +144,6 @@ type BgpServer struct { fsmincomingCh *channels.InfiniteChannel fsmStateCh chan *FsmMsg acceptCh chan *net.TCPConn - zapiMsgCh chan *zebra.Message collector *Collector GrpcReqCh chan *GrpcRequest @@ -155,7 +153,6 @@ type BgpServer struct { listeners []*TCPListener neighborMap map[string]*Peer globalRib *table.TableManager - zclient *zebra.Client roaManager *roaManager shutdown bool watchers Watchers @@ -328,11 +325,6 @@ func (server *BgpServer) Serve() { select { case rmsg := <-server.roaManager.ReceiveROA(): server.roaManager.HandleROAEvent(rmsg) - case zmsg := <-server.zapiMsgCh: - m := handleZapiMsg(zmsg, server) - if len(m) > 0 { - senderMsgs = append(senderMsgs, m...) - } case conn := <-server.acceptCh: passConn(conn) case e, ok := <-server.fsmincomingCh.Out(): @@ -502,22 +494,11 @@ func (server *BgpServer) dropPeerAllRoutes(peer *Peer, families []bgp.RouteFamil } func (server *BgpServer) broadcastBests(bests []*table.Path) { + server.notify2watchers(WATCHER_EVENT_BESTPATH_CHANGE, &watcherEventBestPathMsg{pathList: bests}) for _, path := range bests { if path == nil { continue } - if !path.IsFromExternal() { - z := newBroadcastZapiBestMsg(server.zclient, path) - if z != nil { - server.broadcastMsgs = append(server.broadcastMsgs, z) - log.WithFields(log.Fields{ - "Topic": "Server", - "Client": z.client, - "Message": z.msg, - }).Debug("Default policy applied and rejected.") - } - } - rf := path.GetRouteFamily() result := &GrpcResponse{ @@ -2359,10 +2340,13 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { close(grpcReq.ResponseCh) case REQ_INITIALIZE_ZEBRA: c := grpcReq.Data.(*config.ZebraConfig) - cli, err := NewZclient(c.Url, c.RedistributeRouteTypeList) + protos := make([]string, 0, len(c.RedistributeRouteTypeList)) + for _, p := range c.RedistributeRouteTypeList { + protos = append(protos, string(p)) + } + z, err := newZebraWatcher(server.GrpcReqCh, c.Url, protos) if err == nil { - server.zclient = cli - server.zapiMsgCh = server.zclient.Receive() + server.watchers[WATCHER_ZEBRA] = z } grpcReq.ResponseCh <- &GrpcResponse{ ResponseErr: err, |