News for hackers. Stuff that matters.
Re:Potholes to avoid when migrating to IPv6 by swinglock on Monday December 31, 2018 @04:51AM (#18793860)
The problem was (and remained) programmers thinking addresses are strings.
Re:Potholes to avoid when migrating to IPv6 by ztorkelson on Monday December 31, 2018 @11:32AM (#18795287)
Right. I was waiting for the author to get to this point, and much to my surprise they never did.

The takeaway shouldn’t be “strings are hard”. Strings are hard, but that’s not the problem here. The problem is using inappropriate data types for the task at hand, and the takeaway should be that representation matters.

Representing an IP endpoint as a string only really makes sense at the human-computer interface. In general, the first thing a program should do with such a string is convert it into a more suitable data type. And as noted elsewhere, more often than not there will already be a library function to do so.

Strings are especially pernicious because they are ubiquitous, in that just about anything can be represented as a string, but the operations one can do on a string representation of an object do not generally correspond with the operations one would want to do on the object itself. This disparity is the source of many bugs, which the article exemplifies (though falls short of directly addressing).

Similarly problematic are assumptions that converting an object to a string and a string to an object (i.e. `parse` and `format` functions) are bijective. This is not generally the case. (Wise practitioners might choose such a mapping, though, when the opportunity presents.)

Re:Potholes to avoid when migrating to IPv6 by jsjohnst on Monday December 31, 2018 @09:45AM (#18794668)
I actually prefer them as integers personally. 4 bytes for IPv4, 16 bytes for IPv6, is more space efficient than any string representation usually.
Re:Potholes to avoid when migrating to IPv6 by rkeene2 on Monday December 31, 2018 @12:17PM (#18795559)
16 bytes isn't always enough to store an IPv6 address. Depending on the requirements, you may need to store a fully scoped IPv6 address, such as fe80::1%eth0.

Edit to note: I store the fully scoped IPv6 address in a database as part of my CMDB mechanism.

Re:Potholes to avoid when migrating to IPv6 by jsjohnst on Monday December 31, 2018 @01:36PM (#18796102)
Just curious, but what use do you have for storing link-local addresses?
Re:Potholes to avoid when migrating to IPv6 by alanfranzoni on Monday December 31, 2018 @07:58AM (#18794300)
This. The proper approach is to normalize/deduplicate on ip objects that understand ipv6 domain logic. Then most issues just go away.
Re:Potholes to avoid when migrating to IPv6 by rhacker on Monday December 31, 2018 @01:06PM (#18795913)
They are strings, sometimes, and that is what this article is about. Another non-obvious fix to this issue is to start using DNS. (Well obvious to some)