Magellan Linux

Contents of /trunk/systemd/patches/systemd-242-network-honor-MTUBytes-setting.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: 6011 byte(s)
-added systemd-242 upstream patches
1 From 933c70a0a4e4fac47d18e0348ae97ee3d48dc139 Mon Sep 17 00:00:00 2001
2 From: Yu Watanabe <watanabe.yu+github@gmail.com>
3 Date: Wed, 15 May 2019 16:02:06 +0900
4 Subject: [PATCH] network: honor MTUBytes= setting
5
6 Closes #12552.
7 ---
8 src/network/networkd-dhcp4.c | 4 ++--
9 src/network/networkd-link.c | 6 +++---
10 src/network/networkd-link.h | 2 +-
11 src/network/networkd-network.c | 30 +-----------------------------
12 src/network/networkd-network.h | 1 -
13 5 files changed, 7 insertions(+), 36 deletions(-)
14
15 diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
16 index 81c694822c1..7907988a9bb 100644
17 --- a/src/network/networkd-dhcp4.c
18 +++ b/src/network/networkd-dhcp4.c
19 @@ -261,7 +261,7 @@ static int dhcp_lease_lost(Link *link) {
20
21 r = sd_dhcp_lease_get_mtu(link->dhcp_lease, &mtu);
22 if (r >= 0 && link->original_mtu != mtu) {
23 - r = link_set_mtu(link, link->original_mtu, true);
24 + r = link_set_mtu(link, link->original_mtu);
25 if (r < 0) {
26 log_link_warning(link,
27 "DHCP error: could not reset MTU");
28 @@ -454,7 +454,7 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
29
30 r = sd_dhcp_lease_get_mtu(lease, &mtu);
31 if (r >= 0) {
32 - r = link_set_mtu(link, mtu, true);
33 + r = link_set_mtu(link, mtu);
34 if (r < 0)
35 log_link_error_errno(link, r, "Failed to set MTU to %" PRIu16 ": %m", mtu);
36 }
37 diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
38 index cd1b0325e8e..6c9a056d782 100644
39 --- a/src/network/networkd-link.c
40 +++ b/src/network/networkd-link.c
41 @@ -1383,7 +1383,7 @@ static int set_mtu_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link)
42 return 1;
43 }
44
45 -int link_set_mtu(Link *link, uint32_t mtu, bool force) {
46 +int link_set_mtu(Link *link, uint32_t mtu) {
47 _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
48 int r;
49
50 @@ -1394,7 +1394,7 @@ int link_set_mtu(Link *link, uint32_t mtu, bool force) {
51 if (mtu == 0 || link->setting_mtu)
52 return 0;
53
54 - if (force ? link->mtu == mtu : link->mtu >= mtu)
55 + if (link->mtu == mtu)
56 return 0;
57
58 log_link_debug(link, "Setting MTU: %" PRIu32, mtu);
59 @@ -2634,7 +2634,7 @@ static int link_configure(Link *link) {
60 return r;
61 }
62
63 - r = link_set_mtu(link, link->network->mtu, link->network->mtu_is_set);
64 + r = link_set_mtu(link, link->network->mtu);
65 if (r < 0)
66 return r;
67
68 diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
69 index e1f4b23a5ac..cc4cd070755 100644
70 --- a/src/network/networkd-link.h
71 +++ b/src/network/networkd-link.h
72 @@ -158,7 +158,7 @@ bool link_has_carrier(Link *link);
73
74 int link_ipv6ll_gained(Link *link, const struct in6_addr *address);
75
76 -int link_set_mtu(Link *link, uint32_t mtu, bool force);
77 +int link_set_mtu(Link *link, uint32_t mtu);
78
79 int ipv4ll_configure(Link *link);
80 bool link_ipv4ll_enabled(Link *link);
81 diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
82 index 56a45379c16..81d2b974edf 100644
83 --- a/src/network/networkd-network.c
84 +++ b/src/network/networkd-network.c
85 @@ -143,24 +143,6 @@ static int network_resolve_stacked_netdevs(Network *network) {
86 return 0;
87 }
88
89 -static uint32_t network_get_stacked_netdevs_mtu(Network *network) {
90 - uint32_t mtu = 0;
91 - NetDev *dev;
92 - Iterator i;
93 -
94 - HASHMAP_FOREACH(dev, network->stacked_netdevs, i)
95 - if (dev->kind == NETDEV_KIND_VLAN && dev->mtu > 0)
96 - /* See vlan_dev_change_mtu() in kernel.
97 - * Note that the additional 4bytes may not be necessary for all devices. */
98 - mtu = MAX(mtu, dev->mtu + 4);
99 -
100 - else if (dev->kind == NETDEV_KIND_MACVLAN && dev->mtu > mtu)
101 - /* See macvlan_change_mtu() in kernel. */
102 - mtu = dev->mtu;
103 -
104 - return mtu;
105 -}
106 -
107 int network_verify(Network *network) {
108 Address *address, *address_next;
109 Route *route, *route_next;
110 @@ -169,7 +151,6 @@ int network_verify(Network *network) {
111 AddressLabel *label, *label_next;
112 Prefix *prefix, *prefix_next;
113 RoutingPolicyRule *rule, *rule_next;
114 - uint32_t mtu;
115
116 assert(network);
117 assert(network->filename);
118 @@ -252,16 +233,7 @@ int network_verify(Network *network) {
119 if (network->ip_masquerade)
120 network->ip_forward |= ADDRESS_FAMILY_IPV4;
121
122 - network->mtu_is_set = network->mtu > 0;
123 - mtu = network_get_stacked_netdevs_mtu(network);
124 - if (network->mtu < mtu) {
125 - if (network->mtu_is_set)
126 - log_notice("%s: Bumping MTUBytes= from %"PRIu32" to %"PRIu32" because of stacked device",
127 - network->filename, network->mtu, mtu);
128 - network->mtu = mtu;
129 - }
130 -
131 - if (network->mtu_is_set && network->dhcp_use_mtu) {
132 + if (network->mtu > 0 && network->dhcp_use_mtu) {
133 log_warning("%s: MTUBytes= in [Link] section and UseMTU= in [DHCP] section are set. "
134 "Disabling UseMTU=.", network->filename);
135 network->dhcp_use_mtu = false;
136 diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h
137 index d00062fe599..702e864eafa 100644
138 --- a/src/network/networkd-network.h
139 +++ b/src/network/networkd-network.h
140 @@ -218,7 +218,6 @@ struct Network {
141
142 struct ether_addr *mac;
143 uint32_t mtu;
144 - bool mtu_is_set; /* Indicate MTUBytes= is specified. */
145 int arp;
146 int multicast;
147 int allmulticast;