]> git.ipfire.org Git - thirdparty/FORT-validator.git/commit
RTR server bind review
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Thu, 8 Feb 2024 21:29:35 +0000 (15:29 -0600)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Thu, 8 Feb 2024 21:50:36 +0000 (15:50 -0600)
commit202e0fe34dc3c8dcb1a0ad12faa7f4d5a7c91b2d
tree87be01dd08b7ec220de1b8818dee57d6a702f3b7
parent94a83715c2ed483d65cec6a76f258d830a6991fa
RTR server bind review

- Hint SOCK_STREAM on getaddrinfo(), not on socket().
  I guess this means it was attempting some redundant binds on failure?
- Print the "Attempting to bind socket to address '%s', port '%s'"
  message in every addrinfo, not just the first one. (Improves log
  legibility.)
- Improve the algorithm that produces the printable version of the
  address (used to dereference ai_addr->sa_data like the previous
  commit), and fall back to whatever the user provided if it fails.
- Weird inconsistency: Most errors used to cause create_server_socket()
  to try the next addrinfo candidate, but getsockname() and listen()
  induced immediate abortion. I've no idea what that was about;
  getsockname() isn't even a mandatory step.
- Attempt to bind all addrinfo candidates; they must all succeed.
  (It used to stop on the first success.)

I'm conflicted with the last point. The old behavior appears to have
been inherited from the Linux manual page example, but doesn't make any
sense from where I'm standing.

If `/etc/hosts` defines

127.0.0.1    localhost
::1          localhost

And server.address is "localhost", shouldn't we attempt to bind to both
addresses?
src/rtr/rtr.c
src/types/address.c
src/types/address.h