On Wed, 15 Apr 2015 11:40:21 +0800 Yi Tseng <[email protected]> wrote:
> Simple switch can't handle link failure, to handle that, we can add hard > timeout to every flow entry. Can you example a bit how the link failure can be handle with hard timeout set? Simple switch code is just an example. So I tend to keep it as simple as possible though. > Signed-off-by: Takeshi <[email protected]> > --- > ryu/app/simple_switch.py | 8 ++++---- > ryu/app/simple_switch_12.py | 6 +++--- > ryu/app/simple_switch_13.py | 10 +++++----- > ryu/app/simple_switch_14.py | 7 ++++--- > 4 files changed, 16 insertions(+), 15 deletions(-) > > diff --git a/ryu/app/simple_switch.py b/ryu/app/simple_switch.py > index 8fd3d21..27986e8 100644 > --- a/ryu/app/simple_switch.py > +++ b/ryu/app/simple_switch.py > @@ -38,7 +38,7 @@ class SimpleSwitch(app_manager.RyuApp): > super(SimpleSwitch, self).__init__(*args, **kwargs) > self.mac_to_port = {} > > - def add_flow(self, datapath, in_port, dst, actions): > + def add_flow(self, datapath, in_port, dst, actions, hard_timeout): > ofproto = datapath.ofproto > > match = datapath.ofproto_parser.OFPMatch( > @@ -46,8 +46,8 @@ class SimpleSwitch(app_manager.RyuApp): > > mod = datapath.ofproto_parser.OFPFlowMod( > datapath=datapath, match=match, cookie=0, > - command=ofproto.OFPFC_ADD, idle_timeout=0, hard_timeout=0, > - priority=ofproto.OFP_DEFAULT_PRIORITY, > + command=ofproto.OFPFC_ADD, idle_timeout=0, > + hard_timeout=hard_timeout, > priority=ofproto.OFP_DEFAULT_PRIORITY, > flags=ofproto.OFPFF_SEND_FLOW_REM, actions=actions) > datapath.send_msg(mod) > > @@ -80,7 +80,7 @@ class SimpleSwitch(app_manager.RyuApp): > > # install a flow to avoid packet_in next time > if out_port != ofproto.OFPP_FLOOD: > - self.add_flow(datapath, msg.in_port, dst, actions) > + self.add_flow(datapath, msg.in_port, dst, actions, 3) > > data = None > if msg.buffer_id == ofproto.OFP_NO_BUFFER: > diff --git a/ryu/app/simple_switch_12.py b/ryu/app/simple_switch_12.py > index 3df74e0..bb9c212 100644 > --- a/ryu/app/simple_switch_12.py > +++ b/ryu/app/simple_switch_12.py > @@ -32,7 +32,7 @@ class SimpleSwitch12(app_manager.RyuApp): > super(SimpleSwitch12, self).__init__(*args, **kwargs) > self.mac_to_port = {} > > - def add_flow(self, datapath, port, dst, actions): > + def add_flow(self, datapath, port, dst, actions, hard_timeout): > ofproto = datapath.ofproto > > match = datapath.ofproto_parser.OFPMatch(in_port=port, > @@ -42,7 +42,7 @@ class SimpleSwitch12(app_manager.RyuApp): > > mod = datapath.ofproto_parser.OFPFlowMod( > datapath=datapath, cookie=0, cookie_mask=0, table_id=0, > - command=ofproto.OFPFC_ADD, idle_timeout=0, hard_timeout=0, > + command=ofproto.OFPFC_ADD, idle_timeout=0, > hard_timeout=hard_timeout, > priority=0, buffer_id=ofproto.OFP_NO_BUFFER, > out_port=ofproto.OFPP_ANY, > out_group=ofproto.OFPG_ANY, > @@ -79,7 +79,7 @@ class SimpleSwitch12(app_manager.RyuApp): > > # install a flow to avoid packet_in next time > if out_port != ofproto.OFPP_FLOOD: > - self.add_flow(datapath, in_port, dst, actions) > + self.add_flow(datapath, in_port, dst, actions, 3) > > data = None > if msg.buffer_id == ofproto.OFP_NO_BUFFER: > diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py > index b9cbad0..f1be157 100644 > --- a/ryu/app/simple_switch_13.py > +++ b/ryu/app/simple_switch_13.py > @@ -47,7 +47,7 @@ class SimpleSwitch13(app_manager.RyuApp): > ofproto.OFPCML_NO_BUFFER)] > self.add_flow(datapath, 0, match, actions) > > - def add_flow(self, datapath, priority, match, actions, buffer_id=None): > + def add_flow(self, datapath, priority, match, actions, hard_timeout, > buffer_id=None): > ofproto = datapath.ofproto > parser = datapath.ofproto_parser > > @@ -56,10 +56,10 @@ class SimpleSwitch13(app_manager.RyuApp): > if buffer_id: > mod = parser.OFPFlowMod(datapath=datapath, buffer_id=buffer_id, > priority=priority, match=match, > - instructions=inst) > + instructions=inst, > hard_timeout=hard_timeout) > else: > mod = parser.OFPFlowMod(datapath=datapath, priority=priority, > - match=match, instructions=inst) > + match=match, instructions=inst, > hard_timeout=hard_timeout) > datapath.send_msg(mod) > > @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER) > @@ -102,10 +102,10 @@ class SimpleSwitch13(app_manager.RyuApp): > # verify if we have a valid buffer_id, if yes avoid to send > both > # flow_mod & packet_out > if msg.buffer_id != ofproto.OFP_NO_BUFFER: > - self.add_flow(datapath, 1, match, actions, msg.buffer_id) > + self.add_flow(datapath, 1, match, actions, 3, > msg.buffer_id) > return > else: > - self.add_flow(datapath, 1, match, actions) > + self.add_flow(datapath, 1, match, actions, 3) > data = None > if msg.buffer_id == ofproto.OFP_NO_BUFFER: > data = msg.data > diff --git a/ryu/app/simple_switch_14.py b/ryu/app/simple_switch_14.py > index 052740a..ca6dee8 100644 > --- a/ryu/app/simple_switch_14.py > +++ b/ryu/app/simple_switch_14.py > @@ -47,7 +47,7 @@ class SimpleSwitch14(app_manager.RyuApp): > ofproto.OFPCML_NO_BUFFER)] > self.add_flow(datapath, 0, match, actions) > > - def add_flow(self, datapath, priority, match, actions): > + def add_flow(self, datapath, priority, match, actions, hard_timeout): > ofproto = datapath.ofproto > parser = datapath.ofproto_parser > > @@ -55,7 +55,8 @@ class SimpleSwitch14(app_manager.RyuApp): > actions)] > > mod = parser.OFPFlowMod(datapath=datapath, priority=priority, > - match=match, instructions=inst) > + match=match, instructions=inst, > + hard_timeout=hard_timeout) > datapath.send_msg(mod) > > @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER) > @@ -90,7 +91,7 @@ class SimpleSwitch14(app_manager.RyuApp): > # install a flow to avoid packet_in next time > if out_port != ofproto.OFPP_FLOOD: > match = parser.OFPMatch(in_port=in_port, eth_dst=dst) > - self.add_flow(datapath, 1, match, actions) > + self.add_flow(datapath, 1, match, actions, 3) > > data = None > if msg.buffer_id == ofproto.OFP_NO_BUFFER: > -- > 2.3.2 (Apple Git-55) > > > ----- > Yi Tseng (Takeshi) > Taiwan National Chiao Tung University > Department of Computer Science > > ----- ------------------------------------------------------------------------------ BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT Develop your own process in accordance with the BPMN 2 standard Learn Process modeling best practices with Bonita BPM through live exercises http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_ source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
