summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b8d58bd)
raw | patch | inline | side by side (parent: b8d58bd)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 12 Oct 2007 12:32:20 +0000 (14:32 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Fri, 12 Oct 2007 16:42:30 +0000 (18:42 +0200) |
ipvs_strerror() handles a few special cases in libipvs which are not
relevant in this plugin.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
relevant in this plugin.
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 f9acab5cfaa39cb70b9fe568d452b6778c36cdee..9bf2224a816e9b559fef9fb0ef8a70017268b70e 100644 (file)
--- a/src/ipvs.c
+++ b/src/ipvs.c
*/
static int sockfd = -1;
-static void *ipvs_func = NULL;
/*
* libipvs API
*/
-static struct ip_vs_get_services *ipvs_get_services (void);
-static struct ip_vs_get_dests *ipvs_get_dests (struct ip_vs_service_entry *);
-
-static const char *ipvs_strerror (int err)
-{
- char errbuf[1024];
- unsigned int i;
-
- struct {
- void *func;
- int err;
- const char *message;
- } table [] = {
- { 0, EPERM, "Permission denied (you must be root)" },
- { 0, EINVAL, "Module is wrong version" },
- { 0, ENOPROTOOPT, "Protocol not available" },
- { 0, ENOMEM, "Memory allocation problem" },
- { ipvs_get_services, ESRCH, "No such service" },
- { ipvs_get_dests, ESRCH, "No such service" },
- };
-
- for (i = 0; i < sizeof (table) / sizeof (table[0]); i++) {
- if (((NULL == table[i].func) || (table[i].func == ipvs_func))
- && (table[i].err == err))
- return table[i].message;
- }
- return sstrerror (err, errbuf, sizeof (errbuf));
-} /* ipvs_strerror */
-
static struct ip_vs_get_services *ipvs_get_services (void)
{
struct ip_vs_getinfo ipvs_info;
if (0 != getsockopt (sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO,
(void *)&ipvs_info, &len)) {
+ char errbuf[1024];
log_err ("ip_vs_get_services: getsockopt() failed: %s",
- ipvs_strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return NULL;
}
exit (3);
}
- ipvs_func = ipvs_get_services;
-
ret->num_services = ipvs_info.num_services;
if (0 != getsockopt (sockfd, IPPROTO_IP, IP_VS_SO_GET_SERVICES,
(void *)ret, &len)) {
+ char errbuf[1024];
log_err ("ipvs_get_services: getsockopt failed: %s",
- ipvs_strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
free(ret);
return NULL;
exit (3);
}
- ipvs_func = ipvs_get_dests;
-
ret->fwmark = se->fwmark;
ret->protocol = se->protocol;
ret->addr = se->addr;
if (0 != getsockopt (sockfd, IPPROTO_IP, IP_VS_SO_GET_DESTS,
(void *)ret, &len)) {
+ char errbuf[1024];
log_err ("ipvs_get_dests: getsockopt() failed: %s",
- ipvs_strerror (errno));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
free (ret);
return NULL;
}
static int cipvs_init (void)
{
if (-1 == (sockfd = socket (AF_INET, SOCK_RAW, IPPROTO_RAW))) {
- log_err ("cipvs_init: socket() failed: %s", ipvs_strerror (errno));
+ char errbuf[1024];
+ log_err ("cipvs_init: socket() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return -1;
}
return 0;