summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf/kni/kni.conf4
-rw-r--r--entry/include/kni_entry.h3
-rw-r--r--entry/src/kni_entry.cpp23
-rw-r--r--entry/src/kni_tap_rss.cpp3
4 files changed, 32 insertions, 1 deletions
diff --git a/conf/kni/kni.conf b/conf/kni/kni.conf
index 78b926f..bc5a6af 100644
--- a/conf/kni/kni.conf
+++ b/conf/kni/kni.conf
@@ -22,6 +22,10 @@ bpf_debug_log=0
# 4: BPF 使用四元组分流
bpf_hash_mode=2
+# 配置 tap 网卡的 RPS
+tap_rps_enable=1
+tap_rps_mask=0,1fffffff,c0000000,00000000
+
[io_uring]
enable_iouring=1
enable_debuglog=0
diff --git a/entry/include/kni_entry.h b/entry/include/kni_entry.h
index 11be0c6..fb93919 100644
--- a/entry/include/kni_entry.h
+++ b/entry/include/kni_entry.h
@@ -215,6 +215,9 @@ struct security_policy_shunt_tsg_diagnose{
};
struct kni_handle{
+ int tap_rps_enable;
+ char tap_rps_mask[KNI_SYMBOL_MAX];
+
struct io_uring_conf iouring_conf;
struct kni_marsio_handle *marsio_handle;
struct bpf_ctx *tap_bpf_ctx;
diff --git a/entry/src/kni_entry.cpp b/entry/src/kni_entry.cpp
index db81b59..8e44711 100644
--- a/entry/src/kni_entry.cpp
+++ b/entry/src/kni_entry.cpp
@@ -2702,6 +2702,16 @@ extern "C" int kni_init(){
MESA_load_profile_int_nodef(profile, "io_uring", "flags", (int *)&g_kni_handle->iouring_conf.flags);
MESA_load_profile_int_nodef(profile, "io_uring", "sq_thread_idle", (int *)&g_kni_handle->iouring_conf.sq_thread_idle);
+ MESA_load_profile_int_nodef(profile, "tap", "tap_rps_enable", &g_kni_handle->tap_rps_enable);
+ if (g_kni_handle->tap_rps_enable)
+ {
+ if (MESA_load_profile_string_nodef(profile, "tap", "tap_rps_mask", g_kni_handle->tap_rps_mask, sizeof(g_kni_handle->tap_rps_mask)) < 0)
+ {
+ KNI_LOG_ERROR(local_logger, TAP_RSS_LOG_TAG "under tap mode, when enable tap_rps_enable, tap_rps_mask is required.");
+ goto error_out;
+ }
+ }
+
int tap_allow_mutilthread = 0;
MESA_load_profile_int_nodef(profile, "tap", "tap_allow_mutilthread", &tap_allow_mutilthread);
if (tap_allow_mutilthread)
@@ -2799,6 +2809,19 @@ extern "C" int kni_init(){
}
}
}
+
+ if (g_kni_handle->tap_rps_enable)
+ {
+ char rps_cmd[2048];
+ for (int i = 0; i < g_kni_handle->thread_count; i++)
+ {
+ memset(rps_cmd, 0, sizeof(rps_cmd));
+ snprintf(rps_cmd, sizeof(rps_cmd), "echo %s > /sys/class/net/%s/queues/rx-%d/rps_cpus", g_kni_handle->tap_rps_mask, tap_name, i);
+ system(rps_cmd);
+ KNI_LOG_DEBUG(local_logger, TAP_RSS_LOG_TAG "'%s'", rps_cmd);
+ }
+ }
+
//init ssl dynamic bypass htable
ret = ssl_dynamic_bypass_htable_init(profile, local_logger);
if(ret < 0){
diff --git a/entry/src/kni_tap_rss.cpp b/entry/src/kni_tap_rss.cpp
index 3fa0c0c..180164d 100644
--- a/entry/src/kni_tap_rss.cpp
+++ b/entry/src/kni_tap_rss.cpp
@@ -146,12 +146,13 @@ int kni_tap_open_per_thread(const char *tap_dev, int tap_flags, int bpf_prog_fd,
* The TUNSETPERSIST ioctl can be used to make the TUN/TAP interface persistent.
* In this mode, the interface won't be destroyed when the last process closes the associated /dev/net/tun file descriptor.
*/
+ /*
if (ioctl(tap_fd, TUNSETPERSIST, 1) == -1)
{
KNI_LOG_ERROR(logger, TAP_RSS_LOG_TAG "unable to set persist on %s, aborting: %s", tap_dev, strerror(errno));
goto error;
}
-
+ */
#if (SUPPORT_BPF)
if (bpf_prog_fd > 0)
{