diff options
Diffstat (limited to 'zebra/zapi_msg.c')
| -rw-r--r-- | zebra/zapi_msg.c | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 22c0dd623c..008fc8f066 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1058,7 +1058,8 @@ static void zread_rnh_register(ZAPI_HANDLER_ARGS) STREAM_GET(&p.u.prefix6, s, IPV6_MAX_BYTELEN); l += IPV6_MAX_BYTELEN; } else { - zlog_err( + flog_err( + ZEBRA_ERR_UNKNOWN_FAMILY, "rnh_register: Received unknown family type %d\n", p.family); return; @@ -1136,7 +1137,8 @@ static void zread_rnh_unregister(ZAPI_HANDLER_ARGS) STREAM_GET(&p.u.prefix6, s, IPV6_MAX_BYTELEN); l += IPV6_MAX_BYTELEN; } else { - zlog_err( + flog_err( + ZEBRA_ERR_UNKNOWN_FAMILY, "rnh_register: Received unknown family type %d\n", p.family); return; @@ -1172,7 +1174,8 @@ static void zread_fec_register(ZAPI_HANDLER_ARGS) * registration */ if (hdr->length < ZEBRA_MIN_FEC_LENGTH) { - zlog_err( + flog_err( + ZEBRA_ERR_IRDP_LEN_MISMATCH, "fec_register: Received a fec register of hdr->length %d, it is of insufficient size to properly decode", hdr->length); return; @@ -1183,7 +1186,8 @@ static void zread_fec_register(ZAPI_HANDLER_ARGS) memset(&p, 0, sizeof(p)); STREAM_GETW(s, p.family); if (p.family != AF_INET && p.family != AF_INET6) { - zlog_err( + flog_err( + ZEBRA_ERR_UNKNOWN_FAMILY, "fec_register: Received unknown family type %d\n", p.family); return; @@ -1230,7 +1234,8 @@ static void zread_fec_unregister(ZAPI_HANDLER_ARGS) * fec unregistration */ if (hdr->length < ZEBRA_MIN_FEC_LENGTH) { - zlog_err( + flog_err( + ZEBRA_ERR_IRDP_LEN_MISMATCH, "fec_unregister: Received a fec unregister of hdr->length %d, it is of insufficient size to properly decode", hdr->length); return; @@ -1244,7 +1249,8 @@ static void zread_fec_unregister(ZAPI_HANDLER_ARGS) memset(&p, 0, sizeof(p)); STREAM_GETW(s, p.family); if (p.family != AF_INET && p.family != AF_INET6) { - zlog_err( + flog_err( + ZEBRA_ERR_UNKNOWN_FAMILY, "fec_unregister: Received unknown family type %d\n", p.family); return; @@ -2376,8 +2382,9 @@ static void zread_table_manager_connect(struct zserv *client, /* accept only dynamic routing protocols */ if ((proto >= ZEBRA_ROUTE_MAX) || (proto <= ZEBRA_ROUTE_STATIC)) { - zlog_err("client %d has wrong protocol %s", client->sock, - zebra_route_string(proto)); + flog_err(ZEBRA_ERR_TM_WRONG_PROTO, + "client %d has wrong protocol %s", client->sock, + zebra_route_string(proto)); zsend_table_manager_connect_response(client, vrf_id, 1); return; } @@ -2415,8 +2422,9 @@ static void zread_label_manager_connect(struct zserv *client, /* accept only dynamic routing protocols */ if ((proto >= ZEBRA_ROUTE_MAX) || (proto <= ZEBRA_ROUTE_STATIC)) { - zlog_err("client %d has wrong protocol %s", client->sock, - zebra_route_string(proto)); + flog_err(ZEBRA_ERR_TM_WRONG_PROTO, + "client %d has wrong protocol %s", client->sock, + zebra_route_string(proto)); zsend_label_manager_connect_response(client, vrf_id, 1); return; } @@ -2444,14 +2452,16 @@ static int msg_client_id_mismatch(const char *op, struct zserv *client, uint8_t proto, unsigned int instance) { if (proto != client->proto) { - zlog_err("%s: msg vs client proto mismatch, client=%u msg=%u", - op, client->proto, proto); + flog_err(ZEBRA_ERR_PROTO_OR_INSTANCE_MISMATCH, + "%s: msg vs client proto mismatch, client=%u msg=%u", + op, client->proto, proto); /* TODO: fail when BGP sets proto and instance */ /* return 1; */ } if (instance != client->instance) { - zlog_err( + flog_err( + ZEBRA_ERR_PROTO_OR_INSTANCE_MISMATCH, "%s: msg vs client instance mismatch, client=%u msg=%u", op, client->instance, instance); /* TODO: fail when BGP sets proto and instance */ @@ -2486,7 +2496,8 @@ static void zread_get_label_chunk(struct zserv *client, struct stream *msg, lmc = assign_label_chunk(client->proto, client->instance, keep, size); if (!lmc) - zlog_err( + flog_err( + ZEBRA_ERR_LM_CANNOT_ASSIGN_CHUNK, "Unable to assign Label Chunk of size %u to %s instance %u", size, zebra_route_string(client->proto), client->instance); @@ -2544,7 +2555,8 @@ static void zread_label_manager_request(ZAPI_HANDLER_ARGS) else { /* Sanity: don't allow 'unidentified' requests */ if (!client->proto) { - zlog_err( + flog_err( + ZEBRA_ERR_LM_ALIENS, "Got label request from an unidentified client"); return; } @@ -2572,8 +2584,9 @@ static void zread_get_table_chunk(struct zserv *client, struct stream *msg, tmc = assign_table_chunk(client->proto, client->instance, size); if (!tmc) - zlog_err("%s: Unable to assign Table Chunk of size %u", - __func__, size); + flog_err(ZEBRA_ERR_TM_CANNOT_ASSIGN_CHUNK, + "%s: Unable to assign Table Chunk of size %u", + __func__, size); else zlog_debug("Assigned Table Chunk %u - %u", tmc->start, tmc->end); @@ -2610,7 +2623,8 @@ static void zread_table_manager_request(ZAPI_HANDLER_ARGS) else { /* Sanity: don't allow 'unidentified' requests */ if (!client->proto) { - zlog_err( + flog_err( + ZEBRA_ERR_TM_ALIENS, "Got table request from an unidentified client"); return; } @@ -3073,12 +3087,13 @@ static void zserv_write_incoming(struct stream *orig, uint16_t command) copy = stream_dup(orig); stream_set_getp(copy, 0); - zserv_privs.change(ZPRIVS_RAISE); snprintf(fname, MAXPATHLEN, "%s/%u", DAEMON_VTY_DIR, command); - fd = open(fname, O_CREAT | O_WRONLY | O_EXCL, 0644); + + frr_elevate_privs(&zserv_privs) { + fd = open(fname, O_CREAT | O_WRONLY | O_EXCL, 0644); + } stream_flush(copy, fd); close(fd); - zserv_privs.change(ZPRIVS_LOWER); stream_free(copy); } #endif |
