summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rpc/rpc-lib/src/rpcsvc.c23
-rw-r--r--xlators/cluster/afr/src/afr-common.c4
-rw-r--r--xlators/nfs/server/src/nlm4.c35
3 files changed, 29 insertions, 33 deletions
diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c
index 972461a0a93..ca637a50617 100644
--- a/rpc/rpc-lib/src/rpcsvc.c
+++ b/rpc/rpc-lib/src/rpcsvc.c
@@ -2173,14 +2173,14 @@ rpcsvc_transport_peer_check_addr (dict_t *options, char *volname,
int rjret = RPCSVC_AUTH_REJECT;
char clstr[RPCSVC_PEER_STRLEN];
char *tmp = NULL;
- struct sockaddr_storage sastorage = {0,};
- struct sockaddr *sockaddr = NULL;
+ union gf_sock_union sock_union;
if (!trans)
return ret;
ret = rpcsvc_transport_peeraddr (trans, clstr, RPCSVC_PEER_STRLEN,
- &sastorage, sizeof (sastorage));
+ &sock_union.storage,
+ sizeof (sock_union.storage));
if (ret != 0) {
gf_log (GF_RPCSVC, GF_LOG_ERROR, "Failed to get remote addr: "
"%s", gai_strerror (ret));
@@ -2188,8 +2188,7 @@ rpcsvc_transport_peer_check_addr (dict_t *options, char *volname,
goto err;
}
- sockaddr = (struct sockaddr *) &sastorage;
- switch (sockaddr->sa_family) {
+ switch (sock_union.sa.sa_family) {
case AF_INET:
case AF_INET6:
@@ -2307,10 +2306,9 @@ int
rpcsvc_transport_privport_check (rpcsvc_t *svc, char *volname,
rpc_transport_t *trans)
{
- struct sockaddr_storage sastorage = {0,};
- struct sockaddr_in *sa = NULL;
+ union gf_sock_union sock_union;
int ret = RPCSVC_AUTH_REJECT;
- socklen_t sasize = sizeof (sa);
+ socklen_t sinsize = sizeof (&sock_union.sin);
char *srchstr = NULL;
char *valstr = NULL;
int globalinsecure = RPCSVC_AUTH_REJECT;
@@ -2318,12 +2316,13 @@ rpcsvc_transport_privport_check (rpcsvc_t *svc, char *volname,
uint16_t port = 0;
gf_boolean_t insecure = _gf_false;
+ memset (&sock_union, 0, sizeof (sock_union));
+
if ((!svc) || (!volname) || (!trans))
return ret;
- sa = (struct sockaddr_in*) &sastorage;
- ret = rpcsvc_transport_peeraddr (trans, NULL, 0, &sastorage,
- sasize);
+ ret = rpcsvc_transport_peeraddr (trans, NULL, 0, &sock_union.storage,
+ sinsize);
if (ret != 0) {
gf_log (GF_RPCSVC, GF_LOG_ERROR, "Failed to get peer addr: %s",
gai_strerror (ret));
@@ -2331,7 +2330,7 @@ rpcsvc_transport_privport_check (rpcsvc_t *svc, char *volname,
goto err;
}
- port = ntohs (sa->sin_port);
+ port = ntohs (sock_union.sin.sin_port);
gf_log (GF_RPCSVC, GF_LOG_TRACE, "Client port: %d", (int)port);
/* If the port is already a privileged one, dont bother with checking
* options.
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index ddcd0bca37a..4130adc6f17 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -570,6 +570,7 @@ afr_hash_child (int32_t *success_children, int32_t child_count,
unsigned int hmode, uuid_t gfid)
{
uuid_t gfid_copy = {0,};
+ pid_t pid;
if (!hmode) {
return -1;
@@ -588,7 +589,8 @@ afr_hash_child (int32_t *success_children, int32_t child_count,
* perfection here. All we need is a low probability that
* multiple clients won't converge on the same subvolume.
*/
- *((pid_t *)gfid_copy) = getpid();
+ pid = getpid();
+ memcpy (gfid_copy, &pid, sizeof(pid));
}
return SuperFastHash((char *)gfid_copy,
diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c
index 99541fd4bde..05de66d5633 100644
--- a/xlators/nfs/server/src/nlm4.c
+++ b/xlators/nfs/server/src/nlm4.c
@@ -909,8 +909,7 @@ void *
nlm4_establish_callback (void *csarg)
{
nfs3_call_state_t *cs = NULL;
- struct sockaddr_storage sa;
- struct sockaddr *sockaddr = NULL;
+ union gf_sock_union sock_union;
dict_t *options = NULL;
char peerip[INET6_ADDRSTRLEN+1], *portstr = NULL;
rpc_clnt_t *rpc_clnt = NULL;
@@ -923,9 +922,9 @@ nlm4_establish_callback (void *csarg)
caller_name = cs->args.nlm4_lockargs.alock.caller_name;
- rpc_transport_get_peeraddr (cs->trans, NULL, 0, &sa, sizeof (sa));
- sockaddr = (struct sockaddr*) &sa;
- switch (sockaddr->sa_family) {
+ rpc_transport_get_peeraddr (cs->trans, NULL, 0, &sock_union.storage,
+ sizeof (sock_union.storage));
+ switch (sock_union.sa.sa_family) {
case AF_INET6:
/* can not come here as NLM listens on IPv4 */
gf_log (GF_NLM, GF_LOG_ERROR, "NLM is not supported on IPv6 in"
@@ -938,9 +937,8 @@ nlm4_establish_callback (void *csarg)
break;
*/
case AF_INET:
- inet_ntop (AF_INET,
- &((struct sockaddr_in *)sockaddr)->sin_addr,
- peerip, INET6_ADDRSTRLEN+1);
+ inet_ntop (AF_INET, &sock_union.sin.sin_addr, peerip,
+ INET6_ADDRSTRLEN+1);
break;
default:
break;
@@ -948,7 +946,7 @@ nlm4_establish_callback (void *csarg)
}
/* looks like libc rpc supports only ipv4 */
- port = pmap_getport ((struct sockaddr_in*)sockaddr, NLM_PROGRAM,
+ port = pmap_getport (&sock_union.sin, NLM_PROGRAM,
NLM_V4, IPPROTO_TCP);
if (port == 0) {
@@ -1031,22 +1029,19 @@ nlm4svc_send_granted (nfs3_call_state_t *cs)
struct iobref *iobref = NULL;
char peerip[INET6_ADDRSTRLEN+1];
pthread_t thr;
- struct sockaddr_storage sa;
- struct sockaddr *sockaddr = NULL;
+ union gf_sock_union sock_union;
- rpc_transport_get_peeraddr (cs->trans, NULL, 0, &sa, sizeof (sa));
- sockaddr = (struct sockaddr*) &sa;
- switch (sockaddr->sa_family) {
+ rpc_transport_get_peeraddr (cs->trans, NULL, 0, &sock_union.storage,
+ sizeof (sock_union.storage));
+ switch (sock_union.sa.sa_family) {
case AF_INET6:
- inet_ntop (AF_INET6,
- &((struct sockaddr_in6 *)sockaddr)->sin6_addr,
- peerip, INET6_ADDRSTRLEN+1);
+ inet_ntop (AF_INET6, &sock_union.sin6.sin6_addr, peerip,
+ INET6_ADDRSTRLEN+1);
break;
case AF_INET:
- inet_ntop (AF_INET,
- &((struct sockaddr_in *)sockaddr)->sin_addr,
- peerip, INET6_ADDRSTRLEN+1);
+ inet_ntop (AF_INET, &sock_union.sin.sin_addr, peerip,
+ INET6_ADDRSTRLEN+1);
default:
break;
/* FIXME: handle the error */