app: Fix simple_switch for multi switch env
Currently, the matches of flows in the learning switch examples are based on the destination and the in_port. In a multi-OF-switch environment this could cause issues when doing calls from a host on a first switch to multiple hosts on another switch, namely that new destinations aren't added as a flow because the source is already known on the second switch (when doing multiple calls to different hosts on another switch). This patch fixes this issue by adding the eth_src to the match field. Reported-by: Jerico Moeyersons <jerico09@hotmail.com>
This commit is contained in:
parent
ed2c6eca22
commit
3b946c0192
@ -36,11 +36,12 @@ 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, src, actions):
|
||||
ofproto = datapath.ofproto
|
||||
|
||||
match = datapath.ofproto_parser.OFPMatch(
|
||||
in_port=in_port, dl_dst=haddr_to_bin(dst))
|
||||
in_port=in_port,
|
||||
dl_dst=haddr_to_bin(dst), dl_src=haddr_to_bin(src))
|
||||
|
||||
mod = datapath.ofproto_parser.OFPFlowMod(
|
||||
datapath=datapath, match=match, cookie=0,
|
||||
@ -81,7 +82,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, src, actions)
|
||||
|
||||
data = None
|
||||
if msg.buffer_id == ofproto.OFP_NO_BUFFER:
|
||||
|
@ -30,11 +30,12 @@ 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, src, actions):
|
||||
ofproto = datapath.ofproto
|
||||
|
||||
match = datapath.ofproto_parser.OFPMatch(in_port=port,
|
||||
eth_dst=dst)
|
||||
eth_dst=dst,
|
||||
eth_src=src)
|
||||
inst = [datapath.ofproto_parser.OFPInstructionActions(
|
||||
ofproto.OFPIT_APPLY_ACTIONS, actions)]
|
||||
|
||||
@ -80,7 +81,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, src, actions)
|
||||
|
||||
data = None
|
||||
if msg.buffer_id == ofproto.OFP_NO_BUFFER:
|
||||
|
@ -102,7 +102,7 @@ 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)
|
||||
match = parser.OFPMatch(in_port=in_port, eth_dst=dst, eth_src=src)
|
||||
# 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:
|
||||
|
@ -93,7 +93,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)
|
||||
match = parser.OFPMatch(in_port=in_port, eth_dst=dst, eth_src=src)
|
||||
self.add_flow(datapath, 1, match, actions)
|
||||
|
||||
data = None
|
||||
|
Loading…
Reference in New Issue
Block a user