summaryrefslogtreecommitdiff
path: root/lib/vty.h
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2022-04-28 11:06:20 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2022-04-28 11:09:26 +0200
commit0cbed9511acbf4adbf9209a022b48e1fc0d0e2a3 (patch)
treeaaf3ad8885757cc3cb234333d89093bf40bd4144 /lib/vty.h
parent633a50d11c7dc14e543e849cc4ec135ca0416f17 (diff)
lib, zebra, pimd: clean up/fix VRF DECLVAR macros
There's a common pattern of "get VRF context for CLI node" here, which first got a helper macro in zebra that then permeated into pimd. Unfortunately the pimd copy wasn't quite adjusted correctly and thus caused two coverity warnings (CID 1517453, CID 1517454). Fix the PIM one, and clean up by providing a common base macro in `lib/vty.h`. Also rename the macros (add `_VRF`) to make more clear what they do. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/vty.h')
-rw-r--r--lib/vty.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/vty.h b/lib/vty.h
index e42a3b210f..430579c5a8 100644
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -266,6 +266,15 @@ static inline void vty_push_context(struct vty *vty, int node, uint64_t id)
struct structname *ptr = VTY_GET_CONTEXT(structname); \
VTY_CHECK_CONTEXT(ptr);
+#define VTY_DECLVAR_CONTEXT_VRF(vrfptr) \
+ struct vrf *vrfptr; \
+ if (vty->node == CONFIG_NODE) \
+ vrfptr = vrf_lookup_by_id(VRF_DEFAULT); \
+ else \
+ vrfptr = VTY_GET_CONTEXT(vrf); \
+ VTY_CHECK_CONTEXT(vrfptr); \
+ MACRO_REQUIRE_SEMICOLON() /* end */
+
/* XPath macros. */
#define VTY_PUSH_XPATH(nodeval, value) \
do { \