NetworkManager DBus API exposes IPv4 addresses as UINT32s. It's unfortunate that these are in the API as u instead of ay. However that probably can't be changed now. It's doubly unfortunate that these are in "network byte order". DBus types like UINT32 can get swapped when communicating between machines of different architectures. This puts makes them show up backwards in memory. The same thing happens when they are treated as integers (they are DBus type 'u' after all), by applications like Cockpit. A caller like Cockpit looking at such an integer has no way to interpret the contents of a number like 84650176 ... 0x050ba8c0 ... which is a little endian view of version of 192.168.11.5 stored in network byte order. I would suggest exposing an byte order flag in the NetworkManager API by which these could be rearranged.
I guess callers can also look at the byte order of the DBus message ... although in many bindings they don't have access to that :S
Is it just an inconvenience or a real problem? Do you send D-Bus over network between opposite endian machines? I think D-Bus libraries should handle that. The addresses are documented to be in network-byte order (which is big endian). So any client using the addresses should not have problems converting them to host endianess. Examples: http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/python/dbus/add-connection.py http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/python/gi/get_ips.py http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/ruby/add-connection.rb I remember discussing the issue back in 2009. But at that time we stored the addresses as integers in config files. Thus the issue was only when you took the file and transferred it to dirrerent endian-order machine. It is not the case any longer because addresses are written to configuration files as strings now. https://bugzilla.gnome.org/show_bug.cgi?id=566663
(In reply to Jirka Klimes from comment #2) > Is it just an inconvenience or a real problem? > Do you send D-Bus over network between opposite endian machines? I think > D-Bus libraries should handle that. > > The addresses are documented to be in network-byte order (which is big > endian). So any client using the addresses should not have problems > converting them to host endianess. When they arrive at the other machine they are no longer in network-byte order. DBus automatically switches the order. The integer arrives at the other end not in network-byte order (ie: not as documented). > I remember discussing the issue back in 2009. But at that time we stored the > addresses as integers in config files. Thus the issue was only when you took > the file and transferred it to dirrerent endian-order machine. It is not the > case any longer because addresses are written to configuration files as > strings now. This is the same issue resurfacing in a different form.
> Is it just an inconvenience or a real problem? It is a inconvenience, but it is also a bad API, I'd say, which should be reason enough to fix it also for local clients. The inconvenience comes from the fact that the client needs to know the byteorder of the NetworkManager daemon process in order to do the required ntol call correctly. We currently use a side-channel for that, but it is, well, inconvenient. Getting that information from NM directly would be a little less inconvenient, but the API would still be bad, IMO. To improve the API, NM could deprecate the current properties and export new properties as ay, (yyyy), or even u but pass the number through ntohl. Saying that a uint32 number X is in network byteorder doesn't make sense. If anything this should be reworded in the docs. What the POSIX APIs says is that A = (unsigned char *)&X is an array of four bytes which can be turned into the right 32 bit number by interpreting it in big endian. I think the API should either expose a unsigned char[4] field or do the conversion before returning. Well, that train has sailed. If NM transfers those four bytes A[0], A[1], A[3], A[4] then the client knows that A[0] corresponds to the 'a' in 'a.b.c.d', always. If NM applies Y = ntohl(X) and sends out Y, then the client knows that (Y >> 24) corresponds to 'a', always. But what NM does is to interpret the four bytes in its own native endianess and the sends out that number. Thus X >> 24 might either be A[0] or A[3], depending on the native endianess. The client needs to know that endianess, or hope that it is the same as its own.
This package has changed ownership in the Fedora Package Database. Reassigning to the new owner of this component.
This message is a reminder that Fedora 21 is nearing its end of life. Approximately 4 (four) weeks from now Fedora will stop maintaining and issuing updates for Fedora 21. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '21'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 21 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
Fedora 21 changed to end-of-life (EOL) status on 2015-12-01. Fedora 21 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of Fedora please feel free to reopen this bug against that version. If you are unable to reopen this bug, please file a new report against the current release. If you experience problems, please add a comment to this bug. Thank you for reporting this bug and we are sorry it could not be fixed.
Just to nitpick on the cause issue... > But what NM does is to interpret the four bytes in its own native endianess > and the sends out that number. That seems not accurate to me. NM recieves IPv4 addresses in network-order, exposes them on D-Bus in network-order, and local(!) clients handle it in network-order. That works all very well, as long as you use D-Bus only locally -- which is how it's done usually. I give you, there is a very valid usecase to expose D-Bus over the network. That would require such a bridge to correct for endianness: meaning, for regular integers they have to be swapped, while IPv4 addresses (and other numbers in network-order), must be taken as is and accepted on the receiver side as-is. Of course, such a generic bridge wouldn't know when to swap and when not. It's only integers after all: <property name="DnsPriority" type="i" access="read"/> vs. <property name="Addresses" type="aau" access="read"/> That is, it is not visible via D-Bus introspection that the number is supposed to be in network-order or host order. One could imagine a special format identifier to encode integers as such, contrary to "u" which is in host-order. Which of course doesn't exist, because D-Bus is designed as a local protocol mostly. Anyway, I agree with this bug. The only solution here is to deprecate the old properties and add new properties that get it right (while preserving backward compatibility, like done for "addresses" vs. "address-data". Reopening
Agree. To once again put it succinctly: "The byte ordering issues here assume callers are on the same machine as NetworkManager itself" This is not the case with Cockpit (or several other ways of remoting DBus).
This bug is currently reported against a Fedora version which is already unsuported. I am changing the version to '27', the latest supported release. Please check whether this bug is still an issue on the '27' release. If you find this bug not being applicable on this release, please close it.
with https://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=60f9be4e14e81b45ec12b5de608ccda93244c148 , all properties that suffer from this issue are deprecated (and possibly have a replacement property that does not have the problem). > I would suggest exposing an byte order flag in the NetworkManager API by which > these could be rearranged. This was not done, because new clients should not bother about the deprecated properties. And it would anyway require a new client to consider the byte-order hint. I am closing this as UPSTREAM. The fix will reach Fedora with the next stable release of NetworkManager (1.14.0).