Skip to content

Commit

Permalink
sctp: remove the typedef sctp_chunkhdr_t
Browse files Browse the repository at this point in the history
This patch is to remove the typedef sctp_chunkhdr_t, and replace
with struct sctp_chunkhdr in the places where it's using this
typedef.

It is also to fix some indents and use sizeof(variable) instead
of sizeof(type)., especially in sctp_new.

Signed-off-by: Xin Long <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
lxin authored and davem330 committed Jul 1, 2017
1 parent ae146d9 commit 922dbc5
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 103 deletions.
34 changes: 17 additions & 17 deletions include/linux/sctp.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ static inline struct sctphdr *sctp_hdr(const struct sk_buff *skb)
}

/* Section 3.2. Chunk Field Descriptions. */
typedef struct sctp_chunkhdr {
struct sctp_chunkhdr {
__u8 type;
__u8 flags;
__be16 length;
} sctp_chunkhdr_t;
};


/* Section 3.2. Chunk Type Values.
Expand Down Expand Up @@ -236,8 +236,8 @@ typedef struct sctp_datahdr {
} sctp_datahdr_t;

typedef struct sctp_data_chunk {
sctp_chunkhdr_t chunk_hdr;
sctp_datahdr_t data_hdr;
struct sctp_chunkhdr chunk_hdr;
sctp_datahdr_t data_hdr;
} sctp_data_chunk_t;

/* DATA Chuck Specific Flags */
Expand Down Expand Up @@ -267,7 +267,7 @@ typedef struct sctp_inithdr {
} sctp_inithdr_t;

typedef struct sctp_init_chunk {
sctp_chunkhdr_t chunk_hdr;
struct sctp_chunkhdr chunk_hdr;
sctp_inithdr_t init_hdr;
} sctp_init_chunk_t;

Expand Down Expand Up @@ -386,7 +386,7 @@ typedef struct sctp_sackhdr {
} sctp_sackhdr_t;

typedef struct sctp_sack_chunk {
sctp_chunkhdr_t chunk_hdr;
struct sctp_chunkhdr chunk_hdr;
sctp_sackhdr_t sack_hdr;
} sctp_sack_chunk_t;

Expand All @@ -403,7 +403,7 @@ typedef struct sctp_heartbeathdr {
} sctp_heartbeathdr_t;

typedef struct sctp_heartbeat_chunk {
sctp_chunkhdr_t chunk_hdr;
struct sctp_chunkhdr chunk_hdr;
sctp_heartbeathdr_t hb_hdr;
} sctp_heartbeat_chunk_t;

Expand All @@ -413,7 +413,7 @@ typedef struct sctp_heartbeat_chunk {
* chunk descriptor.
*/
typedef struct sctp_abort_chunk {
sctp_chunkhdr_t uh;
struct sctp_chunkhdr uh;
} sctp_abort_chunk_t;


Expand All @@ -425,8 +425,8 @@ typedef struct sctp_shutdownhdr {
} sctp_shutdownhdr_t;

struct sctp_shutdown_chunk_t {
sctp_chunkhdr_t chunk_hdr;
sctp_shutdownhdr_t shutdown_hdr;
struct sctp_chunkhdr chunk_hdr;
sctp_shutdownhdr_t shutdown_hdr;
};

/* RFC 2960. Section 3.3.10 Operation Error (ERROR) (9) */
Expand All @@ -438,8 +438,8 @@ typedef struct sctp_errhdr {
} sctp_errhdr_t;

typedef struct sctp_operr_chunk {
sctp_chunkhdr_t chunk_hdr;
sctp_errhdr_t err_hdr;
struct sctp_chunkhdr chunk_hdr;
sctp_errhdr_t err_hdr;
} sctp_operr_chunk_t;

/* RFC 2960 3.3.10 - Operation Error
Expand Down Expand Up @@ -528,7 +528,7 @@ typedef struct sctp_ecnehdr {
} sctp_ecnehdr_t;

typedef struct sctp_ecne_chunk {
sctp_chunkhdr_t chunk_hdr;
struct sctp_chunkhdr chunk_hdr;
sctp_ecnehdr_t ence_hdr;
} sctp_ecne_chunk_t;

Expand All @@ -540,7 +540,7 @@ typedef struct sctp_cwrhdr {
} sctp_cwrhdr_t;

typedef struct sctp_cwr_chunk {
sctp_chunkhdr_t chunk_hdr;
struct sctp_chunkhdr chunk_hdr;
sctp_cwrhdr_t cwr_hdr;
} sctp_cwr_chunk_t;

Expand Down Expand Up @@ -649,7 +649,7 @@ typedef struct sctp_addiphdr {
} sctp_addiphdr_t;

typedef struct sctp_addip_chunk {
sctp_chunkhdr_t chunk_hdr;
struct sctp_chunkhdr chunk_hdr;
sctp_addiphdr_t addip_hdr;
} sctp_addip_chunk_t;

Expand Down Expand Up @@ -709,7 +709,7 @@ typedef struct sctp_authhdr {
} sctp_authhdr_t;

typedef struct sctp_auth_chunk {
sctp_chunkhdr_t chunk_hdr;
struct sctp_chunkhdr chunk_hdr;
sctp_authhdr_t auth_hdr;
} sctp_auth_chunk_t;

Expand All @@ -719,7 +719,7 @@ struct sctp_infox {
};

struct sctp_reconf_chunk {
sctp_chunkhdr_t chunk_hdr;
struct sctp_chunkhdr chunk_hdr;
__u8 params[0];
};

Expand Down
2 changes: 1 addition & 1 deletion include/net/sctp/sctp.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ _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 + \
sizeof(sctp_chunkhdr_t));\
sizeof(struct sctp_chunkhdr));\
(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))))
Expand Down
4 changes: 2 additions & 2 deletions net/netfilter/ipvs/ip_vs_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ static int ip_vs_out_icmp_v6(struct netns_ipvs *ipvs, struct sk_buff *skb,
*/
static inline int is_sctp_abort(const struct sk_buff *skb, int nh_len)
{
sctp_chunkhdr_t *sch, schunk;
struct sctp_chunkhdr *sch, schunk;
sch = skb_header_pointer(skb, nh_len + sizeof(struct sctphdr),
sizeof(schunk), &schunk);
if (sch == NULL)
Expand Down Expand Up @@ -1070,7 +1070,7 @@ static inline bool is_new_conn(const struct sk_buff *skb,
return th->syn;
}
case IPPROTO_SCTP: {
sctp_chunkhdr_t *sch, schunk;
struct sctp_chunkhdr *sch, schunk;

sch = skb_header_pointer(skb, iph->len + sizeof(struct sctphdr),
sizeof(schunk), &schunk);
Expand Down
6 changes: 3 additions & 3 deletions net/netfilter/ipvs/ip_vs_proto_sctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sctp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
struct ip_vs_iphdr *iph)
{
struct ip_vs_service *svc;
sctp_chunkhdr_t _schunkh, *sch;
struct sctp_chunkhdr _schunkh, *sch;
struct sctphdr *sh, _sctph;
__be16 _ports[2], *ports = NULL;

Expand Down Expand Up @@ -377,7 +377,7 @@ static inline void
set_sctp_state(struct ip_vs_proto_data *pd, struct ip_vs_conn *cp,
int direction, const struct sk_buff *skb)
{
sctp_chunkhdr_t _sctpch, *sch;
struct sctp_chunkhdr _sctpch, *sch;
unsigned char chunk_type;
int event, next_state;
int ihl, cofs;
Expand Down Expand Up @@ -409,7 +409,7 @@ set_sctp_state(struct ip_vs_proto_data *pd, struct ip_vs_conn *cp,
(sch->type == SCTP_CID_COOKIE_ACK)) {
int clen = ntohs(sch->length);

if (clen >= sizeof(sctp_chunkhdr_t)) {
if (clen >= sizeof(_sctpch)) {
sch = skb_header_pointer(skb, cofs + ALIGN(clen, 4),
sizeof(_sctpch), &_sctpch);
if (sch && sch->type == SCTP_CID_ABORT)
Expand Down
29 changes: 13 additions & 16 deletions net/netfilter/nf_conntrack_proto_sctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static int do_basic_checks(struct nf_conn *ct,
unsigned long *map)
{
u_int32_t offset, count;
sctp_chunkhdr_t _sch, *sch;
struct sctp_chunkhdr _sch, *sch;
int flag;

flag = 0;
Expand Down Expand Up @@ -397,7 +397,7 @@ static int sctp_packet(struct nf_conn *ct,
sch->type == SCTP_CID_INIT_ACK) {
sctp_inithdr_t _inithdr, *ih;

ih = skb_header_pointer(skb, offset + sizeof(sctp_chunkhdr_t),
ih = skb_header_pointer(skb, offset + sizeof(_sch),
sizeof(_inithdr), &_inithdr);
if (ih == NULL)
goto out_unlock;
Expand Down Expand Up @@ -471,23 +471,20 @@ static bool sctp_new(struct nf_conn *ct, const struct sk_buff *skb,

/* Copy the vtag into the state info */
if (sch->type == SCTP_CID_INIT) {
if (sh->vtag == 0) {
sctp_inithdr_t _inithdr, *ih;
sctp_inithdr_t _inithdr, *ih;
/* Sec 8.5.1 (A) */
if (sh->vtag)
return false;

ih = skb_header_pointer(skb, offset + sizeof(sctp_chunkhdr_t),
sizeof(_inithdr), &_inithdr);
if (ih == NULL)
return false;
ih = skb_header_pointer(skb, offset + sizeof(_sch),
sizeof(_inithdr), &_inithdr);
if (!ih)
return false;

pr_debug("Setting vtag %x for new conn\n",
ih->init_tag);
pr_debug("Setting vtag %x for new conn\n",
ih->init_tag);

ct->proto.sctp.vtag[IP_CT_DIR_REPLY] =
ih->init_tag;
} else {
/* Sec 8.5.1 (A) */
return false;
}
ct->proto.sctp.vtag[IP_CT_DIR_REPLY] = ih->init_tag;
} else if (sch->type == SCTP_CID_HEARTBEAT) {
pr_debug("Setting vtag %x for secondary conntrack\n",
sh->vtag);
Expand Down
4 changes: 2 additions & 2 deletions net/netfilter/xt_sctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ match_packet(const struct sk_buff *skb,
bool *hotdrop)
{
u_int32_t chunkmapcopy[256 / sizeof (u_int32_t)];
const sctp_chunkhdr_t *sch;
sctp_chunkhdr_t _sch;
const struct sctp_chunkhdr *sch;
struct sctp_chunkhdr _sch;
int chunk_match_type = info->chunk_match_type;
const struct xt_sctp_flag_info *flag_info = info->flag_info;
int flag_count = info->flag_count;
Expand Down
20 changes: 10 additions & 10 deletions net/sctp/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,19 +663,19 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
*/
static int sctp_rcv_ootb(struct sk_buff *skb)
{
sctp_chunkhdr_t *ch, _ch;
struct sctp_chunkhdr *ch, _ch;
int ch_end, offset = 0;

/* Scan through all the chunks in the packet. */
do {
/* Make sure we have at least the header there */
if (offset + sizeof(sctp_chunkhdr_t) > skb->len)
if (offset + sizeof(_ch) > skb->len)
break;

ch = skb_header_pointer(skb, offset, sizeof(*ch), &_ch);

/* Break out if chunk length is less then minimal. */
if (ntohs(ch->length) < sizeof(sctp_chunkhdr_t))
if (ntohs(ch->length) < sizeof(_ch))
break;

ch_end = offset + SCTP_PAD4(ntohs(ch->length));
Expand Down Expand Up @@ -1106,7 +1106,7 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct net *net,
*/
static struct sctp_association *__sctp_rcv_asconf_lookup(
struct net *net,
sctp_chunkhdr_t *ch,
struct sctp_chunkhdr *ch,
const union sctp_addr *laddr,
__be16 peer_port,
struct sctp_transport **transportp)
Expand Down Expand Up @@ -1144,18 +1144,18 @@ static struct sctp_association *__sctp_rcv_walk_lookup(struct net *net,
struct sctp_transport **transportp)
{
struct sctp_association *asoc = NULL;
sctp_chunkhdr_t *ch;
struct sctp_chunkhdr *ch;
int have_auth = 0;
unsigned int chunk_num = 1;
__u8 *ch_end;

/* Walk through the chunks looking for AUTH or ASCONF chunks
* to help us find the association.
*/
ch = (sctp_chunkhdr_t *) skb->data;
ch = (struct sctp_chunkhdr *)skb->data;
do {
/* Break out if chunk length is less then minimal. */
if (ntohs(ch->length) < sizeof(sctp_chunkhdr_t))
if (ntohs(ch->length) < sizeof(*ch))
break;

ch_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length));
Expand Down Expand Up @@ -1192,7 +1192,7 @@ static struct sctp_association *__sctp_rcv_walk_lookup(struct net *net,
if (asoc)
break;

ch = (sctp_chunkhdr_t *) ch_end;
ch = (struct sctp_chunkhdr *)ch_end;
chunk_num++;
} while (ch_end < skb_tail_pointer(skb));

Expand All @@ -1210,7 +1210,7 @@ static struct sctp_association *__sctp_rcv_lookup_harder(struct net *net,
const union sctp_addr *laddr,
struct sctp_transport **transportp)
{
sctp_chunkhdr_t *ch;
struct sctp_chunkhdr *ch;

/* We do not allow GSO frames here as we need to linearize and
* then cannot guarantee frame boundaries. This shouldn't be an
Expand All @@ -1220,7 +1220,7 @@ static struct sctp_association *__sctp_rcv_lookup_harder(struct net *net,
if ((skb_shinfo(skb)->gso_type & SKB_GSO_SCTP) == SKB_GSO_SCTP)
return NULL;

ch = (sctp_chunkhdr_t *) skb->data;
ch = (struct sctp_chunkhdr *)skb->data;

/* The code below will attempt to walk the chunk and extract
* parameter information. Before we do that, we need to verify
Expand Down
15 changes: 7 additions & 8 deletions net/sctp/inqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void sctp_inq_push(struct sctp_inq *q, struct sctp_chunk *chunk)
struct sctp_chunkhdr *sctp_inq_peek(struct sctp_inq *queue)
{
struct sctp_chunk *chunk;
sctp_chunkhdr_t *ch = NULL;
struct sctp_chunkhdr *ch = NULL;

chunk = queue->in_progress;
/* If there is no more chunks in this packet, say so */
Expand All @@ -108,7 +108,7 @@ struct sctp_chunkhdr *sctp_inq_peek(struct sctp_inq *queue)
chunk->pdiscard)
return NULL;

ch = (sctp_chunkhdr_t *)chunk->chunk_end;
ch = (struct sctp_chunkhdr *)chunk->chunk_end;

return ch;
}
Expand All @@ -122,7 +122,7 @@ struct sctp_chunkhdr *sctp_inq_peek(struct sctp_inq *queue)
struct sctp_chunk *sctp_inq_pop(struct sctp_inq *queue)
{
struct sctp_chunk *chunk;
sctp_chunkhdr_t *ch = NULL;
struct sctp_chunkhdr *ch = NULL;

/* The assumption is that we are safe to process the chunks
* at this time.
Expand Down Expand Up @@ -151,7 +151,7 @@ struct sctp_chunk *sctp_inq_pop(struct sctp_inq *queue)
chunk = queue->in_progress = NULL;
} else {
/* Nothing to do. Next chunk in the packet, please. */
ch = (sctp_chunkhdr_t *) chunk->chunk_end;
ch = (struct sctp_chunkhdr *)chunk->chunk_end;
/* Force chunk->skb->data to chunk->chunk_end. */
skb_pull(chunk->skb, chunk->chunk_end - chunk->skb->data);
/* We are guaranteed to pull a SCTP header. */
Expand Down Expand Up @@ -195,7 +195,7 @@ struct sctp_chunk *sctp_inq_pop(struct sctp_inq *queue)

new_skb:
/* This is the first chunk in the packet. */
ch = (sctp_chunkhdr_t *) chunk->skb->data;
ch = (struct sctp_chunkhdr *)chunk->skb->data;
chunk->singleton = 1;
chunk->data_accepted = 0;
chunk->pdiscard = 0;
Expand All @@ -214,11 +214,10 @@ struct sctp_chunk *sctp_inq_pop(struct sctp_inq *queue)

chunk->chunk_hdr = ch;
chunk->chunk_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length));
skb_pull(chunk->skb, sizeof(sctp_chunkhdr_t));
skb_pull(chunk->skb, sizeof(*ch));
chunk->subh.v = NULL; /* Subheader is no longer valid. */

if (chunk->chunk_end + sizeof(sctp_chunkhdr_t) <
skb_tail_pointer(chunk->skb)) {
if (chunk->chunk_end + sizeof(*ch) < skb_tail_pointer(chunk->skb)) {
/* This is not a singleton */
chunk->singleton = 0;
} else if (chunk->chunk_end > skb_tail_pointer(chunk->skb)) {
Expand Down
Loading

0 comments on commit 922dbc5

Please sign in to comment.