diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-11-04 12:42:38 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-11-04 12:54:26 +0100 |
commit | 8a2b7ee86336e428653436b1e79ed6c4f134ed4b (patch) | |
tree | 178db8296aeed023dd680ff4b7fab6a93ab2f471 | |
parent | data: take reference to peer (diff) | |
download | wireguard-monolithic-historical-8a2b7ee86336e428653436b1e79ed6c4f134ed4b.tar.xz wireguard-monolithic-historical-8a2b7ee86336e428653436b1e79ed6c4f134ed4b.zip |
data: use smaller types
-rw-r--r-- | src/data.c | 12 | ||||
-rw-r--r-- | src/packets.h | 4 |
2 files changed, 8 insertions, 8 deletions
@@ -48,13 +48,13 @@ out: } #include "selftest/counter.h" -static inline size_t skb_padding(struct sk_buff *skb) +static inline unsigned int skb_padding(struct sk_buff *skb) { /* We do this modulo business with the MTU, just in case the networking layer * gives us a packet that's bigger than the MTU. Now that we support GSO, this * shouldn't be a real problem, and this can likely be removed. But, caution! */ - size_t last_unit = skb->len % skb->dev->mtu; - size_t padded_size = (last_unit + MESSAGE_PADDING_MULTIPLE - 1) & ~(MESSAGE_PADDING_MULTIPLE - 1); + unsigned int last_unit = skb->len % skb->dev->mtu; + unsigned int padded_size = (last_unit + MESSAGE_PADDING_MULTIPLE - 1) & ~(MESSAGE_PADDING_MULTIPLE - 1); if (padded_size > skb->dev->mtu) padded_size = skb->dev->mtu; return padded_size - last_unit; @@ -100,7 +100,7 @@ static inline void skb_encrypt(struct sk_buff *skb, struct packet_data_encryptio noise_keypair_put(ctx->keypair); } -static inline bool skb_decrypt(struct sk_buff *skb, unsigned int num_frags, uint64_t nonce, struct noise_symmetric_key *key) +static inline bool skb_decrypt(struct sk_buff *skb, uint8_t num_frags, uint64_t nonce, struct noise_symmetric_key *key) { struct scatterlist sg[num_frags]; /* This should be bound to at most 128 by the caller. */ @@ -188,7 +188,7 @@ int packet_create_data(struct sk_buff *skb, struct wireguard_peer *peer, void(*c struct packet_data_encryption_ctx *ctx = NULL; u64 nonce; struct sk_buff *trailer = NULL; - size_t plaintext_len, padding_len, trailer_len; + unsigned int plaintext_len, padding_len, trailer_len; unsigned int num_frags; rcu_read_lock(); @@ -269,7 +269,7 @@ struct packet_data_decryption_ctx { struct noise_keypair *keypair; struct sockaddr_storage addr; uint64_t nonce; - unsigned int num_frags; + uint8_t num_frags; int ret; }; diff --git a/src/packets.h b/src/packets.h index 035c548..a8ecdf1 100644 --- a/src/packets.h +++ b/src/packets.h @@ -44,8 +44,8 @@ struct packet_data_encryption_ctx { struct sk_buff *skb; void (*callback)(struct sk_buff *, struct wireguard_peer *); struct wireguard_peer *peer; - size_t plaintext_len, trailer_len; - unsigned int num_frags; + unsigned int plaintext_len, trailer_len; + uint8_t num_frags; struct sk_buff *trailer; struct noise_keypair *keypair; uint64_t nonce; |