2000-03-31 00:21:41 +00:00
|
|
|
/*
|
|
|
|
* BIRD -- OSPF
|
|
|
|
*
|
2004-06-04 21:05:43 +00:00
|
|
|
* (c) 1999--2004 Ondrej Filip <feela@network.cz>
|
2000-03-31 00:21:41 +00:00
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ospf.h"
|
|
|
|
|
2000-05-02 22:19:41 +00:00
|
|
|
void
|
2004-07-15 16:37:52 +00:00
|
|
|
flush_lsa(struct top_hash_entry *en, struct proto_ospf *po)
|
2000-05-02 22:19:41 +00:00
|
|
|
{
|
2004-06-06 09:37:54 +00:00
|
|
|
OSPF_TRACE(D_EVENTS,
|
2009-12-14 16:29:33 +00:00
|
|
|
"Going to remove LSA Type: %04x, Id: %R, Rt: %R, Age: %u, Seqno: 0x%x",
|
2012-08-05 20:32:06 +00:00
|
|
|
en->lsa_type, en->lsa.id, en->lsa.rt, en->lsa.age, en->lsa.sn);
|
2000-05-09 19:36:32 +00:00
|
|
|
s_rem_node(SNODE en);
|
2004-06-06 09:37:54 +00:00
|
|
|
if (en->lsa_body != NULL)
|
|
|
|
mb_free(en->lsa_body);
|
|
|
|
en->lsa_body = NULL;
|
2004-07-15 16:37:52 +00:00
|
|
|
ospf_hash_delete(po->gr, en);
|
2000-05-02 22:19:41 +00:00
|
|
|
}
|
|
|
|
|
2011-03-17 14:53:36 +00:00
|
|
|
void
|
|
|
|
ospf_flush_area(struct proto_ospf *po, u32 areaid)
|
|
|
|
{
|
|
|
|
struct top_hash_entry *en, *nxt;
|
|
|
|
|
|
|
|
WALK_SLIST_DELSAFE(en, nxt, po->lsal)
|
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
if ((LSA_SCOPE(en->lsa_type) == LSA_SCOPE_AREA) && (en->domain == areaid))
|
2011-03-17 14:53:36 +00:00
|
|
|
flush_lsa(en, po);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-06-07 22:31:47 +00:00
|
|
|
/**
|
|
|
|
* ospf_age
|
2004-07-15 16:37:52 +00:00
|
|
|
* @po: ospf protocol
|
2000-06-07 22:31:47 +00:00
|
|
|
*
|
2004-07-15 16:37:52 +00:00
|
|
|
* This function is periodicaly invoked from ospf_disp(). It computes the new
|
2003-08-23 10:42:41 +00:00
|
|
|
* age of all LSAs and old (@age is higher than %LSA_MAXAGE) LSAs are flushed
|
|
|
|
* whenever possible. If an LSA originated by the router itself is older
|
|
|
|
* than %LSREFRESHTIME a new instance is originated.
|
2000-06-07 22:31:47 +00:00
|
|
|
*
|
2003-08-23 10:42:41 +00:00
|
|
|
* The RFC says that a router should check the checksum of every LSA to detect
|
|
|
|
* hardware problems. BIRD does not do this to minimalize CPU utilization.
|
2000-06-07 23:34:43 +00:00
|
|
|
*
|
2003-08-23 10:42:41 +00:00
|
|
|
* If routing table calculation is scheduled, it also invalidates the old routing
|
2000-06-07 23:34:43 +00:00
|
|
|
* table calculation results.
|
2000-06-07 22:31:47 +00:00
|
|
|
*/
|
2000-05-02 22:19:41 +00:00
|
|
|
void
|
2004-07-15 16:37:52 +00:00
|
|
|
ospf_age(struct proto_ospf *po)
|
2000-05-02 22:19:41 +00:00
|
|
|
{
|
2004-06-06 09:37:54 +00:00
|
|
|
struct top_hash_entry *en, *nxt;
|
2004-07-15 16:37:52 +00:00
|
|
|
int flush = can_flush_lsa(po);
|
2000-05-31 14:21:56 +00:00
|
|
|
|
2004-07-15 16:37:52 +00:00
|
|
|
WALK_SLIST_DELSAFE(en, nxt, po->lsal)
|
2000-05-02 22:19:41 +00:00
|
|
|
{
|
2004-06-06 09:37:54 +00:00
|
|
|
if (en->lsa.age == LSA_MAXAGE)
|
2000-05-31 14:21:56 +00:00
|
|
|
{
|
2004-06-06 09:37:54 +00:00
|
|
|
if (flush)
|
2004-07-15 16:37:52 +00:00
|
|
|
flush_lsa(en, po);
|
2000-06-02 12:34:28 +00:00
|
|
|
continue;
|
2000-05-31 14:21:56 +00:00
|
|
|
}
|
2009-12-11 00:20:53 +00:00
|
|
|
if ((en->lsa.rt == po->router_id) && (en->lsa.age >= LSREFRESHTIME))
|
2000-05-31 14:21:56 +00:00
|
|
|
{
|
2009-07-23 14:51:28 +00:00
|
|
|
OSPF_TRACE(D_EVENTS, "Refreshing my LSA: Type: %u, Id: %R, Rt: %R",
|
2012-08-05 20:32:06 +00:00
|
|
|
en->lsa_type, en->lsa.id, en->lsa.rt);
|
2004-06-06 09:37:54 +00:00
|
|
|
en->lsa.sn++;
|
|
|
|
en->lsa.age = 0;
|
|
|
|
en->inst_t = now;
|
|
|
|
en->ini_age = 0;
|
2004-06-06 18:45:08 +00:00
|
|
|
lsasum_calculate(&en->lsa, en->lsa_body);
|
2009-08-21 07:27:52 +00:00
|
|
|
ospf_lsupd_flood(po, NULL, NULL, &en->lsa, en->domain, 1);
|
2004-06-06 09:37:54 +00:00
|
|
|
continue;
|
2000-05-31 14:21:56 +00:00
|
|
|
}
|
2004-06-06 09:37:54 +00:00
|
|
|
if ((en->lsa.age = (en->ini_age + (now - en->inst_t))) >= LSA_MAXAGE)
|
2000-05-31 14:21:56 +00:00
|
|
|
{
|
2004-06-06 09:37:54 +00:00
|
|
|
if (flush)
|
2000-06-04 19:21:23 +00:00
|
|
|
{
|
2004-07-15 16:37:52 +00:00
|
|
|
flush_lsa(en, po);
|
2004-06-06 16:00:09 +00:00
|
|
|
schedule_rtcalc(po);
|
2000-06-04 19:21:23 +00:00
|
|
|
}
|
2004-06-06 09:37:54 +00:00
|
|
|
else
|
|
|
|
en->lsa.age = LSA_MAXAGE;
|
2000-05-31 14:21:56 +00:00
|
|
|
}
|
2000-05-02 22:19:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-25 18:12:34 +00:00
|
|
|
#ifndef CPU_BIG_ENDIAN
|
2000-03-31 00:21:41 +00:00
|
|
|
void
|
2012-10-02 09:44:05 +00:00
|
|
|
lsa_hton_hdr(struct ospf_lsa_header *h, struct ospf_lsa_header *n)
|
2000-03-31 00:21:41 +00:00
|
|
|
{
|
2004-06-06 09:37:54 +00:00
|
|
|
n->age = htons(h->age);
|
2012-10-02 09:44:05 +00:00
|
|
|
n->type_raw = htons(h->type_raw);
|
2004-06-06 09:37:54 +00:00
|
|
|
n->id = htonl(h->id);
|
|
|
|
n->rt = htonl(h->rt);
|
|
|
|
n->sn = htonl(h->sn);
|
|
|
|
n->checksum = htons(h->checksum);
|
|
|
|
n->length = htons(h->length);
|
2009-09-08 15:06:47 +00:00
|
|
|
}
|
2000-03-31 00:21:41 +00:00
|
|
|
|
|
|
|
void
|
2012-10-02 09:44:05 +00:00
|
|
|
lsa_ntoh_hdr(struct ospf_lsa_header *n, struct ospf_lsa_header *h)
|
2000-03-31 00:21:41 +00:00
|
|
|
{
|
2004-06-06 09:37:54 +00:00
|
|
|
h->age = ntohs(n->age);
|
2012-10-02 09:44:05 +00:00
|
|
|
h->type_raw = ntohs(n->type_raw);
|
2004-06-06 09:37:54 +00:00
|
|
|
h->id = ntohl(n->id);
|
|
|
|
h->rt = ntohl(n->rt);
|
|
|
|
h->sn = ntohl(n->sn);
|
|
|
|
h->checksum = ntohs(n->checksum);
|
|
|
|
h->length = ntohs(n->length);
|
2009-09-08 15:06:47 +00:00
|
|
|
}
|
2000-03-31 00:21:41 +00:00
|
|
|
|
|
|
|
void
|
2012-10-02 09:44:05 +00:00
|
|
|
lsa_hton_body(void *h, void *n, u16 len)
|
2000-03-31 00:21:41 +00:00
|
|
|
{
|
2009-09-08 15:06:47 +00:00
|
|
|
u32 *hid = h;
|
|
|
|
u32 *nid = n;
|
2010-02-21 13:34:53 +00:00
|
|
|
unsigned i;
|
2000-03-31 00:21:41 +00:00
|
|
|
|
2009-09-08 15:06:47 +00:00
|
|
|
for (i = 0; i < (len / sizeof(u32)); i++)
|
|
|
|
nid[i] = htonl(hid[i]);
|
|
|
|
}
|
2000-03-31 00:21:41 +00:00
|
|
|
|
|
|
|
void
|
2012-10-02 09:44:05 +00:00
|
|
|
lsa_ntoh_body(void *n, void *h, u16 len)
|
2000-03-31 00:21:41 +00:00
|
|
|
{
|
2009-09-08 15:06:47 +00:00
|
|
|
u32 *nid = n;
|
|
|
|
u32 *hid = h;
|
2010-02-21 13:34:53 +00:00
|
|
|
unsigned i;
|
2000-03-31 00:21:41 +00:00
|
|
|
|
2009-09-08 15:06:47 +00:00
|
|
|
for (i = 0; i < (len / sizeof(u32)); i++)
|
|
|
|
hid[i] = ntohl(nid[i]);
|
|
|
|
}
|
2010-04-25 18:12:34 +00:00
|
|
|
#endif /* little endian */
|
2000-03-31 00:21:41 +00:00
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
lsa_flooding_allowed(u32 type, u32 domain, struct ospf_iface *ifa)
|
2013-01-12 23:17:49 +00:00
|
|
|
{
|
|
|
|
/* Handle inactive vlinks */
|
|
|
|
if (ifa->state == OSPF_IS_DOWN)
|
|
|
|
return 0;
|
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
/* 4.5.2 (Case 2) */
|
|
|
|
switch (LSA_SCOPE(type))
|
|
|
|
{
|
|
|
|
case LSA_SCOPE_LINK:
|
2013-01-12 23:17:49 +00:00
|
|
|
return ifa->iface_id == domain;
|
2012-10-02 09:44:05 +00:00
|
|
|
|
|
|
|
case LSA_SCOPE_AREA:
|
|
|
|
return ifa->oa->areaid == domain;
|
|
|
|
|
|
|
|
case LSA_SCOPE_AS:
|
|
|
|
if (ifa->type == OSPF_IT_VLINK)
|
|
|
|
return 0;
|
|
|
|
if (!oa_is_ext(ifa->oa))
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
default:
|
|
|
|
log(L_ERR "OSPF: LSA with invalid scope");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
unknown_lsa_type(u32 type)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case LSA_T_RT:
|
|
|
|
case LSA_T_NET:
|
|
|
|
case LSA_T_SUM_NET:
|
|
|
|
case LSA_T_SUM_RT:
|
|
|
|
case LSA_T_EXT:
|
|
|
|
case LSA_T_NSSA:
|
|
|
|
case LSA_T_LINK:
|
|
|
|
case LSA_T_PREFIX:
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define LSA_V2_TMAX 8
|
|
|
|
static const u16 lsa_v2_types[LSA_V2_TMAX] =
|
|
|
|
{0, LSA_T_RT, LSA_T_NET, LSA_T_SUM_NET, LSA_T_SUM_RT, LSA_T_EXT, 0, LSA_T_NSSA};
|
|
|
|
|
|
|
|
void
|
|
|
|
lsa_xxxxtype(u32 itype, struct ospf_iface *ifa, u32 *otype, u32 *domain)
|
|
|
|
{
|
|
|
|
if (ospf_is_v2(ifa->oa->po))
|
|
|
|
{
|
|
|
|
itype = itype & LSA_T_V2_MASK;
|
|
|
|
itype = (itype < LSA_V2_TMAX) ? lsa_v2_types[itype] : 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* For unkown LSAs without U-bit change scope to LSA_SCOPE_LINK */
|
|
|
|
if (unknown_lsa_type(itype) && !(itype & LSA_UBIT))
|
|
|
|
itype = itype & ~LSA_SCOPE_MASK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*otype = itype;
|
|
|
|
|
|
|
|
switch (LSA_SCOPE(itype))
|
|
|
|
{
|
|
|
|
case LSA_SCOPE_LINK:
|
2013-01-12 23:17:49 +00:00
|
|
|
*domain = ifa->iface_id;
|
2012-10-02 09:44:05 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case LSA_SCOPE_AREA:
|
|
|
|
*domain = ifa->oa->areaid;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case LSA_SCOPE_AS:
|
|
|
|
default:
|
|
|
|
*domain = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-14 16:29:33 +00:00
|
|
|
/*
|
2009-08-27 16:25:46 +00:00
|
|
|
void
|
|
|
|
buf_dump(const char *hdr, const byte *buf, int blen)
|
|
|
|
{
|
|
|
|
char b2[1024];
|
|
|
|
char *bp;
|
|
|
|
int first = 1;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
const char *lhdr = hdr;
|
|
|
|
|
|
|
|
bp = b2;
|
|
|
|
for(i = 0; i < blen; i++)
|
|
|
|
{
|
|
|
|
if ((i > 0) && ((i % 16) == 0))
|
|
|
|
{
|
|
|
|
*bp = 0;
|
|
|
|
log(L_WARN "%s\t%s", lhdr, b2);
|
|
|
|
lhdr = "";
|
|
|
|
bp = b2;
|
|
|
|
}
|
|
|
|
|
|
|
|
bp += snprintf(bp, 1022, "%02x ", buf[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*bp = 0;
|
|
|
|
log(L_WARN "%s\t%s", lhdr, b2);
|
|
|
|
}
|
2009-12-14 16:29:33 +00:00
|
|
|
*/
|
2009-08-27 16:25:46 +00:00
|
|
|
|
2000-04-01 02:45:49 +00:00
|
|
|
#define MODX 4102 /* larges signed value without overflow */
|
|
|
|
|
|
|
|
/* Fletcher Checksum -- Refer to RFC1008. */
|
|
|
|
#define MODX 4102
|
|
|
|
#define LSA_CHECKSUM_OFFSET 15
|
|
|
|
|
|
|
|
/* FIXME This is VERY uneficient, I have huge endianity problems */
|
|
|
|
void
|
2004-06-06 18:45:08 +00:00
|
|
|
lsasum_calculate(struct ospf_lsa_header *h, void *body)
|
2000-04-02 20:41:33 +00:00
|
|
|
{
|
2009-08-27 16:25:46 +00:00
|
|
|
u16 length = h->length;
|
2004-06-06 09:37:54 +00:00
|
|
|
|
2009-09-04 09:06:51 +00:00
|
|
|
// log(L_WARN "Checksum %R %R %d start (len %d)", h->id, h->rt, h->type, length);
|
2012-10-02 09:44:05 +00:00
|
|
|
lsa_hton_hdr(h, h);
|
|
|
|
lsa_hton_body1(body, length - sizeof(struct ospf_lsa_header));
|
2009-08-27 16:25:46 +00:00
|
|
|
|
2009-09-04 09:06:51 +00:00
|
|
|
/*
|
2009-08-27 16:25:46 +00:00
|
|
|
char buf[1024];
|
|
|
|
memcpy(buf, h, sizeof(struct ospf_lsa_header));
|
|
|
|
memcpy(buf + sizeof(struct ospf_lsa_header), body, length - sizeof(struct ospf_lsa_header));
|
|
|
|
buf_dump("CALC", buf, length);
|
2009-09-04 09:06:51 +00:00
|
|
|
*/
|
2000-04-02 20:41:33 +00:00
|
|
|
|
2004-06-06 18:45:08 +00:00
|
|
|
(void) lsasum_check(h, body);
|
2004-06-06 09:37:54 +00:00
|
|
|
|
2009-09-04 09:06:51 +00:00
|
|
|
// log(L_WARN "Checksum result %4x", h->checksum);
|
2009-08-27 16:25:46 +00:00
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
lsa_ntoh_hdr(h, h);
|
|
|
|
lsa_ntoh_body1(body, length - sizeof(struct ospf_lsa_header));
|
2000-04-02 20:41:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note, that this function expects that LSA is in big endianity
|
|
|
|
* It also returns value in big endian
|
|
|
|
*/
|
|
|
|
u16
|
2004-06-06 18:45:08 +00:00
|
|
|
lsasum_check(struct ospf_lsa_header *h, void *body)
|
2000-04-01 02:45:49 +00:00
|
|
|
{
|
|
|
|
u8 *sp, *ep, *p, *q, *b;
|
|
|
|
int c0 = 0, c1 = 0;
|
|
|
|
int x, y;
|
2003-08-26 10:41:02 +00:00
|
|
|
u16 length;
|
2000-04-01 02:45:49 +00:00
|
|
|
|
2003-08-26 10:41:02 +00:00
|
|
|
b = body;
|
2009-08-27 16:25:46 +00:00
|
|
|
sp = (char *) h;
|
2009-08-21 07:27:52 +00:00
|
|
|
sp += 2; /* Skip Age field */
|
2004-06-06 09:37:54 +00:00
|
|
|
length = ntohs(h->length) - 2;
|
2000-04-02 20:41:33 +00:00
|
|
|
h->checksum = 0;
|
2000-04-01 02:45:49 +00:00
|
|
|
|
|
|
|
for (ep = sp + length; sp < ep; sp = q)
|
2004-06-06 09:37:54 +00:00
|
|
|
{ /* Actually MODX is very large, do we need the for-cyclus? */
|
2000-04-02 20:41:33 +00:00
|
|
|
q = sp + MODX;
|
2004-06-06 09:37:54 +00:00
|
|
|
if (q > ep)
|
|
|
|
q = ep;
|
2000-04-02 20:41:33 +00:00
|
|
|
for (p = sp; p < q; p++)
|
2000-04-01 02:45:49 +00:00
|
|
|
{
|
2000-04-02 20:41:33 +00:00
|
|
|
/*
|
|
|
|
* I count with bytes from header and than from body
|
|
|
|
* but if there is no body, it's appended to header
|
|
|
|
* (probably checksum in update receiving) and I go on
|
|
|
|
* after header
|
|
|
|
*/
|
2004-06-06 09:37:54 +00:00
|
|
|
if ((b == NULL) || (p < (u8 *) (h + 1)))
|
2000-04-02 20:41:33 +00:00
|
|
|
{
|
2004-06-06 09:37:54 +00:00
|
|
|
c0 += *p;
|
2000-04-02 20:41:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-07-03 21:24:38 +00:00
|
|
|
c0 += *(b + (p - (u8 *) (h + 1)));
|
2000-04-02 20:41:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
c1 += c0;
|
2000-04-01 02:45:49 +00:00
|
|
|
}
|
2000-04-02 20:41:33 +00:00
|
|
|
c0 %= 255;
|
|
|
|
c1 %= 255;
|
|
|
|
}
|
2000-04-01 02:45:49 +00:00
|
|
|
|
2010-05-02 20:41:40 +00:00
|
|
|
x = (int)((length - LSA_CHECKSUM_OFFSET) * c0 - c1) % 255;
|
2004-06-06 09:37:54 +00:00
|
|
|
if (x <= 0)
|
|
|
|
x += 255;
|
2000-04-01 02:45:49 +00:00
|
|
|
y = 510 - c0 - x;
|
2004-06-06 09:37:54 +00:00
|
|
|
if (y > 255)
|
|
|
|
y -= 255;
|
2000-04-01 02:45:49 +00:00
|
|
|
|
2004-06-06 09:37:54 +00:00
|
|
|
((u8 *) & h->checksum)[0] = x;
|
|
|
|
((u8 *) & h->checksum)[1] = y;
|
2003-08-26 10:41:02 +00:00
|
|
|
return h->checksum;
|
2000-04-01 02:45:49 +00:00
|
|
|
}
|
|
|
|
|
2000-04-02 19:04:23 +00:00
|
|
|
int
|
|
|
|
lsa_comp(struct ospf_lsa_header *l1, struct ospf_lsa_header *l2)
|
2000-04-02 20:41:33 +00:00
|
|
|
/* Return codes from point of view of l1 */
|
2000-04-02 19:04:23 +00:00
|
|
|
{
|
2004-06-06 09:37:54 +00:00
|
|
|
u32 sn1, sn2;
|
2000-05-31 18:21:42 +00:00
|
|
|
|
2004-06-06 09:37:54 +00:00
|
|
|
sn1 = l1->sn - LSA_INITSEQNO + 1;
|
|
|
|
sn2 = l2->sn - LSA_INITSEQNO + 1;
|
2000-05-31 18:21:42 +00:00
|
|
|
|
2004-06-06 09:37:54 +00:00
|
|
|
if (sn1 > sn2)
|
|
|
|
return CMP_NEWER;
|
|
|
|
if (sn1 < sn2)
|
|
|
|
return CMP_OLDER;
|
2000-05-30 15:01:51 +00:00
|
|
|
|
2004-06-06 09:37:54 +00:00
|
|
|
if (l1->checksum != l2->checksum)
|
|
|
|
return l1->checksum < l2->checksum ? CMP_OLDER : CMP_NEWER;
|
2000-05-30 15:01:51 +00:00
|
|
|
|
2004-06-06 09:37:54 +00:00
|
|
|
if ((l1->age == LSA_MAXAGE) && (l2->age != LSA_MAXAGE))
|
|
|
|
return CMP_NEWER;
|
|
|
|
if ((l2->age == LSA_MAXAGE) && (l1->age != LSA_MAXAGE))
|
|
|
|
return CMP_OLDER;
|
2000-05-30 15:01:51 +00:00
|
|
|
|
2004-06-06 09:37:54 +00:00
|
|
|
if (ABS(l1->age - l2->age) > LSA_MAXAGEDIFF)
|
|
|
|
return l1->age < l2->age ? CMP_NEWER : CMP_OLDER;
|
2000-05-30 15:01:51 +00:00
|
|
|
|
|
|
|
return CMP_SAME;
|
2000-04-02 19:04:23 +00:00
|
|
|
}
|
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
|
|
|
|
static inline int
|
|
|
|
lsa_walk_rt2(struct ospf_lsa_rt_walk *rt)
|
|
|
|
{
|
|
|
|
if (rt->buf >= rt->bufend)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
struct ospf_lsa_rt2_link *l = rt->buf;
|
|
|
|
rt->buf += sizeof(struct ospf_lsa_rt2_link) + l->no_tos * sizeof(struct ospf_lsa_rt2_tos);
|
|
|
|
|
|
|
|
rt->type = l->type;
|
|
|
|
rt->metric = l->metric;
|
|
|
|
rt->id = l->id;
|
|
|
|
rt->data = l->data;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
lsa_walk_rt3(struct ospf_lsa_rt_walk *rt)
|
|
|
|
{
|
|
|
|
while (rt->buf >= rt->bufend)
|
|
|
|
{
|
2012-10-19 14:26:51 +00:00
|
|
|
rt->en = ospf_hash_find_rt3_next(rt->en);
|
2012-08-05 20:32:06 +00:00
|
|
|
if (!rt->en)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
rt->buf = rt->en->lsa_body;
|
|
|
|
rt->bufend = rt->buf + rt->en->lsa.length - sizeof(struct ospf_lsa_header);
|
|
|
|
rt->buf += sizeof(struct ospf_lsa_rt);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ospf_lsa_rt3_link *l = rt->buf;
|
|
|
|
rt->buf += sizeof(struct ospf_lsa_rt3_link);
|
|
|
|
|
|
|
|
rt->type = l->type;
|
|
|
|
rt->metric = l->metric;
|
|
|
|
rt->lif = l->lif;
|
|
|
|
rt->nif = l->nif;
|
|
|
|
rt->id = l->id;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
lsa_walk_rt_init(struct proto_ospf *po, struct top_hash_entry *act, struct ospf_lsa_rt_walk *rt)
|
|
|
|
{
|
|
|
|
rt->ospf2 = ospf_is_v2(po);
|
|
|
|
rt->id = rt->data = rt->lif = rt->nif = 0;
|
|
|
|
|
|
|
|
if (rt->ospf2)
|
|
|
|
rt->en = act;
|
|
|
|
else
|
2012-10-19 14:26:51 +00:00
|
|
|
rt->en = ospf_hash_find_rt3_first(po->gr, act->domain, act->lsa.rt);
|
2012-08-05 20:32:06 +00:00
|
|
|
|
|
|
|
rt->buf = rt->en->lsa_body;
|
|
|
|
rt->bufend = rt->buf + rt->en->lsa.length - sizeof(struct ospf_lsa_header);
|
|
|
|
rt->buf += sizeof(struct ospf_lsa_rt);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
lsa_walk_rt(struct ospf_lsa_rt_walk *rt)
|
|
|
|
{
|
|
|
|
return rt->ospf2 ? lsa_walk_rt2(rt) : lsa_walk_rt3(rt);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
lsa_parse_sum_net(struct top_hash_entry *en, int ospf2, ip_addr *ip, int *pxlen, u8 *pxopts, u32 *metric)
|
|
|
|
{
|
|
|
|
if (ospf2)
|
|
|
|
{
|
|
|
|
struct ospf_lsa_sum2 *ls = en->lsa_body;
|
|
|
|
*ip = ipa_from_u32(en->lsa.id & ls->netmask);
|
|
|
|
*pxlen = u32_masklen(ls->netmask);
|
|
|
|
*pxopts = 0;
|
|
|
|
*metric = ls->metric & METRIC_MASK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct ospf_lsa_sum3_net *ls = en->lsa_body;
|
|
|
|
u16 rest;
|
|
|
|
lsa_get_ipv6_prefix(ls->prefix, ip, pxlen, pxopts, &rest);
|
|
|
|
*metric = ls->metric & METRIC_MASK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
lsa_parse_sum_rt(struct top_hash_entry *en, int ospf2, u32 *drid, u32 *metric, u32 *options)
|
|
|
|
{
|
|
|
|
if (ospf2)
|
|
|
|
{
|
|
|
|
struct ospf_lsa_sum2 *ls = en->lsa_body;
|
|
|
|
*drid = en->lsa.id;
|
|
|
|
*metric = ls->metric & METRIC_MASK;
|
|
|
|
*options = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct ospf_lsa_sum3_rt *ls = en->lsa_body;
|
|
|
|
*drid = ls->drid;
|
|
|
|
*metric = ls->metric & METRIC_MASK;
|
|
|
|
*options = ls->options & OPTIONS_MASK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
lsa_parse_ext(struct top_hash_entry *en, int ospf2, struct ospf_lsa_ext_local *rt)
|
|
|
|
{
|
|
|
|
if (ospf2)
|
|
|
|
{
|
|
|
|
struct ospf_lsa_ext2 *ext = en->lsa_body;
|
|
|
|
rt->ip = ipa_from_u32(en->lsa.id & ext->netmask);
|
|
|
|
rt->pxlen = u32_masklen(ext->netmask);
|
|
|
|
rt->pxopts = 0;
|
|
|
|
rt->metric = ext->metric & METRIC_MASK;
|
|
|
|
rt->ebit = ext->metric & LSA_EXT2_EBIT;
|
|
|
|
|
|
|
|
rt->fbit = ip4_nonzero(ext->fwaddr);
|
|
|
|
rt->fwaddr = ipa_from_ip4(ext->fwaddr);
|
|
|
|
|
|
|
|
rt->tag = ext->tag;
|
|
|
|
rt->propagate = lsa_get_options(&en->lsa) & OPT_P;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct ospf_lsa_ext3 *ext = en->lsa_body;
|
|
|
|
u16 rest;
|
|
|
|
u32 *buf = lsa_get_ipv6_prefix(ext->rest, &rt->ip, &rt->pxlen, &rt->pxopts, &rest);
|
|
|
|
rt->metric = ext->metric & METRIC_MASK;
|
|
|
|
rt->ebit = ext->metric & LSA_EXT3_EBIT;
|
|
|
|
|
|
|
|
rt->fbit = ext->metric & LSA_EXT3_FBIT;
|
|
|
|
if (rt->fbit)
|
|
|
|
buf = lsa_get_ipv6_addr(buf, &rt->fwaddr);
|
|
|
|
else
|
|
|
|
rt->fwaddr = IPA_NONE;
|
|
|
|
|
|
|
|
rt->tag = (ext->metric & LSA_EXT3_TBIT) ? *buf++ : 0;
|
|
|
|
rt->propagate = rt->pxopts & OPT_PX_P;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-29 22:57:42 +00:00
|
|
|
#define HDRLEN sizeof(struct ospf_lsa_header)
|
|
|
|
|
|
|
|
static int
|
2012-10-02 09:44:05 +00:00
|
|
|
lsa_validate_rt2(struct ospf_lsa_header *lsa, struct ospf_lsa_rt *body)
|
2009-10-29 22:57:42 +00:00
|
|
|
{
|
|
|
|
if (lsa->length < (HDRLEN + sizeof(struct ospf_lsa_rt)))
|
|
|
|
return 0;
|
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
unsigned i = 0;
|
|
|
|
void *buf = body;
|
|
|
|
void *bufend = buf + lsa->length - HDRLEN;
|
|
|
|
buf += sizeof(struct ospf_lsa_rt);
|
2009-10-29 22:57:42 +00:00
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
while (buf < bufend)
|
2009-10-29 22:57:42 +00:00
|
|
|
{
|
2012-10-02 09:44:05 +00:00
|
|
|
struct ospf_lsa_rt2_link *l = buf;
|
|
|
|
buf += sizeof(struct ospf_lsa_rt2_link) + l->no_tos * sizeof(struct ospf_lsa_rt2_tos);
|
|
|
|
i++;
|
|
|
|
|
|
|
|
if (buf > bufend)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!((l->type == LSART_PTP) ||
|
|
|
|
(l->type == LSART_NET) ||
|
|
|
|
(l->type == LSART_STUB) ||
|
|
|
|
(l->type == LSART_VLNK)))
|
2009-10-29 22:57:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2012-10-02 09:44:05 +00:00
|
|
|
|
|
|
|
if ((body->options & LSA_RT2_LINKS) != i)
|
|
|
|
return 0;
|
|
|
|
|
2009-10-29 22:57:42 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
|
2009-10-29 22:57:42 +00:00
|
|
|
static int
|
2012-10-02 09:44:05 +00:00
|
|
|
lsa_validate_rt3(struct ospf_lsa_header *lsa, struct ospf_lsa_rt *body)
|
2009-10-29 22:57:42 +00:00
|
|
|
{
|
2012-10-02 09:44:05 +00:00
|
|
|
if (lsa->length < (HDRLEN + sizeof(struct ospf_lsa_rt)))
|
2009-10-29 22:57:42 +00:00
|
|
|
return 0;
|
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
void *buf = body;
|
|
|
|
void *bufend = buf + lsa->length - HDRLEN;
|
|
|
|
buf += sizeof(struct ospf_lsa_rt);
|
|
|
|
|
|
|
|
while (buf < bufend)
|
|
|
|
{
|
|
|
|
struct ospf_lsa_rt3_link *l = buf;
|
|
|
|
buf += sizeof(struct ospf_lsa_rt3_link);
|
|
|
|
|
|
|
|
if (buf > bufend)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!((l->type == LSART_PTP) ||
|
|
|
|
(l->type == LSART_NET) ||
|
|
|
|
(l->type == LSART_VLNK)))
|
|
|
|
return 0;
|
|
|
|
}
|
2009-10-29 22:57:42 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-02 09:44:05 +00:00
|
|
|
lsa_validate_net(struct ospf_lsa_header *lsa, struct ospf_lsa_net *body UNUSED)
|
2009-10-29 22:57:42 +00:00
|
|
|
{
|
2012-10-02 09:44:05 +00:00
|
|
|
if (lsa->length < (HDRLEN + sizeof(struct ospf_lsa_net)))
|
2009-10-29 22:57:42 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-02 09:44:05 +00:00
|
|
|
lsa_validate_sum2(struct ospf_lsa_header *lsa, struct ospf_lsa_sum2 *body)
|
2009-10-29 22:57:42 +00:00
|
|
|
{
|
2012-10-02 09:44:05 +00:00
|
|
|
if (lsa->length < (HDRLEN + sizeof(struct ospf_lsa_sum2)))
|
2009-10-29 22:57:42 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* First field should have TOS = 0, we ignore other TOS fields */
|
2012-10-02 09:44:05 +00:00
|
|
|
if ((body->metric & LSA_SUM2_TOS) != 0)
|
2009-10-29 22:57:42 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
pxlen(u32 *buf)
|
|
|
|
{
|
|
|
|
return *buf >> 24;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-02 09:44:05 +00:00
|
|
|
lsa_validate_sum3_net(struct ospf_lsa_header *lsa, struct ospf_lsa_sum3_net *body)
|
2009-10-29 22:57:42 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
if (lsa->length < (HDRLEN + sizeof(struct ospf_lsa_sum3_net) + 4))
|
2009-10-29 22:57:42 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
u8 pxl = pxlen(body->prefix);
|
|
|
|
if (pxl > MAX_PREFIX_LENGTH)
|
|
|
|
return 0;
|
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
if (lsa->length != (HDRLEN + sizeof(struct ospf_lsa_sum3_net) +
|
2009-10-29 22:57:42 +00:00
|
|
|
IPV6_PREFIX_SPACE(pxl)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-02 09:44:05 +00:00
|
|
|
lsa_validate_sum3_rt(struct ospf_lsa_header *lsa, struct ospf_lsa_sum3_rt *body)
|
2009-10-29 22:57:42 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
if (lsa->length != (HDRLEN + sizeof(struct ospf_lsa_sum3_rt)))
|
2009-10-29 22:57:42 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-02 09:44:05 +00:00
|
|
|
lsa_validate_ext2(struct ospf_lsa_header *lsa, struct ospf_lsa_ext2 *body)
|
|
|
|
{
|
|
|
|
if (lsa->length < (HDRLEN + sizeof(struct ospf_lsa_ext2)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* First field should have TOS = 0, we ignore other TOS fields */
|
|
|
|
if ((body->metric & LSA_EXT2_TOS) != 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
lsa_validate_ext3(struct ospf_lsa_header *lsa, struct ospf_lsa_ext3 *body)
|
2009-10-29 22:57:42 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
if (lsa->length < (HDRLEN + sizeof(struct ospf_lsa_ext3) + 4))
|
2009-10-29 22:57:42 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
u8 pxl = pxlen(body->rest);
|
|
|
|
if (pxl > MAX_PREFIX_LENGTH)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int len = IPV6_PREFIX_SPACE(pxl);
|
2012-08-05 20:32:06 +00:00
|
|
|
if (body->metric & LSA_EXT3_FBIT) // forwardinf address
|
2009-10-29 22:57:42 +00:00
|
|
|
len += 16;
|
2012-08-05 20:32:06 +00:00
|
|
|
if (body->metric & LSA_EXT3_TBIT) // route tag
|
2009-10-29 22:57:42 +00:00
|
|
|
len += 4;
|
|
|
|
if (*body->rest & 0xFFFF) // referenced LS type field
|
|
|
|
len += 4;
|
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
if (lsa->length != (HDRLEN + sizeof(struct ospf_lsa_ext3) + len))
|
2009-10-29 22:57:42 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
lsa_validate_pxlist(struct ospf_lsa_header *lsa, u32 pxcount, unsigned int offset, u8 *pbuf)
|
|
|
|
{
|
|
|
|
unsigned int bound = lsa->length - HDRLEN - 4;
|
|
|
|
u32 i;
|
|
|
|
|
|
|
|
for (i = 0; i < pxcount; i++)
|
|
|
|
{
|
|
|
|
if (offset > bound)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
u8 pxl = pxlen((u32 *) (pbuf + offset));
|
|
|
|
if (pxl > MAX_PREFIX_LENGTH)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
offset += IPV6_PREFIX_SPACE(pxl);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lsa->length != (HDRLEN + offset))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
lsa_validate_link(struct ospf_lsa_header *lsa, struct ospf_lsa_link *body)
|
|
|
|
{
|
|
|
|
if (lsa->length < (HDRLEN + sizeof(struct ospf_lsa_link)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return lsa_validate_pxlist(lsa, body->pxcount, sizeof(struct ospf_lsa_link), (u8 *) body);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
lsa_validate_prefix(struct ospf_lsa_header *lsa, struct ospf_lsa_prefix *body)
|
|
|
|
{
|
|
|
|
if (lsa->length < (HDRLEN + sizeof(struct ospf_lsa_prefix)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return lsa_validate_pxlist(lsa, body->pxcount, sizeof(struct ospf_lsa_prefix), (u8 *) body);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* lsa_validate - check whether given LSA is valid
|
|
|
|
* @lsa: LSA header
|
|
|
|
* @body: pointer to LSA body
|
|
|
|
*
|
|
|
|
* Checks internal structure of given LSA body (minimal length,
|
|
|
|
* consistency). Returns true if valid.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
2012-10-02 09:44:05 +00:00
|
|
|
lsa_validate(struct ospf_lsa_header *lsa, u32 lsa_type, int ospf2, void *body)
|
2009-10-29 22:57:42 +00:00
|
|
|
{
|
2012-10-02 09:44:05 +00:00
|
|
|
if (ospf2)
|
|
|
|
{
|
|
|
|
switch (lsa_type)
|
2009-10-29 22:57:42 +00:00
|
|
|
{
|
|
|
|
case LSA_T_RT:
|
2012-10-02 09:44:05 +00:00
|
|
|
return lsa_validate_rt2(lsa, body);
|
2009-10-29 22:57:42 +00:00
|
|
|
case LSA_T_NET:
|
|
|
|
return lsa_validate_net(lsa, body);
|
|
|
|
case LSA_T_SUM_NET:
|
2012-10-02 09:44:05 +00:00
|
|
|
return lsa_validate_sum2(lsa, body);
|
2009-10-29 22:57:42 +00:00
|
|
|
case LSA_T_SUM_RT:
|
2012-10-02 09:44:05 +00:00
|
|
|
return lsa_validate_sum2(lsa, body);
|
2009-10-29 22:57:42 +00:00
|
|
|
case LSA_T_EXT:
|
2011-07-20 21:40:20 +00:00
|
|
|
case LSA_T_NSSA:
|
2012-10-02 09:44:05 +00:00
|
|
|
return lsa_validate_ext2(lsa, body);
|
|
|
|
default:
|
|
|
|
return 0; /* Should not happen, unknown LSAs are already rejected */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (lsa_type)
|
|
|
|
{
|
|
|
|
case LSA_T_RT:
|
|
|
|
return lsa_validate_rt3(lsa, body);
|
|
|
|
case LSA_T_NET:
|
|
|
|
return lsa_validate_net(lsa, body);
|
|
|
|
case LSA_T_SUM_NET:
|
|
|
|
return lsa_validate_sum3_net(lsa, body);
|
|
|
|
case LSA_T_SUM_RT:
|
|
|
|
return lsa_validate_sum3_rt(lsa, body);
|
|
|
|
case LSA_T_EXT:
|
|
|
|
case LSA_T_NSSA:
|
|
|
|
return lsa_validate_ext3(lsa, body);
|
2009-10-29 22:57:42 +00:00
|
|
|
case LSA_T_LINK:
|
|
|
|
return lsa_validate_link(lsa, body);
|
|
|
|
case LSA_T_PREFIX:
|
|
|
|
return lsa_validate_prefix(lsa, body);
|
|
|
|
default:
|
2012-10-02 09:44:05 +00:00
|
|
|
return 1; /* Unknown LSAs are OK in OSPFv3 */
|
2009-10-29 22:57:42 +00:00
|
|
|
}
|
2012-10-02 09:44:05 +00:00
|
|
|
}
|
2009-10-29 22:57:42 +00:00
|
|
|
}
|
|
|
|
|
2000-06-07 22:31:47 +00:00
|
|
|
/**
|
|
|
|
* lsa_install_new - install new LSA into database
|
2009-08-21 07:27:52 +00:00
|
|
|
* @po: OSPF protocol
|
2000-06-07 22:31:47 +00:00
|
|
|
* @lsa: LSA header
|
2009-08-21 07:27:52 +00:00
|
|
|
* @domain: domain of LSA
|
2000-06-08 12:42:34 +00:00
|
|
|
* @body: pointer to LSA body
|
2000-06-07 22:31:47 +00:00
|
|
|
*
|
|
|
|
* This function ensures installing new LSA into LSA database. Old instance is
|
2002-04-03 15:41:05 +00:00
|
|
|
* replaced. Several actions are taken to detect if new routing table
|
2000-06-07 22:31:47 +00:00
|
|
|
* calculation is necessary. This is described in 13.2 of RFC 2328.
|
|
|
|
*/
|
2000-04-04 15:55:55 +00:00
|
|
|
struct top_hash_entry *
|
2009-08-21 07:27:52 +00:00
|
|
|
lsa_install_new(struct proto_ospf *po, struct ospf_lsa_header *lsa, u32 domain, void *body)
|
2000-04-04 15:55:55 +00:00
|
|
|
{
|
2012-10-19 14:26:51 +00:00
|
|
|
/* LSA can be temporary, but body must be mb_allocated. */
|
2004-06-06 09:37:54 +00:00
|
|
|
int change = 0;
|
2000-04-04 15:55:55 +00:00
|
|
|
struct top_hash_entry *en;
|
|
|
|
|
2009-08-25 14:42:14 +00:00
|
|
|
if ((en = ospf_hash_find_header(po->gr, domain, lsa)) == NULL)
|
2000-04-04 15:55:55 +00:00
|
|
|
{
|
2009-08-25 14:42:14 +00:00
|
|
|
en = ospf_hash_get_header(po->gr, domain, lsa);
|
2004-06-06 09:37:54 +00:00
|
|
|
change = 1;
|
2000-04-04 15:55:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-10-19 14:26:51 +00:00
|
|
|
if ((en->lsa.length != lsa->length) ||
|
|
|
|
(en->lsa.type_raw != lsa->type_raw) || /* check for OSPFv2 options */
|
|
|
|
(en->lsa.age == LSA_MAXAGE) ||
|
|
|
|
(lsa->age == LSA_MAXAGE) ||
|
|
|
|
memcmp(en->lsa_body, body, lsa->length - sizeof(struct ospf_lsa_header)))
|
2004-06-06 09:37:54 +00:00
|
|
|
change = 1;
|
2009-08-21 07:27:52 +00:00
|
|
|
|
2000-06-05 02:23:20 +00:00
|
|
|
s_rem_node(SNODE en);
|
2000-04-30 22:14:31 +00:00
|
|
|
}
|
|
|
|
|
2009-07-23 14:51:28 +00:00
|
|
|
DBG("Inst lsa: Id: %R, Rt: %R, Type: %u, Age: %u, Sum: %u, Sn: 0x%x\n",
|
|
|
|
lsa->id, lsa->rt, lsa->type, lsa->age, lsa->checksum, lsa->sn);
|
2000-06-05 02:23:20 +00:00
|
|
|
|
2004-07-15 16:37:52 +00:00
|
|
|
s_add_tail(&po->lsal, SNODE en);
|
2004-06-06 09:37:54 +00:00
|
|
|
en->inst_t = now;
|
|
|
|
if (en->lsa_body != NULL)
|
|
|
|
mb_free(en->lsa_body);
|
|
|
|
en->lsa_body = body;
|
|
|
|
memcpy(&en->lsa, lsa, sizeof(struct ospf_lsa_header));
|
|
|
|
en->ini_age = en->lsa.age;
|
|
|
|
|
|
|
|
if (change)
|
2004-06-06 16:00:09 +00:00
|
|
|
schedule_rtcalc(po);
|
2004-06-06 09:37:54 +00:00
|
|
|
|
2000-04-04 15:55:55 +00:00
|
|
|
return en;
|
|
|
|
}
|