1.
flow.c 加上 OVS_LOG_INFO() compile時會有問題,已加上#include "Debug.h",一樣有其他問題
lib/flow.c:28:56: fatal error: Debug.h: No such file or directory
compilation terminated.
Makefile:4700: recipe for target 'lib/flow.lo' failed
make[2]: *** [lib/flow.lo] Error 1
make[2]: Leaving directory '/usr/local/ovs'
Makefile:5426: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/usr/local/ovs'
Makefile:3171: recipe for target 'all' failed
make: *** [all] Error 2
2. flow.c 加上 fprintf(fp, "%s %d", "ip_src", &nh->ip_src);
數值會跳。因為 &nh->ip_src 拿到的東西是記憶體位置,不是 ip_src 的值。
lib/flow.c: In function ‘miniflow_extract’:
lib/flow.c:779:20: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘const ovs_16aligned_be32 * {aka const struct <anonymous> *}’ [-Wformat=]
fprintf(fp,"%s %d" ,"ip_src", &nh->ip_src);
^
depbase=`echo lib/guarded-list.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
3. 在 flow.c 內,位置在 /usr/local/ovs/lib/flow.c 。
目前把 ip_src 跟 ip_dst 和 tot_len ,但 ip 顯示為十進制有機會成為負值,另 tot_len 僅為 L3 的長度,不包含L2。
%ld 就可以解決。 %d 不夠長的問題,會繞兩圈回來成為負值。
786 dp_packet_set_l2_pad_size(packet, size - tot_len);
787 size = tot_len; /* Never pull padding. */
788
789 //OVS_LOG_INFO("src_ip_20171111");
790 //OVS_LOG_INFO("dst_ip_20171111");
791 fp = fopen("flow_c.txt","a");
792 fprintf(fp,"ip_src = %d \n", nh->ip_src);
793 fprintf(fp,"ip_dst = %d \n", nh->ip_dst);
794 fprintf(fp,"tot_len= %d \n", tot_len);
795 fprintf(fp,"------------- \n");
796 fclose(fp);
797
798
799 /* Push both source and destination address at once. */
800 miniflow_push_words(mf, nw_src, &nh->ip_src, 1);
801 if (ct_nw_proto_p && !md->ct_orig_tuple_ipv6) {
lib/flow.c: In function ‘miniflow_extract’:
lib/flow.c:779:20: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ovs_16aligned_be32 {aka const struct <anonymous>}’ [-Wformat=]
fprintf(fp,"ip_src = %d \n", nh->ip_src);
^
lib/flow.c:780:20: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ovs_16aligned_be32 {aka const struct <anonymous>}’ [-Wformat=]
fprintf(fp,"ip_dst = %d \n", nh->ip_dst);
4. print uint32_t 的問題
%ld 就可以解決
lib/flow.c: In function ‘miniflow_extract’:
lib/flow.c:792:20: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ovs_16aligned_be32 {aka const struct <anonymous>}’ [-Wformat=]
fprintf(fp,"ip_src = %d \n", nh->ip_src);
^
lib/flow.c:793:20: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ovs_16aligned_be32 {aka const struct <anonymous>}’ [-Wformat=]
fprintf(fp,"ip_dst = %d \n", nh->ip_dst);
^
lib/flow.c:794:24: error: expected ‘)’ before ‘PRlu32’
fprintf(fp,"%" PRlu32 "\n", nh->ip_dst);
^
lib/flow.c:794:20: warning: spurious trailing ‘%’ in format [-Wformat=]
fprintf(fp,"%" PRlu32 "\n", nh->ip_dst);
^
lib/flow.c:795:9: error: aggregate value used where an integer was expected
fprintf(fp,"%u\n",(unsigned int)nh->ip_dst);
^
Makefile:4700: recipe for target 'lib/flow.lo' failed
make[2]: *** [lib/flow.lo] Error 1
make[2]: Leaving directory '/usr/local/ovs'
Makefile:5426: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/usr/local/ovs'
Makefile:3171: recipe for target 'all' failed
make: *** [all] Error 2
ll