Commit 5477f7f3 authored by David S. Miller's avatar David S. Miller

Merge branch 'sctp-remove-typedefs-from-structures-part-4'

Xin Long says:

====================
sctp: remove typedefs from structures part 4

As we know, typedef is suggested not to use in kernel, even checkpatch.pl
also gives warnings about it. Now sctp is using it for many structures.

All this kind of typedef's using should be removed. This patchset is the
part 4 to remove it for another 14 basic structures from linux/sctp.h.
After this patchset, all typedefs are cleaned in linux/sctp.h.

Just as the part 1-3, No any code's logic would be changed in these patches,
only cleaning up.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents ddb08042 bb96dec7
...@@ -416,27 +416,27 @@ struct sctp_abort_chunk { ...@@ -416,27 +416,27 @@ struct sctp_abort_chunk {
/* For the graceful shutdown we must carry the tag (in common header) /* For the graceful shutdown we must carry the tag (in common header)
* and the highest consecutive acking value. * and the highest consecutive acking value.
*/ */
typedef struct sctp_shutdownhdr { struct sctp_shutdownhdr {
__be32 cum_tsn_ack; __be32 cum_tsn_ack;
} sctp_shutdownhdr_t; };
struct sctp_shutdown_chunk_t { struct sctp_shutdown_chunk {
struct sctp_chunkhdr chunk_hdr; struct sctp_chunkhdr chunk_hdr;
sctp_shutdownhdr_t shutdown_hdr; struct sctp_shutdownhdr shutdown_hdr;
}; };
/* RFC 2960. Section 3.3.10 Operation Error (ERROR) (9) */ /* RFC 2960. Section 3.3.10 Operation Error (ERROR) (9) */
typedef struct sctp_errhdr { struct sctp_errhdr {
__be16 cause; __be16 cause;
__be16 length; __be16 length;
__u8 variable[0]; __u8 variable[0];
} sctp_errhdr_t; };
typedef struct sctp_operr_chunk { struct sctp_operr_chunk {
struct sctp_chunkhdr chunk_hdr; struct sctp_chunkhdr chunk_hdr;
sctp_errhdr_t err_hdr; struct sctp_errhdr err_hdr;
} sctp_operr_chunk_t; };
/* RFC 2960 3.3.10 - Operation Error /* RFC 2960 3.3.10 - Operation Error
* *
...@@ -457,7 +457,7 @@ typedef struct sctp_operr_chunk { ...@@ -457,7 +457,7 @@ typedef struct sctp_operr_chunk {
* 9 No User Data * 9 No User Data
* 10 Cookie Received While Shutting Down * 10 Cookie Received While Shutting Down
*/ */
typedef enum { enum sctp_error {
SCTP_ERROR_NO_ERROR = cpu_to_be16(0x00), SCTP_ERROR_NO_ERROR = cpu_to_be16(0x00),
SCTP_ERROR_INV_STRM = cpu_to_be16(0x01), SCTP_ERROR_INV_STRM = cpu_to_be16(0x01),
...@@ -512,33 +512,28 @@ typedef enum { ...@@ -512,33 +512,28 @@ typedef enum {
* 0x0105 Unsupported HMAC Identifier * 0x0105 Unsupported HMAC Identifier
*/ */
SCTP_ERROR_UNSUP_HMAC = cpu_to_be16(0x0105) SCTP_ERROR_UNSUP_HMAC = cpu_to_be16(0x0105)
} sctp_error_t; };
/* RFC 2960. Appendix A. Explicit Congestion Notification. /* RFC 2960. Appendix A. Explicit Congestion Notification.
* Explicit Congestion Notification Echo (ECNE) (12) * Explicit Congestion Notification Echo (ECNE) (12)
*/ */
typedef struct sctp_ecnehdr { struct sctp_ecnehdr {
__be32 lowest_tsn; __be32 lowest_tsn;
} sctp_ecnehdr_t; };
typedef struct sctp_ecne_chunk { struct sctp_ecne_chunk {
struct sctp_chunkhdr chunk_hdr; struct sctp_chunkhdr chunk_hdr;
sctp_ecnehdr_t ence_hdr; struct sctp_ecnehdr ence_hdr;
} sctp_ecne_chunk_t; };
/* RFC 2960. Appendix A. Explicit Congestion Notification. /* RFC 2960. Appendix A. Explicit Congestion Notification.
* Congestion Window Reduced (CWR) (13) * Congestion Window Reduced (CWR) (13)
*/ */
typedef struct sctp_cwrhdr { struct sctp_cwrhdr {
__be32 lowest_tsn; __be32 lowest_tsn;
} sctp_cwrhdr_t; };
typedef struct sctp_cwr_chunk {
struct sctp_chunkhdr chunk_hdr;
sctp_cwrhdr_t cwr_hdr;
} sctp_cwr_chunk_t;
/* PR-SCTP /* PR-SCTP
* 3.2 Forward Cumulative TSN Chunk Definition (FORWARD TSN) * 3.2 Forward Cumulative TSN Chunk Definition (FORWARD TSN)
...@@ -634,20 +629,20 @@ struct sctp_fwdtsn_chunk { ...@@ -634,20 +629,20 @@ struct sctp_fwdtsn_chunk {
* The ASCONF Parameter Response is used in the ASCONF-ACK to * The ASCONF Parameter Response is used in the ASCONF-ACK to
* report status of ASCONF processing. * report status of ASCONF processing.
*/ */
typedef struct sctp_addip_param { struct sctp_addip_param {
struct sctp_paramhdr param_hdr; struct sctp_paramhdr param_hdr;
__be32 crr_id; __be32 crr_id;
} sctp_addip_param_t; };
typedef struct sctp_addiphdr { struct sctp_addiphdr {
__be32 serial; __be32 serial;
__u8 params[0]; __u8 params[0];
} sctp_addiphdr_t; };
typedef struct sctp_addip_chunk { struct sctp_addip_chunk {
struct sctp_chunkhdr chunk_hdr; struct sctp_chunkhdr chunk_hdr;
sctp_addiphdr_t addip_hdr; struct sctp_addiphdr addip_hdr;
} sctp_addip_chunk_t; };
/* AUTH /* AUTH
* Section 4.1 Authentication Chunk (AUTH) * Section 4.1 Authentication Chunk (AUTH)
...@@ -698,16 +693,16 @@ typedef struct sctp_addip_chunk { ...@@ -698,16 +693,16 @@ typedef struct sctp_addip_chunk {
* HMAC: n bytes (unsigned integer) This hold the result of the HMAC * HMAC: n bytes (unsigned integer) This hold the result of the HMAC
* calculation. * calculation.
*/ */
typedef struct sctp_authhdr { struct sctp_authhdr {
__be16 shkey_id; __be16 shkey_id;
__be16 hmac_id; __be16 hmac_id;
__u8 hmac[0]; __u8 hmac[0];
} sctp_authhdr_t; };
typedef struct sctp_auth_chunk { struct sctp_auth_chunk {
struct sctp_chunkhdr chunk_hdr; struct sctp_chunkhdr chunk_hdr;
sctp_authhdr_t auth_hdr; struct sctp_authhdr auth_hdr;
} sctp_auth_chunk_t; };
struct sctp_infox { struct sctp_infox {
struct sctp_info *sctpinfo; struct sctp_info *sctpinfo;
......
...@@ -479,13 +479,13 @@ for (pos.v = chunk->member;\ ...@@ -479,13 +479,13 @@ for (pos.v = chunk->member;\
_sctp_walk_errors((err), (chunk_hdr), ntohs((chunk_hdr)->length)) _sctp_walk_errors((err), (chunk_hdr), ntohs((chunk_hdr)->length))
#define _sctp_walk_errors(err, chunk_hdr, end)\ #define _sctp_walk_errors(err, chunk_hdr, end)\
for (err = (sctp_errhdr_t *)((void *)chunk_hdr + \ for (err = (struct sctp_errhdr *)((void *)chunk_hdr + \
sizeof(struct sctp_chunkhdr));\ sizeof(struct sctp_chunkhdr));\
((void *)err + offsetof(sctp_errhdr_t, length) + sizeof(err->length) <=\ ((void *)err + offsetof(struct sctp_errhdr, length) + sizeof(err->length) <=\
(void *)chunk_hdr + end) &&\ (void *)chunk_hdr + end) &&\
(void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\ (void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\
ntohs(err->length) >= sizeof(sctp_errhdr_t); \ ntohs(err->length) >= sizeof(struct sctp_errhdr); \
err = (sctp_errhdr_t *)((void *)err + SCTP_PAD4(ntohs(err->length)))) err = (struct sctp_errhdr *)((void *)err + SCTP_PAD4(ntohs(err->length))))
#define sctp_walk_fwdtsn(pos, chunk)\ #define sctp_walk_fwdtsn(pos, chunk)\
_sctp_walk_fwdtsn((pos), (chunk), ntohs((chunk)->chunk_hdr->length) - sizeof(struct sctp_fwdtsn_chunk)) _sctp_walk_fwdtsn((pos), (chunk), ntohs((chunk)->chunk_hdr->length) - sizeof(struct sctp_fwdtsn_chunk))
......
...@@ -201,7 +201,7 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc, ...@@ -201,7 +201,7 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
struct sctp_hmac *hmac_desc = sctp_auth_asoc_get_hmac(asoc); struct sctp_hmac *hmac_desc = sctp_auth_asoc_get_hmac(asoc);
if (hmac_desc) if (hmac_desc)
max_data -= SCTP_PAD4(sizeof(sctp_auth_chunk_t) + max_data -= SCTP_PAD4(sizeof(struct sctp_auth_chunk) +
hmac_desc->hmac_len); hmac_desc->hmac_len);
} }
......
...@@ -1111,7 +1111,7 @@ static struct sctp_association *__sctp_rcv_asconf_lookup( ...@@ -1111,7 +1111,7 @@ static struct sctp_association *__sctp_rcv_asconf_lookup(
__be16 peer_port, __be16 peer_port,
struct sctp_transport **transportp) struct sctp_transport **transportp)
{ {
sctp_addip_chunk_t *asconf = (struct sctp_addip_chunk *)ch; struct sctp_addip_chunk *asconf = (struct sctp_addip_chunk *)ch;
struct sctp_af *af; struct sctp_af *af;
union sctp_addr_param *param; union sctp_addr_param *param;
union sctp_addr paddr; union sctp_addr paddr;
......
...@@ -135,14 +135,14 @@ static const struct sctp_paramhdr prsctp_param = { ...@@ -135,14 +135,14 @@ static const struct sctp_paramhdr prsctp_param = {
void sctp_init_cause(struct sctp_chunk *chunk, __be16 cause_code, void sctp_init_cause(struct sctp_chunk *chunk, __be16 cause_code,
size_t paylen) size_t paylen)
{ {
sctp_errhdr_t err; struct sctp_errhdr err;
__u16 len; __u16 len;
/* Cause code constants are now defined in network order. */ /* Cause code constants are now defined in network order. */
err.cause = cause_code; err.cause = cause_code;
len = sizeof(sctp_errhdr_t) + paylen; len = sizeof(err) + paylen;
err.length = htons(len); err.length = htons(len);
chunk->subh.err_hdr = sctp_addto_chunk(chunk, sizeof(sctp_errhdr_t), &err); chunk->subh.err_hdr = sctp_addto_chunk(chunk, sizeof(err), &err);
} }
/* A helper to initialize an op error inside a /* A helper to initialize an op error inside a
...@@ -153,19 +153,19 @@ void sctp_init_cause(struct sctp_chunk *chunk, __be16 cause_code, ...@@ -153,19 +153,19 @@ void sctp_init_cause(struct sctp_chunk *chunk, __be16 cause_code,
static int sctp_init_cause_fixed(struct sctp_chunk *chunk, __be16 cause_code, static int sctp_init_cause_fixed(struct sctp_chunk *chunk, __be16 cause_code,
size_t paylen) size_t paylen)
{ {
sctp_errhdr_t err; struct sctp_errhdr err;
__u16 len; __u16 len;
/* Cause code constants are now defined in network order. */ /* Cause code constants are now defined in network order. */
err.cause = cause_code; err.cause = cause_code;
len = sizeof(sctp_errhdr_t) + paylen; len = sizeof(err) + paylen;
err.length = htons(len); err.length = htons(len);
if (skb_tailroom(chunk->skb) < len) if (skb_tailroom(chunk->skb) < len)
return -ENOSPC; return -ENOSPC;
chunk->subh.err_hdr = sctp_addto_chunk_fixed(chunk,
sizeof(sctp_errhdr_t), chunk->subh.err_hdr = sctp_addto_chunk_fixed(chunk, sizeof(err), &err);
&err);
return 0; return 0;
} }
/* 3.3.2 Initiation (INIT) (1) /* 3.3.2 Initiation (INIT) (1)
...@@ -663,11 +663,11 @@ struct sctp_chunk *sctp_make_cwr(const struct sctp_association *asoc, ...@@ -663,11 +663,11 @@ struct sctp_chunk *sctp_make_cwr(const struct sctp_association *asoc,
const struct sctp_chunk *chunk) const struct sctp_chunk *chunk)
{ {
struct sctp_chunk *retval; struct sctp_chunk *retval;
sctp_cwrhdr_t cwr; struct sctp_cwrhdr cwr;
cwr.lowest_tsn = htonl(lowest_tsn); cwr.lowest_tsn = htonl(lowest_tsn);
retval = sctp_make_control(asoc, SCTP_CID_ECN_CWR, 0, retval = sctp_make_control(asoc, SCTP_CID_ECN_CWR, 0,
sizeof(sctp_cwrhdr_t), GFP_ATOMIC); sizeof(cwr), GFP_ATOMIC);
if (!retval) if (!retval)
goto nodata; goto nodata;
...@@ -697,11 +697,11 @@ struct sctp_chunk *sctp_make_ecne(const struct sctp_association *asoc, ...@@ -697,11 +697,11 @@ struct sctp_chunk *sctp_make_ecne(const struct sctp_association *asoc,
const __u32 lowest_tsn) const __u32 lowest_tsn)
{ {
struct sctp_chunk *retval; struct sctp_chunk *retval;
sctp_ecnehdr_t ecne; struct sctp_ecnehdr ecne;
ecne.lowest_tsn = htonl(lowest_tsn); ecne.lowest_tsn = htonl(lowest_tsn);
retval = sctp_make_control(asoc, SCTP_CID_ECN_ECNE, 0, retval = sctp_make_control(asoc, SCTP_CID_ECN_ECNE, 0,
sizeof(sctp_ecnehdr_t), GFP_ATOMIC); sizeof(ecne), GFP_ATOMIC);
if (!retval) if (!retval)
goto nodata; goto nodata;
retval->subh.ecne_hdr = retval->subh.ecne_hdr =
...@@ -857,15 +857,15 @@ struct sctp_chunk *sctp_make_sack(const struct sctp_association *asoc) ...@@ -857,15 +857,15 @@ struct sctp_chunk *sctp_make_sack(const struct sctp_association *asoc)
struct sctp_chunk *sctp_make_shutdown(const struct sctp_association *asoc, struct sctp_chunk *sctp_make_shutdown(const struct sctp_association *asoc,
const struct sctp_chunk *chunk) const struct sctp_chunk *chunk)
{ {
struct sctp_shutdownhdr shut;
struct sctp_chunk *retval; struct sctp_chunk *retval;
sctp_shutdownhdr_t shut;
__u32 ctsn; __u32 ctsn;
ctsn = sctp_tsnmap_get_ctsn(&asoc->peer.tsn_map); ctsn = sctp_tsnmap_get_ctsn(&asoc->peer.tsn_map);
shut.cum_tsn_ack = htonl(ctsn); shut.cum_tsn_ack = htonl(ctsn);
retval = sctp_make_control(asoc, SCTP_CID_SHUTDOWN, 0, retval = sctp_make_control(asoc, SCTP_CID_SHUTDOWN, 0,
sizeof(sctp_shutdownhdr_t), GFP_ATOMIC); sizeof(shut), GFP_ATOMIC);
if (!retval) if (!retval)
goto nodata; goto nodata;
...@@ -979,8 +979,8 @@ struct sctp_chunk *sctp_make_abort_no_data( ...@@ -979,8 +979,8 @@ struct sctp_chunk *sctp_make_abort_no_data(
struct sctp_chunk *retval; struct sctp_chunk *retval;
__be32 payload; __be32 payload;
retval = sctp_make_abort(asoc, chunk, sizeof(sctp_errhdr_t) retval = sctp_make_abort(asoc, chunk,
+ sizeof(tsn)); sizeof(struct sctp_errhdr) + sizeof(tsn));
if (!retval) if (!retval)
goto no_mem; goto no_mem;
...@@ -1015,7 +1015,8 @@ struct sctp_chunk *sctp_make_abort_user(const struct sctp_association *asoc, ...@@ -1015,7 +1015,8 @@ struct sctp_chunk *sctp_make_abort_user(const struct sctp_association *asoc,
void *payload = NULL; void *payload = NULL;
int err; int err;
retval = sctp_make_abort(asoc, NULL, sizeof(sctp_errhdr_t) + paylen); retval = sctp_make_abort(asoc, NULL,
sizeof(struct sctp_errhdr) + paylen);
if (!retval) if (!retval)
goto err_chunk; goto err_chunk;
...@@ -1080,8 +1081,8 @@ struct sctp_chunk *sctp_make_abort_violation( ...@@ -1080,8 +1081,8 @@ struct sctp_chunk *sctp_make_abort_violation(
struct sctp_chunk *retval; struct sctp_chunk *retval;
struct sctp_paramhdr phdr; struct sctp_paramhdr phdr;
retval = sctp_make_abort(asoc, chunk, sizeof(sctp_errhdr_t) + paylen + retval = sctp_make_abort(asoc, chunk, sizeof(struct sctp_errhdr) +
sizeof(phdr)); paylen + sizeof(phdr));
if (!retval) if (!retval)
goto end; goto end;
...@@ -1104,7 +1105,7 @@ struct sctp_chunk *sctp_make_violation_paramlen( ...@@ -1104,7 +1105,7 @@ struct sctp_chunk *sctp_make_violation_paramlen(
{ {
struct sctp_chunk *retval; struct sctp_chunk *retval;
static const char error[] = "The following parameter had invalid length:"; static const char error[] = "The following parameter had invalid length:";
size_t payload_len = sizeof(error) + sizeof(sctp_errhdr_t) + size_t payload_len = sizeof(error) + sizeof(struct sctp_errhdr) +
sizeof(*param); sizeof(*param);
retval = sctp_make_abort(asoc, chunk, payload_len); retval = sctp_make_abort(asoc, chunk, payload_len);
...@@ -1126,7 +1127,7 @@ struct sctp_chunk *sctp_make_violation_max_retrans( ...@@ -1126,7 +1127,7 @@ struct sctp_chunk *sctp_make_violation_max_retrans(
{ {
struct sctp_chunk *retval; struct sctp_chunk *retval;
static const char error[] = "Association exceeded its max_retans count"; static const char error[] = "Association exceeded its max_retans count";
size_t payload_len = sizeof(error) + sizeof(sctp_errhdr_t); size_t payload_len = sizeof(error) + sizeof(struct sctp_errhdr);
retval = sctp_make_abort(asoc, chunk, payload_len); retval = sctp_make_abort(asoc, chunk, payload_len);
if (!retval) if (!retval)
...@@ -1209,7 +1210,8 @@ static struct sctp_chunk *sctp_make_op_error_space( ...@@ -1209,7 +1210,8 @@ static struct sctp_chunk *sctp_make_op_error_space(
struct sctp_chunk *retval; struct sctp_chunk *retval;
retval = sctp_make_control(asoc, SCTP_CID_ERROR, 0, retval = sctp_make_control(asoc, SCTP_CID_ERROR, 0,
sizeof(sctp_errhdr_t) + size, GFP_ATOMIC); sizeof(struct sctp_errhdr) + size,
GFP_ATOMIC);
if (!retval) if (!retval)
goto nodata; goto nodata;
...@@ -1280,16 +1282,16 @@ struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc) ...@@ -1280,16 +1282,16 @@ struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc)
return NULL; return NULL;
retval = sctp_make_control(asoc, SCTP_CID_AUTH, 0, retval = sctp_make_control(asoc, SCTP_CID_AUTH, 0,
hmac_desc->hmac_len + sizeof(sctp_authhdr_t), hmac_desc->hmac_len + sizeof(auth_hdr),
GFP_ATOMIC); GFP_ATOMIC);
if (!retval) if (!retval)
return NULL; return NULL;
auth_hdr.hmac_id = htons(hmac_desc->hmac_id); auth_hdr.hmac_id = htons(hmac_desc->hmac_id);
auth_hdr.shkey_id = htons(asoc->active_key_id); auth_hdr.shkey_id = htons(asoc->active_key_id);
retval->subh.auth_hdr = sctp_addto_chunk(retval, sizeof(sctp_authhdr_t), retval->subh.auth_hdr = sctp_addto_chunk(retval, sizeof(auth_hdr),
&auth_hdr); &auth_hdr);
hmac = skb_put_zero(retval->skb, hmac_desc->hmac_len); hmac = skb_put_zero(retval->skb, hmac_desc->hmac_len);
...@@ -2613,7 +2615,7 @@ static int sctp_process_param(struct sctp_association *asoc, ...@@ -2613,7 +2615,7 @@ static int sctp_process_param(struct sctp_association *asoc,
if (!net->sctp.addip_enable) if (!net->sctp.addip_enable)
goto fall_through; goto fall_through;
addr_param = param.v + sizeof(sctp_addip_param_t); addr_param = param.v + sizeof(struct sctp_addip_param);
af = sctp_get_af_specific(param_type2af(addr_param->p.type)); af = sctp_get_af_specific(param_type2af(addr_param->p.type));
if (af == NULL) if (af == NULL)
...@@ -2750,7 +2752,7 @@ static struct sctp_chunk *sctp_make_asconf(struct sctp_association *asoc, ...@@ -2750,7 +2752,7 @@ static struct sctp_chunk *sctp_make_asconf(struct sctp_association *asoc,
union sctp_addr *addr, union sctp_addr *addr,
int vparam_len) int vparam_len)
{ {
sctp_addiphdr_t asconf; struct sctp_addiphdr asconf;
struct sctp_chunk *retval; struct sctp_chunk *retval;
int length = sizeof(asconf) + vparam_len; int length = sizeof(asconf) + vparam_len;
union sctp_addr_param addrparam; union sctp_addr_param addrparam;
...@@ -2808,7 +2810,7 @@ struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc, ...@@ -2808,7 +2810,7 @@ struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc,
int addrcnt, int addrcnt,
__be16 flags) __be16 flags)
{ {
sctp_addip_param_t param; struct sctp_addip_param param;
struct sctp_chunk *retval; struct sctp_chunk *retval;
union sctp_addr_param addr_param; union sctp_addr_param addr_param;
union sctp_addr *addr; union sctp_addr *addr;
...@@ -2894,7 +2896,7 @@ struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc, ...@@ -2894,7 +2896,7 @@ struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc,
struct sctp_chunk *sctp_make_asconf_set_prim(struct sctp_association *asoc, struct sctp_chunk *sctp_make_asconf_set_prim(struct sctp_association *asoc,
union sctp_addr *addr) union sctp_addr *addr)
{ {
sctp_addip_param_t param; struct sctp_addip_param param;
struct sctp_chunk *retval; struct sctp_chunk *retval;
int len = sizeof(param); int len = sizeof(param);
union sctp_addr_param addrparam; union sctp_addr_param addrparam;
...@@ -2943,7 +2945,7 @@ struct sctp_chunk *sctp_make_asconf_set_prim(struct sctp_association *asoc, ...@@ -2943,7 +2945,7 @@ struct sctp_chunk *sctp_make_asconf_set_prim(struct sctp_association *asoc,
static struct sctp_chunk *sctp_make_asconf_ack(const struct sctp_association *asoc, static struct sctp_chunk *sctp_make_asconf_ack(const struct sctp_association *asoc,
__u32 serial, int vparam_len) __u32 serial, int vparam_len)
{ {
sctp_addiphdr_t asconf; struct sctp_addiphdr asconf;
struct sctp_chunk *retval; struct sctp_chunk *retval;
int length = sizeof(asconf) + vparam_len; int length = sizeof(asconf) + vparam_len;
...@@ -2963,10 +2965,11 @@ static struct sctp_chunk *sctp_make_asconf_ack(const struct sctp_association *as ...@@ -2963,10 +2965,11 @@ static struct sctp_chunk *sctp_make_asconf_ack(const struct sctp_association *as
/* Add response parameters to an ASCONF_ACK chunk. */ /* Add response parameters to an ASCONF_ACK chunk. */
static void sctp_add_asconf_response(struct sctp_chunk *chunk, __be32 crr_id, static void sctp_add_asconf_response(struct sctp_chunk *chunk, __be32 crr_id,
__be16 err_code, sctp_addip_param_t *asconf_param) __be16 err_code,
struct sctp_addip_param *asconf_param)
{ {
sctp_addip_param_t ack_param; struct sctp_addip_param ack_param;
sctp_errhdr_t err_param; struct sctp_errhdr err_param;
int asconf_param_len = 0; int asconf_param_len = 0;
int err_param_len = 0; int err_param_len = 0;
__be16 response_type; __be16 response_type;
...@@ -3004,15 +3007,15 @@ static void sctp_add_asconf_response(struct sctp_chunk *chunk, __be32 crr_id, ...@@ -3004,15 +3007,15 @@ static void sctp_add_asconf_response(struct sctp_chunk *chunk, __be32 crr_id,
/* Process a asconf parameter. */ /* Process a asconf parameter. */
static __be16 sctp_process_asconf_param(struct sctp_association *asoc, static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
struct sctp_chunk *asconf, struct sctp_chunk *asconf,
sctp_addip_param_t *asconf_param) struct sctp_addip_param *asconf_param)
{ {
struct sctp_transport *peer; struct sctp_transport *peer;
struct sctp_af *af; struct sctp_af *af;
union sctp_addr addr; union sctp_addr addr;
union sctp_addr_param *addr_param; union sctp_addr_param *addr_param;
addr_param = (void *)asconf_param + sizeof(sctp_addip_param_t); addr_param = (void *)asconf_param + sizeof(*asconf_param);
if (asconf_param->param_hdr.type != SCTP_PARAM_ADD_IP && if (asconf_param->param_hdr.type != SCTP_PARAM_ADD_IP &&
asconf_param->param_hdr.type != SCTP_PARAM_DEL_IP && asconf_param->param_hdr.type != SCTP_PARAM_DEL_IP &&
...@@ -3137,10 +3140,11 @@ bool sctp_verify_asconf(const struct sctp_association *asoc, ...@@ -3137,10 +3140,11 @@ bool sctp_verify_asconf(const struct sctp_association *asoc,
struct sctp_chunk *chunk, bool addr_param_needed, struct sctp_chunk *chunk, bool addr_param_needed,
struct sctp_paramhdr **errp) struct sctp_paramhdr **errp)
{ {
sctp_addip_chunk_t *addip = (sctp_addip_chunk_t *) chunk->chunk_hdr; struct sctp_addip_chunk *addip;
union sctp_params param; union sctp_params param;
bool addr_param_seen = false; bool addr_param_seen = false;
addip = (struct sctp_addip_chunk *)chunk->chunk_hdr;
sctp_walk_params(param, addip, addip_hdr.params) { sctp_walk_params(param, addip, addip_hdr.params) {
size_t length = ntohs(param.p->length); size_t length = ntohs(param.p->length);
...@@ -3172,13 +3176,13 @@ bool sctp_verify_asconf(const struct sctp_association *asoc, ...@@ -3172,13 +3176,13 @@ bool sctp_verify_asconf(const struct sctp_association *asoc,
if (addr_param_needed && !addr_param_seen) if (addr_param_needed && !addr_param_seen)
return false; return false;
length = ntohs(param.addip->param_hdr.length); length = ntohs(param.addip->param_hdr.length);
if (length < sizeof(sctp_addip_param_t) + if (length < sizeof(struct sctp_addip_param) +
sizeof(**errp)) sizeof(**errp))
return false; return false;
break; break;
case SCTP_PARAM_SUCCESS_REPORT: case SCTP_PARAM_SUCCESS_REPORT:
case SCTP_PARAM_ADAPTATION_LAYER_IND: case SCTP_PARAM_ADAPTATION_LAYER_IND:
if (length != sizeof(sctp_addip_param_t)) if (length != sizeof(struct sctp_addip_param))
return false; return false;
break; break;
default: default:
...@@ -3204,10 +3208,10 @@ bool sctp_verify_asconf(const struct sctp_association *asoc, ...@@ -3204,10 +3208,10 @@ bool sctp_verify_asconf(const struct sctp_association *asoc,
struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc, struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
struct sctp_chunk *asconf) struct sctp_chunk *asconf)
{ {
sctp_addip_chunk_t *addip = (sctp_addip_chunk_t *) asconf->chunk_hdr; struct sctp_addip_chunk *addip;
bool all_param_pass = true; bool all_param_pass = true;
union sctp_params param; union sctp_params param;
sctp_addiphdr_t *hdr; struct sctp_addiphdr *hdr;
union sctp_addr_param *addr_param; union sctp_addr_param *addr_param;
struct sctp_chunk *asconf_ack; struct sctp_chunk *asconf_ack;
__be16 err_code; __be16 err_code;
...@@ -3215,13 +3219,14 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc, ...@@ -3215,13 +3219,14 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
int chunk_len; int chunk_len;
__u32 serial; __u32 serial;
addip = (struct sctp_addip_chunk *)asconf->chunk_hdr;
chunk_len = ntohs(asconf->chunk_hdr->length) - chunk_len = ntohs(asconf->chunk_hdr->length) -
sizeof(struct sctp_chunkhdr); sizeof(struct sctp_chunkhdr);
hdr = (sctp_addiphdr_t *)asconf->skb->data; hdr = (struct sctp_addiphdr *)asconf->skb->data;
serial = ntohl(hdr->serial); serial = ntohl(hdr->serial);
/* Skip the addiphdr and store a pointer to address parameter. */ /* Skip the addiphdr and store a pointer to address parameter. */
length = sizeof(sctp_addiphdr_t); length = sizeof(*hdr);
addr_param = (union sctp_addr_param *)(asconf->skb->data + length); addr_param = (union sctp_addr_param *)(asconf->skb->data + length);
chunk_len -= length; chunk_len -= length;
...@@ -3287,7 +3292,7 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc, ...@@ -3287,7 +3292,7 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
/* Process a asconf parameter that is successfully acked. */ /* Process a asconf parameter that is successfully acked. */
static void sctp_asconf_param_success(struct sctp_association *asoc, static void sctp_asconf_param_success(struct sctp_association *asoc,
sctp_addip_param_t *asconf_param) struct sctp_addip_param *asconf_param)
{ {
struct sctp_af *af; struct sctp_af *af;
union sctp_addr addr; union sctp_addr addr;
...@@ -3296,7 +3301,7 @@ static void sctp_asconf_param_success(struct sctp_association *asoc, ...@@ -3296,7 +3301,7 @@ static void sctp_asconf_param_success(struct sctp_association *asoc,
struct sctp_transport *transport; struct sctp_transport *transport;
struct sctp_sockaddr_entry *saddr; struct sctp_sockaddr_entry *saddr;
addr_param = (void *)asconf_param + sizeof(sctp_addip_param_t); addr_param = (void *)asconf_param + sizeof(*asconf_param);
/* We have checked the packet before, so we do not check again. */ /* We have checked the packet before, so we do not check again. */
af = sctp_get_af_specific(param_type2af(addr_param->p.type)); af = sctp_get_af_specific(param_type2af(addr_param->p.type));
...@@ -3347,11 +3352,11 @@ static void sctp_asconf_param_success(struct sctp_association *asoc, ...@@ -3347,11 +3352,11 @@ static void sctp_asconf_param_success(struct sctp_association *asoc,
* specific success indication is present for the parameter. * specific success indication is present for the parameter.
*/ */
static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack, static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack,
sctp_addip_param_t *asconf_param, struct sctp_addip_param *asconf_param,
int no_err) int no_err)
{ {
sctp_addip_param_t *asconf_ack_param; struct sctp_addip_param *asconf_ack_param;
sctp_errhdr_t *err_param; struct sctp_errhdr *err_param;
int length; int length;
int asconf_ack_len; int asconf_ack_len;
__be16 err_code; __be16 err_code;
...@@ -3367,9 +3372,9 @@ static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack, ...@@ -3367,9 +3372,9 @@ static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack,
/* Skip the addiphdr from the asconf_ack chunk and store a pointer to /* Skip the addiphdr from the asconf_ack chunk and store a pointer to
* the first asconf_ack parameter. * the first asconf_ack parameter.
*/ */
length = sizeof(sctp_addiphdr_t); length = sizeof(struct sctp_addiphdr);
asconf_ack_param = (sctp_addip_param_t *)(asconf_ack->skb->data + asconf_ack_param = (struct sctp_addip_param *)(asconf_ack->skb->data +
length); length);
asconf_ack_len -= length; asconf_ack_len -= length;
while (asconf_ack_len > 0) { while (asconf_ack_len > 0) {
...@@ -3378,7 +3383,7 @@ static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack, ...@@ -3378,7 +3383,7 @@ static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack,
case SCTP_PARAM_SUCCESS_REPORT: case SCTP_PARAM_SUCCESS_REPORT:
return SCTP_ERROR_NO_ERROR; return SCTP_ERROR_NO_ERROR;
case SCTP_PARAM_ERR_CAUSE: case SCTP_PARAM_ERR_CAUSE:
length = sizeof(sctp_addip_param_t); length = sizeof(*asconf_ack_param);
err_param = (void *)asconf_ack_param + length; err_param = (void *)asconf_ack_param + length;
asconf_ack_len -= length; asconf_ack_len -= length;
if (asconf_ack_len > 0) if (asconf_ack_len > 0)
...@@ -3405,7 +3410,7 @@ int sctp_process_asconf_ack(struct sctp_association *asoc, ...@@ -3405,7 +3410,7 @@ int sctp_process_asconf_ack(struct sctp_association *asoc,
{ {
struct sctp_chunk *asconf = asoc->addip_last_asconf; struct sctp_chunk *asconf = asoc->addip_last_asconf;
union sctp_addr_param *addr_param; union sctp_addr_param *addr_param;
sctp_addip_param_t *asconf_param; struct sctp_addip_param *asconf_param;
int length = 0; int length = 0;
int asconf_len = asconf->skb->len; int asconf_len = asconf->skb->len;
int all_param_pass = 0; int all_param_pass = 0;
...@@ -3416,7 +3421,7 @@ int sctp_process_asconf_ack(struct sctp_association *asoc, ...@@ -3416,7 +3421,7 @@ int sctp_process_asconf_ack(struct sctp_association *asoc,
/* Skip the chunkhdr and addiphdr from the last asconf sent and store /* Skip the chunkhdr and addiphdr from the last asconf sent and store
* a pointer to address parameter. * a pointer to address parameter.
*/ */
length = sizeof(sctp_addip_chunk_t); length = sizeof(struct sctp_addip_chunk);
addr_param = (union sctp_addr_param *)(asconf->skb->data + length); addr_param = (union sctp_addr_param *)(asconf->skb->data + length);
asconf_len -= length; asconf_len -= length;
...@@ -3432,7 +3437,7 @@ int sctp_process_asconf_ack(struct sctp_association *asoc, ...@@ -3432,7 +3437,7 @@ int sctp_process_asconf_ack(struct sctp_association *asoc,
* failures are indicated, then all request(s) are considered * failures are indicated, then all request(s) are considered
* successful. * successful.
*/ */
if (asconf_ack->skb->len == sizeof(sctp_addiphdr_t)) if (asconf_ack->skb->len == sizeof(struct sctp_addiphdr))
all_param_pass = 1; all_param_pass = 1;
/* Process the TLVs contained in the last sent ASCONF chunk. */ /* Process the TLVs contained in the last sent ASCONF chunk. */
......
...@@ -828,7 +828,7 @@ static void sctp_cmd_assoc_update(sctp_cmd_seq_t *cmds, ...@@ -828,7 +828,7 @@ static void sctp_cmd_assoc_update(sctp_cmd_seq_t *cmds,
if (!sctp_assoc_update(asoc, new)) if (!sctp_assoc_update(asoc, new))
return; return;
abort = sctp_make_abort(asoc, NULL, sizeof(sctp_errhdr_t)); abort = sctp_make_abort(asoc, NULL, sizeof(struct sctp_errhdr));
if (abort) { if (abort) {
sctp_init_cause(abort, SCTP_ERROR_RSRC_LOW, 0); sctp_init_cause(abort, SCTP_ERROR_RSRC_LOW, 0);
sctp_add_cmd_sf(cmds, SCTP_CMD_REPLY, SCTP_CHUNK(abort)); sctp_add_cmd_sf(cmds, SCTP_CMD_REPLY, SCTP_CHUNK(abort));
......
...@@ -528,7 +528,7 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(struct net *net, ...@@ -528,7 +528,7 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(struct net *net,
(struct sctp_init_chunk *)chunk->chunk_hdr, chunk, (struct sctp_init_chunk *)chunk->chunk_hdr, chunk,
&err_chunk)) { &err_chunk)) {
sctp_error_t error = SCTP_ERROR_NO_RESOURCE; enum sctp_error error = SCTP_ERROR_NO_RESOURCE;
/* This chunk contains fatal error. It is to be discarded. /* This chunk contains fatal error. It is to be discarded.
* Send an ABORT, with causes. If there are no causes, * Send an ABORT, with causes. If there are no causes,
...@@ -1233,7 +1233,7 @@ static int sctp_sf_send_restart_abort(struct net *net, union sctp_addr *ssa, ...@@ -1233,7 +1233,7 @@ static int sctp_sf_send_restart_abort(struct net *net, union sctp_addr *ssa,
union sctp_addr_param *addrparm; union sctp_addr_param *addrparm;
struct sctp_errhdr *errhdr; struct sctp_errhdr *errhdr;
struct sctp_endpoint *ep; struct sctp_endpoint *ep;
char buffer[sizeof(struct sctp_errhdr)+sizeof(union sctp_addr_param)]; char buffer[sizeof(*errhdr) + sizeof(*addrparm)];
struct sctp_af *af = sctp_get_af_specific(ssa->v4.sin_family); struct sctp_af *af = sctp_get_af_specific(ssa->v4.sin_family);
/* Build the error on the stack. We are way to malloc crazy /* Build the error on the stack. We are way to malloc crazy
...@@ -1244,7 +1244,7 @@ static int sctp_sf_send_restart_abort(struct net *net, union sctp_addr *ssa, ...@@ -1244,7 +1244,7 @@ static int sctp_sf_send_restart_abort(struct net *net, union sctp_addr *ssa,
/* Copy into a parm format. */ /* Copy into a parm format. */
len = af->to_addr_param(ssa, addrparm); len = af->to_addr_param(ssa, addrparm);
len += sizeof(sctp_errhdr_t); len += sizeof(*errhdr);
errhdr->cause = SCTP_ERROR_RESTART; errhdr->cause = SCTP_ERROR_RESTART;
errhdr->length = htons(len); errhdr->length = htons(len);
...@@ -2270,7 +2270,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_err(struct net *net, ...@@ -2270,7 +2270,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_err(struct net *net,
sctp_cmd_seq_t *commands) sctp_cmd_seq_t *commands)
{ {
struct sctp_chunk *chunk = arg; struct sctp_chunk *chunk = arg;
sctp_errhdr_t *err; struct sctp_errhdr *err;
if (!sctp_vtag_verify(chunk, asoc)) if (!sctp_vtag_verify(chunk, asoc))
return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
...@@ -2278,7 +2278,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_err(struct net *net, ...@@ -2278,7 +2278,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_err(struct net *net,
/* Make sure that the ERROR chunk has a valid length. /* Make sure that the ERROR chunk has a valid length.
* The parameter walking depends on this as well. * The parameter walking depends on this as well.
*/ */
if (!sctp_chunk_length_valid(chunk, sizeof(sctp_operr_chunk_t))) if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_operr_chunk)))
return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
commands); commands);
...@@ -2337,7 +2337,7 @@ static sctp_disposition_t sctp_sf_do_5_2_6_stale(struct net *net, ...@@ -2337,7 +2337,7 @@ static sctp_disposition_t sctp_sf_do_5_2_6_stale(struct net *net,
struct sctp_chunk *chunk = arg, *reply; struct sctp_chunk *chunk = arg, *reply;
struct sctp_cookie_preserve_param bht; struct sctp_cookie_preserve_param bht;
struct sctp_bind_addr *bp; struct sctp_bind_addr *bp;
sctp_errhdr_t *err; struct sctp_errhdr *err;
u32 stale; u32 stale;
if (attempts > asoc->max_init_attempts) { if (attempts > asoc->max_init_attempts) {
...@@ -2348,7 +2348,7 @@ static sctp_disposition_t sctp_sf_do_5_2_6_stale(struct net *net, ...@@ -2348,7 +2348,7 @@ static sctp_disposition_t sctp_sf_do_5_2_6_stale(struct net *net,
return SCTP_DISPOSITION_DELETE_TCB; return SCTP_DISPOSITION_DELETE_TCB;
} }
err = (sctp_errhdr_t *)(chunk->skb->data); err = (struct sctp_errhdr *)(chunk->skb->data);
/* When calculating the time extension, an implementation /* When calculating the time extension, an implementation
* SHOULD use the RTT information measured based on the * SHOULD use the RTT information measured based on the
...@@ -2364,7 +2364,7 @@ static sctp_disposition_t sctp_sf_do_5_2_6_stale(struct net *net, ...@@ -2364,7 +2364,7 @@ static sctp_disposition_t sctp_sf_do_5_2_6_stale(struct net *net,
* to give ample time to retransmit the new cookie and thus * to give ample time to retransmit the new cookie and thus
* yield a higher probability of success on the reattempt. * yield a higher probability of success on the reattempt.
*/ */
stale = ntohl(*(__be32 *)((u8 *)err + sizeof(sctp_errhdr_t))); stale = ntohl(*(__be32 *)((u8 *)err + sizeof(*err)));
stale = (stale * 2) / 1000; stale = (stale * 2) / 1000;
bht.param_hdr.type = SCTP_PARAM_COOKIE_PRESERVATIVE; bht.param_hdr.type = SCTP_PARAM_COOKIE_PRESERVATIVE;
...@@ -2499,13 +2499,14 @@ static sctp_disposition_t __sctp_sf_do_9_1_abort(struct net *net, ...@@ -2499,13 +2499,14 @@ static sctp_disposition_t __sctp_sf_do_9_1_abort(struct net *net,
/* See if we have an error cause code in the chunk. */ /* See if we have an error cause code in the chunk. */
len = ntohs(chunk->chunk_hdr->length); len = ntohs(chunk->chunk_hdr->length);
if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr)) { if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr)) {
struct sctp_errhdr *err;
sctp_errhdr_t *err;
sctp_walk_errors(err, chunk->chunk_hdr); sctp_walk_errors(err, chunk->chunk_hdr);
if ((void *)err != (void *)chunk->chunk_end) if ((void *)err != (void *)chunk->chunk_end)
return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); return sctp_sf_pdiscard(net, ep, asoc, type, arg,
commands);
error = ((sctp_errhdr_t *)chunk->skb->data)->cause; error = ((struct sctp_errhdr *)chunk->skb->data)->cause;
} }
sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(ECONNRESET)); sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(ECONNRESET));
...@@ -2552,7 +2553,7 @@ sctp_disposition_t sctp_sf_cookie_wait_abort(struct net *net, ...@@ -2552,7 +2553,7 @@ sctp_disposition_t sctp_sf_cookie_wait_abort(struct net *net,
/* See if we have an error cause code in the chunk. */ /* See if we have an error cause code in the chunk. */
len = ntohs(chunk->chunk_hdr->length); len = ntohs(chunk->chunk_hdr->length);
if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr)) if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr))
error = ((sctp_errhdr_t *)chunk->skb->data)->cause; error = ((struct sctp_errhdr *)chunk->skb->data)->cause;
return sctp_stop_t1_and_abort(net, commands, error, ECONNREFUSED, asoc, return sctp_stop_t1_and_abort(net, commands, error, ECONNREFUSED, asoc,
chunk->transport); chunk->transport);
...@@ -2656,8 +2657,8 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(struct net *net, ...@@ -2656,8 +2657,8 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(struct net *net,
sctp_cmd_seq_t *commands) sctp_cmd_seq_t *commands)
{ {
struct sctp_chunk *chunk = arg; struct sctp_chunk *chunk = arg;
sctp_shutdownhdr_t *sdh;
sctp_disposition_t disposition; sctp_disposition_t disposition;
struct sctp_shutdownhdr *sdh;
struct sctp_ulpevent *ev; struct sctp_ulpevent *ev;
__u32 ctsn; __u32 ctsn;
...@@ -2665,14 +2666,13 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(struct net *net, ...@@ -2665,14 +2666,13 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(struct net *net,
return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
/* Make sure that the SHUTDOWN chunk has a valid length. */ /* Make sure that the SHUTDOWN chunk has a valid length. */
if (!sctp_chunk_length_valid(chunk, if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_shutdown_chunk)))
sizeof(struct sctp_shutdown_chunk_t)))
return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
commands); commands);
/* Convert the elaborate header. */ /* Convert the elaborate header. */
sdh = (sctp_shutdownhdr_t *)chunk->skb->data; sdh = (struct sctp_shutdownhdr *)chunk->skb->data;
skb_pull(chunk->skb, sizeof(sctp_shutdownhdr_t)); skb_pull(chunk->skb, sizeof(*sdh));
chunk->subh.shutdown_hdr = sdh; chunk->subh.shutdown_hdr = sdh;
ctsn = ntohl(sdh->cum_tsn_ack); ctsn = ntohl(sdh->cum_tsn_ack);
...@@ -2746,19 +2746,18 @@ sctp_disposition_t sctp_sf_do_9_2_shut_ctsn(struct net *net, ...@@ -2746,19 +2746,18 @@ sctp_disposition_t sctp_sf_do_9_2_shut_ctsn(struct net *net,
sctp_cmd_seq_t *commands) sctp_cmd_seq_t *commands)
{ {
struct sctp_chunk *chunk = arg; struct sctp_chunk *chunk = arg;
sctp_shutdownhdr_t *sdh; struct sctp_shutdownhdr *sdh;
__u32 ctsn; __u32 ctsn;
if (!sctp_vtag_verify(chunk, asoc)) if (!sctp_vtag_verify(chunk, asoc))
return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
/* Make sure that the SHUTDOWN chunk has a valid length. */ /* Make sure that the SHUTDOWN chunk has a valid length. */
if (!sctp_chunk_length_valid(chunk, if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_shutdown_chunk)))
sizeof(struct sctp_shutdown_chunk_t)))
return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
commands); commands);
sdh = (sctp_shutdownhdr_t *)chunk->skb->data; sdh = (struct sctp_shutdownhdr *)chunk->skb->data;
ctsn = ntohl(sdh->cum_tsn_ack); ctsn = ntohl(sdh->cum_tsn_ack);
if (TSN_lt(ctsn, asoc->ctsn_ack_point)) { if (TSN_lt(ctsn, asoc->ctsn_ack_point)) {
...@@ -2863,19 +2862,19 @@ sctp_disposition_t sctp_sf_do_ecn_cwr(struct net *net, ...@@ -2863,19 +2862,19 @@ sctp_disposition_t sctp_sf_do_ecn_cwr(struct net *net,
void *arg, void *arg,
sctp_cmd_seq_t *commands) sctp_cmd_seq_t *commands)
{ {
sctp_cwrhdr_t *cwr;
struct sctp_chunk *chunk = arg; struct sctp_chunk *chunk = arg;
struct sctp_cwrhdr *cwr;
u32 lowest_tsn; u32 lowest_tsn;
if (!sctp_vtag_verify(chunk, asoc)) if (!sctp_vtag_verify(chunk, asoc))
return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
if (!sctp_chunk_length_valid(chunk, sizeof(sctp_ecne_chunk_t))) if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_ecne_chunk)))
return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
commands); commands);
cwr = (sctp_cwrhdr_t *) chunk->skb->data; cwr = (struct sctp_cwrhdr *)chunk->skb->data;
skb_pull(chunk->skb, sizeof(sctp_cwrhdr_t)); skb_pull(chunk->skb, sizeof(*cwr));
lowest_tsn = ntohl(cwr->lowest_tsn); lowest_tsn = ntohl(cwr->lowest_tsn);
...@@ -2919,18 +2918,18 @@ sctp_disposition_t sctp_sf_do_ecne(struct net *net, ...@@ -2919,18 +2918,18 @@ sctp_disposition_t sctp_sf_do_ecne(struct net *net,
void *arg, void *arg,
sctp_cmd_seq_t *commands) sctp_cmd_seq_t *commands)
{ {
sctp_ecnehdr_t *ecne;
struct sctp_chunk *chunk = arg; struct sctp_chunk *chunk = arg;
struct sctp_ecnehdr *ecne;
if (!sctp_vtag_verify(chunk, asoc)) if (!sctp_vtag_verify(chunk, asoc))
return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
if (!sctp_chunk_length_valid(chunk, sizeof(sctp_ecne_chunk_t))) if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_ecne_chunk)))
return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
commands); commands);
ecne = (sctp_ecnehdr_t *) chunk->skb->data; ecne = (struct sctp_ecnehdr *)chunk->skb->data;
skb_pull(chunk->skb, sizeof(sctp_ecnehdr_t)); skb_pull(chunk->skb, sizeof(*ecne));
/* If this is a newer ECNE than the last CWR packet we sent out */ /* If this is a newer ECNE than the last CWR packet we sent out */
sctp_add_cmd_sf(commands, SCTP_CMD_ECN_ECNE, sctp_add_cmd_sf(commands, SCTP_CMD_ECN_ECNE,
...@@ -3312,13 +3311,13 @@ sctp_disposition_t sctp_sf_operr_notify(struct net *net, ...@@ -3312,13 +3311,13 @@ sctp_disposition_t sctp_sf_operr_notify(struct net *net,
sctp_cmd_seq_t *commands) sctp_cmd_seq_t *commands)
{ {
struct sctp_chunk *chunk = arg; struct sctp_chunk *chunk = arg;
sctp_errhdr_t *err; struct sctp_errhdr *err;
if (!sctp_vtag_verify(chunk, asoc)) if (!sctp_vtag_verify(chunk, asoc))
return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
/* Make sure that the ERROR chunk has a valid length. */ /* Make sure that the ERROR chunk has a valid length. */
if (!sctp_chunk_length_valid(chunk, sizeof(sctp_operr_chunk_t))) if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_operr_chunk)))
return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
commands); commands);
sctp_walk_errors(err, chunk->chunk_hdr); sctp_walk_errors(err, chunk->chunk_hdr);
...@@ -3435,7 +3434,7 @@ sctp_disposition_t sctp_sf_ootb(struct net *net, ...@@ -3435,7 +3434,7 @@ sctp_disposition_t sctp_sf_ootb(struct net *net,
struct sctp_chunk *chunk = arg; struct sctp_chunk *chunk = arg;
struct sk_buff *skb = chunk->skb; struct sk_buff *skb = chunk->skb;
struct sctp_chunkhdr *ch; struct sctp_chunkhdr *ch;
sctp_errhdr_t *err; struct sctp_errhdr *err;
__u8 *ch_end; __u8 *ch_end;
int ootb_shut_ack = 0; int ootb_shut_ack = 0;
int ootb_cookie_ack = 0; int ootb_cookie_ack = 0;
...@@ -3614,7 +3613,7 @@ sctp_disposition_t sctp_sf_do_asconf(struct net *net, ...@@ -3614,7 +3613,7 @@ sctp_disposition_t sctp_sf_do_asconf(struct net *net,
struct sctp_chunk *chunk = arg; struct sctp_chunk *chunk = arg;
struct sctp_chunk *asconf_ack = NULL; struct sctp_chunk *asconf_ack = NULL;
struct sctp_paramhdr *err_param = NULL; struct sctp_paramhdr *err_param = NULL;
sctp_addiphdr_t *hdr; struct sctp_addiphdr *hdr;
__u32 serial; __u32 serial;
if (!sctp_vtag_verify(chunk, asoc)) { if (!sctp_vtag_verify(chunk, asoc)) {
...@@ -3630,14 +3629,15 @@ sctp_disposition_t sctp_sf_do_asconf(struct net *net, ...@@ -3630,14 +3629,15 @@ sctp_disposition_t sctp_sf_do_asconf(struct net *net,
* described in [I-D.ietf-tsvwg-sctp-auth]. * described in [I-D.ietf-tsvwg-sctp-auth].
*/ */
if (!net->sctp.addip_noauth && !chunk->auth) if (!net->sctp.addip_noauth && !chunk->auth)
return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); return sctp_sf_discard_chunk(net, ep, asoc, type, arg,
commands);
/* Make sure that the ASCONF ADDIP chunk has a valid length. */ /* Make sure that the ASCONF ADDIP chunk has a valid length. */
if (!sctp_chunk_length_valid(chunk, sizeof(sctp_addip_chunk_t))) if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_addip_chunk)))
return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
commands); commands);
hdr = (sctp_addiphdr_t *)chunk->skb->data; hdr = (struct sctp_addiphdr *)chunk->skb->data;
serial = ntohl(hdr->serial); serial = ntohl(hdr->serial);
/* Verify the ASCONF chunk before processing it. */ /* Verify the ASCONF chunk before processing it. */
...@@ -3731,7 +3731,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net, ...@@ -3731,7 +3731,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net,
struct sctp_chunk *last_asconf = asoc->addip_last_asconf; struct sctp_chunk *last_asconf = asoc->addip_last_asconf;
struct sctp_chunk *abort; struct sctp_chunk *abort;
struct sctp_paramhdr *err_param = NULL; struct sctp_paramhdr *err_param = NULL;
sctp_addiphdr_t *addip_hdr; struct sctp_addiphdr *addip_hdr;
__u32 sent_serial, rcvd_serial; __u32 sent_serial, rcvd_serial;
if (!sctp_vtag_verify(asconf_ack, asoc)) { if (!sctp_vtag_verify(asconf_ack, asoc)) {
...@@ -3747,14 +3747,16 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net, ...@@ -3747,14 +3747,16 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net,
* described in [I-D.ietf-tsvwg-sctp-auth]. * described in [I-D.ietf-tsvwg-sctp-auth].
*/ */
if (!net->sctp.addip_noauth && !asconf_ack->auth) if (!net->sctp.addip_noauth && !asconf_ack->auth)
return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); return sctp_sf_discard_chunk(net, ep, asoc, type, arg,
commands);
/* Make sure that the ADDIP chunk has a valid length. */ /* Make sure that the ADDIP chunk has a valid length. */
if (!sctp_chunk_length_valid(asconf_ack, sizeof(sctp_addip_chunk_t))) if (!sctp_chunk_length_valid(asconf_ack,
sizeof(struct sctp_addip_chunk)))
return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
commands); commands);
addip_hdr = (sctp_addiphdr_t *)asconf_ack->skb->data; addip_hdr = (struct sctp_addiphdr *)asconf_ack->skb->data;
rcvd_serial = ntohl(addip_hdr->serial); rcvd_serial = ntohl(addip_hdr->serial);
/* Verify the ASCONF-ACK chunk before processing it. */ /* Verify the ASCONF-ACK chunk before processing it. */
...@@ -3763,7 +3765,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net, ...@@ -3763,7 +3765,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net,
(void *)err_param, commands); (void *)err_param, commands);
if (last_asconf) { if (last_asconf) {
addip_hdr = (sctp_addiphdr_t *)last_asconf->subh.addip_hdr; addip_hdr = (struct sctp_addiphdr *)last_asconf->subh.addip_hdr;
sent_serial = ntohl(addip_hdr->serial); sent_serial = ntohl(addip_hdr->serial);
} else { } else {
sent_serial = asoc->addip_serial - 1; sent_serial = asoc->addip_serial - 1;
...@@ -3778,7 +3780,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net, ...@@ -3778,7 +3780,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net,
if (ADDIP_SERIAL_gte(rcvd_serial, sent_serial + 1) && if (ADDIP_SERIAL_gte(rcvd_serial, sent_serial + 1) &&
!(asoc->addip_last_asconf)) { !(asoc->addip_last_asconf)) {
abort = sctp_make_abort(asoc, asconf_ack, abort = sctp_make_abort(asoc, asconf_ack,
sizeof(sctp_errhdr_t)); sizeof(struct sctp_errhdr));
if (abort) { if (abort) {
sctp_init_cause(abort, SCTP_ERROR_ASCONF_ACK, 0); sctp_init_cause(abort, SCTP_ERROR_ASCONF_ACK, 0);
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
...@@ -3814,7 +3816,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net, ...@@ -3814,7 +3816,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net,
} }
abort = sctp_make_abort(asoc, asconf_ack, abort = sctp_make_abort(asoc, asconf_ack,
sizeof(sctp_errhdr_t)); sizeof(struct sctp_errhdr));
if (abort) { if (abort) {
sctp_init_cause(abort, SCTP_ERROR_RSRC_LOW, 0); sctp_init_cause(abort, SCTP_ERROR_RSRC_LOW, 0);
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
...@@ -4091,7 +4093,7 @@ static sctp_ierror_t sctp_sf_authenticate(struct net *net, ...@@ -4091,7 +4093,7 @@ static sctp_ierror_t sctp_sf_authenticate(struct net *net,
/* Pull in the auth header, so we can do some more verification */ /* Pull in the auth header, so we can do some more verification */
auth_hdr = (struct sctp_authhdr *)chunk->skb->data; auth_hdr = (struct sctp_authhdr *)chunk->skb->data;
chunk->subh.auth_hdr = auth_hdr; chunk->subh.auth_hdr = auth_hdr;
skb_pull(chunk->skb, sizeof(struct sctp_authhdr)); skb_pull(chunk->skb, sizeof(*auth_hdr));
/* Make sure that we support the HMAC algorithm from the auth /* Make sure that we support the HMAC algorithm from the auth
* chunk. * chunk.
...@@ -4110,7 +4112,8 @@ static sctp_ierror_t sctp_sf_authenticate(struct net *net, ...@@ -4110,7 +4112,8 @@ static sctp_ierror_t sctp_sf_authenticate(struct net *net,
/* Make sure that the length of the signature matches what /* Make sure that the length of the signature matches what
* we expect. * we expect.
*/ */
sig_len = ntohs(chunk->chunk_hdr->length) - sizeof(sctp_auth_chunk_t); sig_len = ntohs(chunk->chunk_hdr->length) -
sizeof(struct sctp_auth_chunk);
hmac = sctp_auth_get_hmac(ntohs(auth_hdr->hmac_id)); hmac = sctp_auth_get_hmac(ntohs(auth_hdr->hmac_id));
if (sig_len != hmac->hmac_len) if (sig_len != hmac->hmac_len)
return SCTP_IERROR_PROTO_VIOLATION; return SCTP_IERROR_PROTO_VIOLATION;
...@@ -4132,8 +4135,8 @@ static sctp_ierror_t sctp_sf_authenticate(struct net *net, ...@@ -4132,8 +4135,8 @@ static sctp_ierror_t sctp_sf_authenticate(struct net *net,
memset(digest, 0, sig_len); memset(digest, 0, sig_len);
sctp_auth_calculate_hmac(asoc, chunk->skb, sctp_auth_calculate_hmac(asoc, chunk->skb,
(struct sctp_auth_chunk *)chunk->chunk_hdr, (struct sctp_auth_chunk *)chunk->chunk_hdr,
GFP_ATOMIC); GFP_ATOMIC);
/* Discard the packet if the digests do not match */ /* Discard the packet if the digests do not match */
if (memcmp(save_digest, digest, sig_len)) { if (memcmp(save_digest, digest, sig_len)) {
...@@ -5419,12 +5422,14 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown_ack( ...@@ -5419,12 +5422,14 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown_ack(
*/ */
if (chunk) { if (chunk) {
if (!sctp_vtag_verify(chunk, asoc)) if (!sctp_vtag_verify(chunk, asoc))
return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); return sctp_sf_pdiscard(net, ep, asoc, type, arg,
commands);
/* Make sure that the SHUTDOWN chunk has a valid length. */ /* Make sure that the SHUTDOWN chunk has a valid length. */
if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_shutdown_chunk_t))) if (!sctp_chunk_length_valid(
return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, chunk, sizeof(struct sctp_shutdown_chunk)))
commands); return sctp_sf_violation_chunklen(net, ep, asoc, type,
arg, commands);
} }
/* If it has no more outstanding DATA chunks, the SHUTDOWN receiver /* If it has no more outstanding DATA chunks, the SHUTDOWN receiver
......
...@@ -371,19 +371,19 @@ sctp_ulpevent_make_remote_error(const struct sctp_association *asoc, ...@@ -371,19 +371,19 @@ sctp_ulpevent_make_remote_error(const struct sctp_association *asoc,
struct sctp_chunk *chunk, __u16 flags, struct sctp_chunk *chunk, __u16 flags,
gfp_t gfp) gfp_t gfp)
{ {
struct sctp_ulpevent *event;
struct sctp_remote_error *sre; struct sctp_remote_error *sre;
struct sctp_ulpevent *event;
struct sctp_errhdr *ch;
struct sk_buff *skb; struct sk_buff *skb;
sctp_errhdr_t *ch;
__be16 cause; __be16 cause;
int elen; int elen;
ch = (sctp_errhdr_t *)(chunk->skb->data); ch = (struct sctp_errhdr *)(chunk->skb->data);
cause = ch->cause; cause = ch->cause;
elen = SCTP_PAD4(ntohs(ch->length)) - sizeof(sctp_errhdr_t); elen = SCTP_PAD4(ntohs(ch->length)) - sizeof(*ch);
/* Pull off the ERROR header. */ /* Pull off the ERROR header. */
skb_pull(chunk->skb, sizeof(sctp_errhdr_t)); skb_pull(chunk->skb, sizeof(*ch));
/* Copy the skb to a new skb with room for us to prepend /* Copy the skb to a new skb with room for us to prepend
* notification with. * notification with.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment