summaryrefslogtreecommitdiffstats
path: root/zebra/zapi_msg.c
diff options
context:
space:
mode:
authorpaco <paco@voltanet.io>2018-06-07 15:28:12 +0200
committerF. Aragon <paco@voltanet.io>2018-09-18 17:39:16 +0200
commitf533be73f6e73e7c6c2f2093f4bec59862c08dd6 (patch)
tree78e6e3c28c4a84b7309aaedfa8b99cc8fc5e5501 /zebra/zapi_msg.c
parentMerge pull request #3017 from pacovn/devbuild_Wshadow_flag (diff)
downloadfrr-f533be73f6e73e7c6c2f2093f4bec59862c08dd6.tar.xz
frr-f533be73f6e73e7c6c2f2093f4bec59862c08dd6.zip
bgpd, doc, ldpd, lib, tests, zebra: LM fixes
Corrections so that the BGP daemon can work with the label manager properly through a label-manager proxy. Details: - Correction so the BGP daemon behind a proxy label manager gets the range correctly (-I added to the BGP daemon, to set the daemon instance id) - For the BGP case, added an asynchronous label manager connect command so the labels get recycled in case of a BGP daemon reconnection. With this, BGPd and LDPd would behave similarly. Signed-off-by: F. Aragon <paco@voltanet.io>
Diffstat (limited to 'zebra/zapi_msg.c')
-rw-r--r--zebra/zapi_msg.c61
1 files changed, 13 insertions, 48 deletions
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index 55c5b934f..b9897bea0 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -1829,7 +1829,8 @@ static void zread_label_manager_connect(struct zserv *client,
flog_err(EC_ZEBRA_TM_WRONG_PROTO,
"client %d has wrong protocol %s", client->sock,
zebra_route_string(proto));
- zsend_label_manager_connect_response(client, vrf_id, 1);
+ if (client->is_synchronous)
+ zsend_label_manager_connect_response(client, vrf_id, 1);
return;
}
zlog_notice("client %d with vrf %u instance %u connected as %s",
@@ -1847,33 +1848,12 @@ static void zread_label_manager_connect(struct zserv *client,
" Label Manager client connected: sock %d, proto %s, vrf %u instance %u",
client->sock, zebra_route_string(proto), vrf_id, instance);
/* send response back */
- zsend_label_manager_connect_response(client, vrf_id, 0);
+ if (client->is_synchronous)
+ zsend_label_manager_connect_response(client, vrf_id, 0);
stream_failure:
return;
}
-static int msg_client_id_mismatch(const char *op, struct zserv *client,
- uint8_t proto, unsigned int instance)
-{
- if (proto != client->proto) {
- flog_err(EC_ZEBRA_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) {
- flog_err(
- EC_ZEBRA_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 */
- /* return 1; */
- }
-
- return 0;
-}
static void zread_get_label_chunk(struct zserv *client, struct stream *msg,
vrf_id_t vrf_id)
@@ -1894,21 +1874,16 @@ static void zread_get_label_chunk(struct zserv *client, struct stream *msg,
STREAM_GETC(s, keep);
STREAM_GETL(s, size);
- /* detect client vs message (proto,instance) mismatch */
- if (msg_client_id_mismatch("Get-label-chunk", client, proto, instance))
- return;
-
- lmc = assign_label_chunk(client->proto, client->instance, keep, size);
+ lmc = assign_label_chunk(proto, instance, keep, size);
if (!lmc)
flog_err(
EC_ZEBRA_LM_CANNOT_ASSIGN_CHUNK,
"Unable to assign Label Chunk of size %u to %s instance %u",
- size, zebra_route_string(client->proto),
- client->instance);
+ size, zebra_route_string(proto), instance);
else
zlog_debug("Assigned Label Chunk %u - %u to %s instance %u",
lmc->start, lmc->end,
- zebra_route_string(client->proto), client->instance);
+ zebra_route_string(proto), instance);
/* send response back */
zsend_assign_label_chunk_response(client, vrf_id, lmc);
@@ -1932,12 +1907,7 @@ static void zread_release_label_chunk(struct zserv *client, struct stream *msg)
STREAM_GETL(s, start);
STREAM_GETL(s, end);
- /* detect client vs message (proto,instance) mismatch */
- if (msg_client_id_mismatch("Release-label-chunk", client, proto,
- instance))
- return;
-
- release_label_chunk(client->proto, client->instance, start, end);
+ release_label_chunk(proto, instance, start, end);
stream_failure:
return;
@@ -1945,8 +1915,8 @@ stream_failure:
static void zread_label_manager_request(ZAPI_HANDLER_ARGS)
{
/* to avoid sending other messages like ZERBA_INTERFACE_UP */
- if (hdr->command == ZEBRA_LABEL_MANAGER_CONNECT)
- client->is_synchronous = 1;
+ client->is_synchronous = hdr->command ==
+ ZEBRA_LABEL_MANAGER_CONNECT;
/* external label manager */
if (lm_is_external)
@@ -1954,16 +1924,10 @@ static void zread_label_manager_request(ZAPI_HANDLER_ARGS)
zvrf_id(zvrf));
/* this is a label manager */
else {
- if (hdr->command == ZEBRA_LABEL_MANAGER_CONNECT)
+ if (hdr->command == ZEBRA_LABEL_MANAGER_CONNECT ||
+ hdr->command == ZEBRA_LABEL_MANAGER_CONNECT_ASYNC)
zread_label_manager_connect(client, msg, zvrf_id(zvrf));
else {
- /* Sanity: don't allow 'unidentified' requests */
- if (!client->proto) {
- flog_err(
- EC_ZEBRA_LM_ALIENS,
- "Got label request from an unidentified client");
- return;
- }
if (hdr->command == ZEBRA_GET_LABEL_CHUNK)
zread_get_label_chunk(client, msg,
zvrf_id(zvrf));
@@ -2448,6 +2412,7 @@ void (*zserv_handlers[])(ZAPI_HANDLER_ARGS) = {
[ZEBRA_MPLS_LABELS_DELETE] = zread_mpls_labels,
[ZEBRA_IPMR_ROUTE_STATS] = zebra_ipmr_route_stats,
[ZEBRA_LABEL_MANAGER_CONNECT] = zread_label_manager_request,
+ [ZEBRA_LABEL_MANAGER_CONNECT_ASYNC] = zread_label_manager_request,
[ZEBRA_GET_LABEL_CHUNK] = zread_label_manager_request,
[ZEBRA_RELEASE_LABEL_CHUNK] = zread_label_manager_request,
[ZEBRA_FEC_REGISTER] = zread_fec_register,