]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Use the zone from which we got the tsig key for the update as well.
authorTed Lemon <source@isc.org>
Mon, 1 May 2000 23:46:39 +0000 (23:46 +0000)
committerTed Lemon <source@isc.org>
Mon, 1 May 2000 23:46:39 +0000 (23:46 +0000)
minires/res_update.c

index 17e4401e78815a857872b9fb2f29f3a764ce5689..4612d814d30b6f71eae4a6e66b7aadd12e274e31 100644 (file)
@@ -1,5 +1,5 @@
 #if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_update.c,v 1.5 2000/04/06 23:02:59 mellon Exp $";
+static const char rcsid[] = "$Id: res_update.c,v 1.6 2000/05/01 23:46:39 mellon Exp $";
 #endif /* not lint */
 
 /*
@@ -76,7 +76,6 @@ static int    nsprom(struct sockaddr_in *, const struct in_addr *, int);
 static void    dprintf(const char *, ...);
 
 void tkey_free (ns_tsig_key **);
-int find_tsig_key (ns_tsig_key **, const char *);
 
 ns_rcode
 res_nupdate(res_state statp, ns_updrec *rrecp_in) {
@@ -89,7 +88,10 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in) {
        struct sockaddr_in nsaddrs[MAXNS];
        ns_rcode rcode;
        ns_tsig_key *key;
+       void *zcookie = 0;
+       void *zcookp = &zcookie;
 
+      again:
        /* Make sure all the updates are in the same zone, and find out
           what zone they are in. */
        zptr = NULL;
@@ -101,7 +103,7 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in) {
                                        RES_EXHAUSTIVE,
                                        tgrp.z_origin,
                                        sizeof tgrp.z_origin,
-                                       tgrp.z_nsaddrs, MAXNS);
+                                       tgrp.z_nsaddrs, MAXNS, zcookp);
                if (tgrp.z_nscount <= 0) {
                        rcode = ns_r_notzone;
                        goto done;
@@ -149,7 +151,7 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in) {
 
        /* Send the update and remember the result. */
        key = (ns_tsig_key *)0;
-       if (!find_tsig_key (&key, zptr->z_origin)) {
+       if (!find_tsig_key (&key, zptr->z_origin, zcookie)) {
                rval = res_nsendsigned(statp, packet, n, key,
                                       answer, sizeof answer);
                tkey_free (&key);
@@ -161,6 +163,9 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in) {
                goto undone;
        }
        rcode = ((HEADER *)answer)->rcode;
+       if (zcookie && rcode == ns_r_badsig) {
+               repudiate_zone (&zcookie);
+       }
 
  undone:
        /* Restore resolver's nameserver set. */
@@ -173,6 +178,15 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in) {
                free(zptr);
        }
 
+       /* If the update failed because we used a cached zone and it
+          didn't work, try it again without the cached zone. */
+       if (zcookp && (rcode == ns_r_notzone || rcode == ns_r_badsig)) {
+               zcookp = 0;
+               goto again;
+       }
+
+       if (zcookie)
+               forget_zone (&zcookie);
        return rcode;
 }