Summary: | test_dhcp incorrect for big endians | ||
---|---|---|---|
Product: | ModemManager | Reporter: | Dan Horák <dan> |
Component: | plugins | Assignee: | ModemManager bug user <modemmanager> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | medium | CC: | than |
Version: | git master | ||
Hardware: | PowerPC | ||
OS: | All | ||
URL: | https://bugzilla.redhat.com/show_bug.cgi?id=1322696 | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Attachments: | fix the bigendian issue on ppc64/s390 |
Description
Dan Horák
2016-04-01 14:11:50 UTC
Created attachment 122790 [details] [review] fix the bigendian issue on ppc64/s390 Comment on attachment 122790 [details] [review] fix the bigendian issue on ppc64/s390 I was assuming that just some GUINT32_FROM_BE() or GUINT32_FROM_LE() would be enough; those macros already convert from BE/LE to host endian the integer values. Could you check if that approach is easier? attach a better and correct fix for endian issue (s390x/ppc64) diff -up ModemManager-1.5.991/plugins/huawei/mm-modem-helpers-huawei.c.than ModemManager-1.5.991/plugins/huawei/mm-modem-helpers-huawei.c --- ModemManager-1.5.991/plugins/huawei/mm-modem-helpers-huawei.c.than 2016-04-12 14:03:15.519328232 +0200 +++ ModemManager-1.5.991/plugins/huawei/mm-modem-helpers-huawei.c 2016-04-12 13:56:58.978491128 +0200 @@ -190,7 +190,11 @@ match_info_to_ip4_addr (GMatchInfo *matc if (!bin || bin_len != 4) goto done; - *out_addr = GUINT32_TO_BE (*((guint32 *) bin)); +#if __BYTE_ORDER == __BIG_ENDIAN + *out_addr = GUINT32_TO_LE (*((guint32 *) bin)); +#else + *out_addr = GUINT32_TO_BE (*((guint32 *) bin)); +#endif success = TRUE; done: it builds fine with the new patch on all fedora platform: http://ppc.koji.fedoraproject.org/koji/taskinfo?taskID=3296203 http://koji.fedoraproject.org/koji/taskinfo?taskID=13634469 (In reply to than from comment #3) > attach a better and correct fix for endian issue (s390x/ppc64) > > diff -up ModemManager-1.5.991/plugins/huawei/mm-modem-helpers-huawei.c.than > ModemManager-1.5.991/plugins/huawei/mm-modem-helpers-huawei.c > --- ModemManager-1.5.991/plugins/huawei/mm-modem-helpers-huawei.c.than > 2016-04-12 14:03:15.519328232 +0200 > +++ ModemManager-1.5.991/plugins/huawei/mm-modem-helpers-huawei.c > 2016-04-12 13:56:58.978491128 +0200 > @@ -190,7 +190,11 @@ match_info_to_ip4_addr (GMatchInfo *matc > if (!bin || bin_len != 4) > goto done; > > - *out_addr = GUINT32_TO_BE (*((guint32 *) bin)); > +#if __BYTE_ORDER == __BIG_ENDIAN > + *out_addr = GUINT32_TO_LE (*((guint32 *) bin)); > +#else > + *out_addr = GUINT32_TO_BE (*((guint32 *) bin)); > +#endif > success = TRUE; > > done: I don't think there should be any need to check the __BYTE_ORDER explicitly. The original code assumed the hex str came with least significant byte first, so GUINT32_TO_BE () was trying to convert from LE to BE, because inet address are given in BE. The issue, I think, is that we're casting the output of mm_utils_hexstr2bin() directly to a host-endian uint32, which isn't explicitly LE. Can you try this change instead in the BE systems? *out_addr = GUINT32_TO_BE (GUINT32_FROM_LE ((*((guint32 *) bin))));
>
> Can you try this change instead in the BE systems?
>
> *out_addr = GUINT32_TO_BE (GUINT32_FROM_LE ((*((guint32 *) bin))));
Or better, likely:
*out_addr = GUINT32_SWAP_LE_BE ((*((guint32 *) bin)));
(In reply to Aleksander Morgado from comment #6) > > > > Can you try this change instead in the BE systems? > > > > *out_addr = GUINT32_TO_BE (GUINT32_FROM_LE ((*((guint32 *) bin)))); > > Or better, likely: > > *out_addr = GUINT32_SWAP_LE_BE ((*((guint32 *) bin))); yes, you are right, the check is not needed here. GUINT32_SWAP_LE_BE works just fine. diff -up ModemManager-1.5.991/plugins/huawei/mm-modem-helpers-huawei.c.than ModemManager-1.5.991/plugins/huawei/mm-modem-helpers-huawei.c --- ModemManager-1.5.991/plugins/huawei/mm-modem-helpers-huawei.c.than 2016-04-12 08:15:09.866846700 -0400 +++ ModemManager-1.5.991/plugins/huawei/mm-modem-helpers-huawei.c 2016-04-13 05:16:08.341392975 -0400 @@ -190,7 +190,7 @@ match_info_to_ip4_addr (GMatchInfo *matc if (!bin || bin_len != 4) goto done; - *out_addr = GUINT32_TO_BE (*((guint32 *) bin)); + *out_addr = GUINT32_SWAP_LE_BE (*((guint32 *) bin)); success = TRUE; done: (In reply to than from comment #7) > (In reply to Aleksander Morgado from comment #6) > > > > > > Can you try this change instead in the BE systems? > > > > > > *out_addr = GUINT32_TO_BE (GUINT32_FROM_LE ((*((guint32 *) bin)))); > > > > Or better, likely: > > > > *out_addr = GUINT32_SWAP_LE_BE ((*((guint32 *) bin))); > > yes, you are right, the check is not needed here. GUINT32_SWAP_LE_BE works > just fine. > > diff -up ModemManager-1.5.991/plugins/huawei/mm-modem-helpers-huawei.c.than > ModemManager-1.5.991/plugins/huawei/mm-modem-helpers-huawei.c > --- ModemManager-1.5.991/plugins/huawei/mm-modem-helpers-huawei.c.than > 2016-04-12 08:15:09.866846700 -0400 > +++ ModemManager-1.5.991/plugins/huawei/mm-modem-helpers-huawei.c > 2016-04-13 05:16:08.341392975 -0400 > @@ -190,7 +190,7 @@ match_info_to_ip4_addr (GMatchInfo *matc > if (!bin || bin_len != 4) > goto done; > > - *out_addr = GUINT32_TO_BE (*((guint32 *) bin)); > + *out_addr = GUINT32_SWAP_LE_BE (*((guint32 *) bin)); > success = TRUE; > > done: Thanks, pushed to git master. |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.