test_cls_bpf.sh 880 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash
  2. function pktgen {
  3. ../pktgen/pktgen_bench_xmit_mode_netif_receive.sh -i $IFC -s 64 \
  4. -m 90:e2:ba:ff:ff:ff -d 192.168.0.1 -t 4
  5. local dropped=`tc -s qdisc show dev $IFC | tail -3 | awk '/drop/{print $7}'`
  6. if [ "$dropped" == "0," ]; then
  7. echo "FAIL"
  8. else
  9. echo "Successfully filtered " $dropped " packets"
  10. fi
  11. }
  12. function test {
  13. echo -n "Loading bpf program '$2'... "
  14. tc qdisc add dev $IFC clsact
  15. tc filter add dev $IFC ingress bpf da obj $1 sec $2
  16. local status=$?
  17. if [ $status -ne 0 ]; then
  18. echo "FAIL"
  19. else
  20. echo "ok"
  21. pktgen
  22. fi
  23. tc qdisc del dev $IFC clsact
  24. }
  25. IFC=test_veth
  26. ip link add name $IFC type veth peer name pair_$IFC
  27. ip link set $IFC up
  28. ip link set pair_$IFC up
  29. test ./parse_simple.o simple
  30. test ./parse_varlen.o varlen
  31. test ./parse_ldabs.o ldabs
  32. ip link del dev $IFC