551 }
552
553 /* Now I'm free. */
554 kmem_free(ptr, size);
555 return (0);
556 }
557 /*
558 * Open routine for keysock.
559 */
560 /* ARGSUSED */
561 static int
562 keysock_open(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp)
563 {
564 keysock_t *ks;
565 keysock_consumer_t *kc;
566 mblk_t *mp;
567 ipsec_info_t *ii;
568 netstack_t *ns;
569 keysock_stack_t *keystack;
570
571 if (secpolicy_ip_config(credp, B_FALSE) != 0) {
572 /* Privilege debugging will log the error */
573 return (EPERM);
574 }
575
576 if (q->q_ptr != NULL)
577 return (0); /* Re-open of an already open instance. */
578
579 ns = netstack_find_by_cred(credp);
580 ASSERT(ns != NULL);
581 keystack = ns->netstack_keysock;
582 ASSERT(keystack != NULL);
583
584 ks3dbg(keystack, ("Entering keysock open.\n"));
585
586 if (keystack->keystack_plumbed < 1) {
587 netstack_t *ns = keystack->keystack_netstack;
588
589 keystack->keystack_plumbed = 0;
590 #ifdef NS_DEBUG
|
551 }
552
553 /* Now I'm free. */
554 kmem_free(ptr, size);
555 return (0);
556 }
557 /*
558 * Open routine for keysock.
559 */
560 /* ARGSUSED */
561 static int
562 keysock_open(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp)
563 {
564 keysock_t *ks;
565 keysock_consumer_t *kc;
566 mblk_t *mp;
567 ipsec_info_t *ii;
568 netstack_t *ns;
569 keysock_stack_t *keystack;
570
571 #ifdef KEBE
572 /*
573 * Some test ASSERT()s that only work with the new dtrace-style assert.
574 */
575 ASSERT(q == NULL); /* Will likely fail. (575) */
576 ASSERT3P(q, ==, NULL); /* Same here. (576) */
577 #endif
578
579 if (secpolicy_ip_config(credp, B_FALSE) != 0) {
580 /* Privilege debugging will log the error */
581 return (EPERM);
582 }
583
584 if (q->q_ptr != NULL)
585 return (0); /* Re-open of an already open instance. */
586
587 ns = netstack_find_by_cred(credp);
588 ASSERT(ns != NULL);
589 keystack = ns->netstack_keysock;
590 ASSERT(keystack != NULL);
591
592 ks3dbg(keystack, ("Entering keysock open.\n"));
593
594 if (keystack->keystack_plumbed < 1) {
595 netstack_t *ns = keystack->keystack_netstack;
596
597 keystack->keystack_plumbed = 0;
598 #ifdef NS_DEBUG
|