diff -ruN pvm3.ori/Readme.IPv6 pvm3/Readme.IPv6 --- pvm3.ori/Readme.IPv6 1970-01-01 01:00:00.000000000 +0100 +++ pvm3/Readme.IPv6 2004-03-31 21:10:32.000000000 +0200 @@ -0,0 +1,211 @@ + +This readme file describes the IPv6 (ANY platform) port of PVM. + +PURPOSE: +-------- + +Some Beowulf clusters are designed so that not all nodes are visible +to the external world. This is commonly known as the NAT problem (Network +Address Translation) and it is inherently bound to the IPv4 protocol +address space of 32 bits. +In these cases, there is often a "front end" +node which connects to the world, and the rest of the nodes are on an +internal network. This has the disadvantage for PVM users running +on an outside computer who want to add the Beowulf computer to their +configuration: the PVM code on their computer will be unable to +communicate with the Beowulf nodes on the internal network. + +Some time ago, the BEOLIN port of PVM was introduced in order to solve +this problem by making the parallelism of the Beowulf computer +transparent to the user. This is done in a way similar to the MPP +ports of PVM for parallel computers such as the IBM SP2, Cray T3D and others. + +Today we present a new way to solve this problem based on the new +networking protocol: IPv6 (see RFC-2460 for more detailed info). Among +new features, address space is virtually increased into +"infinite" (128 bits vs. 32 bits). This will eventually enable +not only computers, but even cellulars and any sort of electronic devices + to connect the Internet. The NAT problem will become use-less, and + P2P (peer-to-peer) decentralized systems will be the main + beneficiaries of this new technology. + +In terms of a non-strict sort, PVM falls in this cathegory (P2P): +Every node runs both as a client (pvm task) and a server (pvm daemon). + +INSTALLATION NOTES: +------------------- +Ordinary PVM deployment skill required. Please, refer to corresponding +info (Readme, under pvm3 dir) + + 0) Prerequisites: + + - A UNIX O.S implementing IPv6 stack. Usually LINUX kernels >= + 2.4 do implement it. Also Freebsd >= 5.1, Solaris >= 8... + - Obviously, IPv6 connectivity at your beowulf. + + 1) Download + + http://www.ngn.euro6ix.org/IPv6/pvm/pvm-3.4.4-v6-20040330.diff + http://www.netlib.org/pvm3/pvm3.4.4.tar.gz + + 2) Unroll the tar.gz and apply the patch. + + $bash-2.04$ tar xzvf pvm3.tar.gz + $bash-2.04$ patch -p0 < pvm-3.4.4-v6-20040330.diff + + 3) Compile the bundle the next way: Be carefull of using SSH protocol + + $bash-2.04$ export PVM_RSH=`which ssh` + $bash-2.04$ cd pvm3 + $bash-2.04$ export PVM_ROOT=`pwd` + $bash-2.04$ make CFLOPTS=-DIPv6 + +WARNING: + - If you don't use GNU make you may be on trouble when + aplying the flag CFLOPTS=-DIPv6 . If so, try to adjust manually the + file pvm3/conf/.def + - Take this patch as a Beta, a scratch , or a seed to go on + hacking. This is a transient solution. Not so steady to + run benchmark problems. Take a look into the BUGS and + TODO sections. + - As far as I know, (2004-03-31) no official UNIX distro + include IPv6-support for NFS and NIS. The tests have been run + by using the ordinary IPv4 ones, I mean, our benchmark + intranet could run both IPv4 and IPv6. Obviously, PVM UDP + daemons were running IPv6. As a matter of abstraction layer + provided by the file system, no problems are expected when + these protocols NFS/NIS become IPv6 available... + +RUNNING: +-------- + +Until now, it has been tested only on a i386-[linux-freebsd] +Beowulf. More precisely, SuSE 8.1 and +FreeBsd 5.1 , but it still not very matured + +DNS was introduced to make easier the "decimal-dot notation" +154.346.34.145 . IPv6 will make it even harder, with addresses like +2005:35a4:12ff:6730:a423::12. You are encouraged to use always DNS +names. If registering DNS entries is not always possible on a benchmark +beowulf, just try to write them on the local hosts file (/etc/hosts on +linux), as was the use prior to DNS system. + +For a simple test: + + bash-2.04$ cd pvm3 + bash-2.04$ make e + +This will compile the examples provided with the tar.gz bundle . + + bash-2.04$ export PVM_ROOT="/path/to/ipv6/pvm/patch" + + + pvm> add pc2.ipv6lab.inv + pvm> conf + pvm> spawn -5 -> hello + + + You should watch alternate "hello worlds" from the virtual nodes... +Take a look into /tmp/pvml.uid... + If you see some dotted address like + + LINUX [2004:2a04:800:ee10:3434::2] + +this means you are running PVM on IPv6 !!! + +Also type + + bash-2.04$netstat -uan + +to check your pvmd, pvmd's daemons running... + +As old PVM used to, the new PVM frees you from dealing with low-level +aspects like networking connectivity and transport. So,YOU DO NOT HAVE +TO MODIFY your original application source code, BUT YOU HAVE TO RE-COMPILE AND +LINK IT against the new library you get in the previous phase, namely +libpvm.a . Be carefull of exporting the rigth environment PATH: + + bash-2.04$ export PVM_ROOT="/path/to/ipv6/pvm/patch" + + +KNOWN BUGS: (Important !!!) +----------------------------- + + - Please, use SSH protocol to make the master setup the slaves pvmd + daemon. You can do this by overwriting the environment variable + PVM_RSH. RSH is to become obsolete with IPv6 . Read README for more info. + + bash-2.04$ export PVM_RSH=`which ssh` + + - Passing the initial configuration file to the console does NOT + work properly yet. Posible problem: "iflist()" is faulty + implemented. To setup the PVM on a console, you have to do it + by-hand... + pvm> add node2.ipv6lab.inv + + pvm> conf + +TODO: +----- + + - Make cleaner the patch ;-) + - Somewhere around a call "sendto()" we have to adjust the length + of the bytes we send, since the new data "struct + sockaddr_storage" is greater than traditional "struct + sockaddr_in". I guess some alligment problems should arise, though + empirically this has not been the case. + - To fix the iflist(). Hard to deal with IPv6 setup interfaces... + - The pvmd-localtask daemon: + Initially this daemon was run on a UNIX socket. Then, due to + portability problems acrross platforms, it was implemented with a + TCP/IP socket . Actually it remains so. I think we should + change it into the IPv6 loop-back address (::1) + + +OPEN QUESTIONS: +--------------- + + Those interested on this section are kindly required to read the more +detailed report: + - http://www.gmonline.demon.co.uk/cscene/CS6/CS6-03.htm + +and contributing with any sugestion by e-mail to +(rafael dot martinez at novagnet dot com) + +* should PVM support dual-stack protocol (IPv6-IPv4)? + +In my opinion, no. Tratiditional client/server models based on +asymetric processing fit entirely this concept, as explained on the +pointed URL, but PVM configuration scheme (globally kept in host table) +may be hard to maintain by considering both types of +connectivity. + Consider the following scenario: a dual-stack node given +IPv6-IPv4 connectivity could be reached by a IPv4 node, if the former +has a DNS A entry (IPv4 addr), but an only IPv4 +node (even provided dual-stack by O.S) could not be reached, unless +you modify the host table layout and/or the pvm messaging dispatch +strategy. Too much effort and not so valuable benefits. + + + +SUPPORT: +--------- + +Suggestions, contributions are welcome at +(rafael dot martinez at novagnet dot com) + +Required aid to support this unmatured porting. + +DISCLAIMER: +----------- + +I don't know why the following has to be in all caps, but you know +lawyers. + +THIS IS A DEMONSTRATION RELEASE. THE AUTHOR MAKES NO REPRESENTATION +ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY OTHER PURPOSE. IT IS +PROVIDED "AS IS" WITHOUT EXPRESSED OR IMPLIED WARRANTY. + +THIS NOTICE MUST BE MAINTAINED IN ALL DISTRIBUTED VERSIONS. + + diff -ruN pvm3.ori/src/ddpro.c pvm3/src/ddpro.c --- pvm3.ori/src/ddpro.c 2001-09-27 01:35:19.000000000 +0200 +++ pvm3/src/ddpro.c 2004-03-31 21:13:14.000000000 +0200 @@ -420,10 +420,18 @@ void pvmbailout(); char *inadport_hex(); char *getenv(); +#ifdef IPv6 +void hex_inadport __ProtoGlarp__ (( char *, struct sockaddr_storage * )); +#else void hex_inadport __ProtoGlarp__ (( char *, struct sockaddr_in * )); +#endif void mesg_rewind __ProtoGlarp__ (( struct pmsg * )); void tev_send_newtask(); +#ifdef IPv6 +#include "safunc.h" +#endif + char **colonsep(); char *varsub(); char *pvmnametag(); @@ -827,7 +835,12 @@ int count; int ngood; int ntid; +#ifdef IPv6 + struct addrinfo hints,*res; + struct in6_addr in6addr; /* XXX hack */ +#else struct hostent *he; +#endif int maxhostid = (tidhmask >> ffs(tidhmask) - 1); int hh; int pid; @@ -903,7 +916,11 @@ hp = hosts->ht_hosts[hosts->ht_local]; +#ifdef IPv6 + if (BCMP(INET6_addr(&hp->hd_sad) , &in6addr_loopback,sizeof(struct in6_addr))==0 ) { +#else if ( hp->hd_sad.sin_addr.s_addr == htonl(0x7f000001) ) { +#endif /* damn, we're hosed. bail on host adds with new */ /* PvmIPLoopback error code... */ @@ -926,14 +943,28 @@ if (hp->hd_err) continue; +#ifdef IPv6 + memset(&hints,0,sizeof(struct addrinfo)); + hints.ai_family = PF_INET6; + hints.ai_socktype = SOCK_DGRAM; + if (!getaddrinfo(hp->hd_aname ? hp->hd_aname : hp->hd_name,"0",&hints,&res)) { + BCOPY(res->ai_addr, (char*)&hp->hd_sad, + res->ai_addrlen); + freeaddrinfo(res); +#else if (he = gethostbyname(hp->hd_aname ? hp->hd_aname : hp->hd_name)) { BCOPY(he->h_addr_list[0], (char*)&hp->hd_sad.sin_addr, sizeof(struct in_addr)); +#endif } else { if (pvmdebmask & PDMSTARTUP) { pvmlogprintf( +#ifdef IPv6 + "start_slaves() can't getaddrinfo %s\n", +#else "start_slaves() can't gethostbyname: %s\n", +#endif hp->hd_name); } hp->hd_err = PvmNoHost; @@ -944,8 +975,14 @@ if (!(hp->hd_flag & HF_OVERLOAD)) { for (hh = hosts->ht_last; hh > 0; hh--) +#ifdef IPv6 + if ((hp2 = hosts->ht_hosts[hh]) + && (BCMP(INET6_addr(&hp2->hd_sad), INET6_addr(&hp->hd_sad),sizeof(struct in6_addr))==0)) { +// if ( 0 ) { /* Rafa */ /* Aqui va a haber problemas */ +#else if ((hp2 = hosts->ht_hosts[hh]) && (hp2->hd_sad.sin_addr.s_addr == hp->hd_sad.sin_addr.s_addr)) { +#endif hp->hd_err = PvmDupHost; break; } @@ -955,8 +992,12 @@ /* make sure new ones aren't duplicated */ for (j = i; j-- > 0; ) +#ifdef IPv6 + if (BCMP(INET6_addr(&hp->hd_sad), INET6_addr(&wxp->w_hosts[j]->hd_sad),sizeof(struct in6_addr))==0) { +#else if (hp->hd_sad.sin_addr.s_addr == wxp->w_hosts[j]->hd_sad.sin_addr.s_addr) { +#endif hp->hd_err = PvmDupHost; break; } @@ -1033,7 +1074,11 @@ len = strlen( (hp->hd_dpath ? hp->hd_dpath : pvmdpath) ) + 1 + strlen( (hp->hd_sopts && !strcmp(hp->hd_sopts, "ms") ? "-S" : "-s") ) + 1 +#ifdef IPv6 /* To fix: What arbitrary length ? */ + + 2 + INET6_ADDRSTRLEN+50 + 1 +#else + 2 + 16 + 1 +#endif + 2 + strlen( hp->hd_name ) + 1 + 5 * ( 16 + 1 ); buf = TALLOC( len, char, "hdall" ); @@ -1722,7 +1767,11 @@ { int count; /* number of hosts in message */ int hh; +#ifdef IPv6 + char buf[INET6_ADDRSTRLEN+50]; /* for converting sockaddr */ +#else char buf[16]; /* for converting sockaddr */ +#endif struct pmsg *mp2; /* unpack new host table params */ diff -ruN pvm3.ori/src/host.c pvm3/src/host.c --- pvm3.ori/src/host.c 2001-09-27 01:35:18.000000000 +0200 +++ pvm3/src/host.c 2004-03-29 18:24:31.000000000 +0200 @@ -227,6 +227,10 @@ #define SIZ(p) sizeof(p) #endif +#ifdef IPv6 +#include "safunc.h" +#endif + char *inadport_decimal(); @@ -266,7 +270,9 @@ BZERO((char*)hp, sizeof(struct hostd)); hp->hd_ref = 1; hp->hd_hostpart = hh << (ffs(tidhmask) - 1); +#ifndef IPv6 hp->hd_sad.sin_family = AF_INET; +#endif hp->hd_txq = pk_new(0); hp->hd_opq = pk_new(0); hp->hd_rxq = pk_new(0); @@ -812,9 +818,15 @@ char buf[512]; /* line buffer */ int lnum = 0; /* line counter */ int err = 0; /* error count */ +#ifdef IPv6 + struct addrinfo hints,*res; + struct in6_addr *my_in_addrs; /* XXX Remember: The pvmd server only opens IPv6 addresses */ + struct sockaddr_in6 *sa6; /* XXX : Subtle hack to get access into the sin6_addr */ +#else struct hostent *he; - char *p; struct in_addr *my_in_addrs; +#endif + char *p; int num_addrs; int i; int maxhostid = tidhmask >> (ffs(tidhmask) - 1); @@ -885,6 +897,21 @@ /* look up ip addr */ +#ifdef IPv6 + memset(&hints,0,sizeof(struct addrinfo)); + hints.ai_family = PF_INET6; /* O UNSPEC ? */ + hints.ai_socktype = SOCK_DGRAM; + if (getaddrinfo(hp->hd_aname?hp->hd_aname: hp->hd_name,"0",&hints,&res)) { + pvmlogprintf("readhostfile() %s %d: %s: can't getaddrinfo\n", + fn, lnum, hp->hd_name); + err++; + goto badline; + } + BCOPY(res->ai_addr, (char*)&hp->hd_sad, + res->ai_addrlen); + freeaddrinfo(res); + sa6 = (struct sockaddr_sin6 *) &hp->hd_sad ; +#else if (!(he = gethostbyname(hp->hd_aname ? hp->hd_aname : hp->hd_name))) { pvmlogprintf("readhostfile() %s %d: %s: can't gethostbyname\n", fn, lnum, hp->hd_name); @@ -893,13 +920,21 @@ } BCOPY(he->h_addr_list[0], (char*)&hp->hd_sad.sin_addr, sizeof(struct in_addr)); +#endif /* mark master host to not start */ if (!(hp->hd_flag & HF_OVERLOAD)) for (i = num_addrs; i-- > 0; ) { +#ifdef IPv6 + if (BCMP((char*)&my_in_addrs[i],(char *)&sa6->sin6_addr, + sizeof(struct in6_addr)) == 0) { + +#else if (BCMP((char*)&my_in_addrs[i], (char*)&hp->hd_sad.sin_addr, sizeof(struct in_addr)) == 0) { +#endif + hp->hd_flag |= HF_NOSTART; break; } @@ -938,6 +973,7 @@ * Return list of addresses for active network interfaces. */ +#ifndef IPv6 #ifdef SIOCGIFCONF int @@ -1025,6 +1061,7 @@ #else /*SIOCGIFCONF*/ + int iflist(alp, np) struct in_addr **alp; /* return list of addresses */ @@ -1063,6 +1100,62 @@ } #endif /*SIOCGIFCONF*/ +#else + + +int +iflist(alp, np) + struct in6_addr **alp; /* return list of addresses */ + int *np; /* return len of alp */ +{ + static struct in6_addr *iplist = 0; /* list of interface addrs found */ + int nip = 0; /* length of iplist */ + char **p; + + FILE *f; + char addr6[40], devname[20]; + struct sockaddr_in6 sap; + int plen, scope, dad_status, if_idx; + char addr6p[8][5]; + + + if (iplist) + PVM_FREE(iplist); + iplist = TALLOC(10, struct in6_addr, "ifl"); + + + + if ((f = fopen(_PATH_PROCNET_IFINET6, "r")) != NULL) { + while (fscanf(f, "%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %20s\n", + addr6p[0], addr6p[1], addr6p[2], addr6p[3], + addr6p[4], addr6p[5], addr6p[6], addr6p[7], + &if_idx, &plen, &scope, &dad_status, devname) != EOF) { + sprintf(addr6, "%s:%s:%s:%s:%s:%s:%s:%s", + addr6p[0], addr6p[1], addr6p[2], addr6p[3], + addr6p[4], addr6p[5], addr6p[6], addr6p[7]); + inet_pton(AF_INET6, addr6, sap.sin6_addr.s6_addr); + if (nip > 0 && !(nip % 10)) + iplist = TREALLOC(iplist, (nip + 10), struct in6_addr); + memcpy(&iplist[nip],&sap.sin6_addr,sizeof(struct in6_addr)); + + } + fclose(f); + } + else + { + fprintf(stderr, "can't open %s\n",_PATH_PROCNET_IFINET6); + goto bail; + } + + *alp = iplist; + *np = nip; + return 0; + +bail: + return -1; +} + +#endif /* IPv6 */ /* acav() diff -ruN pvm3.ori/src/host.h pvm3/src/host.h --- pvm3.ori/src/host.h 2001-09-27 01:35:21.000000000 +0200 +++ pvm3/src/host.h 2004-03-29 18:24:31.000000000 +0200 @@ -71,6 +71,9 @@ * */ +#ifdef IPv6 +#include /* Some O.S need it to be declared explicitly */ +#endif /* Host descriptor */ @@ -89,7 +92,11 @@ int hd_dsig; /* data signature */ int hd_err; /* error code */ int hd_mtu; /* max snd/rcv length */ +#ifdef IPv6 + struct sockaddr_storage hd_sad; /* UDP address/port */ +#else struct sockaddr_in hd_sad; /* UDP address/port */ +#endif int hd_rxseq; /* expected next seq num from host */ int hd_txseq; /* next tx seq num to host */ struct pkt *hd_txq; /* not-yet-sent packet queue to host */ diff -ruN pvm3.ori/src/lpvm.c pvm3/src/lpvm.c --- pvm3.ori/src/lpvm.c 2001-09-25 23:20:17.000000000 +0200 +++ pvm3/src/lpvm.c 2004-03-29 18:24:31.000000000 +0200 @@ -613,6 +613,9 @@ #include "../shmd/shmdproto.h" #endif +#ifdef IPv6 +#include "safunc.h" +#endif #ifndef max #define max(a,b) ((a)>(b)?(a):(b)) @@ -633,7 +636,11 @@ ***************/ char *getenv(); +#ifdef IPv6 +void hex_inadport __ProtoGlarp__ (( char *, struct sockaddr_storage * )); +#else void hex_inadport __ProtoGlarp__ (( char *, struct sockaddr_in * )); +#endif extern char *inadport_decimal(); extern char *inadport_hex(); @@ -660,7 +667,11 @@ ***************/ static int mxfersingle = 1; /* mxfer returns after single frag */ +#ifdef IPv6 +static struct sockaddr_storage pvmourinet; /* our host ip addr */ +#else static struct sockaddr_in pvmourinet; /* our host ip addr */ +#endif static struct ttpcb *ttlist = 0; /* dll of connected tasks */ static struct ttpcb *topvmd = 0; /* default route (to pvmd) */ static int pvmnfds = 0; /* 1 + highest bit set in fds */ @@ -1390,7 +1401,11 @@ #endif /*NOUNIXDOM*/ } else { +#ifdef IPv6 + pcbp->tt_osad.ss_family = AF_INET6; +#else pcbp->tt_osad.sin_family = AF_INET; +#endif hex_inadport(buf, &pcbp->tt_osad); while ((i = connect(pcbp->tt_fd, (struct sockaddr*)&pcbp->tt_osad, @@ -2318,7 +2333,11 @@ int s; /* socket */ int sbf; /* temp TC_CONREQ message */ struct pmsg *up, *up2; +#ifdef IPv6 + struct sockaddr_storage sad; +#else struct sockaddr_in sad; +#endif int l; #ifdef SOCKLENISUINT #ifdef IMA_AIX4SP2 @@ -2426,12 +2445,20 @@ #endif /* !NOUNIXDOM */ /* Open a TCP direct Connection here, instead */ +#ifdef IPv6 + if ((s = socket(AF_INET6, SOCK_STREAM, 0)) == -1) { +#else if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) { +#endif pvmlogperror("mroute() socket"); } else { sad = pvmourinet; +#ifdef IPv6 + oslen = SA_LEN(&sad); +#else oslen = sizeof(sad); +#endif if (bind(s, (struct sockaddr*)&sad, oslen) == -1) { pvmlogperror("mroute() bind"); (void)close(s); @@ -2860,8 +2887,13 @@ try = 5; while (1) { /* goto is at the root of all good programming style */ hex_inadport(p, &topvmd->tt_osad); +#ifdef IPv6 + topvmd->tt_osad.ss_family = AF_INET6; + n = SA_LEN(&topvmd->tt_osad); +#else topvmd->tt_osad.sin_family = AF_INET; n = sizeof(topvmd->tt_osad); +#endif if (connect(topvmd->tt_fd, (struct sockaddr*)&topvmd->tt_osad, n) == -1) { @@ -3264,8 +3296,13 @@ hex_inadport(buf, &pvmourinet); #endif +#ifdef IPv6 + memset(&pvmourinet,0,sizeof(pvmourinet)); + pvmourinet.ss_family = AF_INET; +#else pvmourinet.sin_family = AF_INET; pvmourinet.sin_port = 0; +#endif pvm_upkint(&pvmschedtid, 1, 1); #endif diff -ruN pvm3.ori/src/lpvm.h pvm3/src/lpvm.h --- pvm3.ori/src/lpvm.h 2000-02-16 23:00:59.000000000 +0100 +++ pvm3/src/lpvm.h 2004-03-29 18:24:31.000000000 +0200 @@ -100,6 +100,9 @@ #ifndef NO_NETINET_TCP_H #include #endif +#ifdef IPv6 +#include +#endif #endif #ifdef IMA_MPP @@ -190,8 +193,13 @@ int tt_tid; /* tid of peer or 0 if master of list */ int tt_state; int tt_fd; /* fd of connection or -1 */ +#ifdef IPv6 + struct sockaddr_storage tt_sad; /* address of our socket */ + struct sockaddr_storage tt_osad; /* (authd) address of peer socket */ +#else struct sockaddr_in tt_sad; /* address of our socket */ struct sockaddr_in tt_osad; /* (authd) address of peer socket */ +#endif struct pmsg *tt_rxfrag; /* not-assembled incm msg */ struct frag *tt_rxf; /* partial incm frag */ #ifndef NOUNIXDOM diff -ruN pvm3.ori/src/lpvmgen.c pvm3/src/lpvmgen.c --- pvm3.ori/src/lpvmgen.c 2001-09-27 01:35:43.000000000 +0200 +++ pvm3/src/lpvmgen.c 2004-03-29 18:24:31.000000000 +0200 @@ -1909,7 +1909,6 @@ pvm_pkint(&count, 1, 1); for (i = 0; i < count; i++) pvm_pkstr(names[i]); - if (pvmschedtid) cc = msendrecv(pvmschedtid, SM_ADDHOST, PvmBaseContext); else diff -ruN pvm3.ori/src/pvmcruft.c pvm3/src/pvmcruft.c --- pvm3.ori/src/pvmcruft.c 2001-09-27 23:25:10.000000000 +0200 +++ pvm3/src/pvmcruft.c 2004-03-29 18:24:31.000000000 +0200 @@ -287,6 +287,9 @@ char *read_pvmregistry __ProtoGlarp__(( const char * )); #endif +#ifdef IPv6 +#include "safunc.h" +#endif /*************** ** Globals ** ** ** @@ -660,27 +663,74 @@ /* hex_inadport() * +#ifdef IPv6 +* Both routines are key. +* Takes a string of format [2a03:800:40::10]:1543 and returns a sockaddr_storage +* Hay que arreglarlo. +* Deberiamos igualar todos los getaddrinfo.. +#else * Takes a string of format 00000000:0000 and returns a sockaddr_in. +#endif */ void hex_inadport(s, sad) char *s; +#ifdef IPv6 + struct sockaddr_storage *sad; +{ +#include +#include +#include + struct addrinfo hints,*res; + char hostname[INET6_ADDRSTRLEN]; + char *aux; + memset(hostname,0,INET6_ADDRSTRLEN); + strncpy(hostname,s+1,INET6_ADDRSTRLEN); // Get the numeric part + aux = strchr(hostname,']'); + *aux = '\0'; + + s = (s = CINDEX(s, ']')) ? s + 2 : ""; + memset(&hints,0,sizeof(struct addrinfo)); + hints.ai_family = PF_INET6; /* O UNSPEC ? */ + hints.ai_socktype = SOCK_DGRAM; + getaddrinfo(hostname,s,&hints,&res); + memcpy(sad,res->ai_addr,res->ai_addrlen); + freeaddrinfo(res); +} +#else struct sockaddr_in *sad; { sad->sin_addr.s_addr = htonl((unsigned)pvmxtoi(s)); s = (s = CINDEX(s, ':')) ? s + 1 : ""; sad->sin_port = htons((unsigned short)pvmxtoi(s)); } - +#endif /* inadport_decimal() * +#ifdef IPv6 +* Returns printable string corr. to sockaddr_storage with addr in decimal. +#else * Returns printable string corr. to sockaddr_in with addr in decimal. +#endif */ char * inadport_decimal(sad) +#ifdef IPv6 + struct sockaddr_storage *sad; +{ + static char buf[INET6_ADDRSTRLEN+50]; + char host[INET6_ADDRSTRLEN]; + char service[32]; + memset(buf,INET6_ADDRSTRLEN+50,0); + + getnameinfo((const struct sockaddr *)sad,SA_LEN(sad),host,INET6_ADDRSTRLEN,service,30,NI_NUMERICHOST|NI_NUMERICSERV); + sprintf(buf,"[%s]:%s",host,service); + return buf; +} +#else struct sockaddr_in *sad; { static char buf[32]; @@ -695,15 +745,33 @@ 0xffff & (int)ntohs(sad->sin_port)); return buf; } +#endif /* inadport_hex() * +#ifdef IPv6 + Returns printable string corr. to sockaddr_storage with addr in hex. +#else * Returns printable string corr. to sockaddr_in with addr in hex. +#endif */ char * inadport_hex(sad) +#ifdef IPv6 + struct sockaddr_storage *sad; +{ + static char buf[INET6_ADDRSTRLEN+50]; + char host[INET6_ADDRSTRLEN]; + char service[32]; + memset(buf,INET6_ADDRSTRLEN+50,0); + + getnameinfo((const struct sockaddr *)sad,SA_LEN(sad),host,INET6_ADDRSTRLEN,service,30,NI_NUMERICHOST|NI_NUMERICSERV); + sprintf(buf,"[%s]:%s",host,service); + return buf; +} +#else struct sockaddr_in *sad; { static char buf[16]; @@ -713,6 +781,7 @@ sprintf(buf, "%08x:%04x", a, 0xffff & (int)ntohs(sad->sin_port)); return buf; } +#endif #endif /*I860_NODE*/ diff -ruN pvm3.ori/src/pvmd.c pvm3/src/pvmd.c --- pvm3.ori/src/pvmd.c 2001-09-28 14:43:18.000000000 +0200 +++ pvm3/src/pvmd.c 2004-03-29 18:24:31.000000000 +0200 @@ -675,6 +675,10 @@ #include #include "global.h" +#ifdef IPv6 +#include "safunc.h" +#endif + #ifdef IMA_CRAY #define MAXPATHLEN PATH_MAX+1 #endif @@ -730,7 +734,11 @@ char *pvmgetroot(); void reap(); void i_dump(); +#ifdef IPv6 +void hex_inadport __ProtoGlarp__ (( char *, struct sockaddr_storage * )); +#else void hex_inadport __ProtoGlarp__ (( char *, struct sockaddr_in * )); +#endif void mesg_rewind __ProtoGlarp__ (( struct pmsg * )); void locl_spawn(); /* void make_valid(char *n); sls */ @@ -1420,8 +1428,13 @@ pvmput16(dummy + 8, 0); pvmput16(dummy + 10, 0); pvmput8(dummy + 12, FFFIN|FFACK); +#ifdef IPv6 + sendto(netsock, dummy, DDFRAGHDR, 0, + (struct sockaddr*)&hp->hd_sad, SA_LEN(&hp->hd_sad)); +#else sendto(netsock, dummy, DDFRAGHDR, 0, (struct sockaddr*)&hp->hd_sad, sizeof(hp->hd_sad)); +#endif } } @@ -1706,7 +1719,11 @@ #else int oslen; #endif +#ifdef IPv6 + struct sockaddr_storage osad; +#else struct sockaddr_in osad; +#endif struct timeval t; char buf[DDFRAGHDR]; @@ -1727,9 +1744,15 @@ #endif &t); if (cc == 1) { +#ifdef IPv6 + oslen = SA_LEN(&osad); + recvfrom(ppnetsock, buf, sizeof(buf), + 0, (struct sockaddr*)&osad, &oslen); +#else oslen = sizeof(osad); recvfrom(ppnetsock, buf, sizeof(buf), 0, (struct sockaddr*)&osad, &oslen); +#endif } else if (cc != -1 || errno != EINTR) break; @@ -2201,7 +2224,11 @@ } else #endif if ((cc = sendto(netsock, cp, len, 0, +#ifdef IPv6 + (struct sockaddr*)&hp->hd_sad, SA_LEN(&hp->hd_sad))) == -1 +#else (struct sockaddr*)&hp->hd_sad, sizeof(hp->hd_sad))) == -1 +#endif && errno != EINTR #ifndef WIN32 && errno != ENOBUFS @@ -2292,7 +2319,12 @@ int netinput() { +#ifdef IPv6 + struct sockaddr_storage osad; /* sender's ip addr */ + /* XXX: Remember, IPv4 are IPv6 mapped thanks to dual stack */ +#else struct sockaddr_in osad; /* sender's ip addr */ +#endif #ifdef SOCKLENISUINT #ifdef IMA_AIX4SP2 unsigned int oslen; @@ -2324,7 +2356,11 @@ if (TDFRAGHDR > DDFRAGHDR) pp->pk_dat += TDFRAGHDR - DDFRAGHDR; +#ifdef IPv6 + oslen = SA_LEN(&osad); +#else oslen = sizeof(osad); +#endif if ((pp->pk_len = recvfrom(netsock, pp->pk_dat, pp->pk_max - (pp->pk_dat - pp->pk_buf), 0, (struct sockaddr*)&osad, &oslen)) == -1) { @@ -2373,8 +2409,13 @@ * make sure it's from where it claims */ + hh = (src & tidhmask) >> (ffs(tidhmask) - 1); if (hh < 0 || hh > hosts->ht_last || !(hp = hosts->ht_hosts[hh]) +#ifdef IPv6 + || (BCMP(INET6_addr(&osad), INET6_addr(&hp->hd_sad),sizeof(struct in6_addr))!=0) + || (INET6_port(&osad) != INET6_port(&hp->hd_sad)) +#else /* #ifndef IMA_LINUX */ /* appears to be O.K. now in RedHat 5.0... JAK 1/28/98 */ /* @@ -2383,6 +2424,7 @@ */ || (osad.sin_addr.s_addr != hp->hd_sad.sin_addr.s_addr) || (osad.sin_port != hp->hd_sad.sin_port) +#endif /* #endif */ ) { pvmlogprintf("netinput() bogus pkt from %s\n", @@ -4737,19 +4779,31 @@ * make pvmd-pvmd socket */ +#ifdef IPv6 + if ((netsock = socket(AF_INET6, SOCK_DGRAM, 0)) == -1) { +#else if ((netsock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { +#endif pvmlogperror("mksocs() socket netsock"); return 1; } +#ifdef IPv6 + if (bind(netsock, (struct sockaddr*)&hp->hd_sad, SA_LEN(&hp->hd_sad)) == -1) +#else hp->hd_sad.sin_port = 0; oslen = sizeof(hp->hd_sad); if (bind(netsock, (struct sockaddr*)&hp->hd_sad, oslen) == -1) +#endif { pvmlogperror("mksocs() bind netsock"); return 1; } +#ifdef IPv6 + oslen = SA_LEN(&hp->hd_sad); +#else oslen = sizeof(hp->hd_sad); +#endif if (getsockname(netsock, (struct sockaddr*)&hp->hd_sad, &oslen) == -1) { pvmlogperror("mksocs() getsockname netsock"); return 1; @@ -4759,18 +4813,30 @@ * make pvmd-pvmd' socket */ +#ifdef IPv6 + if ((ppnetsock = socket(AF_INET6, SOCK_DGRAM, 0)) == -1) { +#else if ((ppnetsock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { +#endif pvmlogperror("mksocs() socket ppnetsock"); return 1; } +#ifdef IPv6 + if (bind(ppnetsock, (struct sockaddr*)&hp0->hd_sad, SA_LEN(&hp0->hd_sad)) == -1) { +#else hp0->hd_sad.sin_port = 0; oslen = sizeof(hp0->hd_sad); if (bind(ppnetsock, (struct sockaddr*)&hp0->hd_sad, oslen) == -1) { +#endif pvmlogperror("mksocs() bind ppnetsock"); return 1; } +#ifdef IPv6 + oslen = SA_LEN(&hp0->hd_sad); +#else oslen = sizeof(hp0->hd_sad); +#endif if (getsockname(ppnetsock, (struct sockaddr*)&hp0->hd_sad, &oslen) == -1) { pvmlogperror("mksocs() getsockname ppnetsock"); return 1; @@ -4779,6 +4845,11 @@ /* * make pvmd-local task socket */ +#ifdef IPv6 +/* + For the time being, thereis no need to take port this socket into IPv6, since it is used on local interface +*/ +#endif #ifdef NOUNIXDOM if ((loclsock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { @@ -5150,7 +5221,11 @@ int argc; char **argv; { +#ifdef IPv6 + struct addrinfo hints,*res; +#else struct hostent *he; +#endif struct hostd *hp; struct hostd *hp2; int i; @@ -5229,6 +5304,22 @@ pvmlogperror(s); PVM_FREE(s); +#ifdef IPv6 + memset(&hints,0,sizeof(struct addrinfo)); + hints.ai_family = PF_INET6; /* O UNSPEC ? */ + hints.ai_socktype = SOCK_DGRAM; + if (getaddrinfo(hp->hd_aname? hp->hd_aname: hp->hd_name,"0",&hints,&res)) { + pvmlogprintf("master_config() %s: can't getaddrinfo\n", hn); + pvmbailout(0); + } + + BCOPY(res->ai_addr, (char*)&hp->hd_sad, + res->ai_addrlen); + hp = hosts->ht_hosts[0]; + BCOPY(res->ai_addr, (char*)&hp->hd_sad, + res->ai_addrlen); + freeaddrinfo(res); +#else if (!(he = gethostbyname(hp->hd_aname ? hp->hd_aname : hp->hd_name))) { pvmlogprintf("master_config() %s: can't gethostbyname\n", hn); pvmbailout(0); @@ -5240,6 +5331,7 @@ hp = hosts->ht_hosts[0]; BCOPY(he->h_addr_list[0], (char*)&hp->hd_sad.sin_addr, sizeof(struct in_addr)); +#endif if (pvmdebmask & (PDMHOST|PDMSTARTUP)) { pvmlogerror("master_config() host table:\n"); @@ -5297,6 +5389,9 @@ char *p; char *s; + + char hostname[INET6_ADDRSTRLEN]; + for (i = j = ac = 1; i < argc; i++) { if (argv[i][0] == '-') { switch (argv[i][1]) { @@ -5336,7 +5431,7 @@ hp = hd_new(mh); hp->hd_name = STRALLOC("?"); - hex_inadport(argv[2], &hp->hd_sad); + hex_inadport(argv[2], &hp->hd_sad); hp->hd_mtu = atoi(argv[3]); ht_insert(hosts, hp); hd_unref(hp); diff -ruN pvm3.ori/src/safunc.h pvm3/src/safunc.h --- pvm3.ori/src/safunc.h 1970-01-01 01:00:00.000000000 +0100 +++ pvm3/src/safunc.h 2004-03-29 18:24:31.000000000 +0200 @@ -0,0 +1,109 @@ + + +/* + * PVM version 3.4: Parallel Virtual Machine System + * University of Tennessee, Knoxville TN. + * Oak Ridge National Laboratory, Oak Ridge TN. + * Emory University, Atlanta GA. + * Authors: J. J. Dongarra, G. E. Fagg, M. Fischer + * G. A. Geist, J. A. Kohl, R. J. Manchek, P. Mucci, + * P. M. Papadopoulos, S. L. Scott, and V. S. Sunderam + * (C) 1997 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * Neither the Institutions (Emory University, Oak Ridge National + * Laboratory, and University of Tennessee) nor the Authors make any + * representations about the suitability of this software for any + * purpose. This software is provided ``as is'' without express or + * implied warranty. + * + * PVM version 3 was funded in part by the U.S. Department of Energy, + * the National Science Foundation and the State of Tennessee. + */ + +/* + * safunc.h + * + * SA_LEN function patch. + * + * $Log: bfunc.h,v $ + * Revision 1.4 1999/07/08 19:00:19 kohl + * Fixed "Log" keyword placement. + * - indent with " * " for new CVS. + * + * Revision 1.3 1997/06/25 22:08:42 pvmsrc + * Markus adds his frigging name to the author list of + * every file he ever looked at... + * + * Revision 1.2 1997/01/28 19:27:53 pvmsrc + * New Copyright Notice & Authors. + * + * Revision 1.1 1996/09/23 23:43:11 pvmsrc + * Initial revision + * + * Revision 1.2 1994/06/03 20:38:12 manchek + * version 3.3.0 + * + * Revision 1.1 1993/08/30 23:26:46 manchek + * Initial revision + * + */ + + +#ifdef IPv6 +#ifndef SA_LEN +#define SA_LEN(sa) sa_len(sa) + +static size_t sa_len(struct sockaddr_storage *sa) +{ + switch(sa->ss_family) { + case AF_INET: + return sizeof(struct sockaddr_in); + case AF_INET6: + return sizeof(struct sockaddr_in6); + default: + return sizeof(struct sockaddr_storage); + } +} +#endif /* SA_LEN */ + +#ifndef _PATH_PROCNET_IFINET6 +#define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6" +#endif /* _PATH_PROCNET_IFNET6 */ + +#ifndef INET6_addr +#define INET6_addr(a) inet6_addr(a) + +/* This is a non very portable hack...*/ +static void *inet6_addr(struct sockaddr *sap) +{ + struct sockaddr_in6 *sin6; + + sin6 = (struct sockaddr_in6 *) sap; + + return sin6->sin6_addr.s6_addr; /* ?;) */ +} +#endif /* INET6_addr */ + +#ifndef INET6_port +#define INET6_port(a) inet6_port(a) + +/* This is a non very portable hack...*/ +static int inet6_port(struct sockaddr *sap) +{ + struct sockaddr_in6 *sin6; + + sin6 = (struct sockaddr_in6 *) sap; + + return sin6->sin6_port; +} +#endif /* INET6_port */ + +#endif diff -ruN pvm3.ori/tracer/tracer.h pvm3/tracer/tracer.h --- pvm3.ori/tracer/tracer.h 2001-05-11 23:19:43.000000000 +0200 +++ pvm3/tracer/tracer.h 2004-03-29 18:24:31.000000000 +0200 @@ -40,7 +40,7 @@ #include "pvmwin.h" #include #endif -#ifndef IMA_MACOSX +#if !(defined(IMA_MACOSX) || defined(IMA_FREEBSD)) #include #endif #include diff -ruN pvm3.ori/tracer/trclib.h pvm3/tracer/trclib.h --- pvm3.ori/tracer/trclib.h 2001-05-11 23:19:43.000000000 +0200 +++ pvm3/tracer/trclib.h 2004-03-29 18:24:31.000000000 +0200 @@ -34,7 +34,7 @@ #include "pvmwin.h" #endif #include -#ifndef IMA_MACOSX +#if !(defined(IMA_MACOSX) || defined(IMA_FREEBSD)) #include #endif diff -ruN pvm3.ori/tracer/trcsort.c pvm3/tracer/trcsort.c --- pvm3.ori/tracer/trcsort.c 2001-05-11 23:19:44.000000000 +0200 +++ pvm3/tracer/trcsort.c 2004-03-29 18:24:31.000000000 +0200 @@ -31,7 +31,7 @@ #include #include -#ifndef IMA_MACOSX +#if !(defined(IMA_MACOSX) || defined(IMA_FREEBSD)) #include #endif