From 90444ca35e3037ed43ec695428f0ef6d82f9a320 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 1 Jul 2014 16:14:05 +0200 Subject: [PATCH] lib: unset ZEBRA_IFA_PEER if no dst addr present (BZ#801) On OpenBSD, carp interfaces claim to be PtP interfaces with a 0.0.0.0/0 peer address. We process those in zebra and try to send them to clients, at which point they get encoded as all-0. The client code, however, decodes that to a NULL pointer instead of 0.0.0.0. This later turns into a SEGV when CONNECTED_PREFIX sees that ZEBRA_IFA_PEER is set and tries to access the peer prefix. This is a band-aid fix for stable/0.99.23, a long-term solution needs some conceptual improvements on the entire thing. (The usefulness of a PtP-to-0.0.0.0/0 is a separate question; at this point dropping the peer prefix seems the least intrusive solution.) Reported-by: Laurent Lavaud Signed-off-by: David Lamparter --- lib/zclient.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/zclient.c b/lib/zclient.c index 20188f6abd..3b5477e903 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -805,6 +805,16 @@ zebra_interface_address_read (int type, struct stream *s) ifc->flags = ifc_flags; if (ifc->destination) ifc->destination->prefixlen = ifc->address->prefixlen; + else if (CHECK_FLAG(ifc->flags, ZEBRA_IFA_PEER)) + { + /* carp interfaces on OpenBSD with 0.0.0.0/0 as "peer" */ + char buf[BUFSIZ]; + prefix2str (ifc->address, buf, sizeof(buf)); + zlog_warn("warning: interface %s address %s " + "with peer flag set, but no peer address!", + ifp->name, buf); + UNSET_FLAG(ifc->flags, ZEBRA_IFA_PEER); + } } } else -- 2.39.5