diff options
| author | lijia <[email protected]> | 2020-06-05 19:15:10 +0800 |
|---|---|---|
| committer | lijia <[email protected]> | 2020-06-05 19:15:10 +0800 |
| commit | e30e056c54f59b1bfaf600ff76165d7d7680d4e0 (patch) | |
| tree | 64d944b246004cb9eab248ecb822ec95cc304e7d | |
| parent | 91cbc1bcfca41c99043ce73de4aa2add81dfcb26 (diff) | |
按虚链路ID发包功能, 改为使用接口marsio_buff_set_rehash_index()设置rehash, 而不是设置ctrlzone的变量;
| -rw-r--r-- | include/support/marsio_for_view.h | 12 | ||||
| -rw-r--r-- | src/packet_io/packet_io_lib_load.c | 2 | ||||
| -rw-r--r-- | src/packet_io/sendpacket.c | 26 | ||||
| -rw-r--r-- | test/test_app_sapp.c | 35 | ||||
| -rw-r--r-- | test/test_sendpacket_performance.c | 30 |
5 files changed, 98 insertions, 7 deletions
diff --git a/include/support/marsio_for_view.h b/include/support/marsio_for_view.h index d2d6239..6905dd0 100644 --- a/include/support/marsio_for_view.h +++ b/include/support/marsio_for_view.h @@ -203,6 +203,16 @@ int marsio_buff_is_ctrlbuf(marsio_buff_t * m); void marsio_buff_set_ctrlbuf(marsio_buff_t *m);
+uint64_t marsio_buff_get_timestamp(marsio_buff_t *m);
+void marsio_buff_set_timestamp(marsio_buff_t *m, uint64_t timestamp);
+int marsio_buff_get_timestamp_ex(marsio_buff_t * m, enum mr_timestamp_type ts_type, struct timespec * ts);
+
+void marsio_buff_set_rehash_index(marsio_buff_t *m, uint32_t hash);
+uint32_t marsio_buff_get_rehash_index(marsio_buff_t * m);
+
+void * marsio_shared_mem_alloc(struct mr_instance * instance, size_t len);
+void marsio_shared_mem_free(struct mr_instance * instance, void * mem);
+
#ifdef __cplusplus
}
-#endif
\ No newline at end of file +#endif
diff --git a/src/packet_io/packet_io_lib_load.c b/src/packet_io/packet_io_lib_load.c index cb4ca1c..5931dc1 100644 --- a/src/packet_io/packet_io_lib_load.c +++ b/src/packet_io/packet_io_lib_load.c @@ -152,7 +152,7 @@ static int packet_io_lib_load_by_mode(int cap_mode, const char *no_use) //dl_io_fun_list_static_link[CAP_MODEL_MARSIOV4].dl_io_register_exit_cb = (int (*)(PACKET_IO_EXIT_CB_T exit_fun))marsio_dl_io_register_exit_cb; dl_io_fun_list_static_link[CAP_MODEL_MARSIOV4].dl_io_get_version = (int (*)(void))marsio_dl_io_get_version; dl_io_fun_list_static_link[CAP_MODEL_MARSIOV4].dl_io_device_alias = (void * (*)(unsigned int , char *))marsio_dl_io_device_alias; - dl_io_fun_list_static_link[CAP_MODEL_PCAP_ONLINE].dl_io_send_only_thread_init = (int (*)(void))marsio_dl_io_send_only_thread_init; + dl_io_fun_list_static_link[CAP_MODEL_MARSIOV4].dl_io_send_only_thread_init = (int (*)(void))marsio_dl_io_send_only_thread_init; } #endif diff --git a/src/packet_io/sendpacket.c b/src/packet_io/sendpacket.c index fe38d98..9df73e5 100644 --- a/src/packet_io/sendpacket.c +++ b/src/packet_io/sendpacket.c @@ -3775,8 +3775,10 @@ static void sapp_fakepacket_set_vxlan_options(struct mr_tunnat_ctrlzone *mr_ctrl break; case SAPP_SEND_OPT_REHASH_INDEX: - mr_ctrlzone->rehash_index = option->long_value; - mr_ctrlzone->action |= TUNNAT_CZ_ACTION_ENCAP_VIRTUAL_LINK_ID; + /* rehash_index������ctrlzone������, Ҫͨ���ӿ�marsio_buff_set_rehash_index() */ + //mr_ctrlzone->rehash_index = option->long_value; + //mr_ctrlzone->action |= TUNNAT_CZ_ACTION_ENCAP_VIRTUAL_LINK_ID; + sapp_runtime_log(30, "sendpacket set vxlan options error, cat't set REHASH_INDEX in ctrlzone\n"); break; case SAPP_SEND_OPT_VXLAN_FLAGS: @@ -3828,6 +3830,8 @@ static int __MESA_sendpacket_iplayer_options(int thread_index,const char *data, memcpy(inner_ehdr->ether_shost, options[i].array_value, ETHER_ADDR_LEN); }else if(SAPP_SEND_OPT_INNER_DMAC == options[i].type){ memcpy(inner_ehdr->ether_dhost, options[i].array_value, ETHER_ADDR_LEN); + }else if(SAPP_SEND_OPT_REHASH_INDEX == options[i].type){ + marsio_buff_set_rehash_index(send_mbuf[0], options[i].int_value); }else{ sapp_fakepacket_set_vxlan_options(&mr_ctrlzone, &options[i]); } @@ -3925,6 +3929,8 @@ int MESA_fakepacket_send_ipv4_options(const struct streaminfo *stream, uint8_t p memcpy(inner_ehdr->ether_shost, options[i].array_value, ETHER_ADDR_LEN); }else if(SAPP_SEND_OPT_INNER_DMAC == options[i].type){ memcpy(inner_ehdr->ether_dhost, options[i].array_value, ETHER_ADDR_LEN); + }else if(SAPP_SEND_OPT_REHASH_INDEX == options[i].type){ + marsio_buff_set_rehash_index(send_mbuf[0], options[i].int_value); }else{ sapp_fakepacket_set_vxlan_options(&mr_ctrlzone, &options[i]); } @@ -3998,6 +4004,8 @@ int MESA_fakepacket_send_ipv6_options(const struct streaminfo *stream, uint8_t p memcpy(inner_ehdr->ether_shost, options[i].array_value, ETHER_ADDR_LEN); }else if(SAPP_SEND_OPT_INNER_DMAC == options[i].type){ memcpy(inner_ehdr->ether_dhost, options[i].array_value, ETHER_ADDR_LEN); + }else if(SAPP_SEND_OPT_REHASH_INDEX == options[i].type){ + marsio_buff_set_rehash_index(send_mbuf[0], options[i].int_value); }else{ sapp_fakepacket_set_vxlan_options(&mr_ctrlzone, &options[i]); } @@ -4071,6 +4079,8 @@ int MESA_fakepacket_send_tcp_options(const struct streaminfo *stream, memcpy(inner_ehdr->ether_shost, options[i].array_value, ETHER_ADDR_LEN); }else if(SAPP_SEND_OPT_INNER_DMAC == options[i].type){ memcpy(inner_ehdr->ether_dhost, options[i].array_value, ETHER_ADDR_LEN); + }else if(SAPP_SEND_OPT_REHASH_INDEX == options[i].type){ + marsio_buff_set_rehash_index(send_mbuf[0], options[i].int_value); }else{ sapp_fakepacket_set_vxlan_options(&mr_ctrlzone, &options[i]); } @@ -4151,6 +4161,8 @@ int MESA_fakepacket_send_ipv6_tcp_options(const struct streaminfo *stream, memcpy(inner_ehdr->ether_shost, options[i].array_value, ETHER_ADDR_LEN); }else if(SAPP_SEND_OPT_INNER_DMAC == options[i].type){ memcpy(inner_ehdr->ether_dhost, options[i].array_value, ETHER_ADDR_LEN); + }else if(SAPP_SEND_OPT_REHASH_INDEX == options[i].type){ + marsio_buff_set_rehash_index(send_mbuf[0], options[i].int_value); }else{ sapp_fakepacket_set_vxlan_options(&mr_ctrlzone, &options[i]); } @@ -4225,6 +4237,8 @@ int MESA_fakepacket_send_udp_options(const struct streaminfo *stream, memcpy(inner_ehdr->ether_shost, options[i].array_value, ETHER_ADDR_LEN); }else if(SAPP_SEND_OPT_INNER_DMAC == options[i].type){ memcpy(inner_ehdr->ether_dhost, options[i].array_value, ETHER_ADDR_LEN); + }else if(SAPP_SEND_OPT_REHASH_INDEX == options[i].type){ + marsio_buff_set_rehash_index(send_mbuf[0], options[i].int_value); }else{ sapp_fakepacket_set_vxlan_options(&mr_ctrlzone, &options[i]); } @@ -4245,9 +4259,13 @@ int MESA_fakepacket_send_udp_options(const struct streaminfo *stream, } mr_ctrlzone.route_dir = dir; /* ͨ��ѡ��Ҳ������, �����DZ����˽ӿ�ֱ������dir�IJ���, �ӿ�dir���� */ marsio_buff_ctrlzone_set(send_mbuf[0], 0, &mr_ctrlzone, sizeof(struct mr_tunnat_ctrlzone)); +#if 0 inner_ret = marsio_send_burst_with_options_for_tcpdumpmesa((struct mr_sendpath *)g_packet_device_alias[0].dl_io_param, thread_index, send_mbuf, 1, MARSIO_SEND_OPT_FAST); - +#else + inner_ret = marsio_send_burst_with_options_for_tcpdumpmesa((struct mr_sendpath *)g_packet_device_alias[0].dl_io_param, thread_index, + send_mbuf, 1, 0); +#endif if(inner_ret < 0){ return -1; } @@ -4300,6 +4318,8 @@ int MESA_fakepacket_send_ipv6_udp_options(const struct streaminfo *stream, memcpy(inner_ehdr->ether_shost, options[i].array_value, ETHER_ADDR_LEN); }else if(SAPP_SEND_OPT_INNER_DMAC == options[i].type){ memcpy(inner_ehdr->ether_dhost, options[i].array_value, ETHER_ADDR_LEN); + }else if(SAPP_SEND_OPT_REHASH_INDEX == options[i].type){ + marsio_buff_set_rehash_index(send_mbuf[0], options[i].int_value); }else{ sapp_fakepacket_set_vxlan_options(&mr_ctrlzone, &options[i]); } diff --git a/test/test_app_sapp.c b/test/test_app_sapp.c index 1e29e32..be43b44 100644 --- a/test/test_app_sapp.c +++ b/test/test_app_sapp.c @@ -460,6 +460,41 @@ char testIPFragApp_1(struct streaminfo *pstream,unsigned char routedir, int thre return APP_STATE_GIVEME; } +char ipv4_pkt_detail_entry(struct streaminfo *pstream,unsigned char routedir, int thread_seq,void *a_packet) +{ + char ip_src_str[INET6_ADDRSTRLEN]; + char ip_dst_str[INET6_ADDRSTRLEN]; + struct mesa_ip4_hdr *ihdr4 = (struct mesa_ip4_hdr *)a_packet; + struct mesa_tcp_hdr *thdr; + struct mesa_udp_hdr *uhdr; + if(NULL == a_packet){ + return APP_STATE_GIVEME; + } + + inet_ntop(AF_INET, &ihdr4->ip_src.s_addr, ip_src_str, sizeof(ip_src_str)); + inet_ntop(AF_INET, &ihdr4->ip_dst.s_addr, ip_dst_str, sizeof(ip_dst_str)); + + if(IPPROTO_TCP == ihdr4->ip_p){ + thdr = (struct mesa_tcp_hdr *)((char *)ihdr4 + ihdr4->ip_hl * 4); + printf("IP pkt: %s:%u --> %s:%u, ipid:%u, proto:%d\n", + ip_src_str, ntohs(thdr->th_sport), + ip_dst_str, ntohs(thdr->th_dport), + ntohs(ihdr4->ip_id), ihdr4->ip_p); + }else if(IPPROTO_UDP == ihdr4->ip_p){ + uhdr = (struct mesa_udp_hdr *)((char *)ihdr4 + ihdr4->ip_hl * 4); + printf("IP pkt: %s:%u --> %s:%u, ipid:%u, proto:%d\n", + ip_src_str, ntohs(uhdr->uh_sport), + ip_dst_str, ntohs(uhdr->uh_dport), + ntohs(ihdr4->ip_id), ihdr4->ip_p); + }else{ + printf("IP pkt: %s --> %s, ipid:%u, proto:%d\n", ip_src_str, ip_dst_str, ntohs(ihdr4->ip_id), ihdr4->ip_p); + } + + return APP_STATE_GIVEME; +} + + + char testIPApp_1(struct streaminfo *pstream,unsigned char routedir, int thread_seq,void *a_packet) { static int testcount; diff --git a/test/test_sendpacket_performance.c b/test/test_sendpacket_performance.c index deb9a35..98a21af 100644 --- a/test/test_sendpacket_performance.c +++ b/test/test_sendpacket_performance.c @@ -7,11 +7,25 @@ extern "C" { #endif +static int MRTUNNAT_THREAD_NUM = 1; static int MAX_SEND_THREAD = 1; static int send_payload_len = 22; +typedef struct{ + long long value1; + long long value2; + long long value3; + long long value4; + long long value5; + long long value6; + long long value7; + long long value8; +}cache_align_t; + #if IOMODE_MARSIO +static cache_align_t fake_rand_num[256]; + static void test_send_udp_by_vlink(int thread_seq) { SAPP_TLV_T option[32]; @@ -24,15 +38,22 @@ static void test_send_udp_by_vlink(int thread_seq) option[0].type = SAPP_SEND_OPT_VIRTUAL_LINK_ID; option[0].length = sizeof(long long); - option[0].long_value = 1; + option[0].long_value = 0; + opt_num++; + + option[1].type = SAPP_SEND_OPT_REHASH_INDEX; + option[1].length = sizeof(long long); + option[1].long_value = fake_rand_num[thread_seq].value1 % MRTUNNAT_THREAD_NUM; + fake_rand_num[thread_seq].value1++; opt_num++; + #if 0 ret = MESA_fakepacket_send_udp_options(&tmp_streaminfo, 0xC0A83294, 0xC0A86405, 0x1111, 0x5555, udp_payload, strlen(udp_payload), 0, option, opt_num); #else -ret = MESA_fakepacket_send_udp_options(&tmp_streaminfo, 0xC0A83294, 0xC0A86405, 0x1111, 0x5555, +ret = MESA_fakepacket_send_udp_options(&tmp_streaminfo, 0xC0A83295, 0xC0A86405, 0x1111, 0x5555, udp_paylaod_long, send_payload_len, 0, option, opt_num); @@ -79,6 +100,11 @@ int CHAR_INIT() printf("can't get thread_num from: %s\n", "etc/test_sendpacket_perf.conf"); return -1; } + ret = MESA_load_profile_int_def((char *)"etc/test_sendpacket_perf.conf", (char *)"main", (char *)"mrtunnat_thread_num", &MRTUNNAT_THREAD_NUM, 1); + if(ret < 0){ + printf("can't get mrtunnat_thread_num from: %s\n", "etc/test_sendpacket_perf.conf"); + return -1; + } ret = MESA_load_profile_int_def((char *)"etc/test_sendpacket_perf.conf", (char *)"main", (char *)"send_payload_len", &send_payload_len, 22); if(ret < 0){ printf("can't get send_payload_len from: %s\n", "etc/test_sendpacket_perf.conf"); |
