void
babel_interface_close_all(void)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp = NULL;
- struct listnode *linklist_node = NULL;
- FOR_ALL_INTERFACES(ifp, linklist_node) {
+ FOR_ALL_INTERFACES(vrf, ifp) {
if(!if_up(ifp))
continue;
send_wildcard_retraction(ifp);
usleep(roughly(1000));
gettime(&babel_now);
}
- FOR_ALL_INTERFACES(ifp, linklist_node) {
+ FOR_ALL_INTERFACES(vrf, ifp) {
if(!if_up(ifp))
continue;
/* Make sure they got it. */
"Interface information\n"
"Interface\n")
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- struct listnode *node;
if (argc == 3)
{
- for (ALL_LIST_ELEMENTS_RO (vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
show_babel_interface_sub (vty, ifp);
return CMD_SUCCESS;
}
static int
interface_config_write (struct vty *vty)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
int write = 0;
- for (ALL_LIST_ELEMENTS_RO (vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
vty_frame (vty, "interface %s\n",ifp->name);
if (ifp->desc)
vty_out (vty, " description %s\n",ifp->desc);
}
/* types:
- struct interface _ifp, struct listnode node */
-#define FOR_ALL_INTERFACES(_ifp, _node) \
- for(ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), _node, _ifp))
+ struct vrf _vrf, struct interface _ifp */
+#define FOR_ALL_INTERFACES(_vrf, _ifp) \
+ RB_FOREACH(_ifp, if_name_head, &_vrf->ifaces_by_name)
/* types:
struct interface *ifp, struct connected *_connected, struct listnode *node */
babel_read_protocol (struct thread *thread)
{
int rc;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp = NULL;
struct sockaddr_in6 sin6;
- struct listnode *linklist_node = NULL;
assert(babel_routing_process != NULL);
assert(protocol_socket >= 0);
zlog_err("recv: %s", safe_strerror(errno));
}
} else {
- FOR_ALL_INTERFACES(ifp, linklist_node) {
+ FOR_ALL_INTERFACES(vrf, ifp) {
if(!if_up(ifp))
continue;
if(ifp->ifindex == (ifindex_t)sin6.sin6_scope_id) {
static void
babel_get_myid(void)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp = NULL;
- struct listnode *linklist_node = NULL;
int rc;
int i;
return;
}
- FOR_ALL_INTERFACES(ifp, linklist_node) {
+ FOR_ALL_INTERFACES(vrf, ifp) {
/* ifp->ifindex is not necessarily valid at this point */
int ifindex = if_nametoindex(ifp->name);
if(ifindex > 0) {
static void
babel_initial_noise(void)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp = NULL;
- struct listnode *linklist_node = NULL;
- FOR_ALL_INTERFACES(ifp, linklist_node) {
+ FOR_ALL_INTERFACES(vrf, ifp) {
if(!if_up(ifp))
continue;
/* Apply jitter before we send the first message. */
send_wildcard_retraction(ifp);
}
- FOR_ALL_INTERFACES(ifp, linklist_node) {
+ FOR_ALL_INTERFACES(vrf, ifp) {
if(!if_up(ifp))
continue;
usleep(roughly(10000));
babel_main_loop(struct thread *thread)
{
struct timeval tv;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp = NULL;
- struct listnode *linklist_node = NULL;
while(1) {
gettime(&babel_now);
source_expiry_time = babel_now.tv_sec + roughly(300);
}
- FOR_ALL_INTERFACES(ifp, linklist_node) {
+ FOR_ALL_INTERFACES(vrf, ifp) {
babel_interface_nfo *babel_ifp = NULL;
if(!if_up(ifp))
continue;
flush_unicast(1);
}
- FOR_ALL_INTERFACES(ifp, linklist_node) {
+ FOR_ALL_INTERFACES(vrf, ifp) {
babel_interface_nfo *babel_ifp = NULL;
if(!if_up(ifp))
continue;
#define printIfMin(a,b,c,d) \
if (UNLIKELY(debug & BABEL_DEBUG_TIMEOUT)) {printIfMin(a,b,c,d);}
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp = NULL;
- struct listnode *linklist_node = NULL;
*tv = check_neighbours_timeout;
printIfMin(tv, 0, "check_neighbours_timeout", NULL);
printIfMin(tv, 1, "source_expiry_time", NULL);
timeval_min(tv, &resend_time);
printIfMin(tv, 1, "resend_time", NULL);
- FOR_ALL_INTERFACES(ifp, linklist_node) {
+ FOR_ALL_INTERFACES(vrf, ifp) {
babel_interface_nfo *babel_ifp = NULL;
if(!if_up(ifp))
continue;
static void
babel_distribute_update_all (struct prefix_list *notused)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- struct listnode *node;
- for (ALL_LIST_ELEMENTS_RO (vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
babel_distribute_update_interface (ifp);
}
int i;
if(ifp == NULL) {
- struct interface *ifp_aux;
- struct listnode *linklist_node = NULL;
- FOR_ALL_INTERFACES(ifp_aux, linklist_node)
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ struct interface *ifp_aux;
+ FOR_ALL_INTERFACES(vrf, ifp_aux)
flushupdates(ifp_aux);
return;
}
babel_interface_nfo *babel_ifp = NULL;
if(ifp == NULL) {
- struct interface *ifp_aux;
- struct listnode *linklist_node = NULL;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ struct interface *ifp_aux;
struct babel_route *route;
- FOR_ALL_INTERFACES(ifp_aux, linklist_node)
+ FOR_ALL_INTERFACES(vrf, ifp_aux)
send_update(ifp_aux, urgent, prefix, plen);
if(prefix) {
/* Since flushupdates only deals with non-wildcard interfaces, we
{
babel_interface_nfo *babel_ifp = NULL;
if(ifp == NULL) {
- struct interface *ifp_aux;
- struct listnode *linklist_node = NULL;
- FOR_ALL_INTERFACES(ifp_aux, linklist_node)
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ struct interface *ifp_aux;
+ FOR_ALL_INTERFACES(vrf, ifp_aux)
send_wildcard_retraction(ifp_aux);
return;
}
{
struct xroute_stream *xroutes;
if(ifp == NULL) {
- struct interface *ifp_aux;
- struct listnode *linklist_node = NULL;
- FOR_ALL_INTERFACES(ifp_aux, linklist_node) {
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ struct interface *ifp_aux;
+ FOR_ALL_INTERFACES(vrf, ifp_aux) {
if(!if_up(ifp_aux))
continue;
send_self_update(ifp_aux);
int msglen;
if(neigh == NULL && ifp == NULL) {
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp_aux;
- struct listnode *linklist_node = NULL;
- FOR_ALL_INTERFACES(ifp_aux, linklist_node) {
+ FOR_ALL_INTERFACES(vrf, ifp_aux) {
if(if_up(ifp_aux))
continue;
send_ihu(NULL, ifp_aux);
int v4, pb, len;
if(ifp == NULL) {
- struct interface *ifp_aux;
- struct listnode *linklist_node = NULL;
- FOR_ALL_INTERFACES(ifp_aux, linklist_node) {
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ struct interface *ifp_aux;
+ FOR_ALL_INTERFACES(vrf, ifp_aux) {
if(if_up(ifp_aux))
continue;
send_request(ifp_aux, prefix, plen);
flushupdates(ifp);
if(ifp == NULL) {
- struct interface *ifp_aux;
- struct listnode *linklist_node = NULL;
- FOR_ALL_INTERFACES(ifp_aux, linklist_node) {
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ struct interface *ifp_aux;
+ FOR_ALL_INTERFACES(vrf, ifp_aux) {
if(!if_up(ifp_aux))
continue;
send_multihop_request(ifp_aux, prefix, plen, seqno, id, hop_count);
struct interface *if_lookup_by_ipv4(struct in_addr *addr, vrf_id_t vrf_id)
{
- struct listnode *ifnode;
+ struct vrf *vrf;
struct listnode *cnode;
struct interface *ifp;
struct connected *connected;
struct prefix_ipv4 p;
struct prefix *cp;
+ vrf = vrf_lookup_by_id(vrf_id);
+ if (!vrf)
+ return NULL;
+
p.family = AF_INET;
p.prefix = *addr;
p.prefixlen = IPV4_MAX_BITLEN;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), ifnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
cp = connected->address;
struct interface *if_lookup_by_ipv4_exact(struct in_addr *addr, vrf_id_t vrf_id)
{
- struct listnode *ifnode;
+ struct vrf *vrf;
struct listnode *cnode;
struct interface *ifp;
struct connected *connected;
struct prefix *cp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), ifnode, ifp)) {
+ vrf = vrf_lookup_by_id(vrf_id);
+ if (!vrf)
+ return NULL;
+
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
cp = connected->address;
struct interface *if_lookup_by_ipv6(struct in6_addr *addr, ifindex_t ifindex,
vrf_id_t vrf_id)
{
- struct listnode *ifnode;
+ struct vrf *vrf;
struct listnode *cnode;
struct interface *ifp;
struct connected *connected;
struct prefix_ipv6 p;
struct prefix *cp;
+ vrf = vrf_lookup_by_id(vrf_id);
+ if (!vrf)
+ return NULL;
+
p.family = AF_INET6;
p.prefix = *addr;
p.prefixlen = IPV6_MAX_BITLEN;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), ifnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
cp = connected->address;
struct interface *if_lookup_by_ipv6_exact(struct in6_addr *addr,
ifindex_t ifindex, vrf_id_t vrf_id)
{
- struct listnode *ifnode;
+ struct vrf *vrf;
struct listnode *cnode;
struct interface *ifp;
struct connected *connected;
struct prefix *cp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), ifnode, ifp)) {
+ vrf = vrf_lookup_by_id(vrf_id);
+ if (!vrf)
+ return NULL;
+
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
cp = connected->address;
*/
static void bgp_if_finish(struct bgp *bgp)
{
- struct listnode *ifnode, *ifnnode;
+ struct vrf *vrf = vrf_lookup_by_id(bgp->vrf_id);
struct interface *ifp;
- if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
+ if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW || !vrf)
return;
- for (ALL_LIST_ELEMENTS(vrf_iflist(bgp->vrf_id), ifnode, ifnnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
struct listnode *c_node, *c_nnode;
struct connected *c;
*/
void eigrp_distribute_update_all(struct prefix_list *notused)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- struct listnode *node, *nnode;
- for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
eigrp_distribute_update_interface(ifp);
}
int eigrp_network_set(struct eigrp *eigrp, struct prefix *p)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct route_node *rn;
struct interface *ifp;
- struct listnode *node;
rn = route_node_get(eigrp->networks, (struct prefix *)p);
if (rn->info) {
eigrp_router_id_update(eigrp);
/* Run network config now. */
/* Get target interface. */
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
zlog_debug("Setting up %s", ifp->name);
eigrp_network_run_interface(eigrp, p, ifp);
}
static int eigrp_write_interface(struct vty *vty)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
struct eigrp_interface *ei;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
ei = ifp->info;
if (!ei)
continue;
*/
void eigrp_router_id_update(struct eigrp *eigrp)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- struct listnode *node;
u_int32_t router_id, router_id_old;
router_id_old = eigrp->router_id;
// inet_ntoa(eigrp->router_id));
/* update eigrp_interface's */
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
eigrp_if_update(ifp);
}
}
int isis_interface_config_write(struct vty *vty)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
int write = 0;
- struct listnode *node, *node2;
+ struct listnode *node;
struct interface *ifp;
struct isis_area *area;
struct isis_circuit *circuit;
int i;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
if (ifp->ifindex == IFINDEX_DELETED)
continue;
write++;
}
/* ISIS Circuit */
- for (ALL_LIST_ELEMENTS_RO(isis->area_list, node2, area)) {
+ for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
circuit =
circuit_lookup_by_ifp(ifp, area->circuit_list);
if (circuit == NULL)
"Interface information\n"
"Interface name\n")
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
int idx_interface = 4;
struct interface *ifp;
- struct listnode *node;
/* Show All Interfaces. */
if (argc == 4) {
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
show_mpls_te_sub(vty, ifp);
}
/* Interface name is specified. */
void
kif_redistribute(const char *ifname)
{
- struct listnode *node, *cnode;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ struct listnode *cnode;
struct interface *ifp;
struct connected *ifc;
struct kif kif;
struct kaddr ka;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
if (ifname && strcmp(ifname, ifp->name) != 0)
continue;
DEFINE_MTYPE(LIB, CONNECTED_LABEL, "Connected interface label")
DEFINE_MTYPE_STATIC(LIB, IF_LINK_PARAMS, "Informational Link Parameters")
+static int if_cmp_func(const struct interface *, const struct interface *);
+RB_GENERATE(if_name_head, interface, name_entry, if_cmp_func);
+
DEFINE_QOBJ_TYPE(interface)
DEFINE_HOOK(if_add, (struct interface *ifp), (ifp))
return 0;
}
-static int if_cmp_func(struct interface *ifp1, struct interface *ifp2)
+static int if_cmp_func(const struct interface *ifp1,
+ const struct interface *ifp2)
{
- return if_cmp_name_func(ifp1->name, ifp2->name);
+ return if_cmp_name_func((char *)ifp1->name, (char *)ifp2->name);
}
/* Create new interface structure. */
struct interface *if_create(const char *name, vrf_id_t vrf_id)
{
+ struct vrf *vrf = vrf_get(vrf_id, NULL);
struct interface *ifp;
- struct list *intf_list = vrf_iflist_get(vrf_id);
ifp = XCALLOC(MTYPE_IF, sizeof(struct interface));
ifp->ifindex = IFINDEX_INTERNAL;
assert(name);
strlcpy(ifp->name, name, sizeof(ifp->name));
ifp->vrf_id = vrf_id;
- if (if_lookup_by_name(ifp->name, vrf_id) == NULL)
- listnode_add_sort(intf_list, ifp);
- else
+ if (RB_INSERT(if_name_head, &vrf->ifaces_by_name, ifp))
zlog_err(
"if_create(%s): corruption detected -- interface with this "
"name exists already in VRF %u!",
/* Create new interface structure. */
void if_update_to_new_vrf(struct interface *ifp, vrf_id_t vrf_id)
{
- struct list *intf_list = vrf_iflist_get(vrf_id);
+ struct vrf *vrf;
/* remove interface from old master vrf list */
- if (vrf_iflist(ifp->vrf_id))
- listnode_delete(vrf_iflist(ifp->vrf_id), ifp);
+ vrf = vrf_lookup_by_id(ifp->vrf_id);
+ if (vrf)
+ RB_REMOVE(if_name_head, &vrf->ifaces_by_name, ifp);
ifp->vrf_id = vrf_id;
- if (if_lookup_by_name(ifp->name, vrf_id) == NULL)
- listnode_add_sort(intf_list, ifp);
- else
+ vrf = vrf_get(ifp->vrf_id, NULL);
+ if (RB_INSERT(if_name_head, &vrf->ifaces_by_name, ifp))
zlog_err(
"%s(%s): corruption detected -- interface with this "
- "name exists already in VRF %u!", __func__,
- ifp->name, vrf_id);
-
- return;
+ "name exists already in VRF %u!",
+ __func__, ifp->name, vrf_id);
}
/* Delete and free interface structure. */
void if_delete(struct interface *ifp)
{
- listnode_delete(vrf_iflist(ifp->vrf_id), ifp);
+ struct vrf *vrf = vrf_lookup_by_id(ifp->vrf_id);
+
+ RB_REMOVE(if_name_head, &vrf->ifaces_by_name, ifp);
if_delete_retain(ifp);
/* Interface existance check by index. */
struct interface *if_lookup_by_index(ifindex_t ifindex, vrf_id_t vrf_id)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(vrf_id);
struct interface *ifp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
if (ifp->ifindex == ifindex)
return ifp;
- }
+
return NULL;
}
/* Interface existance check by interface name. */
struct interface *if_lookup_by_name(const char *name, vrf_id_t vrf_id)
{
- struct listnode *node;
- struct interface *ifp;
+ struct vrf *vrf = vrf_lookup_by_id(vrf_id);
+ struct interface if_tmp;
if (!name || strnlen(name, INTERFACE_NAMSIZ) == INTERFACE_NAMSIZ)
return NULL;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), node, ifp)) {
- if (strcmp(name, ifp->name) == 0)
- return ifp;
- }
-
- return NULL;
+ strlcpy(if_tmp.name, name, sizeof(if_tmp.name));
+ return RB_FIND(if_name_head, &vrf->ifaces_by_name, &if_tmp);
}
struct interface *if_lookup_by_name_all_vrf(const char *name)
struct interface *if_lookup_exact_address(void *src, int family,
vrf_id_t vrf_id)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(vrf_id);
struct listnode *cnode;
struct interface *ifp;
struct prefix *p;
struct connected *c;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) {
p = c->address;
struct connected *if_lookup_address(void *matchaddr, int family,
vrf_id_t vrf_id)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(vrf_id);
struct prefix addr;
int bestlen = 0;
struct listnode *cnode;
match = NULL;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) {
if (c->address && (c->address->family == AF_INET)
&& prefix_match(CONNECTED_PREFIX(c), &addr)
/* Lookup interface by prefix */
struct interface *if_lookup_prefix(struct prefix *prefix, vrf_id_t vrf_id)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(vrf_id);
struct listnode *cnode;
struct interface *ifp;
struct connected *c;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) {
if (prefix_cmp(c->address, prefix) == 0) {
return ifp;
void if_dump_all(void)
{
struct vrf *vrf;
- struct listnode *node;
- void *p;
+ void *ifp;
RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
- if (vrf->iflist != NULL)
- for (ALL_LIST_ELEMENTS_RO(vrf->iflist, node, p))
- if_dump(p);
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+ if_dump(ifp);
}
DEFUN (interface_desc,
{
int idx_vrf = 3;
struct listnode *node;
- struct listnode *node2;
struct interface *ifp;
struct connected *ifc;
struct prefix *p;
if (argc > 2)
VRF_GET_ID (vrf_id, argv[idx_vrf]->arg);
- for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
{
- for (ALL_LIST_ELEMENTS_RO (ifp->connected, node2, ifc))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
{
p = ifc->address;
{
struct vrf *vrf;
struct listnode *node;
- struct listnode *node2;
struct interface *ifp;
struct connected *ifc;
struct prefix *p;
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
{
- if (!vrf->iflist || !listcount (vrf->iflist))
+ if (RB_EMPTY (if_name_head, &vrf->ifaces_by_name))
continue;
vty_out (vty, "\nVRF %u\n\n", vrf->vrf_id);
- for (ALL_LIST_ELEMENTS_RO (vrf->iflist, node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
{
- for (ALL_LIST_ELEMENTS_RO (ifp->connected, node2, ifc))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
{
p = ifc->address;
}
#endif /* ifaddr_ipv4_table */
-/* Initialize interface list. */
-void if_init(struct list **intf_list)
-{
- *intf_list = list_new();
-#if 0
- ifaddr_ipv4_table = route_table_init ();
-#endif /* ifaddr_ipv4_table */
-
- (*intf_list)->cmp = (int (*)(void *, void *))if_cmp_func;
-}
-
-void if_terminate(struct list **intf_list)
+void if_terminate(struct vrf *vrf)
{
- for (;;) {
- struct interface *ifp;
-
- ifp = listnode_head(*intf_list);
- if (ifp == NULL)
- break;
+ struct interface *ifp;
+ while ((ifp = RB_ROOT(if_name_head, &vrf->ifaces_by_name)) != NULL) {
if (ifp->node) {
ifp->node->info = NULL;
route_unlock_node(ifp->node);
}
-
if_delete(ifp);
}
-
- list_delete_and_null(intf_list);
}
const char *if_link_type_str(enum zebra_link_type llt)
/* Interface structure */
struct interface {
+ RB_ENTRY(interface) name_entry;
+
/* Interface name. This should probably never be changed after the
interface is created, because the configuration info for this
interface
QOBJ_FIELDS
};
+RB_HEAD(if_name_head, interface);
+RB_PROTOTYPE(if_name_head, interface, name_entry, if_cmp_func);
DECLARE_QOBJ_TYPE(interface)
/* called from the library code whenever interfaces are created/deleted
extern int if_is_broadcast(struct interface *);
extern int if_is_pointopoint(struct interface *);
extern int if_is_multicast(struct interface *);
-extern void if_init(struct list **);
extern void if_cmd_init(void);
-extern void if_terminate(struct list **);
+struct vrf;
+extern void if_terminate(struct vrf *vrf);
extern void if_dump_all(void);
extern const char *if_flag_dump(unsigned long);
extern const char *if_link_type_str(enum zebra_link_type);
if (vrf == NULL) {
vrf = XCALLOC(MTYPE_VRF, sizeof(struct vrf));
vrf->vrf_id = VRF_UNKNOWN;
- if_init(&vrf->iflist);
+ RB_INIT(if_name_head, &vrf->ifaces_by_name);
QOBJ_REG(vrf, vrf);
new = 1;
(*vrf_master.vrf_delete_hook)(vrf);
QOBJ_UNREG(vrf);
- if_terminate(&vrf->iflist);
+ if_terminate(vrf);
if (vrf->vrf_id != VRF_UNKNOWN)
RB_REMOVE(vrf_id_head, &vrfs_by_id, vrf);
return vrf ? vrf->info : NULL;
}
-/* Look up the interface list in a VRF. */
-struct list *vrf_iflist(vrf_id_t vrf_id)
-{
- struct vrf *vrf = vrf_lookup_by_id(vrf_id);
- return vrf ? vrf->iflist : NULL;
-}
-
-/* Get the interface list of the specified VRF. Create one if not find. */
-struct list *vrf_iflist_get(vrf_id_t vrf_id)
-{
- struct vrf *vrf = vrf_get(vrf_id, NULL);
- return vrf->iflist;
-}
-
/*
* VRF bit-map
*/
u_char status;
#define VRF_ACTIVE (1 << 0)
- /* Master list of interfaces belonging to this VRF */
- struct list *iflist;
+ /* Interfaces belonging to this VRF */
+ struct if_name_head ifaces_by_name;
/* User data */
void *info;
/* Look up the data pointer of the specified VRF. */
extern void *vrf_info_lookup(vrf_id_t);
-/*
- * Utilities to obtain the interface list
- */
-
-/* Look up the interface list of the specified VRF. */
-extern struct list *vrf_iflist(vrf_id_t);
-/* Get the interface list of the specified VRF. Create one if not find. */
-extern struct list *vrf_iflist_get(vrf_id_t);
-
/*
* VRF bit-map: maintaining flags, one bit per VRF ID
*/
void nhrp_nhs_terminate(void)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
struct nhrp_interface *nifp;
struct nhrp_nhs *nhs, *tmp;
- struct listnode *node;
afi_t afi;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist (VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
nifp = ifp->info;
for (afi = 0; afi < AFI_MAX; afi++) {
list_for_each_entry_safe(nhs, tmp, &nifp->afi[afi].nhslist_head, nhslist_entry)
"Shortcut information\n"
"opennhrpctl style cache dump\n")
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
struct info_ctx ctx = {
.vty = vty,
};
if (argc <= 3 || argv[3]->text[0] == 'c') {
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
nhrp_cache_foreach(ifp, show_ip_nhrp_cache, &ctx);
} else if (argv[3]->text[0] == 'n') {
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
nhrp_nhs_foreach(ifp, ctx.afi, show_ip_nhrp_nhs, &ctx);
} else if (argv[3]->text[0] == 's') {
nhrp_shortcut_foreach(ctx.afi, show_ip_nhrp_shortcut, &ctx);
} else {
vty_out (vty, "Status: ok\n\n");
ctx.count++;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
nhrp_cache_foreach(ifp, show_ip_opennhrp_cache, &ctx);
}
"Dynamic cache entries\n"
"Shortcut entries\n")
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
struct info_ctx ctx = {
.vty = vty,
};
if (argc <= 3 || argv[3]->text[0] == 'c') {
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
nhrp_cache_foreach(ifp, clear_nhrp_cache, &ctx);
} else {
nhrp_shortcut_foreach(ctx.afi, clear_nhrp_shortcut, &ctx);
static int interface_config_write(struct vty *vty)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct write_map_ctx mapctx;
- struct listnode *node;
struct interface *ifp;
struct nhrp_interface *nifp;
struct nhrp_nhs *nhs;
char buf[SU_ADDRSTRLEN];
int i;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
vty_frame(vty, "interface %s\n", ifp->name);
if (ifp->desc)
vty_out (vty, " description %s\n", ifp->desc);
static int ospf6_bfd_nbr_replay(int command, struct zclient *zclient,
zebra_size_t length, vrf_id_t vrf_id)
{
- struct listnode *inode, *nnode;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ struct listnode *node;
struct interface *ifp;
struct ospf6_interface *oi;
struct ospf6_neighbor *on;
bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER);
/* Replay the neighbor, if BFD is enabled on the interface*/
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), inode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
oi = (struct ospf6_interface *)ifp->info;
if (!oi || !oi->bfd_info)
continue;
- for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, nnode, on)) {
+ for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, node, on)) {
if (on->state < OSPF6_NEIGHBOR_TWOWAY)
continue;
INTERFACE_STR
IFNAME_STR)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
int idx_ifname = 4;
struct interface *ifp;
- struct listnode *i;
if (argc == 5) {
ifp = if_lookup_by_name(argv[idx_ifname]->arg, VRF_DEFAULT);
}
ospf6_interface_show(vty, ifp);
} else {
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), i, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
ospf6_interface_show(vty, ifp);
}
OSPF6_ROUTE_MATCH_STR
"Display details of the prefixes\n")
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
int idx_prefix = 5;
- struct listnode *i;
struct ospf6_interface *oi;
struct interface *ifp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), i, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
oi = (struct ospf6_interface *)ifp->info;
if (oi == NULL)
continue;
static int config_write_ospf6_interface(struct vty *vty)
{
- struct listnode *i;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct ospf6_interface *oi;
struct interface *ifp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), i, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
oi = (struct ospf6_interface *)ifp->info;
if (oi == NULL)
continue;
IFNAME_STR
)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
int idx_ifname = 4;
struct interface *ifp;
- struct listnode *node;
if (argc == 4) /* Clear all the ospfv3 interfaces. */
{
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
ospf6_interface_clear(vty, ifp);
} else /* Interface name is specified. */
{
static void __attribute__((noreturn)) ospf6_exit(int status)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
frr_early_fini();
bfd_gbl_exit();
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
if (ifp->info != NULL)
ospf6_interface_delete(ifp->info);
int exact, size_t *var_len,
WriteMethod **write_method)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct ospf6_lsa *lsa = NULL;
ifindex_t ifindex;
uint32_t area_id, id, instid, adv_router;
if (!ifslist)
return NULL;
ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node,
- iif))
+ RB_FOREACH (iif, if_name_head, &vrf->ifaces_by_name)
listnode_add_sort(ifslist, iif);
for (ALL_LIST_ELEMENTS_RO(ifslist, node, iif)) {
if (!ifslist)
return NULL;
ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), i, iif))
+ RB_FOREACH (iif, if_name_head, &vrf->ifaces_by_name)
listnode_add_sort(ifslist, iif);
for (ALL_LIST_ELEMENTS_RO(ifslist, i, iif)) {
if (!ifslist)
return NULL;
ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), i, iif))
+ RB_FOREACH (iif, if_name_head, &vrf->ifaces_by_name)
listnode_add_sort(ifslist, iif);
for (ALL_LIST_ELEMENTS_RO(ifslist, i, iif)) {
"Interface information\n"
"Interface name\n")
{
+ struct vrf *vrf;
int idx_interface = 5;
struct interface *ifp;
- struct listnode *node, *nnode, *n1;
+ struct listnode *node;
char *vrf_name = NULL;
bool all_vrf;
int inst = 0;
/* vrf input is provided could be all or specific vrf*/
if (vrf_name) {
if (all_vrf) {
- for (ALL_LIST_ELEMENTS_RO(om->ospf, n1, ospf)) {
+ for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
if (!ospf->oi_running)
continue;
- for (ALL_LIST_ELEMENTS(vrf_iflist(ospf->vrf_id),
- node, nnode, ifp))
+ vrf = vrf_lookup_by_id(ospf->vrf_id);
+ RB_FOREACH (ifp, if_name_head,
+ &vrf->ifaces_by_name)
show_mpls_te_link_sub(vty, ifp);
}
return CMD_SUCCESS;
ospf = ospf_lookup_by_inst_name (inst, vrf_name);
if (ospf == NULL || !ospf->oi_running)
return CMD_SUCCESS;
- for (ALL_LIST_ELEMENTS(vrf_iflist(ospf->vrf_id), node,
- nnode, ifp))
+ vrf = vrf_lookup_by_id(ospf->vrf_id);
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
show_mpls_te_link_sub(vty, ifp);
return CMD_SUCCESS;
}
/* Show All Interfaces. */
if (argc == 5) {
- for (ALL_LIST_ELEMENTS_RO(om->ospf, n1, ospf)) {
+ for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
if (!ospf->oi_running)
continue;
- for (ALL_LIST_ELEMENTS(vrf_iflist(ospf->vrf_id), node,
- nnode, ifp))
+ vrf = vrf_lookup_by_id(ospf->vrf_id);
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
show_mpls_te_link_sub(vty, ifp);
}
}
static void ospf_passive_interface_default(struct ospf *ospf, u_char newval)
{
+ struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
struct listnode *ln;
struct interface *ifp;
struct ospf_interface *oi;
ospf->passive_interface_default = newval;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id), ln, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
if (ifp && OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp),
passive_interface))
UNSET_IF_PARAM(IF_DEF_PARAMS(ifp), passive_interface);
"The reference bandwidth in terms of Mbits per second\n")
{
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
+ struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
int idx_number = 2;
u_int32_t refbw;
- struct listnode *node;
struct interface *ifp;
refbw = strtol(argv[idx_number]->arg, NULL, 10);
return CMD_SUCCESS;
ospf->ref_bandwidth = refbw;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
ospf_if_recalculate_output_cost(ifp);
return CMD_SUCCESS;
"The reference bandwidth in terms of Mbits per second\n")
{
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
- struct listnode *node, *nnode;
+ struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
struct interface *ifp;
if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
vty_out(vty,
" Please ensure reference bandwidth is consistent across all routers\n");
- for (ALL_LIST_ELEMENTS(vrf_iflist(ospf->vrf_id), node, nnode, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
ospf_if_recalculate_output_cost(ifp);
return CMD_SUCCESS;
int iface_argv, u_char use_json)
{
struct interface *ifp;
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
json_object *json = NULL;
json_object *json_interface_sub = NULL;
if (argc == iface_argv) {
/* Show All Interfaces.*/
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id),
- node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
if (ospf_oi_count(ifp)) {
if (use_json)
json_interface_sub =
static int config_write_interface_one(struct vty *vty, struct ospf *ospf)
{
- struct listnode *n1, *n2;
+ struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
+ struct listnode *node;
struct interface *ifp;
struct crypt_key *ck;
struct route_node *rn = NULL;
struct ospf_if_params *params;
int write = 0;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id), n1, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
struct vrf *vrf = NULL;
if (memcmp(ifp->name, "VLINK", 5) == 0)
/* Cryptographic Authentication Key print. */
if (params && params->auth_crypt) {
for (ALL_LIST_ELEMENTS_RO(params->auth_crypt,
- n2, ck)) {
+ node, ck)) {
vty_out(vty,
" ip ospf message-digest-key %d md5 %s",
ck->key_id, ck->auth_key);
static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)
{
+ struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
struct interface *ifp;
struct ospf_interface *oi;
struct listnode *node = NULL;
if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
vty_out(vty, " passive-interface default\n");
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
if (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp),
passive_interface)
&& IF_DEF_PARAMS(ifp)->passive_interface
{
int idx_ifname = 4;
struct interface *ifp;
- struct listnode *node, *n1;
+ struct listnode *node;
struct ospf *ospf = NULL;
if (argc == 4) /* Clear all the ospfv2 interfaces. */
{
- for (ALL_LIST_ELEMENTS_RO(om->ospf, n1, ospf)) {
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id),
- node, ifp))
+ for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
+ struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
ospf_interface_clear(ifp);
}
} else {
void ospf_router_id_update(struct ospf *ospf)
{
+ struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
struct in_addr router_id, router_id_old;
struct ospf_interface *oi;
struct interface *ifp;
ospf_router_lsa_update(ospf);
/* update ospf_interface's */
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
ospf_if_update(ospf, ifp);
}
}
/* Final cleanup of ospf instance */
static void ospf_finish_final(struct ospf *ospf)
{
+ struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
struct route_node *rn;
struct ospf_nbr_nbma *nbr_nbma;
struct ospf_lsa *lsa;
struct listnode *node, *nnode;
int i;
u_short instance = 0;
- struct vrf *vrf = NULL;
QOBJ_UNREG(ospf);
list_delete_and_null(&ospf->vlinks);
/* Remove any ospf interface config params */
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
struct ospf_if_params *params;
params = IF_DEF_PARAMS(ifp);
static void ospf_network_run(struct prefix *p, struct ospf_area *area)
{
+ struct vrf *vrf = vrf_lookup_by_id(area->ospf->vrf_id);
struct interface *ifp;
- struct listnode *node;
/* Schedule Router ID Update. */
if (area->ospf->router_id.s_addr == 0)
ospf_router_id_update(area->ospf);
/* Get target interface. */
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(area->ospf->vrf_id), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
ospf_network_run_interface(area->ospf, ifp, p, area);
}
struct interface *ifp = NULL;
struct pim_interface *pim_ifp = NULL;
struct pim_neighbor *neigh = NULL;
- struct listnode *node;
struct listnode *neigh_node;
struct listnode *neigh_nextnode;
struct vrf *vrf = NULL;
bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER);
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
pim_ifp = ifp->info;
if (!pim_ifp)
{
struct pim_interface *pim_ifp;
struct pim_ifchannel *ch;
- struct listnode *if_node;
struct interface *ifp;
time_t now;
vty_out(vty,
"Interface Address Source Group State Winner Uptime Timer\n");
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), if_node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
pim_ifp = ifp->info;
if (!pim_ifp)
continue;
static void pim_show_assert_internal(struct pim_instance *pim, struct vty *vty)
{
struct pim_interface *pim_ifp;
- struct listnode *if_node;
struct pim_ifchannel *ch;
struct interface *ifp;
vty_out(vty,
"Interface Address Source Group CA eCA ATD eATD\n");
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), if_node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
pim_ifp = ifp->info;
if (!pim_ifp)
continue;
static void pim_show_assert_metric(struct pim_instance *pim, struct vty *vty)
{
struct pim_interface *pim_ifp;
- struct listnode *if_node;
struct pim_ifchannel *ch;
struct interface *ifp;
vty_out(vty,
"Interface Address Source Group RPT Pref Metric Address \n");
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), if_node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
pim_ifp = ifp->info;
if (!pim_ifp)
continue;
static void pim_show_assert_winner_metric(struct pim_instance *pim,
struct vty *vty)
{
- struct listnode *if_node;
struct pim_interface *pim_ifp;
struct pim_ifchannel *ch;
struct interface *ifp;
vty_out(vty,
"Interface Address Source Group RPT Pref Metric Address \n");
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), if_node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
pim_ifp = ifp->info;
if (!pim_ifp)
continue;
static void pim_show_membership(struct pim_instance *pim, struct vty *vty,
u_char uj)
{
- struct listnode *if_node;
struct pim_interface *pim_ifp;
struct pim_ifchannel *ch;
struct interface *ifp;
json = json_object_new_object();
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), if_node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
pim_ifp = ifp->info;
if (!pim_ifp)
continue;
static void igmp_show_interfaces(struct pim_instance *pim, struct vty *vty,
u_char uj)
{
- struct listnode *node;
struct interface *ifp;
time_t now;
json_object *json = NULL;
vty_out(vty,
"Interface State Address V Querier Query Timer Uptime\n");
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
struct pim_interface *pim_ifp;
struct listnode *sock_node;
struct igmp_sock *igmp;
{
struct igmp_sock *igmp;
struct interface *ifp;
- struct listnode *node;
struct listnode *sock_node;
struct pim_interface *pim_ifp;
char uptime[10];
now = pim_time_monotonic_sec();
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
pim_ifp = ifp->info;
if (!pim_ifp)
static void igmp_show_interface_join(struct pim_instance *pim, struct vty *vty)
{
- struct listnode *node;
struct interface *ifp;
time_t now;
vty_out(vty,
"Interface Address Source Group Socket Uptime \n");
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
struct pim_interface *pim_ifp;
struct listnode *join_node;
struct igmp_join *ij;
struct in_addr ifaddr;
struct interface *ifp;
struct listnode *neighnode;
- struct listnode *node;
struct listnode *upnode;
struct pim_interface *pim_ifp;
struct pim_neighbor *neigh;
if (uj)
json = json_object_new_object();
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
pim_ifp = ifp->info;
if (!pim_ifp)
u_char uj)
{
struct interface *ifp;
- struct listnode *node;
struct listnode *upnode;
struct pim_interface *pim_ifp;
struct pim_upstream *up;
json = json_object_new_object();
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
pim_ifp = ifp->info;
if (!pim_ifp)
{
struct interface *ifp = NULL;
struct pim_interface *pim_ifp = NULL;
- struct listnode *node = NULL;
json_object *json = NULL;
json_object *json_row = NULL;
"---------------------------------------------------------------------------------------------------------------\n");
}
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
pim_ifp = ifp->info;
if (!pim_ifp)
{
struct interface *ifp = NULL;
struct pim_interface *pim_ifp = NULL;
- struct listnode *node = NULL;
json_object *json = NULL;
json_object *json_row = NULL;
uint8_t found_ifname = 0;
"---------------------------------------------------------------------------------------------------------------\n");
}
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
if (strcmp(ifname, ifp->name))
continue;
static void pim_show_join(struct pim_instance *pim, struct vty *vty, u_char uj)
{
- struct listnode *if_node;
struct pim_interface *pim_ifp;
struct pim_ifchannel *ch;
struct interface *ifp;
vty_out(vty,
"Interface Address Source Group State Uptime Expire Prune\n");
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), if_node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
pim_ifp = ifp->info;
if (!pim_ifp)
continue;
static void pim_show_neighbors_single(struct pim_instance *pim, struct vty *vty,
const char *neighbor, u_char uj)
{
- struct listnode *node;
struct listnode *neighnode;
struct interface *ifp;
struct pim_interface *pim_ifp;
if (uj)
json = json_object_new_object();
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
pim_ifp = ifp->info;
if (!pim_ifp)
static void pim_show_neighbors(struct pim_instance *pim, struct vty *vty,
u_char uj)
{
- struct listnode *node;
struct listnode *neighnode;
struct interface *ifp;
struct pim_interface *pim_ifp;
"Interface Neighbor Uptime Holdtime DR Pri\n");
}
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
pim_ifp = ifp->info;
if (!pim_ifp)
static void pim_show_neighbors_secondary(struct pim_instance *pim,
struct vty *vty)
{
- struct listnode *node;
struct interface *ifp;
vty_out(vty,
"Interface Address Neighbor Secondary \n");
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
struct pim_interface *pim_ifp;
struct in_addr ifaddr;
struct listnode *neighnode;
static void pim_show_join_desired(struct pim_instance *pim, struct vty *vty,
u_char uj)
{
- struct listnode *if_node;
struct pim_interface *pim_ifp;
struct pim_ifchannel *ch;
struct interface *ifp;
"Interface Source Group LostAssert Joins PimInclude JoinDesired EvalJD\n");
/* scan per-interface (S,G) state */
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), if_node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
pim_ifp = ifp->info;
if (!pim_ifp)
continue;
static void igmp_show_groups(struct pim_instance *pim, struct vty *vty,
u_char uj)
{
- struct listnode *ifnode;
struct interface *ifp;
time_t now;
json_object *json = NULL;
"Interface Address Group Mode Timer Srcs V Uptime \n");
/* scan interfaces */
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
struct pim_interface *pim_ifp = ifp->info;
struct listnode *sock_node;
struct igmp_sock *igmp;
static void igmp_show_group_retransmission(struct pim_instance *pim,
struct vty *vty)
{
- struct listnode *ifnode;
struct interface *ifp;
vty_out(vty,
"Interface Address Group RetTimer Counter RetSrcs\n");
/* scan interfaces */
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
struct pim_interface *pim_ifp = ifp->info;
struct listnode *sock_node;
struct igmp_sock *igmp;
static void igmp_show_sources(struct pim_instance *pim, struct vty *vty)
{
- struct listnode *ifnode;
struct interface *ifp;
time_t now;
"Interface Address Group Source Timer Fwd Uptime \n");
/* scan interfaces */
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
struct pim_interface *pim_ifp = ifp->info;
struct listnode *sock_node;
struct igmp_sock *igmp;
static void igmp_show_source_retransmission(struct pim_instance *pim,
struct vty *vty)
{
- struct listnode *ifnode;
struct interface *ifp;
vty_out(vty,
"Interface Address Group Source Counter\n");
/* scan interfaces */
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
struct pim_interface *pim_ifp = ifp->info;
struct listnode *sock_node;
struct igmp_sock *igmp;
static void clear_igmp_interfaces(struct pim_instance *pim)
{
- struct listnode *ifnode;
- struct listnode *ifnextnode;
struct interface *ifp;
- for (ALL_LIST_ELEMENTS(vrf_iflist(pim->vrf_id), ifnode, ifnextnode,
- ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name)
pim_if_addr_del_all_igmp(ifp);
- }
- for (ALL_LIST_ELEMENTS(vrf_iflist(pim->vrf_id), ifnode, ifnextnode,
- ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name)
pim_if_addr_add_all(ifp);
- }
}
static void clear_pim_interfaces(struct pim_instance *pim)
{
- struct listnode *ifnode;
- struct listnode *ifnextnode;
struct interface *ifp;
- for (ALL_LIST_ELEMENTS(vrf_iflist(pim->vrf_id), ifnode, ifnextnode,
- ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
if (ifp->info) {
pim_neighbor_delete_all(ifp, "interface cleared");
}
{
int idx = 2;
struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
- struct listnode *ifnode = NULL;
- struct listnode *ifnextnode = NULL;
struct interface *ifp = NULL;
struct pim_interface *pim_ifp = NULL;
if (!vrf)
return CMD_WARNING;
- for (ALL_LIST_ELEMENTS(vrf_iflist(vrf->vrf_id), ifnode, ifnextnode,
- ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
pim_ifp = ifp->info;
if (!pim_ifp)
static void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty)
{
- struct listnode *node;
struct interface *ifp;
vty_out(vty, "\n");
vty_out(vty,
"Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut\n");
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
struct pim_interface *pim_ifp;
struct in_addr ifaddr;
struct sioc_vif_req vreq;
struct interface *pim_if_find_by_vif_index(struct pim_instance *pim,
ifindex_t vif_index)
{
- struct listnode *ifnode;
struct interface *ifp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
if (ifp->info) {
struct pim_interface *pim_ifp;
pim_ifp = ifp->info;
{
struct pim_interface *new_pim_ifp = new_ifp->info;
struct pim_instance *pim = new_pim_ifp->pim;
- struct listnode *ifnode;
struct interface *ifp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
struct pim_interface *loop_pim_ifp = ifp->info;
struct pim_ifchannel *ch;
void pim_jp_agg_upstream_verification(struct pim_upstream *up, bool ignore)
{
#ifdef PIM_JP_AGG_DEBUG
- struct listnode *node;
struct interface *ifp;
struct pim_interface *pim_ifp = up->rpf.source_nexthop.interface->info;
struct pim_instance *pim = pim_ifp->pim;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
pim_ifp = ifp->info;
struct listnode *nnode;
static int pim_update_upstream_nh(struct pim_instance *pim,
struct pim_nexthop_cache *pnc)
{
- struct listnode *node, *ifnode;
+ struct listnode *node;
struct interface *ifp;
hash_walk(pnc->upstream_hash, pim_update_upstream_nh_helper, pim);
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp))
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name)
if (ifp->info) {
struct pim_interface *pim_ifp = ifp->info;
struct pim_iface_upstream_switch *us;
static void pim_rp_check_interfaces(struct pim_instance *pim,
struct rp_info *rp_info)
{
- struct listnode *node;
struct interface *ifp;
rp_info->i_am_rp = 0;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
struct pim_interface *pim_ifp = ifp->info;
if (!pim_ifp)
struct pim_upstream *up)
{
struct interface *ifp;
- struct listnode *node;
struct pim_ifchannel *ch, *starch;
struct pim_upstream *starup = up->parent;
int ret = 0;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
if (!ifp->info)
continue;
struct interface *ifp;
struct pim_interface *pim_ifp = NULL;
struct pim_ifchannel *ch, *starch;
- struct listnode *node;
struct pim_upstream *starup = up->parent;
int output_intf = 0;
up->channel_oil = pim_channel_oil_add(
pim, &up->sg, pim_ifp->mroute_vif_index);
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
if (!ifp->info)
continue;
int pim_interface_config_write(struct vty *vty)
{
struct pim_instance *pim;
- struct listnode *node;
struct interface *ifp;
struct vrf *vrf;
int writes = 0;
if (!pim)
continue;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), node, ifp)) {
-
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
/* IF name */
if (vrf->vrf_id == VRF_DEFAULT)
vty_frame(vty, "interface %s\n", ifp->name);
pim_rp_check_on_if_add(pim_ifp);
if (if_is_loopback(c->ifp)) {
- struct listnode *ifnode;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), ifnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
if (!if_is_loopback(ifp) && if_is_operative(ifp))
pim_if_addr_add_all(ifp);
}
static void scan_upstream_rpf_cache()
{
struct listnode *up_node;
- struct listnode *ifnode;
struct listnode *up_nextnode;
struct listnode *node;
struct pim_upstream *up;
if (!pim)
continue;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode, ifp))
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name)
if (ifp->info) {
struct pim_interface *pim_ifp = ifp->info;
struct pim_iface_upstream_switch *us;
void igmp_source_forward_reevaluate_all(void)
{
- struct listnode *ifnode;
struct interface *ifp;
struct vrf *vrf;
struct pim_instance *pim;
if (!pim)
continue;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pim->vrf_id), ifnode,
- ifp)) {
+ RB_FOREACH (ifp, if_name_head, &pim->vrf->ifaces_by_name) {
struct pim_interface *pim_ifp = ifp->info;
struct listnode *sock_node;
struct igmp_sock *igmp;
/* Does this address belongs to me ? */
int if_check_address(struct in_addr addr)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
struct listnode *cnode;
struct connected *connected;
void rip_interfaces_clean(void)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
rip_interface_clean(ifp->info);
}
void rip_interfaces_reset(void)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
rip_interface_reset(ifp->info);
}
/* Needed for stop RIP process. */
void rip_if_down_all()
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- struct listnode *node, *nnode;
- for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
rip_if_down(ifp);
}
/* Apply network configuration to all interface. */
void rip_enable_apply_all()
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- struct listnode *node, *nnode;
/* Check each interface. */
- for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
rip_enable_apply(ifp);
}
static void rip_passive_interface_apply_all(void)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- struct listnode *node, *nnode;
- for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
rip_passive_interface_apply(ifp);
}
/* Write rip configuration of each interface. */
static int rip_interface_config_write(struct vty *vty)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
struct rip_interface *ri;
if (ifp->ifindex == IFINDEX_DELETED)
/* Check nexthop address validity. */
static int rip_nexthop_check(struct in_addr *addr)
{
- struct listnode *node;
- struct listnode *cnode;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
+ struct listnode *cnode;
struct connected *ifc;
struct prefix *p;
/* If nexthop address matches local configured address then it is
invalid nexthop. */
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, ifc)) {
p = ifc->address;
/* Update send to all interface and neighbor. */
static void rip_update_process(int route_type)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct listnode *ifnode, *ifnnode;
struct connected *connected;
struct interface *ifp;
struct prefix *p;
/* Send RIP update to each interface. */
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
if (if_is_loopback(ifp))
continue;
"Show RIP routes\n"
"IP routing protocol process parameters and statistics\n")
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
struct rip_interface *ri;
extern const struct message ri_version_msg[];
vty_out(vty, " Interface Send Recv Key-chain\n");
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
ri = ifp->info;
if (!ri->running)
{
int found_passive = 0;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
ri = ifp->info;
if ((ri->enable_network || ri->enable_interface)
/* ARGSUSED */
static void rip_distribute_update_all(struct prefix_list *notused)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- struct listnode *node, *nnode;
- for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
rip_distribute_update_interface(ifp);
}
/* ARGSUSED */
/* ARGSUSED */
static void rip_routemap_update(const char *notused)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- struct listnode *node, *nnode;
- for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
rip_if_rmap_update_interface(ifp);
rip_routemap_update_redistribute();
void ripng_interface_clean(void)
{
- struct listnode *node, *nnode;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
struct ripng_interface *ri;
- for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
ri = ifp->info;
ri->enable_network = 0;
void ripng_interface_reset(void)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
struct ripng_interface *ri;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
ri = ifp->info;
ri->enable_network = 0;
/* Set distribute list to all interfaces. */
static void ripng_enable_apply_all(void)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- struct listnode *node;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
ripng_enable_apply(ifp);
}
static void ripng_passive_interface_apply_all(void)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- struct listnode *node;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
ripng_passive_interface_apply(ifp);
}
/* Configuration write function for ripngd. */
static int interface_config_write(struct vty *vty)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
struct ripng_interface *ri;
int write = 0;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
ri = ifp->info;
/* Do not display the interface if there is no
enabled interface. */
static int ripng_update(struct thread *t)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
struct ripng_interface *ri;
zlog_debug("RIPng update timer expired!");
/* Supply routes to each interface. */
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
ri = ifp->info;
if (if_is_loopback(ifp) || !if_is_up(ifp))
/* Execute triggered update. */
int ripng_triggered_update(struct thread *t)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
struct ripng_interface *ri;
int interval;
/* Split Horizon processing is done when generating triggered
updates as well as normal updates (see section 2.6). */
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
ri = ifp->info;
if (if_is_loopback(ifp) || !if_is_up(ifp))
"Show RIPng routes\n"
"IPv6 routing protocol process parameters and statistics\n")
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
if (!ripng)
vty_out(vty, " Interface Send Recv\n");
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
struct ripng_interface *ri;
ri = ifp->info;
/* Update all interface's distribute list. */
static void ripng_distribute_update_all(struct prefix_list *notused)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- struct listnode *node;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
ripng_distribute_update_interface(ifp);
}
static void ripng_routemap_update(const char *unused)
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- struct listnode *node;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
ripng_if_rmap_update_interface(ifp);
ripng_routemap_update_redistribute();
/* Fetch interface information via ioctl(). */
static void interface_info_ioctl()
{
- struct listnode *node, *nnode;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
if_get_index(ifp);
#ifdef SIOCGIFHWADDR
if_get_hwaddr(ifp);
"Interface status and configuration\n"
VRF_CMD_HELP_STR)
{
- struct listnode *node;
+ struct vrf *vrf;
struct interface *ifp;
vrf_id_t vrf_id = VRF_DEFAULT;
VRF_GET_ID(vrf_id, argv[3]->arg);
/* All interface print. */
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), node, ifp))
+ vrf = vrf_lookup_by_id(vrf_id);
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
if_dump_vty(vty, ifp);
return CMD_SUCCESS;
VRF_ALL_CMD_HELP_STR)
{
struct vrf *vrf;
- struct listnode *node;
struct interface *ifp;
interface_update_stats();
/* All interface print. */
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
- for (ALL_LIST_ELEMENTS_RO(vrf->iflist, node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
if_dump_vty(vty, ifp);
return CMD_SUCCESS;
static void if_show_description(struct vty *vty, vrf_id_t vrf_id)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(vrf_id);
struct interface *ifp;
vty_out(vty, "Interface Status Protocol Description\n");
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(vrf_id), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
int len;
len = vty_out(vty, "%s", ifp->name);
struct vrf *vrf;
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
- if (!list_isempty(vrf->iflist)) {
+ if (!RB_EMPTY (if_name_head, &vrf->ifaces_by_name)) {
vty_out(vty, "\n\tVRF %u\n\n", vrf->vrf_id);
if_show_description(vty, vrf->vrf_id);
}
static int if_config_write(struct vty *vty)
{
struct vrf *vrf;
- struct listnode *node;
struct interface *ifp;
zebra_ptm_write(vty);
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
- for (ALL_LIST_ELEMENTS_RO(vrf->iflist, node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
struct zebra_if *if_data;
struct listnode *addrnode;
struct connected *ifc;
static int irdp_finish(void)
{
struct vrf *vrf;
- struct listnode *node, *nnode;
struct interface *ifp;
struct zebra_if *zi;
struct irdp_interface *irdp;
zlog_info("IRDP: Received shutdown notification.");
RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
- for (ALL_LIST_ELEMENTS(vrf->iflist, node, nnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
zi = ifp->info;
if (!zi)
{
struct zebra_ns *zns = THREAD_ARG(thread);
struct vrf *vrf;
- struct listnode *node, *nnode;
struct interface *ifp;
struct zebra_if *zif;
int period;
}
RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
- for (ALL_LIST_ELEMENTS(vrf->iflist, node, nnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
if (if_is_loopback(ifp)
|| CHECK_FLAG(ifp->status,
ZEBRA_INTERFACE_VRF_LOOPBACK)
static void map_slaves_to_bridge(struct interface *br_if, int link)
{
struct vrf *vrf;
- struct listnode *node;
struct interface *ifp;
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
- for (ALL_LIST_ELEMENTS_RO(vrf->iflist, node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
struct zebra_if *zif;
struct zebra_l2info_brslave *br_slave;
"Enable neighbor check with specified topology\n")
{
struct vrf *vrf;
- struct listnode *i;
struct interface *ifp;
struct zebra_if *if_data;
ptm_cb.ptm_enable = ZEBRA_IF_PTM_ENABLE_ON;
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
- for (ALL_LIST_ELEMENTS_RO(vrf->iflist, i, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
if (!ifp->ptm_enable) {
if_data = (struct zebra_if *)ifp->info;
if (if_data
void zebra_ptm_reset_status(int ptm_disable)
{
struct vrf *vrf;
- struct listnode *i;
struct interface *ifp;
int send_linkup;
RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
- for (ALL_LIST_ELEMENTS_RO(vrf->iflist, i, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
send_linkup = 0;
if (ifp->ptm_enable) {
if (!if_is_operative(ifp))
/* uninstall everything */
if (!CHECK_FLAG(zvrf->flags, ZEBRA_VRF_RETAIN)) {
- struct listnode *node;
struct interface *ifp;
for (afi = AFI_IP; afi <= AFI_IP6; afi++) {
zebra_mpls_close_tables(zvrf);
zebra_pw_exit(zvrf);
- for (ALL_LIST_ELEMENTS_RO(vrf->iflist, node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
if_nbr_ipv6ll_to_ipv4ll_neigh_del_all(ifp);
}
struct zebra_vrf *zvrf = NULL;
struct interface *tmp_if = NULL;
struct zebra_if *zif = NULL;
- struct listnode *node;
zvrf = vrf_info_lookup(ifp->vrf_id);
assert(zvrf);
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(zvrf_id(zvrf)), node, tmp_if)) {
+ RB_FOREACH (tmp_if, if_name_head, &zvrf->vrf->ifaces_by_name) {
zif = tmp_if->info;
if (!zif)
continue;
struct zebra_vrf *zvrf)
{
struct vrf *vrf;
- struct listnode *ifnode, *ifnnode;
struct interface *ifp;
/* Interface information is needed. */
vrf_bitmap_set(client->ifinfo, zvrf_id(zvrf));
RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
- for (ALL_LIST_ELEMENTS(vrf->iflist, ifnode, ifnnode, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
/* Skip pseudo interface. */
if (!CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE))
continue;