Exemplo n.º 1
0
int conn_client_init(void) {
	int errsv = 0;

	if (runc.opt.remote_hostname[0]) {
		if ((runc.fd = panet_client_ipv4(runc.opt.remote_hostname, runc.opt.remote_port, PANET_PROTO_TCP, 5)) == (sock_t) -1) {
			errsv = errno;
			log_crit("conn_client_init(): panet_client_ipv4(): %s\n", strerror(errno));
			errno = errsv;
			return -1;
		}
#ifndef COMPILE_WIN32
	} else if ((runc.fd = panet_client_unix(runc.config.network.sock_name, PANET_PROTO_UNIX_STREAM)) < 0) {
		errsv = errno;
		log_crit("conn_client_init(): panet_client_unix(): %s\n", strerror(errno));
		errno = errsv;
		return -1;
#endif
	}
#ifdef COMPILE_WIN32
	else {
		errno = EINVAL;
		return -1;
	}
#endif

	return 0;
}
Exemplo n.º 2
0
void
core_run(void *arg_admin, void *arg_worker)
{
    pthread_t worker, admin;
    int ret;

    if (!core_init) {
        log_crit("core cannot run because it hasn't been initialized");
        return;
    }

    ret = pthread_create(&worker, NULL, core_worker_evloop, arg_worker);
    if (ret != 0) {
        log_crit("pthread create failed for worker thread: %s", strerror(ret));
        goto error;
    }

    __atomic_store_n(&admin_running, true, __ATOMIC_RELAXED);
    ret = pthread_create(&admin, NULL, core_admin_evloop, arg_admin);
    if (ret != 0) {
        log_crit("pthread create failed for admin thread: %s", strerror(ret));
        goto error;
    }

    core_server_evloop();

error:
    core_teardown();
}
Exemplo n.º 3
0
// Called from CGO code.
int dpdk_init(void)
{
    int i;

    engine_start_notify = (sem_t*)
                    malloc(sizeof(sem_t) * sysconf (_SC_NPROCESSORS_CONF));

    for (i = 0; i < sysconf (_SC_NPROCESSORS_CONF); i++)
        sem_init(&engine_start_notify[i], 0, 0);

    // Call dpdk_main from a thread
    pthread_create(&engine_thread, NULL, dpdk_init_worker, NULL);

    // Wait till all cores are in engine loop
    for (i = 0; i < sysconf (_SC_NPROCESSORS_CONF); i++)
        sem_wait(&engine_start_notify[i]);

    // Initialize the lock for virtio net linked list
    pthread_mutex_init(&ll_virtio_net_lock, NULL);

    // Initialize virtio framework
    if (rte_vhost_driver_callback_register(&virtio_ops) < 0) {
        log_crit( "rte_vhost_driver_callback_register failed\n");
        return -1;
    }

    // Run vhost-user listener
    if (pthread_create(&vhost_thread, NULL, vhost_worker, NULL) < 0) {
        log_crit( "Failed to create cmd thread\n");
        return -1;
    }

    log_info( "VHOST Socket is up and running!\n");
    return 0;
}
Exemplo n.º 4
0
struct mlvpn_reorder_buffer *
mlvpn_reorder_init(struct mlvpn_reorder_buffer *b, unsigned int bufsize,
        unsigned int size)
{
    const unsigned int min_bufsize = sizeof(*b) +
                    (2 * size * sizeof(mlvpn_pkt_t *));
    if (b == NULL) {
        log_crit("reorder", "Invalid reorder buffer parameter: NULL");
        return NULL;
    }
    if (bufsize < min_bufsize) {
        log_crit("reorder", "Invalid reorder buffer memory size: %u, "
            "minimum required: %u", bufsize, min_bufsize);
        return NULL;
    }

    memset(b, 0, bufsize);
    b->memsize = bufsize;
    b->order_buf.size = b->ready_buf.size = size;
    b->order_buf.mask = b->ready_buf.mask = size - 1;
    b->ready_buf.pkts = (void *)&b[1];
    b->order_buf.pkts = (void *)&b[1] + (size * sizeof(b->ready_buf.pkts[0]));

    return b;
}
Exemplo n.º 5
0
struct inode_info *inodetree_insert(struct gfs2_inum di_num)
{
	struct osi_node **newn = &inodetree.osi_node, *parent = NULL;
	struct inode_info *data;

	/* Figure out where to put new node */
	while (*newn) {
		struct inode_info *cur = (struct inode_info *)*newn;

		parent = *newn;
		if (di_num.no_addr < cur->di_num.no_addr)
			newn = &((*newn)->osi_left);
		else if (di_num.no_addr > cur->di_num.no_addr)
			newn = &((*newn)->osi_right);
		else
			return cur;
	}

	data = malloc(sizeof(struct inode_info));
	if (!data) {
		log_crit( _("Unable to allocate inode_info structure\n"));
		return NULL;
	}
	if (!memset(data, 0, sizeof(struct inode_info))) {
		log_crit( _("Error while zeroing inode_info structure\n"));
		return NULL;
	}
	/* Add new node and rebalance tree. */
	data->di_num.no_addr = di_num.no_addr;
	data->di_num.no_formal_ino = di_num.no_formal_ino;
	osi_link_node(&data->node, parent, newn);
	osi_insert_color(&data->node, &inodetree);

	return data;
}
Exemplo n.º 6
0
void
klog_setup(klog_options_st *options, klog_metrics_st *metrics)
{
    size_t nbuf = KLOG_NBUF;
    char *filename = NULL;

    log_info("Set up the %s module", KLOG_MODULE_NAME);

    if (klog_init) {
        log_warn("%s has already been setup, overwrite", KLOG_MODULE_NAME);
        log_destroy(&klogger);
    }

    klog_metrics = metrics;

    if (options != NULL) {
        filename = option_str(&options->klog_file);
        klog_backup = option_str(&options->klog_backup);
        if (klog_backup != NULL) {
            size_t nbyte = strnlen(klog_backup, PATH_MAX + 1);
            if (nbyte > PATH_MAX) {
                log_crit("klog file path too long");
                goto error;
            }
            strncpy(backup_path, klog_backup, PATH_MAX);
            klog_backup = backup_path;
        }
        nbuf = option_uint(&options->klog_nbuf);
        klog_sample = option_uint(&options->klog_sample);
        if (klog_sample == 0) {
            log_crit("klog sample rate cannot be 0 - divide by zero");
            goto error;
        }
        klog_max =  option_uint(&options->klog_max);
    }

    if (filename == NULL) { /* no klog filename provided, do not log */
        klog_enabled = false;
        return;
    }

    klogger = log_create(filename, nbuf);
    if (klogger == NULL) {
        log_crit("Could not create klogger!");
        goto error;
    }

    klog_enabled = true;

    klog_init = true;

    return;

error:
    log_destroy(&klogger);
    exit(EX_CONFIG);
}
Exemplo n.º 7
0
/*
 * Open L2CAP server socket
 */
static bool
server_open_l2cap(server_t *srv)
{
	struct sockaddr_bt	sa;
	int			fd;

	fd = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
	if (fd == -1) {
		log_crit("Could not create L2CAP socket. %s (%d)",
		    strerror(errno), errno);

		return false;
	}

        if (setsockopt(fd, BTPROTO_L2CAP, SO_L2CAP_IMTU,
	    &srv->imtu, sizeof(srv->imtu)) == -1) {
		log_crit("Could not set L2CAP Incoming MTU. %s (%d)",
		    strerror(errno), errno);

		close(fd);
		return false;
        }

	memset(&sa, 0, sizeof(sa));
	sa.bt_len = sizeof(sa);
	sa.bt_family = AF_BLUETOOTH;
	sa.bt_psm = L2CAP_PSM_SDP;
	bdaddr_copy(&sa.bt_bdaddr, BDADDR_ANY);

	if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) == -1) {
		log_crit("Could not bind L2CAP socket. %s (%d)",
		    strerror(errno), errno);

		close(fd);
		return false;
	}

	if (listen(fd, 5) == -1) {
		log_crit("Could not listen on L2CAP socket. %s (%d)",
		    strerror(errno), errno);

		close(fd);
		return false;
	}

	/* Add L2CAP descriptor to index */
	if (fd > srv->fdmax)
		srv->fdmax = fd;

	FD_SET(fd, &srv->fdset);
	srv->fdidx[fd].valid = true;
	srv->fdidx[fd].server = true;
	srv->fdidx[fd].control = false;
	srv->fdidx[fd].priv = false;
	return true;
}
Exemplo n.º 8
0
/**
 * fix_rindex - Add the new entries to the end of the rindex file.
 */
static void fix_rindex(int rindex_fd, lgfs2_rgrps_t rgs, unsigned old_rg_count, unsigned rgcount)
{
	char *buf;
	ssize_t count;
	ssize_t writelen;
	const size_t entrysize = sizeof(struct gfs2_rindex);

	log_info( _("%d new rindex entries.\n"), rgcount);
	buf = rindex_buffer(rgs, rgcount);
	writelen = rgcount * entrysize;

	if (!test) {
		off_t rindex_size = lseek(rindex_fd, 0, SEEK_END);
		if (rindex_size != old_rg_count * entrysize) {
			log_crit(_("Incorrect rindex size. Want %ld (%d resource groups), have %ld\n"),
				 (long)(old_rg_count * entrysize), old_rg_count,
				 (long)rindex_size);
			goto out;
		}
		/* Write the first entry separately to ensure there's enough
		   space in the fs for the rest  */
		count = write(rindex_fd, buf, entrysize);
		if (count != entrysize) {
			log_crit(_("Error writing first new rindex entry; aborted.\n"));
			if (count > 0)
				goto trunc;
			else
				goto out;
		}
		count = write(rindex_fd, (buf + entrysize), (writelen - entrysize));
		if (count != (writelen - entrysize)) {
			log_crit(_("Error writing new rindex entries; aborted.\n"));
			if (count > 0)
				goto trunc;
			else
				goto out;
		}
		if (fallocate(rindex_fd, FALLOC_FL_KEEP_SIZE, (rindex_size + writelen), entrysize) != 0)
			perror("fallocate");
		fsync(rindex_fd);
	}
out:
	free(buf);
	return;
trunc:
	count = (count / sizeof(struct gfs2_rindex)) + old_rg_count;
	log_crit(_("truncating rindex to %ld entries\n"),
		 (long)count * sizeof(struct gfs2_rindex));
	ftruncate(rindex_fd, (off_t)count * sizeof(struct gfs2_rindex));
	free(buf);
}
Exemplo n.º 9
0
/*
 * Initialize server
 */
bool
server_init(server_t *srv, char const *control, char const *sgroup)
{

	assert(srv != NULL);
	assert(control != NULL);

	memset(srv, 0, sizeof(*srv));
	FD_ZERO(&srv->fdset);
	srv->sgroup = sgroup;

	srv->fdmax = -1;
	srv->fdidx = calloc(FD_SETSIZE, sizeof(fd_idx_t));
	if (srv->fdidx == NULL) {
		log_crit("Failed to allocate fd index");
		goto fail;
	}

	srv->ctllen = CMSG_SPACE(SOCKCREDSIZE(MAX_GROUPS));
	srv->ctlbuf = malloc(srv->ctllen);
	if (srv->ctlbuf == NULL) {
		log_crit("Malloc cmsg buffer (len=%zu) failed.", srv->ctllen);
		goto fail;
	}

	srv->imtu = SDP_LOCAL_MTU - sizeof(sdp_pdu_t);
	srv->ibuf = malloc(srv->imtu);
	if (srv->ibuf == NULL) {
		log_crit("Malloc input buffer (imtu=%d) failed.", srv->imtu);
		goto fail;
	}

	srv->omtu = L2CAP_MTU_DEFAULT - sizeof(sdp_pdu_t);
	srv->obuf = malloc(srv->omtu);
	if (srv->obuf == NULL) {
		log_crit("Malloc output buffer (omtu=%d) failed.", srv->omtu);
		goto fail;
	}

	if (db_init(srv)
	    && server_open_control(srv, control)
	    && server_open_l2cap(srv))
		return true;

fail:
	server_shutdown(srv);
	return false;
}
Exemplo n.º 10
0
static void
update_shared_memory(char *last_wal_standby_applied)
{
	PGresult   *res;
	char		sqlquery[QUERY_STR_LEN];

	sprintf(sqlquery, "SELECT %s.repmgr_update_standby_location('%s')",
			repmgr_schema, last_wal_standby_applied);

	/* If an error happens, just inform about that and continue */
	res = PQexec(my_local_conn, sqlquery);
	if (PQresultStatus(res) != PGRES_TUPLES_OK)
	{
		log_warning(_("Cannot update this standby's shared memory: %s\n"),
					PQerrorMessage(my_local_conn));
		/* XXX is this enough reason to terminate this repmgrd? */
	}
	else if (strcmp(PQgetvalue(res, 0, 0), "f") == 0)
	{
		/* this surely is more than enough reason to exit */
		log_crit(_("Cannot update this standby's shared memory, maybe shared_preload_libraries=repmgr_funcs is not set?\n"));
		exit(ERR_BAD_CONFIG);
	}

	PQclear(res);
}
Exemplo n.º 11
0
int alloc_tun(const char *tun_up_cmd) {
    const char *dev = "tun%d";
    struct ifreq ifr;
    int fd, err;
    char buff[100];

    if((fd = open("/dev/net/tun", O_RDWR)) < 0)
        fatal("tun", "ioctl call for tun device failed");

    memset(&ifr, 0, sizeof(ifr));

    ifr.ifr_flags = IFF_TUN; 
    if(*dev)
        strncpy(ifr.ifr_name, dev, IFNAMSIZ);

    if((err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0){
        fatal("tun", "ioctl TUNSETIFF call for tun device failed");
        close(fd);
        return err;
    }
    log_info("tun", "Opened device %s [fd: %d], will run the command [%s] now", ifr.ifr_name, fd, tun_up_cmd);
    int env_var_len = snprintf(buff, sizeof(buff), "TUN_IFACE=%s", ifr.ifr_name);
    assert(env_var_len > 0 && (unsigned) env_var_len < sizeof(buff));
    assert(putenv(buff) == 0);
    int ret = system(tun_up_cmd);
    if (ret != 0) {
        log_crit("tun", "TUN-UP command '%s' failed, return code was %d", tun_up_cmd, ret);
        return -1;
    }
    return fd;
}
Exemplo n.º 12
0
static void _init(int argc, char **argv) {
	if (runtime_client_init(argc, argv) < 0) {
		log_crit("_init(): runtime_client_init(): %s\n", strerror(errno));
		print_client_result_error();
		exit(EXIT_FAILURE);
	}
}
Exemplo n.º 13
0
/*
 * Accept new client connection and register it with index
 */
static void
server_accept_client(server_t *srv, int fd)
{
	struct sockaddr_bt	sa;
	socklen_t		len;
	int			cfd;
	uint16_t		omtu;

	do {
		cfd = accept(fd, NULL, NULL);
	} while (cfd == -1 && errno == EINTR);

	if (cfd == -1) {
		log_err("Could not accept connection on %s socket. %s (%d)",
		    srv->fdidx[fd].control ? "control" : "L2CAP",
		    strerror(errno), errno);

		return;
	}

	if (cfd >= FD_SETSIZE) {
		log_crit("File descriptor too large");
		close(cfd);
		return;
	}

	assert(!FD_ISSET(cfd, &srv->fdset));
	assert(!srv->fdidx[cfd].valid);

	memset(&sa, 0, sizeof(sa));
	omtu = srv->omtu;

	if (!srv->fdidx[fd].control) {
		len = sizeof(sa);
		if (getsockname(cfd, (struct sockaddr *)&sa, &len) == -1)
			log_warning("getsockname failed, using BDADDR_ANY");

		len = sizeof(omtu);
	        if (getsockopt(cfd, BTPROTO_L2CAP, SO_L2CAP_OMTU, &omtu, &len) == -1)
			log_warning("Could not get L2CAP OMTU, using %d", omtu);
		else
			omtu -= sizeof(sdp_pdu_t);
	}

	/* Add client descriptor to the index */
	if (cfd > srv->fdmax)
		srv->fdmax = cfd;

	FD_SET(cfd, &srv->fdset);
	srv->fdidx[cfd].valid = true;
	srv->fdidx[cfd].server = false;
	srv->fdidx[cfd].control = srv->fdidx[fd].control;
	srv->fdidx[cfd].priv = false;
	srv->fdidx[cfd].omtu = (omtu > srv->omtu) ? srv->omtu : omtu;
	srv->fdidx[cfd].offset = 0;
	bdaddr_copy(&srv->fdidx[cfd].bdaddr, &sa.bt_bdaddr);

	log_debug("new %s client on fd#%d",
	    srv->fdidx[cfd].control ? "control" : "L2CAP", cfd);
}
Exemplo n.º 14
0
// Called when user wants to update the fds list for a engine loop.
// This happens when a virtio/vm is created/destroyed.
static void engine_cmd_callback(uint16_t lcore_id, void* data)
{
    struct cmd_event_info* info = (struct cmd_event_info*)data;
    struct engine_cmd_msg* msg;

    eventfd_read(lcore_cmd_event_fd[lcore_id], (eventfd_t*) &msg);

    if (msg->cmd == ENGINE_CMD_FD_ADD) {
        memset(&info->fds[msg->slot], 0, sizeof(struct pollfd));
        info->event_handlers[msg->slot].data = msg->handler.data;
        info->event_handlers[msg->slot].fn = msg->handler.fn;
        info->fds[msg->slot].events = POLLIN|POLLERR;
        info->fds[msg->slot].fd = msg->fd;
        (*info->nb_fd)++;
        free(msg);
    }
    else if (msg->cmd == ENGINE_CMD_FD_DEL) {
        void* arg = info->event_handlers[msg->slot].data;
        memset(&info->fds[msg->slot], 0, sizeof(struct pollfd));
        (*info->nb_fd)--;
        free(arg);
        free(msg);
    }
    else {
        log_crit("Unrecongnized command received\n");
        free(msg);
    }
}
Exemplo n.º 15
0
static void _do(void) {
	/* Transmit entries */
	if (conn_client_process() < 0) {
		log_crit("_do: conn_client_process(): %s\n", strerror(errno));
		print_client_result_error();
		exit(EXIT_FAILURE);
	}
}
Exemplo n.º 16
0
////////////////////////////////////////
// p_device: ignored
// p_parity
//   false: N81 (none, 8 data, 1 stop)
//   true:  E71 (even, 7 data, 1 stop)
bool sp_init(const char* p_device, const uint16_t p_baud, const bool p_parity)
{
    sp_close();
    log_notice("opening %s at %d baud, %s\n", p_device, p_baud, (p_parity ? "E71" : "N81"));

    const speed_t baudrate = sp_parse_baudrate(p_baud);
    if(0 == baudrate)
    {
        log_crit("baudrate not supported");
        return(false);
    }

    // open serial device for reading and writing and not as controlling tty so we don't get killed by CTRL-C
    s_fd = open(p_device, O_RDWR | O_NOCTTY | O_NDELAY);
    if(s_fd < 0)
    {
        log_crit("failed to open device: %s", p_device);
        return(false);
    }

    struct termios tio = { 0 };
    cfsetspeed(&tio, baudrate);
    if(p_parity)
    {
        tio.c_cflag |= (CS7 | PARENB | CLOCAL | CREAD);
    }
    else
    {
        tio.c_cflag |= (CS8 | CLOCAL | CREAD);
    }

    // ignore bytes with parity errors
    tio.c_iflag = IGNPAR;

    // raw output
    tio.c_oflag = 0;

    // local modes
    tio.c_lflag = 0;

    // clean the modem line and activate the settings for the port
    tcflush(s_fd, TCIOFLUSH);
    tcsetattr(s_fd, TCSANOW, &tio);

    return(true);
}
Exemplo n.º 17
0
static void _failure(const char *caller) {
	fprintf(stderr, "[%s] %s() error: %s\n", CONFIG_USCHED_MONITOR_PROC_NAME, caller, strerror(errno));
	log_crit("_failure(): %s(): %s\n", caller, strerror(errno));

	_config_destroy();

	exit(EXIT_FAILURE);
}
Exemplo n.º 18
0
void sig_term(int sig)
{
    if (sig == SIGTERM) {
        log_crit("Terminating ... ");
        unlink(pidFile.c_str());
        exit(0);
    }
}
Exemplo n.º 19
0
int exec_admin_delta_noexec_change(const char *delta_noexec) {
	int errsv = 0;

	if (admin_property_change(CONFIG_USCHED_DIR_EXEC, CONFIG_USCHED_FILE_EXEC_DELTA_NOEXEC, delta_noexec) < 0) {
		errsv = errno;
		log_crit("exec_admin_delta_noexec_change(): admin_property_change(): %s\n", strerror(errno));
		errno = errsv;
		return -1;
	}

	if (exec_admin_delta_noexec_show() < 0) {
		errsv = errno;
		log_crit("exec_admin_delta_noexec_change(): exec_admin_delta_noexec_show(): %s\n", strerror(errno));
		errno = errsv;
		return -1;
	}

	return 0;
}
Exemplo n.º 20
0
/* Bottom half support */
static int schedule_work(void* (*workfn)(void* data), void *arg)
{
    pthread_t th;
    if (pthread_create(&th, NULL, workfn, arg) < 0) {
        log_crit("Failed to create work function thread\n");
        return -1;
    }

    return 0;
}
Exemplo n.º 21
0
void
core_server_evloop(void)
{
    for(;;) {
        if (_server_evwait() != CC_OK) {
            log_crit("server core event loop exited due to failure");
            break;
        }
    }
}
Exemplo n.º 22
0
int main(int argc, char *argv[])
{
    char *envp = NULL;

    set_oom_adj(-1000);
    if (initService(argc, argv) != 0)
        return -1;

    envp = ::getenv("SCI_DISABLE_IPV6");
    if (envp && (::strcasecmp(envp, "yes") == 0)) {
        Socket::setDisableIPv6(1);
    }

    ExtListener *listener = new ExtListener();
    listener->start();

    launcherList.clear();
    while (1) {
        Locker::getLocker()->freeze();

        log_debug("Delete unused launcher");
        Locker::getLocker()->lock();
        vector<ExtLauncher *>::iterator lc;
        for (lc = launcherList.begin(); lc != launcherList.end(); lc++) {
            while (!(*lc)->isLaunched()) {
                // before join, this thread should have been launched
                SysUtil::sleep(WAIT_INTERVAL);
            }
            (*lc)->join();
            delete (*lc);
        }
        launcherList.clear();
        Locker::getLocker()->unlock();

        log_info("Begin to cleanup the jobInfo");
        Locker::getLocker()->lock();
        JOB_INFO::iterator it;
        for (it = jobInfo.begin(); it != jobInfo.end(); ) {
            if ((SysUtil::microseconds() - it->second.timestamp) > FIVE_MINUTES) {
                log_crit("Erase jobInfo item %d", it->first);
                jobInfo.erase(it++);
            } else {
                ++it;
            }
        }
        log_info("Finish cleanup the jobInfo");
        Locker::getLocker()->unlock();
    }

    listener->join();
    delete listener;
    delete Log::getInstance();

    return 0;
}
Exemplo n.º 23
0
static int _bexec(
		const char *file,
		char *const *args)
{
	int status = 0;
	pid_t ret = 0;

	if ((config.cpid = fork()) > 0) {
		if ((config.flags & CONFIG_FL_PIDF_CREATE) && (_file_pid_write(config.cpid) < 0)) {
			log_crit("_bexec(): _file_pid_write(): %s\n", strerror(errno));
			return -1;
		}

		/* SA_RESTART set */
		do {
			if ((ret = waitpid(config.cpid, &status, 0)) != (pid_t) -1)
				break;

			log_crit("_bexec(): waitpid(%u, &status, 0): %s\n", config.cpid, strerror(errno));
		} while (errno == EINTR); /* Restart the syscall if it was interrupted by a signal */

		/* Check if we've an error condition from waitpid() */
		if (ret == (pid_t) -1)
			return -1;

		/* Success? */
		if (WEXITSTATUS(status) != EXIT_SUCCESS)
			log_crit("_bexec(): Execution of '%s' terminated with error status code %d.\n", file, WEXITSTATUS(status));
	} else if (!config.cpid) {
		_config_destroy();

		if (setsid() == (pid_t) -1)
			_failure("setsid");

		if (execve(file, args, environ) < 0)
			_failure("execve");

		return -1;
	}

	return status;
}
Exemplo n.º 24
0
static int get_session_table(l4_protocol l4_proto, struct session_table **result)
{
	switch (l4_proto) {
	case L4PROTO_UDP:
		*result = &session_table_udp;
		return 0;
	case L4PROTO_TCP:
		*result = &session_table_tcp;
		return 0;
	case L4PROTO_ICMP:
		*result = &session_table_icmp;
		return 0;
	case L4PROTO_NONE:
		log_crit(ERR_L4PROTO, "There is no session table for the 'NONE' protocol.");
		return -EINVAL;
	}

	log_crit(ERR_L4PROTO, "Unsupported transport protocol: %u.", l4_proto);
	return -EINVAL;
}
Exemplo n.º 25
0
int thread_daemon_components_init(void) {
	int errsv = 0;

	if ((errno = pthread_mutex_init(&rund.mutex_interrupt, NULL))) {
		errsv = errno;
		log_crit("thread_daemon_components_init(): pthread_mutex_init(): %s\n", strerror(errno));
		errno = errsv;
		return -1;
	}

	if ((errno = pthread_mutex_init(&rund.mutex_rpool, NULL))) {
		errsv = errno;
		log_crit("thread_daemon_components_init(): pthread_mutex_init(): %s\n", strerror(errno));
		errno = errsv;
		return -1;
	}

	if ((errno = pthread_mutex_init(&rund.mutex_apool, NULL))) {
		errsv = errno;
		log_crit("thread_daemon_components_init(): pthread_mutex_init(): %s\n", strerror(errno));
		errno = errsv;
		return -1;
	}

#if CONFIG_USCHED_SERIALIZE_ON_REQ == 1
	if ((errno = pthread_mutex_init(&rund.mutex_marshal, NULL))) {
		errsv = errno;
		log_crit("thread_daemon_components_init(): pthread_mutex_init(): %s\n", strerror(errno));
		errno = errsv;
		return -1;
	}

	if ((errno = pthread_cond_init(&rund.cond_marshal, NULL))) {
		errsv = errno;
		log_crit("thread_daemon_components_init(): pthread_cond_init(): %s\n", strerror(errno));
		errno = errsv;
		return -1;
	}
#endif
	return 0;
}
Exemplo n.º 26
0
int schedule_daemon_init(void) {
	int errsv = 0;

	if (!(rund.psched = psched_thread_init())) {
		errsv = errno;
		log_crit("schedule_daemon_init(): psched_thread_init(): %s\n", strerror(errno));
		errno = errsv;
		return -1;
	}

	return 0;
}
Exemplo n.º 27
0
static void _file_pid_create(const char *file) {
	config.fd_pidf = open(file, O_RDONLY);

	if ((config.fd_pidf >= 0) && (config.flags & CONFIG_FL_PIDF_FORCE)) {
		if (unlink(file) < 0)
			_failure("unlink");
	} else if (config.fd_pidf >= 0) {
		log_crit("_file_pid_create(): PID file %s already exists\n", file);
		fprintf(stderr, "PID file %s already exists.\n", file);
		_config_destroy();
		exit(EXIT_FAILURE);
	}

	_close_safe(config.fd_pidf);

	if ((config.fd_pidf = open(file, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0) {
		log_crit("_file_pid_create(): open(): Cannot create PID file %s: %s.\n", file, strerror(errno));
		fprintf(stderr, "Cannot create PID file %s.\n", file);
		_failure("open");
	}
}
Exemplo n.º 28
0
int exec_admin_show(void) {
	int errsv = 0;

	if (exec_admin_delta_noexec_show() < 0) {
		errsv = errno;
		log_crit("exec_admin_show(): exec_admin_delta_noexec_show(): %s\n", strerror(errno));
		errno = errsv;
		return -1;
	}

	return 0;
}
Exemplo n.º 29
0
/* rte_vhost_driver_session_start is a blocking call, thus we create another
 * thread and call it from there */
static void* vhost_worker(CC_UNUSED void* arg)
{
    pthread_detach(pthread_self());

    log_info("vhost_worker started\n");

    if (rte_vhost_driver_session_start() < 0) {
        log_crit( "rte_vhost_driver_register failed to start\n");
    }

    return NULL;
}
Exemplo n.º 30
0
int exec_admin_delta_noexec_show(void) {
	int errsv = 0;

	if (admin_property_show(CONFIG_USCHED_DIR_EXEC, USCHED_CATEGORY_EXEC_STR, CONFIG_USCHED_FILE_EXEC_DELTA_NOEXEC) < 0) {
		errsv = errno;
		log_crit("exec_admin_delta_noexec_show(): admin_property_show(): %s\n", strerror(errno));
		errno = errsv;
		return -1;
	}

	/* All good */
	return 0;
}