FDD-book/examples/part-06/ch28-network-driver/lab05-bpf/run.sh
Edson Brandi 6e6dac94fe Add book companion files under examples/
Organize companion code and materials by book part:

  part-01/      Foundations
  part-02/      Kernel & driver fundamentals
  part-03/      Character & block devices
  part-04/      Networking & storage
  part-05/      Buses & advanced topics
  part-06/      Debugging & performance
  part-07/      Real-world drivers
  appendices/   Supplementary material
  README.md     Overview and build instructions
2026-04-25 16:51:00 +00:00

38 lines
830 B
Bash
Executable file

#!/bin/sh
#
# run.sh - lifecycle baseline for Chapter 28 Lab 5.
#
# Loads the mynet module, creates an interface, configures an IPv4
# address, captures traffic, and tears everything down. Use it as a
# regression check after edits to mynet.c.
#
# Run this script from the chapter directory:
# examples/part-06/ch28-network-driver/
# after building mynet.ko with "make".
#
# Requires root and FreeBSD 14.3 or later.
set -e
echo "== load =="
kldload ./mynet.ko
echo "== create =="
ifconfig mynet create
echo "== configure =="
ifconfig mynet0 inet 192.0.2.1/24 up
echo "== traffic =="
(tcpdump -i mynet0 -nn -c 5 > /tmp/mynet-tcpdump.txt 2>&1) &
sleep 3
ping -c 2 192.0.2.99 || true
wait
cat /tmp/mynet-tcpdump.txt
echo "== counters =="
netstat -in -I mynet0
echo "== teardown =="
ifconfig mynet0 destroy
kldunload mynet