]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Merge bk://www.ntp.org/home/bk/ntp-dev
authorFrank Kardel <kardel@ntp.org>
Fri, 7 Oct 2005 19:29:33 +0000 (19:29 +0000)
committerFrank Kardel <kardel@ntp.org>
Fri, 7 Oct 2005 19:29:33 +0000 (19:29 +0000)
into  pogo.udel.edu:/pogo/users/kardel/dynamic-if/ntp-dev

bk: 4346cc9dx8_AeNA7S5zErK6_vhAW9w

1  2 
include/ntp.h
include/ntp_config.h
include/ntpd.h
ntpd/ntp_config.c
ntpd/ntp_control.c
ntpd/ntp_crypto.c
ntpd/ntp_peer.c
ntpd/ntp_proto.c

diff --cc include/ntp.h
Simple merge
Simple merge
diff --cc include/ntpd.h
Simple merge
Simple merge
Simple merge
index a51389fb50059b4a9cff69080b56b141bdda2fd9,211e3201dbba85b6a54d17ee7c1b6de8dd3eae47..5d714165e0ffc38a6fde23e0a5f671b8ae93f5e9
@@@ -261,12 -258,9 +261,12 @@@ make_keylist
        keyid_t keyid = 0;      /* next key ID */
        keyid_t cookie;         /* private value */
        u_long  lifetime;
-       u_int   len;
+       u_int   len, mpoll;
        int     i;
  
 +      if (!dstadr)
 +              return;
 +      
        /*
         * Allocate the key list if necessary.
         */
diff --cc ntpd/ntp_peer.c
index 4e5f7f22b643aa50b4034a991e47fecc4625328f,e24a645e805e91fdafb682ad3d776f81e714fc45..9229e1b9dc00d978f4d30bcbec4ee6508f5e3a69
@@@ -343,9 -341,6 +343,10 @@@ unpeer
                printf("demobilize %u %d %d\n", peer_to_remove->associd,
                    peer_associations, peer_preempt);
  #endif
-       peer_clear(peer_to_remove, "KILL");
 +      set_peerdstadr(peer_to_remove, NULL);
 +
++      /* XXXMEMLEAK? peer_clear->crypto allocation */
++
        hash = NTP_HASH_ADDR(&peer_to_remove->srcadr);
        peer_hash_count[hash]--;
        peer_demobilizations++;
index b848416b04cf991eb693185ae090c7bf21b3508c,51b1cd924650d15d562264a690fe1e10d9abb4b6..283cbb7ff7963b3e72cd2f9ec345ef1abfabbeb7
@@@ -1109,10 -1116,10 +1116,10 @@@ process_packet
        /*
         * Capture the header values.
         */
 -      record_raw_stats(&peer->srcadr, &peer->dstadr->sin, &p_org,
 +      record_raw_stats(&peer->srcadr, peer->dstadr ? &peer->dstadr->sin : NULL, &p_org,
            &p_rec, &p_xmt, &peer->rec);
        peer->leap = pleap;
-       peer->stratum = pstratum;
+       peer->stratum = min(pstratum, STRATUM_UNSPEC);
        peer->pmode = pmode;
        peer->ppoll = pkt->ppoll;
        peer->precision = pkt->precision;
@@@ -1554,13 -1533,17 +1575,15 @@@ peer_clear
         */
        peer->nextdate = peer->update = peer->outdate = current_time;
        if (initializing)
-               peer->nextdate = current_time + peer_associations;
+               peer->nextdate += peer_associations;
+       else if (peer->hmode == MODE_PASSIVE)
+               peer->nextdate += RESP_DELAY;
        else
-               peer->nextdate = current_time + (ntp_random() & ((1 <<
-                   NTP_MINPOLL) - 1));
+               peer->nextdate += (ntp_random() & ((1 << NTP_MINDPOLL) -
+                   1));
 -#ifdef DEBUG
 -      if (debug)
 -              printf("peer_clear: at %ld next %ld assoc ID %d refid %s\n",
 -                  current_time, peer->nextdate, peer->associd, ident);
 -#endif
 +
 +      DPRINTF(1, ("peer_clear: at %ld next %ld assoc ID %d refid %s\n",
 +                  current_time, peer->nextdate, peer->associd, ident));
  }
  
  
@@@ -2301,14 -2324,8 +2364,11 @@@ peer_xmit
         * If the crypto is broken, don't make it worse. Otherwise,
         * initialize the header fields.
         */
-       if (peer->flash & TEST9)
-               return;
 +      if (!peer->dstadr)      /* don't bother with peers without interface */
 +              return;
 +
        xpkt.li_vn_mode = PKT_LI_VN_MODE(sys_leap, peer->version,
 -          peer->hmode);
 +                                       peer->hmode);
        xpkt.stratum = STRATUM_TO_PKT(sys_stratum);
        xpkt.ppoll = peer->hpoll;
        xpkt.precision = sys_precision;
                case MODE_BROADCAST:
                        if (peer->flags & FLAG_ASSOC)
                                exten = crypto_args(peer, CRYPTO_AUTO |
 -                                  CRYPTO_RESP, NULL);
 +                                                  CRYPTO_RESP, NULL);
                        else
                                exten = crypto_args(peer, CRYPTO_ASSOC |
 -                                  CRYPTO_RESP, NULL);
 +                                                  CRYPTO_RESP, NULL);
                        break;
  
-                       /*
-                        * In symmetric modes the digest, certificate, agreement
-                        * parameters, cookie and autokey values are required.
-                        * The leapsecond table is optional. But, a passive peer
-                        * will not believe the active peer until the latter has
-                        * synchronized, so the agreement must be postponed
-                        * until then. In any case, if a new keylist is
-                        * generated, the autokey values are pushed.
-                        */
+               /*
+                * In symmetric modes the digest, certificate, agreement
+                * parameters, cookie and autokey values are required.
+                * The leapsecond table is optional. But, a passive peer
+                * will not believe the active peer until the latter has
+                * synchronized, so the agreement must be postponed
+                * until then. In any case, if a new keylist is
+                * generated, the autokey values are pushed.
+                *
+                * If the crypto bit is set, don't send requests.
+                */
                case MODE_ACTIVE:
                case MODE_PASSIVE:
+                       if (peer->flash & TEST9)
+                               break;
+                       /*
+                        * Parameter and certificate.
+                        */
                        if (!peer->crypto)
                                exten = crypto_args(peer, CRYPTO_ASSOC,
 -                                  sys_hostname);
 +                                                  sys_hostname);
                        else if (!(peer->crypto & CRYPTO_FLAG_VALID))
                                exten = crypto_args(peer, CRYPTO_CERT,
 -                                  peer->issuer);
 +                                                  peer->issuer);
  
                        /*
                         * Identity. Note we have to sign the
                         * server and client are synchronized.
                         */
                        else if (sys_leap != LEAP_NOTINSYNC &&
 -                          peer->leap != LEAP_NOTINSYNC &&
 -                          peer->crypto & CRYPTO_FLAG_TAI &&
 -                          !(peer->crypto & CRYPTO_FLAG_LEAP))
 +                               peer->leap != LEAP_NOTINSYNC &&
 +                               peer->crypto & CRYPTO_FLAG_TAI &&
 +                               !(peer->crypto & CRYPTO_FLAG_LEAP))
                                exten = crypto_args(peer, CRYPTO_TAI,
 -                                  NULL);
 +                                                  NULL);
                        break;
  
+               /*
+                * In client mode the digest, certificate, agreement
+                * parameters and cookie are required. The leapsecond
+                * table is optional. If broadcast client mode, the
+                * autokey values are required as well. In broadcast
+                * client mode, these values must be acquired during the
+                * client/server exchange to avoid having to wait until
+                * the next key list regeneration. Otherwise, the poor
+                * dude may die a lingering death until becoming
+                * unreachable and attempting rebirth.
+                *
+                * If neither the server or client have the agreement
+                * parameters, the protocol transmits the cookie in the
+                * clear. If the server has the parameters, the client
+                * requests them and the protocol blinds it using the
+                * agreed key. It is a protocol error if the client has
+                * the parameters but the server does not.
+                *
+                * If the crypto bit is lit, don't send requests.
+                */
+               case MODE_CLIENT:
+                       if (peer->flash & TEST9)
+                               break;
                        /*
-                        * In client mode the digest, certificate, agreement
-                        * parameters and cookie are required. The leapsecond
-                        * table is optional. If broadcast client mode, the
-                        * autokey values are required as well. In broadcast
-                        * client mode, these values must be acquired during the
-                        * client/server exchange to avoid having to wait until
-                        * the next key list regeneration. Otherwise, the poor
-                        * dude may die a lingering death until becoming
-                        * unreachable and attempting rebirth.
-                        *
-                        * If neither the server or client have the agreement
-                        * parameters, the protocol transmits the cookie in the
-                        * clear. If the server has the parameters, the client
-                        * requests them and the protocol blinds it using the
-                        * agreed key. It is a protocol error if the client has
-                        * the parameters but the server does not.
+                        * Parameter and certificate.
                         */
-               case MODE_CLIENT:
                        if (!peer->crypto)
                                exten = crypto_args(peer, CRYPTO_ASSOC,
 -                                  sys_hostname);
 +                                                  sys_hostname);
                        else if (!(peer->crypto & CRYPTO_FLAG_VALID))
                                exten = crypto_args(peer, CRYPTO_CERT,
 -                                  peer->issuer);
 +                                                  peer->issuer);
  
                        /*
                         * Identity
                        peer->cmmd = NULL;
                }
                if (exten != NULL) {
-                       if (exten->opcode != 0) {
+                       if (exten->opcode != 0)
                                sendlen += crypto_xmit(&xpkt,
 -                                  &peer->srcadr, sendlen, exten, 0);
 +                                                     &peer->srcadr, sendlen, exten, 0);
-                               free(exten);
-                       } else {
-                               peer_clear(peer, "CRYP");
+                       if (ntohl(exten->opcode) & CRYPTO_ERROR) {
                                peer->flash |= TEST9; /* crypto error */
-                               msyslog(LOG_INFO,
-                                       "transmit: crypto error for %s",
-                                       stoa(&peer->srcadr));
                                free(exten);
                                return;
                        }