summaryrefslogtreecommitdiffstats
path: root/ospfd
diff options
context:
space:
mode:
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/Makefile.am2
-rw-r--r--ospfd/ospf_ase.c2
-rw-r--r--ospfd/ospf_lsdb.c1
-rw-r--r--ospfd/ospf_main.c20
-rw-r--r--ospfd/ospf_packet.c7
-rw-r--r--ospfd/ospf_vty.c64
-rw-r--r--ospfd/ospfd.c62
-rw-r--r--ospfd/ospfd.h5
8 files changed, 52 insertions, 111 deletions
diff --git a/ospfd/Makefile.am b/ospfd/Makefile.am
index 2e4d5c8e..bed90d7b 100644
--- a/ospfd/Makefile.am
+++ b/ospfd/Makefile.am
@@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in.
INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib @SNMP_INCLUDES@
-DEFS = @DEFS@ $(LOCAL_OPTS) -DSYSCONFDIR=\"$(sysconfdir)/\"
+DEFS = @DEFS@ $(LOCAL_OPTS)
INSTALL_SDATA=@INSTALL@ -m 600
lib_LTLIBRARIES = libospf.la
diff --git a/ospfd/ospf_ase.c b/ospfd/ospf_ase.c
index 7bddf3f4..5d0cae42 100644
--- a/ospfd/ospf_ase.c
+++ b/ospfd/ospf_ase.c
@@ -157,6 +157,7 @@ ospf_ase_forward_address_check (struct ospf *ospf, struct in_addr fwd_addr)
return 1;
}
+#if 0
/* Calculate ASBR route. */
static struct ospf_route *
ospf_ase_calculate_asbr_route (struct ospf *ospf,
@@ -237,6 +238,7 @@ ospf_ase_calculate_asbr_route (struct ospf *ospf,
return asbr_route;
}
+#endif
static struct ospf_route *
ospf_ase_calculate_new_route (struct ospf_lsa *lsa,
diff --git a/ospfd/ospf_lsdb.c b/ospfd/ospf_lsdb.c
index 2e1bdedf..c906f052 100644
--- a/ospfd/ospf_lsdb.c
+++ b/ospfd/ospf_lsdb.c
@@ -75,7 +75,6 @@ ospf_lsdb_cleanup (struct ospf_lsdb *lsdb)
static void
lsdb_prefix_set (struct prefix_ls *lp, struct ospf_lsa *lsa)
{
- memset (lp, 0, sizeof (struct prefix_ls));
lp->family = 0;
lp->prefixlen = 64;
lp->id = lsa->data->id;
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c
index 8b9a3458..0e9e182a 100644
--- a/ospfd/ospf_main.c
+++ b/ospfd/ospf_main.c
@@ -38,6 +38,7 @@
#include "memory.h"
#include "privs.h"
#include "sigevent.h"
+#include "paths.h"
#include "ospfd/ospfd.h"
#include "ospfd/ospf_interface.h"
@@ -72,12 +73,13 @@ struct zebra_privs_t ospfd_privs =
};
/* Configuration filename and directory. */
-char config_default[] = SYSCONFDIR OSPF_DEFAULT_CONFIG;
+char config_default[MAXPATHLEN];
/* OSPFd options. */
struct option longopts[] =
{
{ "daemon", no_argument, NULL, 'd'},
+ { "namespace", required_argument, NULL, 'N'},
{ "config_file", required_argument, NULL, 'f'},
{ "pid_file", required_argument, NULL, 'i'},
{ "dryrun", no_argument, NULL, 'C'},
@@ -96,8 +98,11 @@ struct option longopts[] =
/* Master of threads. */
struct thread_master *master;
+/* pid_file default value */
+static char pid_file_default[MAXPATHLEN];
+
/* Process ID saved for use by init system */
-const char *pid_file = PATH_OSPFD_PID;
+const char *pid_file = pid_file_default;
#ifdef SUPPORT_OSPF_API
extern int ospf_apiserver_enable;
@@ -114,6 +119,7 @@ usage (char *progname, int status)
printf ("Usage : %s [OPTION...]\n\
Daemon which manages OSPF.\n\n\
-d, --daemon Runs in daemon mode\n\
+-N, --namespace Insert argument into all paths\n\
-f, --config_file Set configuration file name\n\
-i, --pid_file Set process identifier file name\n\
-A, --vty_addr Set vty's bind address\n\
@@ -214,7 +220,7 @@ main (int argc, char **argv)
{
int opt;
- opt = getopt_long (argc, argv, "df:i:hA:P:u:g:avC", longopts, 0);
+ opt = getopt_long (argc, argv, "dN:f:i:hA:P:u:g:avC", longopts, 0);
if (opt == EOF)
break;
@@ -226,6 +232,9 @@ main (int argc, char **argv)
case 'd':
daemon_mode = 1;
break;
+ case 'N':
+ path_set_namespace (optarg);
+ break;
case 'f':
config_file = optarg;
break;
@@ -274,6 +283,9 @@ main (int argc, char **argv)
}
}
+ strcpy (config_default, path_config (OSPF_CONFIG_NAME));
+ strcpy (pid_file_default, path_state (OSPF_PID_NAME));
+
/* Initializations. */
master = om->master;
@@ -324,7 +336,7 @@ main (int argc, char **argv)
pid_output (pid_file);
/* Create VTY socket */
- vty_serv_sock (vty_addr, vty_port, OSPF_VTYSH_PATH);
+ vty_serv_sock (vty_addr, vty_port, path_state (OSPF_VTY_NAME));
/* Print banner. */
zlog_notice ("OSPFd %s starting: vty@%d", QUAGGA_VERSION, vty_port);
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index 8f61ed1a..1066e64f 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -1724,17 +1724,17 @@ ospf_ls_upd (struct ip *iph, struct ospf_header *ospfh,
/* Reject from STUB or NSSA */
if (nbr->oi->area->external_routing != OSPF_AREA_DEFAULT)
{
- DISCARD_LSA (lsa, 1);
if (IS_DEBUG_OSPF_NSSA)
zlog_debug("Incoming External LSA Discarded: We are NSSA/STUB Area");
+ DISCARD_LSA (lsa, 1);
}
if (lsa->data->type == OSPF_AS_NSSA_LSA)
if (nbr->oi->area->external_routing != OSPF_AREA_NSSA)
{
- DISCARD_LSA (lsa,2);
if (IS_DEBUG_OSPF_NSSA)
zlog_debug("Incoming NSSA LSA Discarded: Not NSSA Area");
+ DISCARD_LSA (lsa,2);
}
/* Find the LSA in the current database. */
@@ -1953,7 +1953,8 @@ ospf_ls_upd (struct ip *iph, struct ospf_header *ospfh,
}
}
}
-
+#undef DISCARD_LSA
+
assert (listcount (lsas) == 0);
list_delete (lsas);
}
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index e144c299..d024a2ac 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -93,29 +93,6 @@ ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
static int
-str2distribute_source (const char *str, int *source)
-{
- /* Sanity check. */
- if (str == NULL)
- return 0;
-
- if (strncmp (str, "k", 1) == 0)
- *source = ZEBRA_ROUTE_KERNEL;
- else if (strncmp (str, "c", 1) == 0)
- *source = ZEBRA_ROUTE_CONNECT;
- else if (strncmp (str, "s", 1) == 0)
- *source = ZEBRA_ROUTE_STATIC;
- else if (strncmp (str, "r", 1) == 0)
- *source = ZEBRA_ROUTE_RIP;
- else if (strncmp (str, "b", 1) == 0)
- *source = ZEBRA_ROUTE_BGP;
- else
- return 0;
-
- return 1;
-}
-
-static int
str2metric (const char *str, int *metric)
{
/* Sanity check. */
@@ -3511,7 +3488,7 @@ show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
return 0;
}
-const char *show_database_desc[] =
+static const char *show_database_desc[] =
{
"unknown",
"Router Link States",
@@ -3529,10 +3506,7 @@ const char *show_database_desc[] =
#endif /* HAVE_OPAQUE_LSA */
};
-#define SHOW_OSPF_COMMON_HEADER \
- "Link ID ADV Router Age Seq# CkSum"
-
-const char *show_database_header[] =
+static const char *show_database_header[] =
{
"",
"Link ID ADV Router Age Seq# CkSum Link count",
@@ -3550,16 +3524,6 @@ const char *show_database_header[] =
#endif /* HAVE_OPAQUE_LSA */
};
-const char *show_lsa_flags[] =
-{
- "Self-originated",
- "Checked",
- "Received",
- "Approved",
- "Discard",
- "Translated",
-};
-
static void
show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
{
@@ -5831,7 +5795,8 @@ DEFUN (ospf_redistribute_source_metric_type,
int metric = -1;
/* Get distribute source. */
- if (!str2distribute_source (argv[0], &source))
+ source = proto_redistnum(AFI_IP, argv[0]);
+ if (source < 0 || source == ZEBRA_ROUTE_OSPF)
return CMD_WARNING;
/* Get metric value. */
@@ -5892,7 +5857,8 @@ DEFUN (ospf_redistribute_source_type_metric,
int metric = -1;
/* Get distribute source. */
- if (!str2distribute_source (argv[0], &source))
+ source = proto_redistnum(AFI_IP, argv[0]);
+ if (source < 0 || source == ZEBRA_ROUTE_OSPF)
return CMD_WARNING;
/* Get metric value. */
@@ -5956,7 +5922,8 @@ DEFUN (ospf_redistribute_source_metric_routemap,
int metric = -1;
/* Get distribute source. */
- if (!str2distribute_source (argv[0], &source))
+ source = proto_redistnum(AFI_IP, argv[0]);
+ if (source < 0 || source == ZEBRA_ROUTE_OSPF)
return CMD_WARNING;
/* Get metric value. */
@@ -5989,7 +5956,8 @@ DEFUN (ospf_redistribute_source_type_routemap,
int type = -1;
/* Get distribute source. */
- if (!str2distribute_source (argv[0], &source))
+ source = proto_redistnum(AFI_IP, argv[0]);
+ if (source < 0 || source == ZEBRA_ROUTE_OSPF)
return CMD_WARNING;
/* Get metric value. */
@@ -6017,7 +5985,8 @@ DEFUN (ospf_redistribute_source_routemap,
int source;
/* Get distribute source. */
- if (!str2distribute_source (argv[0], &source))
+ source = proto_redistnum(AFI_IP, argv[0]);
+ if (source < 0 || source == ZEBRA_ROUTE_OSPF)
return CMD_WARNING;
if (argc == 2)
@@ -6038,7 +6007,8 @@ DEFUN (no_ospf_redistribute_source,
struct ospf *ospf = vty->index;
int source;
- if (!str2distribute_source (argv[0], &source))
+ source = proto_redistnum(AFI_IP, argv[0]);
+ if (source < 0 || source == ZEBRA_ROUTE_OSPF)
return CMD_WARNING;
ospf_routemap_unset (ospf, source);
@@ -6057,7 +6027,8 @@ DEFUN (ospf_distribute_list_out,
int source;
/* Get distribute source. */
- if (!str2distribute_source (argv[1], &source))
+ source = proto_redistnum(AFI_IP, argv[0]);
+ if (source < 0 || source == ZEBRA_ROUTE_OSPF)
return CMD_WARNING;
return ospf_distribute_list_out_set (ospf, source, argv[0]);
@@ -6075,7 +6046,8 @@ DEFUN (no_ospf_distribute_list_out,
struct ospf *ospf = vty->index;
int source;
- if (!str2distribute_source (argv[1], &source))
+ source = proto_redistnum(AFI_IP, argv[0]);
+ if (source < 0 || source == ZEBRA_ROUTE_OSPF)
return CMD_WARNING;
return ospf_distribute_list_out_unset (ospf, source, argv[0]);
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index b86986b5..a7553e73 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -71,6 +71,8 @@ static void ospf_area_free (struct ospf_area *);
static void ospf_network_run (struct prefix *, struct ospf_area *);
static void ospf_network_run_interface (struct prefix *, struct ospf_area *,
struct interface *);
+static int ospf_network_match_iface (const struct connected *,
+ const struct prefix *);
static void ospf_finish_final (struct ospf *);
#define OSPF_EXTERNAL_LSA_ORIGINATE_DELAY 1
@@ -589,7 +591,7 @@ ospf_area_new (struct ospf *ospf, struct in_addr area_id)
return new;
}
-void
+static void
ospf_area_free (struct ospf_area *area)
{
struct route_node *rn;
@@ -719,7 +721,7 @@ ospf_network_new (struct in_addr area_id, int format)
return new;
}
-void
+static void
ospf_network_free (struct ospf *ospf, struct ospf_network *network)
{
ospf_area_check_free (ospf, network->area_id);
@@ -832,62 +834,14 @@ ospf_network_unset (struct ospf *ospf, struct prefix_ipv4 *p,
/* Check whether interface matches given network
* returns: 1, true. 0, false
*/
-int
-ospf_network_match_iface(struct connected *co, struct prefix *net)
+static int
+ospf_network_match_iface(const struct connected *co, const struct prefix *net)
{
-/* #define COMPATIBILITY_MODE */
- /* The old code used to have a special case for PtP interfaces:
-
- if (if_is_pointopoint (co->ifp) && co->destination &&
- IPV4_ADDR_SAME ( &(co->destination->u.prefix4), &(net->u.prefix4)))
- return 1;
-
- The new approach is much more general. If a peer address is supplied,
- then we are routing to that prefix, so that's the address to compare
- against (not the local address, which may not be unique).
- */
-#ifndef COMPATIBILITY_MODE
/* new approach: more elegant and conceptually clean */
return prefix_match(net, CONNECTED_PREFIX(co));
-#else /* COMPATIBILITY_MODE */
- /* match old (strange?) behavior */
-
- /* Behaviour to match both Cisco where:
- * iface address lies within network specified -> ospf
- * and zebra 0.9[2ish-3]:
- * PtP special case: network specified == iface peer addr -> ospf
- */
-
- /* For PtP, match if peer address matches network address exactly.
- * This can be addr/32 or addr/p for p < 32, but the addr must match
- * exactly; this is not a test for falling within the prefix. This
- * test is solely for compatibility with zebra.
- */
- if (CONNECTED_PEER(co) &&
- IPV4_ADDR_SAME ( &(co->destination->u.prefix4), &(net->u.prefix4)))
- return 1;
-
-#if 0
- /* Decline to accept PtP if dst address does not match the
- * prefix. (ifdefed out because this is a workaround, not the
- * desired behavior.) */
- if (if_is_pointopoint (co->ifp) &&
- ! prefix_match (net, co->destination))
- return 0;
-#endif
-
- /* If the address is within the prefix, accept. Note that this
- * applies to PtP as well as other types.
- */
- if (prefix_match (net, co->address))
- return 1;
-
- return 0; /* no match */
-
-#endif /* COMPATIBILITY_MODE */
}
-void
+static void
ospf_network_run_interface (struct prefix *p, struct ospf_area *area,
struct interface *ifp)
{
@@ -944,7 +898,7 @@ ospf_network_run_interface (struct prefix *p, struct ospf_area *area,
}
}
-void
+static void
ospf_network_run (struct prefix *p, struct ospf_area *area)
{
struct interface *ifp;
diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h
index f81c682c..64e91cef 100644
--- a/ospfd/ospfd.h
+++ b/ospfd/ospfd.h
@@ -48,7 +48,9 @@
#define OSPF_VL_IP_TTL 100
/* Default configuration file name for ospfd. */
-#define OSPF_DEFAULT_CONFIG "ospfd.conf"
+#define OSPF_CONFIG_NAME "ospfd.conf"
+#define OSPF_PID_NAME "ospfd.pid"
+#define OSPF_VTY_NAME "ospfd.vty"
/* Architectual Constants */
#ifdef DEBUG
@@ -558,7 +560,6 @@ extern struct ospf *ospf_lookup (void);
extern struct ospf *ospf_get (void);
extern void ospf_finish (struct ospf *);
extern void ospf_router_id_update (struct ospf *ospf);
-extern int ospf_network_match_iface (struct connected *, struct prefix *);
extern int ospf_network_set (struct ospf *, struct prefix_ipv4 *,
struct in_addr);
extern int ospf_network_unset (struct ospf *, struct prefix_ipv4 *,