summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4f5787f)
raw | patch | inline | side by side (parent: 4f5787f)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 12 Oct 2007 14:14:25 +0000 (16:14 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Fri, 12 Oct 2007 16:42:30 +0000 (18:42 +0200) |
I took over the required minimum version (1.1.4) as used in ipvsadm 1.24
for Linux kernels >= 2.6.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
for Linux kernels >= 2.6.
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 9bf2224a816e9b559fef9fb0ef8a70017268b70e..4c6305864941e4d9572d72ec59326c8679365d25 100644 (file)
--- a/src/ipvs.c
+++ b/src/ipvs.c
#endif /* HAVE_IP_VS_H */
#define log_err(...) ERROR ("ipvs: " __VA_ARGS__)
+#define log_info(...) INFO ("ipvs: " __VA_ARGS__)
/*
@@ -140,12 +141,39 @@ static struct ip_vs_get_dests *ipvs_get_dests (struct ip_vs_service_entry *se)
static int cipvs_init (void)
{
+ struct ip_vs_getinfo ipvs_info;
+
+ socklen_t len;
+
if (-1 == (sockfd = socket (AF_INET, SOCK_RAW, IPPROTO_RAW))) {
char errbuf[1024];
log_err ("cipvs_init: socket() failed: %s",
sstrerror (errno, errbuf, sizeof (errbuf)));
return -1;
}
+
+ len = sizeof (ipvs_info);
+
+ if (0 != getsockopt (sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO,
+ (void *)&ipvs_info, &len)) {
+ char errbuf[1024];
+ log_err ("cipvs_init: getsockopt() failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ close (sockfd);
+ return -1;
+ }
+
+ /* we need IPVS >= 1.1.4 */
+ if (ipvs_info.version < ((1 << 16) + (1 << 8) + 4)) {
+ log_err ("cipvs_init: IPVS version too old (%d.%d.%d < %d.%d.%d)",
+ NVERSION (ipvs_info.version), 1, 1, 4);
+ close (sockfd);
+ return -1;
+ }
+ else {
+ log_info ("Successfully connected to IPVS %d.%d.%d",
+ NVERSION (ipvs_info.version));
+ }
return 0;
} /* cipvs_init */