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.
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.
(In reply to comment #1) [...] > connection.c, daemon.c: replaced PR_SetNetAddr with PRLDAP_SET_ADDR. Oops, "PRLDAP_SET_PORT", of course...
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
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) {
[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
*** Bug 180481 has been marked as a duplicate of this bug. ***
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.