freebsd-dev/sys/netinet6
Doug Rabson 5ab151574c netinet*: Fix redirects for connections from localhost
Redirect rules use PFIL_IN and PFIL_OUT events to allow packet filter
rules to change the destination address and port for a connection.
Typically, the rule triggers on an input event when a packet is received
by a router and the destination address and/or port is changed to
implement the redirect. When a reply packet on this connection is output
to the network, the rule triggers again, reversing the modification.

When the connection is initiated on the same host as the packet filter,
it is initially output via lo0 which queues it for input processing.
This causes an input event on the lo0 interface, allowing redirect
processing to rewrite the destination and create state for the
connection. However, when the reply is received, no corresponding output
event is generated; instead, the packet is delivered to the higher level
protocol (e.g. tcp or udp) without reversing the redirect, the reply is
not matched to the connection and the packet is dropped (for tcp, a
connection reset is also sent).

This commit fixes the problem by adding a second packet filter call in
the input path. The second call happens right before the handoff to
higher level processing and provides the missing output event to allow
the redirect's reply processing to perform its rewrite. This extra
processing is disabled by default and can be enabled using pfilctl:

	pfilctl link -o pf:default-out inet-local
	pfilctl link -o pf:default-out6 inet6-local

PR:		268717
Reviewed-by:	kp, melifaro
MFC-after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D40256
2023-05-31 11:11:05 +01:00
..
dest6.c
frag6.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
icmp6.c netinet: Disallow unspecified addresses in ICMP-embedded packets 2023-03-13 10:45:56 -04:00
icmp6.h
in6_cksum.c
in6_fib_algo.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
in6_fib.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
in6_fib.h
in6_gif.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
in6_ifattach.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
in6_ifattach.h
in6_jail.c jail: convert several functions from int to bool 2023-03-14 21:05:33 -06:00
in6_mcast.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
in6_pcb.c inpcb: Restore missing validation of local addresses for jailed sockets 2023-05-30 15:15:48 -04:00
in6_pcb.h inpcb: Avoid inp_cred dereferences in SMR-protected lookup 2023-04-20 12:13:06 -04:00
in6_proto.c ipv6: disable RFC 4620 nodeinfo by default 2023-04-26 13:47:59 -04:00
in6_rmx.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
in6_rss.c Revert "wpa: Import wpa_supplicant/hostapd commit 14ab4a816" 2021-12-02 14:45:04 -08:00
in6_rss.h
in6_src.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
in6_var.h IfAPI: Hide the in6m_lookup_locked() implementation. 2023-01-31 15:02:14 -05:00
in6.c inet6: protect address manipulation with a lock 2023-03-30 08:46:38 +00:00
in6.h netinet: Remove the IP(V6)_RSS_LISTEN_BUCKET socket option 2023-02-28 15:57:21 -05:00
ip6_ecn.h
ip6_fastfwd.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
ip6_forward.c routing: plug mbuf leak for the packets hitting IPv6 blackhole route 2023-05-17 09:06:04 +00:00
ip6_gre.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
ip6_id.c
ip6_input.c netinet*: Fix redirects for connections from localhost 2023-05-31 11:11:05 +01:00
ip6_mroute.c net.inet6.ip6.log_interval: use ppsratecheck(9) internally 2023-03-13 16:47:06 +00:00
ip6_mroute.h
ip6_output.c netinet: Remove the IP(V6)_RSS_LISTEN_BUCKET socket option 2023-02-28 15:57:21 -05:00
ip6_var.h netinet*: Fix redirects for connections from localhost 2023-05-31 11:11:05 +01:00
ip6.h
ip_fw_nat64.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
ip_fw_nptv6.h
mld6_var.h mld6: use callout(9) directly instead of pr_slowtimo, pr_fasttimo 2022-08-17 11:50:31 -07:00
mld6.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
mld6.h
nd6_nbr.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
nd6_rtr.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
nd6.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
nd6.h IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
pim6_var.h
pim6.h
raw_ip6.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
raw_ip6.h
route6.c
scope6_var.h
scope6.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
sctp6_usrreq.c sctp: minor changes due to upstreaming of Glebs recent changes 2022-11-06 23:06:40 +01:00
sctp6_var.h sctp: minor changes due to upstreaming of Glebs recent changes 2022-11-06 23:06:40 +01:00
send.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
send.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
tcp6_var.h netinet*: de-void control input IP protocol methods 2022-10-03 20:53:04 -07:00
udp6_usrreq.c udp: Fix a memory leak in udp6_send() 2023-03-14 11:58:02 -04:00
udp6_var.h netinet*: de-void control input IP protocol methods 2022-10-03 20:53:04 -07:00