ipfilter: Avoid more null if-then-else blocks
As in 73db3b64f167, when WITHOUT_INET6 is selected, null if-then-else
blocks are generated because #if statements are incorrectly placed.
Moving the #if statements reduces unnecessary runtime comparisons or
compiler optimizations.
(cherry picked from commit 130df64793d7d3c680c0f7177a707867a8a19665)