diff options
author | Chris Hall <GMCH@hestia.halldom.com> | 2010-07-30 10:56:15 +0100 |
---|---|---|
committer | Chris Hall <GMCH@hestia.halldom.com> | 2010-07-30 10:56:15 +0100 |
commit | 1235bafb2cd8a5ae2e9d2f5fb149bfc5ea74969a (patch) | |
tree | 6b276ad2b46b8af8f73668938eea79813c3cb01a | |
parent | 5992b25ebee1ef68a6f0c9aaa9c67f9f7e6d74e9 (diff) | |
download | quagga-1235bafb2cd8a5ae2e9d2f5fb149bfc5ea74969a.tar.bz2 quagga-1235bafb2cd8a5ae2e9d2f5fb149bfc5ea74969a.tar.xz |
Avoid creating neighbor with same address as another.
With bgp multiple-instance it was possible to create a neighbor in one
"view" with the same addres as a neighbor in another view (or the main,
unnamed view).
To do so was a mistake, since (in particular) the accept() mechanism
depends on finding the neighbor by its address -- so two neighbors with
the same address == confusion.
Attempting to create two neighbors with the same address is now
treated as an error, at the command level.
Also, added "-rdynamic" to the CFLAGS for gcc in configure.ac. This
improves the output from the stack traceback in the event of an
assert or other failure.
-rw-r--r-- | bgpd/bgp_vty.c | 3 | ||||
-rw-r--r-- | bgpd/bgpd.c | 8 | ||||
-rw-r--r-- | bgpd/bgpd.h | 3 | ||||
-rwxr-xr-x | configure.ac | 2 |
4 files changed, 14 insertions, 2 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index d99638b2..222e4485 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -219,6 +219,9 @@ bgp_vty_return (struct vty *vty, int ret) case BGP_ERR_TCPSIG_FAILED: str = "Error while applying TCP-Sig to session(s)"; break; + case BGP_ERR_PEER_EXISTS: + str = "Cannot have the same neighbor in different bgp views"; + break; } if (str) { diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 30b882b6..f9e2ed93 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -761,6 +761,10 @@ peer_remote_as (struct bgp *bgp, union sockunion *su, as_t *as, else local_as = bgp->as; + /* Check that the neighbor IP is unique */ + if (peer_lookup (NULL, su) != NULL) + return BGP_ERR_PEER_EXISTS ; + /* TODO: report bug... if is IPv4 unicast, may implicitly activate */ /* If this is IPv4 unicast configuration and "no bgp default @@ -1340,6 +1344,10 @@ peer_group_bind (struct bgp *bgp, union sockunion *su, if (! group->conf->as) return BGP_ERR_PEER_GROUP_NO_REMOTE_AS; + /* Check that the neighbor IP is unique */ + if (peer_lookup (NULL, su) != NULL) + return BGP_ERR_PEER_EXISTS ; + peer = bgp_peer_create (su, bgp, bgp->as, group->conf->as, afi, safi); peer->group = group; peer->af_group[afi][safi] = 1; diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 7a53c511..ee8efa1b 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -398,7 +398,8 @@ enum bgp_clear_type #define BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP -27 #define BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS -28 #define BGP_ERR_TCPSIG_FAILED -29 -#define BGP_ERR_MAX -30 +#define BGP_ERR_PEER_EXISTS -30 +#define BGP_ERR_MAX -31 extern struct bgp_master *bm; diff --git a/configure.ac b/configure.ac index b34c69ff..865e84ed 100755 --- a/configure.ac +++ b/configure.ac @@ -128,7 +128,7 @@ if test "x${cflags_specified}" = "x" ; then CFLAGS="${CFLAGS} -Wbad-function-cast -Wwrite-strings" CFLAGS="${CFLAGS} -Wmissing-prototypes -Wmissing-declarations" CFLAGS="${CFLAGS} -Wchar-subscripts -Wcast-qual" - CFLAGS="${CFLAGS} -pthread" + CFLAGS="${CFLAGS} -pthread -rdynamic" # TODO: conditionally addd -Wpacked if handled AC_MSG_RESULT([gcc default]) ;; |