Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two bugs in simple switch 13 examples #87

Merged
merged 1 commit into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ryu/app/simple_switch_13.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _packet_in_handler(self, ev):
dst = eth.dst
src = eth.src

dpid = datapath.id
dpid = format(datapath.id, "d").zfill(16)
self.mac_to_port.setdefault(dpid, {})

self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port)
Expand Down
8 changes: 4 additions & 4 deletions ryu/app/simple_switch_rest_13.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,21 @@ def __init__(self, req, link, data, **config):
def list_mac_table(self, req, **kwargs):

simple_switch = self.simple_switch_app
dpid = dpid_lib.str_to_dpid(kwargs['dpid'])
dpid = kwargs['dpid']

if dpid not in simple_switch.mac_to_port:
return Response(status=404)

mac_table = simple_switch.mac_to_port.get(dpid, {})
body = json.dumps(mac_table)
return Response(content_type='application/json', body=body)
return Response(content_type='application/json', text=body)

@route('simpleswitch', url, methods=['PUT'],
requirements={'dpid': dpid_lib.DPID_PATTERN})
def put_mac_table(self, req, **kwargs):

simple_switch = self.simple_switch_app
dpid = dpid_lib.str_to_dpid(kwargs['dpid'])
dpid = kwargs['dpid']
try:
new_entry = req.json if req.body else {}
except ValueError:
Expand All @@ -111,6 +111,6 @@ def put_mac_table(self, req, **kwargs):
try:
mac_table = simple_switch.set_mac_to_port(dpid, new_entry)
body = json.dumps(mac_table)
return Response(content_type='application/json', body=body)
return Response(content_type='application/json', text=body)
except Exception as e:
return Response(status=500)