1 Star 0 Fork 48

yinbin6/lwip

forked from src-openEuler/lwip 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0100-replace-qtuple-addr-with-gz_addr_t.patch 2.57 KB
一键复制 编辑 原始数据 按行查看 历史
jinag12 提交于 2024-02-06 10:45 . adapt lwip-2.2.0
From 430469b1fa14ed689781eeed14dc8ce7cadd22a3 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Mon, 5 Feb 2024 19:16:07 +0800
Subject: replace qtuple addr with gz_addr_t
---
src/include/lwip/priv/tcp_priv.h | 24 ++++++------------------
src/include/reg_sock.h | 19 ++++++++++++-------
2 files changed, 18 insertions(+), 25 deletions(-)
diff --git a/src/include/lwip/priv/tcp_priv.h b/src/include/lwip/priv/tcp_priv.h
index 75c67ee..8d7b9df 100644
--- a/src/include/lwip/priv/tcp_priv.h
+++ b/src/include/lwip/priv/tcp_priv.h
@@ -347,24 +347,12 @@ static inline int vdev_reg_done(enum reg_ring_type reg_type, const struct tcp_pc
LWIP_ASSERT("Invalid parameter", pcb != NULL);
struct gazelle_quintuple qtuple;
- if (IP_IS_V4_VAL(pcb->local_ip)) {
- qtuple.protocol = 0;
- qtuple.src_ip = ip_2_ip4(&pcb->local_ip)->addr;
- qtuple.src_port = lwip_htons(pcb->local_port);
- qtuple.dst_ip = ip_2_ip4(&pcb->remote_ip)->addr;
- qtuple.dst_port = lwip_htons(pcb->remote_port);
- } else {
-#if LWIP_IPV6
- qtuple.protocol = 1;
- qtuple.src_port = lwip_htons(pcb->local_port);
- qtuple.dst_port = lwip_htons(pcb->remote_port);
-
- for (int i = 0; i < 4; i++) {
- qtuple.src_ip6[i] = pcb->local_ip.u_addr.ip6.addr[i];
- qtuple.dst_ip6[i] = pcb->remote_ip.u_addr.ip6.addr[i];
- }
-#endif
- }
+
+ qtuple.protocol = IP_IS_V4_VAL(pcb->local_ip) ? GZ_ADDR_TYPE_V4 : GZ_ADDR_TYPE_V6;
+ qtuple.src_ip = *((gz_addr_t *)&pcb->local_ip);
+ qtuple.src_port = lwip_htons(pcb->local_port);
+ qtuple.dst_ip = *((gz_addr_t *)&pcb->remote_ip);
+ qtuple.dst_port = lwip_htons(pcb->remote_port);
#if GAZELLE_TCP_REUSE_IPPORT
if (reg_type == REG_RING_TCP_CONNECT_CLOSE) {
diff --git a/src/include/reg_sock.h b/src/include/reg_sock.h
index a11102e..466a2c2 100644
--- a/src/include/reg_sock.h
+++ b/src/include/reg_sock.h
@@ -37,6 +37,16 @@
#include "lwipopts.h"
+/* compatible with lwip_ip_addr_type */
+enum gz_ip_addr_type {
+ /** IPv4 */
+ GZ_ADDR_TYPE_V4 = 0U,
+ /** IPv6 */
+ GZ_ADDR_TYPE_V6 = 6U,
+ /** IPv4+IPv6 ("dual-stack") */
+ GZ_ADDR_TYPE_ANY = 46U
+};
+
/* compatible with ip4_addr_t */
struct gz_ip4 {
uint32_t addr;
@@ -78,13 +88,8 @@ struct gazelle_quintuple {
uint16_t src_port;
uint16_t dst_port;
- /* TODO: replace with gz_addr_t */
- uint32_t src_ip;
- uint32_t dst_ip;
-#if LWIP_IPV6
- uint32_t src_ip6[4];
- uint32_t dst_ip6[4];
-#endif
+ gz_addr_t src_ip;
+ gz_addr_t dst_ip;
};
struct reg_ring_msg {
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yinbin6/lwip.git
git@gitee.com:yinbin6/lwip.git
yinbin6
lwip
lwip
master

搜索帮助