summaryrefslogtreecommitdiff
path: root/lib/zclient.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/zclient.c')
-rw-r--r--lib/zclient.c50
1 files changed, 40 insertions, 10 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index fd1b181e58..b2c74cd0b9 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -143,6 +143,18 @@ void redist_del_instance(struct redist_proto *red, unsigned short instance)
}
}
+void redist_del_all_instances(struct redist_proto *red)
+{
+ struct listnode *ln, *nn;
+ unsigned short *id;
+
+ if (!red->instances)
+ return;
+
+ for (ALL_LIST_ELEMENTS(red->instances, ln, nn, id))
+ redist_del_instance(red, *id);
+}
+
/* Stop zebra client services. */
void zclient_stop(struct zclient *zclient)
{
@@ -899,8 +911,6 @@ int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh,
stream_putc(s, api_nh->bh_type);
break;
case NEXTHOP_TYPE_IPV4:
- stream_put_in_addr(s, &api_nh->gate.ipv4);
- break;
case NEXTHOP_TYPE_IPV4_IFINDEX:
stream_put_in_addr(s, &api_nh->gate.ipv4);
stream_putl(s, api_nh->ifindex);
@@ -909,9 +919,6 @@ int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh,
stream_putl(s, api_nh->ifindex);
break;
case NEXTHOP_TYPE_IPV6:
- stream_write(s, (uint8_t *)&api_nh->gate.ipv6,
- 16);
- break;
case NEXTHOP_TYPE_IPV6_IFINDEX:
stream_write(s, (uint8_t *)&api_nh->gate.ipv6,
16);
@@ -1059,9 +1066,6 @@ static int zapi_nexthop_decode(struct stream *s, struct zapi_nexthop *api_nh,
STREAM_GETC(s, api_nh->bh_type);
break;
case NEXTHOP_TYPE_IPV4:
- STREAM_GET(&api_nh->gate.ipv4.s_addr, s,
- IPV4_MAX_BYTELEN);
- break;
case NEXTHOP_TYPE_IPV4_IFINDEX:
STREAM_GET(&api_nh->gate.ipv4.s_addr, s,
IPV4_MAX_BYTELEN);
@@ -1071,8 +1075,6 @@ static int zapi_nexthop_decode(struct stream *s, struct zapi_nexthop *api_nh,
STREAM_GETL(s, api_nh->ifindex);
break;
case NEXTHOP_TYPE_IPV6:
- STREAM_GET(&api_nh->gate.ipv6, s, 16);
- break;
case NEXTHOP_TYPE_IPV6_IFINDEX:
STREAM_GET(&api_nh->gate.ipv6, s, 16);
STREAM_GETL(s, api_nh->ifindex);
@@ -1467,6 +1469,21 @@ stream_failure:
return false;
}
+bool zapi_error_decode(struct stream *s, enum zebra_error_types *error)
+{
+ memset(error, 0, sizeof(*error));
+
+ STREAM_GET(error, s, sizeof(*error));
+
+ if (zclient_debug)
+ zlog_debug("%s: type: %s", __func__,
+ zebra_error_type2str(*error));
+
+ return true;
+stream_failure:
+ return false;
+}
+
/*
* send a ZEBRA_REDISTRIBUTE_ADD or ZEBRA_REDISTRIBUTE_DELETE
* for the route type (ZEBRA_ROUTE_KERNEL etc.). The zebra server will
@@ -1706,6 +1723,17 @@ static void zclient_interface_down(struct zclient *zclient, vrf_id_t vrf_id)
if_down_via_zapi(ifp);
}
+static void zclient_handle_error(ZAPI_CALLBACK_ARGS)
+{
+ enum zebra_error_types error;
+ struct stream *s = zclient->ibuf;
+
+ zapi_error_decode(s, &error);
+
+ if (zclient->handle_error)
+ (*zclient->handle_error)(error);
+}
+
static void link_params_set_value(struct stream *s, struct if_link_params *iflp)
{
@@ -3153,6 +3181,8 @@ static int zclient_read(struct thread *thread)
case ZEBRA_MLAG_FORWARD_MSG:
zclient_mlag_handle_msg(command, zclient, length, vrf_id);
break;
+ case ZEBRA_ERROR:
+ zclient_handle_error(command, zclient, length, vrf_id);
default:
break;
}