From 304c818f54efaaecb42f7d746a3b20aa0e0fcfb3 Mon Sep 17 00:00:00 2001 From: luwenpeng Date: Tue, 23 Nov 2021 14:56:33 +0300 Subject: [PATCH] =?UTF-8?q?=E5=BD=93Sapp=E6=94=B6=E5=88=B0=E7=9A=84IP?= =?UTF-8?q?=E5=8C=85=E8=BF=9B=E8=A1=8C=E5=88=86=E7=89=87=E9=87=8D=E7=BB=84?= =?UTF-8?q?=E5=90=8E=EF=BC=8CKNI=E5=8F=91=E7=BB=99TFE=E7=9A=84=E5=8C=85?= =?UTF-8?q?=E9=9C=80=E9=87=8D=E6=96=B0=E8=AE=A1=E7=AE=97IPv4=E7=9A=84?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=92=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/kni_entry.cpp | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/entry/src/kni_entry.cpp b/entry/src/kni_entry.cpp index ee1bc7b..f2b6091 100644 --- a/entry/src/kni_entry.cpp +++ b/entry/src/kni_entry.cpp @@ -790,12 +790,43 @@ static int send_to_tfe_tun_mode(char *raw_data, uint16_t raw_len, addr_type_t ad static int send_to_tfe(char *raw_data, uint16_t raw_len, int thread_seq, int tfe_id, addr_type_t addr_type){ int mode = g_kni_handle->deploy_mode; int ret; - if(mode == KNI_DEPLOY_MODE_TUN){ - ret = send_to_tfe_tun_mode(raw_data, raw_len, addr_type); + + if (addr_type == ADDR_TYPE_IPV6) + { + if (mode == KNI_DEPLOY_MODE_TUN) + { + ret = send_to_tfe_tun_mode(raw_data, raw_len, addr_type); + } + else + { + ret = send_to_tfe_normal_mode(raw_data, raw_len, thread_seq, tfe_id, addr_type); + } } - else{ - ret = send_to_tfe_normal_mode(raw_data, raw_len, thread_seq, tfe_id, addr_type); + else + { + struct pkt_info pktinfo; + memset(&pktinfo, 0, sizeof(pkt_info)); + + char *ptr = (char *)malloc(raw_len); + memcpy(ptr, raw_data, raw_len); + kni_ipv4_header_parse((void*)ptr, &pktinfo); + struct iphdr *iphdr = (struct iphdr*)ptr; + iphdr->check = 0; + iphdr->check = kni_ip_checksum((void*)iphdr, pktinfo.iphdr_len); + + if (mode == KNI_DEPLOY_MODE_TUN) + { + ret = send_to_tfe_tun_mode(ptr, raw_len, addr_type); + } + else + { + ret = send_to_tfe_normal_mode(ptr, raw_len, thread_seq, tfe_id, addr_type); + } + + free(ptr); + ptr = NULL; } + return ret; }