Page MenuHomeFreeBSD

Use IN_foo() macros from sys/netinet/in.h inplace of handcrafted code
ClosedPublic

Authored by rgrimes on Feb 24 2019, 5:36 AM.
Tags
None
Referenced Files
F103275174: D19317.diff
Fri, Nov 22, 10:56 PM
Unknown Object (File)
Thu, Nov 21, 6:45 AM
Unknown Object (File)
Sat, Nov 16, 8:49 PM
Unknown Object (File)
Sat, Nov 16, 8:43 PM
Unknown Object (File)
Sat, Nov 16, 7:08 PM
Unknown Object (File)
Tue, Nov 5, 2:48 PM
Unknown Object (File)
Sun, Nov 3, 12:09 PM
Unknown Object (File)
Wed, Oct 30, 7:24 AM

Details

Summary

There are a few places that use hand crafted versions of the macros from sys/netinet/in.h making it difficult to actually alter the values in use by these macros.

Correct that by replacing handcrafted code with proper macro usage.

Test Plan

An external document shall be referenced in the future describing the testing being done.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Add some more places that hand crafted macros are used, ip_input, ip_output, netdump code.

sys/netpfil/ipfw/nat64/nat64_translate.h
117

Do you intend to commit this comment, or to follow up on it? Sure looks like everything is in network byte order, might as well just fix it.

The pf bit is good.
Everything else looks good to me as well, modulo the remark karels had about the XXX comment.

Convert nat64_check_ip4 in sys/netpfil/ipfw/nat64/nat64_translate.h to use IN_foo macros rather than hand rolled code.

rgrimes added inline comments.
sys/netinet/in.c
196

Since we already block IN_LOOPBACK in ip_input and ip_output it seems to me that we could remove IN_LOOPBACK from here and save a few cycles in the forwarding fast path.

sys/netpfil/ipfw/nat64/nat64_translate.h
117

I intend to fix it, this is WIP. But I also need some feedback before I go make a 1000 line diff, I have just done the critical stuff in the kernel that makes it even possible to transport packets when you alter the macro's values.

Can I get some final accept on this, I updated the open issues

Although I have a couple of inline comments, I wouldn't object to committing this as-is. Touching up would be fine too.

sys/netinet/in.c
196

I could go either way on that. I don't mind having the test here, so it doesn't depend on the details elsewhere.

sys/netinet/ip_output.c
597

This comment is probably not accurate with this change. RFC1122 at least implies 127/8, as Class A is implied. It wouldn't be bad to return the previous comment, but also say that we relax the requirement to include just the standard loopback address itself. An aside, I just checked a recent Ubuntu; I can ping any address on 127/8 successfully except 127.255.255.255. At least it doesn't forward those to itself.

This revision is now accepted and ready to land.Mar 19 2019, 6:34 AM
This revision was automatically updated to reflect the committed changes.