diff options
author | Matteo Croce <mcroce@redhat.com> | 2019-05-29 17:39:41 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-05-30 14:35:44 -0700 |
commit | c3e933a5b8c19145d14e207e0ecf220f1d6cfda1 (patch) | |
tree | 4e69ae36c4ebaf5489da91f29ce912eae8e7992b /include/net/sctp | |
parent | 2544af0344bae65c51e350663ce95110445d7ec8 (diff) | |
download | linux-c3e933a5b8c19145d14e207e0ecf220f1d6cfda1.tar.bz2 |
sctp: deduplicate identical skb_checksum_ops
The same skb_checksum_ops struct is defined twice in two different places,
leading to code duplication. Declare it as a global variable into a common
header instead of allocating it on the stack on each function call.
bloat-o-meter reports a slight code shrink.
add/remove: 1/1 grow/shrink: 0/10 up/down: 128/-1282 (-1154)
Function old new delta
sctp_csum_ops - 128 +128
crc32c_csum_ops 16 - -16
sctp_rcv 6616 6583 -33
sctp_packet_pack 4542 4504 -38
nf_conntrack_sctp_packet 4980 4926 -54
execute_masked_set_action 6453 6389 -64
tcf_csum_sctp 575 428 -147
sctp_gso_segment 1292 1126 -166
sctp_csum_check 579 412 -167
sctp_snat_handler 957 772 -185
sctp_dnat_handler 1321 1132 -189
l4proto_manip_pkt 2536 2313 -223
Total: Before=359297613, After=359296459, chg -0.00%
Reviewed-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Matteo Croce <mcroce@redhat.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/sctp')
-rw-r--r-- | include/net/sctp/checksum.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h index 1c6e6c0766ca..1b74af2477d1 100644 --- a/include/net/sctp/checksum.h +++ b/include/net/sctp/checksum.h @@ -58,19 +58,21 @@ static inline __wsum sctp_csum_combine(__wsum csum, __wsum csum2, (__force __u32)csum2, len); } +static const struct skb_checksum_ops sctp_csum_ops = { + .update = sctp_csum_update, + .combine = sctp_csum_combine, +}; + static inline __le32 sctp_compute_cksum(const struct sk_buff *skb, unsigned int offset) { struct sctphdr *sh = (struct sctphdr *)(skb->data + offset); - const struct skb_checksum_ops ops = { - .update = sctp_csum_update, - .combine = sctp_csum_combine, - }; __le32 old = sh->checksum; __wsum new; sh->checksum = 0; - new = ~__skb_checksum(skb, offset, skb->len - offset, ~(__wsum)0, &ops); + new = ~__skb_checksum(skb, offset, skb->len - offset, ~(__wsum)0, + &sctp_csum_ops); sh->checksum = old; return cpu_to_le32((__force __u32)new); |