Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oper state #14492

Merged
merged 25 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8790457
lib: add simplified native msg support
choppsv1 Jul 6, 2023
80cac37
lib: yang: add tree "printing" utility functions
choppsv1 Jul 9, 2023
772f6c0
lib: step 1: mgmtd: add FE get-tree functionality
choppsv1 Oct 30, 2023
4fee273
lib: step 2: mgmtd: BE client code for get-tree functionality
choppsv1 Oct 30, 2023
33b9c2e
mgmtd: step 3: BE adapter native message handling
choppsv1 Jul 7, 2023
be2424a
mgmtd: step 4: FE adapter get-tree functionality
choppsv1 Jul 7, 2023
8df542b
mgmtd: step 5: add get-tree txn functionality
choppsv1 Jul 7, 2023
9cd8693
mgmtd: step 6: remove old unfinished get-data code
choppsv1 Oct 10, 2023
1bb6f21
tests: add debugs and count in static_simple test
choppsv1 Oct 27, 2023
f3d6edc
lib: darr: add new access and str functions
choppsv1 Oct 16, 2023
db0211d
lib: yang: add new functions
choppsv1 Oct 20, 2023
d58653a
lib: northbound: improve xpath functionality
choppsv1 Oct 10, 2023
408ee24
lib: create and use libyang tree during oper-state walk
choppsv1 Oct 14, 2023
60a8cf7
tools: add more libyang iter macros to .clang-format
choppsv1 Oct 31, 2023
356c01b
lib: yang: add yang_get_node_keys() function
choppsv1 Dec 26, 2023
b7db6b2
lib: darr: add ability to set MTYPE for dynamic arrays
choppsv1 Dec 16, 2023
ad1ccb6
lib: northbound: add yielding and batching to oper-state queries
choppsv1 Oct 30, 2023
4e0147a
lib: add dedicated API functions for native msgs
choppsv1 Dec 13, 2023
ef91d34
zebra: add zebra to mgmtd oper-state
choppsv1 Oct 3, 2023
d266b1c
zebra: support yielding between oper state routes query
choppsv1 Oct 20, 2023
c521d45
zebra: fix oper-state walk bug
choppsv1 Oct 22, 2023
d0f71a9
zebra: fix cleanup of mgmt backend state
choppsv1 Nov 1, 2023
b8b5290
lib: fixes required after rebasing
choppsv1 Dec 9, 2023
2bb115f
tests: client testing
choppsv1 Nov 28, 2023
f725838
tests: add mgmt_oper topotest
choppsv1 Oct 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ ForEachMacros:
# libyang outliers:
- 'LY_FOR_KEYS'
- 'LY_LIST_FOR'
- 'LYD_LIST_FOR_INST'
- 'LYD_LIST_FOR_INST_SAFE'
- 'LY_TREE_FOR'
- 'LY_TREE_DFS_BEGIN'
- 'LYD_TREE_DFS_BEGIN'
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ else
fi
AC_C_FLAG([-Wno-unused-parameter])
AC_C_FLAG([-Wno-missing-field-initializers])
AC_C_FLAG([-Wno-microsoft-anon-tag])

AC_C_FLAG([-Wc++-compat], [], [CXX_COMPAT_CFLAGS="-Wc++-compat"])
AC_SUBST([CXX_COMPAT_CFLAGS])
Expand Down
49 changes: 48 additions & 1 deletion gdb/lib.txt
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,59 @@ define mq_walk
end
set $mg = $mg->next
end
end

document mg_walk
document mq_walk
Walk the memory data structures to show what is holding memory.

Arguments:
1st: A (struct memgroup *) where to start the walk. If you are not
sure where to start pass it mg_first, which is a global DS for
all memory allocated in FRR
end

define __darr_meta
set $_ = ((struct darr_metadata *)$arg0) - 1
end
document __darr_meta
Store a pointer to the struct darr_metadata in $_ for the given dynamic array.

Argument: a pointer to a darr dynamic array.
Returns: pointer to the struct darr_metadata in $_.
end

define darr_meta
__darr_meta $arg0
p *$_
end
document darr_meta
Print the struct darr_metadata for the given dynamic array. Store the value
in $_ as well.

Argument: a pointer to a darr dynamic array.
Returns: pointer to the struct darr_metadata in $_.
end

define darr_len
__darr_meta $arg0
set $_ = $_->len
p $_
end
document darr_len
Print the length of the given dynamic array, and store in $_.

Argument: a pointer to a darr dynamic array.
Returns: length of the array.
end

define darr_cap
__darr_meta $arg0
set $_ = $_->cap
p $_
end
document darr_len
Print the capacity of the given dynamic array, and store in $_.

Argument: a pointer to a darr dynamic array.
Returns: capacity of the array.
end
62 changes: 53 additions & 9 deletions lib/darr.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "memory.h"

DEFINE_MTYPE(LIB, DARR, "Dynamic Array");
DEFINE_MTYPE(LIB, DARR_STR, "Dynamic Array String");

static uint _msb(uint count)
{
Expand Down Expand Up @@ -52,29 +53,72 @@ static size_t darr_size(uint count, size_t esize)
return count * esize + sizeof(struct darr_metadata);
}

void *__darr_resize(void *a, uint count, size_t esize)
char *__darr_in_vsprintf(char **sp, bool concat, const char *fmt, va_list ap)
{
size_t inlen = concat ? darr_strlen(*sp) : 0;
size_t capcount = strlen(fmt) + MIN(inlen + 64, 128);
ssize_t len;

darr_ensure_cap(*sp, capcount);

if (!concat)
darr_reset(*sp);

/* code below counts on having a NUL terminated string */
if (darr_len(*sp) == 0)
*darr_append(*sp) = 0;
again:
len = vsnprintf(darr_last(*sp), darr_avail(*sp), fmt, ap);
if (len < 0)
darr_in_strcat(*sp, fmt);
else if ((size_t)len < darr_avail(*sp))
_darr_len(*sp) += len;
else {
darr_ensure_cap(*sp, darr_len(*sp) + (size_t)len);
goto again;
}
return *sp;
}

char *__darr_in_sprintf(char **sp, bool concat, const char *fmt, ...)
{
va_list ap;

va_start(ap, fmt);
(void)__darr_in_vsprintf(sp, concat, fmt, ap);
va_end(ap);
return *sp;
}


void *__darr_resize(void *a, uint count, size_t esize, struct memtype *mtype)
{
uint ncount = darr_next_count(count, esize);
size_t osz = (a == NULL) ? 0 : darr_size(darr_cap(a), esize);
size_t sz = darr_size(ncount, esize);
struct darr_metadata *dm = XREALLOC(MTYPE_DARR,
a ? _darr_meta(a) : NULL, sz);
struct darr_metadata *dm;

if (sz > osz)
memset((char *)dm + osz, 0, sz - osz);
if (a) {
dm = XREALLOC(_darr_meta(a)->mtype, _darr_meta(a), sz);
if (sz > osz)
memset((char *)dm + osz, 0, sz - osz);
} else {
dm = XCALLOC(mtype, sz);
dm->mtype = mtype;
}
dm->cap = ncount;
return (void *)(dm + 1);
}


void *__darr_insert_n(void *a, uint at, uint count, size_t esize, bool zero)
void *__darr_insert_n(void *a, uint at, uint count, size_t esize, bool zero,
struct memtype *mtype)
{

struct darr_metadata *dm;
uint olen, nlen;

if (!a)
a = __darr_resize(NULL, at + count, esize);
a = __darr_resize(NULL, at + count, esize, mtype);
dm = (struct darr_metadata *)a - 1;
olen = dm->len;

Expand All @@ -89,7 +133,7 @@ void *__darr_insert_n(void *a, uint at, uint count, size_t esize, bool zero)
nlen = olen + count;

if (nlen > dm->cap) {
a = __darr_resize(a, nlen, esize);
a = __darr_resize(a, nlen, esize, mtype);
dm = (struct darr_metadata *)a - 1;
}

Expand Down
Loading
Loading