static int sockfd = -1;
static void *ipvs_func = NULL;
-static struct ip_vs_getinfo ipvs_info;
-
/*
* libipvs API
static struct ip_vs_get_services *ipvs_get_services (void)
{
+ struct ip_vs_getinfo ipvs_info;
struct ip_vs_get_services *ret;
+
socklen_t len;
+ len = sizeof (ipvs_info);
+
+ if (0 != getsockopt (sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO,
+ (void *)&ipvs_info, &len)) {
+ log_err ("ip_vs_get_services: getsockopt() failed: %s",
+ ipvs_strerror (errno));
+ return NULL;
+ }
+
len = sizeof (*ret) +
sizeof (struct ip_vs_service_entry) * ipvs_info.num_services;
static int cipvs_init (void)
{
- socklen_t len;
-
- len = sizeof (ipvs_info);
-
if (-1 == (sockfd = socket (AF_INET, SOCK_RAW, IPPROTO_RAW))) {
log_err ("cipvs_init: socket() failed: %s", ipvs_strerror (errno));
return -1;
}
-
- if (0 != getsockopt (sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO,
- (void *)&ipvs_info, &len)) {
- log_err ("cipvs_init: getsockopt() failed: %s", ipvs_strerror (errno));
- return -1;
- }
return 0;
} /* cipvs_init */