#include "stream.h"
#include "log.h"
#include "memory.h"
+#include "memory_vty.h"
#include "privs.h"
#include "sigevent.h"
#include "zclient.h"
#include "vrf.h"
+#include "sockopt.h"
#include "ospfd/ospfd.h"
#include "ospfd/ospf_interface.h"
struct zebra_privs_t ospfd_privs =
{
-#if defined(QUAGGA_USER) && defined(QUAGGA_GROUP)
- .user = QUAGGA_USER,
- .group = QUAGGA_GROUP,
+#if defined(FRR_USER) && defined(FRR_GROUP)
+ .user = FRR_USER,
+ .group = FRR_GROUP,
#endif
#if defined(VTY_GROUP)
.vty_group = VTY_GROUP,
char config_default[100];
/* OSPFd options. */
+#define OPTION_VTYSOCK 1000
struct option longopts[] =
{
{ "daemon", no_argument, NULL, 'd'},
{ "help", no_argument, NULL, 'h'},
{ "vty_addr", required_argument, NULL, 'A'},
{ "vty_port", required_argument, NULL, 'P'},
+ { "vty_socket", required_argument, NULL, OPTION_VTYSOCK},
{ "user", required_argument, NULL, 'u'},
{ "group", required_argument, NULL, 'g'},
{ "apiserver", no_argument, NULL, 'a'},
/* OSPFd program name */
+/* VTY Socket prefix */
+char vty_sock_path[MAXPATHLEN] = OSPF_VTYSH_PATH;
+
/* Master of threads. */
struct thread_master *master;
-z, --socket Set path of zebra socket\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\
-u, --user User to run as\n\
-g, --group Group to run as\n\
-a. --apiserver Enable OSPF apiserver\n\
-C, --dryrun Check configuration for validity and exit\n\
-h, --help Display this help and exit\n\
\n\
-Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS);
+Report bugs to %s\n", progname, FRR_BUG_ADDRESS);
}
exit (status);
}
ospf_apiserver_enable = 0;
#endif /* SUPPORT_OSPF_API */
+ strcpy(pid_file, PATH_OSPFD_PID);
+
/* get program name */
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
if (vty_port <= 0 || vty_port > 0xffff)
vty_port = OSPF_VTY_PORT;
break;
+ case OPTION_VTYSOCK:
+ set_socket_path(vty_sock_path, OSPF_VTYSH_PATH, optarg, sizeof (vty_sock_path));
+ break;
case 'u':
ospfd_privs.user = optarg;
break;
#ifdef HAVE_SNMP
ospf_snmp_init ();
#endif /* HAVE_SNMP */
-#ifdef HAVE_OPAQUE_LSA
ospf_opaque_init ();
-#endif /* HAVE_OPAQUE_LSA */
/* Need to initialize the default ospf structure, so the interface mode
commands can be duly processed if they are received before 'router ospf',
exit (1);
}
+ /* Create PID file */
+ if (instance)
+ {
+ char pidfile_temp[100];
+
+ /* Override the single file with file including instance
+ number in case of multi-instance */
+ if (strrchr(pid_file, '/') != NULL)
+ /* cut of pid_file at last / char * to get directory */
+ *strrchr(pid_file, '/') = '\0';
+ else
+ /* pid_file contains no directory - should never happen, but deal with it anyway */
+ /* throw-away all pid_file and assume it's only the filename */
+ pid_file[0] = '\0';
+
+ snprintf(pidfile_temp, sizeof(pidfile_temp), "%s/ospfd-%d.pid", pid_file, instance );
+ strlcpy(pid_file, pidfile_temp, sizeof(pid_file));
+ }
+ /* Process id file create. */
+ pid_output (pid_file);
+
/* Create VTY socket */
if (instance)
{
- sprintf(pid_file, "/var/run/quagga/ospfd-%d.pid", instance);
- sprintf(vty_path, "/var/run/quagga/ospfd-%d.vty", instance);
+ /* Multi-Instance. Use only path section of vty_sock_path with new file incl instance */
+ if (strrchr(vty_sock_path, '/') != NULL)
+ {
+ /* cut of pid_file at last / char * to get directory */
+ *strrchr(vty_sock_path, '/') = '\0';
+ }
+ else
+ {
+ /* pid_file contains no directory - should never happen, but deal with it anyway */
+ /* throw-away all pid_file and assume it's only the filename */
+ vty_sock_path[0] = '\0';
+ }
+ snprintf(vty_path, sizeof(vty_path), "%s/ospfd-%d.vty", vty_sock_path, instance );
}
else
{
- strcpy(pid_file, PATH_OSPFD_PID);
- strcpy(vty_path, OSPF_VTYSH_PATH);
+ strlcpy(vty_path, vty_sock_path, sizeof(vty_path));
}
- /* Process id file create. */
- pid_output (pid_file);
-
vty_serv_sock (vty_addr, vty_port, vty_path);
/* Print banner. */
- zlog_notice ("OSPFd %s starting: vty@%d, %s", QUAGGA_VERSION, vty_port, vty_path);
+ zlog_notice ("OSPFd %s starting: vty@%d, %s", FRR_VERSION, vty_port, vty_path);
/* Fetch next active thread. */
while (thread_fetch (master, &thread))