drbd-utils/fix-segfault-up-stacked-resource.patch

50 lines
1.9 KiB
Diff

diff -Naur drbd-utils-8.9.6.orig/user/v9/drbdadm.h drbd-utils-8.9.6/user/v9/drbdadm.h
--- drbd-utils-8.9.6.orig/user/v9/drbdadm.h 2016-06-23 18:20:40.608796513 +0800
+++ drbd-utils-8.9.6/user/v9/drbdadm.h 2016-06-23 18:21:18.828684887 +0800
@@ -388,6 +388,7 @@
extern void global_validate_maybe_expand_die_if_invalid(int expand, enum pp_flags flags);
extern struct d_option *new_opt(char *name, char *value);
extern int hostname_in_list(const char *name, struct names *names);
+extern bool hostnames_equal(const char *a, const char *b);
extern char *_names_to_str(char* buffer, struct names *names);
extern char *_names_to_str_c(char* buffer, struct names *names, char c);
#define NAMES_STR_SIZE 255
diff -Naur drbd-utils-8.9.6.orig/user/v9/drbdadm_postparse.c drbd-utils-8.9.6/user/v9/drbdadm_postparse.c
--- drbd-utils-8.9.6.orig/user/v9/drbdadm_postparse.c 2016-06-23 18:20:40.608796513 +0800
+++ drbd-utils-8.9.6/user/v9/drbdadm_postparse.c 2016-06-23 18:21:13.644700061 +0800
@@ -98,6 +98,21 @@
}
}
+struct d_host_info *find_host_info_by_fakename(struct d_resource* res, char *name)
+{
+ struct d_host_info *host;
+ char *concat_name;
+
+ for_each_host(host, &res->all_hosts) {
+ concat_name = strdup(names_to_str_c(&host->on_hosts, '_'));
+ if (hostnames_equal(name, concat_name))
+ return host;
+ }
+
+ return NULL;
+}
+
+
struct d_host_info *find_host_info_by_name(struct d_resource* res, char *name)
{
struct d_host_info *host;
@@ -403,7 +418,11 @@
if (conn->peer) {
host_info = conn->peer;
} else {
- host_info = find_host_info_by_name(res, candidate->name);
+ if (candidate->faked_hostname) {
+ host_info = find_host_info_by_fakename(res, candidate->name);
+ } else {
+ host_info = find_host_info_by_name(res, candidate->name);
+ }
conn->peer = host_info;
}
path->peer_address = candidate->address.addr ? &candidate->address : &host_info->address;