]> git.proxmox.com Git - mirror_corosync.git/commitdiff
totem: Display IP of sender v2.99.1
authorJan Friesse <jfriesse@redhat.com>
Wed, 14 Mar 2018 16:23:29 +0000 (17:23 +0100)
committerJan Friesse <jfriesse@redhat.com>
Fri, 16 Mar 2018 12:58:15 +0000 (13:58 +0100)
To make finding victim of incompatible messages easier, IP of sender is
logged. Propagating IP in layers makes patch slightly larger.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
exec/totemip.c
exec/totemknet.c
exec/totemknet.h
exec/totemnet.c
exec/totemnet.h
exec/totemsrp.c
exec/totemudp.c
exec/totemudp.h
exec/totemudpu.c
exec/totemudpu.h
include/corosync/totem/totemip.h

index 6a9b682ee5f96fb580ce3893671afbb3ef85bace..1eb0889c0a3730f887f896dbcfb6a37084f1c22f 100644 (file)
@@ -211,6 +211,28 @@ int totemip_localhost_check(const struct totem_ip_address *addr)
        return totemip_equal(addr, &localhost);
 }
 
+const char *totemip_sa_print(const struct sockaddr *sa)
+{
+       static char buf[INET6_ADDRSTRLEN];
+
+       buf[0] = 0;
+
+       switch (sa->sa_family) {
+       case AF_INET:
+               inet_ntop(sa->sa_family, &((struct sockaddr_in *)(sa))->sin_addr, buf,
+                   INET6_ADDRSTRLEN);
+               break;
+       case AF_INET6:
+               inet_ntop(sa->sa_family, &((struct sockaddr_in6 *)(sa))->sin6_addr, buf,
+                   INET6_ADDRSTRLEN);
+               break;
+       default:
+               return (NULL);
+       }
+
+       return (buf);
+}
+
 const char *totemip_print(const struct totem_ip_address *addr)
 {
        static char buf[INET6_ADDRSTRLEN];
index 70ef8bac92c7b4b4b4244aacdbee3fb76b257a39..32ef67907b618f63817394302cb33101d0a12bfa 100644 (file)
@@ -94,7 +94,8 @@ struct totemknet_instance {
        void (*totemknet_deliver_fn) (
                void *context,
                const void *msg,
-               unsigned int msg_len);
+               unsigned int msg_len,
+               const struct sockaddr_storage *system_from);
 
        void (*totemknet_iface_change_fn) (
                void *context,
@@ -648,7 +649,8 @@ static int data_deliver_fn (
        instance->totemknet_deliver_fn (
                instance->context,
                instance->iov_buffer,
-               msg_len);
+               msg_len,
+               &system_from);
 
        return (0);
 }
@@ -777,7 +779,8 @@ int totemknet_initialize (
        void (*deliver_fn) (
                void *context,
                const void *msg,
-               unsigned int msg_len),
+               unsigned int msg_len,
+               const struct sockaddr_storage *system_from),
 
        void (*iface_change_fn) (
                void *context,
index 0f54d6ccd4189136de289ceaec40af0811ab6bc1..5a4dac7b040287c08a9caa99d9a09947937c0c88 100644 (file)
@@ -54,7 +54,8 @@ extern int totemknet_initialize (
        void (*deliver_fn) (
                void *context,
                const void *msg,
-               unsigned int msg_len),
+               unsigned int msg_len,
+               const struct sockaddr_storage *system_from),
 
        void (*iface_change_fn) (
                void *context,
index 7e515385a387a6c4f7358a7aecfe5d606fb353e5..a16604d0f6fedc053005e53eb9eec706b9d02389 100644 (file)
@@ -57,9 +57,10 @@ struct transport {
                void *context,
 
                void (*deliver_fn) (
-               void *context,
-               const void *msg,
-               unsigned int msg_len),
+                       void *context,
+                       const void *msg,
+                       unsigned int msg_len,
+                       const struct sockaddr_storage *system_from),
 
                void (*iface_change_fn) (
                        void *context,
@@ -307,7 +308,8 @@ int totemnet_initialize (
        void (*deliver_fn) (
                void *context,
                const void *msg,
-               unsigned int msg_len),
+               unsigned int msg_len,
+               const struct sockaddr_storage *system_from),
 
        void (*iface_change_fn) (
                void *context,
index 9b54177feba7fd3775f7c3b9331c465d6d65618a..e552c1f69d291b2aa254372082c43702b7557ea5 100644 (file)
@@ -64,7 +64,8 @@ extern int totemnet_initialize (
        void (*deliver_fn) (
                void *context,
                const void *msg,
-               unsigned int msg_len),
+               unsigned int msg_len,
+               const struct sockaddr_storage *system_from),
 
        void (*iface_change_fn) (
                void *context,
index afa4f39fb67e4ff91c6383c0cb4e11e5e11e1a84..203eb0640783807fce3f47d10bfa05cc84038878 100644 (file)
@@ -665,7 +665,8 @@ static const char* gsfrom_to_msg(enum gather_state_from gsfrom);
 void main_deliver_fn (
        void *context,
        const void *msg,
-       unsigned int msg_len);
+       unsigned int msg_len,
+       const struct sockaddr_storage *system_from);
 
 void main_iface_change_fn (
        void *context,
@@ -4617,7 +4618,8 @@ static int message_handler_token_hold_cancel (
 static int check_message_header_validity(
        void *context,
        const void *msg,
-       unsigned int msg_len)
+       unsigned int msg_len,
+       const struct sockaddr_storage *system_from)
 {
        struct totemsrp_instance *instance = context;
        const struct totem_message_header *message_header = msg;
@@ -4626,8 +4628,8 @@ static int check_message_header_validity(
 
        if (msg_len < sizeof (struct totem_message_header)) {
                log_printf (instance->totemsrp_log_level_security,
-                           "Received message is too short...  Ignoring %u.",
-                           (unsigned int)msg_len);
+                           "Message received from %s is too short...  Ignoring %u.",
+                           totemip_sa_print((struct sockaddr *)system_from), (unsigned int)msg_len);
                return (-1);
        }
 
@@ -4675,7 +4677,8 @@ static int check_message_header_validity(
                }
 
                log_printf(instance->totemsrp_log_level_security,
-                   "Received message with bad magic number (probably sent by %s).. Ignoring",
+                   "Message received from %s has bad magic number (probably sent by %s).. Ignoring",
+                   totemip_sa_print((struct sockaddr *)system_from),
                    guessed_str);
 
                return (-1);
@@ -4683,8 +4686,9 @@ static int check_message_header_validity(
 
        if (message_header->version != TOTEM_MH_VERSION) {
                log_printf(instance->totemsrp_log_level_security,
-               "Received message with unsupported version %u... Ignoring",
-               message_header->version);
+                   "Message received from %s has unsupported version %u... Ignoring",
+                   totemip_sa_print((struct sockaddr *)system_from),
+                   message_header->version);
 
                return (-1);
        }
@@ -4696,12 +4700,13 @@ static int check_message_header_validity(
 void main_deliver_fn (
        void *context,
        const void *msg,
-       unsigned int msg_len)
+       unsigned int msg_len,
+       const struct sockaddr_storage *system_from)
 {
        struct totemsrp_instance *instance = context;
        const struct totem_message_header *message_header = msg;
 
-       if (check_message_header_validity(context, msg, msg_len) == -1) {
+       if (check_message_header_validity(context, msg, msg_len, system_from) == -1) {
                return ;
        }
 
@@ -4726,7 +4731,8 @@ void main_deliver_fn (
                break;
        default:
                log_printf (instance->totemsrp_log_level_security,
-                   "Type of received message is wrong...  ignoring %d.\n",
+                   "Message received from %s has wrong type...  ignoring %d.\n",
+                   totemip_sa_print((struct sockaddr *)system_from),
                    (int)message_header->type);
 
                instance->stats.rx_msg_dropped++;
index 154dab736b3ae89fdc6ffd4fa4c100cd2a0ad580..749fc7e8d3dd0f562c5ecf8597fee091ec01d315 100644 (file)
@@ -113,7 +113,8 @@ struct totemudp_instance {
        void (*totemudp_deliver_fn) (
                void *context,
                const void *msg,
-               unsigned int msg_len);
+               unsigned int msg_len,
+               const struct sockaddr_storage *system_from);
 
        void (*totemudp_iface_change_fn) (
                void *context,
@@ -493,7 +494,8 @@ static int net_deliver_fn (
        instance->totemudp_deliver_fn (
                instance->context,
                iovec->iov_base,
-               iovec->iov_len);
+               iovec->iov_len,
+               &system_from);
 
        iovec->iov_len = UDP_RECEIVE_FRAME_SIZE_MAX;
        return (0);
@@ -1137,7 +1139,8 @@ int totemudp_initialize (
        void (*deliver_fn) (
                void *context,
                const void *msg,
-               unsigned int msg_len),
+               unsigned int msg_len,
+               const struct sockaddr_storage *system_from),
 
        void (*iface_change_fn) (
                void *context,
index 135284f4874b71108937faa891927c12a973359d..d4a01f645683074b91c49fb806f29f7404972467 100644 (file)
@@ -54,7 +54,8 @@ extern int totemudp_initialize (
        void (*deliver_fn) (
                void *context,
                const void *msg,
-               unsigned int msg_len),
+               unsigned int msg_len,
+               const struct sockaddr_storage *system_from),
 
        void (*iface_change_fn) (
                void *context,
index db9bf5d157104e5551161a7b10899ec8e6669b4a..fff1d8d9de792c9758d24e025b8915ea2dd5121f 100644 (file)
@@ -103,7 +103,8 @@ struct totemudpu_instance {
        void (*totemudpu_deliver_fn) (
                void *context,
                const void *msg,
-               unsigned int msg_len);
+               unsigned int msg_len,
+               const struct sockaddr_storage *system_from);
 
        void (*totemudpu_iface_change_fn) (
                void *context,
@@ -472,7 +473,8 @@ static int net_deliver_fn (
        instance->totemudpu_deliver_fn (
                instance->context,
                iovec->iov_base,
-               iovec->iov_len);
+               iovec->iov_len,
+               &system_from);
 
        iovec->iov_len = UDP_RECEIVE_FRAME_SIZE_MAX;
        return (0);
@@ -781,7 +783,8 @@ int totemudpu_initialize (
        void (*deliver_fn) (
                void *context,
                const void *msg,
-               unsigned int msg_len),
+               unsigned int msg_len,
+               const struct sockaddr_storage *system_from),
 
        void (*iface_change_fn) (
                void *context,
index e1f227224feb52300951dedb060db40e09eeb2ae..47ee4772832381dfc7efe324bff95638f780d2bc 100644 (file)
@@ -54,7 +54,8 @@ extern int totemudpu_initialize (
        void (*deliver_fn) (
                void *context,
                const void *msg,
-               unsigned int msg_len),
+               unsigned int msg_len,
+               const struct sockaddr_storage *system_from),
 
        void (*iface_change_fn) (
                void *context,
index 428b9513a6f19aa3533bde7ab7f87cef29d3c4a0..4c9f42e4b2eee29fe584e5130f8871b2faeecabb 100644 (file)
@@ -88,6 +88,7 @@ extern void totemip_copy_endian_convert(struct totem_ip_address *addr1,
 int totemip_localhost(int family, struct totem_ip_address *localhost);
 extern int totemip_localhost_check(const struct totem_ip_address *addr);
 extern const char *totemip_print(const struct totem_ip_address *addr);
+extern const char *totemip_sa_print(const struct sockaddr *sa);
 extern int totemip_sockaddr_to_totemip_convert(const struct sockaddr_storage *saddr,
                                               struct totem_ip_address *ip_addr);
 extern int totemip_totemip_to_sockaddr_convert(struct totem_ip_address *ip_addr,