github.com/zhyoulun/cilium@v1.6.12/test/bpf/check-complexity.sh (about) 1 #!/bin/bash 2 # 3 # Copyright 2018 Authors of Cilium 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 set -eo pipefail 18 19 TESTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" 20 BPFDIR="$TESTDIR/../../bpf/" 21 22 function get_insn_cnt { 23 grep -e "^Prog" -e processed -e "Proccessed" -e "^=>" -e "over limit" 24 } 25 26 # These are derived from bpf/lib/common.h CILIUM_CALL_*. 27 function annotate_section_names { 28 sed -e "s/\(section \)'\(1\)\/\([0-9x]*\)'/\1'\2\/\3' (lxc ingress program for EP \3)/" \ 29 -e "s/\(section '2\/1'\)/\1 (tail_call DROP_NOTIFY)/" \ 30 -e "s/\(section '2\/2'\)/\1 (tail_call ERROR_NOTIFY)/" \ 31 -e "s/\(section '2\/3'\)/\1 (tail_call SEND_ICMP6_ECHO_REPLY)/" \ 32 -e "s/\(section '2\/4'\)/\1 (tail_call HANDLE_ICMP6_NS)/" \ 33 -e "s/\(section '2\/5'\)/\1 (tail_call SEND_ICMP6_TIME_EXCEEDED)/" \ 34 -e "s/\(section '2\/6'\)/\1 (tail_call ARP)/" \ 35 -e "s/\(section '2\/7'\)/\1 (tail_call IPV4_FROM_LXC)/" \ 36 -e "s/\(section '2\/8'\)/\1 (tail_call NAT64)/" \ 37 -e "s/\(section '2\/9'\)/\1 (tail_call NAT46)/" \ 38 -e "s/\(section '2\/10'\)/\1 (tail_call IPV6_FROM_LXC)/" \ 39 -e "s/\(section '2\/11'\)/\1 (tail_call IPV4_TO_LXC_POLICY_ONLY)/" \ 40 -e "s/\(section '2\/12'\)/\1 (tail_call IPV6_TO_LXC_POLICY_ONLY)/" \ 41 -e "s/\(section '2\/13'\)/\1 (tail_call IPV4_TO_ENDPOINT)/" \ 42 -e "s/\(section '2\/14'\)/\1 (tail_call IPV6_TO_ENDPOINT)/" \ 43 -e "s/\(section '2\/15'\)/\1 (tail_call IPV4_NODEPORT_NAT)/" \ 44 -e "s/\(section '2\/16'\)/\1 (tail_call IPV6_NODEPORT_NAT)/" \ 45 -e "s/\(section '2\/17'\)/\1 (tail_call IPV4_NODEPORT_REVNAT)/" \ 46 -e "s/\(section '2\/18'\)/\1 (tail_call IPV6_NODEPORT_REVNAT)/" \ 47 -e "s/\(section '2\/19'\)/\1 (tail_call ENCAP_NODEPORT_NAT)/" 48 } 49 50 if ! grep -q "CILIUM_CALL_SIZE.*20" "$BPFDIR/lib/common.h" ; then 51 echo "This script is out of date compared to CILIUM_CALL_SIZE." 1>&2 52 exit 1 53 fi 54 55 "$TESTDIR/verifier-test.sh" -v | get_insn_cnt | annotate_section_names