+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Label Manager for FRR
*
* Volta Networks Inc.
*
* This file is part of FRRouting (FRR)
- *
- * FRR is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * FRR is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
}
/* alloc and fill a label chunk */
-struct label_manager_chunk *create_label_chunk(uint8_t proto,
- unsigned short instance,
- uint32_t session_id,
- uint8_t keep, uint32_t start,
- uint32_t end)
+struct label_manager_chunk *
+create_label_chunk(uint8_t proto, unsigned short instance, uint32_t session_id,
+ uint8_t keep, uint32_t start, uint32_t end)
{
/* alloc chunk, fill it and return it */
struct label_manager_chunk *lmc =
if (lmc->proto != NO_PROTO)
return NULL;
- if (end < lmc->end) {
+ if (end <= lmc->end) {
last_node = node;
break;
}
* @param base Desired starting label of the chunk; if MPLS_LABEL_BASE_ANY it does not apply
* @return Pointer to the assigned label chunk, or NULL if the request could not be satisfied
*/
-struct label_manager_chunk *assign_label_chunk(uint8_t proto,
- unsigned short instance,
- uint32_t session_id,
- uint8_t keep, uint32_t size,
- uint32_t base)
+struct label_manager_chunk *
+assign_label_chunk(uint8_t proto, unsigned short instance, uint32_t session_id,
+ uint8_t keep, uint32_t size, uint32_t base)
{
struct label_manager_chunk *lmc;
struct listnode *node;
- uint32_t prev_end = 0;
+ uint32_t prev_end = MPLS_LABEL_UNRESERVED_MIN;
/* handle chunks request with a specific base label */
if (base != MPLS_LABEL_BASE_ANY)
}
/* check if we hadve a "hole" behind us that we can squeeze into
*/
- if ((lmc->start > prev_end)
- && (lmc->start - prev_end >= size)) {
+ if ((lmc->start > prev_end) && (lmc->start - prev_end > size)) {
lmc = create_label_chunk(proto, instance, session_id,
keep, prev_end + 1,
prev_end + size);
*
* @param proto Daemon protocol of client, to identify the owner
* @param instance Instance, to identify the owner
+ * @param session_id Zclient session ID, to identify the zclient session
* @param start First label of the chunk
* @param end Last label of the chunk
* @return 0 on success, -1 otherwise