summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/if.c4
-rw-r--r--lib/table.h8
-rw-r--r--lib/vrf.h13
3 files changed, 19 insertions, 6 deletions
diff --git a/lib/if.c b/lib/if.c
index 2320093a15..e31ccd8563 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -652,7 +652,7 @@ DEFUN (interface,
/*Pending: need proper vrf name based lookup/(possible creation of VRF)
Imagine forward reference of a vrf by name in this interface config */
if (vrfname)
- VRF_GET_ID(vrf_id, vrfname);
+ VRF_GET_ID(vrf_id, vrfname, false);
#ifdef SUNOS_5
ifp = if_sunwzebra_get(ifname, vrf_id);
@@ -686,7 +686,7 @@ DEFUN_NOSH (no_interface,
vrf_id_t vrf_id = VRF_DEFAULT;
if (argc > 3)
- VRF_GET_ID(vrf_id, vrfname);
+ VRF_GET_ID(vrf_id, vrfname, false);
ifp = if_lookup_by_name(ifname, vrf_id);
diff --git a/lib/table.h b/lib/table.h
index 8304abe59b..ac7df3e695 100644
--- a/lib/table.h
+++ b/lib/table.h
@@ -235,13 +235,17 @@ static inline struct route_node *route_lock_node(struct route_node *node)
}
/* Unlock node. */
-static inline void route_unlock_node(struct route_node *node)
+static inline struct route_node *route_unlock_node(struct route_node *node)
{
assert(node->lock > 0);
(*(unsigned *)&node->lock)--;
- if (node->lock == 0)
+ if (node->lock == 0) {
route_node_delete(node);
+ return NULL;
+ }
+
+ return node;
}
/*
diff --git a/lib/vrf.h b/lib/vrf.h
index 8aa0fc2215..88536eada8 100644
--- a/lib/vrf.h
+++ b/lib/vrf.h
@@ -111,15 +111,24 @@ extern struct vrf *vrf_get(vrf_id_t, const char *);
extern const char *vrf_id_to_name(vrf_id_t vrf_id);
extern vrf_id_t vrf_name_to_id(const char *);
-#define VRF_GET_ID(V, NAME) \
+#define VRF_GET_ID(V, NAME, USE_JSON) \
do { \
struct vrf *vrf; \
if (!(vrf = vrf_lookup_by_name(NAME))) { \
+ if (USE_JSON) { \
+ vty_out(vty, "{}\n"); \
+ } else { \
+ vty_out(vty, "%% VRF %s not found\n", NAME); \
+ } \
vty_out(vty, "%% VRF %s not found\n", NAME); \
return CMD_WARNING; \
} \
if (vrf->vrf_id == VRF_UNKNOWN) { \
- vty_out(vty, "%% VRF %s not active\n", NAME); \
+ if (USE_JSON) { \
+ vty_out(vty, "{}\n"); \
+ } else { \
+ vty_out(vty, "%% VRF %s not active\n", NAME); \
+ } \
return CMD_WARNING; \
} \
(V) = vrf->vrf_id; \