summaryrefslogtreecommitdiffstats
path: root/ospfd/ospf_lsa.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-05-20 03:03:42 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2015-05-20 03:03:42 +0200
commit7c8ff89e9346227f0e721f7686d4c4d58f9c9135 (patch)
tree7a5f73baf68e31220396e2391cdd216cdf981d51 /ospfd/ospf_lsa.c
parentinitd: initd-mi.patch (diff)
downloadfrr-7c8ff89e9346227f0e721f7686d4c4d58f9c9135.tar.xz
frr-7c8ff89e9346227f0e721f7686d4c4d58f9c9135.zip
Multi-Instance OSPF Summary
——————————————------------- - etc/init.d/quagga is modified to support creating separate ospf daemon process for each instance. Each individual instance is monitored by watchquagga just like any protocol daemons.(requires initd-mi.patch). - Vtysh is modified to able to connect to multiple daemons of the same protocol (supported for OSPF only for now). - ospfd is modified to remember the Instance-ID that its invoked with. For the entire life of the process it caters to any command request that matches that instance-ID (unless its a non instance specific command). Routes/messages to zebra are tagged with instance-ID. - zebra route/redistribute mechanisms are modified to work with [protocol type + instance-id] - bgpd now has ability to have multiple instance specific redistribution for a protocol (OSPF only supported/tested for now). - zlog ability to display instance-id besides the protocol/daemon name. - Changes in other daemons are to because of the needed integration with some of the modified APIs/routines. (Didn’t prefer replicating too many separate instance specific APIs.) - config/show/debug commands are modified to take instance-id argument as appropriate. Guidelines to start using multi-instance ospf --------------------------------------------- The patch is backward compatible, i.e for any previous way of single ospf deamon(router ospf <cr>) will continue to work as is, including all the show commands etc. To enable multiple instances, do the following: 1. service quagga stop 2. Modify /etc/quagga/daemons to add instance-ids of each desired instance in the following format: ospfd=“yes" ospfd_instances="1,2,3" assuming you want to enable 3 instances with those instance ids. 3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf and ospfd-3.conf. 4. service quagga start/restart 5. Verify that the deamons are started as expected. You should see ospfd started with -n <instance-id> option. ps –ef | grep quagga With that /var/run/quagga/ should have ospfd-<instance-id>.pid and ospfd-<instance-id>/vty to each instance. 6. vtysh to work with instances as you would with any other deamons. 7. Overall most quagga semantics are the same working with the instance deamon, like it is for any other daemon. NOTE: To safeguard against errors leading to too many processes getting invoked, a hard limit on number of instance-ids is in place, currently its 5. Allowed instance-id range is <1-65535> Once daemons are up, show running from vtysh should show the instance-id of each daemon as 'router ospf <instance-id>’ (without needing explicit configuration) Instance-id can not be changed via vtysh, other router ospf configuration is allowed as before. Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com> Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com> Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
Diffstat (limited to 'ospfd/ospf_lsa.c')
-rw-r--r--ospfd/ospf_lsa.c95
1 files changed, 64 insertions, 31 deletions
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index 1de03440c..f988468e3 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -1590,16 +1590,23 @@ ospf_get_nssa_ip (struct ospf_area *area)
#define DEFAULT_METRIC_TYPE EXTERNAL_METRIC_TYPE_2
int
-metric_type (struct ospf *ospf, u_char src)
+metric_type (struct ospf *ospf, u_char src, u_short instance)
{
- return (ospf->dmetric[src].type < 0 ?
- DEFAULT_METRIC_TYPE : ospf->dmetric[src].type);
+ struct ospf_redist *red;
+
+ red = ospf_redist_lookup(ospf, src, instance);
+
+ return ((!red || red->dmetric.type < 0) ?
+ DEFAULT_METRIC_TYPE : red->dmetric.type);
}
int
-metric_value (struct ospf *ospf, u_char src)
+metric_value (struct ospf *ospf, u_char src, u_short instance)
{
- if (ospf->dmetric[src].value < 0)
+ struct ospf_redist *red;
+
+ red = ospf_redist_lookup(ospf, src, instance);
+ if (!red || red->dmetric.value < 0)
{
if (src == DEFAULT_ROUTE)
{
@@ -1614,7 +1621,7 @@ metric_value (struct ospf *ospf, u_char src)
return ospf->default_metric;
}
- return ospf->dmetric[src].value;
+ return red->dmetric.value;
}
/* Set AS-external-LSA body. */
@@ -1627,6 +1634,7 @@ ospf_external_lsa_body_set (struct stream *s, struct external_info *ei,
u_int32_t mvalue;
int mtype;
int type;
+ u_short instance;
/* Put Network Mask. */
masklen2ip (p->prefixlen, &mask);
@@ -1634,12 +1642,13 @@ ospf_external_lsa_body_set (struct stream *s, struct external_info *ei,
/* If prefix is default, specify DEFAULT_ROUTE. */
type = is_prefix_default (&ei->p) ? DEFAULT_ROUTE : ei->type;
+ instance = is_prefix_default (&ei->p) ? 0 : ei->instance;
mtype = (ROUTEMAP_METRIC_TYPE (ei) != -1) ?
- ROUTEMAP_METRIC_TYPE (ei) : metric_type (ospf, type);
+ ROUTEMAP_METRIC_TYPE (ei) : metric_type (ospf, type, instance);
mvalue = (ROUTEMAP_METRIC (ei) != -1) ?
- ROUTEMAP_METRIC (ei) : metric_value (ospf, type);
+ ROUTEMAP_METRIC (ei) : metric_value (ospf, type, instance);
/* Put type of external metric. */
stream_putc (s, (mtype == EXTERNAL_METRIC_TYPE_2 ? 0x80 : 0));
@@ -2106,17 +2115,25 @@ ospf_external_lsa_originate_timer (struct thread *thread)
struct external_info *ei;
struct route_table *rt;
int type = THREAD_VAL (thread);
+ struct list *ext_list;
+ struct listnode *node;
+ struct ospf_external *ext;
ospf->t_external_lsa = NULL;
- /* Originate As-external-LSA from all type of distribute source. */
- if ((rt = EXTERNAL_INFO (type)))
- for (rn = route_top (rt); rn; rn = route_next (rn))
- if ((ei = rn->info) != NULL)
- if (!is_prefix_default ((struct prefix_ipv4 *)&ei->p))
- if (!ospf_external_lsa_originate (ospf, ei))
- zlog_warn ("LSA: AS-external-LSA was not originated.");
-
+ ext_list = om->external[type];
+ if (!ext_list)
+ return 0;
+
+ for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext))
+ /* Originate As-external-LSA from all type of distribute source. */
+ if ((rt = ext->external_info))
+ for (rn = route_top (rt); rn; rn = route_next (rn))
+ if ((ei = rn->info) != NULL)
+ if (!is_prefix_default ((struct prefix_ipv4 *)&ei->p))
+ if (!ospf_external_lsa_originate (ospf, ei))
+ zlog_warn ("LSA: AS-external-LSA was not originated.");
+
return 0;
}
@@ -2133,17 +2150,30 @@ ospf_default_external_info (struct ospf *ospf)
/* First, lookup redistributed default route. */
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
- if (EXTERNAL_INFO (type) && type != ZEBRA_ROUTE_OSPF)
- {
- rn = route_node_lookup (EXTERNAL_INFO (type), (struct prefix *) &p);
- if (rn != NULL)
- {
- route_unlock_node (rn);
- assert (rn->info);
- if (ospf_redistribute_check (ospf, rn->info, NULL))
- return rn->info;
- }
- }
+ {
+ struct list *ext_list;
+ struct listnode *node;
+ struct ospf_external *ext;
+
+ if (type == ZEBRA_ROUTE_OSPF)
+ continue;
+
+ ext_list = om->external[type];
+ if (!ext_list)
+ continue;
+
+ for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext))
+ {
+ rn = route_node_lookup (ext->external_info, (struct prefix *) &p);
+ if (rn != NULL)
+ {
+ route_unlock_node (rn);
+ assert (rn->info);
+ if (ospf_redistribute_check (ospf, rn->info, NULL))
+ return rn->info;
+ }
+ }
+ }
return NULL;
}
@@ -2167,7 +2197,7 @@ ospf_default_originate_timer (struct thread *thread)
/* If there is no default route via redistribute,
then originate AS-external-LSA with nexthop 0 (self). */
nexthop.s_addr = 0;
- ospf_external_info_add (DEFAULT_ROUTE, p, 0, nexthop, 0);
+ ospf_external_info_add (DEFAULT_ROUTE, 0, p, 0, nexthop, 0);
}
if ((ei = ospf_default_external_info (ospf)))
@@ -2298,15 +2328,18 @@ ospf_external_lsa_refresh_default (struct ospf *ospf)
}
void
-ospf_external_lsa_refresh_type (struct ospf *ospf, u_char type, int force)
+ospf_external_lsa_refresh_type (struct ospf *ospf, u_char type, u_short instance,
+ int force)
{
struct route_node *rn;
struct external_info *ei;
+ struct ospf_external *ext;
if (type != DEFAULT_ROUTE)
- if (EXTERNAL_INFO(type))
+ if ((ext = ospf_external_lookup(type, instance)) &&
+ EXTERNAL_INFO (ext))
/* Refresh each redistributed AS-external-LSAs. */
- for (rn = route_top (EXTERNAL_INFO (type)); rn; rn = route_next (rn))
+ for (rn = route_top (EXTERNAL_INFO (ext)); rn; rn = route_next (rn))
if ((ei = rn->info))
if (!is_prefix_default (&ei->p))
{