diff options
| author | lijie <[email protected]> | 2018-12-07 20:02:24 +0800 |
|---|---|---|
| committer | lijie <[email protected]> | 2018-12-07 20:02:24 +0800 |
| commit | d626a2162b0ba811f7e4c5bf253f33e5170b14c7 (patch) | |
| tree | 4b9e4f0c6e03859cd1f519ca70a2f7334913cc57 /src | |
| parent | ac94ad0124de7a529854ba7e3914ac26b8255ffe (diff) | |
增加调试信息,方便调试link id
Diffstat (limited to 'src')
| -rw-r--r-- | src/mrl_main.c | 2 | ||||
| -rw-r--r-- | src/mrl_packet.c | 19 | ||||
| -rw-r--r-- | src/mrl_redis.c | 45 |
3 files changed, 34 insertions, 32 deletions
diff --git a/src/mrl_main.c b/src/mrl_main.c index f09e1ae..ed40fd2 100644 --- a/src/mrl_main.c +++ b/src/mrl_main.c @@ -724,7 +724,7 @@ extern "C" char mrl_udp_entry(struct streaminfo *a_udp, void **pme, int thread_ }
else
{
- if(mrl_identify_nominee(a_udp))
+ if(mrl_identify_nominee(a_udp,raw_packet))
{
ret =APP_STATE_GIVEME;
}
diff --git a/src/mrl_packet.c b/src/mrl_packet.c index 466107f..6aad69d 100644 --- a/src/mrl_packet.c +++ b/src/mrl_packet.c @@ -245,10 +245,6 @@ void mrl_send_to_gdev(int thread_seq, struct mrl_vxlan_info * vxlan_info, const //�ж��Ƿ���IP���ð�
bool mrl_pkt_signature_identify(struct streaminfo *mystream)
{
- 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, temp_port = 0;
uint32_t hash_sport = 0, hash_dport =0;
@@ -257,8 +253,6 @@ bool mrl_pkt_signature_identify(struct streaminfo *mystream) 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);
switch(mystream->type)
{
case STREAM_TYPE_TCP:
@@ -274,9 +268,9 @@ bool mrl_pkt_signature_identify(struct streaminfo *mystream) 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);
+ MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_pkt_signature_identify","cur stream[sip:%u,sport:%hu, dip:%u,dport:%hu]"
+ "hash info is:[hash_dport:%hu, dest_port:%u,protocol is %d",
+ sip,sport,dip,dport,hash_dport,temp_port,type);
if(hash_dport == temp_port)
{
return true;
@@ -286,9 +280,9 @@ bool mrl_pkt_signature_identify(struct streaminfo *mystream) 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);
+ MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_pkt_signature_identify","cur stream[sip:%u,sport:%hu, dip:%u,dport:%hu]"
+ "hash info is:[hash_sport:%hu, dest_port:%u,protocol is %d",
+ sip,sport,dip,dport,hash_dport,temp_port,type);
if(hash_sport == temp_port)
{
return true;
@@ -447,6 +441,7 @@ void *mrl_detect_ip_action(void *arg) break;
}
ret = MESA_lqueue_get_head(mrl_instance.mrl_queue,&detect_ip,&ip_len);
+ printf("queue head ip is %u\n",detect_ip);
if(ret != 0)
{
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);
diff --git a/src/mrl_redis.c b/src/mrl_redis.c index 7de9db1..0facf17 100644 --- a/src/mrl_redis.c +++ b/src/mrl_redis.c @@ -158,18 +158,25 @@ void nominee_update_cb(int table_id,const char *table_line,void *u_para) assert(0);
}
MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"nominee_update_cb","insert the nominee key[sip:%u, dip:%u, sport:%hu, dport:%hu] into nominee htable.",nominee_key.sip,nominee_key.dip,nominee_key.sport,nominee_key.dport);
- ret = MESA_lqueue_join_tail(mrl_instance.mrl_queue,&(nominee_key.sip),sizeof(nominee_key.sip));
- MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"nominee_update_cb","insert queue ip is %u",nominee_key.sip);
- 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);
- }
+ //ret = MESA_lqueue_join_tail(mrl_instance.mrl_queue,&(nominee_key.sip),sizeof(nominee_key.sip));
+ //MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"nominee_update_cb","insert queue ip is %u",nominee_key.sip);
+ //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_DEBUG,"nominee_update_cb","the nominee key[sip:%u, dip:%u, sport:%hu, dport:%hu] is duplicated in nominee htable.",nominee_key.sip,nominee_key.dip,nominee_key.sport,nominee_key.dport);
}
+ ret = MESA_lqueue_join_tail(mrl_instance.mrl_queue,&(nominee_key.sip),sizeof(nominee_key.sip));
+ printf("nominee ip %u insert into queue\n",nominee_key.sip);
+ 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);
+ }
break;
default:
assert(0);
@@ -179,23 +186,16 @@ void nominee_update_cb(int table_id,const char *table_line,void *u_para) }
-void dnat_policy_update_cb(int table_id, const char *table_line, void *u_para)
-{
-
-}
-
Maat_feather_t mrl_Maat_feather_init()
{
MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_Maat_feather_init","start init Maat feather!");
Maat_feather_t feather;
const char *nominee_instance = "mrl_nominee";
const char *candidate_instance = "mrl_candidate";
- const char *dnat_policy_instance ="mrl_dnat_policy";
// init Maat
feather = Maat_feather(mrl_instance.mrl_cfg.Maat_max_threads, mrl_instance.mrl_cfg.Maat_table_path, mrl_instance.mrl_log_handle);
wrapped_Maat_set_feather_opt(feather, MAAT_OPT_INSTANCE_NAME, nominee_instance, strlen(nominee_instance)+1);
wrapped_Maat_set_feather_opt(feather, MAAT_OPT_INSTANCE_NAME, candidate_instance, strlen(candidate_instance)+1);
- wrapped_Maat_set_feather_opt(feather, MAAT_OPT_INSTANCE_NAME, dnat_policy_instance, strlen(dnat_policy_instance)+1);
wrapped_Maat_set_feather_opt(feather, MAAT_OPT_REDIS_IP, mrl_instance.mrl_cfg.Maat_redis_ip, strlen(mrl_instance.mrl_cfg.Maat_redis_ip)+1);
wrapped_Maat_set_feather_opt(feather, MAAT_OPT_REDIS_PORT, &(mrl_instance.mrl_cfg.Maat_redis_port), sizeof(mrl_instance.mrl_cfg.Maat_redis_port));
wrapped_Maat_set_feather_opt(feather, MAAT_OPT_STAT_FILE_PATH, mrl_instance.mrl_cfg.Maat_stat_path, strlen(mrl_instance.mrl_cfg.Maat_stat_path)+1);
@@ -210,7 +210,6 @@ Maat_feather_t mrl_Maat_feather_init() assert(0);
}
Maat_plugin_table(feather,IR_NOMINEE_IP_TABLE_NAME,NULL,nominee_update_cb,NULL,NULL);
- //Maat_plugin_table(feather,IR_DNAT_POLICY_TABLE_NAME,NULL,dnat_policy_update_cb,NULL,NULL);
return feather;
}
@@ -279,12 +278,17 @@ void mrl_get_vxlan_info(struct streaminfo *mystream, struct mrl_vxlan_info *vxl memcpy(vxlan_info->vxlan_outer_gdev_mac, mrl_instance.mrl_cfg.vxlan_outer_gdev_mac[gdev_index],strlen(mrl_instance.mrl_cfg.vxlan_outer_gdev_mac[gdev_index]));
get_rawpkt_opt_from_streaminfo(mystream, RAW_PKT_GET_VXLAN_ID, &link_id);
vxlan_info->vxlan_link_id = ntohl(link_id);
- printf("cur link id is %d\n",vxlan_info->vxlan_link_id);
+ printf("cur stream[sip:%u,sport:%hu,dip:%u,dport:%hu] link id is %d\n",mystream->addr.tuple4_v4->saddr,mystream->addr.tuple4_v4->source,mystream->addr.tuple4_v4->daddr,mystream->addr.tuple4_v4->dest,vxlan_info->vxlan_link_id);
int position = mrl_get_link_id_index(gdev_index, vxlan_info->vxlan_link_id);
if(position <0)
{
- MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"mrl_get_vxlan_info","mrl_get_link_id_index error,link id is %d,gdev index is %d,position is %d",vxlan_info->vxlan_link_id,gdev_index,position);
- assert(0);
+ printf("cur stream[sip:%u,sport:%hu,dip:%u,dport:%hu]\n",mystream->addr.tuple4_v4->saddr,mystream->addr.tuple4_v4->source,mystream->addr.tuple4_v4->daddr,mystream->addr.tuple4_v4->dest);
+ MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_FATAL,"mrl_get_vxlan_info","cur stream[sip:%u,sport:%hu,dip:%u,dport:%hu]"
+ "get link id error,link id is %d,gdev index is %d,position is %d",
+ mystream->addr.tuple4_v4->saddr,mystream->addr.tuple4_v4->source,mystream->addr.tuple4_v4->daddr,mystream->addr.tuple4_v4->dest,
+ vxlan_info->vxlan_link_id,gdev_index,position);
+ //assert(0);
+ position = 0;
}
vxlan_info->vxlan_encap_type = mrl_instance.mrl_cfg.vxlan_encap_type[gdev_index][position];
@@ -356,7 +360,8 @@ unsigned int get_gdev_ip_index(UINT32 gdev_ip) return index;
}
-bool mrl_identify_nominee(struct streaminfo *mystream)
+bool mrl_identify_nominee(struct streaminfo *mystream,void *rawpkt)
+//bool mrl_identify_nominee(struct streaminfo *mystream)
{
char ip_addr[MRL_STR_IP_LEN];
memset(ip_addr,0,MRL_STR_IP_LEN);
@@ -376,6 +381,8 @@ bool mrl_identify_nominee(struct streaminfo *mystream) if(MESA_htable_search_cb(mrl_instance.ht_nominee, (const unsigned char *)&nominee_key, sizeof(nominee_key),ht_search_cb,(void *)&candidate_item,&ret) != NULL)
{
global_stat.recv_detect_pkts ++;
+ struct iphdr *ip_hdr = (struct iphdr *)rawpkt;
+ printf("cur identify nominee pkt sip is %u,dip is %u\n",ip_hdr->saddr,ip_hdr->daddr);
MESA_handle_runtime_log(mrl_instance.mrl_log_handle, RLOG_LV_DEBUG,"mrl_identify_nominee","cur detected packet key is [sip:%u, dip:%u, sport:%hu, dport:%hu].",nominee_key.sip, nominee_key.dip, nominee_key.sport, nominee_key.dport);
get_rawpkt_opt_from_streaminfo(mystream, RAW_PKT_GET_GDEV_IP, &(gdev_ip));
index = get_gdev_ip_index(gdev_ip);
|
