Working on getting IPv6 support to client tools I find interesting problem:

As part of hardware information we send this record:
  class: NETINFO
  hostname: some.fqdn.com
  ipaddr: 1.2.3.4

I enhanced it to send new item ip6addr. So the structure now looks like:
  class: NETINFO
  hostname: some.fqdn.com
  ipaddr: 1.2.3.4
  ip6addr: dead:beaf:cafe::1

The ip address is get by this logic:
 s = socket.socket(family)
 s.connect((server, port))
 intf = s.getsockname()[0]
where server is rhnParent (i.e. Spacewalk server). This is wrapped by try/except and if error pop up. Then 127.0.0.1 or ::1 address is used.

This was fine when we supported IPv4 only connection. You either connect to rhnParent or not.

But with IPv6 in game I discovered interesting use case:
Client has both IPv4 and IPv6 address, but Spacewalk server only IPv4.
So the logic above will succeed only for IPv6 and for IPv4 it will fail and loopback address will be used. And the record will be:
  class: NETINFO
  hostname: some.fqdn.com
  ipaddr: 127.0.0.1
  ip6addr: dead:beaf:cafe::1
But that is incorrect. As the machine *has* public IPv4 address. It is "just" unroutable between this machine and rhnParent.

So I would like to ask you question:
* Should I leave it as it is (least risc that something will broke up, but not 100% correct) * If connect to rhnParent fail, should I get addr different way (getaddrbyhostname())? (but we use this addr to do some things, and it may broke).
* or something else?

I like the option one, but I thought that I would share this with you and give you chance for feedback.

Mirek

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to