Bug 206724 - Replacing PR_SetNetAddr with PRLDAP_SET_PORT for IPv6 support
Summary: Replacing PR_SetNetAddr with PRLDAP_SET_PORT for IPv6 support
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: 389
Classification: Retired
Component: Directory Server
Version: 1.0.2
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Noriko Hosoi
QA Contact: Viktor Ashirov
URL:
Whiteboard:
: PR_GetAddrInfoByName (view as bug list)
Depends On:
Blocks: 152373 fds103trackingbug 240316
TreeView+ depends on / blocked
 
Reported: 2006-09-15 21:12 UTC by Noriko Hosoi
Modified: 2015-12-07 16:45 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-12-07 16:45:43 UTC
Embargoed:


Attachments (Terms of Use)
cvs diff slapi-private.h connection.c daemon.c (21.30 KB, patch)
2006-09-15 21:32 UTC, Noriko Hosoi
no flags Details | Diff

Description Noriko Hosoi 2006-09-15 21:12:51 UTC
Description of problem:
PR_SetNetAddr was used just to set port into PRNetAddr.  The function has a side
effect, which accidentally cleans up the scope_id field.  So, if the purpose of
calling PR_SetNetAddr is to set port, we were suggested to introduce a macro to
achieve the goal.

Comment 1 Noriko Hosoi 2006-09-15 21:32:49 UTC
Created attachment 136399 [details]
cvs diff slapi-private.h connection.c daemon.c

Files:
  slapi-private.h
  connection.c
  daemon.c

Changes:
slapi-private.h: introduced PRLDAP_SET_PORT to set port to the port field in
PRNetAddr.  A copy of the same macro in LDAP C SDK (v6).  Note: once NSPR
provides an equivalent API, we may want to replace this macro with the one. 
(the NSPR compatibility issue remains, though.)
connection.c, daemon.c: replaced PR_SetNetAddr with PRLDAP_SET_ADDR.

Comment 2 Noriko Hosoi 2006-09-15 21:39:06 UTC
(In reply to comment #1)
[...]
> connection.c, daemon.c: replaced PR_SetNetAddr with PRLDAP_SET_ADDR.

Oops, "PRLDAP_SET_PORT", of course...


Comment 3 Noriko Hosoi 2006-09-15 22:46:12 UTC
(In reply to comment #1)
[...]
> connection.c, daemon.c: replaced PR_SetNetAddr with PRLDAP_SET_ADDR.

Oops, "PRLDAP_SET_PORT", of course...


Comment 4 Noriko Hosoi 2006-09-15 22:50:20 UTC
Sorry, Rich.  I overrode your approval. :p  Recovered.

And checked in into the HEAD.

[206724] Replacing PR_SetNetAddr with PRLDAP_SET_PORT for IPv6 support
slapi-private.h: introduced PRLDAP_SET_PORT to set port to the port field in
PRNetAddr.  A copy of the same macro in LDAP C SDK (v6).  Note: once NSPR
provides an equivalent API, we may want to replace this macro with the one.
(the NSPR compatibility issue remains, though.)
connection.c, daemon.c: replaced PR_SetNetAddr with PRLDAP_SET_PORT.
CVS: ----------------------------------------------------------------------
CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
CVS:
CVS: Committing in .
CVS:
CVS: Modified Files:
CVS:    slapi-private.h connection.c daemon.c
CVS: ----------------------------------------------------------------------
Checking in slapi-private.h;
/cvs/dirsec/ldapserver/ldap/servers/slapd/slapi-private.h,v  <--  slapi-private.h
new revision: 1.11; previous revision: 1.10
done
Checking in connection.c;
/cvs/dirsec/ldapserver/ldap/servers/slapd/connection.c,v  <--  connection.c
new revision: 1.11; previous revision: 1.10
done
Checking in daemon.c;
/cvs/dirsec/ldapserver/ldap/servers/slapd/daemon.c,v  <--  daemon.c
new revision: 1.9; previous revision: 1.8
done


Comment 5 Noriko Hosoi 2006-09-24 00:28:11 UTC
A stupid copy and paste bug... :(

Index: connection.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/connection.c,v
retrieving revision 1.11
diff -t -w -U4 -r1.11 connection.c
--- connection.c        15 Sep 2006 22:45:11 -0000      1.11
+++ connection.c        24 Sep 2006 00:26:57 -0000
@@ -280,9 +280,9 @@
 
     /*
      * get destination address (server IP address this client connected to)
      */
-    slapi_ch_free( (void**)&conn->cin_addr ); /* just to be conservative */
+    slapi_ch_free( (void**)&conn->cin_destaddr ); /* just to be conservative */
     if ( conn->c_prfd != NULL ) {
         conn->cin_destaddr = (PRNetAddr *) slapi_ch_malloc( sizeof( PRNetAddr ) );
         memset( conn->cin_destaddr, 0, sizeof( PRNetAddr ));
         if (PR_GetSockName( conn->c_prfd, conn->cin_destaddr ) == 0) {


Comment 6 Noriko Hosoi 2006-09-24 00:31:28 UTC
[206724] Processed: Replacing PR_SetNetAddr with PRLDAP_SET_PORT for IPv6 support
comment#5: Fixed a stupid copy and paste bug...
CVS: ----------------------------------------------------------------------
CVS: Modified Files:
CVS:    connection.c
CVS: ----------------------------------------------------------------------
Checking in connection.c;
/cvs/dirsec/ldapserver/ldap/servers/slapd/connection.c,v  <--  connection.c
new revision: 1.12; previous revision: 1.11
done
   

Comment 7 Noriko Hosoi 2006-10-09 22:50:28 UTC
*** Bug 180481 has been marked as a duplicate of this bug. ***

Comment 8 Noriko Hosoi 2007-11-30 00:31:57 UTC
Checked source code:
$ pwd
/share/dev4/ds/ds80/builds/20071129.1/earthquake_rhel4/ldapserver

PR_SetNetAddr is used only when netaddr needs to be set:
$ find . -name "*.[ch]" | xargs egrep PR_SetNetAddr
./ldap/servers/slapd/daemon.c:          if ( PR_SUCCESS !=
PR_SetNetAddr(PR_IpAddrAny, PR_AF_INET6, 0, netaddr)) {
./ldap/servers/slapd/daemon.c:                                 
"PR_SetNetAddr(PR_IpAddrAny) failed - %s error %d (%s)\n",
./ldap/servers/slapd/slapi-private.h: * Introduced to avoid calling
PR_SetNetAddr w/ PR_IpAddrNull just to set port.

Where the port needs to be set uses the macro PRLDAP_SET_PORT:
$ find . -name "*.[ch]" | xargs egrep PRLDAP_SET_PORT
./ldap/servers/slapd/connection.c:          PRLDAP_SET_PORT(conn->cin_addr,
addr.sin_port);
./ldap/servers/slapd/connection.c:          PRLDAP_SET_PORT( conn->cin_destaddr,
destaddr.sin_port );
./ldap/servers/slapd/daemon.c:          PRLDAP_SET_PORT( pr_netaddr, ((struct
sockaddr_in *)addr)->sin_port );
./ldap/servers/slapd/daemon.c:                  PRLDAP_SET_PORT( &sa_server, port );
./ldap/servers/slapd/slapi-private.h:#define PRLDAP_SET_PORT(myaddr,myport) \

Verified.


Note You need to log in before you can comment on or make changes to this bug.