diff --git a/protocols/bgp/server/fsm2.go b/protocols/bgp/server/fsm2.go index 86725c681f9a3c7c904d78c538380af4d758f1b0..b365e41c61f42486b0ea00c94c93f0f82c021d02 100644 --- a/protocols/bgp/server/fsm2.go +++ b/protocols/bgp/server/fsm2.go @@ -74,7 +74,6 @@ type FSM2 struct { // NewPassiveFSM2 initiates a new passive FSM func NewPassiveFSM2(peer *Peer, con *net.TCPConn) *FSM2 { - fmt.Printf("NewPassiveFSM2\n") fsm := newFSM2(peer) fsm.con = con fsm.state = newIdleState(fsm) @@ -83,7 +82,6 @@ func NewPassiveFSM2(peer *Peer, con *net.TCPConn) *FSM2 { // NewActiveFSM2 initiates a new passive FSM func NewActiveFSM2(peer *Peer) *FSM2 { - fmt.Printf("NewActiveFSM2\n") fsm := newFSM2(peer) fsm.active = true fsm.state = newIdleState(fsm) @@ -116,7 +114,6 @@ func (fsm *FSM2) activate() { } func (fsm *FSM2) run() { - //fmt.Printf("Starting FSM\n") next, reason := fsm.state.run() for { newState := stateName(next) @@ -135,13 +132,10 @@ func (fsm *FSM2) run() { return } - //fmt.Printf("Aquiring lock...\n") fsm.stateMu.Lock() fsm.state = next - //fmt.Printf("Releasing lock...\n") fsm.stateMu.Unlock() - //fmt.Printf("Running new state\n") next, reason = fsm.state.run() } } @@ -172,12 +166,9 @@ func (fsm *FSM2) cease() { } func (fsm *FSM2) tcpConnector() error { - fmt.Printf("TCP CONNECTOR STARTED\n") for { - //fmt.Printf("READING FROM fsm.initiateCon\n") select { case <-fsm.initiateCon: - fmt.Printf("Initiating connection to %s\n", fsm.peer.addr.String()) c, err := net.DialTCP("tcp", &net.TCPAddr{IP: fsm.local}, &net.TCPAddr{IP: fsm.peer.addr, Port: BGPPORT}) if err != nil { select { @@ -188,7 +179,6 @@ func (fsm *FSM2) tcpConnector() error { } } - //fmt.Printf("GOT CONNECTION!\n") select { case fsm.conCh <- c: continue @@ -210,21 +200,12 @@ func (fsm *FSM2) msgReceiver() error { if err != nil { fsm.msgRecvFailCh <- err return nil - - /*select { - case fsm.msgRecvFailCh <- msgRecvErr{err: err, con: c}: - continue - case <-time.NewTimer(time.Second * 60).C: - return nil - }*/ } - fmt.Printf("Message received for %s: %v\n", fsm.con.RemoteAddr().String(), msg[18]) fsm.msgRecvCh <- msg } } func (fsm *FSM2) startConnectRetryTimer() { - fmt.Printf("Initializing connectRetryTimer: %d\n", fsm.connectRetryTime) fsm.connectRetryTimer = time.NewTimer(fsm.connectRetryTime) } @@ -239,8 +220,6 @@ func (fsm *FSM2) resetConnectRetryCounter() { } func (fsm *FSM2) sendOpen() error { - fmt.Printf("Sending OPEN Message to %s\n", fsm.con.RemoteAddr().String()) - msg := packet.SerializeOpenMsg(&packet.BGPOpen{ Version: BGPVersion, AS: uint16(fsm.peer.localASN), @@ -258,7 +237,6 @@ func (fsm *FSM2) sendOpen() error { } func (fsm *FSM2) sendNotification(errorCode uint8, errorSubCode uint8) error { - fmt.Printf("Sending NOTIFICATION Message to %s\n", fsm.con.RemoteAddr().String()) msg := packet.SerializeNotificationMsg(&packet.BGPNotification{}) _, err := fsm.con.Write(msg) @@ -270,7 +248,6 @@ func (fsm *FSM2) sendNotification(errorCode uint8, errorSubCode uint8) error { } func (fsm *FSM2) sendKeepalive() error { - fmt.Printf("Sending KEEPALIVE to %s\n", fsm.con.RemoteAddr().String()) msg := packet.SerializeKeepaliveMsg() _, err := fsm.con.Write(msg) diff --git a/protocols/bgp/server/fsm_active.go b/protocols/bgp/server/fsm_active.go index 2b269242f7017c10435a3a2a718d009f5a3c3b15..f8fa6b39c933215e0482f7838b89507073d8c515 100644 --- a/protocols/bgp/server/fsm_active.go +++ b/protocols/bgp/server/fsm_active.go @@ -17,7 +17,6 @@ func newActiveState(fsm *FSM2) *activeState { } func (s activeState) run() (state, string) { - fmt.Printf("THIS IS ACTIVE STATE\n") for { select { case e := <-s.fsm.eventCh: @@ -32,7 +31,6 @@ func (s activeState) run() (state, string) { case <-s.fsm.connectRetryTimer.C: return s.connectRetryTimerExpired() case c := <-s.fsm.conCh: - fmt.Printf("Received a connection in active state\n") return s.connectionSuccess(c) } } @@ -66,6 +64,5 @@ func (s *activeState) connectionSuccess(con net.Conn) (state, string) { return newIdleState(s.fsm), fmt.Sprintf("Sending OPEN message failed: %v", err) } s.fsm.holdTimer = time.NewTimer(time.Minute * 4) - fmt.Printf("Next state: OpenSent!\n") return newOpenSentState(s.fsm), "Sent OPEN message" } diff --git a/protocols/bgp/server/fsm_connect.go b/protocols/bgp/server/fsm_connect.go index eac1459425aa66a271851fed21034bf8cd42e006..cc9ce060b12289059099948114f3929d0e2a6c38 100644 --- a/protocols/bgp/server/fsm_connect.go +++ b/protocols/bgp/server/fsm_connect.go @@ -38,7 +38,6 @@ func (s connectState) run() (state, string) { } func (s *connectState) connectionSuccess(c net.Conn) (state, string) { - fmt.Printf("GOT A TCP CONNECTION!\n") s.fsm.con = c stopTimer(s.fsm.connectRetryTimer) err := s.fsm.sendOpen() @@ -50,7 +49,6 @@ func (s *connectState) connectionSuccess(c net.Conn) (state, string) { } func (s *connectState) connectRetryTimerExpired() { - fmt.Printf("Connect retry timer expired\n") s.fsm.resetConnectRetryTimer() s.fsm.tcpConnect() } diff --git a/protocols/bgp/server/fsm_established.go b/protocols/bgp/server/fsm_established.go index faebad99f295507bf11b660f76071908a939bdc6..02f5ac244ddbc5034f7d447705c4d7b74378bfdd 100644 --- a/protocols/bgp/server/fsm_established.go +++ b/protocols/bgp/server/fsm_established.go @@ -201,11 +201,14 @@ func (s *establishedState) updates(u *packet.BGPUpdate) { case packet.MEDAttr: path.BGPPath.MED = pa.Value.(uint32) case packet.NextHopAttr: - fmt.Printf("RECEIVED NEXT_HOP: %d\n", pa.Value.(uint32)) path.BGPPath.NextHop = pa.Value.(uint32) case packet.ASPathAttr: path.BGPPath.ASPath = pa.ASPathString() path.BGPPath.ASPathLen = pa.ASPathLen() + case packet.CommunitiesAttr: + path.BGPPath.Communities = pa.CommunityString() + case packet.LargeCommunitiesAttr: + path.BGPPath.LargeCommunities = pa.LargeCommunityString() } } s.fsm.adjRIBIn.AddPath(pfx, path) diff --git a/protocols/bgp/server/fsm_idle.go b/protocols/bgp/server/fsm_idle.go index 87d57f79050bf00659ade688b22ed2afe090e838..ce4cc105a7a079f15817485b0486686b1ae29eb1 100644 --- a/protocols/bgp/server/fsm_idle.go +++ b/protocols/bgp/server/fsm_idle.go @@ -1,7 +1,6 @@ package server import ( - "fmt" "time" ) @@ -23,7 +22,6 @@ func (s idleState) run() (state, string) { } for { event := <-s.fsm.eventCh - fmt.Printf("Event: %d\n", event) switch event { case ManualStart: return s.manualStart() diff --git a/protocols/bgp/server/fsm_open_sent.go b/protocols/bgp/server/fsm_open_sent.go index bb29ef6f76b443eed8b7ea9085e80bc25ec7826b..5504a525f3c4d0f6569aed80579eb5b2da29fec7 100644 --- a/protocols/bgp/server/fsm_open_sent.go +++ b/protocols/bgp/server/fsm_open_sent.go @@ -14,7 +14,6 @@ type openSentState struct { } func newOpenSentState(fsm *FSM2) *openSentState { - fmt.Printf("newOpenSentState\n") return &openSentState{ fsm: fsm, } diff --git a/protocols/bgp/server/server.go b/protocols/bgp/server/server.go index 6cd2de5e28586e7a94146f05e7dccc8d30c1bc11..bd1f662b470b7a02220bb14010b85e5aa3835683 100644 --- a/protocols/bgp/server/server.go +++ b/protocols/bgp/server/server.go @@ -60,6 +60,7 @@ func (b *BGPServer) Start(c *config.Global) error { func (b *BGPServer) incomingConnectionWorker() { for { + // Disabled. We're active only for now. /*c := <-b.acceptCh fmt.Printf("Incoming connection!\n") fmt.Printf("Connection from: %v\n", c.RemoteAddr()) diff --git a/protocols/bgp/server/update_sender_add_path.go b/protocols/bgp/server/update_sender_add_path.go index e777180cb834361411fcef30f9ae8872ab0152e9..7d22bcaa0eea6dce7747bad27237d7f3dd0401eb 100644 --- a/protocols/bgp/server/update_sender_add_path.go +++ b/protocols/bgp/server/update_sender_add_path.go @@ -50,6 +50,6 @@ func (u *UpdateSenderAddPath) RemovePath(pfx net.Prefix, p *route.Path) bool { // UpdateNewClient does nothing func (u *UpdateSenderAddPath) UpdateNewClient(client routingtable.RouteTableClient) error { - log.Warningf("BGP Update Sender: RemovePath not implemented") + log.Warningf("BGP Update Sender: UpdateNewClient not implemented") return nil }