aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/device.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-04-14 05:27:19 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-04-15 15:45:13 +0200
commita1525bfdccc7fabf35c6c538409e4de4c4812169 (patch)
tree81427f89c2bbf51aef4cde1e873c66a509851c28 /src/device.c
parentwg-quick: account for specified fwmark in auto routing mode (diff)
downloadwireguard-monolithic-historical-a1525bfdccc7fabf35c6c538409e4de4c4812169.tar.xz
wireguard-monolithic-historical-a1525bfdccc7fabf35c6c538409e4de4c4812169.zip
send: account for route-based MTU
It might be that a particular route has a different MTU than the interface, via `ip route add ... dev wg0 mtu 1281`, for example. In this case, it's important that we don't accidently pad beyond the end of the MTU. We accomplish that in this patch by carrying forward the MTU from the dst if it exists. We also add a unit test for this issue. Reported-by: Roman Mamedov <rm.wg@romanrm.net>
Diffstat (limited to 'src/device.c')
-rw-r--r--src/device.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/device.c b/src/device.c
index 1614d61..d64653d 100644
--- a/src/device.c
+++ b/src/device.c
@@ -120,6 +120,7 @@ static netdev_tx_t xmit(struct sk_buff *skb, struct net_device *dev)
struct sk_buff *next;
struct sk_buff_head packets;
sa_family_t family;
+ u32 mtu;
int ret;
if (unlikely(skb_examine_untrusted_ip_hdr(skb) != skb->protocol)) {
@@ -142,6 +143,8 @@ static netdev_tx_t xmit(struct sk_buff *skb, struct net_device *dev)
goto err_peer;
}
+ mtu = dst_mtu(skb_dst(skb));
+
__skb_queue_head_init(&packets);
if (!skb_is_gso(skb))
skb->next = NULL;
@@ -168,6 +171,8 @@ static netdev_tx_t xmit(struct sk_buff *skb, struct net_device *dev)
*/
skb_dst_drop(skb);
+ PACKET_CB(skb)->mtu = mtu;
+
__skb_queue_tail(&packets, skb);
} while ((skb = next) != NULL);