Commit Diff
Diff:
25b52297a89efd243c38662b0822a14ee354f97b
4cddaf23829dbf69c4cdec9b9aa5541a0d054b7d
Commit:
4cddaf23829dbf69c4cdec9b9aa5541a0d054b7d
Tree:
e572c4fdf80be1313988220be65dcab7ad0891af
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Sat Oct 26 08:13:04 2019 UTC
Message:
fix up the IPv6 notify code, it was never really tested. And I don't have it in production either. Now it should work.
blob - 9fe989b2398d6ccc10a437560d0b2c2cfb7b1c55
blob + fedcb8ecfe155f9182ab9e63f9a03233bdc02178
--- axfr.c
+++ axfr.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: axfr.c,v 1.33 2019/07/09 12:24:09 pjp Exp $
+ * $Id: axfr.c,v 1.34 2019/10/26 08:13:04 pjp Exp $
*/
#include <sys/types.h>
@@ -356,10 +356,11 @@ axfrloop(int *afd, int sockcount, char **ident, ddDB *
memset((char *)&from, 0, sizeof(from));
sin6 = (struct sockaddr_in6 *)&from;
- sin->sin_family = AF_INET6;
- sin->sin_port = htons(0);
+ sin6->sin6_family = AF_INET6;
+ sin6->sin6_port = htons(0);
+ sin6->sin6_len = sizeof(struct sockaddr_in6);
- if (bind(notifyfd[1], (struct sockaddr *)sin, sizeof(*sin6)) < 0) {
+ if (bind(notifyfd[1], (struct sockaddr *)sin6, sizeof(*sin6)) < 0) {
dolog(LOG_INFO, "bind notify6: %s\n", strerror(errno));
}
@@ -733,7 +734,9 @@ axfrloop(int *afd, int sockcount, char **ident, ddDB *
sin6 = (struct sockaddr_in6 *)&from;
inet_ntop(AF_INET6, (void*)&sin6->sin6_addr, (char*)&address, sizeof(address));
- question = build_question(buf, len, ntohs(dh->additional), NULL);
+ /* save buf */
+ memcpy(buf0, buf, len);
+ question = build_question(buf0, len, ntohs(dh->additional), NULL);
if (question == NULL) {
dolog(LOG_INFO, "build_question failed on notify reply, drop\n");
continue;
@@ -1607,6 +1610,7 @@ notifypacket(int so, void *vnotnp, void *vmd, int pack
struct sockaddr_in6 *tmpsin = (struct sockaddr_in6 *)&newsin;
tmpsin->sin6_port = ((struct sockaddr_in6 *)&savesin)->sin6_port;
+ tmpsin->sin6_len = sizeof(struct sockaddr_in6);
if (bind(so, (struct sockaddr *)tmpsin, sizeof(struct sockaddr_in6)) < 0) {
dolog(LOG_INFO, "can't bind to v6 bind address found in mzone for zone \"%s\"", mz->humanname);
@@ -1684,9 +1688,10 @@ notifypacket(int so, void *vnotnp, void *vmd, int pack
memset(&bsin6, 0, sizeof(bsin6));
bsin6.sin6_family = AF_INET6;
bsin6.sin6_port = htons(md->port);
+ bsin6.sin6_len = sizeof(struct sockaddr_in6);
memcpy(&bsin6.sin6_addr, &tmpsin->sin6_addr, 16);
- ret = sendto(so, packet, outlen, 0, (struct sockaddr *)sin6, slen);
+ ret = sendto(so, packet, outlen, 0, (struct sockaddr *)&bsin6, slen);
}
if (ret < 0) {
repomaster@centroid.eu