代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/lwip 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From f5df6b241f38a5830920038c05d41ed4444efe63 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Mon, 5 Feb 2024 17:41:16 +0800
Subject: add struct gz addr
---
src/core/tcp.c | 2 +-
src/core/udp.c | 2 +-
src/include/lwipopts.h | 1 +
src/include/reg_sock.h | 36 +++++++++++++++++++++++++++++++++---
4 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/src/core/tcp.c b/src/core/tcp.c
index 17f922e..9f240b8 100644
--- a/src/core/tcp.c
+++ b/src/core/tcp.c
@@ -1161,7 +1161,7 @@ tcp_new_port(void)
if (__atomic_load_n(&port_state[tcp_port - TCP_LOCAL_PORT_RANGE_START], __ATOMIC_ACQUIRE) == 0) {
#if GAZELLE_ENABLE
- if (port_in_stack_queue(pcb->remote_ip, pcb->local_ip, pcb->remote_port, tcp_port)) {
+ if (port_in_stack_queue((gz_addr_t *)&pcb->remote_ip, (gz_addr_t *)&pcb->local_ip, pcb->remote_port, tcp_port)) {
tmp_port = tcp_port;
__atomic_store_n(&port_state[tcp_port - TCP_LOCAL_PORT_RANGE_START], 1, __ATOMIC_RELEASE);
break;
diff --git a/src/core/udp.c b/src/core/udp.c
index 02ffe36..ca82e51 100644
--- a/src/core/udp.c
+++ b/src/core/udp.c
@@ -132,7 +132,7 @@ udp_new_port(struct udp_pcb *dst_pcb)
}
if (__atomic_load_n(&port_state[udp_port - UDP_LOCAL_PORT_RANGE_START], __ATOMIC_ACQUIRE) == 0) {
- if (port_in_stack_queue(dst_pcb->remote_ip, dst_pcb->local_ip, dst_pcb->remote_port, udp_port)) {
+ if (port_in_stack_queue((gz_addr_t *)&dst_pcb->remote_ip, (gz_addr_t *)&dst_pcb->local_ip, dst_pcb->remote_port, udp_port)) {
tmp_port = udp_port;
__atomic_store_n(&port_state[udp_port - UDP_LOCAL_PORT_RANGE_START], 1, __ATOMIC_RELEASE);
break;
diff --git a/src/include/lwipopts.h b/src/include/lwipopts.h
index 11bc65a..4cd2d7a 100644
--- a/src/include/lwipopts.h
+++ b/src/include/lwipopts.h
@@ -178,6 +178,7 @@
*/
#define LWIP_IPV6 1
#define IP6_HLEN 40
+#define LWIP_IPV6_SCOPES 1
/*
---------------------------------
diff --git a/src/include/reg_sock.h b/src/include/reg_sock.h
index 5a5e971..a11102e 100644
--- a/src/include/reg_sock.h
+++ b/src/include/reg_sock.h
@@ -34,7 +34,35 @@
#define __REG_SOCK_H__
#include <stdbool.h>
-#include "lwip/ip_addr.h"
+
+#include "lwipopts.h"
+
+/* compatible with ip4_addr_t */
+struct gz_ip4 {
+ uint32_t addr;
+};
+
+/* compatible with ip6_addr_t */
+#if LWIP_IPV6
+struct gz_ip6 {
+ uint32_t addr[4];
+#if LWIP_IPV6_SCOPES
+ uint8_t zone;
+#endif /* LWIP_IPV6_SCOPES */
+};
+#endif /* LWIP_IPV6 */
+
+/* gazelle ip address, compatible with ip_addr_t */
+typedef struct gz_addr {
+ union {
+#if LWIP_IPV6
+ struct gz_ip6 ip6;
+#endif /* LWIP_IPV6 */
+ struct gz_ip4 ip4;
+ } u_addr;
+ /** @ref lwip_ip_addr_type */
+ uint8_t type;
+} gz_addr_t;
enum reg_ring_type {
REG_RING_TCP_LISTEN = 0,
@@ -45,10 +73,12 @@ enum reg_ring_type {
};
struct gazelle_quintuple {
- uint32_t protocol;
+ uint32_t protocol;
/* net byte order */
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
@@ -65,6 +95,6 @@ struct reg_ring_msg {
};
extern int vdev_reg_xmit(enum reg_ring_type type, struct gazelle_quintuple *qtuple);
-extern bool port_in_stack_queue(ip_addr_t src_ip, ip_addr_t dst_ip, uint16_t src_port, uint16_t dst_port);
+extern bool port_in_stack_queue(gz_addr_t *src_ip, gz_addr_t *dst_ip, uint16_t src_port, uint16_t dst_port);
#endif /* __REG_SOCK_H__ */
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。