diff options
author | Jerico Moeyersons <jerico09@hotmail.com> | 2017-11-28 10:28:12 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-11-28 10:28:12 +0900 |
commit | 3b946c01929c6f390721731c9d31aa09feeb858a (patch) | |
tree | 2d18da915e4c359e17f453948fc5a26cbb98f64f | |
parent | ed2c6eca2227c9efb3c7e51cdd6db6bf578ec609 (diff) |
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>
-rw-r--r-- | ryu/app/simple_switch.py | 7 | ||||
-rw-r--r-- | ryu/app/simple_switch_12.py | 7 | ||||
-rw-r--r-- | ryu/app/simple_switch_13.py | 2 | ||||
-rw-r--r-- | ryu/app/simple_switch_14.py | 2 |
4 files changed, 10 insertions, 8 deletions
diff --git a/ryu/app/simple_switch.py b/ryu/app/simple_switch.py index 862b8303..33c4f7d0 100644 --- a/ryu/app/simple_switch.py +++ b/ryu/app/simple_switch.py @@ -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: diff --git a/ryu/app/simple_switch_12.py b/ryu/app/simple_switch_12.py index 6895b074..5e078515 100644 --- a/ryu/app/simple_switch_12.py +++ b/ryu/app/simple_switch_12.py @@ -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: diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py index 3e7c598c..06a5d0ed 100644 --- a/ryu/app/simple_switch_13.py +++ b/ryu/app/simple_switch_13.py @@ -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: diff --git a/ryu/app/simple_switch_14.py b/ryu/app/simple_switch_14.py index d3151bc0..c932eda1 100644 --- a/ryu/app/simple_switch_14.py +++ b/ryu/app/simple_switch_14.py @@ -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 |