+ dup_sockaddr((struct sockaddr *)unp2->unp_addr, 1);
+
+ /*
+ * unp_peercred management:
+ *
+ * The connecter's (client's) credentials are copied
+ * from its process structure at the time of connect()
+ * (which is now).
+ */
+ cru2x(vfs_context_ucred(ctx), &unp3->unp_peercred);
+ unp3->unp_flags |= UNP_HAVEPC;
+ /*
+ * The receiver's (server's) credentials are copied
+ * from the unp_peercred member of socket on which the
+ * former called listen(); unp_listen() cached that
+ * process's credentials at that time so we can use
+ * them now.
+ */
+ KASSERT(unp2->unp_flags & UNP_HAVEPCCACHED,
+ ("unp_connect: listener without cached peercred"));
+ memcpy(&unp->unp_peercred, &unp2->unp_peercred,
+ sizeof (unp->unp_peercred));
+ unp->unp_flags |= UNP_HAVEPC;
+
+#if CONFIG_MACF_SOCKET
+ /* XXXMAC: recursive lock: SOCK_LOCK(so); */
+ mac_socketpeer_label_associate_socket(so, so3);
+ mac_socketpeer_label_associate_socket(so3, so);
+ /* XXXMAC: SOCK_UNLOCK(so); */
+#endif /* MAC_SOCKET */
+ so2->so_usecount--; /* drop reference taken on so2 */