summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2019-07-12 22:09:33 +0200
committerGitHub <noreply@github.com>2019-07-12 22:09:33 +0200
commit07a4ddf2b65d858d427b18769a20e4aa7f7682cd (patch)
tree145f464ee88c985d944e7d1b84acb798f64ca525 /lib
parentMerge pull request #4664 from sworleys/Zvrf-Debug-Guard (diff)
parenttests: remove lm-proxy-topo1 topotest (diff)
downloadfrr-07a4ddf2b65d858d427b18769a20e4aa7f7682cd.tar.xz
frr-07a4ddf2b65d858d427b18769a20e4aa7f7682cd.zip
Merge pull request #4660 from manuhalo/label_manager_fixes
Label manager improvements + refactor
Diffstat (limited to 'lib')
-rw-r--r--lib/mpls.h1
-rw-r--r--lib/zclient.c17
-rw-r--r--lib/zclient.h10
3 files changed, 20 insertions, 8 deletions
diff --git a/lib/mpls.h b/lib/mpls.h
index b140c8e31..d7b56c47b 100644
--- a/lib/mpls.h
+++ b/lib/mpls.h
@@ -54,6 +54,7 @@ extern "C" {
#define MPLS_LABEL_RESERVED_MAX 15
#define MPLS_LABEL_UNRESERVED_MIN 16
#define MPLS_LABEL_UNRESERVED_MAX 1048575
+#define MPLS_LABEL_BASE_ANY 0
/* Default min and max SRGB label range */
/* Even if the SRGB allows to manage different Label space between routers,
diff --git a/lib/zclient.c b/lib/zclient.c
index e9b4f5a58..693770019 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -1995,10 +1995,11 @@ int lm_label_manager_connect(struct zclient *zclient, int async)
* @param zclient Zclient used to connect to label manager (zebra)
* @param keep Avoid garbage collection
* @param chunk_size Amount of labels requested
+ * @param base Base for the label chunk. if MPLS_LABEL_BASE_ANY we do not care
* @result 0 on success, -1 otherwise
*/
int zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep,
- uint32_t chunk_size)
+ uint32_t chunk_size, uint32_t base)
{
struct stream *s;
@@ -2018,6 +2019,7 @@ int zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep,
stream_putw(s, zclient->instance);
stream_putc(s, keep);
stream_putl(s, chunk_size);
+ stream_putl(s, base);
/* Put length at the first point of the stream. */
stream_putw_at(s, 0, stream_get_endp(s));
@@ -2038,7 +2040,7 @@ int zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep,
* @param end To write last assigned chunk label to
* @result 0 on success, -1 otherwise
*/
-int lm_get_label_chunk(struct zclient *zclient, uint8_t keep,
+int lm_get_label_chunk(struct zclient *zclient, uint8_t keep, uint32_t base,
uint32_t chunk_size, uint32_t *start, uint32_t *end)
{
int ret;
@@ -2063,6 +2065,8 @@ int lm_get_label_chunk(struct zclient *zclient, uint8_t keep,
stream_putc(s, keep);
/* chunk size */
stream_putl(s, chunk_size);
+ /* requested chunk base */
+ stream_putl(s, base);
/* Put length at the first point of the stream. */
stream_putw_at(s, 0, stream_get_endp(s));
@@ -2103,6 +2107,15 @@ int lm_get_label_chunk(struct zclient *zclient, uint8_t keep,
"Wrong instId (%u) in get chunk response Should be %u",
instance, zclient->instance);
+ /* if we requested a specific chunk and it could not be allocated, the
+ * response message will end here
+ */
+ if (!STREAM_READABLE(s)) {
+ zlog_info("Unable to assign Label Chunk to %s instance %u",
+ zebra_route_string(proto), instance);
+ return -1;
+ }
+
/* keep */
response_keep = stream_getc(s);
/* start and end labels */
diff --git a/lib/zclient.h b/lib/zclient.h
index d65173868..be2ef69dc 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -609,15 +609,13 @@ extern struct interface *zebra_interface_link_params_read(struct stream *s,
vrf_id_t vrf_id);
extern size_t zebra_interface_link_params_write(struct stream *,
struct interface *);
-extern int zclient_send_get_label_chunk(
- struct zclient *zclient,
- uint8_t keep,
- uint32_t chunk_size);
+extern int zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep,
+ uint32_t chunk_size, uint32_t base);
extern int lm_label_manager_connect(struct zclient *zclient, int async);
extern int lm_get_label_chunk(struct zclient *zclient, uint8_t keep,
- uint32_t chunk_size, uint32_t *start,
- uint32_t *end);
+ uint32_t base, uint32_t chunk_size,
+ uint32_t *start, uint32_t *end);
extern int lm_release_label_chunk(struct zclient *zclient, uint32_t start,
uint32_t end);
extern int tm_table_manager_connect(struct zclient *zclient);