Skip to content
Snippets Groups Projects
Commit 5c028ffb authored by Oliver Herms's avatar Oliver Herms
Browse files

Cleanup

parent 78e504a5
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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"
}
......@@ -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()
}
......
......@@ -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)
......
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()
......
......@@ -14,7 +14,6 @@ type openSentState struct {
}
func newOpenSentState(fsm *FSM2) *openSentState {
fmt.Printf("newOpenSentState\n")
return &openSentState{
fsm: fsm,
}
......
......@@ -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())
......
......@@ -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
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment