Mailing List Archive

ospfd fix for byte ordering bug on intel
I would like to submit this patch for ospfd

-fixes for byte ordering bug encountered on intel

-LOOKUP can return null if index is out of range

===================================================================
RCS file: ospf_dump.c,v
retrieving revision 1.3
diff -uwb -r1.3 ospf_dump.c
--- ospf_dump.c 2003/07/12 21:30:57 1.3
+++ ospf_dump.c 2004/05/28 15:28:36
@@ -325,12 +325,15 @@
void
ospf_lsa_header_dump (struct lsa_header *lsah)
{
+ char *lsah_type;
+
zlog_info (" LSA Header");
zlog_info (" LS age %d", ntohs (lsah->ls_age));
zlog_info (" Options %d (%s)", lsah->options,
ospf_options_dump (lsah->options));
+ lsah_type = LOOKUP (ospf_lsa_type_msg, lsah->type);
zlog_info (" LS type %d (%s)", lsah->type,
- LOOKUP (ospf_lsa_type_msg, lsah->type));
+ (lsah->type ? lsah_type : "unknown type"));
zlog_info (" Link State ID %s", inet_ntoa (lsah->id));
zlog_info (" Advertising Router %s", inet_ntoa (lsah->adv_router));
zlog_info (" LS sequence number 0x%lx", (u_long)ntohl
(lsah->ls_seqnum));



-zebra on x86 -fixes for incorrect print fields in debug statement
===================================================================
RCS file: ospf_flood.c,v
retrieving revision 1.8
diff -uwb -r1.8 ospf_flood.c
--- ospf_flood.c 2004/03/04 17:45:01 1.8
+++ ospf_flood.c 2004/05/28 14:25:11
@@ -121,7 +121,7 @@
if (IS_DEBUG_OSPF_EVENT)
zlog_info ("LSA[Type%d:%s]: Process self-originated LSA seq 0x%lx",
new->data->type, inet_ntoa (new->data->id),
- (u_long)new->data->ls_seqnum);
+ ntohl(new->data->ls_seqnum));

/* If we're here, we installed a self-originated LSA that we received
from a neighbor, i.e. it's more recent. We must see whether we want


zebra on x86 -
- fixes the ntohl of ls_seqnum, ntohs of ls_age
===================================================================
RCS file: ospf_lsa.c,v
retrieving revision 1.23
diff -uwb -r1.23 ospf_lsa.c
--- ospf_lsa.c 2003/10/13 09:06:46 1.23
+++ ospf_lsa.c 2004/05/28 14:46:52
@@ -2382,7 +2382,7 @@
if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
zlog_info("LSA[Type%d]: ID %s seq 0x%x is self-originated",
new->data->type, inet_ntoa (new->data->id),
- new->data->ls_seqnum);
+ ntohl(new->data->ls_seqnum));
}

return new;
@@ -2652,7 +2652,7 @@
can be originated. "
*/

- if (lsa->data->ls_seqnum - 1 == htonl(OSPF_MAX_SEQUENCE_NUMBER))
+ if (ntohl(lsa->data->ls_seqnum) - 1 == OSPF_MAX_SEQUENCE_NUMBER)
{
if (ospf_lsa_is_self_originated(ospf, lsa))
{
@@ -2770,7 +2770,8 @@
{
if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
zlog_info ("LSA[Type%d:%s]: Install LSA 0x%lx, MaxAge",
- new->data->type, inet_ntoa (new->data->id), (u_long)lsa);
+ new->data->type, inet_ntoa (new->data->id), (u_long)lsa,
+ ntohl(lsa->data->ls_seqnum));
ospf_lsa_maxage (ospf, lsa);
}

@@ -2942,7 +2943,10 @@
listnode_add (ospf->maxage_lsa, ospf_lsa_lock (lsa));

if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
- zlog_info ("LSA[%s]: MaxAge LSA remover scheduled.", dump_lsa_key
(lsa));
+ zlog_info ("LSA[Type%d:%s]: lsa 0x%lx seq 0x%lx "
+ "MaxAge LSA remover scheduled.",
+ lsa->data->type, inet_ntoa (lsa->data->id), lsa,
+ ntohl(lsa->data->ls_seqnum));

OSPF_TIMER_ON (ospf->t_maxage, ospf_maxage_lsa_remover, 2);
}
@@ -2962,7 +2966,9 @@
if (!ospf_lsa_is_self_originated (ospf, lsa))
{
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
- zlog_info("LSA[%s]: is MaxAge", dump_lsa_key (lsa));
+ zlog_info("LSA[Type%d:%s] seq 0x%lx is MaxAge",
lsa->data->type,
+ inet_ntoa (lsa->data->id),
+ ntohl(lsa->data->ls_seqnum));

switch (lsa->data->type)
{


Sagun Shakya
Internet Protocols Systems Group
781.442.7344/ X27344
sagun.shakya@sun.com
Re: ospfd fix for byte ordering bug on intel [ In reply to ]
Cheers Sagun,

Not all of them applied though. I've gone through ospf_lsa.c and
audited all references of (struct lsa *)->data->ls_seqnum to match
intent of your patch.

On Fri, 28 May 2004, Sagun Shakya wrote:

> I would like to submit this patch for ospfd
>
> -fixes for byte ordering bug encountered on intel
>
> -LOOKUP can return null if index is out of range

regards,
--
Paul Jakma paul@clubi.ie paul@jakma.org Key ID: 64A2FF6A
warning: do not ever send email to spam@dishone.st
Fortune:
..you could spend *all day* customizing the title bar. Believe me. I
speak from experience."
(By Matt Welsh)