From: Derrick Brashear Date: Wed, 28 Aug 2002 04:32:18 +0000 (+0000) Subject: STABLE12-netinfo-support-fake-ips-for-nat-20020808 X-Git-Tag: openafs-stable-1_2_7~31 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=fbed21ec62da2e9ebdef00848f4fb77aaa7d6b3b;p=packages%2Fo%2Fopenafs.git STABLE12-netinfo-support-fake-ips-for-nat-20020808 basically verbatim from Todd DeSantis, cleared for release by IBM (cherry picked from commit caeecc241e6b4133009e9997cba4e4f259c33e60) --- diff --git a/src/util/netutils.c b/src/util/netutils.c index e4c85cb24..201b8f002 100644 --- a/src/util/netutils.c +++ b/src/util/netutils.c @@ -256,40 +256,58 @@ const char *fileName; /* For each line in the NetInfo file */ while ( fgets(line, MAX_NETFILE_LINE, fp) != NULL ) { - lineNo++; /* input line number */ - addr = extract_Addr(line, MAX_NETFILE_LINE); + int fake=0; + + /* See if first char is an 'F' for fake */ + /* Added to allow the fileserver to advertise fake IPS for use with + * the translation tables for NAT-like firewalls - defect 12462 */ + for (fake=0; ((fake < strlen(line)) && isspace(line[fake])); fake++); + if ( (fake < strlen(line)) && ((line[fake]=='f') || (line[fake]=='F'))) { + fake++; + } else { + fake = 0; + } + + lineNo++; /* input line number */ + addr = extract_Addr(&line[fake], strlen(&line[fake])); - if (addr == AFS_IPINVALID) { /* syntactically invalid */ - fprintf(stderr,"afs:%s : line %d : parse error\n", fileName, lineNo); - continue; - } - if (addr == AFS_IPINVALIDIGNORE) { /* ignore error */ - continue; - } + if (addr == AFS_IPINVALID) { /* syntactically invalid */ + fprintf(stderr,"afs:%s : line %d : parse error\n", fileName, lineNo); + continue; + } + if (addr == AFS_IPINVALIDIGNORE) { /* ignore error */ + continue; + } - /* See if it is an address that really exists */ - for (i=0; i < existNu; i++) { - if (existingAddr[i] == addr) break; - } - if (i >= existNu) continue; /* not found - ignore */ + /* See if it is an address that really exists */ + for (i=0; i < existNu; i++) { + if (existingAddr[i] == addr) break; + } + if ((i >= existNu) && (!fake)) continue; /* not found/fake - ignore */ - /* Check if it is a duplicate address we alread have */ - for (l=0; l < count; l++) { - if ( final[l] == addr ) break; - } - if (l < count) { - fprintf(stderr,"afs:%x specified twice in NetInfo file\n", ntohl(addr)); - continue; /* duplicate addr - ignore */ - } + /* Check if it is a duplicate address we alread have */ + for (l=0; l < count; l++) { + if ( final[l] == addr ) break; + } + if (l < count) { + fprintf(stderr,"afs:%x specified twice in NetInfo file\n", ntohl(addr)); + continue; /* duplicate addr - ignore */ + } - if ( count == max ) { /* no more space */ - fprintf(stderr,"afs:Too many interfaces. The current kernel configuration supports a maximum of %d interfaces\n", max); - } else { - final[count] = existingAddr[i]; - mask[count] = existingMask[i]; - mtu[count] = existingMtu[i]; - count++; - } + if ( count > max ) { /* no more space */ + fprintf(stderr,"afs:Too many interfaces. The current kernel configuration supports a maximum of %d interfaces\n", max); + } else if (fake) { + fprintf(stderr, "Client (2) also has address %s\n", line); + final[count] = addr; + mask[count] = 0xffffffff; + mtu[count] = htonl(1500); + count++; + } else { + final[count] = existingAddr[i]; + mask[count] = existingMask[i]; + mtu[count] = existingMtu[i]; + count++; + } } /* while */ /* in case of any error, we use all the interfaces present */