opnsense-src/sys/netinet
Kristof Provost 680ad06f90 mroute: avoid calling if_allmulti with the lock held
Avoid locking issues when if_allmulti() calls the driver's if_ioctl,
because that may acquire sleepable locks (while we hold a non-sleepable
rwlock).

Fortunately there's no pressing need to hold the mroute lock while we
do this, so we can postpone the call slightly, until after we've
released the lock.

This avoids the following WITNESS warning (with iflib drivers):

	lock order reversal: (sleepable after non-sleepable)
	 1st 0xffffffff82f64960 IPv4 multicast forwarding (IPv4 multicast forwarding, rw) @ /usr/src/sys/netinet/ip_mroute.c:1050
	 2nd 0xfffff8000480f180 iflib ctx lock (iflib ctx lock, sx) @ /usr/src/sys/net/iflib.c:4525
	lock order IPv4 multicast forwarding -> iflib ctx lock attempted at:
	#0 0xffffffff80bbd6ce at witness_checkorder+0xbbe
	#1 0xffffffff80b56d10 at _sx_xlock+0x60
	#2 0xffffffff80c9ce5c at iflib_if_ioctl+0x2dc
	#3 0xffffffff80c7c395 at if_setflag+0xe5
	#4 0xffffffff82f60a0e at del_vif_locked+0x9e
	#5 0xffffffff82f5f0d5 at X_ip_mrouter_set+0x265
	#6 0xffffffff80bfd402 at sosetopt+0xc2
	#7 0xffffffff80c02105 at kern_setsockopt+0xa5
	#8 0xffffffff80c02054 at sys_setsockopt+0x24
	#9 0xffffffff81046be8 at amd64_syscall+0x138
	#10 0xffffffff8101930b at fast_syscall_common+0xf8

See also:	https://redmine.pfsense.org/issues/12079
Reviewed by:	mjg
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D41209
2023-07-28 11:32:39 +02:00
..
cc tcp: Add and update cubic module variable names 2023-06-06 23:09:28 +02:00
khelp spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
libalias Update various sys/netinet source files to conform with the style(9) 2023-06-20 23:23:19 +02:00
netdump IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
tcp_stacks tcp: fix handling of <RST,ACK> segments in SYN-RCVD for RACK and BBR 2023-07-26 16:22:13 +02:00
accf_data.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
accf_dns.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
accf_http.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
dccp.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
icmp6.h pf: apply the network stack's ICMP rate limiting to ICMP errors sent by pf 2022-10-14 10:36:16 +02:00
icmp_var.h net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
if_ether.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
if_ether.h Retire arpresolve_addr(), which is not used anywhere, from if_ether.c. 2018-11-17 16:08:36 +00:00
igmp.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
igmp.h
igmp_var.h igmp: use callout(9) directly instead of pr_slowtimo, pr_fasttimo 2022-08-17 11:50:31 -07:00
in.c mac_ipacl: new MAC policy module to limit jail/vnet IP configuration 2023-07-26 00:07:57 +00:00
in.h netinet: Remove the IP(V6)_RSS_LISTEN_BUCKET socket option 2023-02-28 15:57:21 -05:00
in_cksum.c netinet: Implement in_cksum_skip() using m_apply() 2021-11-24 13:31:16 -05:00
in_debug.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
in_fib.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
in_fib.h Refactor fib4/fib6 functions. 2020-11-29 13:41:49 +00:00
in_fib_algo.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
in_fib_dxr.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
in_gif.c gif(4): Revert in{,6}_gif_output() misalignment handling 2023-07-26 13:14:22 +02:00
in_jail.c jail: convert several functions from int to bool 2023-03-14 21:05:33 -06:00
in_kdtrace.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
in_kdtrace.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
in_mcast.c in_mcat.c: change multicast not member condition 2023-03-03 22:25:17 -07:00
in_pcb.c inpcb: do not copy so_options into inp_flags2 2023-07-26 20:35:42 -07:00
in_pcb.h inpcb: do not copy so_options into inp_flags2 2023-07-26 20:35:42 -07:00
in_pcb_var.h inpcb: Avoid inp_cred dereferences in SMR-protected lookup 2023-04-20 12:13:06 -04:00
in_prot.c
in_proto.c netinet*: add back necessary headers 2022-10-26 08:16:44 -07:00
in_rmx.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
in_rss.c in_rss: fix set but not used warning 2022-05-07 18:17:33 +02:00
in_rss.h Implement flowid calculation for outbound connections to balance 2020-10-18 17:15:47 +00:00
in_systm.h
in_var.h netinet[6]: make in[6]_control use ucred instead of td. 2023-07-01 06:52:24 +00:00
ip.h ip_reass: retire ipreass_slowtimo() in favor of per-slot callout 2022-09-08 13:49:58 -07:00
ip6.h netinet6: make IPv6 fragment TTL per-VNET configurable. 2023-06-01 12:04:49 +00:00
ip_carp.c carp: fix unicast link-local 2023-05-18 17:47:03 +02:00
ip_carp.h protosw: separate pr_input and pr_ctlinput out of protosw 2022-08-17 11:50:31 -07:00
ip_carp_nl.h carp: allow commands to use interface name rather than index 2023-03-31 11:29:58 +02:00
ip_divert.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
ip_divert.h divert(4): provide statistics 2022-08-30 15:09:21 -07:00
ip_dummynet.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
ip_ecn.c
ip_ecn.h
ip_encap.c Widen NET_EPOCH coverage. 2019-10-07 22:40:05 +00:00
ip_encap.h
ip_fastfwd.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
ip_fw.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
ip_gre.c spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSD 2023-05-12 10:44:04 -06:00
ip_icmp.c netinet: Disallow unspecified addresses in ICMP-embedded packets 2023-03-13 10:45:56 -04:00
ip_icmp.h netinet*: remove PRC_ constants and streamline ICMP processing 2022-10-03 20:53:04 -07:00
ip_id.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
ip_input.c netinet*: Fix redirects for connections from localhost 2023-05-31 11:11:05 +01:00
ip_mroute.c mroute: avoid calling if_allmulti with the lock held 2023-07-28 11:32:39 +02:00
ip_mroute.h IPv4 multicast: fix netstat -g 2022-03-22 07:38:01 -05:00
ip_options.c net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
ip_options.h
ip_output.c inpcb: do not copy so_options into inp_flags2 2023-07-26 20:35:42 -07:00
ip_reass.c IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
ip_var.h netinet*: Fix redirects for connections from localhost 2023-05-31 11:11:05 +01:00
pim.h
pim_var.h
raw_ip.c inpcb: Split PCB hash tables 2023-04-20 12:13:06 -04:00
sctp.h sctp: use constants from RFC 8260 to improve compliance 2023-04-23 17:48:05 +02:00
sctp_asconf.c sctp: improve consistency 2022-05-14 06:28:19 +02:00
sctp_asconf.h net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
sctp_auth.c net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
sctp_auth.h net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
sctp_bsd_addr.c sctp: Remove unused variable. 2022-04-12 14:58:59 -07:00
sctp_bsd_addr.h net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
sctp_cc_functions.c sctp: plug set-but-not-used vars 2022-04-19 12:45:57 +00:00
sctp_constants.h sctp: initial implementation of draft-tuexen-tsvwg-sctp-zero-checksum 2023-03-10 01:45:46 +01:00
sctp_crc32.c sctp: fix a signed/unsigned mismatch. 2022-02-17 22:45:57 +01:00
sctp_crc32.h sctp: fix a signed/unsigned mismatch. 2022-02-17 22:45:57 +01:00
sctp_header.h sctp: update zero checksum support 2023-07-23 06:41:32 +02:00
sctp_indata.c sctp: tweak panic message 2022-08-03 17:28:15 +02:00
sctp_indata.h net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
sctp_input.c sctp: update zero checksum support 2023-07-23 06:41:32 +02:00
sctp_input.h net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
sctp_kdtrace.c Separate out SCTP related dtrace code. 2019-10-14 20:32:11 +00:00
sctp_kdtrace.h Separate out SCTP related dtrace code. 2019-10-14 20:32:11 +00:00
sctp_lock_bsd.h sctp: get rid of stcb send lock 2022-03-29 01:50:17 +02:00
sctp_module.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
sctp_os.h net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
sctp_os_bsd.h IfAPI: Explicitly include <net/if_private.h> in netstack 2023-01-31 15:02:16 -05:00
sctp_output.c sctp: update zero checksum support 2023-07-23 06:41:32 +02:00
sctp_output.h sctp: cleanup the SCTP_MAXSEG socket option. 2021-12-27 23:40:31 +01:00
sctp_pcb.c sctp: update zero checksum support 2023-07-23 06:41:32 +02:00
sctp_pcb.h sctp: update zero checksum support 2023-07-23 06:41:32 +02:00
sctp_peeloff.c sctp: Remove an unused sctp_inpcb field 2021-09-07 11:19:29 -04:00
sctp_peeloff.h
sctp_ss_functions.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
sctp_structs.h sctp: update zero checksum support 2023-07-23 06:41:32 +02:00
sctp_syscalls.c sctp: ansify 2023-02-13 18:17:10 +00:00
sctp_sysctl.c sctp: initial implementation of draft-tuexen-tsvwg-sctp-zero-checksum 2023-03-10 01:45:46 +01:00
sctp_sysctl.h sctp: initial implementation of draft-tuexen-tsvwg-sctp-zero-checksum 2023-03-10 01:45:46 +01:00
sctp_timer.c Fix unused variable warning in sctp_timer.c 2022-07-25 22:08:28 +02:00
sctp_timer.h net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
sctp_uio.h sctp: update zero checksum support 2023-07-23 06:41:32 +02:00
sctp_usrreq.c sctp: update zero checksum support 2023-07-23 06:41:32 +02:00
sctp_var.h sctp: minor changes due to upstreaming of Glebs recent changes 2022-11-06 23:06:40 +01:00
sctputil.c sctp: update zero checksum support 2023-07-23 06:41:32 +02:00
sctputil.h sctp: more sb_cc related cleanups 2022-05-23 16:09:23 +02:00
siftr.c dtrace: improve siftr probe 2023-07-02 03:08:51 +02:00
tcp.h tcp: expose AccECN mode and TCP FastOpen (TFO) in TCPI 2023-06-20 23:48:56 +02:00
tcp_accounting.h Move access to tcp's t_logstate into inline functions and provide new tracepoint and bbpoint capabilities. 2023-03-16 11:43:16 -04:00
tcp_ecn.c Update various sys/netinet source files to conform with the style(9) 2023-06-20 23:23:19 +02:00
tcp_ecn.h tcp: add conservative d.cep accounting algorithm 2022-11-06 12:05:22 +01:00
tcp_fastopen.c tcp: provide macros to access inpcb and socket from a tcpcb 2022-11-08 10:24:40 -08:00
tcp_fastopen.h Use stub inline functions for no-op versions of tcp_fastopen*(). 2022-04-08 17:25:13 -07:00
tcp_fsm.h tcp: remove a 4.4BSD relic 2022-12-13 20:21:45 -08:00
tcp_hostcache.c tcp(4): Fix a typo in a sysctl description 2021-11-30 07:17:30 +01:00
tcp_hpts.c tcp: move HPTS/LRO flags out of inpcb to tcpcb 2023-04-25 12:19:48 -07:00
tcp_hpts.h tcp: add missing static keywords 2023-06-14 14:21:28 -07:00
tcp_input.c tcp: Handle <RST,ACK> in SYN-RCVD 2023-07-27 00:42:26 +02:00
tcp_log_buf.c Update various sys/netinet source files to conform with the style(9) 2023-06-20 23:23:19 +02:00
tcp_log_buf.h tcp: request tracking is not http specific. 2023-05-24 06:35:36 -04:00
tcp_lro.c inline_fls - HAVE_INLINE_FLSLL is always true 2023-07-06 15:27:31 -05:00
tcp_lro.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
tcp_offload.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
tcp_offload.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
tcp_output.c tcp: make the maximum number of retransmissions tunable per VNET 2023-06-06 22:58:54 +02:00
tcp_pcap.c tcp: embed inpcb into tcpcb 2022-12-07 09:00:48 -08:00
tcp_pcap.h
tcp_ratelimit.c Move access to tcp's t_logstate into inline functions and provide new tracepoint and bbpoint capabilities. 2023-03-16 11:43:16 -04:00
tcp_ratelimit.h rack and bbr not loading if TCP_RATELIMIT is not configured. 2023-01-05 11:59:52 -05:00
tcp_reass.c tcp: retire TCPDEBUG 2022-12-14 09:54:06 -08:00
tcp_sack.c tcp: send SACK rescue retransmission also mid-stream 2023-03-28 04:47:01 +02:00
tcp_seq.h tcp: Correctly compute the retransmit length for all 64-bit platforms. 2022-06-03 10:49:17 +02:00
tcp_stats.c tcp: add missing void keyword to tcp_stats_init 2023-02-13 18:38:04 +00:00
tcp_subr.c tcp: improve sending of TTL/hoplimit and DSCP 2023-06-05 18:43:06 +02:00
tcp_syncache.c tcp: Handle <RST,ACK> in SYN-RCVD 2023-07-27 00:42:26 +02:00
tcp_syncache.h tcp: Add/update AccECN related statistics and numbers 2022-02-10 00:21:31 +01:00
tcp_timer.c tcp: make the maximum number of retransmissions tunable per VNET 2023-06-06 22:58:54 +02:00
tcp_timer.h tcp: rearrange enum and remove unused variable 2023-02-21 18:26:49 +01:00
tcp_timewait.c tcp_hpts: move HPTS related fields from inpcb to tcpcb 2023-04-25 12:18:33 -07:00
tcp_usrreq.c tcp: Disallow connecting a disconnected socket 2023-06-23 10:00:52 -04:00
tcp_var.h tcp: document that conditional fields in tcpcb should be at the end 2023-07-27 09:02:19 +02:00
tcpip.h
toecore.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
toecore.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
udp.h headers: make a few more headers self-contained 2022-01-03 10:12:30 +01:00
udp_usrreq.c inpcb: use family specific sockaddr argument for bind functions 2023-02-15 10:30:16 -08:00
udp_var.h udp: add protocol method declarations to udp_var.h 2022-12-07 11:51:49 -08:00
udplite.h White space cleanup -- remove trailing tab's or spaces 2020-02-12 13:31:36 +00:00