sctp: remove typedefs from structures part 4
Subsystems (3)
Xin Long
maintainercover 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.
Xin Long (14):
sctp: remove the typedef sctp_shutdownhdr_t
sctp: fix the name of struct sctp_shutdown_chunk_t
sctp: remove the typedef sctp_errhdr_t
sctp: remove the typedef sctp_operr_chunk_t
sctp: remove the typedef sctp_error_t
sctp: remove the typedef sctp_ecnehdr_t
sctp: remove the typedef sctp_ecne_chunk_t
sctp: remove the typedef sctp_cwrhdr_t
sctp: remove the typedef sctp_cwr_chunk_t
sctp: remove the typedef sctp_addip_param_t
sctp: remove the typedef sctp_addiphdr_t
sctp: remove the typedef sctp_addip_chunk_t
sctp: remove the typedef sctp_authhdr_t
sctp: remove the typedef sctp_auth_chunk_t
include/linux/sctp.h | 69 +++++++++++++-------------- include/net/sctp/sctp.h | 8 ++-- net/sctp/chunk.c | 2 +- net/sctp/input.c | 2 +- net/sctp/sm_make_chunk.c | 119 ++++++++++++++++++++++++----------------------- net/sctp/sm_sideeffect.c | 2 +- net/sctp/sm_statefuns.c | 107 ++++++++++++++++++++++-------------------- net/sctp/ulpevent.c | 10 ++-- 8 files changed, 162 insertions(+), 157 deletions(-)
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 1/14 sctp: remove the typedef sctp_shutdownhdr_t
This patch is to remove the typedef sctp_shutdownhdr_t, and replace with struct sctp_shutdownhdr in the places where it's using this typedef.
It is also to use sizeof(variable) instead of sizeof(type).
--- include/linux/sctp.h | 6 +++--- net/sctp/sm_make_chunk.c | 4 ++-- net/sctp/sm_statefuns.c | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-)
include/linux/sctp.h +3 -3
@@ -416,13 +416,13 @@ struct sctp_abort_chunk {/* For the graceful shutdown we must carry the tag (in common header) * and the highest consecutive acking value. */ -typedef struct sctp_shutdownhdr { +struct sctp_shutdownhdr {__be32 cum_tsn_ack; -}sctp_shutdownhdr_t ; +};struct sctp_shutdown_chunk_t {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) */
net/sctp/sm_make_chunk.c +2 -2
@@ -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,const struct sctp_chunk *chunk) { +struct sctp_shutdownhdr shut;struct sctp_chunk *retval; -sctp_shutdownhdr_t shut;__u32 ctsn; ctsn =sctp_tsnmap_get_ctsn (&asoc->peer.tsn_map); shut.cum_tsn_ack =htonl (ctsn); retval =sctp_make_control (asoc,SCTP_CID_SHUTDOWN ,0 , -sizeof (sctp_shutdownhdr_t),GFP_ATOMIC ); +sizeof (shut),GFP_ATOMIC );if (!retval) goto nodata;
net/sctp/sm_statefuns.c +5 -5
@@ -2656,8 +2656,8 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(struct net *net, sctp_cmd_seq_t *commands) {struct sctp_chunk *chunk = arg; -sctp_shutdownhdr_t *sdh;sctp_disposition_t disposition; +struct sctp_shutdownhdr *sdh;struct sctp_ulpevent *ev;__u32 ctsn;
@@ -2671,8 +2671,8 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(struct net *net, commands);/* Convert the elaborate header. */ - sdh = (sctp_shutdownhdr_t *)chunk->skb->data; -skb_pull (chunk->skb,sizeof (sctp_shutdownhdr_t)); + sdh = (struct sctp_shutdownhdr *)chunk->skb->data; +skb_pull (chunk->skb,sizeof (*sdh)); chunk->subh.shutdown_hdr = sdh; ctsn =ntohl (sdh->cum_tsn_ack);
@@ -2746,7 +2746,7 @@ sctp_disposition_t sctp_sf_do_9_2_shut_ctsn(struct net *net, sctp_cmd_seq_t *commands) {struct sctp_chunk *chunk = arg; -sctp_shutdownhdr_t *sdh; +struct sctp_shutdownhdr *sdh;__u32 ctsn;if (!sctp_vtag_verify (chunk, asoc))
@@ -2758,7 +2758,7 @@ sctp_disposition_t sctp_sf_do_9_2_shut_ctsn(struct net *net,return sctp_sf_violation_chunklen (net, ep, asoc, type, arg, commands); - sdh = (sctp_shutdownhdr_t *)chunk->skb->data; + sdh = (struct sctp_shutdownhdr *)chunk->skb->data; ctsn =ntohl (sdh->cum_tsn_ack);if (TSN_lt (ctsn, asoc->ctsn_ack_point)) {
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 2/14 sctp: fix the name of struct sctp_shutdown_chunk_t
This patch is to fix the name of struct sctp_shutdown_chunk_t , replace with struct sctp_initack_chunk in the places where it's using it.
It is also to fix some indent problem.
--- include/linux/sctp.h | 2 +- net/sctp/sm_statefuns.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-)
include/linux/sctp.h +1 -1
@@ -420,7 +420,7 @@ struct sctp_shutdownhdr {__be32 cum_tsn_ack; }; -struct sctp_shutdown_chunk_t { +struct sctp_shutdown_chunk {struct sctp_chunkhdr chunk_hdr;struct sctp_shutdownhdr shutdown_hdr; };
net/sctp/sm_statefuns.c +8 -8
@@ -2665,8 +2665,7 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(struct net *net,return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands);/* 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 (chunk,sizeof (struct sctp_shutdown_chunk )))return sctp_sf_violation_chunklen (net, ep, asoc, type, arg, commands);
@@ -2753,8 +2752,7 @@ sctp_disposition_t sctp_sf_do_9_2_shut_ctsn(struct net *net,return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands);/* 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 (chunk,sizeof (struct sctp_shutdown_chunk )))return sctp_sf_violation_chunklen (net, ep, asoc, type, arg, commands);
@@ -5419,12 +5417,14 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown_ack(*/ if (chunk) {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. */ -if (!sctp_chunk_length_valid (chunk,sizeof (struct sctp_shutdown_chunk_t ))) -return sctp_sf_violation_chunklen (net, ep, asoc, type, arg, - commands); +if (!sctp_chunk_length_valid ( + chunk,sizeof (struct sctp_shutdown_chunk ))) +return sctp_sf_violation_chunklen (net, ep, asoc, type, + arg, commands); }/* If it has no more outstanding DATA chunks, the SHUTDOWN receiver
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 3/14 sctp: remove the typedef sctp_errhdr_t
This patch is to remove the typedef sctp_errhdr_t, and replace with struct sctp_errhdr in the places where it's using this typedef.
It is also to use sizeof(variable) instead of sizeof(type).
--- include/linux/sctp.h | 6 +++--- include/net/sctp/sctp.h | 8 ++++---- net/sctp/sm_make_chunk.c | 38 ++++++++++++++++++++------------------ net/sctp/sm_sideeffect.c | 2 +- net/sctp/sm_statefuns.c | 29 +++++++++++++++-------------- net/sctp/ulpevent.c | 10 +++++----- 6 files changed, 48 insertions(+), 45 deletions(-)
include/linux/sctp.h +3 -3
@@ -427,15 +427,15 @@ struct sctp_shutdown_chunk {/* RFC 2960. Section 3.3.10 Operation Error (ERROR) (9) */ -typedef struct sctp_errhdr { +struct sctp_errhdr {__be16 cause;__be16 length;__u8 variable[0 ]; -}sctp_errhdr_t ; +};typedef struct sctp_operr_chunk {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
include/net/sctp/sctp.h +4 -4
@@ -479,13 +479,13 @@ for (pos.v = chunk->member;\ _sctp_walk_errors((err), (chunk_hdr), ntohs((chunk_hdr)->length))#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));\ - ((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 *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\ - ntohs(err->length) >= sizeof(sctp_errhdr_t); \ - err = (sctp_errhdr_t *)((void *)err + SCTP_PAD4(ntohs(err->length)))) + ntohs(err->length) >= sizeof(struct sctp_errhdr); \ + err = (struct sctp_errhdr *)((void *)err + SCTP_PAD4(ntohs(err->length))))#define sctp_walk_fwdtsn (pos, chunk)\ _sctp_walk_fwdtsn((pos), (chunk), ntohs((chunk)->chunk_hdr->length) - sizeof(struct sctp_fwdtsn_chunk))
net/sctp/sm_make_chunk.c +20 -18
@@ -135,14 +135,14 @@ static const struct sctp_paramhdr prsctp_param = {void sctp_init_cause (struct sctp_chunk *chunk,__be16 cause_code,size_t paylen) { -sctp_errhdr_t err; +struct sctp_errhdr err;__u16 len;/* Cause code constants are now defined in network order. */ err.cause = cause_code; - len =sizeof (sctp_errhdr_t) + paylen; + len =sizeof (err) + paylen; 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
@@ -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,size_t paylen) { -sctp_errhdr_t err; +struct sctp_errhdr err;__u16 len;/* Cause code constants are now defined in network order. */ err.cause = cause_code; - len =sizeof (sctp_errhdr_t) + paylen; + len =sizeof (err) + paylen; err.length =htons (len);if (skb_tailroom (chunk->skb) < len)return -ENOSPC ; - chunk->subh.err_hdr =sctp_addto_chunk_fixed (chunk, -sizeof (sctp_errhdr_t), - &err); + + chunk->subh.err_hdr =sctp_addto_chunk_fixed (chunk,sizeof (err), &err); +return 0 ; }/* 3.3.2 Initiation (INIT) (1)
@@ -979,8 +979,8 @@ struct sctp_chunk *sctp_make_abort_no_data(struct sctp_chunk *retval;__be32 payload; - retval =sctp_make_abort (asoc, chunk,sizeof (sctp_errhdr_t) - +sizeof (tsn)); + retval =sctp_make_abort (asoc, chunk, +sizeof (struct sctp_errhdr ) +sizeof (tsn));if (!retval) goto no_mem;
@@ -1015,7 +1015,8 @@ struct sctp_chunk *sctp_make_abort_user(const struct sctp_association *asoc,void *payload =NULL ;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) goto err_chunk;
@@ -1080,8 +1081,8 @@ struct sctp_chunk *sctp_make_abort_violation(struct sctp_chunk *retval;struct sctp_paramhdr phdr; - retval =sctp_make_abort (asoc, chunk,sizeof (sctp_errhdr_t) + paylen + -sizeof (phdr)); + retval =sctp_make_abort (asoc, chunk,sizeof (struct sctp_errhdr ) + + paylen +sizeof (phdr));if (!retval) goto end;
@@ -1104,7 +1105,7 @@ struct sctp_chunk *sctp_make_violation_paramlen( {struct sctp_chunk *retval;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); retval =sctp_make_abort (asoc, chunk, payload_len);
@@ -1126,7 +1127,7 @@ struct sctp_chunk *sctp_make_violation_max_retrans( {struct sctp_chunk *retval;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);if (!retval)
@@ -1209,7 +1210,8 @@ static struct sctp_chunk *sctp_make_op_error_space(struct sctp_chunk *retval; 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) goto nodata;
@@ -2966,7 +2968,7 @@ static void sctp_add_asconf_response(struct sctp_chunk *chunk, __be32 crr_id, __be16 err_code, sctp_addip_param_t *asconf_param) { sctp_addip_param_t ack_param; -sctp_errhdr_t err_param; +struct sctp_errhdr err_param;int asconf_param_len =0 ;int err_param_len =0 ;__be16 response_type;
@@ -3351,7 +3353,7 @@ static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack, int no_err) {sctp_addip_param_t *asconf_ack_param; -sctp_errhdr_t *err_param; +struct sctp_errhdr *err_param;int length;int asconf_ack_len;__be16 err_code;
net/sctp/sm_sideeffect.c +1 -1
@@ -828,7 +828,7 @@ static void sctp_cmd_assoc_update(sctp_cmd_seq_t *cmds,if (!sctp_assoc_update (asoc, new))return ; - abort =sctp_make_abort (asoc,NULL ,sizeof (sctp_errhdr_t)); + abort =sctp_make_abort (asoc,NULL ,sizeof (struct sctp_errhdr ));if (abort) {sctp_init_cause (abort,SCTP_ERROR_RSRC_LOW ,0 );sctp_add_cmd_sf (cmds,SCTP_CMD_REPLY ,SCTP_CHUNK (abort));
net/sctp/sm_statefuns.c +15 -14
@@ -1233,7 +1233,7 @@ static int sctp_sf_send_restart_abort(struct net *net, union sctp_addr *ssa,union sctp_addr_param *addrparm;struct sctp_errhdr *errhdr;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);/* 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,/* Copy into a parm format. */ len = af->to_addr_param (ssa, addrparm); - len +=sizeof (sctp_errhdr_t); + len +=sizeof (*errhdr); errhdr->cause =SCTP_ERROR_RESTART ; errhdr->length =htons (len);
@@ -2270,7 +2270,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_err(struct net *net, sctp_cmd_seq_t *commands) {struct sctp_chunk *chunk = arg; -sctp_errhdr_t *err; +struct sctp_errhdr *err;if (!sctp_vtag_verify (chunk, asoc))return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands);
@@ -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_cookie_preserve_param bht;struct sctp_bind_addr *bp; -sctp_errhdr_t *err; +struct sctp_errhdr *err;u32 stale;if (attempts > asoc->max_init_attempts) {
@@ -2348,7 +2348,7 @@ static sctp_disposition_t sctp_sf_do_5_2_6_stale(struct net *net,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 * 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,* to give ample time to retransmit the new cookie and thus * 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 ; 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,/* See if we have an error cause code in the chunk. */ len =ntohs (chunk->chunk_hdr->length);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);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 ));
@@ -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. */ len =ntohs (chunk->chunk_hdr->length);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, chunk->transport);
@@ -3310,7 +3311,7 @@ sctp_disposition_t sctp_sf_operr_notify(struct net *net, sctp_cmd_seq_t *commands) {struct sctp_chunk *chunk = arg; -sctp_errhdr_t *err; +struct sctp_errhdr *err;if (!sctp_vtag_verify (chunk, asoc))return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands);
@@ -3433,7 +3434,7 @@ sctp_disposition_t sctp_sf_ootb(struct net *net,struct sctp_chunk *chunk = arg;struct sk_buff *skb = chunk->skb;struct sctp_chunkhdr *ch; -sctp_errhdr_t *err; +struct sctp_errhdr *err;__u8 *ch_end;int ootb_shut_ack =0 ;int ootb_cookie_ack =0 ;
@@ -3776,7 +3777,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net,if (ADDIP_SERIAL_gte (rcvd_serial, sent_serial +1 ) && !(asoc->addip_last_asconf)) { abort =sctp_make_abort (asoc, asconf_ack, -sizeof (sctp_errhdr_t)); +sizeof (struct sctp_errhdr ));if (abort) {sctp_init_cause (abort,SCTP_ERROR_ASCONF_ACK ,0 ); sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
@@ -3812,7 +3813,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net, } abort =sctp_make_abort (asoc, asconf_ack, -sizeof (sctp_errhdr_t)); +sizeof (struct sctp_errhdr ));if (abort) {sctp_init_cause (abort,SCTP_ERROR_RSRC_LOW ,0 ); sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
net/sctp/ulpevent.c +5 -5
@@ -371,19 +371,19 @@ sctp_ulpevent_make_remote_error(const struct sctp_association *asoc, struct sctp_chunk *chunk, __u16 flags, gfp_t gfp) { - struct sctp_ulpevent *event; struct sctp_remote_error *sre; +struct sctp_ulpevent *event; +struct sctp_errhdr *ch;struct sk_buff *skb; -sctp_errhdr_t *ch;__be16 cause;int elen; - ch = (sctp_errhdr_t *)(chunk->skb->data); + ch = (struct sctp_errhdr *)(chunk->skb->data); 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. */ -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 * notification with.
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 4/14 sctp: remove the typedef sctp_operr_chunk_t
This patch is to remove the typedef sctp_operr_chunk_t, and replace with struct sctp_operr_chunk in the places where it's using this typedef.
--- include/linux/sctp.h | 4 ++-- net/sctp/sm_statefuns.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
include/linux/sctp.h +2 -2
@@ -433,10 +433,10 @@ struct sctp_errhdr {__u8 variable[0 ]; }; -typedef struct sctp_operr_chunk { +struct sctp_operr_chunk {struct sctp_chunkhdr chunk_hdr;struct sctp_errhdr err_hdr; -}sctp_operr_chunk_t ; +};/* RFC 2960 3.3.10 - Operation Error *
net/sctp/sm_statefuns.c +2 -2
@@ -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. * 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, commands);
@@ -3317,7 +3317,7 @@ sctp_disposition_t sctp_sf_operr_notify(struct net *net,return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands);/* 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, commands);sctp_walk_errors (err, chunk->chunk_hdr);
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 5/14 sctp: remove the typedef sctp_error_t
This patch is to remove the typedef sctp_error_t, and replace with enum sctp_error in the places where it's using this typedef.
--- include/linux/sctp.h | 4 ++-- net/sctp/sm_statefuns.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
include/linux/sctp.h +2 -2
@@ -457,7 +457,7 @@ struct sctp_operr_chunk {* 9 No User Data * 10 Cookie Received While Shutting Down */ -typedef enum { +enum sctp_error {SCTP_ERROR_NO_ERROR =cpu_to_be16 (0x00 ),SCTP_ERROR_INV_STRM =cpu_to_be16 (0x01 ),
@@ -512,7 +512,7 @@ typedef enum {* 0x0105 Unsupported HMAC Identifier */ SCTP_ERROR_UNSUP_HMAC = cpu_to_be16(0x0105) -} sctp_error_t; +};
net/sctp/sm_statefuns.c +1 -1
@@ -528,7 +528,7 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(struct net *net, (struct sctp_init_chunk *)chunk->chunk_hdr, 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. * Send an ABORT, with causes. If there are no causes,
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 6/14 sctp: remove the typedef sctp_ecnehdr_t
This patch is to remove the typedef sctp_ecnehdr_t, and replace with struct sctp_ecnehdr in the places where it's using this typedef.
It is also to use sizeof(variable) instead of sizeof(type).
--- include/linux/sctp.h | 6 +++--- net/sctp/sm_make_chunk.c | 4 ++-- net/sctp/sm_statefuns.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-)
include/linux/sctp.h +3 -3
@@ -519,13 +519,13 @@ enum sctp_error {/* RFC 2960. Appendix A. Explicit Congestion Notification. * Explicit Congestion Notification Echo (ECNE) (12) */ -typedef struct sctp_ecnehdr { +struct sctp_ecnehdr {__be32 lowest_tsn; -}sctp_ecnehdr_t ; +};typedef struct sctp_ecne_chunk {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.
net/sctp/sm_make_chunk.c +2 -2
@@ -697,11 +697,11 @@ struct sctp_chunk *sctp_make_ecne(const struct sctp_association *asoc, const __u32 lowest_tsn) {struct sctp_chunk *retval; -sctp_ecnehdr_t ecne; +struct sctp_ecnehdr ecne; ecne.lowest_tsn =htonl (lowest_tsn); retval =sctp_make_control (asoc,SCTP_CID_ECN_ECNE ,0 , -sizeof (sctp_ecnehdr_t),GFP_ATOMIC ); +sizeof (ecne),GFP_ATOMIC );if (!retval) goto nodata; retval->subh.ecne_hdr diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 1d12499..de3e5bf 100644
net/sctp/sm_statefuns.c +3 -3
@@ -2918,8 +2918,8 @@ sctp_disposition_t sctp_sf_do_ecne(struct net *net,void *arg, sctp_cmd_seq_t *commands) { - sctp_ecnehdr_t *ecne; struct sctp_chunk *chunk = arg; +struct sctp_ecnehdr *ecne;if (!sctp_vtag_verify (chunk, asoc))return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands);
@@ -2928,8 +2928,8 @@ sctp_disposition_t sctp_sf_do_ecne(struct net *net,return sctp_sf_violation_chunklen (net, ep, asoc, type, arg, commands); - ecne = (sctp_ecnehdr_t *) chunk->skb->data; -skb_pull (chunk->skb,sizeof (sctp_ecnehdr_t)); + ecne = (struct sctp_ecnehdr *)chunk->skb->data; +skb_pull (chunk->skb,sizeof (*ecne));/* If this is a newer ECNE than the last CWR packet we sent out */ sctp_add_cmd_sf(commands, SCTP_CMD_ECN_ECNE,
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 7/14 sctp: remove the typedef sctp_ecne_chunk_t
This patch is to remove the typedef sctp_ecne_chunk_t, and replace with struct sctp_ecne_chunk in the places where it's using this typedef.
--- include/linux/sctp.h | 4 ++-- net/sctp/sm_statefuns.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
include/linux/sctp.h +2 -2
@@ -523,10 +523,10 @@ struct sctp_ecnehdr {__be32 lowest_tsn; }; -typedef struct sctp_ecne_chunk { +struct sctp_ecne_chunk {struct sctp_chunkhdr chunk_hdr;struct sctp_ecnehdr ence_hdr; -}sctp_ecne_chunk_t ; +};/* RFC 2960. Appendix A. Explicit Congestion Notification. * Congestion Window Reduced (CWR) (13)
net/sctp/sm_statefuns.c +2 -2
@@ -2869,7 +2869,7 @@ sctp_disposition_t sctp_sf_do_ecn_cwr(struct net *net,if (!sctp_vtag_verify (chunk, asoc))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, commands);
@@ -2924,7 +2924,7 @@ sctp_disposition_t sctp_sf_do_ecne(struct net *net,if (!sctp_vtag_verify (chunk, asoc))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, commands);
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 8/14 sctp: remove the typedef sctp_cwrhdr_t
This patch is to remove the typedef sctp_cwrhdr_t, and replace with struct sctp_cwrhdr in the places where it's using this typedef.
It is also to use sizeof(variable) instead of sizeof(type).
--- include/linux/sctp.h | 6 +++--- net/sctp/sm_make_chunk.c | 4 ++-- net/sctp/sm_statefuns.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-)
include/linux/sctp.h +3 -3
@@ -531,13 +531,13 @@ struct sctp_ecne_chunk {/* RFC 2960. Appendix A. Explicit Congestion Notification. * Congestion Window Reduced (CWR) (13) */ -typedef struct sctp_cwrhdr { +struct sctp_cwrhdr {__be32 lowest_tsn; -}sctp_cwrhdr_t ; +};typedef struct sctp_cwr_chunk {struct sctp_chunkhdr chunk_hdr; -sctp_cwrhdr_t cwr_hdr; +struct sctp_cwrhdr cwr_hdr; }sctp_cwr_chunk_t ;/* PR-SCTP
net/sctp/sm_make_chunk.c +2 -2
@@ -663,11 +663,11 @@ struct sctp_chunk *sctp_make_cwr(const struct sctp_association *asoc, const struct sctp_chunk *chunk) {struct sctp_chunk *retval; -sctp_cwrhdr_t cwr; +struct sctp_cwrhdr cwr; cwr.lowest_tsn =htonl (lowest_tsn); retval =sctp_make_control (asoc,SCTP_CID_ECN_CWR ,0 , -sizeof (sctp_cwrhdr_t),GFP_ATOMIC ); +sizeof (cwr),GFP_ATOMIC );if (!retval) goto nodata;
net/sctp/sm_statefuns.c +3 -3
@@ -2862,8 +2862,8 @@ sctp_disposition_t sctp_sf_do_ecn_cwr(struct net *net,void *arg, sctp_cmd_seq_t *commands) { - sctp_cwrhdr_t *cwr; struct sctp_chunk *chunk = arg; +struct sctp_cwrhdr *cwr;u32 lowest_tsn;if (!sctp_vtag_verify (chunk, asoc))
@@ -2873,8 +2873,8 @@ sctp_disposition_t sctp_sf_do_ecn_cwr(struct net *net,return sctp_sf_violation_chunklen (net, ep, asoc, type, arg, commands); - cwr = (sctp_cwrhdr_t *) chunk->skb->data; -skb_pull (chunk->skb,sizeof (sctp_cwrhdr_t)); + cwr = (struct sctp_cwrhdr *)chunk->skb->data; +skb_pull (chunk->skb,sizeof (*cwr)); lowest_tsn =ntohl (cwr->lowest_tsn);
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 9/14 sctp: remove the typedef sctp_cwr_chunk_t
Remove this typedef including the struct, there is even no places using it.
--- include/linux/sctp.h | 5 ----- 1 file changed, 5 deletions(-)
include/linux/sctp.h +0 -5
@@ -535,11 +535,6 @@ struct sctp_cwrhdr {__be32 lowest_tsn; }; -typedef struct sctp_cwr_chunk { -struct sctp_chunkhdr chunk_hdr; -struct sctp_cwrhdr cwr_hdr; -}sctp_cwr_chunk_t ; -/* PR-SCTP * 3.2 Forward Cumulative TSN Chunk Definition (FORWARD TSN) *
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 10/14 sctp: remove the typedef sctp_addip_param_t
This patch is to remove the typedef sctp_addip_param_t, and replace with struct sctp_addip_param in the places where it's using this typedef.
It is to use sizeof(variable) instead of sizeof(type), and also fix some indent problems.
--- include/linux/sctp.h | 8 ++++---- net/sctp/sm_make_chunk.c | 39 ++++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 23 deletions(-)
include/linux/sctp.h +4 -4
@@ -629,10 +629,10 @@ struct sctp_fwdtsn_chunk {* The ASCONF Parameter Response is used in the ASCONF-ACK to * report status of ASCONF processing. */ -typedef struct sctp_addip_param { -struct sctp_paramhdr param_hdr; -__be32 crr_id; -}sctp_addip_param_t ; +struct sctp_addip_param { +struct sctp_paramhdr param_hdr; +__be32 crr_id; +}; typedef struct sctp_addiphdr { __be32 serial;
net/sctp/sm_make_chunk.c +20 -19
@@ -2615,7 +2615,7 @@ static int sctp_process_param(struct sctp_association *asoc,if (!net->sctp.addip_enable) 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));if (af =NULL )
@@ -2810,7 +2810,7 @@ struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc, int addrcnt, __be16 flags) { -sctp_addip_param_t param; +struct sctp_addip_param param;struct sctp_chunk *retval;union sctp_addr_param addr_param;union sctp_addr *addr;
@@ -2896,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,union sctp_addr *addr) { -sctp_addip_param_t param; +struct sctp_addip_param param;struct sctp_chunk *retval;int len =sizeof (param);union sctp_addr_param addrparam;
@@ -2965,9 +2965,10 @@ static struct sctp_chunk *sctp_make_asconf_ack(const struct sctp_association *as/* Add response parameters to an ASCONF_ACK chunk. */ 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;struct sctp_errhdr err_param;int asconf_param_len =0 ;int err_param_len =0 ;
@@ -3006,15 +3007,15 @@ static void sctp_add_asconf_response(struct sctp_chunk *chunk, __be32 crr_id,/* Process a asconf parameter. */ static __be16 sctp_process_asconf_param (struct sctp_association *asoc, -struct sctp_chunk *asconf, -sctp_addip_param_t *asconf_param) +struct sctp_chunk *asconf, +struct sctp_addip_param *asconf_param) {struct sctp_transport *peer;struct sctp_af *af;union sctp_addr addr;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 && asconf_param->param_hdr.type != SCTP_PARAM_DEL_IP &&
@@ -3174,13 +3175,13 @@ bool sctp_verify_asconf(const struct sctp_association *asoc,if (addr_param_needed && !addr_param_seen)return false; length =ntohs (param.addip->param_hdr.length); -if (length <sizeof (sctp_addip_param_t) + +if (length <sizeof (struct sctp_addip_param ) +sizeof (**errp))return false;break ;case SCTP_PARAM_SUCCESS_REPORT :case SCTP_PARAM_ADAPTATION_LAYER_IND : -if (length !=sizeof (sctp_addip_param_t)) +if (length !=sizeof (struct sctp_addip_param ))return false;break ;default :
@@ -3289,7 +3290,7 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,/* Process a asconf parameter that is successfully acked. */ 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;union sctp_addr addr;
@@ -3298,7 +3299,7 @@ static void sctp_asconf_param_success(struct sctp_association *asoc,struct sctp_transport *transport;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. */ af =sctp_get_af_specific (param_type2af (addr_param->p.type));
@@ -3349,10 +3350,10 @@ static void sctp_asconf_param_success(struct sctp_association *asoc,* specific success indication is present for the parameter. */ static __be16 sctp_get_asconf_response (struct sctp_chunk *asconf_ack, -sctp_addip_param_t *asconf_param, -int no_err) +struct sctp_addip_param *asconf_param, +int no_err) { -sctp_addip_param_t *asconf_ack_param; +struct sctp_addip_param *asconf_ack_param;struct sctp_errhdr *err_param;int length;int asconf_ack_len;
@@ -3370,8 +3371,8 @@ static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack,* the first asconf_ack parameter. */ length =sizeof (sctp_addiphdr_t); - asconf_ack_param = (sctp_addip_param_t *)(asconf_ack->skb->data + - length); + asconf_ack_param = (struct sctp_addip_param *)(asconf_ack->skb->data + + length); asconf_ack_len -= length;while (asconf_ack_len >0 ) {
@@ -3380,7 +3381,7 @@ static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack,case SCTP_PARAM_SUCCESS_REPORT :return SCTP_ERROR_NO_ERROR ;case SCTP_PARAM_ERR_CAUSE : - length =sizeof (sctp_addip_param_t); + length =sizeof (*asconf_ack_param); err_param = (void *)asconf_ack_param + length; asconf_ack_len -= length;if (asconf_ack_len >0 )
@@ -3407,7 +3408,7 @@ int sctp_process_asconf_ack(struct sctp_association *asoc, {struct sctp_chunk *asconf = asoc->addip_last_asconf;union sctp_addr_param *addr_param; -sctp_addip_param_t *asconf_param; +struct sctp_addip_param *asconf_param;int length =0 ;int asconf_len = asconf->skb->len;int all_param_pass =0 ;
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 11/14 sctp: remove the typedef sctp_addiphdr_t
This patch is to remove the typedef sctp_addiphdr_t, and replace with struct sctp_addiphdr in the places where it's using this typedef.
It is also to use sizeof(variable) instead of sizeof(type).
--- include/linux/sctp.h | 6 +++--- net/sctp/sm_make_chunk.c | 14 +++++++------- net/sctp/sm_statefuns.c | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-)
include/linux/sctp.h +3 -3
@@ -634,14 +634,14 @@ struct sctp_addip_param {__be32 crr_id; }; -typedef struct sctp_addiphdr { +struct sctp_addiphdr {__be32 serial;__u8 params[0 ]; -}sctp_addiphdr_t ; +};typedef struct sctp_addip_chunk {struct sctp_chunkhdr chunk_hdr; -sctp_addiphdr_t addip_hdr; +struct sctp_addiphdr addip_hdr; }sctp_addip_chunk_t ;/* AUTH
net/sctp/sm_make_chunk.c +7 -7
@@ -2752,7 +2752,7 @@ static struct sctp_chunk *sctp_make_asconf(struct sctp_association *asoc, union sctp_addr *addr, int vparam_len) { -sctp_addiphdr_t asconf; +struct sctp_addiphdr asconf;struct sctp_chunk *retval;int length =sizeof (asconf) + vparam_len;union sctp_addr_param addrparam;
@@ -2945,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,__u32 serial,int vparam_len) { -sctp_addiphdr_t asconf; +struct sctp_addiphdr asconf;struct sctp_chunk *retval;int length =sizeof (asconf) + vparam_len;
@@ -3210,7 +3210,7 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,sctp_addip_chunk_t *addip = (sctp_addip_chunk_t *) asconf->chunk_hdr;bool all_param_pass = true;union sctp_params param; -sctp_addiphdr_t *hdr; +struct sctp_addiphdr *hdr;union sctp_addr_param *addr_param;struct sctp_chunk *asconf_ack;__be16 err_code;
@@ -3220,11 +3220,11 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc, chunk_len =ntohs (asconf->chunk_hdr->length) -sizeof (struct sctp_chunkhdr ); - hdr = (sctp_addiphdr_t *)asconf->skb->data; + hdr = (struct sctp_addiphdr *)asconf->skb->data; serial =ntohl (hdr->serial);/* 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); chunk_len -= length;
@@ -3370,7 +3370,7 @@ static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack,/* Skip the addiphdr from the asconf_ack chunk and store a pointer to * the first asconf_ack parameter. */ - length =sizeof (sctp_addiphdr_t); + length =sizeof (struct sctp_addiphdr ); asconf_ack_param = (struct sctp_addip_param *)(asconf_ack->skb->data + length); asconf_ack_len -= length;
@@ -3435,7 +3435,7 @@ int sctp_process_asconf_ack(struct sctp_association *asoc,* failures are indicated, then all request(s) are considered * successful. */ -if (asconf_ack->skb->len =sizeof (sctp_addiphdr_t)) +if (asconf_ack->skb->len =sizeof (struct sctp_addiphdr )) all_param_pass =1 ;/* Process the TLVs contained in the last sent ASCONF chunk. */
net/sctp/sm_statefuns.c +5 -5
@@ -3613,7 +3613,7 @@ sctp_disposition_t sctp_sf_do_asconf(struct net *net,struct sctp_chunk *chunk = arg;struct sctp_chunk *asconf_ack =NULL ;struct sctp_paramhdr *err_param =NULL ; -sctp_addiphdr_t *hdr; +struct sctp_addiphdr *hdr;__u32 serial;if (!sctp_vtag_verify (chunk, asoc)) {
@@ -3636,7 +3636,7 @@ sctp_disposition_t sctp_sf_do_asconf(struct net *net,return sctp_sf_violation_chunklen (net, ep, asoc, type, arg, commands); - hdr = (sctp_addiphdr_t *)chunk->skb->data; + hdr = (struct sctp_addiphdr *)chunk->skb->data; serial =ntohl (hdr->serial);/* Verify the ASCONF chunk before processing it. */
@@ -3730,7 +3730,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net,struct sctp_chunk *last_asconf = asoc->addip_last_asconf;struct sctp_chunk *abort;struct sctp_paramhdr *err_param =NULL ; -sctp_addiphdr_t *addip_hdr; +struct sctp_addiphdr *addip_hdr;__u32 sent_serial, rcvd_serial;if (!sctp_vtag_verify (asconf_ack, asoc)) {
@@ -3753,7 +3753,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net,return sctp_sf_violation_chunklen (net, ep, asoc, type, arg, 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);/* Verify the ASCONF-ACK chunk before processing it. */
@@ -3762,7 +3762,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net, (void *)err_param, commands);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); }else { sent_serial = asoc->addip_serial -1 ;
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 12/14 sctp: remove the typedef sctp_addip_chunk_t
This patch is to remove the typedef sctp_addip_chunk_t, and replace with struct sctp_addip_chunk in the places where it's using this typedef.
--- include/linux/sctp.h | 4 ++-- net/sctp/input.c | 2 +- net/sctp/sm_make_chunk.c | 8 +++++--- net/sctp/sm_statefuns.c | 11 +++++++---- 4 files changed, 15 insertions(+), 10 deletions(-)
include/linux/sctp.h +2 -2
@@ -639,10 +639,10 @@ struct sctp_addiphdr {__u8 params[0 ]; }; -typedef struct sctp_addip_chunk { +struct sctp_addip_chunk {struct sctp_chunkhdr chunk_hdr;struct sctp_addiphdr addip_hdr; -}sctp_addip_chunk_t ; +};/* AUTH * Section 4.1 Authentication Chunk (AUTH)
net/sctp/input.c +1 -1
@@ -1111,7 +1111,7 @@ static struct sctp_association *__sctp_rcv_asconf_lookup(__be16 peer_port, 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;union sctp_addr_param *param;union sctp_addr paddr;
net/sctp/sm_make_chunk.c +5 -3
@@ -3140,10 +3140,11 @@ bool sctp_verify_asconf(const struct sctp_association *asoc, struct sctp_chunk *chunk, bool addr_param_needed, 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;bool addr_param_seen = false; + addip = (struct sctp_addip_chunk *)chunk->chunk_hdr; sctp_walk_params(param, addip, addip_hdr.params) {size_t length =ntohs (param.p->length);
@@ -3207,7 +3208,7 @@ bool sctp_verify_asconf(const struct sctp_association *asoc,struct sctp_chunk *sctp_process_asconf (struct sctp_association *asoc,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;union sctp_params param;struct sctp_addiphdr *hdr;
@@ -3218,6 +3219,7 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,int chunk_len;__u32 serial; + addip = (struct sctp_addip_chunk *)asconf->chunk_hdr; chunk_len =ntohs (asconf->chunk_hdr->length) -sizeof (struct sctp_chunkhdr ); hdr = (struct sctp_addiphdr *)asconf->skb->data;
@@ -3419,7 +3421,7 @@ int sctp_process_asconf_ack(struct sctp_association *asoc,/* Skip the chunkhdr and addiphdr from the last asconf sent and store * 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); asconf_len -= length;
net/sctp/sm_statefuns.c +7 -4
@@ -3629,10 +3629,11 @@ sctp_disposition_t sctp_sf_do_asconf(struct net *net,* described in [I-D.ietf-tsvwg-sctp-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. */ -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, commands);
@@ -3746,10 +3747,12 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net,* described in [I-D.ietf-tsvwg-sctp-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. */ -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, commands);
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 13/14 sctp: remove the typedef sctp_authhdr_t
This patch is to remove the typedef sctp_authhdr_t, and replace with struct sctp_authhdr in the places where it's using this typedef.
It is also to use sizeof(variable) instead of sizeof(type).
--- include/linux/sctp.h | 6 +++--- net/sctp/sm_make_chunk.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-)
include/linux/sctp.h +3 -3
@@ -693,15 +693,15 @@ struct sctp_addip_chunk {* HMAC: n bytes (unsigned integer) This hold the result of the HMAC * calculation. */ -typedef struct sctp_authhdr { +struct sctp_authhdr {__be16 shkey_id;__be16 hmac_id;__u8 hmac[0 ]; -}sctp_authhdr_t ; +};typedef struct sctp_auth_chunk {struct sctp_chunkhdr chunk_hdr; -sctp_authhdr_t auth_hdr; +struct sctp_authhdr auth_hdr; }sctp_auth_chunk_t ;struct sctp_infox {
net/sctp/sm_make_chunk.c +4 -4
@@ -1282,16 +1282,16 @@ struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc)return NULL ; retval =sctp_make_control (asoc,SCTP_CID_AUTH ,0 , - hmac_desc->hmac_len +sizeof (sctp_authhdr_t), -GFP_ATOMIC ); + hmac_desc->hmac_len +sizeof (auth_hdr), +GFP_ATOMIC );if (!retval)return NULL ; auth_hdr.hmac_id =htons (hmac_desc->hmac_id); auth_hdr.shkey_id =htons (asoc->active_key_id); - retval->subh.auth_hdr =sctp_addto_chunk (retval,sizeof (sctp_authhdr_t), - &auth_hdr); + retval->subh.auth_hdr =sctp_addto_chunk (retval,sizeof (auth_hdr), + &auth_hdr); hmac =skb_put_zero (retval->skb, hmac_desc->hmac_len);
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 14/14 sctp: remove the typedef sctp_auth_chunk_t
This patch is to remove the typedef sctp_auth_chunk_t, and replace with struct sctp_auth_chunk in the places where it's using this typedef.
It is also to use sizeof(variable) instead of sizeof(type).
--- include/linux/sctp.h | 4 ++-- net/sctp/chunk.c | 2 +- net/sctp/sm_statefuns.c | 9 +++++---- 3 files changed, 8 insertions(+), 7 deletions(-)
include/linux/sctp.h +2 -2
@@ -699,10 +699,10 @@ struct sctp_authhdr {__u8 hmac[0 ]; }; -typedef struct sctp_auth_chunk { +struct sctp_auth_chunk {struct sctp_chunkhdr chunk_hdr;struct sctp_authhdr auth_hdr; -}sctp_auth_chunk_t ; +};struct sctp_infox {struct sctp_info *sctpinfo;
net/sctp/chunk.c +1 -1
@@ -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);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); }
net/sctp/sm_statefuns.c +5 -4
@@ -4093,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 */ auth_hdr = (struct sctp_authhdr *)chunk->skb->data; 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 * chunk.
@@ -4112,7 +4112,8 @@ static sctp_ierror_t sctp_sf_authenticate(struct net *net,/* Make sure that the length of the signature matches what * 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));if (sig_len != hmac->hmac_len)return SCTP_IERROR_PROTO_VIOLATION ;
@@ -4134,8 +4135,8 @@ static sctp_ierror_t sctp_sf_authenticate(struct net *net,memset (digest,0 , sig_len);sctp_auth_calculate_hmac (asoc, chunk->skb, - (struct sctp_auth_chunk *)chunk->chunk_hdr, -GFP_ATOMIC ); + (struct sctp_auth_chunk *)chunk->chunk_hdr, +GFP_ATOMIC );/* Discard the packet if the digests do not match */ if (memcmp (save_digest, digest, sig_len)) {
Signature · 1 line
2.1.0
David Miller
maintainerFrom: Xin Long <[email protected]>
Date: Thu, 3 Aug 2017 15:42:08 +0800
Quoted 9 lines
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 inlinux/sctp.h.Just as the part 1-3, No any code's logic would be changed in these patches, only cleaning up.
Series applied, thanks.