Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 220131 Details for
Bug 323711
Add ccs_lookup_nodename function from libccs in HEAD to RHEL5 libccs
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
new function
libccs.diff (text/plain), 5.89 KB, created by
Ryan McCabe
on 2007-10-08 20:27:46 UTC
(
hide
)
Description:
new function
Filename:
MIME Type:
Creator:
Ryan McCabe
Created:
2007-10-08 20:27:46 UTC
Size:
5.89 KB
patch
obsolete
>Index: ccs/lib/ccs.h >=================================================================== >RCS file: /cvs/cluster/cluster/ccs/lib/ccs.h,v >retrieving revision 1.4 >diff -u -r1.4 ccs.h >--- ccs/lib/ccs.h 13 Jan 2005 16:19:08 -0000 1.4 >+++ ccs/lib/ccs.h 8 Oct 2007 16:29:50 -0000 >@@ -1,7 +1,7 @@ > /****************************************************************************** > ******************************************************************************* > ** >-** Copyright (C) 2004 Red Hat, Inc. All rights reserved. >+** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. > ** > ** This copyrighted material is made available to anyone wishing to use, > ** modify, copy, or redistribute it subject to the terms and conditions >@@ -20,5 +20,6 @@ > int ccs_set(int desc, const char *path, char *val); > int ccs_get_state(int desc, char **cw_path, char **prev_query); > int ccs_set_state(int desc, const char *cw_path, int reset_query); >+int ccs_lookup_nodename(int desc, const char *nodename, char **rtn); > > #endif /* __CCS_DOT_H__ */ >Index: ccs/lib/libccs.c >=================================================================== >RCS file: /cvs/cluster/cluster/ccs/lib/libccs.c,v >retrieving revision 1.10 >diff -u -r1.10 libccs.c >--- ccs/lib/libccs.c 11 Jan 2006 16:00:55 -0000 1.10 >+++ ccs/lib/libccs.c 8 Oct 2007 16:29:50 -0000 >@@ -1,7 +1,7 @@ > /****************************************************************************** > ******************************************************************************* > ** >-** Copyright (C) 2004 Red Hat, Inc. All rights reserved. >+** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. > ** > ** This copyrighted material is made available to anyone wishing to use, > ** modify, copy, or redistribute it subject to the terms and conditions >@@ -17,6 +17,8 @@ > #include <sys/un.h> > #include <netinet/in.h> > #include <arpa/inet.h> >+#include <netdb.h> >+#include <ctype.h> > #include <errno.h> > > #include "log.h" /* Libraries should not print - so only use log_dbg */ >@@ -623,3 +625,175 @@ > EXIT("ccs_set_state"); > return error; > } >+ >+/** >+ * ccs_lookup_nodename >+ * @cd: ccs descriptor >+ * @nodename: node name string >+ * @retval: pointer to location to assign the result, if found >+ * >+ * This function takes any valid representation (FQDN, non-qualified >+ * hostname, IP address, IPv6 address) of a node's name and finds its >+ * canonical name (per cluster.conf). This function will find the primary >+ * node name if passed a node's "altname" or any valid representation >+ * of it. >+ * >+ * Returns: 0 on success, < 0 on failure >+ */ >+int ccs_lookup_nodename(int cd, const char *nodename, char **retval) { >+ char path[256]; >+ char host_only[128]; >+ char *str; >+ char *p; >+ int error; >+ int ret; >+ unsigned int i; >+ size_t nodename_len; >+ struct addrinfo hints; >+ >+ if (nodename == NULL) >+ return (-1); >+ >+ nodename_len = strlen(nodename); >+ ret = snprintf(path, sizeof(path), >+ "/cluster/clusternodes/clusternode[@name=\"%s\"]/@name", nodename); >+ if (ret < 0 || (size_t) ret >= sizeof(path)) >+ return (-ENOSPC); >+ >+ str = NULL; >+ error = ccs_get(cd, path, &str); >+ if (!error) { >+ *retval = str; >+ return (0); >+ } >+ >+ if (nodename_len >= sizeof(host_only)) >+ return (-ENOSPC); >+ >+ /* Try just the hostname */ >+ strcpy(host_only, nodename); >+ p = strchr(host_only, '.'); >+ if (p != NULL) { >+ *p = '\0'; >+ >+ ret = snprintf(path, sizeof(path), >+ "/cluster/clusternodes/clusternode[@name=\"%s\"]/@name", >+ host_only); >+ if (ret < 0 || (size_t) ret >= sizeof(path)) >+ return (-ENOSPC); >+ >+ str = NULL; >+ error = ccs_get(cd, path, &str); >+ if (!error) { >+ *retval = str; >+ return (0); >+ } >+ } >+ >+ memset(&hints, 0, sizeof(hints)); >+ if (strchr(nodename, ':') != NULL) >+ hints.ai_family = AF_INET6; >+ else if (isdigit(nodename[nodename_len - 1])) >+ hints.ai_family = AF_INET; >+ else >+ hints.ai_family = AF_UNSPEC; >+ >+ /* >+ ** Try to match against each clusternode in cluster.conf. >+ */ >+ for (i = 1 ; ; i++) { >+ const char *pathstr = NULL; >+ char canonical_name[128]; >+ unsigned int altcnt; >+ >+ ret = snprintf(path, sizeof(path), >+ "/cluster/clusternodes/clusternode[%u]/@name", i); >+ if (ret < 0 || (size_t) ret >= sizeof(path)) >+ continue; >+ >+ for (altcnt = 0 ; ; altcnt++) { >+ size_t len; >+ struct addrinfo *ai = NULL; >+ char cur_node[128]; >+ >+ if (altcnt != 0) { >+ ret = snprintf(path, sizeof(path), pathstr, i, altcnt); >+ if (ret < 0 || (size_t) ret >= sizeof(path)) >+ continue; >+ } >+ >+ str = NULL; >+ error = ccs_get(cd, path, &str); >+ if (error || !str) { >+ if (altcnt == 0) >+ goto out_fail; >+ break; >+ } >+ >+ if (altcnt == 0) { >+ if (strlen(str) >= sizeof(canonical_name)) { >+ free(str); >+ return (-ENOSPC); >+ } >+ strcpy(canonical_name, str); >+ } >+ >+ if (strlen(str) >= sizeof(cur_node)) { >+ free(str); >+ return (-ENOSPC); >+ } >+ >+ strcpy(cur_node, str); >+ >+ p = strchr(cur_node, '.'); >+ if (p != NULL) >+ len = p - cur_node; >+ else >+ len = strlen(cur_node); >+ >+ if (strlen(host_only) == len && >+ !strncasecmp(host_only, cur_node, len)) >+ { >+ free(str); >+ *retval = strdup(canonical_name); >+ if (*retval == NULL) >+ return (-ENOMEM); >+ return (0); >+ } >+ >+ if (getaddrinfo(str, NULL, &hints, &ai) == 0) { >+ struct addrinfo *cur; >+ >+ for (cur = ai ; cur != NULL ; cur = cur->ai_next) { >+ char hostbuf[512]; >+ if (getnameinfo(cur->ai_addr, cur->ai_addrlen, >+ hostbuf, sizeof(hostbuf), >+ NULL, 0, >+ hints.ai_family != AF_UNSPEC ? NI_NUMERICHOST : 0)) >+ { >+ continue; >+ } >+ >+ if (!strcasecmp(hostbuf, nodename)) { >+ freeaddrinfo(ai); >+ free(str); >+ *retval = strdup(canonical_name); >+ if (*retval == NULL) >+ return (-ENOMEM); >+ return (0); >+ } >+ } >+ freeaddrinfo(ai); >+ } >+ >+ free(str); >+ >+ /* Try any altnames */ >+ pathstr = "/cluster/clusternodes/clusternode[%u]/altname[%u]/@name"; >+ } >+ } >+ >+out_fail: >+ *retval = NULL; >+ return (-1); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 323711
: 220131