[net.news.b] optimized network paths for news 2.10.2

wls@astrovax.UUCP (William L. Sebok) (10/15/84)

The following addition to news 2.10.2 has been posted before but it is so
important that I think it needs reiterating.  This addition implements a
C pre-processor variable NETPATHS that causes the reply command of readnews
and vnews to use optimized network paths rather than the roundabout news
arrival path.  NETPATHS is defined in defs.h to be the name of a dbm-style
file.
	This file, uses site names as keys, and under these keys stores the
path to the site with a %s in place of a name of a user at that site.  For
example, under the key "sitename" might be stored the string:
	site1!site2!sitename!%s 

A file of this form can be generated with pathalias.

If a site is not found in the database the path up to the first site in the
news path present in the database is used.

I have a somewhat different philosophy here than Chuq Von Rospach, who has
optimization invoked by a -o option.  Optimization is the default.  It is the
naive user I want make use the optimized paths.  For the sophisticated user
I have provided the News-path: field in the header which contains the
convoluted news path.  This sophisticated user can edit the full path back
by hand if he/she is so inclined.  I have intentionally made the user have to
go to some extra work to get un-optimized paths.

  It is my strong belief that these additions or some other hooks for path
optimizing should be part of the "official distribution".  After all it is
an option.  With the posting of the Uucp map I do not believe that there is
any excuse for replies with long paths bouncing around the net.  If some
hooks for path optimization are not included in the official distribution
there will be no justification for the net powers to complain about the money
wasted by replies passing through large numbers of sites.

Bill Sebok			Princeton University, Astrophysics
{allegra,akgua,burl,cbosgd,decvax,ihnp4,noao,princeton,vax135}!astrovax!wls

*** defs.h.ORIG	Mon Oct 15 01:19:25 1984
--- defs.h	Mon Oct 15 01:18:13 1984
***************
*** 47,52
  				/*   the .newsrc */
  #define ZAPNOTES		/* if you want old style notes headers moved
  				/*   into the headers */
  #define BSD4_2			/* if you are running 4.2 BSD		*/
  /* #define BSD4_1C		/* if you are running 4.1c BSD		*/
  #define SENDMAIL "/usr/lib/sendmail -oi -oem" /* command line to run

--- 47,54 -----
  				/*   the .newsrc */
  #define ZAPNOTES		/* if you want old style notes headers moved
  				/*   into the headers */
+ #define NETPATHS "/usr/lib/uucp/alpath"	/* compiles in pathalias optimizing */
+ 				/* code to read,vnews */
  #define BSD4_2			/* if you are running 4.2 BSD		*/
  /* #define BSD4_1C		/* if you are running 4.1c BSD		*/
  #define SENDMAIL "/usr/lib/sendmail -oi -oem" /* command line to run

*** visual.c.ORIG	Sat Oct  6 20:44:48 1984
--- visual.c		Sun Oct 14 23:47:19 1984
***************
*** 17,22
  
  #include <errno.h>
  #include "rparams.h"
  #if defined(BSD4_2) || defined(BSD4_1C)
  #include <sys/dir.h>
  #else

--- 17,28 -----
  
  #include <errno.h>
  #include "rparams.h"
+ #ifdef NETPATHS
+ # include <dbm.h>
+ # ifdef NULL
+ #   undef NULL
+ # endif NULL
+ #endif NETPATHS
  #if defined(BSD4_2) || defined(BSD4_1C)
  #include <sys/dir.h>
  #else
***************
*** 811,816
  	char *replyname();
  	struct stat statb;
  	time_t creatm;
  
  	/* Put the user in the editor to create the body of the reply. */
  	ed = getenv("EDITOR");

--- 839,852 -----
  	char *replyname();
  	struct stat statb;
  	time_t creatm;
+ #ifdef NETPATHS
+ 	/* stuff for finding paths in pathalias database */
+ 	static dbmopen = 0;
+ 	static char newspaths[] = NETPATHS;
+ 	datum key, result;
+ 	register char *p1, *p2;
+ 	char sitename[100];
+ #endif NETPATHS
  
  	/* Put the user in the editor to create the body of the reply. */
  	ed = getenv("EDITOR");
***************
*** 843,851
  	else
  #endif
  		p = replyname(h);
! 	fprintf(rfp, "To: %s\n", p);
! 	fprintf(rfp, "Subject: %s\n", subj);
! 	fprintf(rfp, "In-reply-to: your article %s\n", h->ident);
  	sprintf(rcbuf, "%s -t < %s; rm -f %s", MAILPARSER, tf, tf);
  	nogomsg = "Mail not sent";
  	putc('\n', rfp);

--- 879,917 -----
  	else
  #endif
  		p = replyname(h);
! #ifdef NETPATHS
! 	/* Use data Base to Find a reply a Path to a site */
! 	if (dbmopen==0)
! 		dbmopen = (dbminit(newspaths)==0) ? 1 : -1 ;
! 
! 	result.dptr = NULL;
! 	if (dbmopen>0) {
! 		for(p1 = p; (p2 = index(p1,'!'))!=NULL; p1 = p2+1);
! 		if (p != p1) {
! 			key.dptr = sitename;
! 			p1--;
! 			do {
! 				for (p2=p1; (p1!=p) && (*--p1!='!'); );
! 				key.dsize = p2 - p1 ;
! 				strncpy(sitename, p1+1, key.dsize);
! 				sitename[key.dsize-1] = '\0';
! 				result = fetch(key);
! 			} while ( (p1 != p) && result.dptr == NULL);
! 		}
! 	}
! 	if (dbmopen > 0 && result.dptr != NULL) {
! 		fprintf(rfp, "To: ");
! 		fprintf(rfp, result.dptr, p2+1);
! 		fprintf(rfp, "\nSubject: %s\n", subj);
! 		fprintf(rfp, "In-reply-to: your article %s\n", h->ident);
! 		fprintf(rfp, "News-path: %s\n", p);
! 	} else
! #endif NETPATHS
! 	{
! 		fprintf(rfp, "To: %s\n", p);
! 		fprintf(rfp, "Subject: %s\n", subj);
! 		fprintf(rfp, "In-reply-to: your article %s\n", h->ident);
! 	}
  	sprintf(rcbuf, "%s -t < %s; rm -f %s", MAILPARSER, tf, tf);
  	nogomsg = "Mail not sent";
  	putc('\n', rfp);
********************

*** readr.c.ORIG	Sat Oct  6 20:13:40 1984
--- readr.c		Sun Oct 14 23:48:24 1984
***************
*** 7,12
  #endif !lint
  
  #include "rparams.h"
  #if defined(BSD4_2) || defined(BSD4_1C)
  #include <sys/dir.h>
  #else

--- 7,20 -----
  #endif !lint
  
  #include "rparams.h"
+ 
+ #ifdef NETPATHS
+ #  include <dbm.h>
+ #  ifdef NULL
+ #    undef NULL
+ #  endif NULL
+ #endif NETPATHS
+ 
  #if defined(BSD4_2) || defined(BSD4_1C)
  #include <sys/dir.h>
  #else
***************
*** 616,621
  	char folbuf[BUFLEN];
  	struct stat statb;
  	long creatm;
  
  	hptr = h;
  	while (*bptr && index("d-", *bptr)) {

--- 644,657 -----
  	char folbuf[BUFLEN];
  	struct stat statb;
  	long creatm;
+ #ifdef NETPATHS
+ 	/* stuff for finding paths from pathalias database */
+ 	static int dbmopen = 0;
+ 	static char newspaths[] = NETPATHS;
+ 	datum key, result;
+ 	register char *p1, *p2;
+ 	char sitename[100];
+ #endif NETPATHS
  
  	hptr = h;
***************
*** 649,654
  
  	*rcbuf = '\0';
  	pathptr = replyname(hptr);;
  	for (ptr1 = address, ptr2 = pathptr; *ptr2; ptr1++, ptr2++) {
  		if (index("\"\\$", *ptr2))
  			*ptr1++ = '\\';

--- 686,717 -----
  
  	*rcbuf = '\0';
  	pathptr = replyname(hptr);;
+ #ifdef NETPATHS
+ 	/* Use data Base to Find a reply a Path to a site --- W. Sebok */
+ 	if (dbmopen==0)
+ 		dbmopen = (dbminit(newspaths)==0) ? 1 : -1 ;
+ 
+ 	result.dptr = NULL;
+ 	if (dbmopen>0) {
+ 		for(p1 = pathptr; (p2 = index(p1,'!')) != NULL; p1 = p2+1);
+ 		if (pathptr != p1) {
+ 			key.dptr = sitename;
+ 			p1--;
+ 			do {
+ 				for ( p2=p1; (p1!=pathptr) && (*--p1 != '!'); );
+ 				key.dsize = p2 - p1 ;
+ 				strncpy(sitename, p1+1, key.dsize);
+ 				sitename[key.dsize-1] = '\0';
+ 				result = fetch(key);
+ 			} while ( (p1 != pathptr) && result.dptr==NULL);
+ 		}
+ 	}
+ 	if (result.dptr != NULL) {
+ 		sprintf(sitename, result.dptr, p2+1);
+ 		p1 = pathptr;
+ 		pathptr = sitename;
+ 	}
+ #endif NETPATHS
  	for (ptr1 = address, ptr2 = pathptr; *ptr2; ptr1++, ptr2++) {
  		if (index("\"\\$", *ptr2))
  			*ptr1++ = '\\';
***************
*** 695,700
  		} else {
  			fprintf(tfp, "To: %s\n", pathptr);
  			fprintf(tfp, "Subject: %s\n", subj);
  			fprintf(tfp, "References: %s\n\n", folbuf);
  			fstat(fileno(tfp), &statb);
  			creatm = statb.st_mtime;

--- 758,767 -----
  		} else {
  			fprintf(tfp, "To: %s\n", pathptr);
  			fprintf(tfp, "Subject: %s\n", subj);
+ #ifdef NETPATHS
+ 			if (dbmopen > 0 && result.dptr != NULL)
+ 				fprintf(tfp,"News-path: %s\n",p1);
+ #endif NETPATHS
  			fprintf(tfp, "References: %s\n\n", folbuf);
  			fstat(fileno(tfp), &statb);
  			creatm = statb.st_mtime;
************
-- 
Bill Sebok			Princeton University, Astrophysics
{allegra,akgua,burl,cbosgd,decvax,ihnp4,noao,princeton,vax135}!astrovax!wls

mark@cbosgd.UUCP (Mark Horton) (10/15/84)

The official distribution HAS had such a feature since 2.10, over
a year ago.  You just define INTERNET and replies use the From
line rather than the Path line.

If you have pathalias on your system, you probably have a mailer
that is capable of dealing with internet addresses, or can make it
happen trivially.

The Path line is not intended for replies, it's intended to keep
articles from looping around the network.  The fact that it's being
used for replies just means that people don't have routing software.

wls@astrovax.UUCP (William L. Sebok) (10/17/84)

> The official distribution HAS had such a feature since 2.10, over
> a year ago.  You just define INTERNET and replies use the From
> line rather than the Path line.
> 
> If you have pathalias on your system, you probably have a mailer
> that is capable of dealing with internet addresses, or can make it
> happen trivially.
> 
> The Path line is not intended for replies, it's intended to keep
> articles from looping around the network.  The fact that it's being
> used for replies just means that people don't have routing software.

I disagree totally.  My own feeling is that the person sending the reply
should have control of the path and be able to override a (possibly erroneous)
smart mailer.  I have a smart mailer but don't trust it unless I can see
what it is doing.

Also the patch inside vnews is able to make use of the additional information
in the Path line when the destination site itself is not present in the data
base.
-- 
Bill Sebok			Princeton University, Astrophysics
{allegra,akgua,burl,cbosgd,decvax,ihnp4,noao,princeton,vax135}!astrovax!wls

piet@mcvax.UUCP (Piet Beertema) (10/19/84)

<...>

	>I have a smart mailer but don't trust it unless I can see
	>what it is doing.
Stick to yesterday's computers that still have all those wonderful lights,
displays and maybe loudspeakers that show you what it's doing....
-- 
	Piet Beertema, CWI, Amsterdam
	...{decvax,philabs}!mcvax!piet

wls@astrovax.UUCP (William L. Sebok) (10/24/84)

>>I have a smart mailer but don't trust it unless I can see
>>what it is doing.

> Stick to yesterday's computers that still have all those wonderful lights,
> displays and maybe loudspeakers that show you what it's doing....
> -- 
> 	Piet Beertema, CWI, Amsterdam
> 	...{decvax,philabs}!mcvax!piet

If one defines INTERNET in the news software even if one knows that the path
to the site it is going to use is wrong there is no way to overide it.  This
is my fundamental objection to the INTERNET option of news.

And yes I think that the removal of all lights from computers was a big
step backwards.
-- 
Bill Sebok			Princeton University, Astrophysics
{allegra,akgua,burl,cbosgd,decvax,ihnp4,noao,princeton,vax135}!astrovax!wls

piet@mcvax.UUCP (Piet Beertema) (10/25/84)

<...>

	>If one defines INTERNET in the news software even if one knows that
	>the path to the site it is going to use is wrong there is no way to
	>overide it. This is my fundamental objection to the INTERNET option
	>of news.
Now THAT has nothing to do with the INTERNET option in news, but everything
with how intelligent (or not) your mailer is. If you do a reply and are thrown
into your favorite editor you can always alter the "To:" line, e.g. using the
info from the "Path:" line. And then it depends on your mailer whether or not
it does (re)routing regardless of the path you gave. Our (re)routing strategy
is not to do (re)routing unless the first site in the given path isn't one of
our uucp connections. Thus "user@astrovax" and "astrovax!user" will be routed,
but "decvax!.....!astrovax!user" not.
-- 
	Piet Beertema, CWI, Amsterdam
	...{decvax,philabs}!mcvax!piet

biep@klipper.UUCP (J. A. "Biep" Durieux) (10/29/84)

[]

>I have a smart mailer but don't trust it unless I can see
>what it is doing.
>-- 
>Bill Sebok			Princeton University, Astrophysics
>{allegra,akgua,burl,cbosgd,decvax,ihnp4,noao,princeton,vax135}!astrovax!wls

	If you don't trust some servant, there may be two reasons: either
	he is stupid and may do things the wrong way, or he is disloyal.
	If you don't trust a *smart* mailer, then it must be disloyal.
	Servants tend to turn disloyal by being mistreated by their masters.


-- 

							  Biep.
	{seismo|decvax|philabs}!mcvax!vu44!botter!klipper!biep

I utterly disagree with everything you are saying, but I am
prepared to fight myself to death for your right to say it.
							--Voltaire

jhull@spp2.UUCP (11/06/84)

> []
> 
> >I have a smart mailer but don't trust it unless I can see
> >what it is doing.
> >-- 
> >Bill Sebok			Princeton University, Astrophysics
> >{allegra,akgua,burl,cbosgd,decvax,ihnp4,noao,princeton,vax135}!astrovax!wls
> 
> 	If you don't trust some servant, there may be two reasons: either
> 	he is stupid and may do things the wrong way, or he is disloyal.
> 	If you don't trust a *smart* mailer, then it must be disloyal.
> 	Servants tend to turn disloyal by being mistreated by their masters.
> 
> 							  Biep.
> 	{seismo|decvax|philabs}!mcvax!vu44!botter!klipper!biep

This raises a question for Bill:  Is the path you are objecting to
unworkable or non-optimal?  If the former, we all have a problem.  If
the latter, perhaps we are defining the current state of the art.


-- 
				Blessed Be,

				Jeff Hull
				trwspp!spp2!jhull@trwrb.UUCP
				jhull@spp2.UUCP

wls@astrovax.UUCP (William L. Sebok) (11/21/84)

> > >I have a smart mailer but don't trust it unless I can see
> > >what it is doing.
> > >Bill Sebok			Princeton University, Astrophysics
> > 
> > 	If you don't trust some servant, there may be two reasons: either
> > 	he is stupid and may do things the wrong way, or he is disloyal.
> > 	If you don't trust a *smart* mailer, then it must be disloyal.
> > 	Servants tend to turn disloyal by being mistreated by their masters.

> > 	{seismo|decvax|philabs}!mcvax!vu44!botter!klipper!biep
 
> This raises a question for Bill:  Is the path you are objecting to
> unworkable or non-optimal?  If the former, we all have a problem.  If
> the latter, perhaps we are defining the current state of the art.
> 				Jeff Hull 		jhull@spp2.UUCP

Both, but the unworkable paths are the main problems.  I strongly object
to the routing being taken completely out of my hands, so that I can't
work around a problem route even if I know that there is a problem.  As
it takes at least 20 minutes to recompile the routing tables (usually more on
this heavily loaded system) it is usually impractical to fix the route that
way at right that instant.  Someone who isn't site administrator doesn't even
have that recourse.
-- 
Bill Sebok			Princeton University, Astrophysics
{allegra,akgua,burl,cbosgd,decvax,ihnp4,noao,princeton,vax135}!astrovax!wls