
http://www.eowyn.fr.eu.org/patch/

Before installing this patch, check that you have already installed
Perl5, Mirror and Autoconf on your system. If your system doesn't
support NDBM, you may install GDBM that includes NDBM compatibility
routines.

Perl5 must be installed as /usr/local/bin/perl (if not, modify
makeindex.pl to match the good path).

To apply this patch, you need to perform the following steps :

1. untar the Harvest Cache distribution
2. apply the patch to the source tree
3. run autoheader and autoconf
4. make and install the Harvest Cache
5. retrieve and index the databases
6. modify your cached.conf
7. start the cache and test your database


1. untar the Harvest Cache distribution
---------------------------------------
Untar the Harvest Cache and the Patch package at the same level :

	% gzip -dc cached-ASpatch-1.0.tar.gz | tar xf -
	% gzip -dc cached-1.4.pl2-src.tar.gz | tar xf -
	% ls
	cached-1.4.pl2/                 cached-ASpatch-1.0/
	cached-1.4.pl2-src.tar.gz       cached-ASpatch-1.0.tar.gz
	% ls cached-ASpatch-1.0
	COPYRIGHT       INSTALL         diffs           makeindex.sh*
	DB/             README          makeindex.pl*   radb.pkg


2. apply the patch to the source tree
-------------------------------------
This patch makes changes to four files :
src/configure.in, src/server/cache_cf.c, src/server/neighbors.c and
src/server/cached.conf.

	% cd cached-1.4.pl2/src
	% patch -c < ../../cached-ASpatch-1.0/diffs
	% cd ../..


3. run autoheader and autoconf
------------------------------
src/configure.in being modified by the patch, so you MUST run autoheader
and autoconf, in order to generate new configure and include/autoconf.h.in.
If you do not, the cached will not be compiled with the AS capability.

	% cd cached-1.4.pl2/src
	% autoheader
	% autoconf
	% cd ../..


4. make and install the Harvest Cache
-------------------------------------
Either you want to re-install all the thing, or not.

If you want to re-install all :
	% cd cached-1.4.pl2
	% make
	% make install
	% cd ..

(Note that $HARVEST_HOME/lib/cached.conf.default will then contain
explanations for the extension of cache_host_domain and the new
autonomous_systems_database command)

If you do not want to install the whole package, because you have a
running installation that works well, you can only perform this :
	% cd cached-1.4.pl2
	% make
	% mv $HARVEST_HOME/bin/cached $HARVEST_HOME/bin/cached.orig
	% cp cached-1.4.pl2/src/server/cached $HARVEST_HOME/bin
	% cp cached-1.4.pl2/src/server/cached.conf \
	     $HARVEST_HOME/lib/cached-patch.conf
	% cd ..

(Note that $HARVEST_HOME/lib/cached-patch.conf will then contain
explanations for the extension of cache_host_domain and the new
autonomous_systems_database command)


5. retrieve and index the databases
-----------------------------------
	% cd cached-ASpatch-1.0
	% ./makeindex.sh

makeindex.sh will :
. use mirror to retrieve the databases
. build an index of the databases with makeindex.pl

If you don't have mirror, comment the line 'mirror -d -d radb.pkg'
in makeindex.sh, retreive with FTP on ftp.ra.net the content
of the directory /pub/radb/dbase, move thoses files locally to the
DB/ directory, uncompress them and run makeindex.sh.

The output of this process is net2as.* (in most cases, it will be
net2as.pag and net2as.dir).

Move the index to the correct place (for instance in $HARVEST_HOME/lib) :
	% mv net2as.* $HARVEST_HOME/lib

It would be a good policy to do this step one time a month, because
the databases change whenever a new network is announced on the INTERNET.


6. modify your cached.conf
--------------------------
You can specify autonomous systems instead of domains with
cache_host_domain when you have built a net2as database.

For example, specifying

	cache_host_domain bigserver.enst.fr !AS1717

has the effect such that query packets are sent to 'bigserver' only
when the requested object doesn't exist on a server in the autonomous system
AS1717.

It is MUCH BETTER than specifying

	cache_host_domain bigserver.enst.fr !fr

because different autonomous systems can share the same top level domain,
and most of the time, you would like to cache queries to other
autonomous systems even if they share the same top level domain as yours.

A common configuration is to put a cache_host_domain for any of your
neighbors and parent, allowing direct connections only for hosts
NOT in your autonomous system (because it's always a good policy not to
go directly when you're asked for an object on a server in another
autonomous system than yours) :

Let's say I live in France (.fr) and my network is enst.fr (137.194.0.0).
It's announced in AS1717, and I have 4 neighbors and a parent.
Let's assume that www.EUnet.fr is in France, but in another AS with
bad connectivity to my AS.
So, I write :

	cache_host_domain my_neighbor_1.fr !AS1717
	cache_host_domain my_neighbor_2.fr !AS1717
	cache_host_domain my_neighbor_3.fr !AS1717
	cache_host_domain my_neighbor_4.fr !AS1717
	cache_host_domain my_parent.fr   !AS1717

Then, when somebody asks my cache for http://www.EUnet.fr, this one
asks neighbors and parent because www.EUnet.fr is NOT in AS1717. With
a configuration file with "!fr" instead of "!AS1717" the cache would
not have asked the neighbors and parent.

Now, you must tell cached where the index resides. If the files created
at step 5 are /etc/net2as.pag and /etc/net2as.dir, you must specify :

	autonomous_systems_database /etc/net2as

These files can be very large, another place can be $HARVEST_HOME/lib/net2as.


7. start the cache and test your database
-----------------------------------------

Start the cache at debug level 5 or higher (see the Harvest Cache
documentation), and test the AS feature :

Example :
	% grep net2as cache.log
	[...] neighbors.c:270:    net2as: checking AS for 134.157.4.0/24
	[...] neighbors.c:276:    net2as: AS(134.156.0.0/15) = AS1717

The first line shows that the cache was asked to retrieve an object in
the subnet 134.157.4.0/24 of the class B network 134.157.0.0.

The second line says that the cache found an announce of size 15
(aggregated CIDR announce of two class B networks) in AS1717.

Note that we ALWAYS start with length 24 to work correctly even if we
encounter RFC 1797 Experiment networks : For class A and B addresses,
we don't start searching announces of length 8 or 16 because some
folks on the INTERNET are announcing subnets of class A (and perhaps
some day class B) networks with BGP4.  This means that it may be
possible to have several subnets of a class A or B network announced
by different autonomous systems...


	Alexandre Fenyo

Any comment or suggestion : fenyo@enst.fr

