News for hackers. Stuff that matters.
Re:The trouble with struct sockaddr's fake flexible array by asveikau on Friday November 29, 2024 @10:44AM (#42274604)
> sock = inet_connect(SOCK_STREAM, “google.com”, 443, NULL, &err);

You just added a DNS lookup to connect(2).

Also, you linked socket creation to all of this. This would make it hard to do an asynchronous version. Today you can create a socket and do a non-blocking connect(2) (after doing your asynchronous DNS lookup)

Lastly, I think if you tasked someone with creating that API, they would probably use the old APIs to build it ...

Re:The trouble with struct sockaddr's fake flexible array by ape4 on Friday November 29, 2024 @11:13AM (#42274814)
That second parameter could accept a text IP-address eg "192.168.100.100". Like the address bar of a browser.
Re:The trouble with struct sockaddr's fake flexible array by braiamp on Friday November 29, 2024 @11:52AM (#42275109)
So, the dns lookup is still there, it's just optional. You would have to pass a flag to tell it not to try to do the lookup or you would have to do something fancy trying to know if the passed parameter is an IP.
Re:The trouble with struct sockaddr's fake flexible array by asveikau on Friday November 29, 2024 @11:54AM (#42275126)
This is already how all the DNS lookup APIs work.
Re:The trouble with struct sockaddr's fake flexible array by tptacek on Friday November 29, 2024 @03:36PM (#42276891)
The problem is with asking the kernel to perform dns lookups.
Re:The trouble with struct sockaddr's fake flexible array by GauntletWizard on Friday November 29, 2024 @05:57PM (#42277871)
If SystemD had it's way, it would. The local system resolver cache is the default on most systems. DNS is well understood. Why not put it in the Kernel?

If you're doing that, though, you'd better dang well give me secure key storage in the Kernel, too, or full TLS capability. Allow my program to n load it's RSA/ECC key at startup, then drop privileges to access that file, and have a kernel module handle the cryptography.

Re:The trouble with struct sockaddr's fake flexible array by tptacek on Friday November 29, 2024 @07:02PM (#42278260)
It extremely doesn't make sense to have a DNS resolver resident in the kernel: DNS resolution is policy-intensive, involves various upgrades to cryptographic transports, and often requires debugging, all weak points of the kernel. Against all that, there's no performance advantage, and doing it admits a new networking API that almost no applications will use --- most new code being written in higher-level languages that already abstract over system calls.
Re:The trouble with struct sockaddr's fake flexible array by GauntletWizard on Friday November 29, 2024 @10:58PM (#42279277)
There's a huge performance advantage, if you ask SystemD - Multiple resolutions can be cached. This is incredible bullshit, of course, but that is one of many lies Pottering has gotten away with.
Re:The trouble with struct sockaddr's fake flexible array by toast0 on Saturday November 30, 2024 @07:22PM (#42285097)
Caching resolutions can be a nice thing, and having in one place can be useful so that the throwing away the cache can be done consistently for all apps when useful (you likely should clear the cache when switching networks, or when the user asks you to), but none of that means it should be a kernel service.

If there's enough volume of requests that a kernel level cache meaningfully improves real world scenarios, something is broken in those scenarios. :p (but I think you agree with me)

Re:The trouble with struct sockaddr's fake flexible array by jandrese on Sunday December 01, 2024 @08:54PM (#42292356)
How often do you not want to support host lookup when doing a TCP or UDP connection?

Certainly you could implement these functions using the existing BSD socket libraries, but that misses out on having them used everywhere so you get "free" IPv6 transitions and whatnot.