]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
IPv4: fix redirect sending conditions
authorBjoern A. Zeeb <bz@FreeBSD.org>
Sun, 26 Dec 2021 15:33:48 +0000 (15:33 +0000)
committerBjoern A. Zeeb <bz@FreeBSD.org>
Wed, 29 Dec 2021 10:52:52 +0000 (10:52 +0000)
commita7e7700fa741d64a31e9d7596175fc0461687b86
treeec640bac53e9d767e6342339416c4b12c71ac06d
parent5143c53dfb289d17a796afdd1c3d38d71356533e
IPv4: fix redirect sending conditions

RFC792,1009,1122 state the original conditions for sending a redirect.
RFC1812 further refine these.
ip_forward() still sepcifies the checks originally implemented for these
(we do slightly more/different than suggested as makes sense).
The implementation added in 8ad114c082a159c0dde95aa35d2e3e108aa30a75
to ip_tryforward() however is flawed and may send a "multi-hop"
redirects (to a host not on the directly connected network).

Do proper checks in ip_tryforward() to stop us from sending redirects
in situations we may not.  Keep as much logic out of ip_tryforward()
and in ip_redir_alloc() and only do the mbuf copy once we are sure we
will send a redirect.

While here enhance and fix comments as to which conditions are handled
for sending redirects in various places.

Reported by: pi (on net@ 2021-12-04)
Sponsored by: Dr.-Ing. Nepustil & Co. GmbH
Reviewed by: cy, others (earlier versions)
Differential Revision: https://reviews.freebsd.org/D33274

(cherry picked from commit f389439f50fc4c27d15d3017b622270e25ba71c7)
sys/netinet/ip_fastfwd.c
sys/netinet/ip_input.c