!946 [sync] PR-937: sync virtio: solve compilation error in 2003sp3

From: @openeuler-sync-bot 
Reviewed-by: @jiangheng12 
Signed-off-by: @jiangheng12
This commit is contained in:
openeuler-ci-bot 2024-08-26 09:56:07 +00:00 committed by Gitee
commit ffdf5bf9bf
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 104 additions and 1 deletions

View File

@ -0,0 +1,73 @@
From 1b994a0e9cd2dfa59076b35e3e4c82b1a18c9e1d Mon Sep 17 00:00:00 2001
From: hkk <hankangkang5@huawei.com>
Date: Mon, 19 Aug 2024 16:34:54 +0800
Subject: [PATCH] virtio_user: check netif status
---
src/lstack/core/lstack_virtio.c | 35 +++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/src/lstack/core/lstack_virtio.c b/src/lstack/core/lstack_virtio.c
index 9862b48..4a91ed7 100644
--- a/src/lstack/core/lstack_virtio.c
+++ b/src/lstack/core/lstack_virtio.c
@@ -26,6 +26,9 @@
#define VIRTIO_DPDK_PARA_LEN 256
#define VIRTIO_TX_RX_RING_SIZE 1024
+#define VIRTIO_NETIF_CHECK_MAX_TIMES 10
+#define VIRTIO_NETIF_CMD_OUTPUT 4096
+
#define VIRTIO_MASK_BITS(mask) (32 - __builtin_clz(mask))
static struct virtio_instance g_virtio_instance = {0};
@@ -123,6 +126,27 @@ static int virtio_set_ipv4_addr(void)
return 0;
}
+static int virtio_ipv6_is_tentative(void)
+{
+ FILE *fp;
+ char output[VIRTIO_NETIF_CMD_OUTPUT] = {0};
+ int not_ready = 0;
+ /* ipv6 tentative state means not ready */
+ const char *cmd = "ip a |grep tentative";
+
+ fp = popen(cmd, "r");
+ if (fp == NULL) {
+ LSTACK_LOG(ERR, LSTACK, "%s execution failed \n", cmd);
+ return -1;
+ }
+
+ if (fgets(output, sizeof(output), fp) != NULL) {
+ not_ready = 1;
+ }
+ pclose(fp);
+ return not_ready;
+}
+
static int virtio_netif_up(void)
{
int sockfd = posix_api->socket_fn(AF_INET, SOCK_DGRAM, 0);
@@ -151,9 +175,16 @@ static int virtio_netif_up(void)
/*
* For virtio_user IPv6 addresses, the kernel will check if they are valid,
* so wait a few seconds for the address status to change from scope global tentative to scope global.
- * 3:systerm check ipv6 addr
*/
- sleep(3);
+ for (int i = 0; i < VIRTIO_NETIF_CHECK_MAX_TIMES; i++) {
+ ret = virtio_ipv6_is_tentative();
+ if (ret == 0) {
+ break;
+ } else if (ret < 0) {
+ return -1;
+ }
+ sleep(1);
+ }
return 0;
}
--
2.33.0

View File

@ -0,0 +1,24 @@
From 4a30424a4ce6135cbd118bc36f00b35955255f41 Mon Sep 17 00:00:00 2001
From: hantwofish <hankangkang5@huawei.com>
Date: Tue, 20 Aug 2024 17:28:37 +0800
Subject: [PATCH] virtio: solve compilation error in 2003sp3
---
src/lstack/core/lstack_virtio.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/lstack/core/lstack_virtio.c b/src/lstack/core/lstack_virtio.c
index 4a91ed7..7a8d947 100644
--- a/src/lstack/core/lstack_virtio.c
+++ b/src/lstack/core/lstack_virtio.c
@@ -15,6 +15,7 @@
#include <net/if.h>
#include <ifaddrs.h>
#include <lwip/lwipgz_posix_api.h>
+#include <lwip/dpdk_version.h>
#include <linux/ipv6.h>
#include "lstack_cfg.h"
#include "lstack_log.h"
--
2.33.0

View File

@ -2,7 +2,7 @@
Name: gazelle
Version: 1.0.2
Release: 55
Release: 56
Summary: gazelle is a high performance user-mode stack
License: MulanPSL-2.0
URL: https://gitee.com/openeuler/gazelle
@ -259,6 +259,8 @@ Patch9239: 0239-WRAP-fix-ltran-mode-did-not-bind-kernel-while-open-k.patch
Patch9240: 0240-WRAP-fix-bind-log-error.patch
Patch9241: 0241-virtio-mod-virtio_user_name-when-multi-process-is-on.patch
Patch9242: 0242-fix-redis-coredump-ctrl-c-during-the-pressure-test.patch
Patch9243: 0243-virtio_user-check-netif-status.patch
Patch9244: 0244-virtio-solve-compilation-error-in-2003sp3.patch
%description
%{name} is a high performance user-mode stack.
@ -300,6 +302,10 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b
%config(noreplace) %{conf_path}/ltran.conf
%changelog
* Fri Aug 23 2024 yinbin6 <yinbin8@huawei.com> - 1.0.2-56
- virtio: solve compilation error in 2003sp3
- virtio_user: check netif status
* Fri Aug 16 2024 yinbin6 <yinbin8@huawei.com> - 1.0.2-55
- virtio: mod virtio_user_name when multi process is on
- WRAP: fix bind log error