summaryrefslogtreecommitdiff
path: root/bgpd/bgp_route.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_route.c')
-rw-r--r--bgpd/bgp_route.c56
1 files changed, 22 insertions, 34 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index b66a913f54..b395543795 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -44,6 +44,7 @@
#include "bgpd/bgp_route.h"
#include "bgpd/bgp_attr.h"
#include "bgpd/bgp_debug.h"
+#include "bgpd/bgp_errors.h"
#include "bgpd/bgp_aspath.h"
#include "bgpd/bgp_regex.h"
#include "bgpd/bgp_community.h"
@@ -2459,16 +2460,10 @@ static void bgp_processq_del(struct work_queue *wq, void *data)
void bgp_process_queue_init(void)
{
- if (!bm->process_main_queue) {
+ if (!bm->process_main_queue)
bm->process_main_queue =
work_queue_new(bm->master, "process_main_queue");
- if (!bm->process_main_queue) {
- zlog_err("%s: Failed to allocate work queue", __func__);
- exit(1);
- }
- }
-
bm->process_main_queue->spec.workfunc = &bgp_process_wq;
bm->process_main_queue->spec.del_item_data = &bgp_processq_del;
bm->process_main_queue->spec.max_retries = 0;
@@ -3838,11 +3833,7 @@ static void bgp_clear_node_queue_init(struct peer *peer)
snprintf(wname, sizeof(wname), "clear %s", peer->host);
#undef CLEAR_QUEUE_NAME_LEN
- if ((peer->clear_node_queue = work_queue_new(bm->master, wname))
- == NULL) {
- zlog_err("%s: Failed to allocate work queue", __func__);
- exit(1);
- }
+ peer->clear_node_queue = work_queue_new(bm->master, wname);
peer->clear_node_queue->spec.hold = 10;
peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node;
peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del;
@@ -4212,8 +4203,9 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
/* Prefix length check. */
if (p.prefixlen > prefix_blen(&p) * 8) {
- zlog_err(
- "%s [Error] Update packet error (wrong perfix length %d for afi %u)",
+ flog_err(
+ BGP_ERR_UPDATE_RCV,
+ "%s [Error] Update packet error (wrong prefix length %d for afi %u)",
peer->host, p.prefixlen, packet->afi);
return -1;
}
@@ -4223,7 +4215,8 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
/* When packet overflow occur return immediately. */
if (pnt + psize > lim) {
- zlog_err(
+ flog_err(
+ BGP_ERR_UPDATE_RCV,
"%s [Error] Update packet error (prefix length %d overflows packet)",
peer->host, p.prefixlen);
return -1;
@@ -4232,7 +4225,8 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
/* Defensive coding, double-check the psize fits in a struct
* prefix */
if (psize > (ssize_t)sizeof(p.u)) {
- zlog_err(
+ flog_err(
+ BGP_ERR_UPDATE_RCV,
"%s [Error] Update packet error (prefix length %d too large for prefix storage %zu)",
peer->host, p.prefixlen, sizeof(p.u));
return -1;
@@ -4253,7 +4247,8 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
* be logged locally, and the prefix SHOULD be
* ignored.
*/
- zlog_err(
+ flog_err(
+ BGP_ERR_UPDATE_RCV,
"%s: IPv4 unicast NLRI is multicast address %s, ignoring",
peer->host, inet_ntoa(p.u.prefix4));
continue;
@@ -4265,7 +4260,8 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
if (IN6_IS_ADDR_LINKLOCAL(&p.u.prefix6)) {
char buf[BUFSIZ];
- zlog_err(
+ flog_err(
+ BGP_ERR_UPDATE_RCV,
"%s: IPv6 unicast NLRI is link-local address %s, ignoring",
peer->host,
inet_ntop(AF_INET6, &p.u.prefix6, buf,
@@ -4276,7 +4272,8 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
if (IN6_IS_ADDR_MULTICAST(&p.u.prefix6)) {
char buf[BUFSIZ];
- zlog_err(
+ flog_err(
+ BGP_ERR_UPDATE_RCV,
"%s: IPv6 unicast NLRI is multicast address %s, ignoring",
peer->host,
inet_ntop(AF_INET6, &p.u.prefix6, buf,
@@ -4305,7 +4302,8 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
/* Packet length consistency check. */
if (pnt != lim) {
- zlog_err(
+ flog_err(
+ BGP_ERR_UPDATE_RCV,
"%s [Error] Update packet error (prefix length mismatch with total length)",
peer->host);
return -1;
@@ -6255,24 +6253,14 @@ static void route_vty_out_route(struct prefix *p, struct vty *vty,
json_object *json)
{
int len = 0;
- uint32_t destination;
char buf[BUFSIZ];
if (p->family == AF_INET) {
if (!json) {
- len = vty_out(vty, "%s",
- inet_ntop(p->family, &p->u.prefix, buf,
- BUFSIZ));
- destination = ntohl(p->u.prefix4.s_addr);
-
- if ((IN_CLASSC(destination) && p->prefixlen == 24)
- || (IN_CLASSB(destination) && p->prefixlen == 16)
- || (IN_CLASSA(destination) && p->prefixlen == 8)
- || p->u.prefix4.s_addr == 0) {
- /* When mask is natural,
- mask is not displayed. */
- } else
- len += vty_out(vty, "/%d", p->prefixlen);
+ len = vty_out(
+ vty, "%s/%d",
+ inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
+ p->prefixlen);
} else {
json_object_string_add(json, "prefix",
inet_ntop(p->family,