summaryrefslogtreecommitdiffstats
path: root/lib/if.h
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2019-02-11 17:42:50 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2019-06-12 14:10:28 +0200
commita41c4e1b1f577443ad26222704a69649c280cd9e (patch)
tree2d01484bb959675b20c1596be1c1f4e28ddaf403 /lib/if.h
parentlib, bgpd, ospfd, pimd, zebra, rip, ripng, bfd: change if_update_to_new_vrf()... (diff)
downloadfrr-a41c4e1b1f577443ad26222704a69649c280cd9e.tar.xz
frr-a41c4e1b1f577443ad26222704a69649c280cd9e.zip
*: change interface structure, from vrf_id to vrf
Field vrf_id is replaced by the pointer of the struct vrf *. For that all other code referencing to (interface)->vrf_id is replaced. This work should not change the behaviour. It is just a continuation work toward having an interface API handling vrf pointer only. some new generic functions are created in vrf: vrf_to_id, vrf_to_name, a zebra function is also created: zvrf_info_lookup an ospf function is also created: ospf_lookup_by_vrf it is to be noted that now that interface has a vrf pointer, some more optimisations could be thought through all the rest of the code. as example, many structure store the vrf_id. those structures could get the exact vrf structure if inherited from an interface vrf context. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'lib/if.h')
-rw-r--r--lib/if.h30
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/if.h b/lib/if.h
index 8bbbd1082..93c651e39 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -294,7 +294,7 @@ struct interface {
#endif /* HAVE_NET_RT_IFLIST */
struct route_node *node;
- vrf_id_t vrf_id;
+ struct vrf *vrf;
QOBJ_FIELDS
};
@@ -305,33 +305,37 @@ RB_HEAD(if_index_head, interface);
RB_PROTOTYPE(if_index_head, interface, index_entry, if_cmp_func)
DECLARE_QOBJ_TYPE(interface)
-#define IFNAME_RB_INSERT(vrf, ifp) \
- if (RB_INSERT(if_name_head, &vrf->ifaces_by_name, (ifp))) \
+#define IFNAME_RB_INSERT(_vrf, _ifp) \
+ if (RB_INSERT(if_name_head, &(_vrf)->ifaces_by_name, (_ifp))) \
flog_err(EC_LIB_INTERFACE, \
"%s(%s): corruption detected -- interface with this " \
"name exists already in VRF %u!", \
- __func__, (ifp)->name, (ifp)->vrf_id);
+ __func__, (_ifp)->name, (_ifp)->vrf ? \
+ (_ifp)->vrf->vrf_id : VRF_UNKNOWN);
-#define IFNAME_RB_REMOVE(vrf, ifp) \
- if (RB_REMOVE(if_name_head, &vrf->ifaces_by_name, (ifp)) == NULL) \
+#define IFNAME_RB_REMOVE(_vrf, _ifp) \
+ if (RB_REMOVE(if_name_head, &(_vrf)->ifaces_by_name, (_ifp)) == 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);
+ __func__, (_ifp)->name, (_ifp)->vrf ? \
+ (_ifp)->vrf->vrf_id : VRF_UNKNOWN);
-#define IFINDEX_RB_INSERT(vrf, ifp) \
- if (RB_INSERT(if_index_head, &vrf->ifaces_by_index, (ifp))) \
+#define IFINDEX_RB_INSERT(_vrf, _ifp) \
+ if (RB_INSERT(if_index_head, &(_vrf)->ifaces_by_index, (_ifp))) \
flog_err(EC_LIB_INTERFACE, \
"%s(%u): corruption detected -- interface with this " \
"ifindex exists already in VRF %u!", \
- __func__, (ifp)->ifindex, (ifp)->vrf_id);
+ __func__, (_ifp)->ifindex, (_ifp)->vrf ? \
+ (_ifp)->vrf->vrf_id : VRF_UNKNOWN);
-#define IFINDEX_RB_REMOVE(vrf, ifp) \
- if (RB_REMOVE(if_index_head, &vrf->ifaces_by_index, (ifp)) == NULL) \
+#define IFINDEX_RB_REMOVE(_vrf, _ifp) \
+ if (RB_REMOVE(if_index_head, &(_vrf)->ifaces_by_index, (_ifp)) == 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);
+ __func__, (_ifp)->ifindex, (_ifp)->vrf ? \
+ (_ifp)->vrf->vrf_id : VRF_UNKNOWN);
#define FOR_ALL_INTERFACES(vrf, ifp) \
if (vrf) \