mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
Shows source (Router ID) for OSPF routes and adds such attribute.
A sad thing is that we does not have a 'router_id' filter type, so it must be given as decimal number in filters.
This commit is contained in:
parent
5a56f27cd0
commit
c27b2449d1
@ -1578,7 +1578,7 @@ protocol ospf <name> {
|
|||||||
|
|
||||||
<sect1>Attributes
|
<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).
|
Metric is ranging from 1 to infinity (65535).
|
||||||
External routes use <cf/metric type 1/ or <cf/metric type 2/.
|
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
|
A <cf/metric of type 1/ is comparable with internal <cf/metric/, a
|
||||||
@ -1588,6 +1588,8 @@ If you specify both metrics only metric1 is used.
|
|||||||
Each external route can also carry a <cf/tag/ which is a 32-bit
|
Each external route can also carry a <cf/tag/ which is a 32-bit
|
||||||
integer which is used when exporting routes to other protocols;
|
integer which is used when exporting routes to other protocols;
|
||||||
otherwise, it doesn't affect routing inside the OSPF domain at all.
|
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/.
|
Default is <cf/metric of type 2 = 10000/ and <cf/tag = 0/.
|
||||||
|
|
||||||
<sect1>Example
|
<sect1>Example
|
||||||
|
@ -166,6 +166,7 @@ typedef struct rte {
|
|||||||
struct {
|
struct {
|
||||||
u32 metric1, metric2; /* OSPF Type 1 and Type 2 metrics */
|
u32 metric1, metric2; /* OSPF Type 1 and Type 2 metrics */
|
||||||
u32 tag; /* External route tag */
|
u32 tag; /* External route tag */
|
||||||
|
u32 router_id; /* Router that originated this route */
|
||||||
} ospf;
|
} ospf;
|
||||||
#endif
|
#endif
|
||||||
struct { /* Routes generated by krt sync (both temporary and inherited ones) */
|
struct { /* Routes generated by krt sync (both temporary and inherited ones) */
|
||||||
|
@ -45,8 +45,8 @@ finish_iface_config(struct ospf_iface_patt *ip)
|
|||||||
|
|
||||||
CF_DECLS
|
CF_DECLS
|
||||||
|
|
||||||
CF_KEYWORDS(OSPF, AREA, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG, BROADCAST)
|
CF_KEYWORDS(OSPF, AREA, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG, OSPF_ROUTER_ID)
|
||||||
CF_KEYWORDS(NEIGHBORS, RFC1583COMPAT, STUB, TICK, COST, RETRANSMIT)
|
CF_KEYWORDS(BROADCAST, NEIGHBORS, RFC1583COMPAT, STUB, TICK, COST, RETRANSMIT)
|
||||||
CF_KEYWORDS(HELLO, TRANSMIT, PRIORITY, DEAD, NONBROADCAST, POINTOPOINT, TYPE)
|
CF_KEYWORDS(HELLO, TRANSMIT, PRIORITY, DEAD, NONBROADCAST, POINTOPOINT, TYPE)
|
||||||
CF_KEYWORDS(NONE, SIMPLE, AUTHENTICATION, STRICT, CRYPTOGRAPHIC)
|
CF_KEYWORDS(NONE, SIMPLE, AUTHENTICATION, STRICT, CRYPTOGRAPHIC)
|
||||||
CF_KEYWORDS(ELIGIBLE, POLL, NETWORKS, HIDDEN, VIRTUAL, LINK)
|
CF_KEYWORDS(ELIGIBLE, POLL, NETWORKS, HIDDEN, VIRTUAL, LINK)
|
||||||
@ -304,6 +304,7 @@ opttext:
|
|||||||
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_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_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_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]])
|
CF_CLI(SHOW OSPF, optsym, [<name>], [[Show information about OSPF protocol]])
|
||||||
{ ospf_sh(proto_get_named($3, &proto_ospf)); };
|
{ ospf_sh(proto_get_named($3, &proto_ospf)); };
|
||||||
|
@ -278,19 +278,20 @@ ospf_rte_same(struct rte *new, struct rte *old)
|
|||||||
return
|
return
|
||||||
new->u.ospf.metric1 == old->u.ospf.metric1 &&
|
new->u.ospf.metric1 == old->u.ospf.metric1 &&
|
||||||
new->u.ospf.metric2 == old->u.ospf.metric2 &&
|
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 *
|
static ea_list *
|
||||||
ospf_build_attrs(ea_list * next, struct linpool *pool, u32 m1, u32 m2,
|
ospf_build_attrs(ea_list * next, struct linpool *pool, u32 m1, u32 m2,
|
||||||
u32 tag)
|
u32 tag, u32 rid)
|
||||||
{
|
{
|
||||||
struct ea_list *l =
|
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->next = next;
|
||||||
l->flags = EALF_SORTED;
|
l->flags = EALF_SORTED;
|
||||||
l->count = 3;
|
l->count = 4;
|
||||||
l->attrs[0].id = EA_OSPF_METRIC1;
|
l->attrs[0].id = EA_OSPF_METRIC1;
|
||||||
l->attrs[0].flags = 0;
|
l->attrs[0].flags = 0;
|
||||||
l->attrs[0].type = EAF_TYPE_INT | EAF_TEMP;
|
l->attrs[0].type = EAF_TYPE_INT | EAF_TEMP;
|
||||||
@ -303,6 +304,10 @@ ospf_build_attrs(ea_list * next, struct linpool *pool, u32 m1, u32 m2,
|
|||||||
l->attrs[2].flags = 0;
|
l->attrs[2].flags = 0;
|
||||||
l->attrs[2].type = EAF_TYPE_INT | EAF_TEMP;
|
l->attrs[2].type = EAF_TYPE_INT | EAF_TEMP;
|
||||||
l->attrs[2].u.data = tag;
|
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;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,7 +440,7 @@ ospf_import_control(struct proto *p, rte ** new, ea_list ** attrs,
|
|||||||
|
|
||||||
if (p == e->attrs->proto)
|
if (p == e->attrs->proto)
|
||||||
return -1; /* Reject our own routes */
|
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 */
|
return 0; /* Leave decision to the filters */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,7 +448,7 @@ struct ea_list *
|
|||||||
ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool)
|
ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool)
|
||||||
{
|
{
|
||||||
return ospf_build_attrs(NULL, pool, rt->u.ospf.metric1, rt->u.ospf.metric2,
|
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
|
void
|
||||||
@ -452,6 +457,7 @@ ospf_store_tmp_attrs(struct rte *rt, struct ea_list *attrs)
|
|||||||
rt->u.ospf.metric1 = ea_get_int(attrs, EA_OSPF_METRIC1, LSINFINITY);
|
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.metric2 = ea_get_int(attrs, EA_OSPF_METRIC2, 10000);
|
||||||
rt->u.ospf.tag = ea_get_int(attrs, EA_OSPF_TAG, 0);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -569,6 +575,8 @@ ospf_get_route_info(rte * rte, byte * buf, ea_list * attrs UNUSED)
|
|||||||
{
|
{
|
||||||
buf += bsprintf(buf, " [%x]", rte->u.ospf.tag);
|
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
|
static int
|
||||||
@ -583,7 +591,10 @@ ospf_get_attr(eattr * a, byte * buf, int buflen UNUSED)
|
|||||||
bsprintf(buf, "metric2");
|
bsprintf(buf, "metric2");
|
||||||
return GA_NAME;
|
return GA_NAME;
|
||||||
case EA_OSPF_TAG:
|
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;
|
return GA_FULL;
|
||||||
default:
|
default:
|
||||||
return GA_UNKNOWN;
|
return GA_UNKNOWN;
|
||||||
|
@ -793,6 +793,7 @@ void ospf_sh_state(struct proto *p, int verbose);
|
|||||||
#define EA_OSPF_METRIC1 EA_CODE(EAP_OSPF, 0)
|
#define EA_OSPF_METRIC1 EA_CODE(EAP_OSPF, 0)
|
||||||
#define EA_OSPF_METRIC2 EA_CODE(EAP_OSPF, 1)
|
#define EA_OSPF_METRIC2 EA_CODE(EAP_OSPF, 1)
|
||||||
#define EA_OSPF_TAG EA_CODE(EAP_OSPF, 2)
|
#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/rt.h"
|
||||||
#include "proto/ospf/hello.h"
|
#include "proto/ospf/hello.h"
|
||||||
|
@ -38,6 +38,7 @@ fill_ri(orta * orta)
|
|||||||
orta->ifa = NULL;
|
orta->ifa = NULL;
|
||||||
orta->ar = NULL;
|
orta->ar = NULL;
|
||||||
orta->tag = 0;
|
orta->tag = 0;
|
||||||
|
orta->rid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -158,6 +159,7 @@ add_network(struct ospf_area *oa, ip_addr px, int pxlen, int metric, struct top_
|
|||||||
nf.ar = en;
|
nf.ar = en;
|
||||||
nf.nh = en->nh;
|
nf.nh = en->nh;
|
||||||
nf.ifa = en->nhi;
|
nf.ifa = en->nhi;
|
||||||
|
nf.rid = en->lsa.rt;
|
||||||
|
|
||||||
/* FIXME check nf.ifa on stubs */
|
/* FIXME check nf.ifa on stubs */
|
||||||
ri_install(oa->po, px, pxlen, ORT_NET, &nf, NULL);
|
ri_install(oa->po, px, pxlen, ORT_NET, &nf, NULL);
|
||||||
@ -256,6 +258,7 @@ ospf_rt_spfa_rtlinks(struct ospf_area *oa, struct top_hash_entry *act, struct to
|
|||||||
nf.ar = act;
|
nf.ar = act;
|
||||||
nf.nh = act->nh;
|
nf.nh = act->nh;
|
||||||
nf.ifa = act->nhi;
|
nf.ifa = act->nhi;
|
||||||
|
nf.rid = act->lsa.rt;
|
||||||
|
|
||||||
if (act == oa->rt)
|
if (act == oa->rt)
|
||||||
{
|
{
|
||||||
@ -373,6 +376,7 @@ ospf_rt_spfa(struct ospf_area *oa)
|
|||||||
nf.ar = act;
|
nf.ar = act;
|
||||||
nf.nh = act->nh;
|
nf.nh = act->nh;
|
||||||
nf.ifa = act->nhi;
|
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);
|
ri_install(po, ipa_from_rid(act->lsa.rt), MAX_PREFIX_LENGTH, ORT_ROUTER, &nf, NULL);
|
||||||
|
|
||||||
#ifdef OSPFv2
|
#ifdef OSPFv2
|
||||||
@ -610,6 +614,7 @@ ospf_rt_sum_tr(struct ospf_area *oa)
|
|||||||
nf.ar = abr->n.ar;
|
nf.ar = abr->n.ar;
|
||||||
nf.nh = abr->n.nh;
|
nf.nh = abr->n.nh;
|
||||||
nf.ifa = abr->n.ifa;
|
nf.ifa = abr->n.ifa;
|
||||||
|
nf.rid = en->lsa.rt; /* ABR ID */
|
||||||
ri_install(po, ip, pxlen, type, &nf, NULL);
|
ri_install(po, ip, pxlen, type, &nf, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -719,6 +724,7 @@ ospf_rt_sum(struct ospf_area *oa)
|
|||||||
nf.ar = abr->n.ar;
|
nf.ar = abr->n.ar;
|
||||||
nf.nh = abr->n.nh;
|
nf.nh = abr->n.nh;
|
||||||
nf.ifa = abr->n.ifa;
|
nf.ifa = abr->n.ifa;
|
||||||
|
nf.rid = en->lsa.rt; /* ABR ID */
|
||||||
ri_install(po, ip, pxlen, type, &nf, NULL);
|
ri_install(po, ip, pxlen, type, &nf, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -961,6 +967,7 @@ ospf_ext_spf(struct proto_ospf *po)
|
|||||||
nfa.ar = nf1->n.ar;
|
nfa.ar = nf1->n.ar;
|
||||||
nfa.nh = nh;
|
nfa.nh = nh;
|
||||||
nfa.ifa = nhi;
|
nfa.ifa = nhi;
|
||||||
|
nfa.rid = en->lsa.rt;
|
||||||
ri_install(po, ip, pxlen, ORT_NET, &nfa, nfh);
|
ri_install(po, ip, pxlen, ORT_NET, &nfa, nfh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1212,6 +1219,7 @@ again1:
|
|||||||
e->u.ospf.metric1 = nf->n.metric1;
|
e->u.ospf.metric1 = nf->n.metric1;
|
||||||
e->u.ospf.metric2 = nf->n.metric2;
|
e->u.ospf.metric2 = nf->n.metric2;
|
||||||
e->u.ospf.tag = nf->n.tag;
|
e->u.ospf.tag = nf->n.tag;
|
||||||
|
e->u.ospf.router_id = nf->n.rid;
|
||||||
e->pflags = 0;
|
e->pflags = 0;
|
||||||
e->net = ne;
|
e->net = ne;
|
||||||
e->pref = p->preference;
|
e->pref = p->preference;
|
||||||
|
@ -28,8 +28,11 @@ typedef struct orta
|
|||||||
u32 metric2;
|
u32 metric2;
|
||||||
ip_addr nh; /* Next hop */
|
ip_addr nh; /* Next hop */
|
||||||
struct ospf_iface *ifa; /* Outgoing interface */
|
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 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;
|
orta;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user