]> git.puffer.fish Git - mirror/frr.git/commitdiff
babeld: BABEL_[ERR|WARN] -> EC_BABEL
authorQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 13 Sep 2018 19:01:19 +0000 (19:01 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 13 Sep 2018 19:01:19 +0000 (19:01 +0000)
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
babeld/babel_errors.c
babeld/babel_errors.h
babeld/babel_interface.c
babeld/babel_main.c
babeld/babeld.c
babeld/message.c
babeld/neighbour.c
babeld/route.c
babeld/source.c

index e03cace37926f034aac504586c7ac79310ef13f7..b22b1d5cbfc783e797e2affdd75e7d6fccecf822 100644 (file)
 /* clang-format off */
 static struct log_ref ferr_babel_err[] = {
        {
-               .code = BABEL_ERR_MEMORY,
+               .code = EC_BABEL_MEMORY,
                .title = "BABEL Memory Errors",
                .description = "Babel has failed to allocate memory, the system is about to run out of memory",
                .suggestion = "Find the process that is causing memory shortages, remediate that process and restart FRR"
        },
        {
-               .code = BABEL_ERR_PACKET,
+               .code = EC_BABEL_PACKET,
                .title = "BABEL Packet Error",
                .description = "Babel has detected a packet encode/decode problem",
                .suggestion = "Collect relevant log files and file an Issue"
        },
        {
-               .code = BABEL_ERR_CONFIG,
+               .code = EC_BABEL_CONFIG,
                .title = "BABEL Configuration Error",
                .description = "Babel has detected a configuration error of some sort",
                .suggestion = "Ensure that the configuration is correct"
        },
        {
-               .code = BABEL_ERR_ROUTE,
+               .code = EC_BABEL_ROUTE,
                .title = "BABEL Route Error",
                .description = "Babel has detected a routing error and has an inconsistent state",
                .suggestion = "Gather data for filing an Issue and then restart FRR"
index 19adc63f049717054d38c46f0243ff62b5b4afed..629b6604be23fec5349130f11f9f91be1e051862 100644 (file)
 #include "lib/ferr.h"
 
 enum babel_log_refs {
-       BABEL_ERR_MEMORY = BABEL_FERR_START,
-       BABEL_ERR_PACKET,
-       BABEL_ERR_CONFIG,
-       BABEL_ERR_ROUTE,
+       EC_BABEL_MEMORY = BABEL_FERR_START,
+       EC_BABEL_PACKET,
+       EC_BABEL_CONFIG,
+       EC_BABEL_ROUTE,
 };
 
 extern void babel_error_init(void);
index b7c01e73dc9412520257bf9b232943f798e63b2b..22bdf1fe1e5d242aee6bc6f36ec961f88249558f 100644 (file)
@@ -169,7 +169,7 @@ babel_interface_address_add (int cmd, struct zclient *client,
         if (babel_ifp->ipv4 == NULL) {
             babel_ifp->ipv4 = malloc(4);
             if (babel_ifp->ipv4 == NULL) {
-                flog_err(BABEL_ERR_MEMORY, "not enough memory");
+                flog_err(EC_BABEL_MEMORY, "not enough memory");
             } else {
                 memcpy(babel_ifp->ipv4, &prefix->u.prefix4, 4);
             }
@@ -709,7 +709,7 @@ interface_recalculate(struct interface *ifp)
     tmp = babel_ifp->sendbuf;
     babel_ifp->sendbuf = realloc(babel_ifp->sendbuf, babel_ifp->bufsize);
     if(babel_ifp->sendbuf == NULL) {
-        flog_err(BABEL_ERR_MEMORY, "Couldn't reallocate sendbuf.");
+        flog_err(EC_BABEL_MEMORY, "Couldn't reallocate sendbuf.");
         free(tmp);
         babel_ifp->bufsize = 0;
         return -1;
@@ -1060,7 +1060,7 @@ DEFUN (show_babel_route,
         }
         route_stream_done(routes);
     } else {
-        flog_err(BABEL_ERR_MEMORY, "Couldn't allocate route stream.");
+        flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
     }
     xroutes = xroute_stream();
     if(xroutes) {
@@ -1072,7 +1072,7 @@ DEFUN (show_babel_route,
         }
         xroute_stream_done(xroutes);
     } else {
-        flog_err(BABEL_ERR_MEMORY, "Couldn't allocate route stream.");
+        flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
     }
     return CMD_SUCCESS;
 }
@@ -1107,7 +1107,7 @@ DEFUN (show_babel_route_prefix,
         }
         route_stream_done(routes);
     } else {
-        flog_err(BABEL_ERR_MEMORY, "Couldn't allocate route stream.");
+        flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
     }
     xroutes = xroute_stream();
     if(xroutes) {
@@ -1119,7 +1119,7 @@ DEFUN (show_babel_route_prefix,
         }
         xroute_stream_done(xroutes);
     } else {
-        flog_err(BABEL_ERR_MEMORY, "Couldn't allocate route stream.");
+        flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
     }
     return CMD_SUCCESS;
 }
@@ -1165,7 +1165,7 @@ DEFUN (show_babel_route_addr,
         }
         route_stream_done(routes);
     } else {
-        flog_err(BABEL_ERR_MEMORY, "Couldn't allocate route stream.");
+        flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
     }
     xroutes = xroute_stream();
     if(xroutes) {
@@ -1177,7 +1177,7 @@ DEFUN (show_babel_route_addr,
         }
         xroute_stream_done(xroutes);
     } else {
-        flog_err(BABEL_ERR_MEMORY, "Couldn't allocate route stream.");
+        flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
     }
     return CMD_SUCCESS;
 }
@@ -1224,7 +1224,7 @@ DEFUN (show_babel_route_addr6,
         }
         route_stream_done(routes);
     } else {
-        flog_err(BABEL_ERR_MEMORY, "Couldn't allocate route stream.");
+        flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
     }
     xroutes = xroute_stream();
     if(xroutes) {
@@ -1236,7 +1236,7 @@ DEFUN (show_babel_route_addr6,
         }
         xroute_stream_done(xroutes);
     } else {
-        flog_err(BABEL_ERR_MEMORY, "Couldn't allocate route stream.");
+        flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
     }
     return CMD_SUCCESS;
 }
index 31a3fb5b4db04aa0078b374f6693c8e8ad221950..f075767204f00e85d52784843886841064b5f26a 100644 (file)
@@ -297,7 +297,7 @@ babel_load_state_file(void)
                 unsigned char sid[8];
                 rc = parse_eui64(buf2, sid);
                 if(rc < 0) {
-                    flog_err(BABEL_ERR_CONFIG, "Couldn't parse babel-state.");
+                    flog_err(EC_BABEL_CONFIG, "Couldn't parse babel-state.");
                 } else {
                     struct timeval realnow;
                     debugf(BABEL_DEBUG_COMMON,
@@ -307,13 +307,13 @@ babel_load_state_file(void)
                     if(memcmp(sid, myid, 8) == 0)
                         myseqno = seqno_plus(s, 1);
                     else
-                        flog_err(BABEL_ERR_CONFIG,
+                        flog_err(EC_BABEL_CONFIG,
                                 "ID mismatch in babel-state. id=%s; old=%s",
                                  format_eui64(myid),
                                  format_eui64(sid));
                 }
             } else {
-                flog_err(BABEL_ERR_CONFIG, "Couldn't parse babel-state.");
+                flog_err(EC_BABEL_CONFIG, "Couldn't parse babel-state.");
             }
         }
         goto fini;
@@ -364,12 +364,12 @@ babel_save_state_file(void)
                       format_eui64(myid), (int)myseqno,
                       (long)realnow.tv_sec);
         if(rc < 0 || rc >= 100) {
-            flog_err(BABEL_ERR_CONFIG, "write(babel-state): overflow.");
+            flog_err(EC_BABEL_CONFIG, "write(babel-state): overflow.");
             unlink(state_file);
         } else {
             rc = write(fd, buf, rc);
             if(rc < 0) {
-                flog_err(BABEL_ERR_CONFIG, "write(babel-state): %s",
+                flog_err(EC_BABEL_CONFIG, "write(babel-state): %s",
                          safe_strerror(errno));
                 unlink(state_file);
             }
index 54692cdf2ee56feab5e35cc34e9d79a80d0ca66d..18e5b479bc884fefc0e275b717fe210a586df3ce 100644 (file)
@@ -255,12 +255,12 @@ babel_get_myid(void)
         return;
     }
 
-    flog_err(BABEL_ERR_CONFIG,
+    flog_err(EC_BABEL_CONFIG,
              "Warning: couldn't find router id -- using random value.");
 
     rc = read_random_bytes(myid, 8);
     if(rc < 0) {
-        flog_err(BABEL_ERR_CONFIG, "read(random): %s (cannot assign an ID)",
+        flog_err(EC_BABEL_CONFIG, "read(random): %s (cannot assign an ID)",
                  safe_strerror(errno));
         exit(1);
     }
@@ -519,7 +519,7 @@ resize_receive_buffer(int size)
     if(receive_buffer == NULL) {
         receive_buffer = malloc(size);
         if(receive_buffer == NULL) {
-            flog_err(BABEL_ERR_MEMORY, "malloc(receive_buffer): %s",
+            flog_err(EC_BABEL_MEMORY, "malloc(receive_buffer): %s",
                      safe_strerror(errno));
             return -1;
         }
@@ -528,7 +528,7 @@ resize_receive_buffer(int size)
         unsigned char *new;
         new = realloc(receive_buffer, size);
         if(new == NULL) {
-            flog_err(BABEL_ERR_MEMORY, "realloc(receive_buffer): %s",
+            flog_err(EC_BABEL_MEMORY, "realloc(receive_buffer): %s",
                      safe_strerror(errno));
             return -1;
         }
index 09eaca7a48297185316a4c7d986eaf1e649dd16b..f85a08ac3a62544833e788e2af3bc1da668c38fa 100644 (file)
@@ -141,12 +141,12 @@ parse_update_subtlv(const unsigned char *a, int alen,
         }
 
         if(i + 1 > alen) {
-            flog_err(BABEL_ERR_PACKET, "Received truncated attributes.");
+            flog_err(EC_BABEL_PACKET, "Received truncated attributes.");
             return;
         }
         len = a[i + 1];
         if(i + len > alen) {
-            flog_err(BABEL_ERR_PACKET, "Received truncated attributes.");
+            flog_err(EC_BABEL_PACKET, "Received truncated attributes.");
             return;
         }
 
@@ -154,14 +154,14 @@ parse_update_subtlv(const unsigned char *a, int alen,
             /* Nothing. */
         } else if(type == SUBTLV_DIVERSITY) {
             if(len > DIVERSITY_HOPS) {
-                flog_err(BABEL_ERR_PACKET,
+                flog_err(EC_BABEL_PACKET,
                          "Received overlong channel information (%d > %d).n",
                           len, DIVERSITY_HOPS);
                 len = DIVERSITY_HOPS;
             }
             if(memchr(a + i + 2, 0, len) != NULL) {
                 /* 0 is reserved. */
-                flog_err(BABEL_ERR_PACKET, "Channel information contains 0!");
+                flog_err(EC_BABEL_PACKET, "Channel information contains 0!");
                 return;
             }
             memset(channels, 0, DIVERSITY_HOPS);
@@ -189,13 +189,13 @@ parse_hello_subtlv(const unsigned char *a, int alen,
         }
 
         if(i + 1 > alen) {
-            flog_err(BABEL_ERR_PACKET,
+            flog_err(EC_BABEL_PACKET,
                      "Received truncated sub-TLV on Hello message.");
             return -1;
         }
         len = a[i + 1];
         if(i + len > alen) {
-            flog_err(BABEL_ERR_PACKET,
+            flog_err(EC_BABEL_PACKET,
                      "Received truncated sub-TLV on Hello message.");
             return -1;
         }
@@ -207,7 +207,7 @@ parse_hello_subtlv(const unsigned char *a, int alen,
                 DO_NTOHL(*hello_send_us, a + i + 2);
                 ret = 1;
             } else {
-                flog_err(BABEL_ERR_PACKET,
+                flog_err(EC_BABEL_PACKET,
                          "Received incorrect RTT sub-TLV on Hello message.");
             }
         } else {
@@ -235,13 +235,13 @@ parse_ihu_subtlv(const unsigned char *a, int alen,
         }
 
         if(i + 1 > alen) {
-            flog_err(BABEL_ERR_PACKET,
+            flog_err(EC_BABEL_PACKET,
                      "Received truncated sub-TLV on IHU message.");
             return -1;
         }
         len = a[i + 1];
         if(i + len > alen) {
-            flog_err(BABEL_ERR_PACKET,
+            flog_err(EC_BABEL_PACKET,
                      "Received truncated sub-TLV on IHU message.");
             return -1;
         }
@@ -255,7 +255,7 @@ parse_ihu_subtlv(const unsigned char *a, int alen,
                 ret = 1;
             }
             else {
-                flog_err(BABEL_ERR_PACKET,
+                flog_err(EC_BABEL_PACKET,
                          "Received incorrect RTT sub-TLV on IHU message.");
             }
         } else {
@@ -345,14 +345,14 @@ parse_packet(const unsigned char *from, struct interface *ifp,
     }
 
     if(!linklocal(from)) {
-        flog_err(BABEL_ERR_PACKET,
+        flog_err(EC_BABEL_PACKET,
                  "Received packet from non-local address %s.",
                   format_address(from));
         return;
     }
 
     if (babel_packet_examin (packet, packetlen)) {
-        flog_err(BABEL_ERR_PACKET,
+        flog_err(EC_BABEL_PACKET,
                  "Received malformed packet on %s from %s.",
                   ifp->name, format_address(from));
         return;
@@ -360,14 +360,14 @@ parse_packet(const unsigned char *from, struct interface *ifp,
 
     neigh = find_neighbour(from, ifp);
     if(neigh == NULL) {
-        flog_err(BABEL_ERR_PACKET, "Couldn't allocate neighbour.");
+        flog_err(EC_BABEL_PACKET, "Couldn't allocate neighbour.");
         return;
     }
 
     DO_NTOHS(bodylen, packet + 2);
 
     if(bodylen + 4 > packetlen) {
-        flog_err(BABEL_ERR_PACKET, "Received truncated packet (%d + 4 > %d).",
+        flog_err(EC_BABEL_PACKET, "Received truncated packet (%d + 4 > %d).",
                  bodylen, packetlen);
         bodylen = packetlen - 4;
     }
@@ -516,7 +516,7 @@ parse_packet(const unsigned char *from, struct interface *ifp,
                 have_router_id = 1;
             }
             if(!have_router_id && message[2] != 0) {
-                flog_err(BABEL_ERR_PACKET,
+                flog_err(EC_BABEL_PACKET,
                          "Received prefix with no router id.");
                 goto fail;
             }
@@ -528,7 +528,7 @@ parse_packet(const unsigned char *from, struct interface *ifp,
 
             if(message[2] == 0) {
                 if(metric < 0xFFFF) {
-                    flog_err(BABEL_ERR_PACKET,
+                    flog_err(EC_BABEL_PACKET,
                              "Received wildcard update with finite metric.");
                     goto done;
                 }
@@ -621,7 +621,7 @@ parse_packet(const unsigned char *from, struct interface *ifp,
         continue;
 
     fail:
-        flog_err(BABEL_ERR_PACKET,
+        flog_err(EC_BABEL_PACKET,
                  "Couldn't parse packet (%d, %d) from %s on %s.",
                   message[0], message[1], format_address(from), ifp->name);
         goto done;
@@ -710,7 +710,7 @@ fill_rtt_message(struct interface *ifp)
             DO_HTONL(babel_ifp->sendbuf + babel_ifp->buffered_hello + 10, time);
             return 1;
         } else {
-            flog_err(BABEL_ERR_PACKET, "No space left for timestamp sub-TLV "
+            flog_err(EC_BABEL_PACKET, "No space left for timestamp sub-TLV "
                      "(this shouldn't happen)");
             return -1;
         }
@@ -745,9 +745,9 @@ flushbuf(struct interface *ifp)
                             babel_ifp->sendbuf, babel_ifp->buffered,
                             (struct sockaddr*)&sin6, sizeof(sin6));
             if(rc < 0)
-                flog_err(BABEL_ERR_PACKET, "send: %s", safe_strerror(errno));
+                flog_err(EC_BABEL_PACKET, "send: %s", safe_strerror(errno));
         } else {
-            flog_err(BABEL_ERR_PACKET,
+            flog_err(EC_BABEL_PACKET,
                      "Warning: bucket full, dropping packet to %s.",
                       ifp->name);
         }
@@ -870,7 +870,7 @@ start_unicast_message(struct neighbour *neigh, int type, int len)
     if(!unicast_buffer)
         unicast_buffer = malloc(UNICAST_BUFSIZE);
     if(!unicast_buffer) {
-        flog_err(BABEL_ERR_MEMORY, "malloc(unicast_buffer): %s",
+        flog_err(EC_BABEL_MEMORY, "malloc(unicast_buffer): %s",
                  safe_strerror(errno));
         return -1;
     }
@@ -1007,10 +1007,10 @@ flush_unicast(int dofree)
                         unicast_buffer, unicast_buffered,
                         (struct sockaddr*)&sin6, sizeof(sin6));
         if(rc < 0)
-            flog_err(BABEL_ERR_PACKET, "send(unicast): %s",
+            flog_err(EC_BABEL_PACKET, "send(unicast): %s",
                      safe_strerror(errno));
     } else {
-        flog_err(BABEL_ERR_PACKET,
+        flog_err(EC_BABEL_PACKET,
                  "Warning: bucket full, dropping unicast packet to %s if %s.",
                   format_address(unicast_neighbour->address),
                   unicast_neighbour->ifp->name);
@@ -1318,7 +1318,7 @@ buffer_update(struct interface *ifp,
     again:
         babel_ifp->buffered_updates = malloc(n *sizeof(struct buffered_update));
         if(babel_ifp->buffered_updates == NULL) {
-            flog_err(BABEL_ERR_MEMORY, "malloc(buffered_updates): %s",
+            flog_err(EC_BABEL_MEMORY, "malloc(buffered_updates): %s",
                      safe_strerror(errno));
             if(n > 4) {
                 /* Try again with a tiny buffer. */
@@ -1382,7 +1382,7 @@ send_update(struct interface *ifp, int urgent,
             }
             route_stream_done(routes);
         } else {
-            flog_err(BABEL_ERR_MEMORY, "Couldn't allocate route stream.");
+            flog_err(EC_BABEL_MEMORY, "Couldn't allocate route stream.");
         }
         set_timeout(&babel_ifp->update_timeout, babel_ifp->update_interval);
         babel_ifp->last_update_time = babel_now.tv_sec;
@@ -1460,7 +1460,7 @@ send_self_update(struct interface *ifp)
         }
         xroute_stream_done(xroutes);
     } else {
-        flog_err(BABEL_ERR_MEMORY, "Couldn't allocate xroute stream.");
+        flog_err(EC_BABEL_MEMORY, "Couldn't allocate xroute stream.");
     }
 }
 
index 512b60e29a11491818dabfaf249ccf8b345cccb5..83f05bb5cf337698dc0b8622ee7394d26c6ba45e 100644 (file)
@@ -94,7 +94,7 @@ find_neighbour(const unsigned char *address, struct interface *ifp)
 
     neigh = malloc(sizeof(struct neighbour));
     if(neigh == NULL) {
-        flog_err(BABEL_ERR_MEMORY, "malloc(neighbour): %s",
+        flog_err(EC_BABEL_MEMORY, "malloc(neighbour): %s",
                  safe_strerror(errno));
         return NULL;
     }
index ceeaa105779a48408a222cc3a370bbf910b2a378..76f038cda5f4793fc90bdf6dff77d7e1c486ea2b 100644 (file)
@@ -399,14 +399,14 @@ install_route(struct babel_route *route)
         return;
 
     if(!route_feasible(route))
-        flog_err(BABEL_ERR_ROUTE, "WARNING: installing unfeasible route "
+        flog_err(EC_BABEL_ROUTE, "WARNING: installing unfeasible route "
                   "(this shouldn't happen).");
 
     i = find_route_slot(route->src->prefix, route->src->plen, NULL);
     assert(i >= 0 && i < route_slots);
 
     if(routes[i] != route && routes[i]->installed) {
-        flog_err(BABEL_ERR_ROUTE,
+        flog_err(EC_BABEL_ROUTE,
                  "WARNING: attempting to install duplicate route "
                   "(this shouldn't happen).");
         return;
@@ -418,7 +418,7 @@ install_route(struct babel_route *route)
                       metric_to_kernel(route_metric(route)), NULL, 0, 0);
     if(rc < 0) {
         int save = errno;
-        flog_err(BABEL_ERR_ROUTE, "kernel_route(ADD): %s",
+        flog_err(EC_BABEL_ROUTE, "kernel_route(ADD): %s",
                  safe_strerror(errno));
         if(save != EEXIST)
             return;
@@ -441,7 +441,7 @@ uninstall_route(struct babel_route *route)
                       route->neigh->ifp->ifindex,
                       metric_to_kernel(route_metric(route)), NULL, 0, 0);
     if(rc < 0)
-        flog_err(BABEL_ERR_ROUTE, "kernel_route(FLUSH): %s",
+        flog_err(EC_BABEL_ROUTE, "kernel_route(FLUSH): %s",
                  safe_strerror(errno));
 
     route->installed = 0;
@@ -465,7 +465,7 @@ switch_routes(struct babel_route *old, struct babel_route *new)
         return;
 
     if(!route_feasible(new))
-        flog_err(BABEL_ERR_ROUTE, "WARNING: switching to unfeasible route "
+        flog_err(EC_BABEL_ROUTE, "WARNING: switching to unfeasible route "
                   "(this shouldn't happen).");
 
     rc = kernel_route(ROUTE_MODIFY, old->src->prefix, old->src->plen,
@@ -474,7 +474,7 @@ switch_routes(struct babel_route *old, struct babel_route *new)
                       new->nexthop, new->neigh->ifp->ifindex,
                       metric_to_kernel(route_metric(new)));
     if(rc < 0) {
-        flog_err(BABEL_ERR_ROUTE, "kernel_route(MODIFY): %s",
+        flog_err(EC_BABEL_ROUTE, "kernel_route(MODIFY): %s",
                  safe_strerror(errno));
         return;
     }
@@ -503,7 +503,7 @@ change_route_metric(struct babel_route *route,
                           route->nexthop, route->neigh->ifp->ifindex,
                           new);
         if(rc < 0) {
-            flog_err(BABEL_ERR_ROUTE, "kernel_route(MODIFY metric): %s",
+            flog_err(EC_BABEL_ROUTE, "kernel_route(MODIFY metric): %s",
                      safe_strerror(errno));
             return;
         }
@@ -798,7 +798,7 @@ update_route(const unsigned char *router_id,
         return NULL;
 
     if(martian_prefix(prefix, plen)) {
-        flog_err(BABEL_ERR_ROUTE, "Rejecting martian route to %s through %s.",
+        flog_err(EC_BABEL_ROUTE, "Rejecting martian route to %s through %s.",
                  format_prefix(prefix, plen), format_address(nexthop));
         return NULL;
     }
@@ -906,7 +906,7 @@ update_route(const unsigned char *router_id,
         route->next = NULL;
         new_route = insert_route(route);
         if(new_route == NULL) {
-            flog_err(BABEL_ERR_ROUTE, "Couldn't insert route.");
+            flog_err(EC_BABEL_ROUTE, "Couldn't insert route.");
             free(route);
             return NULL;
         }
index 75bca0620639d32f9f17cd01ea7b017818f8f0b0..ed165b41b44d8956a8c1ca69efba9b0a810d7de8 100644 (file)
@@ -63,7 +63,7 @@ find_source(const unsigned char *id, const unsigned char *p, unsigned char plen,
 
     src = malloc(sizeof(struct source));
     if(src == NULL) {
-        flog_err(BABEL_ERR_MEMORY, "malloc(source): %s", safe_strerror(errno));
+        flog_err(EC_BABEL_MEMORY, "malloc(source): %s", safe_strerror(errno));
         return NULL;
     }