一、版本配套
Ubuntu16.04 LTS + Python 2.7 + P4(protobuf,bmv2,p4c)
参考链接:
https://github.com/p4lang/tutorials/blob/master/vm/user-bootstrap.sh (只需安装protobuf,bmv2,p4c) https://blog.csdn.net/sheen_zhuang/article/details/80725575
二、Protobuf安装:
命令执行:
git clone https://github.com/google/protobuf.git cd protobuf export CFLAGS="-Os" export CXXFLAGS="-Os" export LDFLAGS="-Wl,-s" ./autogen.sh ./configure --prefix=/usr make -j `grep -c ^processor /proc/cpuinfo` make install ldconfig unset CFLAGS CXXFLAGS LDFLAGS # force install python module cd python python setup.py install cd ../..
三、bmv2安装
进入bmv2目录 cd ~/bmv2 安装依赖 ./install_deps.sh 编译bmv2 ./autogen.sh ./configure make 安装bmv2 make install 更新共享库 ldconfig 单元测试,如果出错用sudo make check
四、P4C安装
# P4C git clone https://github.com/p4lang/p4c cd p4c git checkout ${P4C_COMMIT} git submodule update --init --recursive mkdir -p build cd build apt-get install g++ git automake libtool libgc-dev bison flex libfl-dev libgmp-dev libboost-dev libboost-iostreams-dev pkg-config python python-scapy python-ipaddr tcpdump cmake cmake .. make -j `grep -c ^processor /proc/cpuinfo` make -j `grep -c ^processor /proc/cpuinfo` check #耗时较长 make install ldconfig cd .. cd ..
执行 make -j `grep -c ^processor /proc/cpuinfo` check 结果信息
82% tests passed, 203 tests failed out of 1121 Label Time Summary: XFAIL = 11.48 sec (13 tests) bmv2 = 1184.96 sec (310 tests) cpplint = 20.13 sec (1 test) ebpf-bcc = 1.60 sec (13 tests) ebpf-test = 1.74 sec (13 tests) gtest = 7.08 sec (1 test) p14_to_16 = 551.19 sec (195 tests) p4 = 204.14 sec (588 tests) Total Test time (real) = 1971.70 sec The following tests FAILED: 312 - ebpf-bcc/testdata/p4_16_samples/hit_ebpf.p4 (Failed) 313 - ebpf-bcc/testdata/p4_16_samples/count_ebpf.p4 (Failed) 314 - ebpf-bcc/testdata/p4_16_samples/test_ebpf.p4 (Failed) 315 - ebpf-bcc/testdata/p4_16_samples/key_ebpf.p4 (Failed) 316 - ebpf-bcc/testdata/p4_16_samples/issue870_ebpf.p4 (Failed) 317 - ebpf-bcc/testdata/p4_16_samples/init_ebpf.p4 (Failed) 318 - ebpf-bcc/testdata/p4_16_samples/valid_ebpf.p4 (Failed) 319 - ebpf-bcc/testdata/p4_16_samples/switch_ebpf.p4 (Failed) 320 - ebpf-bcc/testdata/p4_16_samples/bool_ebpf.p4 (Failed) 321 - ebpf-bcc/testdata/p4_16_samples/two_ebpf.p4 (Failed) 322 - ebpf-bcc/testdata/p4_16_samples/action_call_ebpf.p4 (Failed) 323 - ebpf-bcc/testdata/p4_16_samples/action_call_table_ebpf.p4 (Failed) 324 - ebpf-bcc/testdata/p4_16_samples/key-issue-1020_ebpf.p4 (Failed) 325 - ebpf-test/testdata/p4_16_samples/hit_ebpf.p4 (Failed) 326 - ebpf-test/testdata/p4_16_samples/count_ebpf.p4 (Failed) 327 - ebpf-test/testdata/p4_16_samples/test_ebpf.p4 (Failed) 328 - ebpf-test/testdata/p4_16_samples/key_ebpf.p4 (Failed) 329 - ebpf-test/testdata/p4_16_samples/issue870_ebpf.p4 (Failed) 330 - ebpf-test/testdata/p4_16_samples/init_ebpf.p4 (Failed) 331 - ebpf-test/testdata/p4_16_samples/valid_ebpf.p4 (Failed) 332 - ebpf-test/testdata/p4_16_samples/switch_ebpf.p4 (Failed) 333 - ebpf-test/testdata/p4_16_samples/bool_ebpf.p4 (Failed) 334 - ebpf-test/testdata/p4_16_samples/two_ebpf.p4 (Failed) 335 - ebpf-test/testdata/p4_16_samples/action_call_ebpf.p4 (Failed) 336 - ebpf-test/testdata/p4_16_samples/action_call_table_ebpf.p4 (Failed) 337 - ebpf-test/testdata/p4_16_samples/key-issue-1020_ebpf.p4 (Failed) 492 - p4/testdata/p4_16_samples/issue635-bmv2.p4 (Failed) 495 - p4/testdata/p4_16_samples/junk-prop-bmv2.p4 (Failed) 500 - p4/testdata/p4_16_samples/named_meter_1-bmv2.p4 (Failed) 502 - p4/testdata/p4_16_samples/inline-bmv2.p4 (Failed) 506 - p4/testdata/p4_16_samples/slice-def-use1.p4 (Failed) 511 - p4/testdata/p4_16_samples/issue1049-bmv2.p4 (Failed) 512 - p4/testdata/p4_16_samples/psa-counter2.p4 (Failed) 513 - p4/testdata/p4_16_samples/issue907-bmv2.p4 (Failed) 515 - p4/testdata/p4_16_samples/issue1406.p4 (Failed) 517 - p4/testdata/p4_16_samples/issue355-bmv2.p4 (Failed) 522 - p4/testdata/p4_16_samples/issue737-bmv2.p4 (Failed) 530 - p4/testdata/p4_16_samples/crc32-bmv2.p4 (Failed) 532 - p4/testdata/p4_16_samples/bitwise-and.p4 (Failed) 535 - p4/testdata/p4_16_samples/mux-bmv2.p4 (Failed) 536 - p4/testdata/p4_16_samples/default_action-bmv2.p4 (Failed) 537 - p4/testdata/p4_16_samples/psa-register2.p4 (Failed) 538 - p4/testdata/p4_16_samples/union4-bmv2.p4 (Failed) 539 - p4/testdata/p4_16_samples/arith3-bmv2.p4 (Failed) 547 - p4/testdata/p4_16_samples/issue887.p4 (Failed) 550 - p4/testdata/p4_16_samples/issue447-5-bmv2.p4 (Failed) 551 - p4/testdata/p4_16_samples/issue1079-bmv2.p4 (Failed) 552 - p4/testdata/p4_16_samples/key-bmv2.p4 (Failed) 553 - p4/testdata/p4_16_samples/psa-meter6.p4 (Failed) 555 - p4/testdata/p4_16_samples/basic_routing-bmv2.p4 (Failed) 559 - p4/testdata/p4_16_samples/issue414-bmv2.p4 (Failed) 561 - p4/testdata/p4_16_samples/table-entries-exact-bmv2.p4 (Failed) 563 - p4/testdata/p4_16_samples/issue841.p4 (Failed) 566 - p4/testdata/p4_16_samples/issue1386.p4 (Failed) 567 - p4/testdata/p4_16_samples/constant-in-calculation-bmv2.p4 (Failed) 568 - p4/testdata/p4_16_samples/issue655.p4 (Failed) 569 - p4/testdata/p4_16_samples/checksum1-bmv2.p4 (Failed) 571 - p4/testdata/p4_16_samples/psa-action-selector2.p4 (Failed) 573 - p4/testdata/p4_16_samples/issue1208-1.p4 (Failed) 576 - p4/testdata/p4_16_samples/issue914-bmv2.p4 (Failed) 579 - p4/testdata/p4_16_samples/ternary2-bmv2.p4 (Failed) 580 - p4/testdata/p4_16_samples/issue323.p4 (Failed) 581 - p4/testdata/p4_16_samples/psa-action-selector3.p4 (Failed) 583 - p4/testdata/p4_16_samples/scalarmeta-bmv2.p4 (Failed) 585 - p4/testdata/p4_16_samples/issue447-1-bmv2.p4 (Failed) 586 - p4/testdata/p4_16_samples/verify-bmv2.p4 (Failed) 587 - p4/testdata/p4_16_samples/arith4-bmv2.p4 (Failed) 588 - p4/testdata/p4_16_samples/def-use.p4 (Failed) 589 - p4/testdata/p4_16_samples/extern-funcs-bmv2.p4 (Failed) 591 - p4/testdata/p4_16_samples/issue407-3.p4 (Failed) 593 - p4/testdata/p4_16_samples/array-copy-bmv2.p4 (Failed) 594 - p4/testdata/p4_16_samples/issue486-bmv2.p4 (Failed) 596 - p4/testdata/p4_16_samples/issue1043-bmv2.p4 (Failed) 602 - p4/testdata/p4_16_samples/union2-bmv2.p4 (Failed) 607 - p4/testdata/p4_16_samples/psa-random.p4 (Failed) 608 - p4/testdata/p4_16_samples/issue232-bmv2.p4 (Failed) 615 - p4/testdata/p4_16_samples/issue422.p4 (Failed) 617 - p4/testdata/p4_16_samples/drop-bmv2.p4 (Failed) 623 - p4/testdata/p4_16_samples/issue1304.p4 (Failed) 624 - p4/testdata/p4_16_samples/issue1193-bmv2.p4 (Failed) 625 - p4/testdata/p4_16_samples/stack_complex-bmv2.p4 (Failed) 630 - p4/testdata/p4_16_samples/named_meter_bmv2.p4 (Failed) 634 - p4/testdata/p4_16_samples/issue430-bmv2.p4 (Failed) 635 - p4/testdata/p4_16_samples/issue461-bmv2.p4 (Failed) 636 - p4/testdata/p4_16_samples/intrinsic-bmv2.p4 (Failed) 638 - p4/testdata/p4_16_samples/issue447-2-bmv2.p4 (Failed) 641 - p4/testdata/p4_16_samples/issue447-bmv2.p4 (Failed) 643 - p4/testdata/p4_16_samples/x-bmv2.p4 (Failed) 646 - p4/testdata/p4_16_samples/psa-meter3.p4 (Failed) 647 - p4/testdata/p4_16_samples/arith5-bmv2.p4 (Failed) 648 - p4/testdata/p4_16_samples/noMatch.p4 (Failed) 650 - p4/testdata/p4_16_samples/issue891-bmv2.p4 (Failed) 651 - p4/testdata/p4_16_samples/issue510-bmv2.p4 (Failed) 653 - p4/testdata/p4_16_samples/arith2-inline-bmv2.p4 (Failed) 654 - p4/testdata/p4_16_samples/flag_lost-bmv2.p4 (Failed) 656 - p4/testdata/p4_16_samples/psa-example-digest-bmv2.p4 (Failed) 658 - p4/testdata/p4_16_samples/psa-example-register2-bmv2.p4 (Failed) 663 - p4/testdata/p4_16_samples/pvs-nested-struct.p4 (Failed) 664 - p4/testdata/p4_16_samples/psa-counter6.p4 (Failed) 667 - p4/testdata/p4_16_samples/psa-action-profile3.p4 (Failed) 671 - p4/testdata/p4_16_samples/issue270-bmv2.p4 (Failed) 672 - p4/testdata/p4_16_samples/equality-bmv2.p4 (Failed) 673 - p4/testdata/p4_16_samples/issue1412-bmv2.p4 (Failed) 674 - p4/testdata/p4_16_samples/saturated-bmv2.p4 (Failed) 675 - p4/testdata/p4_16_samples/issue281.p4 (Failed) 677 - p4/testdata/p4_16_samples/issue1409-bmv2.p4 (Failed) 678 - p4/testdata/p4_16_samples/issue512.p4 (Failed) 679 - p4/testdata/p4_16_samples/psa-hash.p4 (Failed) 681 - p4/testdata/p4_16_samples/issue249.p4 (Failed) 686 - p4/testdata/p4_16_samples/action-synth.p4 (Failed) 687 - p4/testdata/p4_16_samples/slice-def-use.p4 (Failed) 696 - p4/testdata/p4_16_samples/header-stack-ops-bmv2.p4 (Failed) 697 - p4/testdata/p4_16_samples/psa-action-profile1.p4 (Failed) 698 - p4/testdata/p4_16_samples/psa-action-profile2.p4 (Failed) 700 - p4/testdata/p4_16_samples/arith-bmv2.p4 (Failed) 705 - p4/testdata/p4_16_samples/pred1.p4 (Failed) 706 - p4/testdata/p4_16_samples/arith2-bmv2.p4 (Failed) 707 - p4/testdata/p4_16_samples/issue1097-2-bmv2.p4 (Failed) 708 - p4/testdata/p4_16_samples/psa-action-selector1.p4 (Failed) 709 - p4/testdata/p4_16_samples/header-bmv2.p4 (Failed) 718 - p4/testdata/p4_16_samples/psa-counter1.p4 (Failed) 719 - p4/testdata/p4_16_samples/hash-bmv2.p4 (Failed) 722 - p4/testdata/p4_16_samples/issue242.p4 (Failed) 724 - p4/testdata/p4_16_samples/issue496.p4 (Failed) 727 - p4/testdata/p4_16_samples/issue364-bmv2.p4 (Failed) 728 - p4/testdata/p4_16_samples/issue420.p4 (Failed) 730 - p4/testdata/p4_16_samples/issue584-1.p4 (Failed) 731 - p4/testdata/p4_16_samples/issue1000-bmv2.p4 (Failed) 733 - p4/testdata/p4_16_samples/issue1062-1-bmv2.p4 (Failed) 734 - p4/testdata/p4_16_samples/issue361-bmv2.p4 (Failed) 735 - p4/testdata/p4_16_samples/issue430-1-bmv2.p4 (Failed) 736 - p4/testdata/p4_16_samples/issue1325-bmv2.p4 (Failed) 742 - p4/testdata/p4_16_samples/psa-meter4.p4 (Failed) 743 - p4/testdata/p4_16_samples/psa-test.p4 (Failed) 744 - p4/testdata/p4_16_samples/union3-bmv2.p4 (Failed) 745 - p4/testdata/p4_16_samples/issue1025-bmv2.p4 (Failed) 746 - p4/testdata/p4_16_samples/issue774-4-bmv2.p4 (Failed) 748 - p4/testdata/p4_16_samples/issue696-bmv2.p4 (Failed) 749 - p4/testdata/p4_16_samples/issue955.p4 (Failed) 751 - p4/testdata/p4_16_samples/action_selector_unused-bmv2.p4 (Failed) 752 - p4/testdata/p4_16_samples/pred2.p4 (Failed) 754 - p4/testdata/p4_16_samples/issue356-bmv2.p4 (Failed) 755 - p4/testdata/p4_16_samples/arith1-bmv2.p4 (Failed) 760 - p4/testdata/p4_16_samples/issue1352-bmv2.p4 (Failed) 763 - p4/testdata/p4_16_samples/psa-fwd-bmv2.p4 (Failed) 764 - p4/testdata/p4_16_samples/issue677-bmv2.p4 (Failed) 766 - p4/testdata/p4_16_samples/action_selector_shared-bmv2.p4 (Failed) 768 - p4/testdata/p4_16_samples/issue407-2.p4 (Failed) 770 - p4/testdata/p4_16_samples/action_profile-bmv2.p4 (Failed) 774 - p4/testdata/p4_16_samples/psa-action-profile4.p4 (Failed) 776 - p4/testdata/p4_16_samples/issue447-3-bmv2.p4 (Failed) 778 - p4/testdata/p4_16_samples/inline-stack-bmv2.p4 (Failed) 779 - p4/testdata/p4_16_samples/issue272-2-bmv2.p4 (Failed) 780 - p4/testdata/p4_16_samples/union-valid-bmv2.p4 (Failed) 788 - p4/testdata/p4_16_samples/issue995-bmv2.p4 (Failed) 790 - p4/testdata/p4_16_samples/psa-register3.p4 (Failed) 792 - p4/testdata/p4_16_samples/stack-bmv2.p4 (Failed) 800 - p4/testdata/p4_16_samples/std_meta_inlining.p4 (Failed) 803 - p4/testdata/p4_16_samples/equality-varbit-bmv2.p4 (Failed) 804 - p4/testdata/p4_16_samples/key1-bmv2.p4 (Failed) 809 - p4/testdata/p4_16_samples/issue983-bmv2.p4 (Failed) 810 - p4/testdata/p4_16_samples/psa-counter4.p4 (Failed) 816 - p4/testdata/p4_16_samples/union1-bmv2.p4 (Failed) 817 - p4/testdata/p4_16_samples/issue986-1-bmv2.p4 (Failed) 818 - p4/testdata/p4_16_samples/issue298-bmv2.p4 (Failed) 821 - p4/testdata/p4_16_samples/issue655-bmv2.p4 (Failed) 823 - p4/testdata/p4_16_samples/issue1107.p4 (Failed) 826 - p4/testdata/p4_16_samples/enum-bmv2.p4 (Failed) 832 - p4/testdata/p4_16_samples/hit-expr.p4 (Failed) 836 - p4/testdata/p4_16_samples/issue1097-bmv2.p4 (Failed) 837 - p4/testdata/p4_16_samples/issue986-bmv2.p4 (Failed) 843 - p4/testdata/p4_16_samples/table-entries-valid-bmv2.p4 (Failed) 845 - p4/testdata/p4_16_samples/issue134-bmv2.p4 (Failed) 847 - p4/testdata/p4_16_samples/table-entries-range-bmv2.p4 (Failed) 850 - p4/testdata/p4_16_samples/pvs-struct.p4 (Failed) 851 - p4/testdata/p4_16_samples/issue272-1-bmv2.p4 (Failed) 852 - p4/testdata/p4_16_samples/psa-meter5.p4 (Failed) 855 - p4/testdata/p4_16_samples/psa-counter3.p4 (Failed) 856 - p4/testdata/p4_16_samples/issue1291-bmv2.p4 (Failed) 859 - p4/testdata/p4_16_samples/arith-inline-bmv2.p4 (Failed) 860 - p4/testdata/p4_16_samples/unused-counter-bmv2.p4 (Failed) 862 - p4/testdata/p4_16_samples/multicast-bmv2.p4 (Failed) 866 - p4/testdata/p4_16_samples/union-bmv2.p4 (Failed) 868 - p4/testdata/p4_16_samples/issue1127-bmv2.p4 (Failed) 870 - p4/testdata/p4_16_samples/pred.p4 (Failed) 872 - p4/testdata/p4_16_samples/issue949.p4 (Failed) 873 - p4/testdata/p4_16_samples/issue447-4-bmv2.p4 (Failed) 876 - p4/testdata/p4_16_samples/subparser-with-header-stack-bmv2.p4 (Failed) 877 - p4/testdata/p4_16_samples/table-entries-exact-ternary-bmv2.p4 (Failed) 880 - p4/testdata/p4_16_samples/psa-example-counters-bmv2.p4 (Failed) 886 - p4/testdata/p4_16_samples/table-entries-priority-bmv2.p4 (Failed) 894 - p4/testdata/p4_16_samples/parser-locals2.p4 (Failed) 898 - p4/testdata/p4_16_samples/concat-bmv2.p4 (Failed) 900 - p4/testdata/p4_16_samples/issue1001-bmv2.p4 (Failed) 902 - p4/testdata/p4_16_samples/psa-register1.p4 (Failed) 905 - p4/testdata/p4_16_samples/issue297-bmv2.p4 (Failed) 908 - p4/testdata/p4_16_samples/flowlet_switching-bmv2.p4 (Failed) 910 - p4/testdata/p4_16_samples/table-entries-lpm-bmv2.p4 (Failed) 915 - p4/testdata/p4_16_samples/issue1210.p4 (Failed) 916 - p4/testdata/p4_16_samples/table-entries-ternary-bmv2.p4 (Failed) 917 - p4/testdata/p4_16_samples/clone-bmv2.p4 (Failed) 920 - p4/testdata/p4_16_samples/inline1-bmv2.p4 (Failed) 1121 - gtestp4c (Failed) Errors while running CTest CMakeFiles/check-all.dir/build.make:57: recipe for target 'CMakeFiles/check-all' failed make[3]: *** [CMakeFiles/check-all] Error 8 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/check-all.dir/all' failed make[2]: *** [CMakeFiles/check-all.dir/all] Error 2 CMakeFiles/Makefile2:234: recipe for target 'CMakeFiles/check.dir/rule' failed make[1]: *** [CMakeFiles/check.dir/rule] Error 2 Makefile:238: recipe for target 'check' failed make: *** [check] Error 2