summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBenjamin Eggerstedt <benjamin.eggerstedt@gmail.com>2014-11-01 05:13:49 +0100
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-11-01 05:13:49 +0100
commit2528c33ba61ef9436210b1f0bd7dae7a138d1c91 (patch)
treef8eab0f7a9e3ea53b4100a1c4d0160195c733ae3
parent8fd7b9098aa347fb0193fcc77650a9f544242fff (diff)
simple_switch_13.py: Added ability to use buffer_id in FlowMod
This avoids to send two packets (FlowMod & PacketOut). OF v1.3.1 (the specification most switch vendors implemented) mentions in A.3.4.1 on page 65 that this is a valid way to avoid two packets. Signed-off-by: Benny Eggerstedt <benjamin.eggerstedt@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/app/simple_switch_13.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py
index 0e1574fd..b9cbad0f 100644
--- a/ryu/app/simple_switch_13.py
+++ b/ryu/app/simple_switch_13.py
@@ -47,15 +47,19 @@ class SimpleSwitch13(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, buffer_id=None):
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,
actions)]
-
- mod = parser.OFPFlowMod(datapath=datapath, priority=priority,
- match=match, instructions=inst)
+ if buffer_id:
+ mod = parser.OFPFlowMod(datapath=datapath, buffer_id=buffer_id,
+ priority=priority, match=match,
+ instructions=inst)
+ else:
+ mod = parser.OFPFlowMod(datapath=datapath, priority=priority,
+ match=match, instructions=inst)
datapath.send_msg(mod)
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
@@ -95,8 +99,13 @@ class SimpleSwitch13(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)
-
+ # 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)
+ return
+ else:
+ self.add_flow(datapath, 1, match, actions)
data = None
if msg.buffer_id == ofproto.OFP_NO_BUFFER:
data = msg.data