diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-04-16 02:45:30 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-04-16 02:45:30 +0200 |
commit | 7b16ee53178b21b55591ccb1ca01ee141dcfdaf3 (patch) | |
tree | 8c51dded3b0cc649d4b5feb8695b43a2d77bafdf /src/send.c | |
parent | 0b12a85f27e9a41f8fd10536ebd23768f0d97519 (diff) |
send: simplify skb_padding with nice macro
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/send.c')
-rw-r--r-- | src/send.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -112,12 +112,11 @@ static inline void keep_key_fresh(struct wireguard_peer *peer) 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. Since we support GSO, this - * isn't strictly neccessary, but it's better to be cautious here, especially - * if that code ever changes. + * gives us a packet that's bigger than the MTU. In that case, we wouldn't want + * the final subtraction to overflow in the case of the padded_size being clamped. */ unsigned int last_unit = skb->len % PACKET_CB(skb)->mtu; - unsigned int padded_size = (last_unit + MESSAGE_PADDING_MULTIPLE - 1) & ~(MESSAGE_PADDING_MULTIPLE - 1); + unsigned int padded_size = ALIGN(last_unit, MESSAGE_PADDING_MULTIPLE); if (padded_size > PACKET_CB(skb)->mtu) padded_size = PACKET_CB(skb)->mtu; |