From de9b2d4ff40d5874de7d8fc7fe3a8e46b99f99d9 Mon Sep 17 00:00:00 2001 From: lijie Date: Wed, 21 Nov 2018 20:47:01 +0800 Subject: 初步和接入网关联调成功 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/conf/mrl.conf | 15 ++-- bin/conf/mrl.inf | 4 +- bin/conf/table_info.conf | 2 +- bin/mrl.so | Bin 89144 -> 0 bytes include/mrl_main.h | 17 +++-- include/mrl_packet.h | 6 +- include/mrl_redis.h | 20 +++--- include/mrl_utils.h | 2 +- src/Makefile | 2 +- src/mrl.so | Bin 88928 -> 0 bytes src/mrl_main.c | 70 +++++++++++++----- src/mrl_main.o | Bin 47664 -> 0 bytes src/mrl_packet.c | 179 ++++++++++++++++++++++++++++++++--------------- src/mrl_packet.o | Bin 36104 -> 0 bytes src/mrl_redis.c | 126 ++++++++++++++++++--------------- src/mrl_redis.o | Bin 45856 -> 0 bytes src/mrl_utils.o | Bin 22040 -> 0 bytes 17 files changed, 280 insertions(+), 163 deletions(-) delete mode 100644 bin/mrl.so delete mode 100644 src/mrl.so delete mode 100644 src/mrl_main.o delete mode 100644 src/mrl_packet.o delete mode 100644 src/mrl_redis.o delete mode 100644 src/mrl_utils.o diff --git a/bin/conf/mrl.conf b/bin/conf/mrl.conf index 58ee390..92c58f0 100644 --- a/bin/conf/mrl.conf +++ b/bin/conf/mrl.conf @@ -1,6 +1,10 @@ [LOG_INFO] -log_level=20 +log_level=10 log_path=./log/mrl.log +[DETECT_INFO] +dest_ip=123.57.35.217 +dest_port=20181 +local_port=20182 [SOCK_INFO] mrl_port=23456 mgw_port=33456 @@ -18,14 +22,15 @@ ht_max_element_num=40000 ht_mutex_num=5 [VXLAN_INFO] vxlan_gdev_num=1 -vxlan_local_mac=e4:95:6e:20:0d:0as +vxlan_local_mac=e4:95:6e:20:0d:0a vxlan_gdev_mac=00:1e:73:6c:fa:43 vxlan_local_ip=192.168.1.10 vxlan_gdev_ip=10.1.1.1 -vxlan_local_port=4789 -vxlan_gdev_port=50710 +vxlan_local_port=50710 +vxlan_gdev_port=4789 vxlan_encap_type=0 vxlan_link_id=1 vxlan_link_dir=1 -vxlan_inner_smac=60:67:20:2a:6a:b0 +vxlan_vpn_id=112 +vxlan_inner_smac=7c:2a:31:a3:44:9a vxlan_inner_dmac=e8:61:1f:13:70:7a \ No newline at end of file diff --git a/bin/conf/mrl.inf b/bin/conf/mrl.inf index 66e03a1..203ec1c 100644 --- a/bin/conf/mrl.inf +++ b/bin/conf/mrl.inf @@ -4,9 +4,9 @@ SO_PATH=./plug/business/mrl/mrl.so INIT_FUNC=mrl_init DESTROY_FUNC=mrl_destroy -[TCPALL] +[TCP_ALL] FUNC_FLAG=ALL -FUNC_NAME=mrl_tcp_entry +FUNC_NAME=mrl_tcpall_entry [UDP] FUNC_FLAG=ALL diff --git a/bin/conf/table_info.conf b/bin/conf/table_info.conf index 42d2ead..d860d44 100644 --- a/bin/conf/table_info.conf +++ b/bin/conf/table_info.conf @@ -16,4 +16,4 @@ #For expr/expr_plus Table #id name type src_charset dst_charset do_merge cross_cache quick_mode 0 IR_NOMINEE_IP plugin 5 -- -1 IR_CANDIDATE_IP plugin 18 -- \ No newline at end of file +1 IR_CANDIDATE_IP plugin 19 -- \ No newline at end of file diff --git a/bin/mrl.so b/bin/mrl.so deleted file mode 100644 index f269249..0000000 Binary files a/bin/mrl.so and /dev/null differ diff --git a/include/mrl_main.h b/include/mrl_main.h index d3ab72c..a9bd8d5 100644 --- a/include/mrl_main.h +++ b/include/mrl_main.h @@ -8,6 +8,7 @@ #include "MESA_prof_load.h" #include "MESA_handle_logger.h" #include "MESA_htable.h" +#include "MESA_list_queue.h" #include "Maat_rule.h" #include "Maat_command.h" @@ -20,8 +21,8 @@ struct mrl_global_cfg int mrl_log_level; //detect info - char detect_ip[MRL_STR_IP_LEN]; - uint16_t detect_port; + char dest_ip[MRL_STR_IP_LEN]; + uint16_t dest_port; uint16_t local_port; //socket info @@ -41,7 +42,7 @@ struct mrl_global_cfg unsigned int ht_slots; unsigned int ht_max_element_num; unsigned int ht_mutex_num; - + /*vxlan info*/ unsigned int vxlan_gdev_num; char **vxlan_outer_gdev_mac; @@ -51,13 +52,11 @@ struct mrl_global_cfg char **vxlan_outer_gdev_port; char xvlan_outer_local_port[MRL_STR_PORT_LEN]; char **vxlan_encap_type; + char **vxlan_vpn_id; char **vxlan_link_id; char **vxlan_link_dir; char **vxlan_inner_smac; char **vxlan_inner_dmac; - //char vxlan_inner_dip[MRL_STR_IP_LEN]; - //char vxlan_inner_dport[MRL_STR_PORT_LEN]; - //char vxlan_inner_sport[MRL_STR_PORT_LEN]; }; struct mrl_global_instance @@ -69,9 +68,13 @@ struct mrl_global_instance Maat_feather_t candidate_feather; MESA_htable_handle ht_nominee; - MESA_htable_handle ht_candidate; + + //MESA_htable_handle ht_candidate; + MESA_lqueue_head mrl_queue; MMDB_s mrl_mmdb; + + int stop_flag; int *mrl_snd_fd; int mrl_rcv_fd; diff --git a/include/mrl_packet.h b/include/mrl_packet.h index 06069ae..aec886f 100644 --- a/include/mrl_packet.h +++ b/include/mrl_packet.h @@ -8,14 +8,12 @@ void mrl_socket_close(); void mrl_send_to_gdev(int thread_seq, struct mrl_vxlan_info * vxlan_info, const char *payload, size_t payload_len); bool mrl_pkt_signature_identify(struct streaminfo *mystream); -void *mrl_recv_mgw_action(void *arg); void mrl_send_to_mgw(void *raw_pkt, int thread_seq); void mrl_detect_init(); void mrl_detect_action(const char *ip_addr); - bool mrl_pkt_signature_identify(struct streaminfo *mystream); - - +void *mrl_recv_mgw_action(void *arg); +void *mrl_detect_ip_action(void *arg); #endif diff --git a/include/mrl_redis.h b/include/mrl_redis.h index de6cdcb..b840a8e 100644 --- a/include/mrl_redis.h +++ b/include/mrl_redis.h @@ -16,16 +16,17 @@ struct mrl_nominee_item{ char op_time[MRL_DATE_LEN]; }; -struct mrl_vxlan_info{ - char vxlan_outer_local_mac[MRL_STR_MAC_LEN];//յݰı豸MACַ - char vxlan_outer_gdev_mac[MRL_STR_MAC_LEN];//յݰĴ豸MACַ - char vxlan_outer_local_ip[MRL_STR_IP_LEN]; - char vxlan_outer_gdev_ip[MRL_STR_IP_LEN];//豸IP - char vxlan_outer_gdev_port[MRL_STR_PORT_LEN]; - char vxlan_outer_local_port[MRL_STR_PORT_LEN]; - int vxlan_encap_type; +struct mrl_vxlan_info{ int vxlan_link_id; + int vxlan_encap_type; int vxlan_link_dir; + int vxlan_vpn_id; + char vxlan_outer_local_port[MRL_STR_PORT_LEN]; + char vxlan_outer_gdev_port[MRL_STR_PORT_LEN]; + char vxlan_outer_local_ip[MRL_STR_IP_LEN]; + char vxlan_outer_gdev_ip[MRL_STR_IP_LEN];//豸IP + char vxlan_outer_local_mac[MRL_STR_MAC_LEN];//յݰı豸MACַ + char vxlan_outer_gdev_mac[MRL_STR_MAC_LEN];//յݰĴ豸MACַ char vxlan_inner_smac[MRL_STR_MAC_LEN]; char vxlan_inner_dmac[MRL_STR_MAC_LEN]; }; @@ -43,14 +44,13 @@ struct mrl_candidate_item{ MESA_htable_handle mrl_htable_init(void * fn_data_free_cb); -void ht_candidate_free_cb(void * data); +//void ht_candidate_free_cb(void * data); void ht_nominee_free_cb(void * data); void Maat_set_cmd_line(Maat_feather_t feather, struct mrl_candidate_item *candidate_item); void Maat_set_nominee_cmd_line(Maat_feather_t feather, struct mrl_nominee_item *nominee_item); Maat_feather_t mrl_Maat_feather_init(const char * instance_name,const char *table_name, Maat_start_callback_t *start,Maat_update_callback_t *update,Maat_finish_callback_t *finish,void *u_para); void nominee_update_cb(int table_id,const char* table_line,void* u_para); -void candidate_update_cb(int table_id,const char* table_line,void* u_para); void mrl_identify_nominee(struct streaminfo *mystream); #endif diff --git a/include/mrl_utils.h b/include/mrl_utils.h index 2bf05d8..ca148a6 100644 --- a/include/mrl_utils.h +++ b/include/mrl_utils.h @@ -8,7 +8,7 @@ #define MRL_STR_ENCAP_TYPE_LEN 5 #define MRL_STR_LINK_ID_LEN 5 #define MRL_STR_LINK_DIR_LEN 2 - +#define MRL_STR_VPN_ID_LEN 5 #define MRL_DATE_LEN 50 diff --git a/src/Makefile b/src/Makefile index f1e4639..b9cb678 100644 --- a/src/Makefile +++ b/src/Makefile @@ -8,7 +8,7 @@ CXXFLAGS = -Wall -g -fPIC INCLUDES = -I ../include -#INCLUDES += -I ../support/include +INCLUDES += -I /opt/mrzcpd/include INCLUDES += -I /opt/MESA/include diff --git a/src/mrl.so b/src/mrl.so deleted file mode 100644 index 445ab26..0000000 Binary files a/src/mrl.so and /dev/null differ diff --git a/src/mrl_main.c b/src/mrl_main.c index 12153b2..99f8001 100644 --- a/src/mrl_main.c +++ b/src/mrl_main.c @@ -17,11 +17,12 @@ void mrl_cfg_init(const char *profile) char *temp_port_str; char *temp_ip_str; char *temp_encap_type_str; + char *temp_vpn_id_str; char *temp_link_id_str; char *temp_link_dir_str; unsigned int split_num = 0; - short temp_port = 0; + int temp_port = 0; unsigned int i=0; /********** load log info **********/ @@ -29,22 +30,23 @@ void mrl_cfg_init(const char *profile) MESA_load_profile_string_def(profile, "LOG_INFO", "log_path", mrl_instance.mrl_cfg.mrl_log_path, MRL_MAX_PATH, "./log/mrl.log"); /********** load detect info **********/ - MESA_load_profile_string_def(profile, "DETECT_INFO", "detect_ip", mrl_instance.mrl_cfg.detect_ip, MRL_STR_IP_LEN, "0.0.0.0"); + MESA_load_profile_string_def(profile, "DETECT_INFO", "dest_ip", mrl_instance.mrl_cfg.dest_ip, MRL_STR_IP_LEN, "0.0.0.0"); - MESA_load_profile_short_def(profile, "SOCK_INFO", "mrl_port",&(temp_port),8888); + MESA_load_profile_int_def(profile, "DETECT_INFO", "dest_port",&(temp_port),8888); assert(temp_port > 0 && temp_port <= 65535); - mrl_instance.mrl_cfg.detect_port = temp_port; + mrl_instance.mrl_cfg.dest_port = temp_port; - MESA_load_profile_short_def(profile, "SOCK_INFO", "mrl_port",&(temp_port),8888); + MESA_load_profile_int_def(profile, "DETECT_INFO", "local_port",&(temp_port),8888); assert(temp_port > 0 && temp_port <= 65535); mrl_instance.mrl_cfg.local_port = temp_port; /********** load sock info **********/ - MESA_load_profile_short_def(profile, "SOCK_INFO", "mrl_port",&(temp_port),8888); + MESA_load_profile_int_def(profile, "SOCK_INFO", "mrl_port",&(temp_port),8888); assert(temp_port > 0 && temp_port <= 65535); mrl_instance.mrl_cfg.mrl_port = temp_port; + - MESA_load_profile_short_def(profile, "SOCK_INFO", "mgw_port",&(temp_port),8888); + MESA_load_profile_int_def(profile, "SOCK_INFO", "mgw_port",&(temp_port),8888); assert(temp_port > 0 && temp_port <= 65535); mrl_instance.mrl_cfg.mgw_port = temp_port; @@ -56,9 +58,9 @@ void mrl_cfg_init(const char *profile) MESA_load_profile_string_def(profile, "MAAT_INFO", "Maat_table_path", mrl_instance.mrl_cfg.Maat_table_path, MRL_MAX_PATH, "./conf/table_info.conf"); MESA_load_profile_uint_def(profile, "MAAT_INFO", "Maat_max_threads", &(mrl_instance.mrl_cfg.Maat_max_threads), 1); MESA_load_profile_string_def(profile, "MAAT_INFO", "Maat_redis_ip", mrl_instance.mrl_cfg.Maat_redis_ip, MRL_STR_IP_LEN, "127.0.0.1"); - MESA_load_profile_short_def(profile, "MAAT_INFO", "Maat_redis_port", &(temp_port), 6379); + MESA_load_profile_int_def(profile, "MAAT_INFO", "Maat_redis_port", &(temp_port), 6379); assert(temp_port > 0 && temp_port <= 65535); - mrl_instance.mrl_cfg.Maat_redis_port = (unsigned short)temp_port; + mrl_instance.mrl_cfg.Maat_redis_port = temp_port; MESA_load_profile_string_def(profile, "MAAT_INFO", "Maat_stat_path", mrl_instance.mrl_cfg.Maat_stat_path,MRL_MAX_PATH, "./log/Maat_stat.log"); @@ -75,6 +77,7 @@ void mrl_cfg_init(const char *profile) temp_ip_str = (char *)calloc(mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_IP_LEN,sizeof(char)); temp_port_str = (char *)calloc(mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_PORT_LEN, sizeof(char)); temp_encap_type_str = (char *)calloc(mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_ENCAP_TYPE_LEN,sizeof(char)); + temp_vpn_id_str = (char *)calloc(mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_VPN_ID_LEN,sizeof(char)); temp_link_id_str = (char *)calloc(mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_LINK_ID_LEN,sizeof(char)); temp_link_dir_str = (char *)calloc(mrl_instance.mrl_cfg.vxlan_gdev_num * MRL_STR_LINK_DIR_LEN, sizeof(char)); @@ -114,6 +117,17 @@ void mrl_cfg_init(const char *profile) split_num = mrl_split_str(temp_encap_type_str,",",mrl_instance.mrl_cfg.vxlan_encap_type); assert(split_num == mrl_instance.mrl_cfg.vxlan_gdev_num); + + MESA_load_profile_string_def(profile, "VXLAN_INFO", "vxlan_vpn_id",temp_vpn_id_str, mrl_instance.mrl_cfg.vxlan_gdev_num*MRL_STR_VPN_ID_LEN, "0000"); + mrl_instance.mrl_cfg.vxlan_vpn_id = (char **)malloc(sizeof(char *)*mrl_instance.mrl_cfg.vxlan_gdev_num); + for(i=0;ivxlan_outer_local_mac, ':', temp_mac); + //printf("SAPP_SEND_OPT_GDEV_SMAC is:%02x-%02x-%02x-%02x-%02x-%02x\n",temp_mac[0],temp_mac[1],temp_mac[2],temp_mac[3],temp_mac[4],temp_mac[5]); option[option_num].type = SAPP_SEND_OPT_GDEV_SMAC; option[option_num].length = MRL_MAC_LEN; memcpy(option[option_num].array_value, temp_mac, MRL_MAC_LEN); @@ -134,12 +136,14 @@ void mrl_send_to_gdev(int thread_seq, struct mrl_vxlan_info * vxlan_info, const memset(temp_mac, 0, MRL_MAC_LEN); mrl_mac_pton(vxlan_info->vxlan_outer_gdev_mac, ':', temp_mac); + //printf("SAPP_SEND_OPT_GDEV_DMAC is:%02x-%02x-%02x-%02x-%02x-%02x\n",temp_mac[0],temp_mac[1],temp_mac[2],temp_mac[3],temp_mac[4],temp_mac[5]); option[option_num].type = SAPP_SEND_OPT_GDEV_DMAC; option[option_num].length = MRL_MAC_LEN; memcpy(option[option_num].array_value, temp_mac, MRL_MAC_LEN); option_num++;/////// - inet_pton(AF_INET, vxlan_info->vxlan_outer_local_ip, &temp_ip); + inet_pton(AF_INET, vxlan_info->vxlan_outer_local_ip, &temp_ip); + //printf("SAPP_SEND_OPT_GDEV_SIP is:%u\n",temp_ip); option[option_num].type = SAPP_SEND_OPT_GDEV_SIP; option[option_num].length = 4; option[option_num].int_value = temp_ip; @@ -147,6 +151,7 @@ void mrl_send_to_gdev(int thread_seq, struct mrl_vxlan_info * vxlan_info, const inet_pton(AF_INET, vxlan_info->vxlan_outer_gdev_ip, &temp_ip); + //printf("SAPP_SEND_OPT_GDEV_DIP is:%u\n",temp_ip); option[option_num].type = SAPP_SEND_OPT_GDEV_DIP; option[option_num].length = 4; option[option_num].int_value = temp_ip; @@ -155,52 +160,57 @@ void mrl_send_to_gdev(int thread_seq, struct mrl_vxlan_info * vxlan_info, const temp_port = atoi(vxlan_info->vxlan_outer_local_port); assert(temp_port >0 && temp_port <= 65535); + //printf("SAPP_SEND_OPT_GDEV_UDP_SPORT is:%hu\n",temp_port); option[option_num].type = SAPP_SEND_OPT_GDEV_UDP_SPORT; option[option_num].length = 2; - option[option_num].short_value = temp_port; + option[option_num].short_value = htons(temp_port); option_num++;/////// temp_port = atoi(vxlan_info->vxlan_outer_gdev_port); assert(temp_port >0 && temp_port <= 65535); + //printf("SAPP_SEND_OPT_GDEV_UDP_DPORT is:%hu\n",temp_port); option[option_num].type = SAPP_SEND_OPT_GDEV_UDP_DPORT; option[option_num].length = 2; - option[option_num].short_value = temp_port; + option[option_num].short_value = htons(temp_port); + //printf("cur option gdev_udp_dport value is %hu\n",ntohs(option[option_num].short_value)); option_num++;/////// option[option_num].type = SAPP_SEND_OPT_VXLAN_VPN_ID; + //printf("SAPP_SEND_OPT_VXLAN_VPN_ID is %d\n",vxlan_info->vxlan_vpn_id); option[option_num].length = 4; - option[option_num].int_value = 0; + option[option_num].int_value = vxlan_info->vxlan_vpn_id; option_num++;/////// - + //printf("SAPP_SEND_OPT_VXLAN_LINK_ID is:%d\n",vxlan_info->vxlan_link_id); option[option_num].type = SAPP_SEND_OPT_VXLAN_LINK_ID; option[option_num].length = 4; option[option_num].int_value = vxlan_info->vxlan_link_id; option_num++;/////// - + //printf("SAPP_SEND_OPT_VXLAN_LINK_ENCAP_TYPE is:%d\n",vxlan_info->vxlan_encap_type); option[option_num].type = SAPP_SEND_OPT_VXLAN_LINK_ENCAP_TYPE; option[option_num].length = 1; - option[option_num].char_value = vxlan_info->vxlan_encap_type; + option[option_num].char_value = TUNNAT_TUNNEL_TYPE_ETHER; option_num++;/////// - + //printf("SAPP_SEND_OPT_VXLAN_LINK_DIR is:%d\n",vxlan_info->vxlan_link_dir); option[option_num].type = SAPP_SEND_OPT_VXLAN_LINK_DIR; option[option_num].length = 1; option[option_num].char_value = vxlan_info->vxlan_link_dir; option_num++;/////// - + //printf("SAPP_SEND_OPT_INNER_LINK_ENCAP_TYPE is:%d\n",vxlan_info->vxlan_encap_type); option[option_num].type = SAPP_SEND_OPT_INNER_LINK_ENCAP_TYPE; option[option_num].length = 1; - option[option_num].char_value = vxlan_info->vxlan_encap_type; + option[option_num].char_value = TUNNAT_TUNNEL_TYPE_ETHER; option_num++;/////// memset(temp_mac, 0, MRL_MAC_LEN); mrl_mac_pton(vxlan_info->vxlan_inner_smac, ':', temp_mac); + //printf("SAPP_SEND_OPT_INNER_SMAC is:%02x-%02x-%02x-%02x-%02x-%02x\n",temp_mac[0],temp_mac[1],temp_mac[2],temp_mac[3],temp_mac[4],temp_mac[5]); option[option_num].type = SAPP_SEND_OPT_INNER_SMAC; option[option_num].length = MRL_MAC_LEN; memcpy(option[option_num].array_value, temp_mac, MRL_MAC_LEN); @@ -209,32 +219,58 @@ void mrl_send_to_gdev(int thread_seq, struct mrl_vxlan_info * vxlan_info, const memset(temp_mac, 0, MRL_MAC_LEN); mrl_mac_pton(vxlan_info->vxlan_inner_dmac, ':', temp_mac); + //printf("SAPP_SEND_OPT_INNER_DMAC is:%02x-%02x-%02x-%02x-%02x-%02x\n",temp_mac[0],temp_mac[1],temp_mac[2],temp_mac[3],temp_mac[4],temp_mac[5]); option[option_num].type = SAPP_SEND_OPT_INNER_DMAC; option[option_num].length = MRL_MAC_LEN; memcpy(option[option_num].array_value, temp_mac, MRL_MAC_LEN); option_num++;/////// - - printf("send to gdev\n"); - MESA_sendpacket_iplayer_options(thread_seq, + int ret = 0; + ret = MESA_sendpacket_iplayer_options(thread_seq, payload, payload_len, vxlan_info->vxlan_link_dir, option, option_num); + assert(ret >=0); + //printf("send to gdev ret is %d\n",ret); } //жǷIPð bool mrl_pkt_signature_identify(struct streaminfo *mystream) { - printf("start to signature identify\n"); + //printf("start to signature identify\n"); + char temp_sip[MRL_STR_IP_LEN]; + char temp_dip[MRL_STR_IP_LEN]; + memset(temp_sip,0,MRL_STR_IP_LEN); + memset(temp_dip,0,MRL_STR_IP_LEN); uint8_t type = 0; - uint16_t sport = 0,dport = 0; - uint32_t sip = 0,dip = 0; - sport = mystream->addr.tuple4_v4->source; - dport = mystream->addr.tuple4_v4->dest; - sip = mystream->addr.tuple4_v4->saddr; - dip = mystream->addr.tuple4_v4->daddr; + uint16_t sport = 0, dport = 0, temp_port = 0; + uint32_t hash_sport = 0, hash_dport =0; + uint32_t sip = 0, dip = 0; + sport = ntohs(mystream->addr.tuple4_v4->source); + dport = ntohs(mystream->addr.tuple4_v4->dest); + sip = ntohl(mystream->addr.tuple4_v4->saddr); + dip = ntohl(mystream->addr.tuple4_v4->daddr); + inet_ntop(AF_INET,&(mystream->addr.tuple4_v4->saddr),temp_sip,MRL_STR_IP_LEN); + inet_ntop(AF_INET,&(mystream->addr.tuple4_v4->daddr),temp_dip,MRL_STR_IP_LEN); + /*if(memcmp(temp_sip,"61.135.169.121",strlen(temp_sip)) == 0) + { + printf("cur sip is baidu\n"); + return true; + } + else + { + if(memcmp(temp_dip,"61.135.169.121",strlen(temp_sip)) == 0) + { + printf("cur dip is baidu\n"); + return true; + } + else + { + return false; + } + }*/ switch(mystream->type) { case STREAM_TYPE_TCP: @@ -247,23 +283,27 @@ bool mrl_pkt_signature_identify(struct streaminfo *mystream) assert(0); break; } - printf("cur stream sport is %u and dport is %u and sip is %d and dip is %d and protocol is %d\n",sport,dport,sip,dip,type); - unsigned int hash_sport = sport ^ sip ^ dip ^type; - hash_sport = hash_sport & 0xff; - if(hash_sport == dport) + hash_dport = sport ^ sip ^ dip ^type; + hash_dport = hash_dport & 0xff; + temp_port = dport & 0xff; + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_pkt_signature_identify","sapp recv stream info:" + "sport is %hu, dport is %hu, hash_dport is %hu, temp_port is %u,sip is %s,dip is %s, protocol is %d", + sport,dport,hash_dport,temp_port,temp_sip,temp_dip,type); + if(hash_dport == temp_port) { return true; } else { - if(type == MRL_UDP_TYPE) + hash_sport = dport ^ sip ^ dip ^type; + hash_sport = hash_sport & 0xff; + temp_port = sport & 0xff; + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_pkt_signature_identify","sapp recv stream info:" + "sport is %hu, dport is %hu, hash_sport is %hu, temp_port is %u,sip is %s,dip is %s, protocol is %d", + sport,dport,hash_sport,temp_port,temp_sip,temp_dip,type); + if(hash_sport == temp_port) { - unsigned int hash_dport = dport ^ sip ^ dip ^type; - hash_dport = hash_dport & 0xff; - if(hash_dport == sport) - { - return true; - } + return true; } return false; } @@ -273,9 +313,12 @@ bool mrl_pkt_signature_identify(struct streaminfo *mystream) void mrl_send_to_mgw(void *raw_pkt, int thread_seq) { const char *pkt = (const char *)raw_pkt; - ssize_t pkt_len = strlen(pkt); + struct iphdr *ip_hdr = (struct iphdr *)pkt; + ssize_t pkt_len = ntohs(ip_hdr->tot_len); + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_send_to_mgw","send to mgw len is %d",pkt_len); ssize_t send_len = 0; send_len = mrl_sock_send(mrl_instance.mrl_snd_fd[thread_seq],pkt,pkt_len,&(mrl_instance.mgw_addr)); + assert(send_len == pkt_len); printf("send socket len is %ld\n",send_len); } @@ -289,35 +332,48 @@ void *mrl_recv_mgw_action(void *arg) int temp_len = 0; while(1) { + if(mrl_instance.stop_flag == 1) + { + break; + } + memset(rcv_buff,0,MRL_BUFF_LEN); recv_len = mrl_sock_recv(mrl_instance.mrl_rcv_fd,rcv_buff, MRL_BUFF_LEN); printf("recv from mgw len is %ld\n",recv_len); struct mrl_vxlan_info *vxlan_info = (struct mrl_vxlan_info *)rcv_buff; + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_recv_mgw_action","recv mgw vxlan info:" + "link_id:%d,encap_type:%d,link_dir:%d,vpn_id:%d,local_port:%s,gdev_port:%s, local_ip:%s,gdev_ip:%s," + "local_mac:%s, gdev_mac:%s,inner_smac:%s, inner_dmac:%s", + vxlan_info->vxlan_link_id,vxlan_info->vxlan_encap_type,vxlan_info->vxlan_link_dir, + vxlan_info->vxlan_vpn_id,vxlan_info->vxlan_outer_local_port,vxlan_info->vxlan_outer_gdev_port, + vxlan_info->vxlan_outer_local_ip,vxlan_info->vxlan_outer_gdev_ip,vxlan_info->vxlan_outer_local_mac, + vxlan_info->vxlan_outer_gdev_mac,vxlan_info->vxlan_inner_smac, vxlan_info->vxlan_inner_dmac); size_t vxlan_len = sizeof(struct mrl_vxlan_info); + temp_len = sizeof(thread_seq); sapp_get_platform_opt(SPO_INDEPENDENT_THREAD_ID, &thread_seq, &temp_len); - printf("send to gdev thread seq is %d\n",thread_seq); + //printf("send to gdev thread seq is %d\n",thread_seq); mrl_send_to_gdev(thread_seq,vxlan_info,rcv_buff + vxlan_len, recv_len - vxlan_len); } return NULL; } -size_t mrl_build_ip_hdr(char *ip_pkt, const char *src_ip, const char *dst_ip, size_t udp_len) +size_t mrl_build_ip_hdr(char *ip_pkt, uint32_t src_ip, uint32_t dst_ip, size_t udp_len) { size_t ip_len = udp_len + MRL_IP_HDR_LEN; struct iphdr *ip_hdr =(struct iphdr *)ip_pkt; ip_hdr->ihl = 0x5; ip_hdr->version=0x4; ip_hdr->tos = 0x00; - ip_hdr->tot_len = ip_len; + ip_hdr->tot_len = htons(ip_len); ip_hdr->id = 0x325f; ip_hdr->frag_off =0x0000; ip_hdr->ttl = 0x80; ip_hdr->protocol =0x11; ip_hdr->check = 0x0000; - inet_pton(AF_INET,src_ip,&(ip_hdr->saddr)); - inet_pton(AF_INET,dst_ip,&(ip_hdr->daddr)); - ip_hdr->check = htons(mrl_get_checksum((uint16_t *)ip_pkt,MRL_IP_HDR_LEN)); + ip_hdr->saddr = src_ip; + ip_hdr->daddr = dst_ip; + ip_hdr->check = mrl_get_checksum((uint16_t *)ip_pkt,MRL_IP_HDR_LEN); return ip_len; } @@ -325,10 +381,9 @@ size_t mrl_build_udp_hdr(char *udp_pkt,size_t payload_len) { struct udphdr *udp_hdr = (struct udphdr *)udp_pkt; udp_hdr->source = htons(mrl_instance.mrl_cfg.local_port); - udp_hdr->dest = htons(mrl_instance.mrl_cfg.detect_port); - udp_hdr->len = payload_len + MRL_UDP_HDR_LEN; + udp_hdr->dest = htons(mrl_instance.mrl_cfg.dest_port); + udp_hdr->len = htons(payload_len + MRL_UDP_HDR_LEN); udp_hdr->check = 0; - udp_hdr->check = htons(mrl_get_checksum((uint16_t *)udp_pkt,payload_len + MRL_UDP_HDR_LEN)); return payload_len + MRL_UDP_HDR_LEN; } @@ -339,23 +394,24 @@ size_t mrl_build_udp_payload(char *payload) memcpy(payload,content,payload_len); return payload_len; } -void mrl_detect_action(const char *ip_addr) +void mrl_detect_action(uint32_t src_ip) { - printf("start detect ip %s\n",ip_addr); + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"mrl_detect_action","detect ip is %u",src_ip); unsigned int i = 0; int thread_seq = 0; int temp_len = 0; size_t udp_payload_len = 0; size_t udp_len = 0; size_t ip_len = 0; + uint32_t dest_ip = 0; char ip_pkt[MRL_IP_PKT_LEN]; memset(ip_pkt,0,MRL_IP_PKT_LEN); struct mrl_vxlan_info vxlan_info; sapp_get_platform_opt(SPO_INDEPENDENT_THREAD_ID, &thread_seq, &temp_len); udp_payload_len = mrl_build_udp_payload(ip_pkt +MRL_UDP_HDR_LEN + MRL_IP_HDR_LEN); udp_len = mrl_build_udp_hdr(ip_pkt + MRL_IP_HDR_LEN, udp_payload_len); - ip_len = mrl_build_ip_hdr(ip_pkt,ip_addr,mrl_instance.mrl_cfg.detect_ip,udp_len); - MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_detect_action","detect pkt len is %d",ip_len); + inet_pton(AF_INET,mrl_instance.mrl_cfg.dest_ip,&dest_ip); + ip_len = mrl_build_ip_hdr(ip_pkt,src_ip,dest_ip,udp_len); for(i = 0; i< mrl_instance.mrl_cfg.vxlan_gdev_num;i++) { memset(&vxlan_info,0,sizeof(vxlan_info)); @@ -364,20 +420,27 @@ void mrl_detect_action(const char *ip_addr) } } -void ht_nominee_iterate_cb(const uchar *key, uint size, void *data, void *user) +void *mrl_detect_ip_action(void *arg) { - if(data != NULL) + sleep(10); + int ret = 0; + uint32_t detect_ip = 0; + long int ip_len = sizeof(detect_ip); + while(1) { - if(MESA_htable_search_cb(mrl_instance.ht_candidate, key, size, NULL,NULL, NULL) == NULL) + if(mrl_instance.stop_flag == 1) + { + break; + } + ret = MESA_lqueue_get_head(mrl_instance.mrl_queue,&detect_ip,&ip_len); + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"mrl_detect_ip_action","get ip from lqueue is %u",detect_ip); + if(ret != 0) { - mrl_detect_action((const char *)key); - } + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"mrl_detect_ip_action","MESA_lqueue_get_head func error! ret is %d",ret); + assert(0); + } + mrl_detect_action(detect_ip); } - -} -void mrl_detect_init() -{ - printf("mrl detect init\n"); - MESA_htable_iterate(mrl_instance.ht_nominee, ht_nominee_iterate_cb, NULL); - + return NULL; } + diff --git a/src/mrl_packet.o b/src/mrl_packet.o deleted file mode 100644 index 64dd8c0..0000000 Binary files a/src/mrl_packet.o and /dev/null differ diff --git a/src/mrl_redis.c b/src/mrl_redis.c index 81b343f..86287db 100644 --- a/src/mrl_redis.c +++ b/src/mrl_redis.c @@ -26,7 +26,7 @@ void ht_nominee_free_cb(void * data) nominee_item = NULL; } } - +/* void ht_candidate_free_cb(void * data) { struct mrl_candidate_item *candidate_item = (struct mrl_candidate_item *)data; @@ -36,7 +36,7 @@ void ht_candidate_free_cb(void * data) candidate_item = NULL; } } - +*/ MESA_htable_handle mrl_htable_init(void * fn_data_free_cb) { printf("mrl htable init\n"); @@ -134,6 +134,11 @@ int mrl_get_candidate_location(const char *ip_addr) const char *mycountry="China"; int location = 0; location = mrl_search_ip_country(mrl_instance.mrl_mmdb, ip_addr, mycountry); + if(location < 0) + { + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"mrl_get_candidate_location","cur ip addr %s not exist in mmdb",ip_addr); + return 0; + } return location; } void mrl_create_candidate_item(struct mrl_candidate_item *candidate_item, struct mrl_nominee_item *nominee_item) @@ -144,7 +149,6 @@ void mrl_create_candidate_item(struct mrl_candidate_item *candidate_item, struct memcpy(candidate_item->ip_addr,nominee_item->ip_addr,strlen(nominee_item->ip_addr)); //to do how to get ip location candidate_item->location = mrl_get_candidate_location(candidate_item->ip_addr); - assert(candidate_item->location >= 0); memcpy(candidate_item->mrl_ip, mrl_instance.mrl_cfg.mrl_ip,strlen(mrl_instance.mrl_cfg.mrl_ip)); candidate_item->is_vaild = 1; get_cur_time(candidate_item->op_time); @@ -153,39 +157,55 @@ void mrl_create_candidate_item(struct mrl_candidate_item *candidate_item, struct void nominee_update_cb(int table_id,const char* table_line,void* u_para) { int ret = 0; - printf("this is nominee update cb\n"); + uint32_t client_ip = 0; struct mrl_nominee_item *nominee_item = (struct mrl_nominee_item *)calloc(1, sizeof(struct mrl_nominee_item)); sscanf(table_line,"%d\t%d\t%d\t%s\t%d\t%s", &(nominee_item->config_id), &(nominee_item->group_id), &(nominee_item->addr_type), nominee_item->ip_addr, &(nominee_item->is_vaild), nominee_item->op_time); + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"nominee_update_cb","get nominee item:" + "config_id:%d,group_id:%d,addr_type:%d,ip_addr:%s,is_vaild:%d,op_time:%s", + nominee_item->config_id, nominee_item->group_id,nominee_item->addr_type, + nominee_item->ip_addr, nominee_item->is_vaild,nominee_item->op_time); switch(nominee_item->is_vaild) { case 0: - ret = MESA_htable_del(mrl_instance.ht_nominee, (const unsigned char *)nominee_item->ip_addr, sizeof(nominee_item->ip_addr), NULL); - assert(ret >= 0); - if(MESA_htable_search_cb(mrl_instance.ht_candidate, (const unsigned char *)nominee_item->ip_addr, sizeof(nominee_item->ip_addr),NULL,NULL,NULL) != NULL) + if(MESA_htable_search_cb(mrl_instance.ht_nominee, (const unsigned char *)nominee_item->ip_addr, MRL_STR_IP_LEN,NULL,NULL,NULL) == NULL) + { + ret = MESA_htable_del(mrl_instance.ht_nominee, (const unsigned char *)nominee_item->ip_addr, MRL_STR_IP_LEN, NULL); + if(ret < 0) + { + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"nominee_update_cb","MESA_htable_del func error! ret is %d",ret); + assert(0); + } + } + else { - ret = MESA_htable_del(mrl_instance.ht_candidate, (const unsigned char *)nominee_item->ip_addr, sizeof(nominee_item->ip_addr), NULL); - assert(ret >= 0); + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"nominee_update_cb","the nominee item %s is not exsit in nominee htable.",nominee_item->ip_addr); } break; case 1: - if(MESA_htable_search_cb(mrl_instance.ht_candidate, (const unsigned char *)nominee_item->ip_addr, sizeof(nominee_item->ip_addr),NULL,NULL,NULL) == NULL) + if(MESA_htable_search_cb(mrl_instance.ht_nominee, (const unsigned char *)nominee_item->ip_addr, MRL_STR_IP_LEN,NULL,NULL,NULL) == NULL) { - ret = MESA_htable_add(mrl_instance.ht_nominee, (const unsigned char *)nominee_item->ip_addr, sizeof(nominee_item->ip_addr), nominee_item); - if(ret < 0) - { + ret = MESA_htable_add(mrl_instance.ht_nominee, (const unsigned char *)nominee_item->ip_addr, MRL_STR_IP_LEN, nominee_item); + if(ret < 0) + { MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"nominee_update_cb","MESA_htable_add func error! ret is %d",ret); assert(0); - } + } + inet_pton(AF_INET,nominee_item->ip_addr,&client_ip); + ret = MESA_lqueue_join_tail(mrl_instance.mrl_queue,&client_ip,sizeof(client_ip)); + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"nominee_update_cb","insert queue ip is %u",client_ip); + if(ret != 0) + { + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"nominee_update_cb","MESA_lqueue_join_tail func error! ret is %d",ret); + assert(0); + } } else { - MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"nominee_update_cb","the nominee item is duplicated in nominee htable."); + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"nominee_update_cb","the nominee item %s is duplicated in nominee htable.",nominee_item->ip_addr); } - //todo active detect - mrl_detect_action(nominee_item->ip_addr); - break; + break; default: assert(0); break; @@ -193,7 +213,7 @@ void nominee_update_cb(int table_id,const char* table_line,void* u_para) } - +/* void candidate_update_cb(int table_id,const char* table_line,void* u_para) { int ret = 0; @@ -223,7 +243,7 @@ void candidate_update_cb(int table_id,const char* table_line,void* u_para) } } - +*/ long ht_search_cb(void *data, const uchar *key, uint size, void *user_arg) { struct mrl_nominee_item *nominee_item = (struct mrl_nominee_item *)data; @@ -242,6 +262,7 @@ void mrl_get_vxlan_info(struct mrl_vxlan_info *vxlan, unsigned int index) memcpy(vxlan->vxlan_inner_smac, mrl_instance.mrl_cfg.vxlan_inner_smac[index],strlen(mrl_instance.mrl_cfg.vxlan_inner_smac[index])); memcpy(vxlan->vxlan_inner_dmac, mrl_instance.mrl_cfg.vxlan_inner_dmac[index], strlen(mrl_instance.mrl_cfg.vxlan_inner_dmac[index])); vxlan->vxlan_encap_type = atoi(mrl_instance.mrl_cfg.vxlan_encap_type[index]); + vxlan->vxlan_vpn_id= atoi(mrl_instance.mrl_cfg.vxlan_vpn_id[index]); vxlan->vxlan_link_id = atoi(mrl_instance.mrl_cfg.vxlan_link_id[index]); vxlan->vxlan_link_dir = atoi(mrl_instance.mrl_cfg.vxlan_link_dir[index]); memcpy(vxlan->vxlan_outer_local_port, mrl_instance.mrl_cfg.xvlan_outer_local_port,strlen(mrl_instance.mrl_cfg.xvlan_outer_local_port)); @@ -250,27 +271,11 @@ void mrl_get_vxlan_info(struct mrl_vxlan_info *vxlan, unsigned int index) memcpy(vxlan->vxlan_outer_gdev_ip, mrl_instance.mrl_cfg.vxlan_outer_gdev_ip[index],strlen(mrl_instance.mrl_cfg.vxlan_outer_gdev_ip[index])); memcpy(vxlan->vxlan_outer_local_mac, mrl_instance.mrl_cfg.vxlan_outer_local_mac,strlen(mrl_instance.mrl_cfg.vxlan_outer_local_mac)); memcpy(vxlan->vxlan_outer_gdev_mac, mrl_instance.mrl_cfg.vxlan_outer_gdev_mac[index],strlen(mrl_instance.mrl_cfg.vxlan_outer_gdev_mac[index])); - printf("get vxlan opt from rawpkt:inner_smac:%s, inner_dmac:%s,encap_type:%d,link_id:%d, link_dir:%d,local_port:%s," - "gdev_port:%s, local_ip:%s,gdev_ip:%s,local_mac:%s, gdev_mac:%s\n", - vxlan->vxlan_inner_smac, vxlan->vxlan_inner_dmac, vxlan->vxlan_encap_type, - vxlan->vxlan_link_id, vxlan->vxlan_link_dir,vxlan->vxlan_outer_local_port, - vxlan->vxlan_outer_gdev_port,vxlan->vxlan_outer_local_ip,vxlan->vxlan_outer_gdev_ip, - vxlan->vxlan_outer_local_mac,vxlan->vxlan_outer_gdev_mac); - - MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_get_candidate_vxlan_info", "get vxlan opt from rawpkt:" - "inner_smac:%s, inner_dmac:%s,encap_type:%d,link_id:%d, link_dir:%d,local_port:%s," - "gdev_port:%s, local_ip:%s,gdev_ip:%s,local_mac:%s, gdev_mac:%s", - vxlan->vxlan_inner_smac, vxlan->vxlan_inner_dmac, vxlan->vxlan_encap_type, - vxlan->vxlan_link_id, vxlan->vxlan_link_dir,vxlan->vxlan_outer_local_port, - vxlan->vxlan_outer_gdev_port,vxlan->vxlan_outer_local_ip,vxlan->vxlan_outer_gdev_ip, - vxlan->vxlan_outer_local_mac,vxlan->vxlan_outer_gdev_mac); - } void Maat_set_cmd_line(Maat_feather_t feather, struct mrl_candidate_item *candidate_item) { - printf("start to insert candidate table\n"); const struct Maat_line_t *p_line; struct Maat_line_t line_rule; char table_line[512]; @@ -280,15 +285,16 @@ void Maat_set_cmd_line(Maat_feather_t feather, struct mrl_candidate_item *candid line_rule.label_id=0; line_rule.rule_id=candidate_item->config_id; line_rule.table_name=IR_CANDIDATE_IP_TABLE_NAME; - snprintf(table_line,sizeof(table_line),"%d\t%d\t%d\t%s\t%d\t%s\t%d\t%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%d\t%s", + snprintf(table_line,sizeof(table_line),"%d\t%d\t%d\t%s\t%d\t%s\t%d\t%d\t%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%d\t%s", candidate_item->config_id, candidate_item->group_id,candidate_item->addr_type, candidate_item->ip_addr,candidate_item->location, candidate_item->mrl_ip, candidate_item->vxlan_info.vxlan_link_id,candidate_item->vxlan_info.vxlan_encap_type, - candidate_item->vxlan_info.vxlan_link_dir,candidate_item->vxlan_info.vxlan_outer_local_port, - candidate_item->vxlan_info.vxlan_outer_gdev_port,candidate_item->vxlan_info.vxlan_outer_local_ip, - candidate_item->vxlan_info.vxlan_outer_gdev_ip,candidate_item->vxlan_info.vxlan_outer_local_mac, - candidate_item->vxlan_info.vxlan_outer_gdev_mac,candidate_item->vxlan_info.vxlan_inner_smac, - candidate_item->vxlan_info.vxlan_inner_dmac,candidate_item->is_vaild, candidate_item->op_time); + candidate_item->vxlan_info.vxlan_link_dir,candidate_item->vxlan_info.vxlan_vpn_id, + candidate_item->vxlan_info.vxlan_outer_local_port,candidate_item->vxlan_info.vxlan_outer_gdev_port, + candidate_item->vxlan_info.vxlan_outer_local_ip,candidate_item->vxlan_info.vxlan_outer_gdev_ip, + candidate_item->vxlan_info.vxlan_outer_local_mac,candidate_item->vxlan_info.vxlan_outer_gdev_mac, + candidate_item->vxlan_info.vxlan_inner_smac,candidate_item->vxlan_info.vxlan_inner_dmac, + candidate_item->is_vaild, candidate_item->op_time); line_rule.table_line=table_line; line_rule.expire_after=0; p_line = &line_rule; @@ -296,9 +302,20 @@ void Maat_set_cmd_line(Maat_feather_t feather, struct mrl_candidate_item *candid if(ret < 0) { MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"Maat_set_cmd_line","Maat_cmd_set_lines func error! ret is %d",ret); - assert(0); } - + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"Maat_set_cmd_line","maat set candidate item:" + "config_id:%d,group_id:%d,addr_type:%d,ip_addr:%s,location:%d,mrl_ip:%s,link_id:%d,encap_type:%d," + "link_dir:%d,vpn_id:%d,local_port:%s,gdev_port:%s, local_ip:%s,gdev_ip:%s,local_mac:%s, gdev_mac:%s," + "inner_smac:%s, inner_dmac:%s,is_vaild:%d,op_time:%s", + candidate_item->config_id, candidate_item->group_id,candidate_item->addr_type, candidate_item->ip_addr, + candidate_item->location, candidate_item->mrl_ip,candidate_item->vxlan_info.vxlan_link_id, + candidate_item->vxlan_info.vxlan_encap_type, candidate_item->vxlan_info.vxlan_link_dir, + candidate_item->vxlan_info.vxlan_vpn_id, + candidate_item->vxlan_info.vxlan_outer_local_port,candidate_item->vxlan_info.vxlan_outer_gdev_port, + candidate_item->vxlan_info.vxlan_outer_local_ip,candidate_item->vxlan_info.vxlan_outer_gdev_ip, + candidate_item->vxlan_info.vxlan_outer_local_mac,candidate_item->vxlan_info.vxlan_outer_gdev_mac, + candidate_item->vxlan_info.vxlan_inner_smac, candidate_item->vxlan_info.vxlan_inner_dmac, + candidate_item->is_vaild,candidate_item->op_time); return; } @@ -320,26 +337,23 @@ unsigned int get_gdev_ip_index(UINT32 gdev_ip) void mrl_identify_nominee(struct streaminfo *mystream) { - char dip[MRL_STR_IP_LEN]; - memset(dip,0,MRL_STR_IP_LEN); - + char ip_addr[MRL_STR_IP_LEN]; + memset(ip_addr,0,MRL_STR_IP_LEN); uint32_t gdev_ip; + long ret = 0; unsigned int index = 0; struct mrl_candidate_item candidate_item; memset(&candidate_item ,0,sizeof(struct mrl_candidate_item)); - inet_ntop(AF_INET, &(mystream->addr.tuple4_v4->daddr), dip, MRL_STR_IP_LEN); - if(MESA_htable_search_cb(mrl_instance.ht_nominee, (const unsigned char *)dip, MRL_STR_IP_LEN,ht_search_cb,(void *)&candidate_item,NULL) != NULL) + inet_ntop(AF_INET, &(mystream->addr.tuple4_v4->saddr), ip_addr, MRL_STR_IP_LEN); + MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_identify_nominee","cur identify nominee stream ip is %s\n",ip_addr); + if(MESA_htable_search_cb(mrl_instance.ht_nominee, (const unsigned char *)ip_addr, MRL_STR_IP_LEN,ht_search_cb,(void *)&candidate_item,&ret) != NULL) { get_rawpkt_opt_from_streaminfo(mystream, RAW_PKT_GET_GDEV_IP, &(gdev_ip)); - printf("cur gdev ip is %d\n",gdev_ip); + //printf("cur gdev ip is %d\n",gdev_ip); index = get_gdev_ip_index(gdev_ip); - printf("cur gdev info index is %d\n",index); + //printf("cur gdev info index is %d\n",index); assert(index < mrl_instance.mrl_cfg.vxlan_gdev_num);//ھ˵ݰGDEV̽GDEVУ - mrl_get_vxlan_info(&(candidate_item.vxlan_info),index); - MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_identify_nominee","get candidate item:" - "config_id:%d,group_id:%d,addr_type:%d,ip_addr:%s,location:%d,mrl_ip:%s,is_vaild:%d,op_time:%s", - candidate_item.config_id, candidate_item.group_id,candidate_item.addr_type, candidate_item.ip_addr, - candidate_item.location, candidate_item.mrl_ip,candidate_item.is_vaild,candidate_item.op_time); + mrl_get_vxlan_info(&(candidate_item.vxlan_info),index); Maat_set_cmd_line(mrl_instance.candidate_feather,&candidate_item); } } diff --git a/src/mrl_redis.o b/src/mrl_redis.o deleted file mode 100644 index a5987ea..0000000 Binary files a/src/mrl_redis.o and /dev/null differ diff --git a/src/mrl_utils.o b/src/mrl_utils.o deleted file mode 100644 index 83236e2..0000000 Binary files a/src/mrl_utils.o and /dev/null differ -- cgit v1.2.3