* 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
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)
{
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;
}
\f
+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)
{
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);