Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle vswitch reconnect gracefully (vxlan + bridge fwd mode) #101

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions vxlanBridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,24 @@ func (self *Vxlan) SwitchConnected(sw *ofctrl.OFSwitch) {
self.initFgraph()

log.Infof("Switch connected(vxlan)")

// If vlanDb is populated and switch is connected, this implies
// we reconnected to a switch again. In this case, we have to
// update the current vlan entry to use a new switch object
if len(self.vlanDb) != 0 {
for vlanId, vlan := range self.vlanDb {
log.Debugf(" Updating vlan %s switch object", vlanId)
var err error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since none of the variables are used outside of the if statements immediately following them, I would get rid of this error variable and have the rest like this (also added error logging):

if vlan.localFlood, err := self.ofSwitch.NewFlood(); err != nil {
	log.Errorf("Unable to assign new switch to vlan %s local flood: %v", vlanId, err)
	return
}

if vlan.allFlood, err := self.ofSwitch.NewFlood(); err != nil {
	log.Errorf("Unable to assign new switch to vlan %s all flood: %v", vlanId, err)
	return
}

Also, do we want to break instead of return? Do we want to exit the loop at all or try to continue processing the rest of the entries? continue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind about the inline assignment thing, you can't do that when assigning to struct members lol

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I was think to use os.Exit().

vlan.localFlood, err = self.ofSwitch.NewFlood()
if err != nil {
log.Fatalf("Unable to assign new switch to vlan %v local flood", vlanId)
}
vlan.allFlood, err = self.ofSwitch.NewFlood()
if err != nil {
log.Fatalf("Unable to assign new switch to vlan %v all flood", vlanId)
}
}
}
}

// Handle switch disconnected notification
Expand Down