You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If this method is called with a dpid value of hex(2) # == '0x2, then the validation (on line 883) will work because int('0x2', 16) == 2.
But in the end, the value returned will be '00000000000000x2' (assuming a dpidLen == 16) which cannot be converted to an integer. When the switch is started it will crash on line 1170 with:
ValueError: invalid literal for int() with base 16: '00000000000000x2'
This weird dpid of '00000000000000x2' comes from the mininet.net.node.Switch.defaultDpid method which insert zeroes in front of a valid hex number but fails to consider the 0x prefix.
You seem to be misunderstanding the API, which requires a string of hex digits, not a python integer in string form. But I agree that python isn't quite validating the argument as might be expected.
I've changed the title to perhaps more accurately reflect what you are requesting, though I'm not 100% sure.
changed the title [-]Improper handling of integer base prefix in dpid[/-][+]Feature request: accept arbitrary-based python numeric strings (or possibly ints) as DPID argument[/+]on Nov 13, 2016
Ok I misunderstood the fact that only hex digits should be used. The doc says dpid: dpid hex string (or None to derive from name, e.g. s1 -> 1).
I agree that from a semantic point of view this may break. On the other hand I would also assume that people may use the builtin hex function to get a hex string and it would be nice to handle those cases.
Note that the solution above should not break any existing behaviour, so deadbeef would still be a valid dpid.
Activity
0xjac commentedon Nov 13, 2016
I am happy to submit a PR with the fix if you agree with my suggestion.
lantz commentedon Nov 13, 2016
You seem to be misunderstanding the API, which requires a string of hex digits, not a python integer in string form. But I agree that python isn't quite validating the argument as might be expected.
I've changed the title to perhaps more accurately reflect what you are requesting, though I'm not 100% sure.
[-]Improper handling of integer base prefix in dpid[/-][+]Feature request: accept arbitrary-based python numeric strings (or possibly ints) as DPID argument[/+][-]Feature request: accept arbitrary-based python numeric strings (or possibly ints) as DPID argument[/-][+]Feature request: accept arbitrary-based python numeric strings (or possibly ints?) as DPID argument[/+]0xjac commentedon Nov 13, 2016
Ok I misunderstood the fact that only hex digits should be used. The doc says
dpid: dpid hex string (or None to derive from name, e.g. s1 -> 1).I agree that from a semantic point of view this may break. On the other hand I would also assume that people may use the builtin
hexfunction to get a hex string and it would be nice to handle those cases.Note that the solution above should not break any existing behaviour, so
deadbeefwould still be a valid dpid.[-]Feature request: accept arbitrary-based python numeric strings (or possibly ints?) as DPID argument[/-][+]Fix argument DPID argument validation and/or allow arbitrary-based python numeric strings[/+][-]Fix argument DPID argument validation and/or allow arbitrary-based python numeric strings[/-][+]Fix DPID hex string validation and/or allow arbitrary-based python numeric strings[/+]lantz commentedon Nov 13, 2016
I think this is probably OK, though I'm not quite sure it's exactly the right way to do it.
[-]Fix DPID hex string validation and/or allow arbitrary-based python numeric strings[/-][+]Fix DPID hex string validation and/or allow python hex() strings[/+][-]Fix DPID hex string validation and/or allow python hex() strings[/-][+]Fix DPID hex string validation and/or allow python `hex()` strings[/+][-]Fix DPID hex string validation and/or allow python `hex()` strings[/-][+]Fix DPID hex string validation and/or allow python hex() strings[/+]