Page MenuHomeFreeBSD

rwhod: IPv6 clean
Needs ReviewPublic

Authored by bses30074_gmail.com on Wed, May 8, 1:38 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 17, 11:08 AM
Unknown Object (File)
Tue, May 14, 2:56 PM
Unknown Object (File)
Sat, May 11, 8:00 AM
Unknown Object (File)
Sat, May 11, 7:58 AM
Unknown Object (File)
Sat, May 11, 2:48 AM
Unknown Object (File)
Thu, May 9, 5:04 PM
Subscribers

Details

Reviewers
hrs
lwhsu

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 57748
Build 54636: arc lint + arc unit

Event Timeline

I tested the IPv6-only machine and found no errors affecting it. Here are some methods I employed to ensure IPv6 cleanliness:

  1. I added an IPv6 multicast link-local address to simulate broadcast.
  2. Utilized sockaddr_storage to represent the multicast address, making it compatible with both IPv4 and IPv6.
  3. Replaced the use of getservbyname with getaddrinfo for address resolution.
  4. Employed getnameinfo to retrieve the port string instead of relying on getservbyname.

However, there are instances where I still used switch case statements:

  1. I resorted to switch case statements for setsockopt as IPv4 and IPv6 have different options, and I couldn't find a function to handle this divergence effectively.
  2. Similarly, I employed switch case statements for setting multicast addresses.

While I understand that using switch case statements is generally not recommended, in the mentioned instances, it seemed like the most suitable solution. If there's an alternative approach you know of, I'm open to suggestions.

Regarding your question about the for loop iterating over the return list from getaddrinfo: I currently only create a socket and bind it to the first address encountered in the list if it succeeds. Is this approach advisable, or should I prioritize binding IPv6 addresses first?

What do you do if neither INET nor INET6 are defined? In a lot of cases, it looks like you fail. Likewise for when you don't have the right address family compiled in.

In D45124#1029225, @imp wrote:

What do you do if neither INET nor INET6 are defined? In a lot of cases, it looks like you fail. Likewise when you don't have the right address family compiled in.

Ah, that's unexpected. However, is there a chance that INET and INET6 might not be defined? This scenario suggests that users aren't seeking to disable all network functions (WITHOUT_INET and WITHOUT_INET6 defined), which essentially implies they can't use the rwhod command.

Alternatively, should I set INET as the default if INET and INET6 are undefined? Or print some info when both are not defined? I've examined some clean IPv6 examples (like syslog and ifmcstat), and it appears they don't implement any special procedures. If there's a better approach to revising this, please advise.

Addressed IPv6 and formatting issues