summaryrefslogtreecommitdiff
path: root/bgpd/bgp_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_main.c')
-rw-r--r--bgpd/bgp_main.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index 23514dece4..9607d381d9 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -40,6 +40,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "queue.h"
#include "vrf.h"
#include "bfd.h"
+#include "sockopt.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_attr.h"
@@ -60,6 +61,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#endif
/* bgpd options, we use GNU getopt library. */
+#define OPTION_VTYSOCK 1000
static const struct option longopts[] =
{
{ "daemon", no_argument, NULL, 'd'},
@@ -70,6 +72,7 @@ static const struct option longopts[] =
{ "listenon", required_argument, NULL, 'l'},
{ "vty_addr", required_argument, NULL, 'A'},
{ "vty_port", required_argument, NULL, 'P'},
+ { "vty_socket", required_argument, NULL, OPTION_VTYSOCK },
{ "retain", no_argument, NULL, 'r'},
{ "no_kernel", no_argument, NULL, 'n'},
{ "user", required_argument, NULL, 'u'},
@@ -112,6 +115,9 @@ static struct quagga_signal_t bgp_signals[] =
/* Configuration file and directory. */
char config_default[] = SYSCONFDIR BGP_DEFAULT_CONFIG;
+/* VTY Socket prefix */
+char vty_sock_path[MAXPATHLEN] = BGP_VTYSH_PATH;
+
/* Route retain mode flag. */
static int retain_mode = 0;
@@ -124,6 +130,7 @@ static const char *pid_file = PATH_BGPD_PID;
/* VTY port number and address. */
int vty_port = BGP_VTY_PORT;
char *vty_addr = NULL;
+char *vty_sock_name;
/* privileges */
static zebra_capabilities_t _caps_p [] =
@@ -166,6 +173,7 @@ redistribution between different routing protocols.\n\n\
-l, --listenon Listen on specified address (implies -n)\n\
-A, --vty_addr Set vty's bind address\n\
-P, --vty_port Set vty's port number\n\
+ --vty_socket Override vty socket path\n\
-r, --retain When program terminates, retain added route by bgpd.\n\
-n, --no_kernel Do not install route to kernel.\n\
-u, --user User to run as\n\
@@ -196,7 +204,7 @@ sighup (void)
vty_read_config (config_file, config_default);
/* Create VTY's socket */
- vty_serv_sock (vty_addr, vty_port, BGP_VTYSH_PATH);
+ vty_serv_sock (vty_addr, vty_port, vty_sock_path);
/* Try to return to normal operation. */
}
@@ -303,6 +311,8 @@ bgp_exit (int status)
if (zlog_default)
closezlog (zlog_default);
+ memset (bm, 0, sizeof (*bm));
+
if (bgp_debug_count())
log_memstats_stderr ("bgpd");
exit (status);
@@ -470,6 +480,9 @@ main (int argc, char **argv)
if (vty_port <= 0 || vty_port > 0xffff)
vty_port = BGP_VTY_PORT;
break;
+ case OPTION_VTYSOCK:
+ set_socket_path(vty_sock_path, BGP_VTYSH_PATH, optarg, sizeof (vty_sock_path));
+ break;
case 'r':
retain_mode = 1;
break;
@@ -545,7 +558,7 @@ main (int argc, char **argv)
pid_output (pid_file);
/* Make bgp vty socket. */
- vty_serv_sock (vty_addr, vty_port, BGP_VTYSH_PATH);
+ vty_serv_sock (vty_addr, vty_port, vty_sock_path);
/* Print banner. */
zlog_notice ("BGPd %s starting: vty@%d, bgp@%s:%d", FRR_COPYRIGHT,