News for hackers. Stuff that matters.
Re:Tell HN: IPv6-only still pretty much unusable by theamk on Wednesday December 07, 2022 @04:22PM (#33900483)
OK:

Let's use "IPv4+" scheme as described by redox99: we still have dotted-decimal, and IPv4 addresses are guaranteed to be accessible via IPv4+ interface.

Right now, most application software need non-trivial rewrite to add ipv6 support: it has to support 2 sockets instead of 1, and ":" in address breaks basically every address parsing function out there. With IPv4+, you do search/replace "sockaddr_in"->"sockaddr_in4plus" and AF_INET->AF_INET4PLUS. That's it -- since backward compatibility guaranteed, my software still works on IPv4 system, and hostname parsing is not broken. There might be some minor breakage (unexpected dependencies on struct size or ipv4+ address string length), but it would be way, way smaller than the mess IPv6 is in too.

Right now, I have to set up my firewall twice for ipv4 and ipv6. But with ipv4+? I should be able to write "-m tcp --dport 80 -j ACCEPT" once and have it work with both.

Right now, all the network monitoring tools have to have separate "ipv4" and "ipv6" codepaths. But with ipv4+, there could be only one codepath. Yes, packet parsing will have to handle two different IP header format, but once it's parsed, old and new are treated identically.

Sure, the network layer will be more complex. The IP stack in kernel would need to determine if the address is "short" or "long", and format packets differently (either old or new format). The high-performance routers would need to be rewritten. The TCP/IP network card offload will need to accommodate new format.

But this would be way, way less intrusive than current IPv4->IPv6 transitions, because for each line of low-level network code there are millions of lines of application-level code, and for some totally stupid reason the app code transition was made way harder than needed.

Re:Tell HN: IPv6-only still pretty much unusable by throw0101c on Wednesday December 07, 2022 @05:38PM (#33901366)
> I should be able to write "-m tcp --dport 80 -j ACCEPT" once and have it work with both.

Kind of like how PF does it?

    tcp_services = "{ ssh, smtp, domain, www, pop3, auth, pop3s }"
    udp_services = "{ domain }"
    block all
    pass out proto tcp to any port $tcp_services keep state
    pass proto udp to any port $udp_services keep state
* https://docs.freebsd.org/en/books/handbook/firewalls/#pf-tut...

If an address family ("af") is not specified, the rule applies to both:

     […]

     pf-rule     = action [ ( "in" | "out" ) ]
        [ "log" [ "(" logopts ")"] ] [ "quick" ]
        [ "on" ifspec ] [ route ] [ af ] [ protospec ]
        hosts [ filteropt-list ]

     […]

     af      = "inet" | "inet6"

     […]
* https://www.freebsd.org/cgi/man.cgi?query=pf.conf

    action [direction] [log] [quick] [on interface] [af] [proto protocol]
       [from src_addr [port src_port]] [to dst_addr [port dst_port]]
       [flags tcp_flags] [state]
* https://www.openbsd.org/faq/pf/filter.html#syntax

Perhaps the protocol isn't the problem and you're just using firewall software that doesn't have very good syntax?

Re:Tell HN: IPv6-only still pretty much unusable by sillystuff on Wednesday December 07, 2022 @09:36PM (#33903403)
Similar functionality is provided in nftables for linux ('inet' filter applies to both ipv4 and ipv6). But, outside of the most trivial use cases of just block/allow a port, it doesn't really work out to be that useful because of other restrictions. E.g., if you are collecting IPs that have e.g., created new connections to some set of ports greater than n times within a time period to rate limit them, you are out of luck and will need separate rules for ipv4 and ipv6 since you cannot save a mix of ipv4 and ipv6 addresses to the same list.
Re:Tell HN: IPv6-only still pretty much unusable by bert64 on Wednesday December 07, 2022 @09:51PM (#33903518)
How you represent the address is arbitrary, using a colon instead of a dot matters little as underneath it's just an integer with the only difference being 32 or 128bit.

Using a dot causes its own problems, because it conflicts with DNS. DNS allows fully numeric domain names, but they conflict with legacy ip so are not used on a the public DNS. Using hex would make the problem worse as it's perfectly valid to have an ipv6 address ending "de" for example, which is the TLD for germany.

Legacy addresses can be represented via hex too - try ping 0xdeadbeef.

The socket apis between v6 and legacy ip are largely as compatible as they can be, you need to use sockaddr_in6 and AF_INET6 which is the same as you propose. You can open an AF_INET6 socket and still connect to legacy addresses with it.

For higher level languages that don't deal with fixed size memory structures directly it's pretty much fully compatible, you can just say "connect www.google.com tcp/443" or equivalent, and the system takes care of resolving what protocol and address to connect to.

Re:Tell HN: IPv6-only still pretty much unusable by Plasmoid on Wednesday December 07, 2022 @08:05PM (#33902748)
> Right now, most application software need non-trivial rewrite to add ipv6 support:

That's not right.

If you've been using the platform network libraries for things then IPv6 will just work with anything more recent than Windows XP. Unless you've been hardcoding IP length expectations then there is basically nothing to do.

Seriously, use the platform libraries. They handle all the edge cases and stop storing IP address in a uint32.

Re:Tell HN: IPv6-only still pretty much unusable by theamk on Wednesday December 07, 2022 @09:45PM (#33903472)
Unless you are doing something super trivial, like making http/https requests to pre-defined URLs, your platform libraries will not help you.

Your network servers need two explicit bind() calls for two different protocols, and some logic to select which ones to call, and your main accept() code needs to be able to handle two listening sockets... Theoretically you could create IPv6 socket only and accept both addresses but.. (1) apparently it is disabled on many BSD's by default and (2) even on Linux bind() will fail if you have no IPv6 addresses assigned at all.

Your network client would be better, as there are some libraries which let you connect to ipv4 or ipv6 address, but then IPv6 colon-separated format will trip you. How many clients split on ":" to get port number? Or concatenate (IP, ":", PORT) in the logs / settings? All of those would break.

The really annoying part is that all of these problems were 100% predictable from day 1, and yet someone decided to go ahead with this implementation.

Re:Tell HN: IPv6-only still pretty much unusable by vlovich123 on Wednesday December 07, 2022 @10:35PM (#33903848)
Sorry. What? You’re claiming that the hard part is the parsing of textual ipv6 addresses to binary representation but these same algorithms would work on a hypothetical hand-wavy ipv4+ how? It’s extended so you’ve either got numbers > 255 (breaks parsing routines) or more dots (again breaks parsing routines). Either way you slice it you have to upgrade the parsing routines. And the hard part has not been the parsing routines. And you’d need to justify that what you describe about bound addresses doesn’t apply to a non-existent ipv4+.

It’s getting all the middleware routers, services, and websites to support both that’s been the challenge because it was a chicken and egg. ISPs didn’t want to do it. Websites wouldn’t do it because there were no customers. Carrier grade NATs bought another decade or two. Manufacturers didn’t bother prioritizing the ipv6 stack because carriers weren’t demanding it so HW had very immature and buggy ipv6 stacks which further prohibited ISPs from turning it on because it was another 1-3 purchase cycles before the stack actually worked correctly. And none of that solves the chicken/egg problem of the lack of eyeball supply / customer demand.

The complexity of IPv6 contributed to some of it. Carrier grade NAT did most of the harm though and that would have been a thing regardless.

Re:Tell HN: IPv6-only still pretty much unusable by anyfoo on Wednesday December 07, 2022 @05:14PM (#33901096)
I am not sure why you are downvoted, since you do make some valid points. I myself am not sure whether the very fundamental changes that IPv6 brings did not hamper its adoption than if it was just extended IPv4.

From a network administration perspective, sure, "you need to replace every piece of equipment". But from a software modification perspective (thinking more about the software on network infrastructure equipment than endpoints like applications), you have two very different stacks.

On the other hand, if there was ever a time to make (assumedly so) highly desirable compatibility-breaking changes, that was it.