summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/ChangeLog8
-rw-r--r--bgpd/bgp_vty.c8
-rw-r--r--bgpd/bgp_zebra.c64
-rw-r--r--bgpd/bgpd.c40
-rw-r--r--bgpd/bgpd.h1
5 files changed, 30 insertions, 91 deletions
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog
index 2bcce1c7..d5ab3282 100644
--- a/bgpd/ChangeLog
+++ b/bgpd/ChangeLog
@@ -1,3 +1,11 @@
+2004-10-03 James R. Leu <jleu at mindspring.com>
+
+ * bgp_vty.c: Router id from zebra can be manually overriden.
+ * bgp_zebra.c: Read router id related messages from zebra daemon.
+ Remove own code related with router id selection.
+ * bgpd.c, bgpd.h: Remove own router id selection code. Use the one
+ from zebra daemon if it isn't manually overriden.
+
2004-09-26 Hasso Tepper <hasso at quagga.net>
* bgp_aspath.c, bgp_packet.c, bgp_vty.c: Fix compiler warnings.
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 27a3c2eb..6b3c4988 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -41,6 +41,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "bgpd/bgp_zebra.h"
#include "bgpd/bgp_table.h"
+extern struct in_addr router_id_zebra;
+
/* Utility function to get address family from current node. */
afi_t
bgp_node_afi (struct vty *vty)
@@ -400,6 +402,7 @@ DEFUN (bgp_router_id,
return CMD_WARNING;
}
+ bgp->router_id_static = id;
bgp_router_id_set (bgp, &id);
return CMD_SUCCESS;
@@ -427,14 +430,15 @@ DEFUN (no_bgp_router_id,
return CMD_WARNING;
}
- if (! IPV4_ADDR_SAME (&bgp->router_id, &id))
+ if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
{
vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
- bgp_router_id_unset (bgp);
+ bgp->router_id_static.s_addr = 0;
+ bgp_router_id_set (bgp, &router_id_zebra);
return CMD_SUCCESS;
}
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 42b8fc74..6226a938 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -39,61 +39,25 @@ Boston, MA 02111-1307, USA. */
/* All information about zebra. */
static struct zclient *zclient = NULL;
+struct in_addr router_id_zebra;
-/* Update default router id. */
+/* Router-id update message from zebra. */
int
-bgp_if_update (struct interface *ifp)
+bgp_router_id_update (int command, struct zclient *zclient, zebra_size_t length)
{
- struct bgp *bgp;
- struct listnode *cn;
+ struct prefix router_id;
struct listnode *nn;
- struct listnode *nm;
- struct peer *peer;
-
- for (cn = listhead (ifp->connected); cn; nextnode (cn))
- {
- struct connected *co;
- struct in_addr addr;
-
- co = getdata (cn);
-
- if (co->address->family == AF_INET)
- {
- addr = co->address->u.prefix4;
-
- /* Ignore NET127. */
- if (IPV4_NET127 (ntohl (addr.s_addr)))
- continue;
-
- LIST_LOOP (bm->bgp, bgp, nn)
- {
- /* Respect configured router id */
- if (! (bgp->config & BGP_CONFIG_ROUTER_ID))
- if (ntohl (bgp->router_id.s_addr) < ntohl (addr.s_addr))
- {
- bgp->router_id = addr;
- LIST_LOOP (bgp->peer, peer, nm)
- {
- peer->local_id = addr;
- }
- }
- }
- }
- }
- return 0;
-}
+ struct bgp *bgp;
-int
-bgp_if_update_all ()
-{
- struct listnode *node;
- struct interface *ifp;
+ zebra_router_id_update_read(zclient->ibuf,&router_id);
+ router_id_zebra = router_id.u.prefix4;
- for (node = listhead (iflist); node; node = nextnode (node))
+ LIST_LOOP (bm->bgp, bgp, nn)
{
- ifp = getdata (node);
- bgp_if_update (ifp);
+ if (!bgp->router_id_static.s_addr)
+ bgp_router_id_set (bgp, &router_id.u.prefix4);
}
+
return 0;
}
@@ -104,7 +68,6 @@ bgp_interface_add (int command, struct zclient *zclient, zebra_size_t length)
struct interface *ifp;
ifp = zebra_interface_add_read (zclient->ibuf);
- bgp_if_update (ifp);
return 0;
}
@@ -206,8 +169,6 @@ bgp_interface_address_add (int command, struct zclient *zclient,
if (ifc == NULL)
return 0;
- bgp_if_update (ifc->ifp);
-
if (if_is_operative (ifc->ifp))
bgp_connected_add (ifc);
@@ -225,8 +186,6 @@ bgp_interface_address_delete (int command, struct zclient *zclient,
if (ifc == NULL)
return 0;
- bgp_if_update (ifc->ifp);
-
if (if_is_operative (ifc->ifp))
bgp_connected_delete (ifc);
@@ -987,6 +946,7 @@ bgp_zebra_init (int enable)
/* Set default values. */
zclient = zclient_new ();
zclient_init (zclient, ZEBRA_ROUTE_BGP);
+ zclient->router_id_update = bgp_router_id_update;
zclient->interface_add = bgp_interface_add;
zclient->interface_delete = bgp_interface_delete;
zclient->interface_address_add = bgp_interface_address_add;
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 6afbe959..61ffe279 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -63,6 +63,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
/* BGP process wide configuration. */
static struct bgp_master bgp_master;
+extern struct in_addr router_id_zebra;
+
/* BGP process wide configuration pointer to export. */
struct bgp_master *bm;
@@ -182,42 +184,6 @@ bgp_router_id_set (struct bgp *bgp, struct in_addr *id)
return 0;
}
-/* Unset BGP router identifier. */
-int
-bgp_router_id_unset (struct bgp *bgp)
-{
- struct peer *peer;
- struct listnode *nn;
-
- if (! bgp_config_check (bgp, BGP_CONFIG_ROUTER_ID))
- return 0;
-
- bgp->router_id.s_addr = 0;
- bgp_config_unset (bgp, BGP_CONFIG_ROUTER_ID);
-
- /* Clear peer router id configuration. */
- LIST_LOOP (bgp->peer, peer, nn)
- {
- peer->local_id.s_addr = 0;
- }
-
- /* Set router-id from interface's address. */
- bgp_if_update_all ();
-
- /* Reset all BGP sessions to use new router-id. */
- LIST_LOOP (bgp->peer, peer, nn)
- {
- if (peer->status == Established)
- {
- peer->last_reset = PEER_DOWN_RID_CHANGE;
- bgp_notify_send (peer, BGP_NOTIFY_CEASE,
- BGP_NOTIFY_CEASE_CONFIG_CHANGE);
- }
- }
-
- return 0;
-}
-
/* BGP's cluster-id control. */
int
bgp_cluster_id_set (struct bgp *bgp, struct in_addr *cluster_id)
@@ -1910,7 +1876,7 @@ bgp_get (struct bgp **bgp_val, as_t *as, char *name)
bgp = bgp_create (as, name);
listnode_add (bm->bgp, bgp);
- bgp_if_update_all ();
+ bgp_router_id_set(bgp, &router_id_zebra);
*bgp_val = bgp;
return 0;
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 61472d85..ed3f4d18 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -76,6 +76,7 @@ struct bgp
/* BGP router identifier. */
struct in_addr router_id;
+ struct in_addr router_id_static;
/* BGP route reflector cluster ID. */
struct in_addr cluster_id;