Magellan Linux

Contents of /trunk/systemd/patches/systemd-242-network-bump-MTU-bytes-only-when-MTUBytes-is-not-set.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3368 - (show annotations) (download)
Tue Jul 9 11:20:22 2019 UTC (4 years, 9 months ago) by niro
File size: 2446 byte(s)
-added systemd-242 upstream patches
1 From f6fcc1c2a41eae749467de58453174296b635a69 Mon Sep 17 00:00:00 2001
2 From: Yu Watanabe <watanabe.yu+github@gmail.com>
3 Date: Thu, 16 May 2019 11:42:46 +0900
4 Subject: [PATCH] network: bump MTU bytes only when MTUByte= is not set
5
6 ---
7 src/network/networkd-link.c | 44 ++++++++++++++++++++++++++++++++++++-
8 1 file changed, 43 insertions(+), 1 deletion(-)
9
10 diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
11 index 6c9a056d782..6a07836f00e 100644
12 --- a/src/network/networkd-link.c
13 +++ b/src/network/networkd-link.c
14 @@ -1432,6 +1432,48 @@ int link_set_mtu(Link *link, uint32_t mtu) {
15 return 0;
16 }
17
18 +static bool link_reduces_vlan_mtu(Link *link) {
19 + /* See netif_reduces_vlan_mtu() in kernel. */
20 + return streq_ptr(link->kind, "macsec");
21 +}
22 +
23 +static uint32_t link_get_requested_mtu_by_stacked_netdevs(Link *link) {
24 + uint32_t mtu = 0;
25 + NetDev *dev;
26 + Iterator i;
27 +
28 + HASHMAP_FOREACH(dev, link->network->stacked_netdevs, i)
29 + if (dev->kind == NETDEV_KIND_VLAN && dev->mtu > 0)
30 + /* See vlan_dev_change_mtu() in kernel. */
31 + mtu = MAX(mtu, link_reduces_vlan_mtu(link) ? dev->mtu + 4 : dev->mtu);
32 +
33 + else if (dev->kind == NETDEV_KIND_MACVLAN && dev->mtu > mtu)
34 + /* See macvlan_change_mtu() in kernel. */
35 + mtu = dev->mtu;
36 +
37 + return mtu;
38 +}
39 +
40 +static int link_configure_mtu(Link *link) {
41 + uint32_t mtu;
42 +
43 + assert(link);
44 + assert(link->network);
45 +
46 + if (link->network->mtu > 0)
47 + return link_set_mtu(link, link->network->mtu);
48 +
49 + mtu = link_get_requested_mtu_by_stacked_netdevs(link);
50 + if (link->mtu >= mtu)
51 + return 0;
52 +
53 + log_link_notice(link, "Bumping MTU bytes from %"PRIu32" to %"PRIu32" because of stacked device. "
54 + "If it is not desired, then please explicitly specify MTUBytes= setting.",
55 + link->mtu, mtu);
56 +
57 + return link_set_mtu(link, mtu);
58 +}
59 +
60 static int set_flags_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
61 int r;
62
63 @@ -2634,7 +2676,7 @@ static int link_configure(Link *link) {
64 return r;
65 }
66
67 - r = link_set_mtu(link, link->network->mtu);
68 + r = link_configure_mtu(link);
69 if (r < 0)
70 return r;
71