代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/gazelle 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From fa28c2bf790466ab3a4cfc8fa39ed14764797e87 Mon Sep 17 00:00:00 2001
From: zhengjiebing <zhengjiebing_yewu@cmss.chinamobile.com>
Date: Tue, 2 Jan 2024 17:10:44 +0800
Subject: [PATCH] replace with gz_addr_t
---
src/common/gazelle_opt.h | 5 +----
src/lstack/core/lstack_control_plane.c | 6 +++---
src/lstack/core/lstack_lwip.c | 3 +--
src/lstack/netif/lstack_vdev.c | 16 +++++++++-------
src/ltran/ltran_forward.c | 10 +++++-----
src/ltran/ltran_stat.c | 4 ++--
src/ltran/ltran_tcp_conn.c | 4 ++--
src/ltran/ltran_tcp_sock.c | 4 ++--
src/ltran/ltran_timer.c | 4 ++--
9 files changed, 27 insertions(+), 29 deletions(-)
diff --git a/src/common/gazelle_opt.h b/src/common/gazelle_opt.h
index bb540f4..36915c6 100644
--- a/src/common/gazelle_opt.h
+++ b/src/common/gazelle_opt.h
@@ -27,6 +27,7 @@
#define KERNEL_EPOLL_MAX 512
#define ETHER_ADDR_LEN 6
+#define IPV6_ADDR_LEN 16
#define DEFAULT_RING_SIZE (512)
#define DEFAULT_RING_MASK (511)
@@ -52,10 +53,6 @@
#define STACK_THREAD_DEFAULT 4
#define STACK_NIC_READ_DEFAULT 128
-/* same as define in lwip/ip_addr.h */
-#define GZ_ADDR_TYPE_V4 0
-#define GZ_ADDR_TYPE_V6 6
-
#define MTU_DEFAULT_DATA_LEN 1460
#define VLAN_HEAD_LEN 4
#define IPV6_EXTRA_HEAD_LEN 20
diff --git a/src/lstack/core/lstack_control_plane.c b/src/lstack/core/lstack_control_plane.c
index 668ff80..2d629c8 100644
--- a/src/lstack/core/lstack_control_plane.c
+++ b/src/lstack/core/lstack_control_plane.c
@@ -361,12 +361,12 @@ static int32_t reg_conn(enum tcp_list_state table_state, enum reg_ring_type reg_
continue;
}
qtuple.protocol = 0;
- qtuple.src_ip = conn->conn_list[i].lip.u_addr.ip4.addr;
+ qtuple.src_ip = conn->conn_list[i].lip;
qtuple.src_port = lwip_htons(conn->conn_list[i].l_port);
- qtuple.dst_ip = conn->conn_list[i].rip.u_addr.ip4.addr;
+ qtuple.dst_ip = conn->conn_list[i].rip;
qtuple.dst_port = lwip_htons(conn->conn_list[i].r_port);
- if ((table_state == LISTEN_LIST) && (!match_host_addr(qtuple.src_ip))) {
+ if ((table_state == LISTEN_LIST) && (!match_host_addr(qtuple.src_ip.u_addr.ip4.addr))) {
continue;
}
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index 4953f3d..87ec1f5 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -446,8 +446,7 @@ static inline ssize_t app_buff_write(struct lwip_sock *sock, void *buf, size_t l
} else if (addr->sa_family == AF_INET6) {
struct sockaddr_in6 *saddr = (struct sockaddr_in6 *)addr;
for (int i = 0; i < write_num; i++) {
- memcpy_s(pbufs[i]->addr.u_addr.ip6.addr, sizeof(pbufs[i]->addr.u_addr.ip6.addr),
- saddr->sin6_addr.s6_addr, sizeof(saddr->sin6_addr.s6_addr));
+ memcpy_s(pbufs[i]->addr.u_addr.ip6.addr, IPV6_ADDR_LEN, saddr->sin6_addr.s6_addr, IPV6_ADDR_LEN);
pbufs[i]->port = lwip_ntohs((saddr)->sin6_port);
IP_SET_TYPE(&pbufs[i]->addr, IPADDR_TYPE_V6);
}
diff --git a/src/lstack/netif/lstack_vdev.c b/src/lstack/netif/lstack_vdev.c
index ccf664a..9a79dc3 100644
--- a/src/lstack/netif/lstack_vdev.c
+++ b/src/lstack/netif/lstack_vdev.c
@@ -185,10 +185,12 @@ int32_t vdev_reg_xmit(enum reg_ring_type type, struct gazelle_quintuple *qtuple)
delete_user_process_port(qtuple->src_port, PORT_CONNECT);
uint16_t queue_id = get_protocol_stack()->queue_id;
if (queue_id != 0) {
- transfer_delete_rule_info_to_process0(qtuple->dst_ip, qtuple->src_port, qtuple->dst_port);
+ transfer_delete_rule_info_to_process0(qtuple->dst_ip.u_addr.ip4.addr,
+ qtuple->src_port, qtuple->dst_port);
}
} else {
- transfer_delete_rule_info_to_process0(qtuple->dst_ip, qtuple->src_port, qtuple->dst_port);
+ transfer_delete_rule_info_to_process0(qtuple->dst_ip.u_addr.ip4.addr,
+ qtuple->src_port, qtuple->dst_port);
}
}
@@ -197,12 +199,12 @@ int32_t vdev_reg_xmit(enum reg_ring_type type, struct gazelle_quintuple *qtuple)
if (get_global_cfg_params()->is_primary) {
add_user_process_port(qtuple->src_port, get_global_cfg_params()->process_idx, PORT_CONNECT);
if (queue_id != 0) {
- transfer_create_rule_info_to_process0(queue_id, qtuple->src_ip, qtuple->dst_ip,
- qtuple->src_port, qtuple->dst_port);
+ transfer_create_rule_info_to_process0(queue_id, qtuple->src_ip.u_addr.ip4.addr,
+ qtuple->dst_ip.u_addr.ip4.addr, qtuple->src_port, qtuple->dst_port);
}
} else {
- transfer_create_rule_info_to_process0(queue_id, qtuple->src_ip, qtuple->dst_ip,
- qtuple->src_port, qtuple->dst_port);
+ transfer_create_rule_info_to_process0(queue_id, qtuple->src_ip.u_addr.ip4.addr,
+ qtuple->dst_ip.u_addr.ip4.addr, qtuple->src_port, qtuple->dst_port);
}
}
@@ -228,7 +230,7 @@ int32_t vdev_reg_xmit(enum reg_ring_type type, struct gazelle_quintuple *qtuple)
struct protocol_stack *stack = get_protocol_stack();
if (type == REG_RING_TCP_LISTEN || type == REG_RING_TCP_LISTEN_CLOSE) {
- if (!match_host_addr(qtuple->src_ip)) {
+ if (!match_host_addr(qtuple->src_ip.u_addr.ip4.addr)) {
LSTACK_LOG(INFO, LSTACK, "lstack ip not match in conf.\n");
return 0;
}
diff --git a/src/ltran/ltran_forward.c b/src/ltran/ltran_forward.c
index a6f2d71..ee379b5 100644
--- a/src/ltran/ltran_forward.c
+++ b/src/ltran/ltran_forward.c
@@ -246,8 +246,8 @@ static __rte_always_inline int32_t tcp_handle(struct rte_mbuf *m, const struct r
struct gazelle_tcp_sock *tcp_sock = NULL;
struct gazelle_quintuple quintuple;
- quintuple.dst_ip = ipv4_hdr->dst_addr;
- quintuple.src_ip = ipv4_hdr->src_addr;
+ quintuple.dst_ip.u_addr.ip4.addr = ipv4_hdr->dst_addr;
+ quintuple.src_ip.u_addr.ip4.addr = ipv4_hdr->src_addr;
quintuple.dst_port = tcp_hdr->dst_port;
quintuple.src_port = tcp_hdr->src_port;
quintuple.protocol = 0;
@@ -260,7 +260,7 @@ static __rte_always_inline int32_t tcp_handle(struct rte_mbuf *m, const struct r
}
tcp_sock = gazelle_sock_get_by_min_conn(gazelle_get_tcp_sock_htable(),
- quintuple.dst_ip, quintuple.dst_port);
+ quintuple.dst_ip.u_addr.ip4.addr, quintuple.dst_port);
if (unlikely(tcp_sock == NULL)) {
return GAZELLE_ERR;
}
@@ -494,7 +494,7 @@ static void tcp_hash_table_modify(struct gazelle_stack *stack, const struct reg_
case REG_RING_TCP_LISTEN:
/* add sock htable */
tcp_sock = gazelle_sock_add_by_ipporttid(gazelle_get_tcp_sock_htable(),
- transfer_qtuple.dst_ip, transfer_qtuple.dst_port, msg->tid);
+ transfer_qtuple.dst_ip.u_addr.ip4.addr, transfer_qtuple.dst_port, msg->tid);
if (tcp_sock == NULL) {
LTRAN_ERR("add tcp sock htable failed\n");
break;
@@ -506,7 +506,7 @@ static void tcp_hash_table_modify(struct gazelle_stack *stack, const struct reg_
case REG_RING_TCP_LISTEN_CLOSE:
/* del sock htable */
gazelle_sock_del_by_ipporttid(gazelle_get_tcp_sock_htable(),
- transfer_qtuple.dst_ip, transfer_qtuple.dst_port, msg->tid);
+ transfer_qtuple.dst_ip.u_addr.ip4.addr, transfer_qtuple.dst_port, msg->tid);
break;
case REG_RING_TCP_CONNECT:
/* add conn htable */
diff --git a/src/ltran/ltran_stat.c b/src/ltran/ltran_stat.c
index 2a0c03a..dfd5fc9 100644
--- a/src/ltran/ltran_stat.c
+++ b/src/ltran/ltran_stat.c
@@ -267,8 +267,8 @@ void handle_resp_ltran_conn(int32_t fd)
if (index < GAZELLE_LSTACK_MAX_CONN) {
forward_table.conn_list[index].protocol = conn->quintuple.protocol;
forward_table.conn_list[index].tid = conn->tid;
- forward_table.conn_list[index].dst_ip = conn->quintuple.dst_ip;
- forward_table.conn_list[index].src_ip = conn->quintuple.src_ip;
+ forward_table.conn_list[index].dst_ip = conn->quintuple.dst_ip.u_addr.ip4.addr;
+ forward_table.conn_list[index].src_ip = conn->quintuple.src_ip.u_addr.ip4.addr;
forward_table.conn_list[index].dst_port = ntohs(conn->quintuple.dst_port);
forward_table.conn_list[index].src_port = ntohs(conn->quintuple.src_port);
}
diff --git a/src/ltran/ltran_tcp_conn.c b/src/ltran/ltran_tcp_conn.c
index e0ad562..026d22a 100644
--- a/src/ltran/ltran_tcp_conn.c
+++ b/src/ltran/ltran_tcp_conn.c
@@ -78,8 +78,8 @@ struct gazelle_tcp_conn_hbucket *gazelle_conn_hbucket_get(struct gazelle_tcp_con
const struct gazelle_quintuple *quintuple)
{
uint32_t index;
- index = tuple_hash_fn(quintuple->src_ip, quintuple->src_port, quintuple->dst_ip, quintuple->dst_port) %
- GAZELLE_MAX_CONN_HTABLE_SIZE;
+ index = tuple_hash_fn(quintuple->src_ip.u_addr.ip4.addr, quintuple->src_port, quintuple->dst_ip.u_addr.ip4.addr,
+ quintuple->dst_port) % GAZELLE_MAX_CONN_HTABLE_SIZE;
return &conn_htable->array[index];
}
diff --git a/src/ltran/ltran_tcp_sock.c b/src/ltran/ltran_tcp_sock.c
index d6a0d17..940ded8 100644
--- a/src/ltran/ltran_tcp_sock.c
+++ b/src/ltran/ltran_tcp_sock.c
@@ -104,8 +104,8 @@ static void recover_sock_info_from_conn(struct gazelle_tcp_sock *tcp_sock)
head = &conn_htable->array[i].chain;
hlist_for_each_entry(conn, node, head, conn_node) {
- if ((conn->quintuple.dst_ip != tcp_sock->ip) || (conn->quintuple.dst_port != tcp_sock->port) ||
- (conn->tid != tcp_sock->tid)) {
+ if ((conn->quintuple.dst_ip.u_addr.ip4.addr != tcp_sock->ip) ||
+ (conn->quintuple.dst_port != tcp_sock->port) || (conn->tid != tcp_sock->tid)) {
continue;
}
count++;
diff --git a/src/ltran/ltran_timer.c b/src/ltran/ltran_timer.c
index 85ea324..96c622e 100644
--- a/src/ltran/ltran_timer.c
+++ b/src/ltran/ltran_timer.c
@@ -103,8 +103,8 @@ void gazelle_detect_conn_logout(struct gazelle_tcp_conn_htable *conn_htable)
conn_htable->array[i].chain_size--;
LTRAN_DEBUG("delete the tcp conn htable: tid %u quintuple[%u %u %u %u %u]\n",
conn->tid, conn->quintuple.protocol,
- conn->quintuple.src_ip, (uint32_t)ntohs(conn->quintuple.src_port),
- conn->quintuple.dst_ip, (uint32_t)ntohs(conn->quintuple.dst_port));
+ conn->quintuple.src_ip.u_addr.ip4.addr, (uint32_t)ntohs(conn->quintuple.src_port),
+ conn->quintuple.dst_ip.u_addr.ip4.addr, (uint32_t)ntohs(conn->quintuple.dst_port));
rte_free(conn);
}
}
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。