From 73486c5d0b96b1bce05226b508be40a831f1c5f8 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Thu, 15 Jul 2010 09:58:35 -0700 Subject: [PATCH] fea: Handle funky input from netlink without crashing. We found a situation where we were evidently getting a bad subnet prefix (181) reported by netlink API. This was causing an un-caught exception that crashed FEA. I think I found the right place to catch this exception, but now I cannot reproduce the failure. Leaving in a bit of debug print statements in case this crops up again. Signed-off-by: Ben Greear --- .../control_socket/netlink_socket_utilities.cc | 14 ++++++++++++-- xorp/libxorp/exceptions.cc | 8 ++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/xorp/fea/data_plane/control_socket/netlink_socket_utilities.cc b/xorp/fea/data_plane/control_socket/netlink_socket_utilities.cc index 3371a3649..883d14371 100644 --- a/xorp/fea/data_plane/control_socket/netlink_socket_utilities.cc +++ b/xorp/fea/data_plane/control_socket/netlink_socket_utilities.cc @@ -563,8 +563,18 @@ NlmUtils::nlm_get_to_fte_cfg(const IfTree& iftree, FteX& fte, // // TODO: define default admin distance instead of 0xffff // - fte = FteX(IPvXNet(dst_addr, dst_mask_len), nexthop_addr, - if_name, vif_name, route_metric, 0xffff, xorp_route); + try { + fte = FteX(IPvXNet(dst_addr, dst_mask_len), nexthop_addr, + if_name, vif_name, route_metric, 0xffff, xorp_route); + } + catch (XorpException& xe) { + err_msg += "exception in nlm_get_to_fte_cfg: "; + err_msg += xe.str(); + err_msg += "\n"; + XLOG_ERROR("exception in nlm_get_to_fte_cfg: %s", xe.str().c_str()); + return XORP_ERROR; + } + if (is_deleted) fte.mark_deleted(); diff --git a/xorp/libxorp/exceptions.cc b/xorp/libxorp/exceptions.cc index d8e46a9dc..26173fd1c 100644 --- a/xorp/libxorp/exceptions.cc +++ b/xorp/libxorp/exceptions.cc @@ -134,6 +134,14 @@ InvalidNetmaskLength::InvalidNetmaskLength(const char* file, : XorpException("XorpInvalidNetmaskLength", file, line), _netmask_length (netmask_length) { + // There was a case where fea was crashing due to un-caught exception. + // Somehow, no useful info was being printed other than the exception + // name. So, add some logging here just in case it happens again. + // (On reboot, couldn't cause the problem to happen again, so not sure + // I actually fixed the root cause in fea yet.) + cerr << "Creating InvalidNetmaskLength exception, file: " + << file << ":" << line << " netmask_length: " << netmask_length + << endl; } const string