summaryrefslogtreecommitdiffhomepage
path: root/src/send.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/send.c')
-rw-r--r--src/send.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/send.c b/src/send.c
index 9c9f694..9b1aec0 100644
--- a/src/send.c
+++ b/src/send.c
@@ -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;