Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/netdump/netdump_client.c
Show All 28 Lines | |||||
* netdump_client.c | * netdump_client.c | ||||
* FreeBSD subsystem supporting netdump network dumps. | * FreeBSD subsystem supporting netdump network dumps. | ||||
* A dedicated server must be running to accept client dumps. | * A dedicated server must be running to accept client dumps. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_ddb.h" | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/conf.h> | #include <sys/conf.h> | ||||
#include <sys/disk.h> | #include <sys/disk.h> | ||||
#include <sys/endian.h> | #include <sys/endian.h> | ||||
#include <sys/jail.h> | #include <sys/jail.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/kerneldump.h> | #include <sys/kerneldump.h> | ||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
Show All 20 Lines | |||||
#include <netinet/ip_options.h> | #include <netinet/ip_options.h> | ||||
#include <netinet/udp.h> | #include <netinet/udp.h> | ||||
#include <netinet/udp_var.h> | #include <netinet/udp_var.h> | ||||
#include <netinet/netdump/netdump.h> | #include <netinet/netdump/netdump.h> | ||||
#include <machine/in_cksum.h> | #include <machine/in_cksum.h> | ||||
#include <machine/pcb.h> | #include <machine/pcb.h> | ||||
#ifdef DDB | |||||
#include <ddb/ddb.h> | |||||
#endif | |||||
#define NETDDEBUG(f, ...) do { \ | #define NETDDEBUG(f, ...) do { \ | ||||
if (nd_debug > 0) \ | if (nd_debug > 0) \ | ||||
printf(("%s: " f), __func__, ## __VA_ARGS__); \ | printf(("%s: " f), __func__, ## __VA_ARGS__); \ | ||||
} while (0) | } while (0) | ||||
#define NETDDEBUG_IF(i, f, ...) do { \ | #define NETDDEBUG_IF(i, f, ...) do { \ | ||||
if (nd_debug > 0) \ | if (nd_debug > 0) \ | ||||
if_printf((i), ("%s: " f), __func__, ## __VA_ARGS__); \ | if_printf((i), ("%s: " f), __func__, ## __VA_ARGS__); \ | ||||
} while (0) | } while (0) | ||||
▲ Show 20 Lines • Show All 1,220 Lines • ▼ Show 20 Lines | |||||
static moduledata_t netdump_mod = { | static moduledata_t netdump_mod = { | ||||
"netdump", | "netdump", | ||||
netdump_modevent, | netdump_modevent, | ||||
NULL, | NULL, | ||||
}; | }; | ||||
MODULE_VERSION(netdump, 1); | MODULE_VERSION(netdump, 1); | ||||
DECLARE_MODULE(netdump, netdump_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); | DECLARE_MODULE(netdump, netdump_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); | ||||
#ifdef DDB | |||||
DB_SHOW_COMMAND(netdumpconf, db_show_netdumpconf) | |||||
{ | |||||
char ipbuf[sizeof("255.255.255.255")]; | |||||
if (!nd_enabled) { | |||||
db_printf("Netdump isn't enabled.\n"); | |||||
return; | |||||
} | |||||
db_printf("Netdump is configured on %.*s:\n", | |||||
(int)sizeof(nd_conf.ndc_iface), nd_conf.ndc_iface); | |||||
db_printf(" server: %s:%u\n", inet_ntop(AF_INET, | |||||
(void *)&nd_conf.ndc_server, ipbuf, sizeof(ipbuf)), | |||||
(unsigned)nd_server_port); | |||||
markj: The casts to unsigned here and below shouldn't be needed. | |||||
cemAuthorUnsubmitted Done Inline ActionsWhy not? nd_server_port is a uint16_t; the kda casts below are uint8_t. nd_seqno is uint32_t, which I guess is the same size as unsigned on all supported FreeBSD architectures; that one could be dropped. cem: Why not? `nd_server_port` is a `uint16_t`; the kda casts below are `uint8_t`.
`nd_seqno` is… | |||||
markjUnsubmitted Not Done Inline ActionsSorry, I didn't think that through. I think they're unneeded if you also change the format specifier to %d, which should be fine since nd_server_port and the kda fields fit in an int. It's not important. :) markj: Sorry, I didn't think that through. I think they're unneeded if you also change the format… | |||||
db_printf(" client: %s\n", inet_ntop(AF_INET, | |||||
(void *)&nd_conf.ndc_client, ipbuf, sizeof(ipbuf))); | |||||
db_printf(" gateway: %s (%6D)\n", inet_ntop(AF_INET, | |||||
(void *)&nd_conf.ndc_gateway, ipbuf, sizeof(ipbuf)), | |||||
nd_gw_mac.octet, ":"); | |||||
/* XXX Maybe this bit could be a db_show_dumperinfo in kern_shutdown */ | |||||
markjUnsubmitted Not Done Inline ActionsI was going to suggest this too. Maybe have a generic "show dumpdev" or whatever which calls a function in the netdump code to print additional parameters. markj: I was going to suggest this too. Maybe have a generic "show dumpdev" or whatever which calls a… | |||||
cemAuthorUnsubmitted Done Inline ActionsThat seems reasonable. I probably won't have time to work on that until at least Sunday — three different family gatherings this week 🥳🤯😱. cem: That seems reasonable. I probably won't have time to work on that until at least Sunday —… | |||||
db_printf(" generic dump configuration:\n"); | |||||
db_printf(" compresssion: %u\n", | |||||
(unsigned)nd_conf.ndc_kda.kda_compression); | |||||
db_printf(" encryption: %u\n", | |||||
(unsigned)nd_conf.ndc_kda.kda_encryption); | |||||
db_printf(" Netdump internals:\n"); | |||||
db_printf(" nd_seqno: %u, nd_ifp: %p\n", (unsigned)nd_seqno, nd_ifp); | |||||
db_printf(" nd_debug: %d, nd_path: '%.*s'\n", nd_debug, | |||||
(int)sizeof(nd_path), nd_path); | |||||
db_printf(" nd_polls: %d, nd_retries: %d, nd_arp_retries: %d\n", | |||||
nd_polls, nd_retries, nd_arp_retries); | |||||
} | |||||
#endif |
The casts to unsigned here and below shouldn't be needed.