Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sctp: rename WORD_TRUNC/ROUND macros

To something more meaningful these days, specially because this is
working on packet headers or lengths and which are not tied to any CPU
arch but to the protocol itself.

So, WORD_TRUNC becomes SCTP_TRUNC4 and WORD_ROUND becomes SCTP_PAD4.

Reported-by: David Laight <David.Laight@ACULAB.COM>
Reported-by: David Miller <davem@davemloft.net>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Marcelo Ricardo Leitner and committed by
David S. Miller
e2f036a9 b80b8d7a

+42 -42
+5 -5
include/net/sctp/sctp.h
··· 83 83 #endif 84 84 85 85 /* Round an int up to the next multiple of 4. */ 86 - #define WORD_ROUND(s) (((s)+3)&~3) 86 + #define SCTP_PAD4(s) (((s)+3)&~3) 87 87 /* Truncate to the previous multiple of 4. */ 88 - #define WORD_TRUNC(s) ((s)&~3) 88 + #define SCTP_TRUNC4(s) ((s)&~3) 89 89 90 90 /* 91 91 * Function declarations. ··· 433 433 if (asoc->user_frag) 434 434 frag = min_t(int, frag, asoc->user_frag); 435 435 436 - frag = WORD_TRUNC(min_t(int, frag, SCTP_MAX_CHUNK_LEN)); 436 + frag = SCTP_TRUNC4(min_t(int, frag, SCTP_MAX_CHUNK_LEN)); 437 437 438 438 return frag; 439 439 } ··· 462 462 for (pos.v = chunk->member;\ 463 463 pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\ 464 464 ntohs(pos.p->length) >= sizeof(sctp_paramhdr_t);\ 465 - pos.v += WORD_ROUND(ntohs(pos.p->length))) 465 + pos.v += SCTP_PAD4(ntohs(pos.p->length))) 466 466 467 467 #define sctp_walk_errors(err, chunk_hdr)\ 468 468 _sctp_walk_errors((err), (chunk_hdr), ntohs((chunk_hdr)->length)) ··· 472 472 sizeof(sctp_chunkhdr_t));\ 473 473 (void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\ 474 474 ntohs(err->length) >= sizeof(sctp_errhdr_t); \ 475 - err = (sctp_errhdr_t *)((void *)err + WORD_ROUND(ntohs(err->length)))) 475 + err = (sctp_errhdr_t *)((void *)err + SCTP_PAD4(ntohs(err->length)))) 476 476 477 477 #define sctp_walk_fwdtsn(pos, chunk)\ 478 478 _sctp_walk_fwdtsn((pos), (chunk), ntohs((chunk)->chunk_hdr->length) - sizeof(struct sctp_fwdtsn_chunk))
+1 -1
net/netfilter/xt_sctp.c
··· 68 68 ++i, offset, sch->type, htons(sch->length), 69 69 sch->flags); 70 70 #endif 71 - offset += WORD_ROUND(ntohs(sch->length)); 71 + offset += SCTP_PAD4(ntohs(sch->length)); 72 72 73 73 pr_debug("skb->len: %d\toffset: %d\n", skb->len, offset); 74 74
+1 -1
net/sctp/associola.c
··· 1408 1408 transports) { 1409 1409 if (t->pmtu_pending && t->dst) { 1410 1410 sctp_transport_update_pmtu(sk, t, 1411 - WORD_TRUNC(dst_mtu(t->dst))); 1411 + SCTP_TRUNC4(dst_mtu(t->dst))); 1412 1412 t->pmtu_pending = 0; 1413 1413 } 1414 1414 if (!pmtu || (t->pathmtu < pmtu))
+3 -3
net/sctp/chunk.c
··· 208 208 struct sctp_hmac *hmac_desc = sctp_auth_asoc_get_hmac(asoc); 209 209 210 210 if (hmac_desc) 211 - max_data -= WORD_ROUND(sizeof(sctp_auth_chunk_t) + 212 - hmac_desc->hmac_len); 211 + max_data -= SCTP_PAD4(sizeof(sctp_auth_chunk_t) + 212 + hmac_desc->hmac_len); 213 213 } 214 214 215 215 /* Now, check if we need to reduce our max */ ··· 229 229 asoc->outqueue.out_qlen == 0 && 230 230 list_empty(&asoc->outqueue.retransmit) && 231 231 msg_len > max) 232 - max_data -= WORD_ROUND(sizeof(sctp_sack_chunk_t)); 232 + max_data -= SCTP_PAD4(sizeof(sctp_sack_chunk_t)); 233 233 234 234 /* Encourage Cookie-ECHO bundling. */ 235 235 if (asoc->state < SCTP_STATE_COOKIE_ECHOED)
+4 -4
net/sctp/input.c
··· 605 605 /* PMTU discovery (RFC1191) */ 606 606 if (ICMP_FRAG_NEEDED == code) { 607 607 sctp_icmp_frag_needed(sk, asoc, transport, 608 - WORD_TRUNC(info)); 608 + SCTP_TRUNC4(info)); 609 609 goto out_unlock; 610 610 } else { 611 611 if (ICMP_PROT_UNREACH == code) { ··· 673 673 if (ntohs(ch->length) < sizeof(sctp_chunkhdr_t)) 674 674 break; 675 675 676 - ch_end = offset + WORD_ROUND(ntohs(ch->length)); 676 + ch_end = offset + SCTP_PAD4(ntohs(ch->length)); 677 677 if (ch_end > skb->len) 678 678 break; 679 679 ··· 1121 1121 if (ntohs(ch->length) < sizeof(sctp_chunkhdr_t)) 1122 1122 break; 1123 1123 1124 - ch_end = ((__u8 *)ch) + WORD_ROUND(ntohs(ch->length)); 1124 + ch_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length)); 1125 1125 if (ch_end > skb_tail_pointer(skb)) 1126 1126 break; 1127 1127 ··· 1190 1190 * that the chunk length doesn't cause overflow. Otherwise, we'll 1191 1191 * walk off the end. 1192 1192 */ 1193 - if (WORD_ROUND(ntohs(ch->length)) > skb->len) 1193 + if (SCTP_PAD4(ntohs(ch->length)) > skb->len) 1194 1194 return NULL; 1195 1195 1196 1196 /* If this is INIT/INIT-ACK look inside the chunk too. */
+1 -1
net/sctp/inqueue.c
··· 213 213 } 214 214 215 215 chunk->chunk_hdr = ch; 216 - chunk->chunk_end = ((__u8 *)ch) + WORD_ROUND(ntohs(ch->length)); 216 + chunk->chunk_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length)); 217 217 skb_pull(chunk->skb, sizeof(sctp_chunkhdr_t)); 218 218 chunk->subh.v = NULL; /* Subheader is no longer valid. */ 219 219
+6 -6
net/sctp/output.c
··· 297 297 struct sctp_chunk *chunk) 298 298 { 299 299 sctp_xmit_t retval = SCTP_XMIT_OK; 300 - __u16 chunk_len = WORD_ROUND(ntohs(chunk->chunk_hdr->length)); 300 + __u16 chunk_len = SCTP_PAD4(ntohs(chunk->chunk_hdr->length)); 301 301 302 302 /* Check to see if this chunk will fit into the packet */ 303 303 retval = sctp_packet_will_fit(packet, chunk, chunk_len); ··· 508 508 if (gso) { 509 509 pkt_size = packet->overhead; 510 510 list_for_each_entry(chunk, &packet->chunk_list, list) { 511 - int padded = WORD_ROUND(chunk->skb->len); 511 + int padded = SCTP_PAD4(chunk->skb->len); 512 512 513 513 if (pkt_size + padded > tp->pathmtu) 514 514 break; ··· 538 538 * included in the chunk length field. The sender should 539 539 * never pad with more than 3 bytes. 540 540 * 541 - * [This whole comment explains WORD_ROUND() below.] 541 + * [This whole comment explains SCTP_PAD4() below.] 542 542 */ 543 543 544 544 pkt_size -= packet->overhead; ··· 560 560 has_data = 1; 561 561 } 562 562 563 - padding = WORD_ROUND(chunk->skb->len) - chunk->skb->len; 563 + padding = SCTP_PAD4(chunk->skb->len) - chunk->skb->len; 564 564 if (padding) 565 565 memset(skb_put(chunk->skb, padding), 0, padding); 566 566 ··· 587 587 * acknowledged or have failed. 588 588 * Re-queue auth chunks if needed. 589 589 */ 590 - pkt_size -= WORD_ROUND(chunk->skb->len); 590 + pkt_size -= SCTP_PAD4(chunk->skb->len); 591 591 592 592 if (!sctp_chunk_is_data(chunk) && chunk != packet->auth) 593 593 sctp_chunk_free(chunk); ··· 911 911 */ 912 912 maxsize = pmtu - packet->overhead; 913 913 if (packet->auth) 914 - maxsize -= WORD_ROUND(packet->auth->skb->len); 914 + maxsize -= SCTP_PAD4(packet->auth->skb->len); 915 915 if (chunk_len > maxsize) 916 916 retval = SCTP_XMIT_PMTU_FULL; 917 917
+14 -14
net/sctp/sm_make_chunk.c
··· 253 253 num_types = sp->pf->supported_addrs(sp, types); 254 254 255 255 chunksize = sizeof(init) + addrs_len; 256 - chunksize += WORD_ROUND(SCTP_SAT_LEN(num_types)); 256 + chunksize += SCTP_PAD4(SCTP_SAT_LEN(num_types)); 257 257 chunksize += sizeof(ecap_param); 258 258 259 259 if (asoc->prsctp_enable) ··· 283 283 /* Add HMACS parameter length if any were defined */ 284 284 auth_hmacs = (sctp_paramhdr_t *)asoc->c.auth_hmacs; 285 285 if (auth_hmacs->length) 286 - chunksize += WORD_ROUND(ntohs(auth_hmacs->length)); 286 + chunksize += SCTP_PAD4(ntohs(auth_hmacs->length)); 287 287 else 288 288 auth_hmacs = NULL; 289 289 290 290 /* Add CHUNKS parameter length */ 291 291 auth_chunks = (sctp_paramhdr_t *)asoc->c.auth_chunks; 292 292 if (auth_chunks->length) 293 - chunksize += WORD_ROUND(ntohs(auth_chunks->length)); 293 + chunksize += SCTP_PAD4(ntohs(auth_chunks->length)); 294 294 else 295 295 auth_chunks = NULL; 296 296 ··· 300 300 301 301 /* If we have any extensions to report, account for that */ 302 302 if (num_ext) 303 - chunksize += WORD_ROUND(sizeof(sctp_supported_ext_param_t) + 304 - num_ext); 303 + chunksize += SCTP_PAD4(sizeof(sctp_supported_ext_param_t) + 304 + num_ext); 305 305 306 306 /* RFC 2960 3.3.2 Initiation (INIT) (1) 307 307 * ··· 443 443 444 444 auth_hmacs = (sctp_paramhdr_t *)asoc->c.auth_hmacs; 445 445 if (auth_hmacs->length) 446 - chunksize += WORD_ROUND(ntohs(auth_hmacs->length)); 446 + chunksize += SCTP_PAD4(ntohs(auth_hmacs->length)); 447 447 else 448 448 auth_hmacs = NULL; 449 449 450 450 auth_chunks = (sctp_paramhdr_t *)asoc->c.auth_chunks; 451 451 if (auth_chunks->length) 452 - chunksize += WORD_ROUND(ntohs(auth_chunks->length)); 452 + chunksize += SCTP_PAD4(ntohs(auth_chunks->length)); 453 453 else 454 454 auth_chunks = NULL; 455 455 ··· 458 458 } 459 459 460 460 if (num_ext) 461 - chunksize += WORD_ROUND(sizeof(sctp_supported_ext_param_t) + 462 - num_ext); 461 + chunksize += SCTP_PAD4(sizeof(sctp_supported_ext_param_t) + 462 + num_ext); 463 463 464 464 /* Now allocate and fill out the chunk. */ 465 465 retval = sctp_make_control(asoc, SCTP_CID_INIT_ACK, 0, chunksize, gfp); ··· 1390 1390 struct sock *sk; 1391 1391 1392 1392 /* No need to allocate LL here, as this is only a chunk. */ 1393 - skb = alloc_skb(WORD_ROUND(sizeof(sctp_chunkhdr_t) + paylen), gfp); 1393 + skb = alloc_skb(SCTP_PAD4(sizeof(sctp_chunkhdr_t) + paylen), gfp); 1394 1394 if (!skb) 1395 1395 goto nodata; 1396 1396 ··· 1482 1482 void *target; 1483 1483 void *padding; 1484 1484 int chunklen = ntohs(chunk->chunk_hdr->length); 1485 - int padlen = WORD_ROUND(chunklen) - chunklen; 1485 + int padlen = SCTP_PAD4(chunklen) - chunklen; 1486 1486 1487 1487 padding = skb_put(chunk->skb, padlen); 1488 1488 target = skb_put(chunk->skb, len); ··· 1900 1900 struct __sctp_missing report; 1901 1901 __u16 len; 1902 1902 1903 - len = WORD_ROUND(sizeof(report)); 1903 + len = SCTP_PAD4(sizeof(report)); 1904 1904 1905 1905 /* Make an ERROR chunk, preparing enough room for 1906 1906 * returning multiple unknown parameters. ··· 2098 2098 2099 2099 if (*errp) { 2100 2100 if (!sctp_init_cause_fixed(*errp, SCTP_ERROR_UNKNOWN_PARAM, 2101 - WORD_ROUND(ntohs(param.p->length)))) 2101 + SCTP_PAD4(ntohs(param.p->length)))) 2102 2102 sctp_addto_chunk_fixed(*errp, 2103 - WORD_ROUND(ntohs(param.p->length)), 2103 + SCTP_PAD4(ntohs(param.p->length)), 2104 2104 param.v); 2105 2105 } else { 2106 2106 /* If there is no memory for generating the ERROR
+3 -3
net/sctp/sm_statefuns.c
··· 3454 3454 } 3455 3455 3456 3456 /* Report violation if chunk len overflows */ 3457 - ch_end = ((__u8 *)ch) + WORD_ROUND(ntohs(ch->length)); 3457 + ch_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length)); 3458 3458 if (ch_end > skb_tail_pointer(skb)) 3459 3459 return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, 3460 3460 commands); ··· 4185 4185 hdr = unk_chunk->chunk_hdr; 4186 4186 err_chunk = sctp_make_op_error(asoc, unk_chunk, 4187 4187 SCTP_ERROR_UNKNOWN_CHUNK, hdr, 4188 - WORD_ROUND(ntohs(hdr->length)), 4188 + SCTP_PAD4(ntohs(hdr->length)), 4189 4189 0); 4190 4190 if (err_chunk) { 4191 4191 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, ··· 4203 4203 hdr = unk_chunk->chunk_hdr; 4204 4204 err_chunk = sctp_make_op_error(asoc, unk_chunk, 4205 4205 SCTP_ERROR_UNKNOWN_CHUNK, hdr, 4206 - WORD_ROUND(ntohs(hdr->length)), 4206 + SCTP_PAD4(ntohs(hdr->length)), 4207 4207 0); 4208 4208 if (err_chunk) { 4209 4209 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
+2 -2
net/sctp/transport.c
··· 233 233 } 234 234 235 235 if (transport->dst) { 236 - transport->pathmtu = WORD_TRUNC(dst_mtu(transport->dst)); 236 + transport->pathmtu = SCTP_TRUNC4(dst_mtu(transport->dst)); 237 237 } else 238 238 transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT; 239 239 } ··· 287 287 return; 288 288 } 289 289 if (transport->dst) { 290 - transport->pathmtu = WORD_TRUNC(dst_mtu(transport->dst)); 290 + transport->pathmtu = SCTP_TRUNC4(dst_mtu(transport->dst)); 291 291 292 292 /* Initialize sk->sk_rcv_saddr, if the transport is the 293 293 * association's active path for getsockname().
+2 -2
net/sctp/ulpevent.c
··· 383 383 384 384 ch = (sctp_errhdr_t *)(chunk->skb->data); 385 385 cause = ch->cause; 386 - elen = WORD_ROUND(ntohs(ch->length)) - sizeof(sctp_errhdr_t); 386 + elen = SCTP_PAD4(ntohs(ch->length)) - sizeof(sctp_errhdr_t); 387 387 388 388 /* Pull off the ERROR header. */ 389 389 skb_pull(chunk->skb, sizeof(sctp_errhdr_t)); ··· 688 688 * MUST ignore the padding bytes. 689 689 */ 690 690 len = ntohs(chunk->chunk_hdr->length); 691 - padding = WORD_ROUND(len) - len; 691 + padding = SCTP_PAD4(len) - len; 692 692 693 693 /* Fixup cloned skb with just this chunks data. */ 694 694 skb_trim(skb, chunk->chunk_end - padding - skb->data);