86 lines
2.6 KiB
Diff
86 lines
2.6 KiB
Diff
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
|
|
|