summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-12-18 20:19:01 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-12-18 20:19:01 -0800
commitd7b9a40ba1fa2fb8d1aa9e0210bf117b6c88e996 (patch)
treee2e0ea342a605da3be60329a49c7970877284ab9
parentd5a7a4569a5e6b55eda9c26ce70b846b643ebf50 (diff)
peer: update local rib
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--server/peer.go15
-rw-r--r--table/table_manager.go4
2 files changed, 14 insertions, 5 deletions
diff --git a/server/peer.go b/server/peer.go
index f4e2d1f8..b24a1349 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -36,6 +36,9 @@ type Peer struct {
outEventCh chan *message
fsm *FSM
adjRib *table.AdjRib
+ // peer and rib are always not one-to-one so should not be
+ // here but it's the simplest and works our first target.
+ rib *table.TableManager
}
func NewPeer(g config.GlobalType, peer config.NeighborType, outEventCh chan *message) *Peer {
@@ -50,6 +53,7 @@ func NewPeer(g config.GlobalType, peer config.NeighborType, outEventCh chan *mes
}
p.fsm = NewFSM(&g, &peer, p.acceptedConnCh, p.incoming, p.outgoing)
p.adjRib = table.NewAdjRib()
+ p.rib = table.NewTableManager()
p.t.Go(p.loop)
return p
}
@@ -71,8 +75,13 @@ func (peer *Peer) handleBGPmessage(m *bgp.BGPMessage) {
peer.adjRib.UpdateIn(pathList)
- for path := range pathList {
- peer.sendToHub("", PEER_MSG_PATH, path)
+ peer.sendToHub("", PEER_MSG_PATH, pathList)
+}
+
+func (peer *Peer) handlePeermessage(m *message) {
+ switch m.event {
+ case PEER_MSG_PATH:
+ pList, wList, _ := peer.rib.ProcessPaths(m.data.([]table.Path))
}
}
@@ -100,7 +109,7 @@ func (peer *Peer) loop() error {
}
peer.handleBGPmessage(m)
case m := <-peer.inEventCh:
- fmt.Println(m)
+ peer.handlePeermessage(m)
}
}
}
diff --git a/table/table_manager.go b/table/table_manager.go
index 9fe4032a..72fa5f0b 100644
--- a/table/table_manager.go
+++ b/table/table_manager.go
@@ -257,7 +257,7 @@ func (manager *TableManager) incrCounter(name PeerCounterName, step int) {
manager.Counter[name] = val
}
-func (manager *TableManager) processUpdate(pathList []Path) ([]Path, []Destination, error) {
+func (manager *TableManager) ProcessPaths(pathList []Path) ([]Path, []Destination, error) {
bestPaths := make([]Path, 0)
lostDest := make([]Destination, 0)
@@ -339,7 +339,7 @@ func (manager *TableManager) ProcessUpdate(fromPeer *PeerInfo, message *bgp.BGPM
fromPeer: fromPeer,
}
- return manager.processUpdate(msg.ToPathList())
+ return manager.ProcessPaths(msg.ToPathList())
}
type AdjRib struct {