Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mel.connect.com.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!worldnet.att.net!europa.clark.net!newsfeed2!newsfeed.internetmci.com!scoop.eco.twg.com!twg.com!usenet
From: Jos Scherders <joss@twg.com>
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Question about rn_addroute() function.
Date: Tue, 08 Apr 1997 20:31:30 -0700
Organization: Attachmate Corporation
Lines: 57
Message-ID: <334B0D92.1EA9@twg.com>
NNTP-Posting-Host: batcave.twg.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 2.02 (Win16; I)
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:38763
Hi all,
I am trying to understand how the BSDI handles IP routing. I have
reasonable idea know but I fail the understand some lines of the
function rn_addroute() (radix.c). This is the code fragment
I am referring too:
/*
* If the mask is not duplicated, we wouldn't
* find it among possible duplicate key entries
* anyway, so the above test doesn't hurt.
*
* We sort the masks for a duplicated key the same way
* in a masklist -- most specific to least specific.
* This may require the unfortunate nuisance of
* relocating
* the head of the list.
*/
if (tt == saved_tt) {
struct radix_node *xx = x;
/* link in at head of list */
(tt = treenodes)->rn_dupedkey = t;
tt->rn_flags = t->rn_flags;
tt->rn_p = x = t->rn_p;
t->rn_p = tt; /* parent
*/
if (x->rn_l == t) x->rn_l = tt; else x->rn_r =
tt;
saved_tt = tt; x = xx;
} else {
(tt = treenodes)->rn_dupedkey = t->rn_dupedkey;
t->rn_dupedkey = tt;
tt->rn_p = t; /* parent
*/
if (tt->rn_dupedkey) /* parent
*/
tt->rn_dupedkey->rn_p = tt; /* parent
*/
}
#ifdef RN_DEBUG
t=tt+1; tt->rn_info = rn_nodenum++; t->rn_info =
rn_nodenum++;
tt->rn_twin = t; tt->rn_ybro = rn_clist; rn_clist = tt;
#endif
tt->rn_key = (caddr_t) v;
tt->rn_b = -1;
tt->rn_flags = RNF_ACTIVE;
}
I thought the rn_dupedkey pointed to a linked list of nodes containing
the same key. I also thought the masks where stored in a linked list but
the above codes manipulates left/right pointers of a tree node. Can some
explain what is really happening in here ?
Jos.
Jos Scherders
joss@rahul.net