From 36f8f4b91d13c590050412aa586a41c16d4f0c1b Mon Sep 17 00:00:00 2001 From: Melvin Walls Date: Tue, 21 Mar 2017 13:36:11 -0700 Subject: [PATCH] avoid creating ports twice --- generator/generator_commands.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/generator/generator_commands.py b/generator/generator_commands.py index 7c0fdfe..fbbe7e1 100644 --- a/generator/generator_commands.py +++ b/generator/generator_commands.py @@ -383,7 +383,7 @@ def get_all_stats(cli, sess, port): for port in ports: sess = cli.get_session(port) last[port] = get_all_stats(cli, sess, port) - print(port, last[port]) + try: while True: time.sleep(1) @@ -509,10 +509,13 @@ def start(cli, tx_port, rx_port, mode, spec): tx_port_args['driver'], tx_port_args['name'], arg=tx_port_args['arg']) tx_port = ret.name - ret = cli.bess.create_port( - rx_port_args['driver'], rx_port_args['name'], - arg=rx_port_args['arg']) - rx_port = ret.name + if rx_port != tx_port: + ret = cli.bess.create_port( + rx_port_args['driver'], rx_port_args['name'], + arg=rx_port_args['arg']) + rx_port = ret.name + else: + rx_port = tx_port if spec is not None and 'src_mac' not in spec: spec['src_mac'] = ret.mac_addr