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>
This commit is contained in:
parent
8fd7b9098a
commit
2528c33ba6
@ -47,13 +47,17 @@ class SimpleSwitch13(app_manager.RyuApp):
|
|||||||
ofproto.OFPCML_NO_BUFFER)]
|
ofproto.OFPCML_NO_BUFFER)]
|
||||||
self.add_flow(datapath, 0, match, actions)
|
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
|
ofproto = datapath.ofproto
|
||||||
parser = datapath.ofproto_parser
|
parser = datapath.ofproto_parser
|
||||||
|
|
||||||
inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,
|
inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,
|
||||||
actions)]
|
actions)]
|
||||||
|
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,
|
mod = parser.OFPFlowMod(datapath=datapath, priority=priority,
|
||||||
match=match, instructions=inst)
|
match=match, instructions=inst)
|
||||||
datapath.send_msg(mod)
|
datapath.send_msg(mod)
|
||||||
@ -95,8 +99,13 @@ class SimpleSwitch13(app_manager.RyuApp):
|
|||||||
# install a flow to avoid packet_in next time
|
# install a flow to avoid packet_in next time
|
||||||
if out_port != ofproto.OFPP_FLOOD:
|
if out_port != ofproto.OFPP_FLOOD:
|
||||||
match = parser.OFPMatch(in_port=in_port, eth_dst=dst)
|
match = parser.OFPMatch(in_port=in_port, eth_dst=dst)
|
||||||
|
# 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)
|
self.add_flow(datapath, 1, match, actions)
|
||||||
|
|
||||||
data = None
|
data = None
|
||||||
if msg.buffer_id == ofproto.OFP_NO_BUFFER:
|
if msg.buffer_id == ofproto.OFP_NO_BUFFER:
|
||||||
data = msg.data
|
data = msg.data
|
||||||
|
Loading…
Reference in New Issue
Block a user