Skip to content

Commit

Permalink
[SCTP]: Update AUTH structures to match declarations in draft-16.
Browse files Browse the repository at this point in the history
The new SCTP socket api (draft 16) updates the AUTH API structures.
We never exported these since we knew they would change.
Update the rest to match the draft.

Signed-off-by: Vlad Yasevich <[email protected]>
  • Loading branch information
Vlad Yasevich committed Feb 28, 2008
1 parent b40db68 commit 7e8616d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
10 changes: 6 additions & 4 deletions include/net/sctp/user.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ struct sctp_event_subscribe {
__u8 sctp_shutdown_event;
__u8 sctp_partial_delivery_event;
__u8 sctp_adaptation_layer_event;
__u8 sctp_authentication_event;
};

/*
Expand Down Expand Up @@ -587,7 +588,7 @@ struct sctp_authchunk {
* endpoint requires the peer to use.
*/
struct sctp_hmacalgo {
__u16 shmac_num_idents;
__u32 shmac_num_idents;
__u16 shmac_idents[];
};

Expand All @@ -600,7 +601,7 @@ struct sctp_hmacalgo {
struct sctp_authkey {
sctp_assoc_t sca_assoc_id;
__u16 sca_keynumber;
__u16 sca_keylen;
__u16 sca_keylength;
__u8 sca_key[];
};

Expand Down Expand Up @@ -693,8 +694,9 @@ struct sctp_status {
* the peer requires to be received authenticated only.
*/
struct sctp_authchunks {
sctp_assoc_t gauth_assoc_id;
uint8_t gauth_chunks[];
sctp_assoc_t gauth_assoc_id;
__u32 gauth_number_of_chunks;
uint8_t gauth_chunks[];
};

/*
Expand Down
4 changes: 2 additions & 2 deletions net/sctp/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,11 +838,11 @@ int sctp_auth_set_key(struct sctp_endpoint *ep,
}

/* Create a new key data based on the info passed in */
key = sctp_auth_create_key(auth_key->sca_keylen, GFP_KERNEL);
key = sctp_auth_create_key(auth_key->sca_keylength, GFP_KERNEL);
if (!key)
goto nomem;

memcpy(key->data, &auth_key->sca_key[0], auth_key->sca_keylen);
memcpy(key->data, &auth_key->sca_key[0], auth_key->sca_keylength);

/* If we are replacing, remove the old keys data from the
* key id. If we are adding new key id, add it to the
Expand Down
6 changes: 5 additions & 1 deletion net/sctp/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,7 @@ static int sctp_setsockopt_disable_fragments(struct sock *sk,
static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
int optlen)
{
if (optlen != sizeof(struct sctp_event_subscribe))
if (optlen > sizeof(struct sctp_event_subscribe))
return -EINVAL;
if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
return -EFAULT;
Expand Down Expand Up @@ -5094,6 +5094,8 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len,
len = num_chunks;
if (put_user(len, optlen))
return -EFAULT;
if (put_user(num_chunks, &p->gauth_number_of_chunks))
return -EFAULT;
if (copy_to_user(to, ch->chunks, len))
return -EFAULT;

Expand Down Expand Up @@ -5133,6 +5135,8 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len,
len = num_chunks;
if (put_user(len, optlen))
return -EFAULT;
if (put_user(num_chunks, &p->gauth_number_of_chunks))
return -EFAULT;
if (copy_to_user(to, ch->chunks, len))
return -EFAULT;

Expand Down

0 comments on commit 7e8616d

Please sign in to comment.