TSG-10961 在KNI插件中配置TAP网卡的RPS
This commit is contained in:
@@ -22,6 +22,10 @@ bpf_debug_log=0
|
|||||||
# 4: BPF 使用四元组分流
|
# 4: BPF 使用四元组分流
|
||||||
bpf_hash_mode=2
|
bpf_hash_mode=2
|
||||||
|
|
||||||
|
# 配置 tap 网卡的 RPS
|
||||||
|
tap_rps_enable=1
|
||||||
|
tap_rps_mask=0,1fffffff,c0000000,00000000
|
||||||
|
|
||||||
[io_uring]
|
[io_uring]
|
||||||
enable_iouring=1
|
enable_iouring=1
|
||||||
enable_debuglog=0
|
enable_debuglog=0
|
||||||
|
|||||||
@@ -215,6 +215,9 @@ struct security_policy_shunt_tsg_diagnose{
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct kni_handle{
|
struct kni_handle{
|
||||||
|
int tap_rps_enable;
|
||||||
|
char tap_rps_mask[KNI_SYMBOL_MAX];
|
||||||
|
|
||||||
struct io_uring_conf iouring_conf;
|
struct io_uring_conf iouring_conf;
|
||||||
struct kni_marsio_handle *marsio_handle;
|
struct kni_marsio_handle *marsio_handle;
|
||||||
struct bpf_ctx *tap_bpf_ctx;
|
struct bpf_ctx *tap_bpf_ctx;
|
||||||
|
|||||||
@@ -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", "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, "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;
|
int tap_allow_mutilthread = 0;
|
||||||
MESA_load_profile_int_nodef(profile, "tap", "tap_allow_mutilthread", &tap_allow_mutilthread);
|
MESA_load_profile_int_nodef(profile, "tap", "tap_allow_mutilthread", &tap_allow_mutilthread);
|
||||||
if (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
|
//init ssl dynamic bypass htable
|
||||||
ret = ssl_dynamic_bypass_htable_init(profile, local_logger);
|
ret = ssl_dynamic_bypass_htable_init(profile, local_logger);
|
||||||
if(ret < 0){
|
if(ret < 0){
|
||||||
|
|||||||
@@ -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.
|
* 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.
|
* 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)
|
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));
|
KNI_LOG_ERROR(logger, TAP_RSS_LOG_TAG "unable to set persist on %s, aborting: %s", tap_dev, strerror(errno));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
#if (SUPPORT_BPF)
|
#if (SUPPORT_BPF)
|
||||||
if (bpf_prog_fd > 0)
|
if (bpf_prog_fd > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user