Re: [PATCH 2/2] Display warning if multiple IPs are found

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/12/12 14:11 +0100, Fabio M. Di Nitto wrote:
On 12/3/2012 1:57 PM, Jan Friesse wrote:
Fabio M. Di Nitto napsal(a):
On 12/3/2012 12:13 PM, Jan Friesse wrote:
Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 exec/totemip.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/exec/totemip.c b/exec/totemip.c
index 77bcad5..35741c5 100644
--- a/exec/totemip.c
+++ b/exec/totemip.c
@@ -53,12 +53,15 @@

 #include <corosync/totem/totemip.h>
 #include <corosync/swab.h>
+#include <corosync/logsys.h>

 #define LOCALHOST_IPV4 "127.0.0.1"
 #define LOCALHOST_IPV6 "::1"

 #define NETLINK_BUFSIZE 16384

+LOGSYS_DECLARE_SUBSYS ("IP");
+
 #ifdef SO_NOSIGPIPE
 void totemip_nosigpipe(int s)
 {
@@ -287,6 +290,11 @@ int totemip_parse(struct totem_ip_address *totemip, const char *addr, int family
 	else
 		memcpy(totemip->addr, &sa6->sin6_addr, sizeof(struct in6_addr));

+	if (ainfo->ai_next != NULL) {
+		log_printf(LOGSYS_LEVEL_WARNING,
+		    "More then one address found for %s. Please consider using /etc/hosts", addr);
+	}
+
 	freeaddrinfo(ainfo);
 	return 0;
 }


This patch doesn´t look right. We can´t add a subsystem without logging
config et all. And calling log_printf directly breaks totem logging
callbacks.


Actually, config should be created by LOGSYS_DECLARE_SUBSYS

The issue is that we can´t call either LOGSYS_DECLARE_SUBSYS nor
log_printf directly here.

By declaring a subsystem, that subsystem would be "standalone" and won´t
refer to the global config.

libtotem has aliases all over the code for log_printf to point to a
function exported from exec/main.c (totemlog_printf) that points to
qb_log_from_external_source_va.
It´s not a direct call from libtotem into libqb->log_printf.

The reason is that a shared library should never log directly, but it
can be instructed to log if a logging function is provided (what
libtotem does).

Exactly, basically you need that for totemip.

some options:
1) just add a similar mechanism for totemip.
   pass that totem config struct with the logging callback into totemip
2) Do this only once for all of totem instead of in each file and totem has
   it's own log wrapper.

3) just pass the subsysid around (it's the tag that gets passed into qb_log_from_external_source_va)
   and #include <qb/qblog.h> then you can call qb_logt(LOG_INFO, subsysid, "message") directly.

-Angus



How about returning a different error code from totemip_parse if there
is more than one ip?

< 0 == error
0 == all good
0 == more than one ip


Ya, that was actually idea. Problem is, that call of this function is in
multiple places, and (at least) totemconfig.c also doesn't register
itself to logsys...


I see, the above patch can´t work as-is (or at least it won´t integrate
nicely).

Since we are linking to libqb, maybe we can talk to Angus to move the
whole libtotem logging to LOGSYS_DECLARE_SUBSYS with some defaults to be
"off" and the libtotem users can turn it on on-demand (that would
default on for corosync). But I am not sure if it´s possible or how that
would work.

Fabio

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss
_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss



[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux