diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2017-06-20 23:56:50 +0000 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2017-06-21 15:22:21 +0000 |
| commit | 56b40679304df9c4bfcfd5764af24f1d35b86142 (patch) | |
| tree | 755de54cbc890545f73efe5f1f4d1843506d1860 /zebra/rt_socket.c | |
| parent | d368cd48b94cb9a22b9733200d8cfd94c71338ce (diff) | |
*: simplify log message lookup
log.c provides functionality for associating a constant (typically a
protocol constant) with a string and finding the string given the
constant. However this is highly delicate code that is extremely prone
to stack overflows and off-by-one's due to requiring the developer to
always remember to update the array size constant and to do so correctly
which, as shown by example, is never a good idea.b
The original goal of this code was to try to implement lookups in O(1)
time without a linear search through the message array. Since this code
is used 99% of the time for debugs, it's worth the 5-6 additional cmp's
worst case if it means we avoid explitable bugs due to oversights...
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'zebra/rt_socket.c')
| -rw-r--r-- | zebra/rt_socket.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c index ee706a1e8c..9859a31627 100644 --- a/zebra/rt_socket.c +++ b/zebra/rt_socket.c @@ -218,14 +218,14 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct route_entry *re) default: zlog_err ("%s: %s: rtm_write() unexpectedly returned %d for command %s", __func__, prefix2str(p, prefix_buf, sizeof(prefix_buf)), - error, lookup (rtm_type_str, cmd)); + error, lookup_msg(rtm_type_str, cmd, NULL)); break; } } /* if (cmd and flags make sense) */ else if (IS_ZEBRA_DEBUG_RIB) zlog_debug ("%s: odd command %s for flags %d", - __func__, lookup (rtm_type_str, cmd), nexthop->flags); + __func__, lookup_msg(rtm_type_str, cmd, NULL), nexthop->flags); } /* for (ALL_NEXTHOPS_RO(...))*/ /* If there was no useful nexthop, then complain. */ |
