summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-10-16 18:00:38 +0200
committerGitHub <noreply@github.com>2017-10-16 18:00:38 +0200
commit5b8d8894f8ecb401acc9b3986bbb6ce95b3263e9 (patch)
tree077628692cdbae750e26d1b8f237c422bae6519d /bgpd
parentMerge pull request #1305 from donaldsharp/workqueue (diff)
parent*: use the FOR_ALL_INTERFACES abstraction from babeld (diff)
downloadfrr-5b8d8894f8ecb401acc9b3986bbb6ce95b3263e9.tar.xz
frr-5b8d8894f8ecb401acc9b3986bbb6ce95b3263e9.zip
Merge pull request #1298 from opensourcerouting/iface-rb-tree
Use rb-trees to store interfaces instead of linked-lists
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_zebra.c34
-rw-r--r--bgpd/bgpd.c6
2 files changed, 28 insertions, 12 deletions
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index f97945724..ddf461f1b 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -238,7 +238,7 @@ static int bgp_interface_delete(int command, struct zclient *zclient,
bgp_update_interface_nbrs(bgp, ifp, NULL);
- ifp->ifindex = IFINDEX_DELETED;
+ if_set_index(ifp, IFINDEX_INTERNAL);
return 0;
}
@@ -593,18 +593,22 @@ static int zebra_read_route(int command, struct zclient *zclient,
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)) {
+ FOR_ALL_INTERFACES (vrf, ifp) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
cp = connected->address;
@@ -618,13 +622,17 @@ struct interface *if_lookup_by_ipv4(struct in_addr *addr, vrf_id_t vrf_id)
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;
+
+ FOR_ALL_INTERFACES (vrf, ifp) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
cp = connected->address;
@@ -639,18 +647,22 @@ struct interface *if_lookup_by_ipv4_exact(struct in_addr *addr, vrf_id_t vrf_id)
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)) {
+ FOR_ALL_INTERFACES (vrf, ifp) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
cp = connected->address;
@@ -671,13 +683,17 @@ struct interface *if_lookup_by_ipv6(struct in6_addr *addr, ifindex_t ifindex,
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;
+
+ FOR_ALL_INTERFACES (vrf, ifp) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, connected)) {
cp = connected->address;
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 308698e1c..d223cecc5 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -7342,13 +7342,13 @@ void bgp_master_init(struct thread_master *master)
*/
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)) {
+ FOR_ALL_INTERFACES (vrf, ifp) {
struct listnode *c_node, *c_nnode;
struct connected *c;