diff --git a/usrsctplib/netinet/sctp_auth.c b/usrsctplib/netinet/sctp_auth.c index a7a73157b..852512d74 100755 --- a/usrsctplib/netinet/sctp_auth.c +++ b/usrsctplib/netinet/sctp_auth.c @@ -575,7 +575,7 @@ sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id, int so_locked) if ((skey->refcount <= 2) && (skey->deactivated)) { /* notify ULP that key is no longer used */ sctp_ulp_notify(SCTP_NOTIFY_AUTH_FREE_KEY, stcb, - key_id, 0, so_locked); + 0, &key_id, so_locked); SCTPDBG(SCTP_DEBUG_AUTH2, "%s: stcb %p key %u no longer used, %d\n", __func__, (void *)stcb, key_id, skey->refcount); @@ -1334,8 +1334,8 @@ sctp_deact_sharedkey(struct sctp_tcb *stcb, uint16_t keyid) /* are there other refcount holders on the key? */ if (skey->refcount == 1) { /* no other users, send a notification for this key */ - sctp_ulp_notify(SCTP_NOTIFY_AUTH_FREE_KEY, stcb, keyid, 0, - SCTP_SO_LOCKED); + sctp_ulp_notify(SCTP_NOTIFY_AUTH_FREE_KEY, stcb, 0, &keyid, + SCTP_SO_LOCKED); } /* mark the key as deactivated */ @@ -1679,15 +1679,10 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth, return (-1); } /* generate a notification if this is a new key id */ - if (stcb->asoc.authinfo.recv_keyid != shared_key_id) - /* - * sctp_ulp_notify(SCTP_NOTIFY_AUTH_NEW_KEY, stcb, - * shared_key_id, (void - * *)stcb->asoc.authinfo.recv_keyid); - */ - sctp_notify_authentication(stcb, SCTP_AUTH_NEW_KEY, - shared_key_id, stcb->asoc.authinfo.recv_keyid, - SCTP_SO_NOT_LOCKED); + if (stcb->asoc.authinfo.recv_keyid != shared_key_id) { + sctp_ulp_notify(SCTP_NOTIFY_AUTH_NEW_KEY, stcb, 0, + &shared_key_id, SCTP_SO_NOT_LOCKED); + } /* compute a new recv assoc key and cache it */ if (stcb->asoc.authinfo.recv_key != NULL) sctp_free_key(stcb->asoc.authinfo.recv_key); @@ -1730,7 +1725,7 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth, */ void sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication, - uint16_t keyid, uint16_t alt_keyid, int so_locked) + uint16_t keyid, int so_locked) { struct mbuf *m_notify; struct sctp_authkey_event *auth; @@ -1739,8 +1734,7 @@ sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication, if ((stcb == NULL) || (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) || (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) || - (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET) - ) { + (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET)) { /* If the socket is gone we are out of here */ return; } @@ -1750,7 +1744,7 @@ sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication, return; m_notify = sctp_get_mbuf_for_msg(sizeof(struct sctp_authkey_event), - 0, M_NOWAIT, 1, MT_HEADER); + 0, M_NOWAIT, 1, MT_HEADER); if (m_notify == NULL) /* no space left */ return; @@ -1762,7 +1756,12 @@ sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication, auth->auth_flags = 0; auth->auth_length = sizeof(*auth); auth->auth_keynumber = keyid; - auth->auth_altkeynumber = alt_keyid; + /* XXXMT: The following is BSD specific. */ + if (indication == SCTP_AUTH_NEW_KEY) { + auth->auth_altkeynumber = stcb->asoc.authinfo.recv_keyid; + } else { + auth->auth_altkeynumber = 0; + } auth->auth_indication = indication; auth->auth_assoc_id = sctp_get_associd(stcb); @@ -1782,7 +1781,8 @@ sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication, /* not that we need this */ control->tail_mbuf = m_notify; sctp_add_to_readq(stcb->sctp_ep, stcb, control, - &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, so_locked); + &stcb->sctp_socket->so_rcv, 1, + SCTP_READ_LOCK_NOT_HELD, so_locked); } /*- diff --git a/usrsctplib/netinet/sctp_auth.h b/usrsctplib/netinet/sctp_auth.h index e7cac3468..00682ae78 100755 --- a/usrsctplib/netinet/sctp_auth.h +++ b/usrsctplib/netinet/sctp_auth.h @@ -194,7 +194,7 @@ extern struct mbuf *sctp_add_auth_chunk(struct mbuf *m, struct mbuf **m_end, extern int sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *ch, struct mbuf *m, uint32_t offset); extern void sctp_notify_authentication(struct sctp_tcb *stcb, - uint32_t indication, uint16_t keyid, uint16_t alt_keyid, int so_locked); + uint32_t indication, uint16_t keyid, int so_locked); extern int sctp_validate_init_auth_params(struct mbuf *m, int offset, int limit); extern void sctp_initialize_auth_params(struct sctp_inpcb *inp, diff --git a/usrsctplib/netinet/sctputil.c b/usrsctplib/netinet/sctputil.c index 2c5c2280d..73e38f080 100755 --- a/usrsctplib/netinet/sctputil.c +++ b/usrsctplib/netinet/sctputil.c @@ -4396,19 +4396,16 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, sctp_notify_shutdown_event(stcb); break; case SCTP_NOTIFY_AUTH_NEW_KEY: - sctp_notify_authentication(stcb, SCTP_AUTH_NEW_KEY, error, - (uint16_t)(uintptr_t)data, - so_locked); + sctp_notify_authentication(stcb, SCTP_AUTH_NEW_KEY, + *(uint16_t *)data, so_locked); break; case SCTP_NOTIFY_AUTH_FREE_KEY: - sctp_notify_authentication(stcb, SCTP_AUTH_FREE_KEY, error, - (uint16_t)(uintptr_t)data, - so_locked); + sctp_notify_authentication(stcb, SCTP_AUTH_FREE_KEY, + *(uint16_t *)data, so_locked); break; case SCTP_NOTIFY_NO_PEER_AUTH: - sctp_notify_authentication(stcb, SCTP_AUTH_NO_AUTH, error, - (uint16_t)(uintptr_t)data, - so_locked); + sctp_notify_authentication(stcb, SCTP_AUTH_NO_AUTH, + 0, so_locked); break; case SCTP_NOTIFY_SENDER_DRY: sctp_notify_sender_dry_event(stcb, so_locked);