drbdadm: Fix segfault while starting stacked resource in DRBD9
PATCH 1/1 drbdadm: Fix segfault while starting stacked resource in DRBD9
Happens in:
adm_new_peer()
argv[NA(argc)] = ssprintf("%s", conn->peer->node_id);
conn->peer == 0x0
Example config:
resource r0-U {
stacked-on-top-of r0 {
address 192.168.122.5:7788;
}
}The name of stacked host_info is set as all hosts's name concatenate by '_'. Fail to find the fake hostname in on_hosts list, which make peer of conn set to 0x0.
--- user/v9/drbdadm.h | 1 + user/v9/drbdadm_postparse.c | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-)
user/v9/drbdadm.h +1 -0
@@ -388,6 +388,7 @@ extern void expand_common(void);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
user/v9/drbdadm_postparse.c +19 -1
@@ -98,6 +98,20 @@ void set_on_hosts_in_res(struct d_resource *res) } } +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 +417,11 @@ static void set_peer_in_connection(struct d_resource* res, struct connection *coif (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;
Signature · 1 line
1.8.5.6
Quoted 12 lines · Nick Wang
Happens in:
adm_new_peer()
argv[NA(argc)] = ssprintf("%s", conn->peer->node_id);
conn->peer == 0x0
Example config:
resource r0-U {
stacked-on-top-of r0 {
address 192.168.122.5:7788;
}
}Quoted 4 lines
The name of stacked
host_infois set as all hosts's name concatenate by '_'. Fail to find the fake hostname inon_hostslist, which make peer of conn set to0x0.
Hi Nick,
The segfault happens because conn->peer is NULL? It could still be NULL with your patch. I need a real/complete configuration and please provide more information how and why you think this fixes anything. As is, I can not apply this patch, the intention is unclear to me and it looks broken.
Regards, rck
Hi Roland,
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 2016-7-4 at 17:30, in message <[email protected]>, Roland
Quoted 4 lines · Kammerer
The segfault happens because
conn->peeris NULL? It could still be NULL with your patch. I need a real/complete configuration and please provide more information how and why you think this fixes anything. As is, I can not apply this patch, the intention is unclear to me and it looks broken.
Sorry for didn't describe clearly, information is list below:
# DRBD version:
drbd: 9.0.1-1 (GIT-hash: 86e443973082570aeb651848db89e0c7b995c306)
drbd-utils: 8.9.6
# Steps to reproduce this issue:
Launch "drbdadm up r0-U" on node "siteB-node1"(can be reproduced as long as the peer node is stacked) to start stached resource, segment fault happend.
# r0.res
resource r0 {
protocol C;
device /dev/drbd2;
disk /dev/vdb3;
meta-disk internal; on siteA-node1 {
address 192.168.122.57:7900;
} on siteA-node2 {
address 192.168.122.29:7900; }
}
resource r0-U {
protocol A;
device /dev/drbd5;
stacked-on-top-of r0 {
address 10.0.0.1:7910;
} on siteB-node1 {
disk /dev/vdb3;
address 10.0.0.2:7910; # Public IP of the backup node
meta-disk internal; }
}
# Coredump file:
#0 0x000000000040c547 in adm_new_peer (ctx=<optimized out>) at drbdadm_main.c:1617
1617 argv[NA(argc)] = ssprintf("%s", conn->peer->node_id);
(gdb) bt
#0 0x000000000040c547 in adm_new_peer (ctx=<optimized out>) at drbdadm_main.c:1617
#1 0x000000000040ba23 in __call_cmd_fn (ctx=ctx@entry=0x2478800, on_error=on_error@entry=KEEP_RUNNING) at drbdadm_main.c:607
#2 0x000000000040e078 in _run_deferred_cmds (stage=stage@entry=CFG_NET_PREP_UP) at drbdadm_main.c:722
#3 0x000000000040e15f in run_deferred_cmds () at drbdadm_main.c:758
#4 0x0000000000403368 in main (argc=3, argv=0x7ffdc0b4dcc8) at drbdadm_main.c:3339
(gdb) p *conn
$3 = {name = 0x0, paths = {stqh_first = 0x2478550, stqh_last = 0x2478598}, config_line = 0, peer_devices = {stqh_first = 0x2473750,
stqh_last = 0x2473780}, peer = 0x0, net_options = {stqh_first = 0x2478790, stqh_last = 0x2478790}, pd_options = {stqh_first = 0x0,
stqh_last = 0x2478528}, ignore = 0, ignore_tmp = 0, implicit = 1, is_standalone = 0, link = {stqe_next = 0x0}}The conn->peer was set to 0x0, which cause this segment fault.
# Debug:
In create_implicit_connections() of post_parse, the name of struct hostname address for stacked peer is a fakename, which is concatenated by the lower nodes, in this case is "siteA-node1_siteA-node2". However, in set_peer_in_connection(), no matter stacked peer or not hostinfo is finding by compare to the on_hosts list, but "siteA-node1_siteA-node2" is not in this list. Result in fail to find the corresponding peer,so conn->peer is set to NULL.
The patch sent in last thread " [PATCH] drbdadm: Fix segfault while starting stacked resource in DRBD9" only change the behavior of finding host info of stacked peer. I tested against regular/stacked resource, the network connection can be find and establish successfully after apply the patch.
Best regards,
Nick