Print this page
6141 use kmem_zalloc instead of kmem_alloc + bzero/memset


4503         if (!(ixa->ixa_flags & IXAF_IPSEC_GLOBAL_POLICY))
4504                 return (B_TRUE);
4505 
4506         return (ixa->ixa_ipsec_policy_gen == ipss->ipsec_system_policy.iph_gen);
4507 }
4508 
4509 void
4510 iplatch_free(ipsec_latch_t *ipl)
4511 {
4512         if (ipl->ipl_local_cid != NULL)
4513                 IPSID_REFRELE(ipl->ipl_local_cid);
4514         if (ipl->ipl_remote_cid != NULL)
4515                 IPSID_REFRELE(ipl->ipl_remote_cid);
4516         mutex_destroy(&ipl->ipl_lock);
4517         kmem_free(ipl, sizeof (*ipl));
4518 }
4519 
4520 ipsec_latch_t *
4521 iplatch_create()
4522 {
4523         ipsec_latch_t *ipl = kmem_alloc(sizeof (*ipl), KM_NOSLEEP);
4524         if (ipl == NULL)
4525                 return (ipl);
4526         bzero(ipl, sizeof (*ipl));
4527         mutex_init(&ipl->ipl_lock, NULL, MUTEX_DEFAULT, NULL);
4528         ipl->ipl_refcnt = 1;
4529         return (ipl);
4530 }
4531 
4532 /*
4533  * Hash function for ID hash table.
4534  */
4535 static uint32_t
4536 ipsid_hash(int idtype, char *idstring)
4537 {
4538         uint32_t hval = idtype;
4539         unsigned char c;
4540 
4541         while ((c = *idstring++) != 0) {
4542                 hval = (hval << 4) | (hval >> 28);
4543                 hval ^= c;
4544         }
4545         hval = hval ^ (hval >> 16);
4546         return (hval & (IPSID_HASHSIZE-1));




4503         if (!(ixa->ixa_flags & IXAF_IPSEC_GLOBAL_POLICY))
4504                 return (B_TRUE);
4505 
4506         return (ixa->ixa_ipsec_policy_gen == ipss->ipsec_system_policy.iph_gen);
4507 }
4508 
4509 void
4510 iplatch_free(ipsec_latch_t *ipl)
4511 {
4512         if (ipl->ipl_local_cid != NULL)
4513                 IPSID_REFRELE(ipl->ipl_local_cid);
4514         if (ipl->ipl_remote_cid != NULL)
4515                 IPSID_REFRELE(ipl->ipl_remote_cid);
4516         mutex_destroy(&ipl->ipl_lock);
4517         kmem_free(ipl, sizeof (*ipl));
4518 }
4519 
4520 ipsec_latch_t *
4521 iplatch_create()
4522 {
4523         ipsec_latch_t *ipl = kmem_zalloc(sizeof (*ipl), KM_NOSLEEP);
4524         if (ipl == NULL)
4525                 return (ipl);

4526         mutex_init(&ipl->ipl_lock, NULL, MUTEX_DEFAULT, NULL);
4527         ipl->ipl_refcnt = 1;
4528         return (ipl);
4529 }
4530 
4531 /*
4532  * Hash function for ID hash table.
4533  */
4534 static uint32_t
4535 ipsid_hash(int idtype, char *idstring)
4536 {
4537         uint32_t hval = idtype;
4538         unsigned char c;
4539 
4540         while ((c = *idstring++) != 0) {
4541                 hval = (hval << 4) | (hval >> 28);
4542                 hval ^= c;
4543         }
4544         hval = hval ^ (hval >> 16);
4545         return (hval & (IPSID_HASHSIZE-1));