Merge ~mateus-morais/ubuntu/+source/nvme-stas:nvme-stas-s390x-autopkgtest-failure into ubuntu/+source/nvme-stas:ubuntu/devel

Proposed by Mateus Rodrigues de Morais
Status: Merged
Merge reported by: Mateus Rodrigues de Morais
Merged at revision: 62ae9d566ed18a8b068a5bd9ee6ca33132cd7d23
Proposed branch: ~mateus-morais/ubuntu/+source/nvme-stas:nvme-stas-s390x-autopkgtest-failure
Merge into: ubuntu/+source/nvme-stas:ubuntu/devel
Diff against target: 112 lines (+80/-1)
4 files modified
debian/changelog (+7/-0)
debian/control (+2/-1)
debian/patches/1000-iputil-fix-byte-ordering.patch (+70/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Benjamin Drung (community) Approve
Review via email: mp+450606@code.launchpad.net

Description of the change

Fixes LP: #2026878.

On staslib/iputil.py, all byte-related operations were hardcoded as byteorder='little'. Since s390x is a big-endian architecture, the iputil unit tests were failing and, most likely, iputil itself was not working as expected on this platform.

This merge proposal changes the way byteorder is handled by replacing 'little' with sys.byteorder.

A PPA build is available at [1]. The s390x autopkgtest is now passing, as reported in [2].

[1] https://launchpad.net/~mateus-morais/+archive/ubuntu/nvme-stas-s390x-fix
[2] https://autopkgtest.ubuntu.com/results/autopkgtest-mantic-mateus-morais-nvme-stas-s390x-fix/mantic/s390x/n/nvme-stas/20230904_164958_d28c9@/log.gz

To post a comment you must log in.
Revision history for this message
Benjamin Drung (bdrung) wrote :

Thanks. I took your patch, converted it to a "gbp pq" one and uploaded the fix to Debian unstable as 2.2.2-2.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 9320662..0145627 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+nvme-stas (2.2.2-1ubuntu1) mantic; urgency=medium
7+
8+ * d/p/1000-iputil-fix-byte-ordering.patch: made byteorder architecture-aware
9+ in order to fix s390x autopkgtest failures. (LP: #2026878)
10+
11+ -- Mateus Rodrigues de Morais <mateus.morais@canonical.com> Mon, 04 Sep 2023 11:33:08 -0300
12+
13 nvme-stas (2.2.2-1) sid; urgency=medium
14
15 * Uploading to sid.
16diff --git a/debian/control b/debian/control
17index c26dae6..782f6b3 100644
18--- a/debian/control
19+++ b/debian/control
20@@ -1,7 +1,8 @@
21 Source: nvme-stas
22 Section: net
23 Priority: optional
24-Maintainer: Daniel Baumann <daniel.baumann@progress-linux.org>
25+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
26+XSBC-Original-Maintainer: Daniel Baumann <daniel.baumann@progress-linux.org>
27 Uploaders:
28 Benjamin Drung <bdrung@debian.org>,
29 Build-Depends:
30diff --git a/debian/patches/1000-iputil-fix-byte-ordering.patch b/debian/patches/1000-iputil-fix-byte-ordering.patch
31new file mode 100644
32index 0000000..a7aaeff
33--- /dev/null
34+++ b/debian/patches/1000-iputil-fix-byte-ordering.patch
35@@ -0,0 +1,70 @@
36+Description: Fix byte ordering in iputil operations
37+ Previously, the byte ordering on all byte array operations in iputil were
38+ hard-coded to 'little'. This patch makes the byteorder parameter arch-aware
39+ by using sys.byteorder instead.
40+Author: Mateus Rodrigues de Morais <mateus.morais@canonical.com>
41+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/nvme-stas/+bug/2026878
42+Last-Update: 2023-09-04
43+---
44+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
45+Index: nvme-stas-gu/staslib/iputil.py
46+===================================================================
47+--- nvme-stas-gu.orig/staslib/iputil.py 2023-09-04 11:01:16.238467138 -0300
48++++ nvme-stas-gu/staslib/iputil.py 2023-09-04 11:18:14.286867008 -0300
49+@@ -8,6 +8,7 @@
50+
51+ '''A collection of IP address and network interface utilities'''
52+
53++import sys
54+ import socket
55+ import logging
56+ import ipaddress
57+@@ -27,14 +28,14 @@
58+ GETADDRCMD = (
59+ # BEGIN: struct nlmsghdr
60+ b'\0' * 4 # nlmsg_len (placeholder - actual length calculated below)
61+- + (RTM_GETADDR).to_bytes(2, byteorder='little', signed=False) # nlmsg_type
62+- + (NLM_F_REQUEST | NLM_F_ROOT).to_bytes(2, byteorder='little', signed=False) # nlmsg_flags
63++ + (RTM_GETADDR).to_bytes(2, byteorder=sys.byteorder, signed=False) # nlmsg_type
64++ + (NLM_F_REQUEST | NLM_F_ROOT).to_bytes(2, byteorder=sys.byteorder, signed=False) # nlmsg_flags
65+ + b'\0' * 2 # nlmsg_seq
66+ + b'\0' * 2 # nlmsg_pid
67+ # END: struct nlmsghdr
68+ + b'\0' * 8 # struct ifaddrmsg
69+ )
70+-GETADDRCMD = len(GETADDRCMD).to_bytes(4, byteorder='little') + GETADDRCMD[4:] # nlmsg_len
71++GETADDRCMD = len(GETADDRCMD).to_bytes(4, byteorder=sys.byteorder) + GETADDRCMD[4:] # nlmsg_len
72+
73+
74+ # ******************************************************************************
75+@@ -85,25 +86,25 @@
76+ if nlmsg_idx >= len(nlmsg):
77+ nlmsg += sock.recv(8192)
78+
79+- nlmsg_type = int.from_bytes(nlmsg[nlmsg_idx + 4 : nlmsg_idx + 6], byteorder='little', signed=False)
80++ nlmsg_type = int.from_bytes(nlmsg[nlmsg_idx + 4 : nlmsg_idx + 6], byteorder=sys.byteorder, signed=False)
81+ if nlmsg_type == NLMSG_DONE:
82+ break
83+
84+ if nlmsg_type != RTM_NEWADDR:
85+ break
86+
87+- nlmsg_len = int.from_bytes(nlmsg[nlmsg_idx : nlmsg_idx + 4], byteorder='little', signed=False)
88++ nlmsg_len = int.from_bytes(nlmsg[nlmsg_idx : nlmsg_idx + 4], byteorder=sys.byteorder, signed=False)
89+ if nlmsg_len % 4: # Is msg length not a multiple of 4?
90+ break
91+
92+ ifaddrmsg_indx = nlmsg_idx + NLMSGHDR_SZ
93+ ifa_family = nlmsg[ifaddrmsg_indx]
94+- ifa_index = int.from_bytes(nlmsg[ifaddrmsg_indx + 4 : ifaddrmsg_indx + 8], byteorder='little', signed=False)
95++ ifa_index = int.from_bytes(nlmsg[ifaddrmsg_indx + 4 : ifaddrmsg_indx + 8], byteorder=sys.byteorder, signed=False)
96+
97+ rtattr_indx = ifaddrmsg_indx + IFADDRMSG_SZ
98+ while rtattr_indx < (nlmsg_idx + nlmsg_len):
99+- rta_len = int.from_bytes(nlmsg[rtattr_indx : rtattr_indx + 2], byteorder='little', signed=False)
100+- rta_type = int.from_bytes(nlmsg[rtattr_indx + 2 : rtattr_indx + 4], byteorder='little', signed=False)
101++ rta_len = int.from_bytes(nlmsg[rtattr_indx : rtattr_indx + 2], byteorder=sys.byteorder, signed=False)
102++ rta_type = int.from_bytes(nlmsg[rtattr_indx + 2 : rtattr_indx + 4], byteorder=sys.byteorder, signed=False)
103+ if rta_type == IFLA_ADDRESS:
104+ data = nlmsg[rtattr_indx + RTATTR_SZ : rtattr_indx + rta_len]
105+ if _data_matches_ip(ifa_family, data, src_addr):
106diff --git a/debian/patches/series b/debian/patches/series
107new file mode 100644
108index 0000000..245d0d2
109--- /dev/null
110+++ b/debian/patches/series
111@@ -0,0 +1 @@
112+1000-iputil-fix-byte-ordering.patch

Subscribers

People subscribed via source and target branches