summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/if.c16
-rw-r--r--lib/if.h37
-rw-r--r--lib/vrf.c7
-rw-r--r--lib/vrf.h2
-rw-r--r--lib/zclient.c15
5 files changed, 32 insertions, 45 deletions
diff --git a/lib/if.c b/lib/if.c
index c000c3165c..fe1d3ebb4a 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -167,7 +167,6 @@ static struct interface *if_new(struct vrf *vrf)
ifp->name[0] = '\0';
ifp->vrf = vrf;
- ifp->vrf_id = vrf->vrf_id;
ifp->connected = list_new();
ifp->connected->del = ifp_connected_free;
@@ -238,8 +237,7 @@ void if_update_to_new_vrf(struct interface *ifp, vrf_id_t vrf_id)
if (ifp->ifindex != IFINDEX_INTERNAL)
IFINDEX_RB_REMOVE(old_vrf, ifp);
- ifp->vrf_id = vrf_id;
- vrf = vrf_get(ifp->vrf_id, NULL);
+ vrf = vrf_get(vrf_id, NULL);
ifp->vrf = vrf;
if (ifp->name[0] != '\0')
@@ -604,7 +602,7 @@ struct interface *if_get_by_name(const char *name, vrf_id_t vrf_id,
/* If it came from the kernel or by way of zclient,
* believe it and update the ifp accordingly.
*/
- if (ifp->vrf_id != vrf_id && vrf_id != VRF_UNKNOWN)
+ if (ifp->vrf->vrf_id != vrf_id && vrf_id != VRF_UNKNOWN)
if_update_to_new_vrf(ifp, vrf_id);
return ifp;
@@ -617,7 +615,7 @@ struct interface *if_get_by_name(const char *name, vrf_id_t vrf_id,
/* If it came from the kernel or by way of zclient,
* believe it and update the ifp accordingly.
*/
- if (ifp->vrf_id != vrf_id && vrf_id != VRF_UNKNOWN)
+ if (ifp->vrf->vrf_id != vrf_id && vrf_id != VRF_UNKNOWN)
if_update_to_new_vrf(ifp, vrf_id);
return ifp;
@@ -643,7 +641,7 @@ int if_set_index(struct interface *ifp, ifindex_t ifindex)
* If there is already an interface with this ifindex, we will collide
* on insertion, so don't even try.
*/
- if (if_lookup_by_ifindex(ifindex, ifp->vrf_id))
+ if (if_lookup_by_ifindex(ifindex, ifp->vrf->vrf_id))
return -1;
if (ifp->ifindex != IFINDEX_INTERNAL)
@@ -807,8 +805,8 @@ static void if_dump(const struct interface *ifp)
for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, c))
zlog_info(
"Interface %s vrf %s(%u) index %d metric %d mtu %d mtu6 %d %s",
- ifp->name, ifp->vrf->name, ifp->vrf_id, ifp->ifindex,
- ifp->metric, ifp->mtu, ifp->mtu6,
+ ifp->name, ifp->vrf->name, ifp->vrf->vrf_id,
+ ifp->ifindex, ifp->metric, ifp->mtu, ifp->mtu6,
if_flag_dump(ifp->flags));
}
@@ -885,7 +883,7 @@ connected_log(struct connected *connected, char *str)
p = connected->address;
snprintf(logbuf, sizeof(logbuf), "%s interface %s vrf %s(%u) %s %pFX ",
- str, ifp->name, ifp->vrf->name, ifp->vrf_id,
+ str, ifp->name, ifp->vrf->name, ifp->vrf->vrf_id,
prefix_family_str(p), p);
p = connected->destination;
diff --git a/lib/if.h b/lib/if.h
index f52e7cb200..c8f4d9ab9d 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -295,7 +295,6 @@ struct interface {
struct route_node *node;
struct vrf *vrf;
- vrf_id_t vrf_id;
/*
* Has the end users entered `interface XXXX` from the cli in some
@@ -312,56 +311,56 @@ RB_HEAD(if_index_head, interface);
RB_PROTOTYPE(if_index_head, interface, index_entry, if_cmp_index_func)
DECLARE_QOBJ_TYPE(interface);
-#define IFNAME_RB_INSERT(vrf, ifp) \
+#define IFNAME_RB_INSERT(v, ifp) \
({ \
struct interface *_iz = \
- RB_INSERT(if_name_head, &vrf->ifaces_by_name, (ifp)); \
+ RB_INSERT(if_name_head, &v->ifaces_by_name, (ifp)); \
if (_iz) \
flog_err( \
EC_LIB_INTERFACE, \
"%s(%s): corruption detected -- interface with this " \
- "name exists already in VRF %u!", \
- __func__, (ifp)->name, (ifp)->vrf_id); \
+ "name exists already in VRF %s!", \
+ __func__, (ifp)->name, (ifp)->vrf->name); \
_iz; \
})
-#define IFNAME_RB_REMOVE(vrf, ifp) \
+#define IFNAME_RB_REMOVE(v, ifp) \
({ \
struct interface *_iz = \
- RB_REMOVE(if_name_head, &vrf->ifaces_by_name, (ifp)); \
+ RB_REMOVE(if_name_head, &v->ifaces_by_name, (ifp)); \
if (_iz == NULL) \
flog_err( \
EC_LIB_INTERFACE, \
"%s(%s): corruption detected -- interface with this " \
- "name doesn't exist in VRF %u!", \
- __func__, (ifp)->name, (ifp)->vrf_id); \
+ "name doesn't exist in VRF %s!", \
+ __func__, (ifp)->name, (ifp)->vrf->name); \
_iz; \
})
-#define IFINDEX_RB_INSERT(vrf, ifp) \
+#define IFINDEX_RB_INSERT(v, ifp) \
({ \
- struct interface *_iz = RB_INSERT( \
- if_index_head, &vrf->ifaces_by_index, (ifp)); \
+ struct interface *_iz = \
+ RB_INSERT(if_index_head, &v->ifaces_by_index, (ifp)); \
if (_iz) \
flog_err( \
EC_LIB_INTERFACE, \
"%s(%u): corruption detected -- interface with this " \
- "ifindex exists already in VRF %u!", \
- __func__, (ifp)->ifindex, (ifp)->vrf_id); \
+ "ifindex exists already in VRF %s!", \
+ __func__, (ifp)->ifindex, (ifp)->vrf->name); \
_iz; \
})
-#define IFINDEX_RB_REMOVE(vrf, ifp) \
+#define IFINDEX_RB_REMOVE(v, ifp) \
({ \
- struct interface *_iz = RB_REMOVE( \
- if_index_head, &vrf->ifaces_by_index, (ifp)); \
+ struct interface *_iz = \
+ RB_REMOVE(if_index_head, &v->ifaces_by_index, (ifp)); \
if (_iz == NULL) \
flog_err( \
EC_LIB_INTERFACE, \
"%s(%u): corruption detected -- interface with this " \
- "ifindex doesn't exist in VRF %u!", \
- __func__, (ifp)->ifindex, (ifp)->vrf_id); \
+ "ifindex doesn't exist in VRF %s!", \
+ __func__, (ifp)->ifindex, (ifp)->vrf->name); \
_iz; \
})
diff --git a/lib/vrf.c b/lib/vrf.c
index a9a5a83794..5dc4e05855 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -354,13 +354,6 @@ const char *vrf_id_to_name(vrf_id_t vrf_id)
return VRF_LOGNAME(vrf);
}
-/* Get the data pointer of the specified VRF. If not found, create one. */
-void *vrf_info_get(vrf_id_t vrf_id)
-{
- struct vrf *vrf = vrf_get(vrf_id, NULL);
- return vrf->info;
-}
-
/* Look up the data pointer of the specified VRF. */
void *vrf_info_lookup(vrf_id_t vrf_id)
{
diff --git a/lib/vrf.h b/lib/vrf.h
index 0e2e601a7e..73e324c152 100644
--- a/lib/vrf.h
+++ b/lib/vrf.h
@@ -176,8 +176,6 @@ static inline uint32_t vrf_interface_count(struct vrf *vrf)
* Utilities to obtain the user data
*/
-/* Get the data pointer of the specified VRF. If not found, create one. */
-extern void *vrf_info_get(vrf_id_t);
/* Look up the data pointer of the specified VRF. */
extern void *vrf_info_lookup(vrf_id_t);
diff --git a/lib/zclient.c b/lib/zclient.c
index a6103cfee9..000dcaac8f 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -4072,11 +4072,12 @@ enum zclient_send_status zclient_interface_set_master(struct zclient *client,
s = client->obuf;
stream_reset(s);
- zclient_create_header(s, ZEBRA_INTERFACE_SET_MASTER, master->vrf_id);
+ zclient_create_header(s, ZEBRA_INTERFACE_SET_MASTER,
+ master->vrf->vrf_id);
- stream_putl(s, master->vrf_id);
+ stream_putl(s, master->vrf->vrf_id);
stream_putl(s, master->ifindex);
- stream_putl(s, slave->vrf_id);
+ stream_putl(s, slave->vrf->vrf_id);
stream_putl(s, slave->ifindex);
stream_putw_at(s, 0, stream_get_endp(s));
@@ -4163,7 +4164,7 @@ zclient_send_neigh_discovery_req(struct zclient *zclient,
s = zclient->obuf;
stream_reset(s);
- zclient_create_header(s, ZEBRA_NEIGH_DISCOVER, ifp->vrf_id);
+ zclient_create_header(s, ZEBRA_NEIGH_DISCOVER, ifp->vrf->vrf_id);
stream_putl(s, ifp->ifindex);
stream_putc(s, p->family);
@@ -4253,7 +4254,7 @@ int zclient_neigh_ip_encode(struct stream *s, uint16_t cmd, union sockunion *in,
{
int ret = 0;
- zclient_create_header(s, cmd, ifp->vrf_id);
+ zclient_create_header(s, cmd, ifp->vrf->vrf_id);
stream_putc(s, sockunion_family(in));
stream_write(s, sockunion_get_addr(in), sockunion_get_addrlen(in));
if (out && sockunion_family(out) != AF_UNSPEC) {
@@ -4297,9 +4298,7 @@ int zclient_send_zebra_gre_request(struct zclient *client,
}
s = client->obuf;
stream_reset(s);
- zclient_create_header(s,
- ZEBRA_GRE_GET,
- ifp->vrf_id);
+ zclient_create_header(s, ZEBRA_GRE_GET, ifp->vrf->vrf_id);
stream_putl(s, ifp->ifindex);
stream_putw_at(s, 0, stream_get_endp(s));
zclient_send_message(client);