Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue: 2247939 Add option VMA_VMAD_ENABLED #907

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Example:
VMA DETAILS: Stats File [VMA_STATS_FILE]
VMA DETAILS: Stats shared memory directory /tmp/ [VMA_STATS_SHMEM_DIR]
VMA DETAILS: VMAD output directory /tmp/vma/ [VMA_VMAD_NOTIFY_DIR]
VMA DETAILS: VMAD support Enabled [VMA_VMAD_ENABLED]
VMA DETAILS: Stats FD Num (max) 100 [VMA_STATS_FD_NUM]
VMA DETAILS: Conf File /etc/libvma.conf [VMA_CONFIG_FILE]
VMA DETAILS: Application ID VMA_DEFAULT_APPLICATION_ID [VMA_APPLICATION_ID]
Expand Down Expand Up @@ -324,6 +325,10 @@ Set the directory path for VMA to write files used by vmad.
Default value is /tmp/vma/
Note: when used vmad must be run with --notify-dir directing the same folder.

VMA_VMAD_ENABLED
When this option is disabled VMA won't communicate with vmad.
Default vale is 1 (Enabled)

VMA_STATS_FD_NUM
Max number of sockets monitored by VMA statistic mechanism.
Value range is 0 to 1024.
Expand Down
6 changes: 6 additions & 0 deletions src/vma/dev/ring_tap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ int ring_tap::prepare_flow_message(vma_msg_flow& data, msg_flow_t flow_action,
{
int rc = 0;

if (unlikely(g_p_agent == NULL))
return 0;

Copy link
Collaborator

@igor-ivanov igor-ivanov Nov 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is needless and incorrect because it conflicts with

	/* create egress rule (redirect traffic from tap device to physical interface) */
	rc = prepare_flow_message(data, VMA_MSG_FLOW_ADD);
	if (rc != 0) {
		ring_logwarn("Add TC rule failed with error=%d", rc);
	}

ring_tap() does not work correctly w/o vma daemon.
So preferable way is to report error once ring_tap() is called. It can be before call or inside constructor.

memset(&data, 0, sizeof(data));
data.hdr.code = VMA_MSG_FLOW;
data.hdr.ver = VMA_AGENT_VER;
Expand Down Expand Up @@ -400,6 +403,9 @@ int ring_tap::prepare_flow_message(vma_msg_flow& data, msg_flow_t flow_action)
{
int rc = 0;

if (unlikely(g_p_agent == NULL))
return 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same as above


memset(&data, 0, sizeof(data));
data.hdr.code = VMA_MSG_FLOW;
data.hdr.ver = VMA_AGENT_VER;
Expand Down
17 changes: 14 additions & 3 deletions src/vma/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ void print_vma_global_settings()
VLOG_STR_PARAM_STRING("Stats File", safe_mce_sys().stats_filename, MCE_DEFAULT_STATS_FILE, SYS_VAR_STATS_FILENAME, safe_mce_sys().stats_filename);
VLOG_STR_PARAM_STRING("Stats shared memory directory", safe_mce_sys().stats_shmem_dirname, MCE_DEFAULT_STATS_SHMEM_DIR, SYS_VAR_STATS_SHMEM_DIRNAME, safe_mce_sys().stats_shmem_dirname);
VLOG_STR_PARAM_STRING("VMAD output directory", safe_mce_sys().vmad_notify_dir, MCE_DEFAULT_VMAD_FOLDER, SYS_VAR_VMAD_DIR, safe_mce_sys().vmad_notify_dir);
VLOG_PARAM_STRING("VMAD support", safe_mce_sys().vmad_enabled, MCE_DEFAULT_VMAD_ENABLED, SYS_VAR_VMAD_ENABLED, safe_mce_sys().vmad_enabled ? "Enabled" : "Disabled");
VLOG_PARAM_NUMBER("Stats FD Num (max)", safe_mce_sys().stats_fd_num_max, MCE_DEFAULT_STATS_FD_NUM, SYS_VAR_STATS_FD_NUM);
VLOG_STR_PARAM_STRING("Conf File", safe_mce_sys().conf_filename, MCE_DEFAULT_CONF_FILE, SYS_VAR_CONF_FILENAME, safe_mce_sys().conf_filename);
VLOG_STR_PARAM_STRING("Application ID", safe_mce_sys().app_id, MCE_DEFAULT_APP_ID, SYS_VAR_APPLICATION_ID, safe_mce_sys().app_id);
Expand Down Expand Up @@ -674,9 +675,19 @@ static void do_global_ctors_helper()
g_is_forked_child = false;

/* Open communication with daemon */
NEW_CTOR(g_p_agent, agent());
vlog_printf(VLOG_DEBUG,"Agent setup state: g_p_agent=%p active=%d\n",
g_p_agent, (g_p_agent ? g_p_agent->state() : -1));
if (safe_mce_sys().vmad_enabled) {
NEW_CTOR(g_p_agent, agent());
vlog_printf(VLOG_DEBUG, "Agent setup state: g_p_agent=%p active=%d\n",
g_p_agent, (g_p_agent ? g_p_agent->state() : -1));
} else {
vlog_printf(VLOG_DEBUG, "Agent is disabled");
if (mce_sys_var::HYPER_MSHV == safe_mce_sys().hypervisor) {
vlog_printf(VLOG_WARNING, "*************************************************************\n");
vlog_printf(VLOG_WARNING, "* VMA agent is disabled on Hyper-V system, but shouldn't be.*\n");
vlog_printf(VLOG_WARNING, "* Consider using VMA_VMAD_ENABLED=1 option. *\n");
vlog_printf(VLOG_WARNING, "*************************************************************\n");
}
}

// Create all global managment objects
NEW_CTOR(g_p_event_handler_manager, event_handler_manager());
Expand Down
14 changes: 9 additions & 5 deletions src/vma/sock/sockinfo_tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ sockinfo_tcp::sockinfo_tcp(int fd):
}

si_tcp_logdbg("TCP PCB FLAGS: 0x%x", m_pcb.flags);
g_p_agent->register_cb((agent_cb_t)&sockinfo_tcp::put_agent_msg, (void *)this);
if (g_p_agent != NULL) {
g_p_agent->register_cb((agent_cb_t)&sockinfo_tcp::put_agent_msg, (void *)this);
}
si_tcp_logfunc("done");
}

Expand Down Expand Up @@ -356,8 +358,9 @@ sockinfo_tcp::~sockinfo_tcp()
si_tcp_logerr("not all buffers were freed. protocol=TCP. m_n_rx_pkt_ready_list_count=%d, m_rx_ready_byte_count=%d, m_rx_pkt_ready_list.size()=%d, m_rx_ring_map.size()=%d, m_rx_reuse_buff.n_buff_num=%d, m_rx_reuse_buff.rx_reuse.size=%d, m_rx_cb_dropped_list.size=%d, m_rx_ctl_packets_list.size=%d, m_rx_peer_packets.size=%d, m_rx_ctl_reuse_list.size=%d",
m_n_rx_pkt_ready_list_count, m_rx_ready_byte_count, (int)m_rx_pkt_ready_list.size() ,(int)m_rx_ring_map.size(), m_rx_reuse_buff.n_buff_num, m_rx_reuse_buff.rx_reuse.size(), m_rx_cb_dropped_list.size(), m_rx_ctl_packets_list.size(), m_rx_peer_packets.size(), m_rx_ctl_reuse_list.size());

g_p_agent->unregister_cb((agent_cb_t)&sockinfo_tcp::put_agent_msg, (void *)this);

if (g_p_agent != NULL) {
g_p_agent->unregister_cb((agent_cb_t)&sockinfo_tcp::put_agent_msg, (void *)this);
}
si_tcp_logdbg("sock closed");
}

Expand Down Expand Up @@ -1159,7 +1162,7 @@ err_t sockinfo_tcp::ip_output_syn_ack(struct pbuf *p, void* v_p_conn, int is_rex
p_si_tcp->m_p_socket_stats->tcp_state = new_state;

/* Update daemon about actual state for offloaded connection */
if (likely(p_si_tcp->m_sock_offload == TCP_SOCK_LWIP)) {
if (g_p_agent != NULL && likely(p_si_tcp->m_sock_offload == TCP_SOCK_LWIP)) {
p_si_tcp->put_agent_msg((void *)p_si_tcp);
}
}
Expand Down Expand Up @@ -4733,7 +4736,8 @@ void tcp_timers_collection::handle_timer_expired(void* user_data)
m_n_location = (m_n_location + 1) % m_n_intervals_size;

/* Processing all messages for the daemon */
g_p_agent->progress();
if (g_p_agent != NULL)
g_p_agent->progress();
}

void tcp_timers_collection::add_new_timer(timer_node_t* node, timer_handler* handler, void* user_data)
Expand Down
5 changes: 5 additions & 0 deletions src/vma/util/sys_vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ void mce_sys_var::get_env_params()
handle_sigintr = MCE_DEFAULT_HANDLE_SIGINTR;
handle_segfault = MCE_DEFAULT_HANDLE_SIGFAULT;
stats_fd_num_max = MCE_DEFAULT_STATS_FD_NUM;
vmad_enabled = MCE_DEFAULT_VMAD_ENABLED;

ring_allocation_logic_tx= MCE_DEFAULT_RING_ALLOCATION_LOGIC_TX;
ring_allocation_logic_rx= MCE_DEFAULT_RING_ALLOCATION_LOGIC_RX;
Expand Down Expand Up @@ -804,6 +805,10 @@ void mce_sys_var::get_env_params()
read_env_variable_with_pid(vmad_notify_dir, sizeof(vmad_notify_dir), env_ptr);
}

if ((env_ptr = getenv(SYS_VAR_VMAD_ENABLED)) != NULL){
vmad_enabled = atoi(env_ptr) ? true : false;
}

if ((env_ptr = getenv(SYS_VAR_LOG_LEVEL)) != NULL)
log_level = log_level::from_str(env_ptr, VLOG_DEFAULT);

Expand Down
5 changes: 4 additions & 1 deletion src/vma/util/sys_vars.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ struct mce_sys_var {
char stats_shmem_dirname[PATH_MAX];
char conf_filename[PATH_MAX];
char vmad_notify_dir[PATH_MAX];
bool vmad_enabled;
bool log_colors;
bool handle_sigintr;
bool handle_segfault;
Expand Down Expand Up @@ -457,6 +458,7 @@ extern mce_sys_var & safe_mce_sys();
#define SYS_VAR_LOG_FILENAME "VMA_LOG_FILE"
#define SYS_VAR_STATS_FILENAME "VMA_STATS_FILE"
#define SYS_VAR_VMAD_DIR "VMA_VMAD_NOTIFY_DIR"
#define SYS_VAR_VMAD_ENABLED "VMA_VMAD_ENABLED"
#define SYS_VAR_STATS_SHMEM_DIRNAME "VMA_STATS_SHMEM_DIR"
#define SYS_VAR_CONF_FILENAME "VMA_CONFIG_FILE"
#define SYS_VAR_LOG_COLORS "VMA_LOG_COLORS"
Expand Down Expand Up @@ -575,7 +577,8 @@ extern mce_sys_var & safe_mce_sys();
#define MCE_DEFAULT_LOG_FILE ("")
#define MCE_DEFAULT_CONF_FILE ("/etc/libvma.conf")
#define MCE_DEFAULT_STATS_FILE ("")
#define MCE_DEFAULT_VMAD_FOLDER (VMA_AGENT_PATH)
#define MCE_DEFAULT_VMAD_FOLDER (VMA_AGENT_PATH)
#define MCE_DEFAULT_VMAD_ENABLED (true)
#define MCE_DEFAULT_STATS_SHMEM_DIR ("/tmp/")
#define MCE_DEFAULT_LOG_DETAILS (0)
#define MCE_DEFAULT_LOG_COLORS (true)
Expand Down