freebsd-dev/sys/netinet6
Kristof Provost a7f20faa07 netinet6: fix panic on kldunload pfsync
Commit d6cd20cc5 ("netinet6: fix ndp proxying") caused us to panic when
unloading pfsync:

	Fatal trap 12: page fault while in kernel mode
	cpuid = 19; apic id = 38
	fault virtual address	= 0x20
	fault code		= supervisor read data, page not present
	instruction pointer	= 0x20:0xffffffff80dfe7f4
	stack pointer	        = 0x28:0xfffffe015d4f8ac0
	frame pointer	        = 0x28:0xfffffe015d4f8ae0
	code segment		= base 0x0, limit 0xfffff, type 0x1b
				= DPL 0, pres 1, long 1, def32 0, gran 1
	processor eflags	= interrupt enabled, resume, IOPL = 0
	current process		= 5477 (kldunload)
	trap number		= 12
	panic: page fault
	cpuid = 19
	time = 1654023100
	KDB: stack backtrace:
	db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe015d4f8880
	vpanic() at vpanic+0x17f/frame 0xfffffe015d4f88d0
	panic() at panic+0x43/frame 0xfffffe015d4f8930
	trap_fatal() at trap_fatal+0x387/frame 0xfffffe015d4f8990
	trap_pfault() at trap_pfault+0xab/frame 0xfffffe015d4f89f0
	calltrap() at calltrap+0x8/frame 0xfffffe015d4f89f0
	--- trap 0xc, rip = 0xffffffff80dfe7f4, rsp = 0xfffffe015d4f8ac0, rbp = 0xfffffe015d4f8ae0 ---
	in6_purge_proxy_ndp() at in6_purge_proxy_ndp+0x14/frame 0xfffffe015d4f8ae0
	if_purgeaddrs() at if_purgeaddrs+0x24/frame 0xfffffe015d4f8b90
	if_detach_internal() at if_detach_internal+0x1c2/frame 0xfffffe015d4f8bf0
	if_detach() at if_detach+0x71/frame 0xfffffe015d4f8c20
	pfsync_clone_destroy() at pfsync_clone_destroy+0x1dd/frame 0xfffffe015d4f8c70
	if_clone_destroyif() at if_clone_destroyif+0x239/frame 0xfffffe015d4f8cc0
	if_clone_detach() at if_clone_detach+0xc8/frame 0xfffffe015d4f8cf0
	vnet_pfsync_uninit() at vnet_pfsync_uninit+0xda/frame 0xfffffe015d4f8d10
	vnet_deregister_sysuninit() at vnet_deregister_sysuninit+0x85/frame 0xfffffe015d4f8d40
	linker_file_sysuninit() at linker_file_sysuninit+0x147/frame 0xfffffe015d4f8d70
	linker_file_unload() at linker_file_unload+0x269/frame 0xfffffe015d4f8db0
	kern_kldunload() at kern_kldunload+0x18d/frame 0xfffffe015d4f8e00
	amd64_syscall() at amd64_syscall+0x12e/frame 0xfffffe015d4f8f30
	fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe015d4f8f30
	--- syscall (444, FreeBSD ELF64, sys_kldunloadf), rip = 0x1601eab28cba, rsp = 0x1601e9c363f8, rbp = 0x1601e9c36c50 ---

This happens because ifp->if_afdata[AF_INET6] is NULL. Check for this,
just as we already do in a few other places.
See also c139b3c19b ("arp/nd: Cope with late calls to
iflladdr_event").

Reviewed by:	melifaro
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D35374
2022-06-01 09:26:15 +02:00
..
dest6.c
frag6.c netinet6: Fix a typo in a sysctl description 2021-11-30 07:24:44 +01:00
icmp6.c Revert "wpa: Import wpa_supplicant/hostapd commit 14ab4a816" 2021-12-02 14:45:04 -08:00
icmp6.h
in6_cksum.c
in6_fib_algo.c
in6_fib.c
in6_fib.h
in6_gif.c
in6_ifattach.c nd6: Mark several callouts as MPSAFE 2021-08-09 13:27:52 -04:00
in6_ifattach.h
in6_jail.c sysent: Get rid of bogus sys/sysent.h include. 2022-05-28 20:52:17 +03:00
in6_mcast.c in6p_set_multicast_if(): fix malloc(M_WAITOK) with epoch 2021-12-06 14:33:23 -08:00
in6_pcb.c in_pcb: use jenkins hash over the entire IPv6 (or IPv4) address 2021-12-26 10:47:28 -08:00
in6_pcb.h Revert "wpa: Import wpa_supplicant/hostapd commit 14ab4a816" 2021-12-02 14:45:04 -08:00
in6_proto.c domains: make domain_init() initialize only global state 2022-01-03 10:15:22 -08:00
in6_rmx.c netinet6: Use __diagused for variables only used in KASSERT(). 2022-04-13 16:08:19 -07: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 Move in6_pcbsetport() to in6_pcb.c 2021-10-18 10:19:03 -07:00
in6_var.h netinet6: fix ndp proxying 2022-05-30 10:53:33 +00:00
in6.c netinet6: fix panic on kldunload pfsync 2022-06-01 09:26:15 +02:00
in6.h Add in_localip_fib(), in6_localip_fib(). 2021-11-12 08:59:42 -08:00
ip6_ecn.h
ip6_fastfwd.c
ip6_forward.c
ip6_gre.c udp: allow udp_tun_func_t() to indicate it did not eat the packet 2022-04-12 10:04:59 +02:00
ip6_id.c
ip6_input.c sockbuf: improve sbcreatecontrol() 2022-05-17 10:10:42 -07:00
ip6_mroute.c ip6_mroute: Mark a variable only used in a debug trace as unused. 2022-04-06 16:45:29 -07:00
ip6_mroute.h
ip6_output.c Fix ipfw fwd that doesn't work in some cases 2022-04-11 14:16:43 +03:00
ip6_var.h protocols: init with standard SYSINIT(9) or VNET_SYSINIT 2022-01-03 10:15:21 -08:00
ip6.h
ip6protosw.h
ip_fw_nat64.h
ip_fw_nptv6.h
mld6_var.h
mld6.c mbuf: remove PH_vt alias for mbuf packet header persistent shared data 2022-05-13 13:32:43 -07:00
mld6.h
nd6_nbr.c netinet6: fix ndp proxying 2022-05-30 10:53:33 +00:00
nd6_rtr.c netinet6: Fix a typo in a source code comment 2022-03-28 19:32:10 +02:00
nd6.c netinet6: Fix mbuf leak in NDP 2022-05-31 21:06:14 +00:00
nd6.h lltable: Add support for "child" LLEs holding encap for IPv4oIPv6 entries. 2021-08-21 17:34:35 +00:00
pim6_var.h
pim6.h
raw_ip6.c netinet6: Use __diagused for variables only used in KASSERT(). 2022-04-13 16:08:19 -07:00
raw_ip6.h
route6.c
scope6_var.h
scope6.c ifnet_byindex() actually requires network epoch 2021-12-06 09:32:31 -08:00
sctp6_usrreq.c sctp: improve sctp_pathmtu_adjustment() 2021-12-30 15:16:05 +01:00
sctp6_var.h
send.c socket: Implement SO_RERROR 2021-07-28 09:35:09 -07:00
send.h
tcp6_var.h
udp6_usrreq.c sockbuf: merge two versions of sbcreatecontrol() into one 2022-05-17 10:10:42 -07:00
udp6_var.h