MCPcopy Create free account
hub / github.com/F-Stack/f-stack / netdump_start

Function netdump_start

freebsd/netinet/netdump/netdump_client.c:284–337  ·  view source on GitHub ↗

* Perform any initialization needed prior to transmitting the kernel core. */

Source from the content-addressed store, hash-verified

282 * Perform any initialization needed prior to transmitting the kernel core.
283 */
284static int
285netdump_start(struct dumperinfo *di)
286{
287 struct debugnet_conn_params dcp;
288 struct debugnet_pcb *pcb;
289 char buf[INET_ADDRSTRLEN];
290 int error;
291
292 error = 0;
293
294 /* Check if the dumping is allowed to continue. */
295 if (!netdump_enabled())
296 return (EINVAL);
297
298 if (!KERNEL_PANICKED()) {
299 printf(
300 "netdump_start: netdump may only be used after a panic\n");
301 return (EINVAL);
302 }
303
304 memset(&dcp, 0, sizeof(dcp));
305
306 if (nd_server.s_addr == INADDR_ANY) {
307 printf("netdump_start: can't netdump; no server IP given\n");
308 return (EINVAL);
309 }
310
311 /* We start dumping at offset 0. */
312 di->dumpoff = 0;
313
314 dcp.dc_ifp = nd_ifp;
315
316 dcp.dc_client = nd_client.s_addr;
317 dcp.dc_server = nd_server.s_addr;
318 dcp.dc_gateway = nd_gateway.s_addr;
319
320 dcp.dc_herald_port = NETDUMP_PORT;
321 dcp.dc_client_port = NETDUMP_ACKPORT;
322
323 dcp.dc_herald_data = nd_path;
324 dcp.dc_herald_datalen = (nd_path[0] == 0) ? 0 : strlen(nd_path) + 1;
325
326 error = debugnet_connect(&dcp, &pcb);
327 if (error != 0) {
328 printf("failed to contact netdump server\n");
329 /* Squash debugnet to something the dumper code understands. */
330 return (EINVAL);
331 }
332
333 printf("netdumping to %s (%6D)\n", inet_ntoa_r(nd_server, buf),
334 debugnet_get_gw_mac(pcb), ":");
335 nd_conf.nd_pcb = pcb;
336 return (0);
337}
338
339static int
340netdump_write_headers(struct dumperinfo *di, struct kerneldumpheader *kdh,

Callers

nothing calls this directly

Calls 6

netdump_enabledFunction · 0.85
memsetFunction · 0.85
debugnet_connectFunction · 0.85
inet_ntoa_rFunction · 0.85
debugnet_get_gw_macFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected