summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlijia <[email protected]>2021-01-20 14:36:14 +0800
committerlijia <[email protected]>2021-01-20 14:36:14 +0800
commit893d15d4597bcf59dd9ebefaa5ae80f083f8b7ee (patch)
tree63eaa49eae4cb821b8b6461b5f492a8744179c4d /src
parent2622066394444005663f0effdfc673b0b40b5e7e (diff)
修复双臂模式下,vlan_id没有初始化,导致误认为是开启了vlan flip功能.v4.2.25
Diffstat (limited to 'src')
-rw-r--r--src/config/config_parse.cpp3
-rw-r--r--src/dealpkt/deal_vxlan.c2
-rw-r--r--src/inner_plug/gdev_assistant.c18
-rw-r--r--src/packet_io/packet_io_hook.c2
-rw-r--r--src/packet_io/packet_io_pcap.c5
-rw-r--r--src/packet_io/sapp_inject.c2
-rw-r--r--src/packet_io/sendpacket.c9
7 files changed, 23 insertions, 18 deletions
diff --git a/src/config/config_parse.cpp b/src/config/config_parse.cpp
index 1c07038..5ba04a5 100644
--- a/src/config/config_parse.cpp
+++ b/src/config/config_parse.cpp
@@ -1316,7 +1316,8 @@ int sapp_parse_config(void)
void sapp_init_breakpad_mini(void)
{
#ifdef GIT_VERSION
- __attribute__((__used__)) const char *sapp_git_ver = GIT_VERSION;
+ //__attribute__((__used__)) const char *sapp_git_ver = GIT_VERSION;
+ const char *sapp_git_ver = GIT_VERSION;
#else
const char * sapp_git_ver = "sapp_version_unkonw";
#endif
diff --git a/src/dealpkt/deal_vxlan.c b/src/dealpkt/deal_vxlan.c
index 6ef56b6..59387a1 100644
--- a/src/dealpkt/deal_vxlan.c
+++ b/src/dealpkt/deal_vxlan.c
@@ -16,7 +16,7 @@ static int set_vxlan_addr(const void *this_layer_hdr, struct layer_addr_vxlan *a
addr->link_type = vxlan_hdr->link_layer_type;
vlan_id_high = vxlan_hdr->vlan_id_half_high;
vlan_id_low = vxlan_hdr->vlan_id_half_low;
- addr->vlan_id = (vlan_id_high<<8) | vlan_id_low;
+ addr->vlan_id = htons((vlan_id_high<<4) | vlan_id_low);
return 0;
}
diff --git a/src/inner_plug/gdev_assistant.c b/src/inner_plug/gdev_assistant.c
index e884db3..db176fb 100644
--- a/src/inner_plug/gdev_assistant.c
+++ b/src/inner_plug/gdev_assistant.c
@@ -274,7 +274,7 @@ int packet_io_send_fake_pkt_by_gdev(MESA_send_handle *send_handle, enum addr_typ
//const struct streaminfo_private *pstrem_pr = (const struct streaminfo_private *)send_handle->user_arg;
const struct streaminfo *pstream = (const struct streaminfo *)send_handle->user_arg;
const struct streaminfo *tmpstream = pstream;
- vxlan_header_t *vxlan_hdr;
+ inline_vxlan_hdr_t *vxlan_hdr;
struct vxlan_info mim_mem_hdr;
struct mesa_ethernet_hdr *inner_eth_hdr;
//struct mesa_udp_hdr *udp_hdr;
@@ -298,8 +298,8 @@ int packet_io_send_fake_pkt_by_gdev(MESA_send_handle *send_handle, enum addr_typ
sapp_runtime_log(20, "packet_io_send_fake_pkt_by_gdev(): get vxlan info error!\n");
return -1;
}
- data += sizeof(vxlan_header_t);/*����Ԥ����vxlanͷ��*/
- datalen -= sizeof(vxlan_header_t);
+ data += sizeof(inline_vxlan_hdr_t);/*����Ԥ����vxlanͷ��*/
+ datalen -= sizeof(inline_vxlan_hdr_t);
data += sizeof(struct mesa_ethernet_hdr);/*����mim�����MAC*/
datalen -= sizeof(struct mesa_ethernet_hdr);
@@ -323,12 +323,12 @@ int packet_io_send_fake_pkt_by_gdev(MESA_send_handle *send_handle, enum addr_typ
return -1;
}
- data -= sizeof(vxlan_header_t);
- datalen += sizeof(vxlan_header_t);
+ data -= sizeof(inline_vxlan_hdr_t);
+ datalen += sizeof(inline_vxlan_hdr_t);
- vxlan_hdr = (vxlan_header_t *)data;
+ vxlan_hdr = (inline_vxlan_hdr_t *)data;
- memset(vxlan_hdr, 0, sizeof(vxlan_header_t));
+ memset(vxlan_hdr, 0, sizeof(inline_vxlan_hdr_t));
vxlan_hdr->link_id = mim_mem_hdr.link_id;
vxlan_hdr->link_layer_type = mim_mem_hdr.encap_type;
@@ -346,7 +346,7 @@ int packet_io_send_fake_pkt_by_gdev(MESA_send_handle *send_handle, enum addr_typ
udp_hdr->uh_sport = htons((unsigned short)sapp_global_single.send_fake_pkt_gdev_sport); /* ���������ļ���дvxlanԴ�˿� */
udp_hdr->uh_dport = htons(4789);
- udp_hdr->uh_ulen = htons(datalen + sizeof(vxlan_header_t) + sizeof(struct mesa_udp_hdr));
+ udp_hdr->uh_ulen = htons(datalen + sizeof(inline_vxlan_hdr_t) + sizeof(struct mesa_udp_hdr));
udp_hdr->uh_sum = 0;
data -= sizeof(struct mesa_ip4_hdr);
@@ -355,7 +355,7 @@ int packet_io_send_fake_pkt_by_gdev(MESA_send_handle *send_handle, enum addr_typ
ip4_hdr->ip_v = 4;
ip4_hdr->ip_hl = 5;
ip4_hdr->ip_tos = 0;
- ip4_hdr->ip_len = htons(datalen + sizeof(vxlan_header_t) + sizeof(struct mesa_udp_hdr) + sizeof(struct mesa_ip4_hdr));
+ ip4_hdr->ip_len = htons(datalen + sizeof(inline_vxlan_hdr_t) + sizeof(struct mesa_udp_hdr) + sizeof(struct mesa_ip4_hdr));
ip4_hdr->ip_off = 0;
ip4_hdr->ip_id = MESA_rand_range(10000, 60000);
ip4_hdr->ip_ttl = MESA_rand_range(64, 128);
diff --git a/src/packet_io/packet_io_hook.c b/src/packet_io/packet_io_hook.c
index 25bb79f..f38397a 100644
--- a/src/packet_io/packet_io_hook.c
+++ b/src/packet_io/packet_io_hook.c
@@ -257,6 +257,8 @@ int packet_io_hook_sendto(const raw_pkt_t *raw_pkt, unsigned char route_dir, cha
if(OVERLAY_MODE_VXLAN == sapp_global_val->config.packet_io.packet_io_tunnel.overlay_mode_bin){
ret = packet_io_hook_output_vxlan((raw_pkt_t *)raw_pkt, (void *)send_pkt_data, route_dir);
+ }else if(OVERLAY_MODE_NONE == sapp_global_val->config.packet_io.packet_io_tunnel.overlay_mode_bin){
+ ret = 0;
}else{
sapp_runtime_log(20, "packet_io_hook_sendto() error, unsupport overlay_mode:%d\n", sapp_global_val->config.packet_io.packet_io_tunnel.overlay_mode_bin);
}
diff --git a/src/packet_io/packet_io_pcap.c b/src/packet_io/packet_io_pcap.c
index 9933480..e156067 100644
--- a/src/packet_io/packet_io_pcap.c
+++ b/src/packet_io/packet_io_pcap.c
@@ -1042,7 +1042,7 @@ static int gen_route_dir_for_dumpfile_mode(const u_char *data)
static void __pcap_pkt_handle(u_char *user, const struct pcap_pkthdr *hdr, const u_char *data)
{
- pkt_queue_t pkt_queue_node;
+ pkt_queue_t pkt_queue_node = {};
int thread_num, ret;
if(CAP_MODEL_PCAP_ONLINE == g_pcap_cap_mode){
@@ -1114,6 +1114,9 @@ retry:
pkt_queue_node.raw_pkt.magic_num = RAW_PKT_MAGIC_NUM; /* 2014-12-11 lijia add */
pkt_queue_node.raw_pkt.hd_hash = 0; /* 2016-05-05 lijia add, pcapģʽ��֧��Ӳ��HASH */
pkt_queue_node.raw_pkt.io_lib_pkt_reference = pkt_queue_node.raw_pkt.__lib_raw_pkt_data; /* ����dpdkģʽ, ���˱�����ֵ */
+ pkt_queue_node.raw_pkt.vlan_flipping_couple[0] = 0;
+ pkt_queue_node.raw_pkt.vlan_flipping_couple[1] = 0;
+ pkt_queue_node.raw_pkt.mac_flipping_enable = 0;
pkt_queue_node.raw_pkt.diagnose_error_to_dump = 0;
pkt_queue_node.raw_pkt.overlay_layer_bytes = 0;
diff --git a/src/packet_io/sapp_inject.c b/src/packet_io/sapp_inject.c
index 53b24d4..559f33f 100644
--- a/src/packet_io/sapp_inject.c
+++ b/src/packet_io/sapp_inject.c
@@ -51,7 +51,7 @@ int sapp_inject_pkt(struct streaminfo *stream, enum sapp_inject_opt sio, const v
stream_pr->stream_c2s_route_dir, snd_routedir, send_stream_dir,
ip4hdr->ip_ttl, ntohs(ip4hdr->ip_id), ntohs(ip4hdr->ip_sum));
}else{
- //todo;
+ //todo ipv6;
}
}
diff --git a/src/packet_io/sendpacket.c b/src/packet_io/sendpacket.c
index 6e935a7..4825ac4 100644
--- a/src/packet_io/sendpacket.c
+++ b/src/packet_io/sendpacket.c
@@ -1872,7 +1872,6 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct
switch(stream->addr.addrtype){
case ADDR_TYPE_IPV4:
{
- const struct mesa_ip4_hdr *ip4hdr = (struct mesa_ip4_hdr *)buf;
/* 2015-12-30 lijia modify, IP�Ͷ˿ڴ洢��һ���ṹ, �ȹ���TCP/UDP�� */
if(STREAM_TYPE_TCP == stream->type){
transport_layer_len = sizeof(struct mesa_tcp_hdr);
@@ -1894,8 +1893,8 @@ static int build_net_layer_pkt(const struct streaminfo *top_stream, const struct
/* TCP��У�����ҪIP��ַ��Ϣ, ����Ҫ�ڹ�����IP����Ϣ��, �ټ���checksum */
checksum_for_carry_layer(buf, __ADDR_TYPE_IP_PAIR_V4, carry_layer_type, carry_layer_len+transport_layer_len);
carry_layer_type = __ADDR_TYPE_IP_PAIR_V4;
-
- sapp_runtime_log(RLOG_LV_DEBUG, "build_net_layer_pkt()->IPV4, %s, send_dir:%d, ipid:%u, ip_checksum:0x%x",
+ const struct mesa_ip4_hdr *ip4hdr = (struct mesa_ip4_hdr *)buf;
+ sapp_runtime_log(RLOG_LV_DEBUG, "build_net_layer_pkt()->IPV4, %s, send_stream_dir:%d, ipid:%u, ip_checksum:0x%x",
sapp_raw_ipv4_ntop(ip4hdr, debug_print_buf, sizeof(debug_print_buf)), send_stream_dir,
ntohs(ip4hdr->ip_id), ntohs(ip4hdr->ip_sum));
}
@@ -2237,7 +2236,7 @@ static int __do_kill_tcp(struct streaminfo *stream, const void *ext_raw_pkt, int
goto fun_exit;
}
if(sapp_global_val->config.packet_io.inject_pkt_mode == SEND_PKT_MODE_GDEV){ /* gdevע��ģʽʱԤ���ײ��װvxlan���Ŀռ�, �����ٶ���copy */
- reserved_hdr_len += sizeof(vxlan_header_t);
+ reserved_hdr_len += sizeof(inline_vxlan_hdr_t);
}
send_handle->send_buf = packet_io_get_sendbuf(SEND_TYPE_LINK_INJECT, thread_num);
@@ -2282,7 +2281,7 @@ static int __do_kill_tcp(struct streaminfo *stream, const void *ext_raw_pkt, int
goto fun_exit;
}
if(sapp_global_val->config.packet_io.inject_pkt_mode == SEND_PKT_MODE_GDEV){ /* gdevע��ģʽʱԤ���ײ��װvxlan���Ŀռ�, �����ٶ���copy */
- reserved_hdr_len += sizeof(vxlan_header_t);
+ reserved_hdr_len += sizeof(inline_vxlan_hdr_t);
}
low_net_layer_type = get_eth_carry_layer_type(stream, stream_pr->stream_public.curdir ^ DIR_DOUBLE);
if(low_net_layer_type < 0){