summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2009-01-19 15:33:24 +0100
committerMichael Adam <obnox@samba.org>2009-01-19 22:50:53 +0100
commit3cca0f75e483f4ee11c643046067300069559fd5 (patch)
treed96d8791adb753c98509d2e762af7b6dc8265fce /ctdb
parentb6828ab22f554b1de248c0490a94693f724ecee2 (diff)
downloadsamba-3cca0f75e483f4ee11c643046067300069559fd5.tar.gz
Fix treatment of link local ipv6 addresses: set the scope id.
metze / Michael Signed-off-by: Michael Adam <obnox@samba.org> (This used to be ctdb commit 9d12de1ca6107801dada927729e755c0949d73bf)
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/common/ctdb_util.c16
-rw-r--r--ctdb/include/ctdb_private.h4
-rw-r--r--ctdb/server/ctdb_recover.c5
-rw-r--r--ctdb/server/ctdb_takeover.c12
-rw-r--r--ctdb/server/ctdbd.c1
-rw-r--r--ctdb/tcp/tcp_connect.c2
-rw-r--r--ctdb/tools/ctdb.c10
7 files changed, 30 insertions, 20 deletions
diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c
index 00a9c8c984c..33d30e21084 100644
--- a/ctdb/common/ctdb_util.c
+++ b/ctdb/common/ctdb_util.c
@@ -381,7 +381,7 @@ bool parse_ipv4(const char *s, unsigned port, struct sockaddr_in *sin)
return true;
}
-static bool parse_ipv6(const char *s, unsigned port, ctdb_sock_addr *saddr)
+static bool parse_ipv6(const char *s, const char *iface, unsigned port, ctdb_sock_addr *saddr)
{
saddr->ip6.sin6_family = AF_INET6;
saddr->ip6.sin6_port = htons(port);
@@ -393,6 +393,10 @@ static bool parse_ipv6(const char *s, unsigned port, ctdb_sock_addr *saddr)
return false;
}
+ if (iface && IN6_IS_ADDR_LINKLOCAL(&saddr->ip6.sin6_addr)) {
+ saddr->ip6.sin6_scope_id = if_nametoindex(iface);
+ }
+
return true;
}
/*
@@ -431,7 +435,7 @@ bool parse_ip_port(const char *addr, ctdb_sock_addr *saddr)
/* now is this a ipv4 or ipv6 address ?*/
- ret = parse_ip(s, addr);
+ ret = parse_ip(s, NULL, addr);
talloc_free(tmp_ctx);
return ret;
@@ -440,7 +444,7 @@ bool parse_ip_port(const char *addr, ctdb_sock_addr *saddr)
/*
parse an ip
*/
-bool parse_ip(const char *addr, ctdb_sock_addr *saddr)
+bool parse_ip(const char *addr, const char *iface, ctdb_sock_addr *saddr)
{
char *p;
bool ret;
@@ -450,7 +454,7 @@ bool parse_ip(const char *addr, ctdb_sock_addr *saddr)
if (p == NULL) {
ret = parse_ipv4(addr, 0, &saddr->ip);
} else {
- ret = parse_ipv6(addr, 0, saddr);
+ ret = parse_ipv6(addr, iface, 0, saddr);
}
return ret;
@@ -459,7 +463,7 @@ bool parse_ip(const char *addr, ctdb_sock_addr *saddr)
/*
parse a ip/mask pair
*/
-bool parse_ip_mask(const char *str, ctdb_sock_addr *addr, unsigned *mask)
+bool parse_ip_mask(const char *str, const char *iface, ctdb_sock_addr *addr, unsigned *mask)
{
TALLOC_CTX *tmp_ctx = talloc_new(NULL);
char *s, *p;
@@ -492,7 +496,7 @@ bool parse_ip_mask(const char *str, ctdb_sock_addr *addr, unsigned *mask)
/* now is this a ipv4 or ipv6 address ?*/
- ret = parse_ip(s, addr);
+ ret = parse_ip(s, iface, addr);
talloc_free(tmp_ctx);
return ret;
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 49e7a3e26b8..ceac3842bd7 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -1281,9 +1281,9 @@ int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
void ctdb_start_freeze(struct ctdb_context *ctdb);
-bool parse_ip_mask(const char *s, ctdb_sock_addr *addr, unsigned *mask);
+bool parse_ip_mask(const char *s, const char *iface, ctdb_sock_addr *addr, unsigned *mask);
bool parse_ip_port(const char *s, ctdb_sock_addr *addr);
-bool parse_ip(const char *s, ctdb_sock_addr *addr);
+bool parse_ip(const char *s, const char *iface, ctdb_sock_addr *addr);
bool parse_ipv4(const char *s, unsigned port, struct sockaddr_in *sin);
diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c
index 8bed9e6aea7..2d95b184666 100644
--- a/ctdb/server/ctdb_recover.c
+++ b/ctdb/server/ctdb_recover.c
@@ -163,7 +163,10 @@ ctdb_control_getnodemap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA ind
node_map = (struct ctdb_node_map *)outdata->dptr;
node_map->num = num_nodes;
for (i=0; i<num_nodes; i++) {
- if (parse_ip(ctdb->nodes[i]->address.address, &node_map->nodes[i].addr) == 0) {
+ if (parse_ip(ctdb->nodes[i]->address.address,
+ NULL, /* TODO: pass in the correct interface here*/
+ &node_map->nodes[i].addr) == 0)
+ {
DEBUG(DEBUG_ERR, (__location__ " Failed to parse %s into a sockaddr\n", ctdb->nodes[i]->address.address));
}
diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c
index fa9bd7719bf..4b32c6e6ff6 100644
--- a/ctdb/server/ctdb_takeover.c
+++ b/ctdb/server/ctdb_takeover.c
@@ -485,6 +485,7 @@ int ctdb_set_public_addresses(struct ctdb_context *ctdb, const char *alist)
for (i=0;i<nlines;i++) {
unsigned mask;
ctdb_sock_addr addr;
+ const char *addrstr;
const char *iface;
char *tok, *line;
@@ -499,11 +500,7 @@ int ctdb_set_public_addresses(struct ctdb_context *ctdb, const char *alist)
continue;
}
tok = strtok(line, " \t");
- if (!tok || !parse_ip_mask(tok, &addr, &mask)) {
- DEBUG(DEBUG_CRIT,("Badly formed line %u in public address list\n", i+1));
- talloc_free(lines);
- return -1;
- }
+ addrstr = tok;
tok = strtok(NULL, " \t");
if (tok == NULL) {
if (NULL == ctdb->default_public_interface) {
@@ -517,6 +514,11 @@ int ctdb_set_public_addresses(struct ctdb_context *ctdb, const char *alist)
iface = tok;
}
+ if (!addrstr || !parse_ip_mask(addrstr, iface, &addr, &mask)) {
+ DEBUG(DEBUG_CRIT,("Badly formed line %u in public address list\n", i+1));
+ talloc_free(lines);
+ return -1;
+ }
if (ctdb_add_public_address(ctdb, &addr, mask, iface)) {
DEBUG(DEBUG_CRIT,("Failed to add line %u to the public address list\n", i+1));
talloc_free(lines);
diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c
index 351948c9e5b..ee433da2eb6 100644
--- a/ctdb/server/ctdbd.c
+++ b/ctdb/server/ctdbd.c
@@ -280,6 +280,7 @@ int main(int argc, const char *argv[])
CTDB_NO_MEMORY(ctdb, svnn->iface);
if (parse_ip(options.single_public_ip,
+ svnn->iface,
&svnn->public_address) == 0) {
DEBUG(DEBUG_ALERT,("Invalid --single-public-ip argument : %s . This is not a valid ip address. Exiting.\n", options.single_public_ip));
exit(10);
diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c
index 6aa377bb405..8efb5974438 100644
--- a/ctdb/tcp/tcp_connect.c
+++ b/ctdb/tcp/tcp_connect.c
@@ -109,7 +109,7 @@ static void ctdb_node_connect_write(struct event_context *ev, struct fd_event *f
static int ctdb_tcp_get_address(struct ctdb_context *ctdb,
const char *address, ctdb_sock_addr *addr)
{
- if (parse_ip(address, addr) == 0) {
+ if (parse_ip(address, NULL, addr) == 0) {
DEBUG(DEBUG_CRIT, (__location__ " Unparsable address : %s.\n", address));
return -1;
}
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 4ba351c921c..b2014f0eb69 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -502,7 +502,7 @@ static int control_get_tickles(struct ctdb_context *ctdb, int argc, const char *
usage();
}
- if (parse_ip(argv[0], &addr) == 0) {
+ if (parse_ip(argv[0], NULL, &addr) == 0) {
DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[0]));
return -1;
}
@@ -574,7 +574,7 @@ static int control_moveip(struct ctdb_context *ctdb, int argc, const char **argv
usage();
}
- if (parse_ip(argv[0], &addr) == 0) {
+ if (parse_ip(argv[0], NULL, &addr) == 0) {
DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[0]));
return -1;
}
@@ -809,7 +809,7 @@ static int control_addip(struct ctdb_context *ctdb, int argc, const char **argv)
usage();
}
- if (!parse_ip_mask(argv[0], &addr, &mask)) {
+ if (!parse_ip_mask(argv[0], argv[1], &addr, &mask)) {
DEBUG(DEBUG_ERR, ("Badly formed ip/mask : %s\n", argv[0]));
talloc_free(tmp_ctx);
return -1;
@@ -950,7 +950,7 @@ static int control_delip(struct ctdb_context *ctdb, int argc, const char **argv)
usage();
}
- if (parse_ip(argv[0], &addr) == 0) {
+ if (parse_ip(argv[0], NULL, &addr) == 0) {
DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[0]));
return -1;
}
@@ -1048,7 +1048,7 @@ static int control_gratious_arp(struct ctdb_context *ctdb, int argc, const char
usage();
}
- if (!parse_ip(argv[0], &addr)) {
+ if (!parse_ip(argv[0], NULL, &addr)) {
DEBUG(DEBUG_ERR, ("Bad IP '%s'\n", argv[0]));
return -1;
}