From 41bb38c03d017da40bb7fc231836165225b09de3 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 17 Nov 2009 10:18:08 +0000 Subject: [PATCH] Handle non-existant default interface in VIP definition. 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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/keepalived/vrrp/vrrp_ipaddress.c b/keepalived/vrrp/vrrp_ipaddress.c index 028b818..66ab1e2 100644 --- a/keepalived/vrrp/vrrp_ipaddress.c +++ b/keepalived/vrrp/vrrp_ipaddress.c @@ -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); } -- 1.7.10.4