Page MenuHomeFreeBSD

Fix ipfw fwd that doesn't work in some cases
ClosedPublic

Authored by ae on Apr 1 2022, 1:52 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 3:08 PM
Unknown Object (File)
Tue, Apr 9, 2:31 PM
Unknown Object (File)
Sun, Mar 31, 12:28 PM
Unknown Object (File)
Mar 10 2024, 12:51 AM
Unknown Object (File)
Feb 27 2024, 1:21 AM
Unknown Object (File)
Feb 17 2024, 9:27 AM
Unknown Object (File)
Jan 29 2024, 6:40 PM
Unknown Object (File)
Dec 23 2023, 1:01 AM

Details

Summary

We need to use destination address stored in dst variable instead of IP header when doing route lookup.
Thus correct address will be used when PACKET_TAG_IPFORWARD is set by ipfw.

This code path is used when ip_output is called with NULL route pointer, in this case ro == &iproute and dst is initialized as ip->ip_dst. After ip_output_pfil dst value can be changed to the address from fwd_tag, but IP header keeps unchanged, thus we need to use dst variable in fib4_lookup.

IPv6 code is a bit different and patch seems hackish.
Probably we should just move block to be before again: label

if (ro == NULL || ro->ro_nh == NULL) {
        bzero(dst, sizeof(*dst));
        dst->sin6_family = AF_INET6;
        dst->sin6_len = sizeof(*dst);
        dst->sin6_addr = ip6->ip6_dst;
}

Regression was introduced in D19804 and D23886.

PR: 256828, 261697, 255705

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable