aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet/netdump
Commit message (Collapse)AuthorAgeFilesLines
* netdump: Check the return value of ifunit_ref()Mark Johnston2023-10-021-0/+2
| | | | | | | | | We may fail to match if the specific interface doesn't exist or was renamed. PR: 273715 Reported by: grembo MFC after: 1 week
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-161-2/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* IfAPI: Explicitly include <net/if_private.h> in netstackJustin Hibbits2023-01-311-0/+1
| | | | | | | | | | | Summary: In preparation of making if_t completely opaque outside of the netstack, explicitly include the header. <net/if_var.h> will stop including the header in the future. Sponsored by: Juniper Networks, Inc. Reviewed by: glebius, melifaro Differential Revision: https://reviews.freebsd.org/D38200
* netdump(4): Correct a typo in source code commentGordon Bergling2022-09-041-1/+1
| | | | | | - s/occured/occurred/ MFC after: 3 days
* ddb: use _FLAGS command macros where appropriateMitchell Horne2022-07-051-1/+1
| | | | | | | | | | | | Some command definitions were forced to use DB_FUNC in order to specify their required flags, CS_OWN or CS_MORE. Use the new macros to simplify these. Reviewed by: markj, jhb MFC after: 3 days Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35582
* netdump: check the support status of the interfaceMitchell Horne2022-05-141-0/+4
| | | | | | | | | | | If the interface does not support debugnet(4) we should bail early, rather than having the user find this out at the time of the panic. dumpon(8) already expects this return value and will print a helpful error message. Reviewed by: cem, markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D35180
* kerneldump: remove physical argument from d_dumperMitchell Horne2022-05-131-4/+2
| | | | | | | | | | | The physical address argument is essentially ignored by every dumper method. In addition, the dump routines don't actually pass a real address; every call to dump_append() passes a value of zero for physical. Reviewed by: markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D35173
* Remove 12.x ABI compat for kernel dump ioctlsMitchell Horne2022-04-152-94/+3
| | | | | | | | | | | | | | | This code was marked gone_in(14), so it can now be removed. The only consumer of this interface is dumpon(8). We do not maintain strict backwards compatibility for this utility because a) it can't/shouldn't be used from a jail or chroot and b) it is highly specific interface unique to FreeBSD. The host's (presumably more up-to-date) copy of dumpon(8) should be used to configure kernel dump devices. Reviewed by: markj, emaste MFC after: never Differential Revision: https://reviews.freebsd.org/D34914
* Remove 11.x ABI compat for kernel dump ioctlsMitchell Horne2022-04-151-15/+0
| | | | | | | | | | | | | | | This code was marked gone_in(13), so its time has passed. The only consumer of this interface is dumpon(8). We do not maintain strict backwards compatibility for this utility because a) it can't/shouldn't be used from a jail or chroot and b) it is highly specific interface unique to FreeBSD. The host's (presumably more up-to-date) copy of dumpon(8) should be used to configure kernel dump devices. Reviewed by: markj, emaste MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D34913
* netdump: send key before dump, in case dump failsEric van Gyzen2021-08-111-14/+28
| | | | | | | | | | | | | | Previously, if an encrypted netdump failed, such as due to a timeout or network failure, the key was not saved, so a partial dump was completely useless. Send the key first, so the partial dump can be decrypted, because even a partial dump can be useful. Reviewed by: bdrewery, markj MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D31453
* netdump: Fix leaking debugnet state on errors.Bryan Drewery2021-07-271-6/+26
| | | | | | Reviewed by: cem, markj Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D31319
* Use zfree() instead of explicit_bzero() and free().John Baldwin2020-06-251-5/+1
| | | | | | | | | | | | | | | In addition to reducing lines of code, this also ensures that the full allocation is always zeroed avoiding possible bugs with incorrect lengths passed to explicit_bzero(). Suggested by: cem Reviewed by: cem, delphij Approved by: csprng (cem) Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D25435 Notes: svn path=/head/; revision=362624
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-3/+5
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* Miscellaneous typo fixesEd Maste2020-02-071-1/+1
| | | | | | | | Submitted by: Gordon Bergling <gbergling_gmail.com> Differential Revision: https://reviews.freebsd.org/D23453 Notes: svn path=/head/; revision=357664
* Add KERNEL_PANICKED macro for use in place of direct panicstr testsMateusz Guzik2020-01-121-1/+1
| | | | Notes: svn path=/head/; revision=356655
* Fix compile issues when building a kernel without the VIMAGE option.Michael Tuexen2019-10-191-9/+2
| | | | | | | | | | | Thanks to cem@ for discussing the issue which resulted in this patch. Reviewed by: cem@ Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D22089 Notes: svn path=/head/; revision=353770
* debugnet(4): Add optional full-duplex modeConrad Meyer2019-10-171-1/+1
| | | | | | | | | | | | It remains unattached to any client protocol. Netdump is unaffected (remaining half-duplex). The intended consumer is NetGDB. Submitted by: John Reimer <john.reimer AT emc.com> (earlier version) Discussed with: markj Differential Revision: https://reviews.freebsd.org/D21541 Notes: svn path=/head/; revision=353696
* debugnet(4): Infer non-server connection parametersConrad Meyer2019-10-171-37/+45
| | | | | | | | | | | | | | | | Loosen requirements for connecting to debugnet-type servers. Only require a destination address; the rest can theoretically be inferred from the routing table. Relax corresponding constraints in netdump(4) and move ifp validation to debugnet connection time. Submitted by: John Reimer <john.reimer AT emc.com> (earlier version) Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D21482 Notes: svn path=/head/; revision=353694
* Add ddb(4) 'netdump' command to netdump a core without preconfigurationConrad Meyer2019-10-171-3/+88
| | | | | | | | | | | | | | | | | Add a 'X -s <server> -c <client> [-g <gateway>] -i <interface>' subroutine to the generic debugnet code. The imagined use is both netdump, shown here, and NetGDB (vaporware). It uses the ddb(4) lexer, with some new extensions, to parse out IPv4 addresses. 'Netdump' uses the generic debugnet routine to load a configuration and start a dump, without any netdump configuration prior to panic. Loosely derived from work by: John Reimer <john.reimer AT emc.com> Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D21460 Notes: svn path=/head/; revision=353692
* Split out a more generic debugnet(4) from netdump(4)Conrad Meyer2019-10-172-931/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Debugnet is a simplistic and specialized panic- or debug-time reliable datagram transport. It can drive a single connection at a time and is currently unidirectional (debug/panic machine transmit to remote server only). It is mostly a verbatim code lift from netdump(4). Netdump(4) remains the only consumer (until the rest of this patch series lands). The INET-specific logic has been extracted somewhat more thoroughly than previously in netdump(4), into debugnet_inet.c. UDP-layer logic and up, as much as possible as is protocol-independent, remains in debugnet.c. The separation is not perfect and future improvement is welcome. Supporting INET6 is a long-term goal. Much of the diff is "gratuitous" renaming from 'netdump_' or 'nd_' to 'debugnet_' or 'dn_' -- sorry. I thought keeping the netdump name on the generic module would be more confusing than the refactoring. The only functional change here is the mbuf allocation / tracking. Instead of initiating solely on netdump-configured interface(s) at dumpon(8) configuration time, we watch for any debugnet-enabled NIC for link activation and query it for mbuf parameters at that time. If they exceed the existing high-water mark allocation, we re-allocate and track the new high-water mark. Otherwise, we leave the pre-panic mbuf allocation alone. In a future patch in this series, this will allow initiating netdump from panic ddb(4) without pre-panic configuration. No other functional change intended. Reviewed by: markj (earlier version) Some discussion with: emaste, jhb Objection from: marius Differential Revision: https://reviews.freebsd.org/D21421 Notes: svn path=/head/; revision=353685
* Fix netdump buffering after r348473.Mark Johnston2019-08-191-12/+27
| | | | | | | | | | | | | | | nd_buf is used to buffer headers (for both the kernel dump itself and for EKCD) before the final call to netdump_dumper(), which flushes residual data in nd_buf. As a result, a small portion of the residual data would be corrupted. This manifests when kernel dump compression is enabled since both zstd and zlib detect the corruption during decompression. Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D21294 Notes: svn path=/head/; revision=351219
* netdump: Buffer pages to avoid calling netdump_send() on each 4KB write.Mark Johnston2019-05-311-5/+26
| | | | | | | | | | | | | | | | | netdump waits for acknowledgement from the server for each write. When dumping page table pages, we perform many small writes, limiting throughput. Use the netdump client's buffer to buffer small contiguous writes before calling netdump_send() to flush the MAXDUMPPGS-sized buffer. This results in a significant reduction in the time taken to complete a netdump. Submitted by: Sam Gwydir <sam@samgwydir.com> Reviewed by: cem MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20317 Notes: svn path=/head/; revision=348473
* Add two missing eventhandler.h headersConrad Meyer2019-05-211-0/+1
| | | | | | | | | | | | | These are obviously missing from the .c files, but don't show up in any tinderbox configuration (due to latent header pollution of some kind). It seems some configurations don't have this pollution, and the includes are obviously missing, so go ahead and add them. Reported by: Peter Jeremy <peter AT rulingia.com> X-MFC-With: r347984 Notes: svn path=/head/; revision=348022
* netdump: Ref the interface we're attached toConrad Meyer2019-05-101-58/+129
| | | | | | | | | | | | | Serialize netdump configuration / deconfiguration, and discard our configuration when the affiliated interface goes away by monitoring ifnet_departure_event. Reviewed by: markj, with input from vangyzen@ (earlier version) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D20206 Notes: svn path=/head/; revision=347473
* netdump: Fix boot-time configuration typoConrad Meyer2019-05-101-2/+2
| | | | | | | | | | | | | Boot-time netdump configuration is much more useful if one can configure the client and gateway addresses. Fix trivial typo. (Long-standing bug, I believe it dates to the original netdump commit.) Spotted by: one of vangyzen@ or markj@ Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=347471
* netdump: Don't store sensitive key data we don't needConrad Meyer2019-05-101-8/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this revision, struct diocskerneldump_arg (and struct netdump_conf with embedded diocskerneldump_arg before r347192), were copied in their entirety to the global 'nd_conf' variable. Also prior to this revision, de-configuring netdump would *not* remove the the key material from global nd_conf. As part of Encrypted Kernel Crash Dumps (EKCD), which was developed contemporaneously with netdump but happened to land first, the diocskerneldump_arg structure will contain sensitive key material (kda_key[]) when encrypted dumps are configured. Netdump doesn't have any use for the key data -- encryption is handled in the core dumper code -- so in this revision, we no longer store it. Unfortunately, I think this leak dates to the initial import of netdump in r333283; so it's present in FreeBSD 12.0. Fortunately, the impact *seems* relatively minor. Any new *netdump* configuration would overwrite the key material; for active encrypted netdump configurations, the key data stored was just a duplicate of the key material already in the core dumper code; and no user interface (other than /dev/kmem) actually exposed the leaked material to userspace. Reviewed by: markj, rpokala (earlier commit message) MFC after: 2 weeks Security: yes (minor) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D20233 Notes: svn path=/head/; revision=347467
* List-ify kernel dump device configurationConrad Meyer2019-05-062-59/+157
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow users to specify multiple dump configurations in a prioritized list. This enables fallback to secondary device(s) if primary dump fails. E.g., one might configure a preference for netdump, but fallback to disk dump as a second choice if netdump is unavailable. This change does not list-ify netdump configuration, which is tracked separately from ordinary disk dumps internally; only one netdump configuration can be made at a time, for now. It also does not implement IPv6 netdump. savecore(8) is already capable of scanning and iterating multiple devices from /etc/fstab or passed on the command line. This change doesn't update the rc or loader variables 'dumpdev' in any way; it can still be set to configure a single dump device, and rc.d/savecore still uses it as a single device. Only dumpon(8) is updated to be able to configure the more complicated configurations for now. As part of revving the ABI, unify netdump and disk dump configuration ioctl / structure, and leave room for ipv6 netdump as a future possibility. Backwards-compatibility ioctls are added to smooth ABI transition, especially for developers who may not keep kernel and userspace perfectly synced. Reviewed by: markj, scottl (earlier version) Relnotes: maybe Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D19996 Notes: svn path=/head/; revision=347192
* netdump: Fix !COMPAT_FREEBSD11 unused variable warningConrad Meyer2019-04-231-0/+2
| | | | | | | | Reported by: Ralf Wenk <iz-rpi03_hs-karlsruhe.de> Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=346599
* netdump: Fix 11 compatibility DIOCSKERNELDUMP ioctlConrad Meyer2019-04-201-2/+14
| | | | | | | | | | | The logic was present for the 11 version of the DIOCSKERNELDUMP ioctl, but had not been updated for the 12 ABI. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D19980 Notes: svn path=/head/; revision=346448
* Use IN_foo() macros from sys/netinet/in.h inplace of handcrafted codeRodney W. Grimes2019-04-041-2/+2
| | | | | | | | | | | | | | | | There are a few places that use hand crafted versions of the macros from sys/netinet/in.h making it difficult to actually alter the values in use by these macros. Correct that by replacing handcrafted code with proper macro usage. Reviewed by: karels, kristof Approved by: bde (mentor) MFC after: 3 weeks Sponsored by: John Gilmore Differential Revision: https://reviews.freebsd.org/D19317 Notes: svn path=/head/; revision=345888
* Mechanical cleanup of epoch(9) usage in network stack.Gleb Smirnoff2019-01-091-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | - Remove macros that covertly create epoch_tracker on thread stack. Such macros a quite unsafe, e.g. will produce a buggy code if same macro is used in embedded scopes. Explicitly declare epoch_tracker always. - Unmask interface list IFNET_RLOCK_NOSLEEP(), interface address list IF_ADDR_RLOCK() and interface AF specific data IF_AFDATA_RLOCK() read locking macros to what they actually are - the net_epoch. Keeping them as is is very misleading. They all are named FOO_RLOCK(), while they no longer have lock semantics. Now they allow recursion and what's more important they now no longer guarantee protection against their companion WLOCK macros. Note: INP_HASH_RLOCK() has same problems, but not touched by this commit. This is non functional mechanical change. The only functionally changed functions are ni6_addrs() and ni6_store_addrs(), where we no longer enter epoch recursively. Discussed with: jtl, gallatin Notes: svn path=/head/; revision=342872
* Expose some netdump configuration parameters through sysctl.Mark Johnston2018-10-291-12/+12
| | | | | | | | | Reviewed by: cem MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D17755 Notes: svn path=/head/; revision=339883
* UDP: further performance improvements on txMatt Macy2018-05-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cumulative throughput while running 64 netperf -H $DUT -t UDP_STREAM -- -m 1 on a 2x8x2 SKL went from 1.1Mpps to 2.5Mpps Single stream throughput increases from 910kpps to 1.18Mpps Baseline: https://people.freebsd.org/~mmacy/2018.05.11/udpsender2.svg - Protect read access to global ifnet list with epoch https://people.freebsd.org/~mmacy/2018.05.11/udpsender3.svg - Protect short lived ifaddr references with epoch https://people.freebsd.org/~mmacy/2018.05.11/udpsender4.svg - Convert if_afdata read lock path to epoch https://people.freebsd.org/~mmacy/2018.05.11/udpsender5.svg A fix for the inpcbhash contention is pending sufficient time on a canary at LLNW. Reviewed by: gallatin Sponsored by: Limelight Networks Differential Revision: https://reviews.freebsd.org/D15409 Notes: svn path=/head/; revision=334118
* Initialize the dumper struct before calling set_dumper().Mark Johnston2018-05-221-0/+1
| | | | | | | | | | | Fields owned by the generic code were being left uninitialized, causing problems in clear_dumper() if an error occurred. Coverity CID: 1391200 X-MFC with: r333283 Notes: svn path=/head/; revision=334055
* Fix netdump configuration when VIMAGE is enabled.Mark Johnston2018-05-171-6/+17
| | | | | | | | | | | | | | | | | | We need to set the current vnet before iterating over the global interface list. Because the dump device may only be set from the host, only proceed with configuration if the thread belongs to the default vnet. [1] Also fix a resource leak that occurs if the priv_check() in set_dumper() fails. Reported by: mmacy, sbruno [1] Reviewed by: sbruno X-MFC with: r333283 Differential Revision: https://reviews.freebsd.org/D15449 Notes: svn path=/head/; revision=333702
* Import the netdump client code.Mark Johnston2018-05-062-0/+1426
This is a component of a system which lets the kernel dump core to a remote host after a panic, rather than to a local storage device. The server component is available in the ports tree. netdump is particularly useful on diskless systems. The netdump(4) man page contains some details describing the protocol. Support for configuring netdump will be added to dumpon(8) in a future commit. To use netdump, the kernel must have been compiled with the NETDUMP option. The initial revision of netdump was written by Darrell Anderson and was integrated into Sandvine's OS, from which this version was derived. Reviewed by: bdrewery, cem (earlier versions), julian, sbruno MFC after: 1 month X-MFC note: use a spare field in struct ifnet Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D15253 Notes: svn path=/head/; revision=333283