| 6762 | } |
| 6763 | |
| 6764 | static uint32_t |
| 6765 | key_newacq(const struct secasindex *saidx, int *perror) |
| 6766 | { |
| 6767 | struct secacq *acq; |
| 6768 | uint32_t seq; |
| 6769 | |
| 6770 | acq = malloc(sizeof(*acq), M_IPSEC_SAQ, M_NOWAIT | M_ZERO); |
| 6771 | if (acq == NULL) { |
| 6772 | ipseclog((LOG_DEBUG, "%s: No more memory.\n", __func__)); |
| 6773 | *perror = ENOBUFS; |
| 6774 | return (0); |
| 6775 | } |
| 6776 | |
| 6777 | /* copy secindex */ |
| 6778 | bcopy(saidx, &acq->saidx, sizeof(acq->saidx)); |
| 6779 | acq->created = time_second; |
| 6780 | acq->count = 0; |
| 6781 | |
| 6782 | /* add to acqtree */ |
| 6783 | ACQ_LOCK(); |
| 6784 | seq = acq->seq = (V_acq_seq == ~0 ? 1 : ++V_acq_seq); |
| 6785 | LIST_INSERT_HEAD(&V_acqtree, acq, chain); |
| 6786 | LIST_INSERT_HEAD(ACQADDRHASH_HASH(saidx), acq, addrhash); |
| 6787 | LIST_INSERT_HEAD(ACQSEQHASH_HASH(seq), acq, seqhash); |
| 6788 | ACQ_UNLOCK(); |
| 6789 | *perror = 0; |
| 6790 | return (seq); |
| 6791 | } |
| 6792 | |
| 6793 | static uint32_t |
| 6794 | key_getacq(const struct secasindex *saidx, int *perror) |