Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:Update
pacemaker.3577
bug-964183_pacemaker-remote-sockaddr-refactor.p...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File bug-964183_pacemaker-remote-sockaddr-refactor.patch of Package pacemaker.3577
commit 149c045750414e852f2623528ae80b84f88d0cf3 Author: Gao,Yan <ygao@suse.com> Date: Tue Feb 23 12:09:37 2016 +0100 Refactor: remote: Simplify calls to accept() and inet_ntop() by using "struct sockaddr_storage" diff --git a/lrmd/tls_backend.c b/lrmd/tls_backend.c index fd316e4..aac4f55 100644 --- a/lrmd/tls_backend.c +++ b/lrmd/tls_backend.c @@ -188,9 +188,9 @@ lrmd_auth_timeout_cb(gpointer data) /* Convert a struct sockaddr address to a string, IPv4 and IPv6: */ static char * -get_ip_str(const struct sockaddr * sa, char * s, size_t maxlen) +get_ip_str(const struct sockaddr_storage * sa, char * s, size_t maxlen) { - switch(sa->sa_family) { + switch(((struct sockaddr *)sa)->sa_family) { case AF_INET: inet_ntop(AF_INET, &(((struct sockaddr_in *)sa)->sin_addr), s, maxlen); @@ -215,7 +215,8 @@ lrmd_remote_listen(gpointer data) int csock = 0; int flag = 0; unsigned laddr = 0; - struct sockaddr addr; + struct sockaddr_storage addr; + char addr_str[INET6_ADDRSTRLEN]; gnutls_session_t *session = NULL; crm_client_t *new_client = NULL; @@ -224,32 +225,13 @@ lrmd_remote_listen(gpointer data) .destroy = lrmd_remote_client_destroy, }; + /* accept the connection */ laddr = sizeof(addr); memset(&addr, 0, sizeof(addr)); - getsockname(ssock, &addr, &laddr); - - /* accept the connection */ - - if (addr.sa_family == AF_INET6) { - struct sockaddr_in6 sa; - char addr_str[INET6_ADDRSTRLEN]; + csock = accept(ssock, (struct sockaddr *)&addr, &laddr); - laddr = sizeof(sa); - memset(&sa, 0, sizeof(sa)); - csock = accept(ssock, &sa, &laddr); - get_ip_str((struct sockaddr *)&sa, addr_str, INET6_ADDRSTRLEN); - crm_info("New remote connection from %s", addr_str); - - } else { - struct sockaddr_in sa; - char addr_str[INET_ADDRSTRLEN]; - - laddr = sizeof(sa); - memset(&sa, 0, sizeof(sa)); - csock = accept(ssock, &sa, &laddr); - get_ip_str((struct sockaddr *)&sa, addr_str, INET_ADDRSTRLEN); - crm_info("New remote connection from %s", addr_str); - } + get_ip_str(&addr, addr_str, INET6_ADDRSTRLEN); + crm_info("New remote connection from %s", addr_str); if (csock == -1) { crm_err("accept socket failed");
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor