Hi Michal,

Thank you for submitting your patch!
It looks good to me.

BTW, is this problem means that HP switch sends non ascii/utf-8 decodable
characters in OFPMP_PORT_DESC reply messages?
If so, I guess HP switch does not seem to follow the OpenFlow Spec.

The OpenFlow Spec does not say clearly about the "name" field in "struct
ofp_port" though, but about the each field in "struct ofp_desc", the Spec
says clearly like:
---
/* Body of reply to OFPMP_DESC request. Each entry is a NULL-terminated
  * ASCII string. */
struct ofp_desc {
---
Therefore, also the "name" field in OFPMP_PORT_DESC reply should be encoded
as ASCII string for consistence.

This problem seems to be a bug of HP switch for me...
What do you think?

Thanks,
Iwase

On 2016年10月05日 22:56, Michał Rzepka wrote:
> The patch resolves issue experienced when decoding certain values of
> name field in OFPMP_PORT_DESCRIPTION body. Non-decodable bytes are
> replaced with utf-8 replacement character.
>
> This issue was observed while retrieving OFPMP_PORT_DESC reply from
> OpenFlow 1.3 compliant HP switch. One of ofp_struct structures
> describing OFPP_LOCAL port has a name field with value 4f 46 50 50 5f 4c
> 4f 43 41 4c 00 81 ff ff ff ff that translates to OFPP_LOCAL.......
> Attempt to decode the value, as in modified line, raises an exception
> "UnicodeDecodeError: 'utf8' codec can't decode byte 0x81 in position 11:
> invalid start byte". In the submitted patch, non-decodable characters
> are replaced with utf-8 REPLACEMENT CHARACTER (U+FFFD), which is
> sufficient for the get_port_desc method to work seamlessly. Similar
> usages of str.decode method may be found in ofctl_v1_3, ofctl_v1_4,
> ofctl_v1_5 and need to be fixed in the future.
>
> Signed-off-by: Michal Rzepka <[email protected]>
> ---
>   ryu/lib/ofctl_v1_3.py | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git ryu/lib/ofctl_v1_3.py ryu/lib/ofctl_v1_3.py
> index 3cac36d..4744a2e 100644
> --- ryu/lib/ofctl_v1_3.py
> +++ ryu/lib/ofctl_v1_3.py
> @@ -1014,7 +1014,7 @@ def get_port_desc(dp, waiters, to_user=True):
>           stats = msg.body
>           for stat in stats:
>               d = {'hw_addr': stat.hw_addr,
> -                 'name': stat.name.decode('utf-8'),
> +                 'name': stat.name.decode('utf-8', errors='replace'),
>                    'config': stat.config,
>                    'state': stat.state,
>                    'curr': stat.curr,
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to