summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d41d41e)
raw | patch | inline | side by side (parent: d41d41e)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 12 Oct 2007 12:31:29 +0000 (14:31 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Fri, 12 Oct 2007 16:42:30 +0000 (18:42 +0200) |
IP_VS_SO_GET_INFO also provides the number of services which might change after
initializing the plugin. Also, the globale variable ipvs_info could be removed
as ip_vs_get_services() is the only function using these information.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
initializing the plugin. Also, the globale variable ipvs_info could be removed
as ip_vs_get_services() is the only function using these information.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/ipvs.c | patch | blob | history |
diff --git a/src/ipvs.c b/src/ipvs.c
index c670b09da1da52c976a2f440aae1b4ccff61569f..f9acab5cfaa39cb70b9fe568d452b6778c36cdee 100644 (file)
--- a/src/ipvs.c
+++ b/src/ipvs.c
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;
@@ -162,20 +171,10 @@ static struct ip_vs_get_dests *ipvs_get_dests (struct ip_vs_service_entry *se)
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 */