Commit Graph

78 Commits

Author SHA1 Message Date
Jan Friesse
1777d9992c Revert "totemip: compare sin6_scope_id and interface_num"
This reverts commit efd34df531 to make
master compile after revert of 934c47ed43.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2020-04-22 13:30:36 +02:00
Jan Friesse
cd6cc90a6f Revert "totemip: Add support for sin6_scope_id"
This reverts commit 934c47ed43 which is
causing protocol incompatibility in needle. Master seems to be not
affected, but it needs more checking.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2020-04-22 13:30:19 +02:00
liangxin1300
efd34df531 totemip: compare sin6_scope_id and interface_num
When user configure a specific interface like vlan
with the same IPv6 link-local address, Corosync should
compare sin6_scope_id with interface_num, to make sure got
the right interface to bind

Signed-off-by: liangxin1300 <XLiang@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-02-21 15:46:22 +01:00
Jan Friesse
38d1d10d39 totemip: Remove unused totemip_copy_endian_convert
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2020-02-17 17:31:55 +01:00
Jan Friesse
934c47ed43 totemip: Add support for sin6_scope_id
sin6_scope_id was not present in totemip structure making impossible to
use link-local ipv6 address.

Patch adds sin6_scope_id and changes convert/copy functions to use it
(formally also comparator functions should be changed, but it seems to
cause more harm and it is not really needed).

This makes corosync work with link-local addresses fine for both UDPU
and Knet transport as long as interface specification is used (so
fe80::xxxx:xxxx:xxxx:xxxx%eth0).

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2020-02-17 17:31:42 +01:00
Jan Friesse
d4d48d9268 totemip: Use res in totemip_sa_equal
Setting res to -1 was not entirely following semantics of "equal"
operation. Set it to 0 and return it when families differs makes
compiler happy.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2019-06-12 15:40:50 +02:00
Jan Friesse
72737d3929 udpu: Drop packets from unlisted IPs
This feature allows corosync to block packets received from unknown
nodes (nodes with IP address which is not in the nodelist). This is
mainly for situations when "forgotten" node is booted and tries to join
cluster which already removed such node from configuration. Another use
case is to allow atomic reconfiguration and rejoin of two separate
clusters.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2019-05-29 16:30:10 +02:00
Jan Friesse
2ab4d41886 totemip: Use AF_UNSPEC for ipv4-6 and ipv6-4
AF_UNSPEC returns different results than AF_INET/AF_INET6, because of
nsswitch.conf search is in order and it stops asking other
modules once current module success.

Example of difference between previous and new code when ipv6-4 is used:
- /etc/hosts contains test_name with an ipv4
- previous code called AF_INET6 where /etc/hosts failed so other methods
were used which may return IPv6 addr -> result was ether fail or IPv6
address.
- new code calls AF_UNSPEC returning IPv4 defined in /etc/hosts ->
result is IPv4 address

New code behavior should solve problems caused by nss-myhostname.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2019-01-11 09:37:30 +01:00
Jan Friesse
a84ade701c totemconfig: Enhance totem.ip_version
Originally totem.ip_version was used to force ip version used by totem.
With Knet this variable didn't make too much sense so it was not used.

Sadly rely only on DNS resolver order doesn't always work (RFC is quite
complicated, but if IPv6 is not configured then IPv4 is preferred), what
we tried to solve by forcing IPv6 and only if that fails, use IPv4.

Sadly this collides with nss_myhostname which is able to return every
local address and today system usually have at least one autogenerated
link-local IPv6 address so it is able to "overwrite" /etc/hosts.

Solution is to enhance totem.ip_version and use it also for Knet.
totem.ip_version is now just a flag for resolver and can have four
states: ipv4 (only IPv4 is used), ipv6 (only IPv6 is used), ipv4-6 (ask
IPv4 first and if it fails ask for IPv6) and ipv6-4 (ask IPv6 first and
if it fails ask for IPv4). Default for Knet and UDPU transports is
ipv6-4, for UDP it's ipv4, because autogenerated mcast addr doesn't play
too well with ipv6-4.

So everywhere where nss_myhostname becomes problem, it's just possible
to set totem.ip_version to ipv4-6.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-12-14 10:56:06 +01:00
Jan Friesse
aa7daf8c77 totemip: Add debug information to totemip_parse
It's required to create TOTEM logsys subsys before totemip_parse is used
(so before totem_config_read). Logsys is not yet fully initialized, but
it's good enough.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2018-12-13 15:25:04 +01:00
Christine Caulfield
3d7f136f86 config: Look up hostnames in a defined order
Current practice is to let getaddrinfo() decide which address we get
but this is not necessarily deterministic as DNS servers won't
always return addresses in the same order if a node has
several. While this doesn't deal with node names that have
multiple IP addresses of the same family (that's an installation issue
IMHO) we can, at least, force a definite order for IPv6/IPv4 name
resolution.

I've chosen IPv6 then IPv4 as that's what happens on my test system (
using /etc/hosts) and it also seems more 'future proof'.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-12-11 11:20:50 +01:00
Christine Caulfield
707a9afa30 config: Allow generated nodeis for UDP & UDPU
The conversion to the new srp_addr format broke the feature where
UDP/UDPU nodes could get their nodeids generated from the IP address.

A big part of this was the removal of mandatory ring0_addr - it was used
as a placeholder when reading down the nodelist. I replaced this with
nodeid thinking that nodeid was now mandatory, forgetting this use case.
So the compare on "ring0_addr" or "nodeid" is now replaced with a more
robust check that we're only reading keys from the same node_pos once,
this was needed in votequorum.c as well as totemconfig.c

Another tidying side-effect of this patch is that the nodeid generation
is now all in a single routine in totemconfig.c and not shared between
it and totemip.c.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-10-25 18:21:02 +02:00
Jan Friesse
69857efb5b totem: Display IP of sender
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>
2018-03-16 13:58:15 +01:00
Jan Friesse
1f90c31ba7 list: Replace for_each by safe version where need
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2016-10-27 14:56:52 +02:00
Michael Jones
b4c06e52f3 list: Replace uses of list.h with qblist.h
Signed-off-by: Michael Jones <jonesmz@jonesmz.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2016-10-27 14:56:52 +02:00
Jan Friesse
03f95ddaa1 Adjust MTU for IPv6 correctly
MTU for IPv6 is 20 bytes larger then IPv4. This fact was not taken into
account so IPv6 packets were larger then MTU resulting in fragmentation.

Solution is to substract correct IP header size.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2014-10-01 14:20:21 +02:00
Xia Li
ca6051e80c Convert the nodeid byte order to be aligned with network order
When using corosync with clear_node_high_bit setting to yes,
the highest bit is cleared.  When all the cluster nodes are in
one subnet, we probably configure the IP addresses as follows:

node1: 147.2.207.64
node2: 147.2.207.192

If the byte order of the nodeid is little endian, wiping off the
highest bit will make the two nodes have the same nodeid!

This patch fixes this by converting the nodeid to network order.

Signed-off-by: Xia Li <xli@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2013-03-19 16:39:59 +01:00
Jan Friesse
ee59122ad7 OpenBSD getifaddrs returns netmask without sa_family
So we relax netmask check and set to same family as ipaddr
if needed

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2012-09-03 09:34:33 +02:00
Jan Friesse
932829bfca Add header files when needed
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2012-09-03 09:34:31 +02:00
Fabio M. Di Nitto
a0a14c68e3 totemip: clean up headers a lot more
getifaddrs is always available if there is freeifaddr.

all BSD and openindiana have it defined in ifaddr.h.

drop a bunch of obsoleted headers.

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-30 15:00:27 +02:00
Fabio M. Di Nitto
6098ef2c14 build: make exec/totemip os detection free
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2012-08-30 15:00:27 +02:00
Jan Friesse
2894f33c4f totemip: Support bind to exact address
Logic for binding now works in following way:
- Try to find exact match
- If not exact match is found, use first found network address

This allows set concrete IP even if network settings contains two IPs on
same network.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2012-05-24 14:01:12 +02:00
Jan Friesse
aaa575e091 totemip: insert items in correct order
list_add_tail is used instead of list_add so ip addresses are inserted
in same order as returned by getifaddrs.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2012-05-24 14:01:08 +02:00
Jan Friesse
25381738c2 Always set interface_up in totemip_iface_check
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2012-03-02 09:41:36 +01:00
Jan Friesse
88ddaecfe9 Create solaris specific getifaddrs
This not only makes possible to use generic totemip_iface_check, but
also fixes some problems with previous implementation (fixed mask, not
very well supported ipv6, ...)

Tested on OpenIndiana 151a

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2012-02-16 10:47:57 +01:00
Jan Friesse
fd47fddcaf Add totemip_iface_check based on totemip_getifaddrs
Also Linux and BSD/Darwin specific bits are no longer needed, so they
are gone.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2012-02-16 10:47:57 +01:00
Jan Friesse
27e9988486 Add generic implementation of getifaddrs
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2012-02-16 10:47:56 +01:00
Steven Dake
2ad0cdc832 Update copyright header dates in exec directory
Signed-off-by: Steven Dake <sdake@redhat.com>
Reviewed-by: Angus Salkeld <asalkeld@redhat.com>
2012-02-13 17:05:04 -07:00
Angus Salkeld
390391acba Free mem allocated by getaddrinfo
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
2011-11-11 08:11:17 +11:00
Steven Dake
83f528b473 Fix problem where unaligned totemip address access would result in bus error on non-unaligned-safe architectures.
Signed-off-by: Steven Dake <sdake@redhat.com>
Reviewed-by: Angus Salkeld <asalkeld@redhat.com>
2011-04-14 17:22:02 -07:00
Angus Salkeld
10be299e7b Check for a properly configured multicast address.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@3057 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-09-27 22:41:26 +00:00
Jan Friesse
4d2e24a2c3 Generate nodeid value when unset on BSD
Generated nodeid is generated in same way as
on Linux is.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2641 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-01-11 10:12:17 +00:00
Steven Dake
ee226d0730 Patch to use proper IFA on Linux platforms to match interface addresses when
netmask is not 255.255.255.0.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2550 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-11-27 22:59:48 +00:00
Angus Salkeld
147c81ffab don't return the ip address when the mask is not found
Currently totemip_copy (boundto,&ipaddr) is called even when the
required mask is not found.

This patch changes the behavior to only copy the ipaddr when the
mask is found.

The current behavior makes debugging an incorrect config really
confusing.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2409 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-09-09 18:55:17 +00:00
Steven Dake
4e3e77eb13 Always keep autogenerated node ids in totem as LE even on BE arches.
Have testcpg print out autogenerated nodeid properly on BE arch.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2377 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-08-04 00:04:13 +00:00
Steven Dake
b8e3951ca1 Add (void *) casts for iovector assignments to remove compile warnings.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2270 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-06-19 20:43:12 +00:00
Jim Meyering
74a2fa1194 maint: remove trailing blanks
By running this command from a git-cloned directory:
git grep -z -l -E '[[:blank:]]+$' | xargs -0 perl -pi -e 's/[ \t]+$//'

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2266 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-06-19 11:34:50 +00:00
Steven Dake
7c6911a3b1 Add iface checking for Solaris platform.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2236 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-06-14 10:13:48 +00:00
Steven Dake
1e0e9a5633 First run at adding support for corosync totemip determination.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2213 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-06-07 01:46:31 +00:00
Steven Dake
e8225b667e Port of totemip to Solaris.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2210 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-06-07 00:43:18 +00:00
Jim Meyering
eb5919f0cc totemip.h: const'ify
* include/corosync/totem/totemip.h: Add const to prototypes.
* exec/totemip.c (totemip_equal, totemip_copy): Adjust.
(totemip_copy_endian_convert, totemip_localhost_check): Likewise.
(totemip_sockaddr_to_totemip_convert): Likewise.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2012 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-07 13:03:07 +00:00
Jim Meyering
a660341656 totemip.c: avoid 1 warning
* exec/totemip.c (totemip_print): Add const.
* include/corosync/totem/totemip.h: Ditto.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1974 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-30 21:18:29 +00:00
Jim Meyering
f7152d349a totem*: add "const" to avoid 1 more warning
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1935 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-30 21:12:11 +00:00
Fabio M. Di Nitto
031c02f589 - Every .c file should include "config.h" to get the right defines...
- services/Makefile.am: add include search paths for config.h

- include/corosync/cs_config.h.in exports LCRSODIR and SOCKETDIR

- tools/Makefile.am: drop -D defines for dirs that are now in
cs_config.h or config.h

- configure.ac: sanitize prefix and exec_prefix paths. Export DIRS in
*config.h

- lib/Makefile.am: : drop -D defines for dirs that are now in
cs_config.h or config.h. Add rule to build lcr_ifact.o or building from
lib/ fails miserably



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1877 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-19 12:58:53 +00:00
Christine Caulfield
359fc86601 Add a dummy parameter to totemip_iface check so that it compiles on Darwin.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1864 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-18 08:37:10 +00:00
Steven Dake
3b9f70d235 Remove const warnings in totemip code.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1808 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-10 10:05:40 +00:00
Steven Dake
0bc9cd90f6 Automake. The journey begins.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1798 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-10 08:35:41 +00:00
Fabio M. Di Nitto
39c4b8b1b6 Fix uninitialized memory. Spotted by valgrind
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1788 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-03 03:57:37 +00:00
Steven Dake
e6c95a5fbd Fix node masking for 32 bit node ids.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1749 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-01-26 20:46:45 +00:00
Steven Dake
63fa74305b Fix message rejection problem.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1743 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-01-25 21:15:25 +00:00