Repository : ssh://git@open-mesh.org/doc
On branch : master
commit 8bb3b776e23005ce8610f8c261f3f660beeac28d Merge: b210854 11ff514 Author: Sven Eckelmann sven@narfation.org Date: Sun Oct 13 09:05:12 2019 +0200
Merge branch 'backup-redmine/2019-10-12'
8bb3b776e23005ce8610f8c261f3f660beeac28d open-mesh/Emulation_Debug.rst | 113 ++++++++++++++---- open-mesh/News-draft.rst | 44 ++++--- open-mesh/OpenWrt_KGDB.rst | 271 ++++++++++++++++++++++++++++++++++++++++++ open-mesh/random.rst | 1 + 4 files changed, 388 insertions(+), 41 deletions(-)
diff --cc open-mesh/Emulation_Debug.rst index b19d01d,0000000..d8dca5b mode 100644,000000..100644 --- a/open-mesh/Emulation_Debug.rst +++ b/open-mesh/Emulation_Debug.rst @@@ -1,398 -1,0 +1,463 @@@ +.. SPDX-License-Identifier: GPL-2.0 + +Emulation Debug +=============== + +Create an Image +--------------- + +:: + + qemu-img create debian.img 8G + sudo mkfs.ext4 -O '^has_journal' -F debian.img + sudo mkdir debian + sudo mount -o loop debian.img debian + sudo debootstrap buster debian + sudo chroot debian apt update + sudo chroot debian apt install --no-install-recommends build-essential vim openssh-server less \ + pkg-config libnl-3-dev libnl-genl-3-dev libcap-dev tcpdump \ + trace-cmd flex bison libelf-dev libdw-dev binutils-dev libunwind-dev libssl-dev libslang2-dev liblzma-dev + + sudo mkdir debian/root/.ssh/ + ssh-add -L | sudo tee debian/root/.ssh/authorized_keys + + sudo mkdir debian/host + sudo sh -c 'cat > debian/etc/fstab << EOF + host /host 9p trans=virtio,version=9p2000.L 0 0 + EOF' + + sudo sh -c 'cat > debian/etc/rc.local << "EOF" + #!/bin/sh -e + - MAC_PART="$(ip link show enp0s3 | awk "/ether/ {print $2}"| sed -e "s/.*://" -e "s/[\n\ ].*//"|awk "{print ("0x"$1)*1 }")" ++ MAC_PART="$(ip link show enp0s1 | awk "/ether/ {print $2}"| sed -e "s/.*://" -e "s/[\n\ ].*//"|awk "{print ("0x"$1)*1 }")" + IP_PART="$(echo $MAC_PART|awk "{ print $1+50 }")" + NODE_NR="$(echo $MAC_PART|awk "{ printf("%02d", $1) }")" - ip addr add 192.168.2.${IP_PART}/24 dev enp0s3 - ip link set up dev enp0s3 ++ ip addr add 192.168.251.${IP_PART}/24 dev enp0s1 ++ ip link set up dev enp0s1 + hostname "node"$NODE_NR + ip link set up dev lo + [ ! -x /host/test-init.sh ] || /host/test-init.sh + exit 0 + EOF' + sudo chmod a+x debian/etc/rc.local + + sudo sed -i 's/^root:[^:]*:/root::/' debian/etc/shadow + + ## optionally: allow ssh logins without passwords + # sudo sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' debian/etc/ssh/sshd_config + # sudo sed -i 's/^#PermitEmptyPasswords.*/PermitEmptyPasswords yes/' debian/etc/ssh/sshd_config + # sudo sed -i 's/^UsePAM.*/UsePAM no/' debian/etc/ssh/sshd_config + + ## optionally: enable autologin for user root + #sudo mkdir debian/etc/systemd/system/serial-getty@ttyS0.service.d/ + #sudo sh -c 'cat > debian/etc/systemd/system/serial-getty@ttyS0.service.d/autologin.conf << EOF + #[Service] + #ExecStart= + #ExecStart=-/sbin/agetty --autologin root -s %I 115200,38400,9600 vt102 + #EOF' + + sudo sh -c 'echo '''PATH="/host/batctl/:$PATH"''' >> debian/etc/profile' + sudo rm debian/var/cache/apt/archives/*.deb + sudo rm debian/var/lib/apt/lists/* + sudo e4defrag -v debian/ + sudo umount debian + sudo zerofree -v debian.img + + + ## optionally: convert image to qcow2 + #sudo qemu-img convert -c -f raw -O qcow2 debian.img debian.qcow2 + #sudo mv debian.qcow2 debian.img + +Kernel compile +-------------- + +Any recent kernel can be used for the setup. The build result +``arch/x86/boot/bzImage`` has to be copied to the same directory as the +debian.img + +:: + + # make sure that libelf-dev is installed or module build will fail with something like "No rule to make target 'net/batman-adv/bat_algo.o'" + + git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git + cd linux-next + + make allnoconfig + cat >> .config << EOF + + # small configuration + CONFIG_SMP=y + CONFIG_EMBEDDED=n + # CONFIG_EXPERT is not set + CONFIG_MODULES=y + CONFIG_MODULE_UNLOAD=y + CONFIG_MODVERSIONS=y + CONFIG_MODULE_SRCVERSION_ALL=y + CONFIG_64BIT=y + CONFIG_X86_VSYSCALL_EMULATION=n + CONFIG_IA32_EMULATION=n + CONFIG_VOP_BUS=y + CONFIG_VOP=y + CONFIG_HW_RANDOM_VIRTIO=y + CONFIG_NET_9P_VIRTIO=y + CONFIG_VIRTIO_MENU=y + CONFIG_SCSI_VIRTIO=y + CONFIG_VIRTIO_BALLOON=y + CONFIG_VIRTIO_BLK=y + CONFIG_VIRTIO_CONSOLE=y + CONFIG_VIRTIO_INPUT=y + CONFIG_VIRTIO_NET=y + CONFIG_VIRTIO_PCI=y + CONFIG_VIRTIO_PCI_LEGACY=y + CONFIG_VIRTIO_BALLOON=y + CONFIG_VIRTIO_BLK_SCSI=y + CONFIG_VIRTIO_INPUT=y + CONFIG_VIRTIO_MMIO=y + CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y + CONFIG_RPMSG_VIRTIO=y + CONFIG_VSOCKETS=y + CONFIG_VIRTIO_VSOCKETS=y + CONFIG_DRM=y + CONFIG_DRM_VIRTIO_GPU=y + CONFIG_CAIF=y + CONFIG_CAIF_VIRTIO=y + CONFIG_CRC16=y + CONFIG_LIBCRC32C=y + CONFIG_CRYPTO_SHA512=y + CONFIG_NET=y + CONFIG_INET=y + CONFIG_DEBUG_FS=y + CONFIG_IPV6=y + CONFIG_BRIDGE=y + CONFIG_VLAN_8021Q=y + CONFIG_WIRELESS=n + CONFIG_NET_9P=y + CONFIG_NETWORK_FILESYSTEMS=y + CONFIG_9P_FS=y + CONFIG_9P_FS_POSIX_ACL=y + CONFIG_9P_FS_SECURITY=y + CONFIG_BLOCK=y + CONFIG_BLK_DEV=y + CONFIG_EXT4_FS=y + CONFIG_EXT4_USE_FOR_EXT23=y + CONFIG_TTY=y + CONFIG_SERIAL_8250=y + CONFIG_SERIAL_8250_CONSOLE=y + CONFIG_HW_RANDOM=y + CONFIG_VHOST_RING=y + CONFIG_GENERIC_ALLOCATOR=y + CONFIG_SCSI_LOWLEVEL=y + CONFIG_SCSI=y + CONFIG_NETDEVICES=y + CONFIG_NET_CORE=y + CONFIG_DEVTMPFS=y + CONFIG_HYPERVISOR_GUEST=y + CONFIG_PARAVIRT=y + CONFIG_KVM_GUEST=y + CONFIG_BINFMT_ELF=y + CONFIG_BINFMT_SCRIPT=y + CONFIG_BINFMT_MISC=y + CONFIG_PCI=y + CONFIG_SYSVIPC=y + CONFIG_POSIX_MQUEUE=y + CONFIG_CROSS_MEMORY_ATTACH=y + CONFIG_UNIX=y + CONFIG_TMPFS=y + CONFIG_CGROUPS=y + CONFIG_BLK_CGROUP=y + CONFIG_CGROUP_CPUACCT=y + CONFIG_CGROUP_DEVICE=y + CONFIG_CGROUP_FREEZER=y + CONFIG_CGROUP_HUGETLB=y + CONFIG_CGROUP_NET_CLASSID=y + CONFIG_CGROUP_NET_PRIO=y + CONFIG_CGROUP_PERF=y + CONFIG_CGROUP_SCHED=y + CONFIG_DEVPTS_MULTIPLE_INSTANCES=y + CONFIG_INOTIFY_USER=y + CONFIG_FHANDLE=y + CONFIG_E1000=y + CONFIG_CPU_FREQ=y + CONFIG_CONFIG_X86_ACPI_CPUFREQ=y + CONFIG_CPU_FREQ_GOV_ONDEMAND=y + CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y + CONFIG_CFG80211=y + CONFIG_PARAVIRT_SPINLOCKS=y + CONFIG_DUMMY=y + CONFIG_PACKET=y + CONFIG_VETH=y + CONFIG_IP_MULTICAST=y + CONFIG_NET_IPGRE_DEMUX=y + CONFIG_NET_IP_TUNNEL=y + CONFIG_NET_IPGRE=y + CONFIG_NET_IPGRE_BROADCAST=y + # CONFIG_LEGACY_PTYS is not set + + # makes boot a lot slower but required for shutdown + CONFIG_ACPI=y + + #debug stuff + CONFIG_CC_STACKPROTECTOR_STRONG=y + CONFIG_LOCKUP_DETECTOR=y + CONFIG_DETECT_HUNG_TASK=y + CONFIG_SCHED_STACK_END_CHECK=y + CONFIG_DEBUG_RT_MUTEXES=y + CONFIG_DEBUG_SPINLOCK=y + CONFIG_DEBUG_MUTEXES=y + CONFIG_PROVE_LOCKING=y + CONFIG_LOCK_STAT=y + CONFIG_DEBUG_LOCKDEP=y + CONFIG_DEBUG_ATOMIC_SLEEP=y + CONFIG_DEBUG_LIST=y + CONFIG_DEBUG_PI_LIST=y + CONFIG_DEBUG_SG=y + CONFIG_DEBUG_NOTIFIERS=y + CONFIG_PROVE_RCU_REPEATEDLY=y + CONFIG_SPARSE_RCU_POINTER=y + CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y + CONFIG_X86_VERBOSE_BOOTUP=y + CONFIG_DEBUG_RODATA=y + CONFIG_DEBUG_RODATA_TEST=n + CONFIG_DEBUG_SET_MODULE_RONX=y + CONFIG_PAGE_EXTENSION=y + CONFIG_DEBUG_PAGEALLOC=y + CONFIG_DEBUG_OBJECTS=y + CONFIG_DEBUG_OBJECTS_FREE=y + CONFIG_DEBUG_OBJECTS_TIMERS=y + CONFIG_DEBUG_OBJECTS_WORK=y + CONFIG_DEBUG_OBJECTS_RCU_HEAD=y + CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER=y + CONFIG_DEBUG_KMEMLEAK=y + CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE=8000 + CONFIG_DEBUG_STACK_USAGE=y + CONFIG_DEBUG_STACKOVERFLOW=y + CONFIG_DEBUG_INFO=y + CONFIG_DEBUG_INFO_DWARF4=y + CONFIG_GDB_SCRIPTS=y + CONFIG_READABLE_ASM=y + CONFIG_STACK_VALIDATION=y + CONFIG_WQ_WATCHDOG=y + CONFIG_DEBUG_KOBJECT_RELEASE=y + CONFIG_DEBUG_WQ_FORCE_RR_CPU=y + CONFIG_OPTIMIZE_INLINING=y + CONFIG_ENABLE_MUST_CHECK=y + CONFIG_ENABLE_WARN_DEPRECATED=y + CONFIG_DEBUG_SECTION_MISMATCH=y + CONFIG_UNWINDER_ORC=y + CONFIG_FTRACE=y + CONFIG_FUNCTION_TRACER=y + CONFIG_FUNCTION_GRAPH_TRACER=y + CONFIG_FTRACE_SYSCALLS=y + CONFIG_TRACER_SNAPSHOT=y + CONFIG_TRACER_SNAPSHOT_PER_CPU_SWAP=y + CONFIG_STACK_TRACER=y + CONFIG_UPROBE_EVENTS=y + CONFIG_DYNAMIC_FTRACE=y + CONFIG_FUNCTION_PROFILER=y + CONFIG_HIST_TRIGGERS=y + + # for GCC 5+ + CONFIG_KASAN=y + CONFIG_KASAN_INLINE=y + CONFIG_UBSAN_SANITIZE_ALL=y + CONFIG_UBSAN=y + CONFIG_UBSAN_NULL=y + EOF + make olddefconfig + + cat >> .config << EOF + # allow to use unsigned regdb with hwsim + CONFIG_EXPERT=y + CONFIG_CFG80211_CERTIFICATION_ONUS=y + # CONFIG_CFG80211_REQUIRE_SIGNED_REGDB is not set + EOF + make olddefconfig + + make all -j$(nproc || echo 1) + +Start of the simple environment +------------------------------- + +The two node environment must be started inside a screen session. The - hub (bridge with eth0 + 2 tap devices) has to be started first to have a - simple network. A more complex network setup can be on the page - :doc:`Emulation <Emulation>` ++hub (bridge with 5 tap devices) has to be started first to have a simple ++network. A more complex network setup can be on the page [[Emulation]] + +The ``ETH`` in hub.sh has to be changed to the real interface which +provides internet-connectivity + +:: + + cat > hub.sh << "EOF" + #! /bin/sh + USER="$(whoami)" - BRIDGE=br0 - ETH=enp8s0 ++ BRIDGE=br-qemu + + sudo ip link add "${BRIDGE}" type bridge + for i in `seq 1 5`; do + sudo ip tuntap add dev tap$i mode tap user "$USER" + sudo ip link set tap$i up + sudo ip link set tap$i master "${BRIDGE}" + done + + sudo ip link set "${BRIDGE}" up - - sudo ip addr flush dev "${ETH}" - sudo ip link set "${ETH}" master "${BRIDGE}" - sudo dhclient "${BRIDGE}" ++ sudo ip addr replace 192.168.251.1/24 dev br-qemu + EOF + + chmod +x hub.sh + +The ``SHARED_PATH`` in run.sh has to be changed to a valid path which is +used to share the precompiled batman-adv.ko and other tools + +:: + + cat > run.sh << "EOF" + #! /bin/sh + ++ if [ "${LINKS_XTERM}" != "screen" ]; then ++ echo "must be started inside a screen session" >&2 ++ exit 1 ++ fi ++ + SHARED_PATH=/home/sven/tmp/qemu-batman/ + - for i in `seq 1 5`; do ++ for i in $(seq 1 5); do + qemu-img create -b debian.img -f qcow2 root.cow$i - normalized_id=`echo "$i"|awk '{ printf "%02d\n",$1 }'` - screen qemu-system-x86_64 -enable-kvm -kernel linux-next/arch/x86/boot/bzImage -append "root=/dev/vda rw console=ttyS0" \ - -smp 2 -m 512 -drive file=root.cow$i,if=virtio \ - -netdev type=tap,id=net0,ifname=tap$i,script=no -device virtio-net-pci,mac=02:ba:de:af:fe:`echo $i|awk '{ printf "%02X", $1 }'`,netdev=net0 \ ++ normalized_id="$(echo "$i"|awk '{ printf "%02d\n",$1 }')" ++ twodigit_id="$(echo $i|awk '{ printf "%02X", $1 }')" ++ screen qemu-system-x86_64 -enable-kvm -name "debian${i}" \ ++ -kernel linux-next/arch/x86/boot/bzImage -append "root=/dev/vda rw console=ttyS0 nokaslr" \ ++ -display none -no-user-config -nodefaults \ ++ -m 512 -device virtio-balloon \ ++ -cpu host -smp 2 -machine q35,accel=kvm,usb=off,dump-guest-core=off \ ++ -drive file=root.cow$i,if=virtio,cache=unsafe \ ++ -nic tap,ifname=tap$i,script=no,model=virtio-net-pci,mac=02:ba:de:af:fe:"${twodigit_id}" \ ++ -nic user,model=virtio-net-pci,mac=06:ba:de:af:fe:"${twodigit_id}" \ + -virtfs local,path="${SHARED_PATH}",security_model=none,mount_tag=host \ - -device virtio-rng-pci -nographic ++ -gdb tcp:127.0.0.1:$((23000+$i)) \ ++ -device virtio-rng-pci \ ++ -serial mon:stdio + sleep 1 + done + EOF + + chmod +x run.sh + +The test-init.sh script can be used to automatically initialize the +testsetup during boot: + +:: + + cat > test-init.sh << "EOF" + #! /bin/sh + + set -e + export PATH="/host/batctl/:$PATH" + + # ip link add dummy0 type dummy + ip link set up dummy0 + + rmmod batman-adv || true + insmod /host/batman-adv/net/batman-adv/batman-adv.ko + batctl routing_algo BATMAN_IV + /host/batctl/batctl if add dummy0 + /host/batctl/batctl it 5000 - /host/batctl/batctl if add enp0s3 - ip link set up dev enp0s3 ++ /host/batctl/batctl if add enp0s1 ++ ip link set up dev enp0s1 + ip link set up dev bat0 + EOF + + chmod +x test-init.sh + +Everything can then be started up inside a screen session + +:: + + screen + ./hub.sh + ./run.sh + ++.. _open-mesh-open-mesh-emulation-debug-building-the-batman-adv-module: ++ +Building the batman-adv module +------------------------------ + +The kernel module can be build outside the virtual environment and +shared over the 9p mount. The path to the kernel sources have to be +provided to the make process + +:: + + make KERNELPATH=/home/batman/linux-next + +The kernel module can also be compiled for better readability for the +calltraces: + +:: + - make EXTRA_CFLAGS="-fno-inline -O1 -fno-optimize-sibling-calls" KERNELPATH=/home/sven/tmp/linux-next V=1 ++ make EXTRA_CFLAGS="-fno-inline -Og -fno-optimize-sibling-calls" KERNELPATH=/home/sven/tmp/qemu-batman/linux-next V=1 + +View traffic via wireshark from virtual machine +----------------------------------------------- + +On host system + +:: + - mkfifo remote-dump - ssh root@192.168.2.51 'tcpdump -i enp3s0 -s 0 -U -n -w - "port not 22"' > remote-dump - wireshark -k -i remote-dump ++ mkfifo remote-dump ++ ssh root@192.168.251.51 'tcpdump -i enp3s0 -s 0 -U -n -w - "port not 22"' > remote-dump ++ wireshark -k -i remote-dump ++ ++.. _open-mesh-open-mesh-emulation-debug-using-gdb: ++ ++Using GDB ++--------- ++ ++The instances are listening on 127.0.0.1 TCP port 23000 + instance_no. ++We will use in the following example instance 1. The gdb debugger can be ++started from the linux source directory and all lx-* helpers will ++automatically be loaded. ++ ++The debugging session with gdb can be started from the linux-next ++directory: ++ ++:: ++ ++ $ gdb -iex "set auto-load safe-path scripts/gdb/" -ex 'target remote 127.0.0.1:23001' -ex c ./vmlinux ++ ++The module can now be loaded in the qemu instance. After that, we have ++to reload the symbol information via lx-symbol and can set any kind of ++breakpoints on the batman-adv module: ++ ++:: ++ ++ ^C ++ Thread 1 received signal SIGINT, Interrupt. ++ default_idle () at arch/x86/kernel/process.c:581 ++ 581 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id()); ++ (gdb) lx-symbols /home/sven/tmp/qemu-batman/batman-adv/net/batman-adv/ ++ loading vmlinux ++ scanning for modules in /home/sven/tmp/qemu-batman/batman-adv/net/batman-adv/ ++ scanning for modules in /home/sven/tmp/qemu-batman/linux-next ++ loading @0xffffffffa0000000: /home/sven/tmp/qemu-batman/batman-adv/net/batman-adv//batman-adv.ko ++ (gdb) b batadv_iv_send_outstanding_bat_ogm_packet ++ Breakpoint 1 at 0xffffffffa0005d60: file /home/sven/tmp/qemu-batman/batman-adv/net/batman-adv/bat_iv_ogm.c, line 1692. ++ (gdb) c ++ ++It is also possible to evaluate data structures in the gdb commandline ++using small python code blocks. To get for example the name of all ++devices which batman-adv knows about and the name of the batman-adv ++interface they belong to: ++ ++:: ++ ++ python ++ import linux.lists ++ from linux.utils import CachedType ++ ++ struct_batadv_hard_iface = CachedType('struct batadv_hard_iface').get_type().pointer() ++ ++ for node in linux.lists.list_for_each_entry(gdb.parse_and_eval("batadv_hardif_list"), struct_batadv_hard_iface, 'list'): ++ hardif = node['net_dev']['name'].string() ++ softif = node['soft_iface']['name'].string() if node['soft_iface'] else "none" ++ gdb.write("hardif {} belongs to {}\n".format(hardif, softif)) ++ end diff --cc open-mesh/News-draft.rst index a9e96c7,0000000..324a101 mode 100644,000000..100644 --- a/open-mesh/News-draft.rst +++ b/open-mesh/News-draft.rst @@@ -1,124 -1,0 +1,134 @@@ +.. SPDX-License-Identifier: GPL-2.0 + +DRAFT: Batman-adv 2019.4 released +================================= + - Sep 23th, 2019. Today the B.A.T.M.A.N. team publishes the September 2019 update - to batman-adv, batctl and alfred! The B.A.T.M.A.N. V implementation can now - aggregate OGM2 messages into single messages before sending them out. As usual, - this release also contains various bugfixes and code cleanups. ++Oct 15th, 2019. Today the B.A.T.M.A.N. team publishes the October 2019 ++update to batman-adv, batctl and alfred! The B.A.T.M.A.N. V ++implementation can now aggregate OGM2 messages into single messages ++before sending them out. As usual, this release also contains various ++bugfixes and code cleanups. + - As the kernel module always depends on the Linux kernel it is compiled against, - it does not make sense to provide binaries on our website. As usual, you will - find the signed tarballs in our download section: ++As the kernel module always depends on the Linux kernel it is compiled ++against, it does not make sense to provide binaries on our website. As ++usual, you will find the signed tarballs in our download section: + +https://downloads.open-mesh.org/batman/releases/batman-adv-2019.4/ + +Thanks +------ + +Thanks to all people sending in patches: + +* Eric Dumazet edumazet@google.com ++* Florian Westphal fw@strlen.de ++* Krzysztof Kozlowski krzk@kernel.org +* Linus Lüssing linus.luessing@c0d3.blue +* Simon Wunderlich sw@simonwunderlich.de +* Sven Eckelmann sven@narfation.org + +batman-adv +---------- + +:: + + $ git describe origin/master + v2019.3-10-gbcadeaa3 - $ $ range=v2019.3..v2019.3-10-gbcadeaa3 ++ $ range=v2019.3..v2019.3-15-g888f60e5 + $ git shortlog --email --no-merges "${range}" + $ git log --no-merges "${range}"|grep -e '(Reported|Tested|Acked|Reviewed-by|Co-authored-by)-by'|sed 's/.*:/*/'|sort|uniq + ++ ++ new kernel support ++ ================== ++ ++ + coding style cleanup/refactoring + ================================ + + batman-adv: Replace usage of strlcpy with strscpy - ++ batman-adv: Fix Kconfig indentation ++ batman-adv: netfilter: drop bridge nf reset from nf_reset + + BATMAN V + ========= + + batman-adv: BATMAN_V: introduce per hard-iface OGMv2 queues + batman-adv: BATMAN_V: aggregate OGMv2 packets + - - + bugfixes + ======== + + batman-adv: fix uninit-value in batadv_netlink_get_ifindex() ++ batman-adv: Avoid free/alloc race when handling OGM2 buffer ++ batman-adv: Avoid free/alloc race when handling OGM2 buffer + + + + - 2019.4 (2019-09-23) ++ 2019.4 (2019-10-15) + =================== + + * support latest kernels (3.16 - 5.4) + * coding style cleanups and refactoring + * implement aggregation of OGM2 packets + * bugs squashed: + + - fix length validation in netlink messages + - fix out of buffer read when parsing aggregated packets - ++ - avoid race condition in OGM(2) packet modification and submission + +batctl +------ + +:: + + $ git describe origin/master + v2019.3-2-gdd82cf5 + $ range=v2019.3..v2019.3-2-gdd82cf5 + $ git shortlog --email --no-merges "${range}" + $ git log --no-merges "${range}"|grep -e '(Reported|Tested|Acked|Reviewed-by|Co-authored-by)-by'|sed 's/.*:/*/'|sort|uniq + + + tcpump + ====== + ++ + new command structure + ===================== + ++ + bugfix + ====== + + batctl: Fix deprecation warning for option '-m' + - - 2019.4 (2019-09-23) ++ 2019.4 (2019-10-15) + =================== + + * fix deprecation warning for option '-m' + +alfred +------ + +:: + + $ git describe origin/master + v2019.3-3-g0e0fcc5 + $ range=v2019.3..v2019.3-3-g0e0fcc5 + $ git shortlog --email --no-merges "${range}" + $ git log --no-merges "${range}"|grep -e '(Reported|Tested|Acked|Reviewed-by|Co-authored-by)-by'|sed 's/.*:/*/'|sort|uniq + + Sven Eckelmann sven@narfation.org (2): + alfred: vis: Add missing include for ifinfomsg + alfred: vis: Fix ifindex check when registering interface + - 2019.4 (2019-09-23) ++ ++ 2019.4 (2019-10-15) + =================== + + * fix build with musl + - +Happy routing, + +The B.A.T.M.A.N. team diff --cc open-mesh/OpenWrt_KGDB.rst index 0000000,0000000..2808a44 new file mode 100644 --- /dev/null +++ b/open-mesh/OpenWrt_KGDB.rst @@@ -1,0 -1,0 +1,271 @@@ ++.. SPDX-License-Identifier: GPL-2.0 ++ ++OpenWrt KGDB ++============ ++ ++The :doc:`Emulation Debug <Emulation_Debug>` documentation explains how to start multiple ++virtual Linux kernels+userspace, connect them and connect various ++helpers to test/debug a whole linux system. But some problems might only ++be reproducible on actual hardware. It is therefore sometimes necessary ++to debug a whole system. ++ ++In best case, the system can be `debugged using ++JTAG https://openwrt.org/docs/techref/hardware/port.jtag`__. But this ++is often not possible and an in-kernel gdb remote stub like ++`KGDB https://www.kernel.org/doc/html/latest/dev-tools/kgdb.html`__ ++has to be used. The only requirement it has on the actual board is a ++simple serial console. ++ ++Preparing OpenWrt ++----------------- ++ ++Disabling watchdog ++~~~~~~~~~~~~~~~~~~ ++ ++Most CPUs have some kind of watchdog integrated. They can often be ++disabled and are often inactive when the watchdog driver is not loaded. ++For example, ath79/ar71xx can be build without the internal watchdog ++support by changing in target/linux/{ar71xx,ath79}/config-*: ++ ++.. code-block:: diff ++ ++ -CONFIG_ATH79_WDT=y ++ +# CONFIG_ATH79_WDT is not set ++ ++Unfortunately, there are also external watchdog chips which cannot be ++disabled. They have to be manually triggered regularly during the ++debugging process to prevent a sudden reboot. The details depend on the ++actual hardware but it often ends up in writing to a specific (GPIO ++control/set/clear) register. ++ ++Enabling KGDB in kernel ++~~~~~~~~~~~~~~~~~~~~~~~ ++ ++The actual kernel gdbstub cannot be enabled via OpenWrt’s .config. ++Instead the actual configuration has to be set in the target ++configuration: ++ ++:: ++ ++ # CONFIG_STRICT_KERNEL_RWX is not set ++ CONFIG_FRAME_POINTER=y ++ CONFIG_KGDB=y ++ CONFIG_KGDB_SERIAL_CONSOLE=y ++ CONFIG_DEBUG_INFO=y ++ CONFIG_DEBUG_INFO_DWARF4=y ++ # CONFIG_DEBUG_INFO_REDUCED is not set ++ CONFIG_GDB_SCRIPTS=y ++ ++For x86-64, the change (mostly created using make kernel_menuconfig) ++would be: ++ ++.. code-block:: diff ++ ++ diff --git a/target/linux/x86/config-4.14 b/target/linux/x86/config-4.14 ++ index 014e7b275b..c6c6f871a9 100644 ++ --- a/target/linux/x86/config-4.14 ++ +++ b/target/linux/x86/config-4.14 ++ @@ -70,6 +70,7 @@ CONFIG_CLONE_BACKWARDS=y ++ CONFIG_COMMON_CLK=y ++ CONFIG_COMPAT_32=y ++ # CONFIG_COMPAT_VDSO is not set ++ +CONFIG_CONSOLE_POLL=y ++ CONFIG_CONSOLE_TRANSLATIONS=y ++ # CONFIG_CPU5_WDT is not set ++ CONFIG_CPU_FREQ=y ++ @@ -108,6 +109,9 @@ CONFIG_DCACHE_WORD_ACCESS=y ++ # CONFIG_DCDBAS is not set ++ # CONFIG_DEBUG_BOOT_PARAMS is not set ++ # CONFIG_DEBUG_ENTRY is not set ++ +CONFIG_DEBUG_INFO=y ++ +CONFIG_DEBUG_INFO_DWARF4=y ++ +# CONFIG_DEBUG_INFO_REDUCED is not set ++ CONFIG_DEBUG_MEMORY_INIT=y ++ # CONFIG_DEBUG_NMI_SELFTEST is not set ++ # CONFIG_DEBUG_TLBFLUSH is not set ++ @@ -144,6 +148,7 @@ CONFIG_FUSION=y ++ # CONFIG_FUSION_LOGGING is not set ++ CONFIG_FUSION_MAX_SGE=128 ++ CONFIG_FUSION_SPI=y ++ +CONFIG_GDB_SCRIPTS=y ++ CONFIG_GENERIC_ALLOCATOR=y ++ CONFIG_GENERIC_BUG=y ++ CONFIG_GENERIC_CLOCKEVENTS=y ++ @@ -288,6 +293,11 @@ CONFIG_KALLSYMS=y ++ CONFIG_KEXEC=y ++ CONFIG_KEXEC_CORE=y ++ CONFIG_KEYBOARD_ATKBD=y ++ +CONFIG_KGDB=y ++ +# CONFIG_KGDB_KDB is not set ++ +# CONFIG_KGDB_LOW_LEVEL_TRAP is not set ++ +CONFIG_KGDB_SERIAL_CONSOLE=y ++ +# CONFIG_KGDB_TESTS is not set ++ # CONFIG_LEDS_CLEVO_MAIL is not set ++ CONFIG_LIBNVDIMM=y ++ # CONFIG_M486 is not set ++ @@ -296,6 +306,7 @@ CONFIG_M586MMX=y ++ # CONFIG_M586TSC is not set ++ # CONFIG_M686 is not set ++ # CONFIG_MACHZ_WDT is not set ++ +CONFIG_MAGIC_SYSRQ=y ++ # CONFIG_MATOM is not set ++ # CONFIG_MCORE2 is not set ++ # CONFIG_MCRUSOE is not set ++ @@ -404,6 +415,7 @@ CONFIG_SCx200HR_TIMER=y ++ # CONFIG_SCx200_WDT is not set ++ # CONFIG_SERIAL_8250_FSL is not set ++ CONFIG_SERIAL_8250_PCI=y ++ +# CONFIG_SERIAL_KGDB_NMI is not set ++ CONFIG_SERIO=y ++ CONFIG_SERIO_I8042=y ++ CONFIG_SERIO_LIBPS2=y ++ diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile ++ index 84a3d88a7f..c8a017f970 100644 ++ --- a/target/linux/x86/image/Makefile ++ +++ b/target/linux/x86/image/Makefile ++ @@ -14,7 +14,7 @@ GRUB2_MODULES_ISO = biosdisk boot chain configfile iso9660 linux ls part_msdos r ++ GRUB_TERMINALS = ++ GRUB_SERIAL_CONFIG = ++ GRUB_TERMINAL_CONFIG = ++ -GRUB_CONSOLE_CMDLINE = ++ +GRUB_CONSOLE_CMDLINE = nokaslr ++ ++ USE_ATKBD = generic 64 ++ ++Enabling python support for gdb ++~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ++OpenWrt will build a gdb when ``CONFIG_GDB=y`` is set in .config. But this ++version is missing python support. But it can be enabled with following ++patch: ++ ++.. code-block:: diff ++ ++ diff --git a/toolchain/gdb/Makefile b/toolchain/gdb/Makefile ++ index 3b884f9e79..9b0149faca 100644 ++ --- a/toolchain/gdb/Makefile ++ +++ b/toolchain/gdb/Makefile ++ @@ -45,7 +45,7 @@ HOST_CONFIGURE_ARGS = \ ++ --without-included-gettext \ ++ --enable-threads \ ++ --with-expat \ ++ - --without-python \ ++ + --with-python \ ++ --disable-binutils \ ++ --disable-ld \ ++ --disable-gas \ ++ @@ -56,9 +56,11 @@ define Host/Install ++ $(INSTALL_BIN) $(HOST_BUILD_DIR)/gdb/gdb $(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)gdb ++ ln -fs $(TARGET_CROSS)gdb $(TOOLCHAIN_DIR)/bin/$(GNU_TARGET_NAME)-gdb ++ strip $(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)gdb ++ + $(MAKE) -C $(HOST_BUILD_DIR)/gdb/data-directory install ++ endef ++ ++ define Host/Clean ++ + $(MAKE) -C $(HOST_BUILD_DIR)/gdb/data-directory uninstall ++ rm -rf \ ++ $(HOST_BUILD_DIR) \ ++ $(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)gdb \ ++ ++Start debugging session ++----------------------- ++ ++Disable kASLR ++~~~~~~~~~~~~~ ++ ++The kernel address space layout randomization complicates the resolving ++of addresses of symbols. It is highly recommended to start the kernel ++with the parameter “nokaslr”. For example by adding it to CONFIG_CMDLINE ++or by adjusting the bootargs. It should be checked in /proc/cmdline ++whether it was really booted with this parameter. ++ ++Configure KGDB serial ++~~~~~~~~~~~~~~~~~~~~~ ++ ++The kgdb needs a serial device to work. This has to be set in the module ++parameter. We assume now that the serial console on our device is ttyS0 ++with baudrate 115200: ++ ++.. code-block:: sh ++ ++ echo ttyS0,115200 > /sys/module/kgdboc/parameters/kgdboc ++ ++Switch to kgdb ++~~~~~~~~~~~~~~ ++ ++The gdb frontend cannot directly talk to the kernel over serial and ++create breakpoints. The sysrq mechanism has to be used to switch to kgdb ++before gdb can be used. Under OpenWrt, this is the easily done using ++ ++.. code-block:: sh ++ ++ echo g > /proc/sysrq-trigger ++ ++Connecting gdb ++~~~~~~~~~~~~~~ ++ ++I would use following folder in my x86-64 build environment: ++ ++* ``LINUX_DIR=${OPENWRT_DIR}/build_dir/target-x86_64_musl/linux-x86_64/linux-4.14.148/`` ++* ``GDB=${OPENWRT_DIR}/staging_dir/toolchain-x86_64_gcc-7.4.0_musl/bin/x86_64-openwrt-linux-gdb`` ++* ``BATADV_DIR=${OPENWRT_DIR}/build_dir/target-x86_64_musl/linux-x86_64/batman-adv-2019.2/`` ++ ++When kgdb is activated using sysrq, we can configure gdb to connect via ++a serial adapter to the device. But we should first load the vmlinux ++with our target specific gdb. We must change to the LINUX_DIR first and ++can then start our GDB before we will connect to the remote device. ++ ++.. code-block:: sh ++ ++ cd "${LINUX_DIR}" ++ "${GDB}" -iex "set auto-load safe-path scripts/gdb/" ./vmlinux ++ ++In this example, we are using an USB TTL converter. It has to be ++configured in gdb ++ ++:: ++ ++ set serial baud 115200 ++ target remote /dev/ttyUSB0 ++ ++ lx-symbols .. ++ ++ continue ++ ++You should make sure that it doesn’t load any \ **.ko files from ++ipkg-**\ directories. These files are stripped and doesn’t contain the ++necessary symbol information. When necessary, just delete these folders ++or specify the folders with the unstripped kernel modules: ++ ++:: ++ ++ lx-symbols ../batman-adv-2019.2/.pkgdir/ ../backports-4.19.66-1/.pkgdir/ ../button-hotplug/.pkgdir/ ++ ++The rest of the usage now works similar to debugging using gdbserver. ++Just set some additional breakpoints and let the kernel run again. kgdb ++will then inform gdb whenever a breakpoints was hit. Just keep in mind ++that it is not possible to interrupt the kernel from gdb (without a Oops ++or an already existing breakpoint) - use sysrq from linux for that. ++ ++Some other ideas are documented in :ref:`Emulation Debug <open-mesh-open-mesh-emulation-debug-using-gdb>`. This ++document also contains important hints about ++:ref:`increasing the chance of getting debugable modules <open-mesh-open-mesh-emulation-debug-building-the-batman-adv-module>` ++which didn’t had all information ++optimized away. THe relevant flags could be set directly in the routing ++feed like this: ++ ++.. code-block:: diff ++ ++ diff --git a/batman-adv/Makefile b/batman-adv/Makefile ++ index a7c6a79..c18f978 100644 ++ --- a/batman-adv/Makefile ++ +++ b/batman-adv/Makefile ++ @@ -89,7 +89,7 @@ define Build/Compile ++ CROSS_COMPILE="$(TARGET_CROSS)" \ ++ SUBDIRS="$(PKG_BUILD_DIR)/net/batman-adv" \ ++ $(PKG_EXTRA_KCONFIG) \ ++ - EXTRA_CFLAGS="$(PKG_EXTRA_CFLAGS)" \ ++ + EXTRA_CFLAGS="$(PKG_EXTRA_CFLAGS) -fno-inline -Og -fno-optimize-sibling-calls" \ ++ NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \ ++ modules ++ endef diff --cc open-mesh/random.rst index a13e4c5,0000000..f821708 mode 100644,000000..100644 --- a/open-mesh/random.rst +++ b/open-mesh/random.rst @@@ -1,41 -1,0 +1,42 @@@ +.. SPDX-License-Identifier: GPL-2.0 + +====== +Random +====== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + BATMANConcept + Emulation + Emulation_Debug ++ OpenWrt_KGDB + FFTrace + Joker + MeshLinux + Logos + BatmanAdvBootLogo + NetworkingTechnologies + New_papers + News-archive + News-draft + ResearchProposals + Routing_scenarios + The-olsr-story + UsingBatmanGit + Gsoc2010-ideas + Gsoc2011-ideas + Gsoc2011-roadmap + Gsoc2012-ideas + Wbmv4-batmandev-agenda + Wbmv5-batmandev-agenda + Wbmv6-batmandev-agenda + +.. only:: subproject + + Indices + ======= + + * :ref:`genindex`