&vrf_id, &resp_cmd);
if (ret < 0 && errno != EAGAIN) {
flog_err(EC_ZEBRA_LM_RESPONSE,
- "Error reading Label Manager response: %s",
- strerror(errno));
+ "Error reading Label Manager response: %s",
+ strerror(errno));
return -1;
}
- zlog_debug("Label Manager response received, %d bytes", size);
+
+ /* do not relay a msg that has nothing to do with LM */
+ switch (resp_cmd) {
+ case ZEBRA_LABEL_MANAGER_CONNECT:
+ case ZEBRA_LABEL_MANAGER_CONNECT_ASYNC: /* should not be seen */
+ case ZEBRA_GET_LABEL_CHUNK:
+ case ZEBRA_RELEASE_LABEL_CHUNK:
+ break;
+ default:
+ zlog_debug("Not relaying '%s' response (size %d) from LM",
+ zserv_command_string(resp_cmd), size);
+ return -1;
+ }
+
+ zlog_debug("Received '%s' response (size %d) from LM",
+ zserv_command_string(resp_cmd), size);
+
if (size == 0)
return -1;
ret = writen(zserv->sock, dst->data, stream_get_endp(dst));
if (ret <= 0) {
flog_err(EC_ZEBRA_LM_RELAY_FAILED,
- "Error relaying LM response to %s instance %u: %s",
- proto_str, instance, strerror(errno));
+ "Error relaying LM response to %s instance %u: %s",
+ proto_str, instance, strerror(errno));
return -1;
}
zlog_debug("Relayed LM response (%d bytes) to %s instance %u", ret,
/* read response and send it back */
ret = relay_response_back();
+ /* on error, schedule another read */
+ if (ret == -1)
+ if (!zclient->t_read)
+ thread_add_read(zclient->master, lm_zclient_read, NULL,
+ zclient->sock, &zclient->t_read);
return ret;
}
if (zclient->sock < 0) {
flog_err(EC_ZEBRA_LM_NO_SOCKET,
- "Unable to relay LM request: no socket");
+ "Unable to relay LM request: no socket");
reply_error(cmd, zserv, vrf_id);
return -1;
}
/* check & set client instance if unset */
if (zserv->instance && zserv->instance != instance) {
flog_err(EC_ZEBRA_LM_BAD_INSTANCE,
- "Client instance(%u) != msg instance(%u)",
- zserv->instance, instance);
+ "Client instance(%u) != msg instance(%u)",
+ zserv->instance, instance);
return -1;
}
zserv->proto = proto;
/* in case there's any incoming message enqueued, read and forward it */
- while (ret == 0)
- ret = relay_response_back();
+ if (zserv->is_synchronous)
+ while (ret == 0)
+ ret = relay_response_back();
/* get the msg buffer used toward the 'master' Label Manager */
dst = zclient->obuf;
ret = writen(zclient->sock, dst->data, stream_get_endp(dst));
if (ret <= 0) {
flog_err(EC_ZEBRA_LM_RELAY_FAILED,
- "Error relaying LM request from %s instance %u: %s",
- proto_str, instance, strerror(errno));
+ "Error relaying LM request from %s instance %u: %s",
+ proto_str, instance, strerror(errno));
reply_error(cmd, zserv, vrf_id);
return -1;
}
if (zclient_socket_connect(zclient) < 0) {
flog_err(EC_ZEBRA_LM_CLIENT_CONNECTION_FAILED,
- "Error connecting synchronous zclient!");
+ "Error connecting synchronous zclient!");
thread_add_timer(zebrad.master, lm_zclient_connect, zclient,
CONNECTION_DELAY, &zclient->t_connect);
return -1;
lm_zserv_path);
/* Set default values. */
- zclient = zclient_new_notify(zebrad.master, &zclient_options_default);
+ zclient = zclient_new(zebrad.master, &zclient_options_default);
zclient->privs = &zserv_privs;
zclient->sock = -1;
zclient->t_connect = NULL;
+ 1;
if (lmc->start > MPLS_LABEL_UNRESERVED_MAX - size + 1) {
flog_err(EC_ZEBRA_LM_EXHAUSTED_LABELS,
- "Reached max labels. Start: %u, size: %u", lmc->start,
- size);
+ "Reached max labels. Start: %u, size: %u", lmc->start,
+ size);
XFREE(MTYPE_LM_CHUNK, lmc);
return NULL;
}
continue;
if (lmc->proto != proto || lmc->instance != instance) {
flog_err(EC_ZEBRA_LM_DAEMON_MISMATCH,
- "%s: Daemon mismatch!!", __func__);
+ "%s: Daemon mismatch!!", __func__);
continue;
}
lmc->proto = NO_PROTO;
}
if (ret != 0)
flog_err(EC_ZEBRA_LM_UNRELEASED_CHUNK,
- "%s: Label chunk not released!!", __func__);
+ "%s: Label chunk not released!!", __func__);
return ret;
}
void label_manager_close()
{
- list_delete_and_null(&lbl_mgr.lc_list);
+ list_delete(&lbl_mgr.lc_list);
stream_free(obuf);
}