示例#1
0
int ipvs_init(void)
{
	socklen_t len;

	ipvs_func = ipvs_init;

#ifdef LIBIPVS_USE_NL
	try_nl = 1;

	if (ipvs_nl_send_message(NULL, NULL, NULL) == 0) {
		try_nl = 1;
		return ipvs_getinfo();
	}

	try_nl = 0;
#endif

	len = sizeof(ipvs_info);
	if ((sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) == -1)
		return -1;

	if (getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO,
		       (char *)&ipvs_info, &len))
		return -1;

	return 0;
}
示例#2
0
/* ------------------------------------------------------------ */
void ipvsfuncs_initialize(void) {
    int ret;

	ret = ipvs_init();
	if (ret) {
		LOGERROR("%s\n", ipvs_strerror(errno));
		if (ipvsfuncs_modprobe_ipvs() || ipvs_init()) {
			LOGERROR("Can't initialize ipvs [%s]", ipvs_strerror(errno));
			exit(1);
		}
	}
    
	ret = ipvs_getinfo();
	if (ret) {
		LOGINFO("%s", ipvs_strerror(errno));
        exit(1);
	} else {
		LOGINFO("ipvs version: %d", ipvs_version());
	}
}