summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenato Westphal <renato@openbsd.org>2017-10-10 12:25:23 -0300
committerGitHub <noreply@github.com>2017-10-10 12:25:23 -0300
commit3cda75059844fe1f4612f2ecf047288e40b46c2c (patch)
tree7ca38a4f15c8b883db3fc371ee31ae493fc38d68
parente56ab0e97122d35d3f8d21faf820a90eb1953948 (diff)
parent2f9123e06920a96797a9e139ee3af0dab52f6639 (diff)
Merge pull request #1315 from dslicenc/bgp-interface
bgpd: check for bgp instance before processing interfaces
-rw-r--r--bgpd/bgp_zebra.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index c90257d659..f979457244 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -224,6 +224,10 @@ static int bgp_interface_delete(int command, struct zclient *zclient,
struct interface *ifp;
struct bgp *bgp;
+ bgp = bgp_lookup_by_vrf_id(vrf_id);
+ if (!bgp)
+ return 0;
+
s = zclient->ibuf;
ifp = zebra_interface_state_read(s, vrf_id);
if (!ifp) /* This may happen if we've just unregistered for a VRF. */
@@ -232,10 +236,6 @@ static int bgp_interface_delete(int command, struct zclient *zclient,
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("Rx Intf del VRF %u IF %s", vrf_id, ifp->name);
- bgp = bgp_lookup_by_vrf_id(vrf_id);
- if (!bgp)
- return 0;
-
bgp_update_interface_nbrs(bgp, ifp, NULL);
ifp->ifindex = IFINDEX_DELETED;
@@ -252,6 +252,10 @@ static int bgp_interface_up(int command, struct zclient *zclient,
struct listnode *node, *nnode;
struct bgp *bgp;
+ bgp = bgp_lookup_by_vrf_id(vrf_id);
+ if (!bgp)
+ return 0;
+
s = zclient->ibuf;
ifp = zebra_interface_state_read(s, vrf_id);
@@ -261,10 +265,6 @@ static int bgp_interface_up(int command, struct zclient *zclient,
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("Rx Intf up VRF %u IF %s", vrf_id, ifp->name);
- bgp = bgp_lookup_by_vrf_id(vrf_id);
- if (!bgp)
- return 0;
-
for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, c))
bgp_connected_add(bgp, c);
@@ -284,6 +284,10 @@ static int bgp_interface_down(int command, struct zclient *zclient,
struct listnode *node, *nnode;
struct bgp *bgp;
+ bgp = bgp_lookup_by_vrf_id(vrf_id);
+ if (!bgp)
+ return 0;
+
s = zclient->ibuf;
ifp = zebra_interface_state_read(s, vrf_id);
if (!ifp)
@@ -292,10 +296,6 @@ static int bgp_interface_down(int command, struct zclient *zclient,
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("Rx Intf down VRF %u IF %s", vrf_id, ifp->name);
- bgp = bgp_lookup_by_vrf_id(vrf_id);
- if (!bgp)
- return 0;
-
for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, c))
bgp_connected_delete(bgp, c);
@@ -338,6 +338,11 @@ static int bgp_interface_address_add(int command, struct zclient *zclient,
zebra_size_t length, vrf_id_t vrf_id)
{
struct connected *ifc;
+ struct bgp *bgp;
+
+ bgp = bgp_lookup_by_vrf_id(vrf_id);
+ if (!bgp)
+ return 0;
ifc = zebra_interface_address_read(command, zclient->ibuf, vrf_id);
@@ -352,13 +357,8 @@ static int bgp_interface_address_add(int command, struct zclient *zclient,
}
if (if_is_operative(ifc->ifp)) {
- struct bgp *bgp;
-
- bgp = bgp_lookup_by_vrf_id(vrf_id);
- if (!bgp)
- return 0;
-
bgp_connected_add(bgp, ifc);
+
/* If we have learnt of any neighbors on this interface,
* check to kick off any BGP interface-based neighbors,
* but only if this is a link-local address.
@@ -377,6 +377,10 @@ static int bgp_interface_address_delete(int command, struct zclient *zclient,
struct connected *ifc;
struct bgp *bgp;
+ bgp = bgp_lookup_by_vrf_id(vrf_id);
+ if (!bgp)
+ return 0;
+
ifc = zebra_interface_address_read(command, zclient->ibuf, vrf_id);
if (ifc == NULL)
@@ -390,9 +394,7 @@ static int bgp_interface_address_delete(int command, struct zclient *zclient,
}
if (if_is_operative(ifc->ifp)) {
- bgp = bgp_lookup_by_vrf_id(vrf_id);
- if (bgp)
- bgp_connected_delete(bgp, ifc);
+ bgp_connected_delete(bgp, ifc);
}
connected_free(ifc);