OpenVAS Scanner  21.4.1
Data Structures | Macros | Functions | Variables
pluginlaunch.c File Reference

Manages the launching of plugins within processes. More...

#include "pluginlaunch.h"
#include "../misc/network.h"
#include "../misc/nvt_categories.h"
#include "pluginload.h"
#include "pluginscheduler.h"
#include "plugs_req.h"
#include "processes.h"
#include "sighand.h"
#include "utils.h"
#include <errno.h>
#include <gvm/base/prefs.h>
#include <gvm/util/nvticache.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <unistd.h>

Data Structures

struct  running
 Structure to represent a process in the sense of a running NVT. More...
 

Macros

#define G_LOG_DOMAIN   "sd main"
 GLib log domain. More...
 
#define MAX_PROCESSES   32
 'Hard' limit of the max. number of concurrent plugins per host. More...
 

Functions

static void update_running_processes (kb_t kb)
 
static int common (GSList *list1, GSList *list2)
 
static GSList * required_ports_in_list (const char *oid, GSList *list)
 
static int simult_ports (const char *oid, const char *next_oid)
 
static int next_free_process (kb_t kb, struct scheduler_plugin *upcoming)
 
void pluginlaunch_init (const char *host)
 
void pluginlaunch_disable_parallel_checks (void)
 
void pluginlaunch_enable_parallel_checks (void)
 
void pluginlaunch_stop (void)
 
static int plugin_timeout (nvti_t *nvti)
 
static int get_available_memory ()
 
static int check_memory ()
 
int check_sysload ()
 
int plugin_launch (struct scan_globals *globals, struct scheduler_plugin *plugin, struct in6_addr *ip, GSList *vhosts, kb_t kb, kb_t main_kb, nvti_t *nvti)
 
void pluginlaunch_wait (kb_t kb)
 Waits and 'pushes' processes until num_running_processes is 0. More...
 
static int timeout_running_processes (void)
 Return shortest timeout of the running processes. More...
 
void pluginlaunch_wait_for_free_process (kb_t kb)
 Waits and 'pushes' processes until the number of running processes has changed. More...
 

Variables

int global_min_memory
 
int global_max_sysload
 
static struct running processes [MAX_PROCESSES]
 
static int num_running_processes
 
static int max_running_processes
 
static int old_max_running_processes
 
static GSList * non_simult_ports = NULL
 
const char * hostname = NULL
 

Detailed Description

Manages the launching of plugins within processes.

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "sd main"

GLib log domain.

◆ MAX_PROCESSES

#define MAX_PROCESSES   32

'Hard' limit of the max. number of concurrent plugins per host.

Function Documentation

◆ check_memory()

static int check_memory ( )
static

◆ check_sysload()

int check_sysload ( )

◆ common()

static int common ( GSList *  list1,
GSList *  list2 
)
static

◆ get_available_memory()

static int get_available_memory ( )
static

◆ next_free_process()

static int next_free_process ( kb_t  kb,
struct scheduler_plugin upcoming 
)
static

If another NVT with same port requirements is running, wait.

Returns
-1 if MAX_PROCESSES are running, the index of the first free "slot" in the processes array otherwise.

◆ plugin_launch()

int plugin_launch ( struct scan_globals globals,
struct scheduler_plugin plugin,
struct in6_addr *  ip,
GSList *  vhosts,
kb_t  kb,
kb_t  main_kb,
nvti_t *  nvti 
)
Returns
PID of process that is connected to the plugin as returned by plugin classes pl_launch function (<=0 means there was a problem).

◆ plugin_timeout()

static int plugin_timeout ( nvti_t *  nvti)
static

◆ pluginlaunch_disable_parallel_checks()

void pluginlaunch_disable_parallel_checks ( void  )

◆ pluginlaunch_enable_parallel_checks()

void pluginlaunch_enable_parallel_checks ( void  )

◆ pluginlaunch_init()

void pluginlaunch_init ( const char *  host)

◆ pluginlaunch_stop()

void pluginlaunch_stop ( void  )

◆ pluginlaunch_wait()

void pluginlaunch_wait ( kb_t  kb)

Waits and 'pushes' processes until num_running_processes is 0.

◆ pluginlaunch_wait_for_free_process()

void pluginlaunch_wait_for_free_process ( kb_t  kb)

Waits and 'pushes' processes until the number of running processes has changed.

◆ required_ports_in_list()

static GSList* required_ports_in_list ( const char *  oid,
GSList *  list 
)
static

◆ simult_ports()

static int simult_ports ( const char *  oid,
const char *  next_oid 
)
static

◆ timeout_running_processes()

static int timeout_running_processes ( void  )
static

Return shortest timeout of the running processes.

◆ update_running_processes()

static void update_running_processes ( kb_t  kb)
static

Variable Documentation

◆ global_max_sysload

int global_max_sysload
extern

◆ global_min_memory

int global_min_memory
extern

◆ hostname

const char* hostname = NULL

◆ max_running_processes

int max_running_processes
static

◆ non_simult_ports

GSList* non_simult_ports = NULL
static

◆ num_running_processes

int num_running_processes
static

◆ old_max_running_processes

int old_max_running_processes
static

◆ processes

struct running processes[MAX_PROCESSES]
static