# # To execute this run script on your Linux host you have to do some # preparation: # # 1) Setup a TAP device: # ! sudo ip tuntap add dev tap0 mode tap user $USER # ! sudo ip address flush dev tap0 # ! sudo ip address add 10.0.2.1/24 brd 10.0.2.255 dev tap0 # ! sudo ip link set dev tap0 addr 02:00:00:ca:fe:01 # ! sudo ip link set dev tap0 up # # 2) Ensure that 'nping' is installed and that it is permitted run # UDP mode as user (examplary for Ubuntu 18.04): # ! sudo apt install nmap # ! sudo setcap cap_net_raw=+ep /usr/bin/nping # # 3) Now, start the test: # ! cd build/x86_64 # ! make run/nic_router_ipv4_fragm KERNEL=linux BOARD=linux # # 4) Clean up your Linux when done testing: # ! sudo ip tuntap delete tap0 mode tap # if {![have_board linux]} { puts "Run script is not supported on this platform." exit 0 } set nping_missing [catch { spawn nping --version expect { {Nping version} { } eof { return } timeout { return } } }] if {$nping_missing} { puts "\nPlease install 'nping' and try again\n" exit 1; } create_boot_directory import_from_depot [depot_user]/pkg/[drivers_nic_pkg] build { core lib/ld init timer lib/libc lib/libm lib/vfs lib/vfs_lwip server/nic_router app/ping test/lwip/udp server/report_rom } install_config { } build_boot_image [build_artifacts] # wait for server ip stack to come up run_genode_until {.*lwIP Nic interface up.*\n} 30 set genode_id [output_spawn_id] # ping server without ipv4 fragmentation (should succeed) spawn nping -c 1 --privileged --udp --data-length 160 --mtu 800 -p 8000 10.0.2.55 set pattern_string "" append pattern_string {.*RCVD .* UDP 10\.0\.2\.55:8000 > 10\.0\.2\.1:53 .*\n} append pattern_string {.*Raw packets sent: 1 (188B) | Rcvd: 1 (188B) | Lost: 0.*\n} run_genode_until $pattern_string 30 $spawn_id # ping server with ipv4 fragmentation (should fail) spawn nping -c 1 --privileged --udp --data-length 1600 --mtu 800 -p 8000 10.0.2.55 set pattern_string "" append pattern_string {.*RCVD .* ICMP .*10\.0\.2\.55 > 10\.0\.2\.1 Fragmentation required.*\n} append pattern_string {.*RCVD .* ICMP .*10\.0\.2\.55 > 10\.0\.2\.1 Fragmentation required.*\n} append pattern_string {.*RCVD .* ICMP .*10\.0\.2\.55 > 10\.0\.2\.1 Fragmentation required.*\n} run_genode_until $pattern_string 30 $spawn_id # check that the nic router dropped the ipv4 fragments of the second ping set pattern_string "" append pattern_string {.*snd .*IPV4.* 10\.0\.2\.55 > 10\.0\.2\.1 .*ICMP.* 3 4.*\n} append pattern_string {.*drop packet .fragmented IPv4 not supported.*\n} append pattern_string {.*snd .*IPV4.* 10\.0\.2\.55 > 10\.0\.2\.1 .*ICMP.* 3 4.*\n} append pattern_string {.*drop packet .fragmented IPv4 not supported.*\n} append pattern_string {.*snd .*IPV4.* 10\.0\.2\.55 > 10\.0\.2\.1 .*ICMP.* 3 4.*\n} append pattern_string {.*drop packet .fragmented IPv4 not supported.*\n} append pattern_string {.*.*\n} run_genode_until $pattern_string 30 $genode_id