mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-11 22:02:23 +00:00
ospfd: use new defaults mechanism (v2)
Some preprocessor constants converted to enums to make the names usable in the preprocessor. v2: better isolation between core and vty code to make future northbound conversion easier. Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
parent
8908161ff7
commit
c572fbfe2d
@ -18,24 +18,10 @@
|
||||
#ifndef _FRR_DEFAULTS_H
|
||||
#define _FRR_DEFAULTS_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#ifdef HAVE_DATACENTER
|
||||
|
||||
#define DFLT_OSPF_LOG_ADJACENCY_CHANGES 1
|
||||
#define DFLT_OSPF6_LOG_ADJACENCY_CHANGES 1
|
||||
|
||||
#else /* !HAVE_DATACENTER */
|
||||
|
||||
#define DFLT_OSPF_LOG_ADJACENCY_CHANGES 0
|
||||
#define DFLT_OSPF6_LOG_ADJACENCY_CHANGES 0
|
||||
|
||||
#endif /* !HAVE_DATACENTER */
|
||||
|
||||
/* frr_default wraps information about a default that has different
|
||||
* values depending on FRR version or default-set
|
||||
*
|
||||
|
@ -51,6 +51,11 @@
|
||||
|
||||
DEFINE_QOBJ_TYPE(ospf6)
|
||||
|
||||
FRR_CFG_DEFAULT_BOOL(OSPF6_LOG_ADJACENCY_CHANGES,
|
||||
{ .val_long = true, .match_profile = "datacenter", },
|
||||
{ .val_long = false },
|
||||
)
|
||||
|
||||
/* global ospf6d variable */
|
||||
struct ospf6 *ospf6;
|
||||
static struct ospf6_master ospf6_master;
|
||||
@ -179,11 +184,6 @@ static struct ospf6 *ospf6_create(vrf_id_t vrf_id)
|
||||
|
||||
o->distance_table = route_table_init();
|
||||
|
||||
/* Enable "log-adjacency-changes" */
|
||||
#if DFLT_OSPF6_LOG_ADJACENCY_CHANGES
|
||||
SET_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
|
||||
#endif
|
||||
|
||||
QOBJ_REG(o, ospf6);
|
||||
|
||||
return o;
|
||||
@ -327,6 +327,9 @@ DEFUN_NOSH (router_ospf6,
|
||||
{
|
||||
if (ospf6 == NULL) {
|
||||
ospf6 = ospf6_create(VRF_DEFAULT);
|
||||
if (DFLT_OSPF6_LOG_ADJACENCY_CHANGES)
|
||||
SET_FLAG(ospf6->config_flags,
|
||||
OSPF6_LOG_ADJACENCY_CHANGES);
|
||||
if (ospf6->router_id == 0)
|
||||
ospf6_router_id_update();
|
||||
}
|
||||
@ -1079,9 +1082,9 @@ static int config_write_ospf6(struct vty *vty)
|
||||
if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES)) {
|
||||
if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL))
|
||||
vty_out(vty, " log-adjacency-changes detail\n");
|
||||
else if (!DFLT_OSPF6_LOG_ADJACENCY_CHANGES)
|
||||
else if (!SAVE_OSPF6_LOG_ADJACENCY_CHANGES)
|
||||
vty_out(vty, " log-adjacency-changes\n");
|
||||
} else if (DFLT_OSPF6_LOG_ADJACENCY_CHANGES) {
|
||||
} else if (SAVE_OSPF6_LOG_ADJACENCY_CHANGES) {
|
||||
vty_out(vty, " no log-adjacency-changes\n");
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,12 @@ struct ospf6_master {
|
||||
uint32_t zebra_router_id;
|
||||
};
|
||||
|
||||
/* ospf6->config_flags */
|
||||
enum {
|
||||
OSPF6_LOG_ADJACENCY_CHANGES = (1 << 0),
|
||||
OSPF6_LOG_ADJACENCY_DETAIL = (1 << 1),
|
||||
};
|
||||
|
||||
/* OSPFv3 top level data structure */
|
||||
struct ospf6 {
|
||||
/* The relevant vrf_id */
|
||||
@ -68,10 +74,8 @@ struct ospf6 {
|
||||
|
||||
uint8_t flag;
|
||||
|
||||
/* Configured flags */
|
||||
/* Configuration bitmask, refer to enum above */
|
||||
uint8_t config_flags;
|
||||
#define OSPF6_LOG_ADJACENCY_CHANGES (1 << 0)
|
||||
#define OSPF6_LOG_ADJACENCY_DETAIL (1 << 1)
|
||||
|
||||
/* LSA timer parameters */
|
||||
unsigned int lsa_minarrival; /* LSA minimum arrival in milliseconds. */
|
||||
|
@ -53,6 +53,11 @@
|
||||
#include "ospfd/ospf_dump.h"
|
||||
#include "ospfd/ospf_bfd.h"
|
||||
|
||||
FRR_CFG_DEFAULT_BOOL(OSPF_LOG_ADJACENCY_CHANGES,
|
||||
{ .val_long = true, .match_profile = "datacenter", },
|
||||
{ .val_long = false },
|
||||
)
|
||||
|
||||
static const char *const ospf_network_type_str[] = {
|
||||
"Null", "POINTOPOINT", "BROADCAST", "NBMA", "POINTOMULTIPOINT",
|
||||
"VIRTUALLINK", "LOOPBACK"};
|
||||
@ -138,6 +143,7 @@ static struct ospf *ospf_cmd_lookup_ospf(struct vty *vty,
|
||||
struct ospf *ospf = NULL;
|
||||
int idx_vrf = 0, idx_inst = 0;
|
||||
const char *vrf_name = NULL;
|
||||
bool created = false;
|
||||
|
||||
*instance = 0;
|
||||
if (argv_find(argv, argc, "(1-65535)", &idx_inst))
|
||||
@ -149,18 +155,23 @@ static struct ospf *ospf_cmd_lookup_ospf(struct vty *vty,
|
||||
vrf_name = NULL;
|
||||
if (enable) {
|
||||
/* Allocate VRF aware instance */
|
||||
ospf = ospf_get(*instance, vrf_name);
|
||||
ospf = ospf_get(*instance, vrf_name, &created);
|
||||
} else {
|
||||
ospf = ospf_lookup_by_inst_name(*instance, vrf_name);
|
||||
}
|
||||
} else {
|
||||
if (enable) {
|
||||
ospf = ospf_get(*instance, NULL);
|
||||
ospf = ospf_get(*instance, NULL, &created);
|
||||
} else {
|
||||
ospf = ospf_lookup_instance(*instance);
|
||||
}
|
||||
}
|
||||
|
||||
if (created) {
|
||||
if (DFLT_OSPF_LOG_ADJACENCY_CHANGES)
|
||||
SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
|
||||
}
|
||||
|
||||
return ospf;
|
||||
}
|
||||
|
||||
@ -10358,9 +10369,9 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)
|
||||
if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) {
|
||||
if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
|
||||
vty_out(vty, " log-adjacency-changes detail\n");
|
||||
else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES)
|
||||
else if (!SAVE_OSPF_LOG_ADJACENCY_CHANGES)
|
||||
vty_out(vty, " log-adjacency-changes\n");
|
||||
} else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES) {
|
||||
} else if (SAVE_OSPF_LOG_ADJACENCY_CHANGES) {
|
||||
vty_out(vty, " no log-adjacency-changes\n");
|
||||
}
|
||||
|
||||
|
@ -293,11 +293,6 @@ static struct ospf *ospf_new(unsigned short instance, const char *name)
|
||||
new->oi_write_q = list_new();
|
||||
new->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT;
|
||||
|
||||
/* Enable "log-adjacency-changes" */
|
||||
#if DFLT_OSPF_LOG_ADJACENCY_CHANGES
|
||||
SET_FLAG(new->config, OSPF_LOG_ADJACENCY_CHANGES);
|
||||
#endif
|
||||
|
||||
QOBJ_REG(new, ospf);
|
||||
|
||||
new->fd = -1;
|
||||
@ -368,7 +363,7 @@ struct ospf *ospf_lookup_by_inst_name(unsigned short instance, const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct ospf *ospf_get(unsigned short instance, const char *name)
|
||||
struct ospf *ospf_get(unsigned short instance, const char *name, bool *created)
|
||||
{
|
||||
struct ospf *ospf;
|
||||
|
||||
@ -379,6 +374,7 @@ struct ospf *ospf_get(unsigned short instance, const char *name)
|
||||
else
|
||||
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
||||
|
||||
*created = (ospf == NULL);
|
||||
if (ospf == NULL) {
|
||||
ospf = ospf_new(instance, name);
|
||||
ospf_add(ospf);
|
||||
@ -392,11 +388,12 @@ struct ospf *ospf_get(unsigned short instance, const char *name)
|
||||
return ospf;
|
||||
}
|
||||
|
||||
struct ospf *ospf_get_instance(unsigned short instance)
|
||||
struct ospf *ospf_get_instance(unsigned short instance, bool *created)
|
||||
{
|
||||
struct ospf *ospf;
|
||||
|
||||
ospf = ospf_lookup_instance(instance);
|
||||
*created = (ospf == NULL);
|
||||
if (ospf == NULL) {
|
||||
ospf = ospf_new(instance, NULL /* VRF_DEFAULT*/);
|
||||
ospf_add(ospf);
|
||||
@ -574,7 +571,6 @@ static void ospf_finish_final(struct ospf *ospf)
|
||||
struct ospf_vl_data *vl_data;
|
||||
struct listnode *node, *nnode;
|
||||
int i;
|
||||
unsigned short instance = 0;
|
||||
|
||||
QOBJ_UNREG(ospf);
|
||||
|
||||
@ -745,9 +741,6 @@ static void ospf_finish_final(struct ospf *ospf)
|
||||
ospf_distance_reset(ospf);
|
||||
route_table_finish(ospf->distance_table);
|
||||
|
||||
if (!CHECK_FLAG(om->options, OSPF_MASTER_SHUTDOWN))
|
||||
instance = ospf->instance;
|
||||
|
||||
list_delete(&ospf->areas);
|
||||
list_delete(&ospf->oi_write_q);
|
||||
|
||||
@ -768,9 +761,6 @@ static void ospf_finish_final(struct ospf *ospf)
|
||||
}
|
||||
|
||||
XFREE(MTYPE_OSPF_TOP, ospf);
|
||||
|
||||
if (!CHECK_FLAG(om->options, OSPF_MASTER_SHUTDOWN))
|
||||
ospf_get_instance(instance);
|
||||
}
|
||||
|
||||
|
||||
|
@ -117,6 +117,14 @@ struct ospf_redist {
|
||||
#define ROUTEMAP(R) (R->route_map.map)
|
||||
};
|
||||
|
||||
/* ospf->config */
|
||||
enum {
|
||||
OSPF_RFC1583_COMPATIBLE = (1 << 0),
|
||||
OSPF_OPAQUE_CAPABLE = (1 << 2),
|
||||
OSPF_LOG_ADJACENCY_CHANGES = (1 << 3),
|
||||
OSPF_LOG_ADJACENCY_DETAIL = (1 << 4),
|
||||
};
|
||||
|
||||
/* OSPF instance structure. */
|
||||
struct ospf {
|
||||
/* OSPF's running state based on the '[no] router ospf [<instance>]'
|
||||
@ -151,12 +159,8 @@ struct ospf {
|
||||
/* NSSA ABR */
|
||||
uint8_t anyNSSA; /* Bump for every NSSA attached. */
|
||||
|
||||
/* Configured variables. */
|
||||
/* Configuration bitmask, refer to enum above */
|
||||
uint8_t config;
|
||||
#define OSPF_RFC1583_COMPATIBLE (1 << 0)
|
||||
#define OSPF_OPAQUE_CAPABLE (1 << 2)
|
||||
#define OSPF_LOG_ADJACENCY_CHANGES (1 << 3)
|
||||
#define OSPF_LOG_ADJACENCY_DETAIL (1 << 4)
|
||||
|
||||
/* Opaque-LSA administrative flags. */
|
||||
uint8_t opaque;
|
||||
@ -500,8 +504,9 @@ extern struct zebra_privs_t ospfd_privs;
|
||||
/* Prototypes. */
|
||||
extern const char *ospf_redist_string(unsigned int route_type);
|
||||
extern struct ospf *ospf_lookup_instance(unsigned short);
|
||||
extern struct ospf *ospf_get(unsigned short instance, const char *name);
|
||||
extern struct ospf *ospf_get_instance(unsigned short);
|
||||
extern struct ospf *ospf_get(unsigned short instance, const char *name,
|
||||
bool *created);
|
||||
extern struct ospf *ospf_get_instance(unsigned short, bool *created);
|
||||
extern struct ospf *ospf_lookup_by_inst_name(unsigned short instance,
|
||||
const char *name);
|
||||
extern struct ospf *ospf_lookup_by_vrf_id(vrf_id_t vrf_id);
|
||||
|
Loading…
Reference in New Issue
Block a user