<sect1>Attributes
-<p>OSPF defines three route attributes. Each internal route has a <cf/metric/
+<p>OSPF defines four route attributes. Each internal route has a <cf/metric/.
Metric is ranging from 1 to infinity (65535).
External routes use <cf/metric type 1/ or <cf/metric type 2/.
A <cf/metric of type 1/ is comparable with internal <cf/metric/, a
Each external route can also carry a <cf/tag/ which is a 32-bit
integer which is used when exporting routes to other protocols;
otherwise, it doesn't affect routing inside the OSPF domain at all.
+The fourth attribute is a <cf/router_id/ of the router advertising
+that route/network. This attribute is read-only.
Default is <cf/metric of type 2 = 10000/ and <cf/tag = 0/.
<sect1>Example
struct {
u32 metric1, metric2; /* OSPF Type 1 and Type 2 metrics */
u32 tag; /* External route tag */
+ u32 router_id; /* Router that originated this route */
} ospf;
#endif
struct { /* Routes generated by krt sync (both temporary and inherited ones) */
CF_DECLS
-CF_KEYWORDS(OSPF, AREA, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG, BROADCAST)
-CF_KEYWORDS(NEIGHBORS, RFC1583COMPAT, STUB, TICK, COST, RETRANSMIT)
+CF_KEYWORDS(OSPF, AREA, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG, OSPF_ROUTER_ID)
+CF_KEYWORDS(BROADCAST, NEIGHBORS, RFC1583COMPAT, STUB, TICK, COST, RETRANSMIT)
CF_KEYWORDS(HELLO, TRANSMIT, PRIORITY, DEAD, NONBROADCAST, POINTOPOINT, TYPE)
CF_KEYWORDS(NONE, SIMPLE, AUTHENTICATION, STRICT, CRYPTOGRAPHIC)
CF_KEYWORDS(ELIGIBLE, POLL, NETWORKS, HIDDEN, VIRTUAL, LINK)
CF_ADDTO(dynamic_attr, OSPF_METRIC1 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_METRIC1); })
CF_ADDTO(dynamic_attr, OSPF_METRIC2 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_METRIC2); })
CF_ADDTO(dynamic_attr, OSPF_TAG { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_TAG); })
+CF_ADDTO(dynamic_attr, OSPF_ROUTER_ID { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_ROUTER_ID); })
CF_CLI(SHOW OSPF, optsym, [<name>], [[Show information about OSPF protocol]])
{ ospf_sh(proto_get_named($3, &proto_ospf)); };
return
new->u.ospf.metric1 == old->u.ospf.metric1 &&
new->u.ospf.metric2 == old->u.ospf.metric2 &&
- new->u.ospf.tag == old->u.ospf.tag;
+ new->u.ospf.tag == old->u.ospf.tag &&
+ new->u.ospf.router_id == old->u.ospf.router_id;
}
static ea_list *
ospf_build_attrs(ea_list * next, struct linpool *pool, u32 m1, u32 m2,
- u32 tag)
+ u32 tag, u32 rid)
{
struct ea_list *l =
- lp_alloc(pool, sizeof(struct ea_list) + 3 * sizeof(eattr));
+ lp_alloc(pool, sizeof(struct ea_list) + 4 * sizeof(eattr));
l->next = next;
l->flags = EALF_SORTED;
- l->count = 3;
+ l->count = 4;
l->attrs[0].id = EA_OSPF_METRIC1;
l->attrs[0].flags = 0;
l->attrs[0].type = EAF_TYPE_INT | EAF_TEMP;
l->attrs[2].flags = 0;
l->attrs[2].type = EAF_TYPE_INT | EAF_TEMP;
l->attrs[2].u.data = tag;
+ l->attrs[3].id = EA_OSPF_ROUTER_ID;
+ l->attrs[3].flags = 0;
+ l->attrs[3].type = EAF_TYPE_INT | EAF_TEMP;
+ l->attrs[3].u.data = rid;
return l;
}
if (p == e->attrs->proto)
return -1; /* Reject our own routes */
- *attrs = ospf_build_attrs(*attrs, pool, LSINFINITY, 10000, 0);
+ *attrs = ospf_build_attrs(*attrs, pool, LSINFINITY, 10000, 0, 0);
return 0; /* Leave decision to the filters */
}
ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool)
{
return ospf_build_attrs(NULL, pool, rt->u.ospf.metric1, rt->u.ospf.metric2,
- rt->u.ospf.tag);
+ rt->u.ospf.tag, rt->u.ospf.router_id);
}
void
rt->u.ospf.metric1 = ea_get_int(attrs, EA_OSPF_METRIC1, LSINFINITY);
rt->u.ospf.metric2 = ea_get_int(attrs, EA_OSPF_METRIC2, 10000);
rt->u.ospf.tag = ea_get_int(attrs, EA_OSPF_TAG, 0);
+ rt->u.ospf.router_id = ea_get_int(attrs, EA_OSPF_ROUTER_ID, 0);
}
/**
{
buf += bsprintf(buf, " [%x]", rte->u.ospf.tag);
}
+ if (rte->u.ospf.router_id)
+ buf += bsprintf(buf, " [%R]", rte->u.ospf.router_id);
}
static int
bsprintf(buf, "metric2");
return GA_NAME;
case EA_OSPF_TAG:
- bsprintf(buf, "tag: %08x", a->u.data);
+ bsprintf(buf, "tag: %08x (%u)", a->u.data, a->u.data);
+ return GA_FULL;
+ case EA_OSPF_ROUTER_ID:
+ bsprintf(buf, "router_id: %R (%u)", a->u.data, a->u.data);
return GA_FULL;
default:
return GA_UNKNOWN;
#define EA_OSPF_METRIC1 EA_CODE(EAP_OSPF, 0)
#define EA_OSPF_METRIC2 EA_CODE(EAP_OSPF, 1)
#define EA_OSPF_TAG EA_CODE(EAP_OSPF, 2)
+#define EA_OSPF_ROUTER_ID EA_CODE(EAP_OSPF, 3)
#include "proto/ospf/rt.h"
#include "proto/ospf/hello.h"
orta->ifa = NULL;
orta->ar = NULL;
orta->tag = 0;
+ orta->rid = 0;
}
void
nf.ar = en;
nf.nh = en->nh;
nf.ifa = en->nhi;
+ nf.rid = en->lsa.rt;
/* FIXME check nf.ifa on stubs */
ri_install(oa->po, px, pxlen, ORT_NET, &nf, NULL);
nf.ar = act;
nf.nh = act->nh;
nf.ifa = act->nhi;
+ nf.rid = act->lsa.rt;
if (act == oa->rt)
{
nf.ar = act;
nf.nh = act->nh;
nf.ifa = act->nhi;
+ nf.rid = act->lsa.rt;
ri_install(po, ipa_from_rid(act->lsa.rt), MAX_PREFIX_LENGTH, ORT_ROUTER, &nf, NULL);
#ifdef OSPFv2
nf.ar = abr->n.ar;
nf.nh = abr->n.nh;
nf.ifa = abr->n.ifa;
+ nf.rid = en->lsa.rt; /* ABR ID */
ri_install(po, ip, pxlen, type, &nf, NULL);
}
}
nf.ar = abr->n.ar;
nf.nh = abr->n.nh;
nf.ifa = abr->n.ifa;
+ nf.rid = en->lsa.rt; /* ABR ID */
ri_install(po, ip, pxlen, type, &nf, NULL);
}
}
nfa.ar = nf1->n.ar;
nfa.nh = nh;
nfa.ifa = nhi;
+ nfa.rid = en->lsa.rt;
ri_install(po, ip, pxlen, ORT_NET, &nfa, nfh);
}
e->u.ospf.metric1 = nf->n.metric1;
e->u.ospf.metric2 = nf->n.metric2;
e->u.ospf.tag = nf->n.tag;
+ e->u.ospf.router_id = nf->n.rid;
e->pflags = 0;
e->net = ne;
e->pref = p->preference;
u32 metric2;
ip_addr nh; /* Next hop */
struct ospf_iface *ifa; /* Outgoing interface */
- struct top_hash_entry *ar; /* Advertising router */
+ struct top_hash_entry *ar; /* Advertising router (or ABR) */
u32 tag;
+ u32 rid; /* Router ID of real advertising router */
+ /* For ext-LSA from different area, 'ar' is a type 1 LSA of ABR.
+ Router ID of real advertising router is stored in 'rid'. */
}
orta;