~ubuntu-branches/debian/squeeze/ntp/squeeze-201010051545

« back to all changes in this revision

Viewing changes to ntpd/ntp_peer.c

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2009-01-05 21:10:03 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090105211003-mh6zc3um4k1uhsj7
Tags: 1:4.2.4p4+dfsg-8
It did not properly check the return value of EVP_VerifyFinal
which results in an malformed DSA signature being treated as
a good signature rather than as an error.  (CVE-2009-0021)

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
#include "ntpd.h"
12
12
#include "ntp_stdlib.h"
 
13
#include <ntp_random.h>
13
14
#ifdef OPENSSL
14
15
#include "openssl/rand.h"
15
16
#endif /* OPENSSL */
21
22
 *                             packet->mode
22
23
 * peer->mode      | UNSPEC  ACTIVE PASSIVE  CLIENT  SERVER  BCAST
23
24
 * ----------      | ---------------------------------------------
24
 
 * NO_PEER         |   e       1       e       1       1       1
 
25
 * NO_PEER         |   e       1       0       1       1       1
25
26
 * ACTIVE          |   e       1       1       0       0       0
26
27
 * PASSIVE         |   e       1       e       0       0       0
27
28
 * CLIENT          |   e       0       0       0       1       1
28
29
 * SERVER          |   e       0       0       0       0       0
29
30
 * BCAST           |   e       0       0       0       0       0
30
 
 * CONTROL         |   e       0       0       0       0       0
31
 
 * PRIVATE         |   e       0       0       0       0       0
32
31
 * BCLIENT         |   e       0       0       0       e       1
33
32
 *
34
33
 * One point to note here: a packet in BCAST mode can potentially match
38
37
 * circumvent that problem by requiring that the first b(m)roadcast
39
38
 * received after the change back to BCLIENT mode sets the clock.
40
39
 */
 
40
#define AM_MODES        7       /* number of rows and columns */
 
41
#define NO_PEER         0       /* action when no peer is found */
41
42
 
42
43
int AM[AM_MODES][AM_MODES] = {
43
44
/*      { UNSPEC,   ACTIVE,     PASSIVE,    CLIENT,     SERVER,     BCAST } */
44
45
 
45
 
/*NONE*/{ AM_ERR, AM_NEWPASS, AM_ERR,     AM_FXMIT,   AM_MANYCAST, AM_NEWBCL},
 
46
/*NONE*/{ AM_ERR, AM_NEWPASS, AM_NOMATCH, AM_FXMIT,   AM_MANYCAST, AM_NEWBCL},
46
47
 
47
48
/*A*/   { AM_ERR, AM_PROCPKT, AM_PROCPKT, AM_NOMATCH, AM_NOMATCH,  AM_NOMATCH},
48
49
 
54
55
 
55
56
/*BCST*/{ AM_ERR, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH,  AM_NOMATCH},
56
57
 
57
 
/*CNTL*/{ AM_ERR, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH,  AM_NOMATCH},
58
 
 
59
 
/*PRIV*/{ AM_ERR, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH,  AM_NOMATCH},
60
 
 
61
 
/*BCL*/ { AM_ERR, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_ERR,      AM_PROCPKT},
 
58
/*BCL*/ { AM_ERR, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH,  AM_PROCPKT},
62
59
};
63
60
 
64
61
#define MATCH_ASSOC(x,y)        AM[(x)][(y)]
102
99
u_long peer_allocations;                /* allocations from free list */
103
100
u_long peer_demobilizations;            /* structs freed to free list */
104
101
int total_peer_structs;                 /* peer structs */
105
 
int peer_associations;                  /* active associations */
 
102
int peer_associations;                  /* mobilized associations */
 
103
int peer_preempt;                       /* preemptable associations */
106
104
static struct peer init_peer_alloc[INIT_PEER_ALLOC]; /* init alloc */
107
105
 
108
 
static  void    getmorepeermem  P((void));
 
106
static void         getmorepeermem       P((void));
 
107
static struct interface *select_peerinterface P((struct peer *, struct sockaddr_storage *, struct interface *, u_char));
109
108
 
110
109
/*
111
110
 * init_peer - initialize peer data structures and counters
148
147
        /*
149
148
         * Initialize our first association ID
150
149
         */
151
 
        current_association_ID = (associd_t)ranp2(16);
152
 
        if (current_association_ID == 0)
153
 
            current_association_ID = 1;
 
150
        while ((current_association_ID = ntp_random() & 0xffff) == 0);
154
151
}
155
152
 
156
153
 
218
215
findpeer(
219
216
        struct sockaddr_storage *srcadr,
220
217
        struct interface *dstadr,
221
 
        int fd,
222
 
        int pkt_mode,
223
 
        int *action
 
218
        int     pkt_mode,
 
219
        int     *action
224
220
        )
225
221
{
226
222
        register struct peer *peer;
229
225
        findpeer_calls++;
230
226
        hash = NTP_HASH_ADDR(srcadr);
231
227
        for (peer = peer_hash[hash]; peer != NULL; peer = peer->next) {
232
 
                if (SOCKCMP(srcadr, &peer->srcadr)
233
 
                    && NSRCPORT(srcadr) == NSRCPORT(&peer->srcadr)) {
 
228
                if (SOCKCMP(srcadr, &peer->srcadr) &&
 
229
                    NSRCPORT(srcadr) == NSRCPORT(&peer->srcadr)) {
234
230
 
235
231
                        /*
236
232
                         * if the association matching rules determine
240
236
                        *action = MATCH_ASSOC(peer->hmode, pkt_mode);
241
237
 
242
238
                        /*
243
 
                         * Sigh!  Check if BCLIENT peer in client
244
 
                         * server mode, else return error.
245
 
                         */
246
 
                        if ((*action == AM_POSSBCL) && !(peer->flags &
247
 
                            FLAG_MCAST))
248
 
                                *action = AM_ERR;
249
 
 
250
 
                        /*
251
239
                         * if an error was returned, exit back right
252
240
                         * here.
253
241
                         */
269
257
                *action = MATCH_ASSOC(NO_PEER, pkt_mode);
270
258
                return ((struct peer *)0);
271
259
        }
272
 
        peer->dstadr = dstadr;
 
260
 
 
261
        set_peerdstadr(peer, dstadr);
 
262
 
273
263
        return (peer);
274
264
}
275
265
 
312
302
        for (n = 0; n < NTP_HASH_SIZE; n++) {
313
303
                for (peer = peer_hash[n]; peer != 0; peer = next_peer) {
314
304
                        next_peer = peer->next;
315
 
                        if (peer->flags & FLAG_CONFIG) {
316
 
                                if (!(peer->cast_flags & (MDF_ACAST |
317
 
                                     MDF_MCAST | MDF_BCAST)))
318
 
                                        peer_clear(peer, "STEP");
319
 
                        } else {
320
 
                                unpeer(peer);
 
305
                        if (!(peer->cast_flags & (MDF_ACAST | MDF_MCAST |
 
306
                            MDF_BCAST))) {
 
307
                                peer->hpoll = peer->minpoll;
 
308
                                peer_clear(peer, "STEP");
321
309
                        }
322
310
                }
323
311
        }
353
341
#endif /* OPENSSL */
354
342
#ifdef DEBUG
355
343
        if (debug)
356
 
                printf("demobilize %u %d\n", peer_to_remove->associd,
357
 
                    peer_associations);
 
344
                printf("demobilize %u %d %d\n", peer_to_remove->associd,
 
345
                    peer_associations, peer_preempt);
358
346
#endif
359
 
        peer_clear(peer_to_remove, "NULL");
 
347
        set_peerdstadr(peer_to_remove, NULL);
 
348
 
 
349
        /* XXXMEMLEAK? peer_clear->crypto allocation */
 
350
 
360
351
        hash = NTP_HASH_ADDR(&peer_to_remove->srcadr);
361
352
        peer_hash_count[hash]--;
362
353
        peer_demobilizations++;
 
354
        peer_associations--;
 
355
        if (peer_to_remove->flags & FLAG_PREEMPT)
 
356
                peer_preempt--;
363
357
#ifdef REFCLOCK
364
358
        /*
365
359
         * If this peer is actually a clock, shut it down first
412
406
        peer_to_remove->next = peer_free;
413
407
        peer_free = peer_to_remove;
414
408
        peer_free_count++;
415
 
        peer_associations--;
416
409
}
417
410
 
418
411
 
440
433
         * First search from the beginning for an association with given
441
434
         * remote address and mode. If an interface is given, search
442
435
         * from there to find the association which matches that
443
 
         * destination.
 
436
         * destination.  If the given interface is "any", track down
 
437
         * the actual interface, because that's what gets put into the
 
438
         * peer structure.
444
439
         */
445
440
        peer = findexistingpeer(srcadr, (struct peer *)0, hmode);
446
441
        if (dstadr != 0) {
447
442
                while (peer != 0) {
448
443
                        if (peer->dstadr == dstadr)
449
444
                                break;
 
445
                        if (dstadr == ANY_INTERFACE_CHOOSE(srcadr) &&
 
446
                            peer->dstadr == findinterface(srcadr))
 
447
                             break;
450
448
                        peer = findexistingpeer(srcadr, peer, hmode);
451
449
                }
452
450
        }
525
523
        return (peer);
526
524
}
527
525
 
 
526
/*
 
527
 * setup peer dstadr field keeping it in sync with the interface structures
 
528
 */
 
529
void
 
530
set_peerdstadr(struct peer *peer, struct interface *interface)
 
531
{
 
532
        if (peer->dstadr != interface) {
 
533
                if (interface != NULL &&
 
534
                    (peer->cast_flags & MDF_BCLNT) &&
 
535
                    (interface->flags & INT_MCASTIF) &&
 
536
                    peer->burst) {
 
537
                        /*
 
538
                         * don't accept updates to a true multicast reception
 
539
                         * interface while a BCLNT peer is running it's
 
540
                         * unicast protocol
 
541
                         */
 
542
                        return;
 
543
                }
 
544
 
 
545
                if (peer->dstadr != NULL)
 
546
                {
 
547
                        peer->dstadr->peercnt--;
 
548
                        ISC_LIST_UNLINK_TYPE(peer->dstadr->peers, peer, ilink, struct peer);
 
549
                }
 
550
 
 
551
                DPRINTF(4, ("set_peerdstadr(%s): change interface from %s to %s\n",
 
552
                            stoa(&peer->srcadr),
 
553
                            (peer->dstadr != NULL) ? stoa(&peer->dstadr->sin) : "<null>",
 
554
                            (interface != NULL) ? stoa(&interface->sin) : "<null>"));
 
555
 
 
556
                peer->dstadr = interface;
 
557
 
 
558
                if (peer->dstadr != NULL)
 
559
                {
 
560
                        ISC_LIST_APPEND(peer->dstadr->peers, peer, ilink);
 
561
                        peer->dstadr->peercnt++;
 
562
                }
 
563
        }
 
564
}
 
565
 
 
566
/*
 
567
 * attempt to re-rebind interface if necessary
 
568
 */
 
569
static void
 
570
peer_refresh_interface(struct peer *peer)
 
571
{
 
572
        struct interface *niface, *piface;
 
573
 
 
574
        niface = select_peerinterface(peer, &peer->srcadr, NULL, peer->cast_flags);
 
575
 
 
576
#ifdef DEBUG
 
577
        if (debug > 3)
 
578
        {
 
579
                printf(
 
580
                        "peer_refresh_interface: %s->%s mode %d vers %d poll %d %d flags 0x%x 0x%x ttl %d key %08x: new interface: ",
 
581
                        peer->dstadr == NULL ? "<null>" : stoa(&peer->dstadr->sin),
 
582
                        stoa(&peer->srcadr),
 
583
                        peer->hmode, peer->version, peer->minpoll,
 
584
                        peer->maxpoll, peer->flags, peer->cast_flags,
 
585
                        peer->ttl, peer->keyid);
 
586
                if (niface != NULL) 
 
587
                {
 
588
                        printf("fd=%d, bfd=%d, name=%.16s, flags=0x%x, scope=%d, ",
 
589
                               niface->fd,
 
590
                               niface->bfd,
 
591
                               niface->name,
 
592
                               niface->flags,
 
593
                               niface->scopeid);
 
594
                        /* Leave these as three printf calls. */
 
595
                        printf(", sin=%s",
 
596
                               stoa((&niface->sin)));
 
597
                        if (niface->flags & INT_BROADCAST)
 
598
                                printf(", bcast=%s,",
 
599
                                       stoa((&niface->bcast)));
 
600
                        printf(", mask=%s\n",
 
601
                               stoa((&niface->mask)));
 
602
                }
 
603
                else
 
604
                {
 
605
                        printf("<NONE>\n");
 
606
                }
 
607
        }
 
608
#endif
 
609
 
 
610
        piface = peer->dstadr;
 
611
 
 
612
        set_peerdstadr(peer, niface);
 
613
 
 
614
        if (peer->dstadr) {
 
615
                /*
 
616
                 * clear crypto if we change the local address
 
617
                 */
 
618
                if (peer->dstadr != piface && !(peer->cast_flags & MDF_BCLNT)) {
 
619
                        peer_crypto_clear(peer);
 
620
                }
 
621
 
 
622
                /*
 
623
                 * Broadcast needs the socket enabled for broadcast
 
624
                 */
 
625
                if (peer->cast_flags & MDF_BCAST) {
 
626
                        enable_broadcast(peer->dstadr, &peer->srcadr);
 
627
                }
 
628
 
 
629
                /*
 
630
                 * Multicast needs the socket interface enabled for multicast
 
631
                 */
 
632
                if (peer->cast_flags & MDF_MCAST) {
 
633
                        enable_multicast_if(peer->dstadr, &peer->srcadr);
 
634
                }
 
635
        }
 
636
}
 
637
 
 
638
/*
 
639
 * refresh_all_peerinterfaces - see that all interface bindings are up to date
 
640
 */
 
641
void
 
642
refresh_all_peerinterfaces(void)
 
643
{
 
644
        struct peer *peer, *next_peer;
 
645
        int n;
 
646
 
 
647
        /*
 
648
         * this is called when the interface list has changed
 
649
         * give all peers a chance to find a better interface
 
650
         */
 
651
        for (n = 0; n < NTP_HASH_SIZE; n++) {
 
652
                for (peer = peer_hash[n]; peer != 0; peer = next_peer) {
 
653
                        next_peer = peer->next;
 
654
                        peer_refresh_interface(peer);
 
655
                }
 
656
        }
 
657
}
 
658
 
 
659
        
 
660
/*
 
661
 * find an interface suitable for the src address
 
662
 */
 
663
static struct interface *
 
664
select_peerinterface(struct peer *peer, struct sockaddr_storage *srcadr, struct interface *dstadr, u_char cast_flags)
 
665
{
 
666
        struct interface *interface;
 
667
  
 
668
        /*
 
669
         * Initialize the peer structure and dance the interface jig.
 
670
         * Reference clocks step the loopback waltz, the others
 
671
         * squaredance around the interface list looking for a buddy. If
 
672
         * the dance peters out, there is always the wildcard interface.
 
673
         * This might happen in some systems and would preclude proper
 
674
         * operation with public key cryptography.
 
675
         */
 
676
        if (ISREFCLOCKADR(srcadr))
 
677
                interface = loopback_interface;
 
678
        else
 
679
                if (cast_flags & (MDF_BCLNT | MDF_ACAST | MDF_MCAST | MDF_BCAST)) {
 
680
                        interface = findbcastinter(srcadr);
 
681
#ifdef DEBUG
 
682
                        if (debug > 3) {
 
683
                                if (interface != NULL)
 
684
                                        printf("Found *-cast interface address %s, for address %s\n",
 
685
                                               stoa(&(interface)->sin), stoa(srcadr));
 
686
                                else
 
687
                                        printf("No *-cast local address found for address %s\n",
 
688
                                               stoa(srcadr));
 
689
                        }
 
690
#endif
 
691
                        /*
 
692
                         * If it was a multicast packet, findbcastinter() may not
 
693
                         * find it, so try a little harder.
 
694
                         */
 
695
                        if (interface == ANY_INTERFACE_CHOOSE(srcadr))
 
696
                                interface = findinterface(srcadr);
 
697
                }
 
698
                else if (dstadr != NULL && dstadr != ANY_INTERFACE_CHOOSE(srcadr))
 
699
                        interface = dstadr;
 
700
                else
 
701
                        interface = findinterface(srcadr);
 
702
 
 
703
        /*
 
704
         * we do not bind to the wildcard interfaces for output 
 
705
         * as our (network) source address would be undefined and
 
706
         * crypto will not work without knowing the own transmit address
 
707
         */
 
708
        if (interface != NULL && interface->flags & INT_WILDCARD)
 
709
                interface = NULL;
 
710
 
 
711
        return interface;
 
712
}
528
713
 
529
714
/*
530
715
 * newpeer - initialize a new peer association
559
744
        peer_free = peer->next;
560
745
        peer_free_count--;
561
746
        peer_associations++;
 
747
        if (flags & FLAG_PREEMPT)
 
748
                peer_preempt++;
562
749
        memset((char *)peer, 0, sizeof(struct peer));
563
750
 
564
751
        /*
568
755
        if (++current_association_ID == 0)
569
756
                ++current_association_ID;
570
757
 
 
758
        DPRINTF(3, ("newpeer: cast flags: 0x%x for address: %s\n",
 
759
                    cast_flags, stoa(srcadr)));
 
760
 
 
761
        ISC_LINK_INIT(peer, ilink);  /* set up interface link chain */
 
762
 
 
763
        dstadr = select_peerinterface(peer, srcadr, dstadr, cast_flags);
 
764
        
571
765
        /*
572
 
         * Initialize the peer structure and dance the interface jig.
573
 
         * Reference clocks step the loopback waltz, the others
574
 
         * squaredance around the interface list looking for a buddy. If
575
 
         * the dance peters out, there is always the wildcard interface.
576
 
         * This might happen in some systems and would preclude proper
577
 
         * operation with public key cryptography.
 
766
         * If we can't find an interface to use we return a NULL
 
767
         * unless the DYNAMIC flag is set - then we expect the dynamic
 
768
         * interface detection code to bind us some day to an interface
578
769
         */
579
 
        if (ISREFCLOCKADR(srcadr))
580
 
                peer->dstadr = loopback_interface;
581
 
        else if (cast_flags & (MDF_BCLNT | MDF_ACAST | MDF_MCAST | MDF_BCAST)) {
582
 
                peer->dstadr = findbcastinter(srcadr);
583
 
                /*
584
 
                 * If it was a multicast packet, findbcastinter() may not
585
 
                 * find it, so try a little harder.
586
 
                 */
587
 
                if (peer->dstadr == ANY_INTERFACE_CHOOSE(srcadr))
588
 
                        peer->dstadr = findinterface(srcadr);
589
 
        } else if (dstadr != NULL && dstadr != ANY_INTERFACE_CHOOSE(srcadr))
590
 
                peer->dstadr = dstadr;
591
 
        else
592
 
                peer->dstadr = findinterface(srcadr);
 
770
        if (dstadr == NULL && !(flags & FLAG_DYNAMIC))
 
771
        {
 
772
                msyslog(LOG_ERR, "Cannot find existing interface for address %s", stoa(srcadr));
 
773
 
 
774
                peer->next = peer_free;
 
775
                peer_free = peer;
 
776
                peer_associations--;
 
777
                peer_free_count++;
 
778
                
 
779
                return (NULL);
 
780
        }
 
781
        
593
782
        peer->srcadr = *srcadr;
594
783
        peer->hmode = (u_char)hmode;
595
784
        peer->version = (u_char)version;
596
785
        peer->minpoll = (u_char)max(NTP_MINPOLL, minpoll);
597
786
        peer->maxpoll = (u_char)min(NTP_MAXPOLL, maxpoll);
598
787
        peer->flags = flags;
 
788
 
 
789
        set_peerdstadr(peer, dstadr);
 
790
 
 
791
#ifdef DEBUG
 
792
        if (debug > 2) {
 
793
                if (peer->dstadr)
 
794
                        printf("newpeer: using fd %d and our addr %s\n",
 
795
                               peer->dstadr->fd, stoa(&peer->dstadr->sin));
 
796
                else
 
797
                        printf("newpeer: local interface currently not bound\n");
 
798
        }
 
799
#endif
 
800
        
 
801
        /*
 
802
         * Broadcast needs the socket enabled for broadcast
 
803
         */
 
804
        if (cast_flags & MDF_BCAST && peer->dstadr) {
 
805
                enable_broadcast(peer->dstadr, srcadr);
 
806
        }
 
807
        /*
 
808
         * Multicast needs the socket interface enabled for multicast
 
809
         */
 
810
        if (cast_flags & MDF_MCAST && peer->dstadr) {
 
811
                enable_multicast_if(peer->dstadr, srcadr);
 
812
        }
599
813
        if (key != 0)
600
814
                peer->flags |= FLAG_AUTHENABLE;
601
815
        if (key > NTP_MAXKEY)
604
818
        peer->ttl = (u_char)ttl;
605
819
        peer->keyid = key;
606
820
        peer->precision = sys_precision;
 
821
        peer->hpoll = peer->minpoll;
607
822
        if (cast_flags & MDF_ACAST)
608
823
                peer_clear(peer, "ACST");
609
824
        else if (cast_flags & MDF_MCAST)
621
836
        peer->timereset = current_time;
622
837
        peer->timereachable = current_time;
623
838
        peer->timereceived = current_time;
 
839
 
624
840
#ifdef REFCLOCK
625
841
        if (ISREFCLOCKADR(&peer->srcadr)) {
 
842
 
626
843
                /*
627
844
                 * We let the reference clock support do clock
628
845
                 * dependent initialization.  This includes setting
633
850
                        /*
634
851
                         * Dump it, something screwed up
635
852
                         */
 
853
                        set_peerdstadr(peer, NULL);
 
854
        
636
855
                        peer->next = peer_free;
637
856
                        peer_free = peer;
638
857
                        peer_free_count++;
652
871
        peer->ass_next = assoc_hash[i];
653
872
        assoc_hash[i] = peer;
654
873
        assoc_hash_count[i]++;
 
874
 
655
875
#ifdef OPENSSL
656
876
        if (peer->flags & FLAG_SKEY) {
657
877
                sprintf(statstr, "newpeer %d", peer->associd);
658
878
                record_crypto_stats(&peer->srcadr, statstr);
659
 
#ifdef DEBUG
660
 
                if (debug)
661
 
                        printf("peer: %s\n", statstr);
662
 
#endif
 
879
                DPRINTF(1, ("peer: %s\n", statstr));
663
880
        }
664
881
#endif /* OPENSSL */
665
 
#ifdef DEBUG
666
 
        if (debug)
667
 
                printf(
668
 
                    "newpeer: %s->%s mode %d vers %d poll %d %d flags 0x%x 0x%x ttl %d key %08x\n",
669
 
                    peer->dstadr == NULL ? "null" : stoa(&peer->dstadr->sin),
 
882
 
 
883
        DPRINTF(1, ("newpeer: %s->%s mode %d vers %d poll %d %d flags 0x%x 0x%x ttl %d key %08x\n",
 
884
                    peer->dstadr == NULL ? "<null>" : stoa(&peer->dstadr->sin),
670
885
                    stoa(&peer->srcadr),
671
886
                    peer->hmode, peer->version, peer->minpoll,
672
887
                    peer->maxpoll, peer->flags, peer->cast_flags,
673
 
                    peer->ttl, peer->keyid);
674
 
#endif
 
888
                    peer->ttl, peer->keyid));
 
889
 
675
890
        return (peer);
676
891
}
677
892
 
749
964
        peer->bogusorg = 0;
750
965
        peer->oldpkt = 0;
751
966
        peer->seldisptoolarge = 0;
752
 
        peer->selbroken = 0;
753
 
        peer->rank = 0;
754
967
        peer->timereset = current_time;
755
968
}
756
969
 
790
1003
         */
791
1004
        if (!crypto_flags)
792
1005
                return;
 
1006
 
793
1007
        for (n = 0; n < NTP_HASH_SIZE; n++) {
794
1008
                for (peer = peer_hash[n]; peer != 0; peer = next_peer) {
795
1009
                        next_peer = peer->next;
796
1010
                        if (!(peer->flags & FLAG_SKEY)) {
797
1011
                                continue;
798
 
                        } else if (peer->cast_flags & MDF_ACAST) {
799
 
                                peer_clear(peer, "ACST");
 
1012
 
800
1013
                        } else if (peer->hmode == MODE_ACTIVE ||
801
1014
                            peer->hmode == MODE_PASSIVE) {
802
1015
                                key_expire(peer);
808
1021
        }
809
1022
        RAND_bytes((u_char *)&sys_private, 4);
810
1023
        crypto_update();
811
 
        resetmanycast();
812
1024
}
813
1025
#endif /* OPENSSL */
814
1026
 
827
1039
        int i;
828
1040
 
829
1041
        /*
830
 
         * This routine is called upon arrival of a client-mode message
831
 
         * from a manycast server. Search the peer list for a manycast
 
1042
         * This routine is called upon arrival of a server-mode message
 
1043
         * from a manycast client. Search the peer list for a manycast
832
1044
         * client association where the last transmit timestamp matches
833
1045
         * the originate timestamp. This assumes the transmit timestamps
834
1046
         * for possibly more than one manycast association are unique.
849
1061
        }
850
1062
        return (NULL);
851
1063
}
852
 
 
853
 
 
854
 
/*
855
 
 * resetmanycast - reset all manycast clients
856
 
 */
857
 
void
858
 
resetmanycast(void)
859
 
{
860
 
        register struct peer *peer;
861
 
        int i;
862
 
 
863
 
        /*
864
 
         * This routine is called when the number of client associations
865
 
         * falls below the minimum. Search the peer list for manycast
866
 
         * client associations and reset the ttl and poll interval.
867
 
         */
868
 
        for (i = 0; i < NTP_HASH_SIZE; i++) {
869
 
                if (peer_hash_count[i] == 0)
870
 
                        continue;
871
 
 
872
 
                for (peer = peer_hash[i]; peer != 0; peer =
873
 
                    peer->next) {
874
 
                        if (peer->cast_flags & MDF_ACAST) {
875
 
                                peer_clear(peer, "ACST");
876
 
                        }
877
 
                }
878
 
        }
879
 
}