Handle non-existant default interface in VIP definition.
authorVincent Bernat <bernat@luffy.cx>
Tue, 17 Nov 2009 10:18:08 +0000 (10:18 +0000)
committerAlexandre Cassen <acassen@freebox.fr>
Thu, 6 May 2010 12:48:59 +0000 (14:48 +0200)
When the user does not specify an interface for a VIP, a default
interface is used. This default interface is fixed to "eth0" which may
not exist on a system (for example, it may have been renamed). We
display a warning instead of just segfaulting in this case.

keepalived/vrrp/vrrp_ipaddress.c

index 028b818..66ab1e2 100644 (file)
@@ -125,6 +125,13 @@ alloc_ipaddress(list ip_list, vector strvec, interface *ifp)
                new->ifindex = IF_INDEX(ifp);
        } else {
                new->ifp = if_get_by_ifname(DFLT_INT);
+               if (!new->ifp) {
+                       log_message(LOG_INFO, "Default interface " DFLT_INT
+                                   " does not exist and no interface specified. "
+                                   "Skip VRRP address.");
+                       FREE(new);
+                       return;
+               }
                new->ifindex = IF_INDEX(new->ifp);
        }