Hello, Minoru.
On 8/19/14, Minoru TAKAHASHI <[email protected]> wrote:
> Hi, Pyxis
>
> (2014年08月19日 00:03), Pyxis LX wrote:
>> Hi, all.
>>
>> I'm trying to make a patch for this.
>>
>> But I'm not sure which behavior is more preferable?
>>
>> 1. These configuration items will override the output port in the test
>> files.
>>
>> 2. These configuration items will not override the output port in the
>> test files.
>>
>> I think 1. should be more preferable, but I'm not quite about this.
>
> I agree with you.
>
>> 1. These configuration items will override the output port in the test
>> files.
> Just for your information,
> for the following tests, must also override "input port".
> * Match ... "input port" of target sw
> * Meter,Group ... "input port" of target sw and tester sw
> And,Group test must override the multiple ports.
Thank you for the advise.
I've done a quick & dirty hack for this purpose.
This patch will only override port 1 and 2 on target & tester.
Other ports are left as-is.
>
> If there's anything you need help with please tell me.
> Alternatively, It is also possible for me to create a patch.
>
> thanks
>
If someone has created one for this, please feel free to ignore mine.
If I omitted anything, please feel free to modify it. ;)
Thanks!
-PLX
diff --git a/ryu/flags.py b/ryu/flags.py
index 7c50e69..61e0f03 100644
--- a/ryu/flags.py
+++ b/ryu/flags.py
@@ -53,8 +53,12 @@ CONF.register_cli_opts([
CONF.register_cli_opts([
# tests/switch/tester
- cfg.StrOpt('target', default='0000000000000001', help='target sw dp-id'),
cfg.StrOpt('tester', default='0000000000000002', help='tester sw dp-id'),
+ cfg.StrOpt('tester_send_port', default=1, help='tester sw sending port'),
+ cfg.StrOpt('tester_recv_port', default=2, help='tester sw receiving port'),
+ cfg.StrOpt('target', default='0000000000000001', help='target sw dp-id'),
+ cfg.StrOpt('target_send_port', default=2, help='target sw sending port'),
+ cfg.StrOpt('target_recv_port', default=1, help='target sw receiving port'),
cfg.StrOpt('dir', default='ryu/tests/switch/of13',
help='test files directory'),
cfg.StrOpt('target-version', default='openflow13',
diff --git a/ryu/tests/switch/tester.py b/ryu/tests/switch/tester.py
index b6826e5..2caf1e8 100644
--- a/ryu/tests/switch/tester.py
+++ b/ryu/tests/switch/tester.py
@@ -81,11 +81,6 @@ CONF = cfg.CONF
# Default settings.
-TESTER_SENDER_PORT = 1
-TESTER_RECEIVE_PORT = 2
-TARGET_SENDER_PORT = 2
-TARGET_RECEIVE_PORT = 1
-
INTERVAL = 1 # sec
WAIT_TIMER = 3 # sec
CONTINUOUS_THREAD_INTVL = float(0.01) # sec
@@ -265,7 +260,11 @@ class OfTester(app_manager.RyuApp):
self._set_logger()
self.target_dpid = self._convert_dpid(CONF['test-switch']['target'])
+ self.target_send_port = int(CONF['test-switch']['target_send_port'])
+ self.target_recv_port = int(CONF['test-switch']['target_recv_port'])
self.tester_dpid = self._convert_dpid(CONF['test-switch']['tester'])
+ self.tester_send_port = int(CONF['test-switch']['tester_send_port'])
+ self.tester_recv_port = int(CONF['test-switch']['tester_recv_port'])
self.logger.info('target_dpid=%s',
dpid_lib.dpid_to_str(self.target_dpid))
self.logger.info('tester_dpid=%s',
@@ -363,7 +362,7 @@ class OfTester(app_manager.RyuApp):
else:
self.tester_sw.dp = dp
self.tester_sw.add_flow(
- in_port=TESTER_RECEIVE_PORT,
+ in_port=self.tester_recv_port,
out_port=dp.ofproto.OFPP_CONTROLLER)
msg = 'Join tester SW.'
else:
@@ -712,14 +711,22 @@ class OfTester(app_manager.RyuApp):
def _test_no_pktin_reason_check(self, test_type,
target_pkt_count, tester_pkt_count):
- before_target_receive = target_pkt_count[0][TARGET_RECEIVE_PORT]['rx']
- before_target_send = target_pkt_count[0][TARGET_SENDER_PORT]['tx']
- before_tester_receive = tester_pkt_count[0][TESTER_RECEIVE_PORT]['rx']
- before_tester_send = tester_pkt_count[0][TESTER_SENDER_PORT]['tx']
- after_target_receive = target_pkt_count[1][TARGET_RECEIVE_PORT]['rx']
- after_target_send = target_pkt_count[1][TARGET_SENDER_PORT]['tx']
- after_tester_receive = tester_pkt_count[1][TESTER_RECEIVE_PORT]['rx']
- after_tester_send = tester_pkt_count[1][TESTER_SENDER_PORT]['tx']
+ before_target_receive = target_pkt_count[0][
+ self.target_recv_port]['rx']
+ before_target_send = target_pkt_count[0][
+ self.target_send_port]['tx']
+ before_tester_receive = tester_pkt_count[0][
+ self.tester_recv_port]['rx']
+ before_tester_send = tester_pkt_count[0][
+ self.tester_send_port]['tx']
+ after_target_receive = target_pkt_count[1][
+ self.target_recv_port]['rx']
+ after_target_send = target_pkt_count[1][
+ self.target_send_port]['tx']
+ after_tester_receive = tester_pkt_count[1][
+ self.tester_recv_port]['rx']
+ after_tester_send = tester_pkt_count[1][
+ self.tester_send_port]['tx']
if after_tester_send == before_tester_send:
log_msg = 'no change in tx_packets on tester.'
@@ -1125,6 +1132,7 @@ class OpenFlowSw(object):
super(OpenFlowSw, self).__init__()
self.dp = dp
self.logger = logger
+ self.tester_send_port = int(CONF['test-switch']['tester_send_port'])
def send_msg(self, msg):
if isinstance(self.dp, DummyDatapath):
@@ -1229,7 +1237,7 @@ class OpenFlowSw(object):
""" send a PacketOut message."""
ofp = self.dp.ofproto
parser = self.dp.ofproto_parser
- actions = [parser.OFPActionOutput(TESTER_SENDER_PORT)]
+ actions = [parser.OFPActionOutput(self.tester_send_port)]
out = parser.OFPPacketOut(
datapath=self.dp, buffer_id=ofp.OFP_NO_BUFFER,
data=data, in_port=ofp.OFPP_CONTROLLER, actions=actions)
@@ -1290,6 +1298,8 @@ class TestFile(stringify.StringifyMixin):
class Test(stringify.StringifyMixin):
def __init__(self, test_json):
+ self.target_send_port = int(CONF['test-switch']['target_send_port'])
+ self.target_recv_port = int(CONF['test-switch']['target_recv_port'])
super(Test, self).__init__()
(self.description,
self.prerequisite,
@@ -1307,11 +1317,20 @@ class Test(stringify.StringifyMixin):
fields = []
for field in oxm_fields:
field_obj = ofproto.oxm_from_jsondict(field)
- field_obj = ofproto.oxm_normalize_user(*field_obj)
+ field_obj = list(ofproto.oxm_normalize_user(*field_obj))
+ # Override values by the following rules:
+ # in_port == 1 -> target_recv_port
+ # in_port == 2 -> target_send_port
+ # otherwise leave it as-is.
+ if field_obj[0] == 'in_port':
+ if field_obj[1] == 1:
+ field_obj[1] = self.target_recv_port
+ if field_obj[1] == 2:
+ field_obj[1] = self.target_send_port
fields.append(field_obj)
return match.__class__(_ordered_fields=fields)
- def __normalize_action(ofproto, action):
+ def __normalize_action_set_field(ofproto, action):
action_json = action.to_jsondict()
field = action_json['OFPActionSetField']['field']
field_obj = ofproto.oxm_from_jsondict(field)
@@ -1320,6 +1339,21 @@ class Test(stringify.StringifyMixin):
kwargs[field_obj[0]] = field_obj[1]
return action.__class__(**kwargs)
+ def __override_action_output(ofproto, action):
+ action_json = action.to_jsondict()
+ # Override values by the following rules:
+ # port == 1 -> target_recv_port
+ # port == 2 -> target_send_port
+ if action_json['OFPActionOutput']['port'] == 1:
+ action = target_parser.OFPActionOutput(
+ self.target_recv_port,
+ action_json['OFPActionOutput']['max_len'])
+ if action_json['OFPActionOutput']['port'] == 2:
+ action = target_parser.OFPActionOutput(
+ self.target_send_port,
+ action_json['OFPActionOutput']['max_len'])
+ return action
+
# get ofproto modules using user-specified versions
(target_ofproto, target_parser) = ofproto_protocol._versions[
OfTester.target_ver]
@@ -1362,7 +1396,14 @@ class Test(stringify.StringifyMixin):
for act in inst.actions:
if isinstance(
act, target_parser.OFPActionSetField):
- act = __normalize_action(target_ofproto, act)
+ act = __normalize_action_set_field(
+ target_ofproto,
+ act)
+ elif isinstance(
+ act, target_parser.OFPActionOutput):
+ act = __override_action_output(
+ target_ofproto,
+ act)
acts.append(act)
inst = target_parser.OFPInstructionActions(
inst.type, actions=acts)
@@ -1375,7 +1416,13 @@ class Test(stringify.StringifyMixin):
acts = []
for act in bucket.actions:
if isinstance(act, target_parser.OFPActionSetField):
- act = __normalize_action(target_ofproto, act)
+ act = __normalize_action_set_field(
+ target_ofproto,
+ act)
+ if isinstance(act, target_parser.OFPActionOutput):
+ act = __override_action_output(
+ target_ofproto,
+ act)
acts.append(act)
bucket = target_parser.OFPBucket(
weight=bucket.weight,
------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel