summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
authorPaul Jakma <paul@quagga.net>2012-05-01 16:24:35 +0100
committerPaul Jakma <paul@quagga.net>2012-05-02 11:02:11 +0100
commit7621f336e2f346edee43227f0b1ef93fe769720b (patch)
tree2bda36681214336bf55345cd47efb2c25fc460c2 /bgpd
parent1dba254e107dd0c4254d58e9304fc6293b46fd4d (diff)
bgpd: Make socket init separate, so unit tests work again.
* Separate out BGP socket initialisation from bgp_get, and make it an explicit function. Allows unit tests to work again and probably also benefits dry-run. * bgpd.c: (bgp_get) move socket init out... (bgp_socket_init) to here * bgp_main.c: and call it after dry-run. * bgpd.h: (bgp_socket_init) add prototype
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_main.c6
-rw-r--r--bgpd/bgpd.c16
-rw-r--r--bgpd/bgpd.h1
3 files changed, 16 insertions, 7 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index 0f1d4829..5abc8756 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -441,6 +441,12 @@ main (int argc, char **argv)
if(dryrun)
return(0);
+ if (bgp_socket_init ())
+ {
+ zlog_err ("BGP socket creation failed");
+ return 1;
+ }
+
/* Turn into daemon if daemon_mode is set. */
if (daemon_mode && daemon (0, 0) < 0)
{
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 9c8eda88..ab27783f 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -2055,13 +2055,6 @@ bgp_get (struct bgp **bgp_val, as_t *as, const char *name)
bgp_router_id_set(bgp, &router_id_zebra);
*bgp_val = bgp;
- /* Create BGP server socket, if first instance. */
- if (list_isempty(bm->bgp))
- {
- if (bgp_socket (bm->port, bm->address) < 0)
- return BGP_ERR_INVALID_VALUE;
- }
-
listnode_add (bm->bgp, bgp);
return 0;
@@ -5341,6 +5334,15 @@ bgp_master_init (void)
}
+int
+bgp_socket_init (void)
+{
+ /* Create BGP server socket */
+ if (bgp_socket (bm->port, bm->address) < 0)
+ return BGP_ERR_INVALID_VALUE;
+ return 0;
+}
+
void
bgp_init (void)
{
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 09a3435c..d1e4f8e9 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -844,6 +844,7 @@ extern void bgp_config_write_family_header (struct vty *, afi_t, safi_t, int *);
extern void bgp_master_init (void);
extern void bgp_init (void);
+extern int bgp_socket_init (void);
extern void bgp_route_map_init (void);
extern int bgp_option_set (int);