From 5470822952b3489faed9664a5c91eb277eafbfd3 Mon Sep 17 00:00:00 2001 From: Kahou Lei Date: Tue, 21 Nov 2017 23:06:25 -0800 Subject: [PATCH 1/4] Handle vswitch reconnect gracefully (vxlan + bridge fwd mode) With vxlan bridge fwd mode, vxlanBridge will start the ovs switch object in two of the vlan flooding objects (localFlood and allFlood). The switch object is being populated when the first vxlan is assigned. When user restart ovs switch, ofnet handle the reconnect which pass down the notification to vxlanBridge object but it doesn't refresh the existing vlans to save the new switch object. This causes netplugin stuck to talk to an unbuffered channel. This patchset is to refresh vxlan entry to store new switch object when ofnet handle ovs switch reconnection Signed-off-by: Kahou Lei --- vxlanBridge.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/vxlanBridge.go b/vxlanBridge.go index 889f7d58..7d06ecd4 100755 --- a/vxlanBridge.go +++ b/vxlanBridge.go @@ -130,6 +130,26 @@ 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 + vlan.localFlood, err = self.ofSwitch.NewFlood() + if err != nil { + log.Errorf("Unable to assign new switch to vlan %s local flood", vlanId) + return + } + vlan.allFlood, err = self.ofSwitch.NewFlood() + if err != nil { + log.Errorf("Unable to assign new switch to vlan %s all flood", vlanId) + return + } + } + } } // Handle switch disconnected notification From fe03d11fa38f886f05b0316fc7bd44db298d97eb Mon Sep 17 00:00:00 2001 From: Kahou Lei Date: Wed, 22 Nov 2017 11:32:10 -0800 Subject: [PATCH 2/4] Use os.Exit(1) instead of return --- vxlanBridge.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vxlanBridge.go b/vxlanBridge.go index 7d06ecd4..5b68e18f 100755 --- a/vxlanBridge.go +++ b/vxlanBridge.go @@ -21,6 +21,7 @@ import ( "fmt" "net" "net/rpc" + "os" "strings" "github.com/contiv/libOpenflow/openflow13" @@ -141,12 +142,12 @@ func (self *Vxlan) SwitchConnected(sw *ofctrl.OFSwitch) { vlan.localFlood, err = self.ofSwitch.NewFlood() if err != nil { log.Errorf("Unable to assign new switch to vlan %s local flood", vlanId) - return + os.Exit(1) } vlan.allFlood, err = self.ofSwitch.NewFlood() if err != nil { log.Errorf("Unable to assign new switch to vlan %s all flood", vlanId) - return + os.Exit(1) } } } From 84e2c10a8199ec594cc63aecab91849cf20f4221 Mon Sep 17 00:00:00 2001 From: Kahou Lei Date: Wed, 22 Nov 2017 11:41:05 -0800 Subject: [PATCH 3/4] Use %v instead --- vxlanBridge.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vxlanBridge.go b/vxlanBridge.go index 5b68e18f..6a72ce7d 100755 --- a/vxlanBridge.go +++ b/vxlanBridge.go @@ -141,12 +141,12 @@ func (self *Vxlan) SwitchConnected(sw *ofctrl.OFSwitch) { var err error vlan.localFlood, err = self.ofSwitch.NewFlood() if err != nil { - log.Errorf("Unable to assign new switch to vlan %s local flood", vlanId) + log.Errorf("Unable to assign new switch to vlan %v local flood", vlanId) os.Exit(1) } vlan.allFlood, err = self.ofSwitch.NewFlood() if err != nil { - log.Errorf("Unable to assign new switch to vlan %s all flood", vlanId) + log.Errorf("Unable to assign new switch to vlan %v all flood", vlanId) os.Exit(1) } } From 5887e5c8fd9278d6c39a9bf928170ec3a7f1f41a Mon Sep 17 00:00:00 2001 From: Kahou Lei Date: Sat, 25 Nov 2017 08:03:48 -0800 Subject: [PATCH 4/4] Use Fatalf instead of os.Exit(1) --- vxlanBridge.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/vxlanBridge.go b/vxlanBridge.go index 6a72ce7d..21a33ec9 100755 --- a/vxlanBridge.go +++ b/vxlanBridge.go @@ -21,7 +21,6 @@ import ( "fmt" "net" "net/rpc" - "os" "strings" "github.com/contiv/libOpenflow/openflow13" @@ -141,13 +140,11 @@ func (self *Vxlan) SwitchConnected(sw *ofctrl.OFSwitch) { var err error vlan.localFlood, err = self.ofSwitch.NewFlood() if err != nil { - log.Errorf("Unable to assign new switch to vlan %v local flood", vlanId) - os.Exit(1) + log.Fatalf("Unable to assign new switch to vlan %v local flood", vlanId) } vlan.allFlood, err = self.ofSwitch.NewFlood() if err != nil { - log.Errorf("Unable to assign new switch to vlan %v all flood", vlanId) - os.Exit(1) + log.Fatalf("Unable to assign new switch to vlan %v all flood", vlanId) } } }