1 |
commit: 701d8158f31d695a453704b1b8f8f03bda93a39f |
2 |
Author: Jason A. Donenfeld <zx2c4 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Feb 8 17:16:49 2018 +0000 |
4 |
Commit: Jason Donenfeld <zx2c4 <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Feb 8 17:17:18 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=701d8158 |
7 |
|
8 |
sys-apps/systemd: show proper networkctl display type |
9 |
|
10 |
Upstream commit: |
11 |
https://github.com/systemd/systemd/commit/3b8f29fd93899c4876a6ef53f9bcb6b40e1c98e7 |
12 |
|
13 |
Package-Manager: Portage-2.3.24, Repoman-2.3.6 |
14 |
|
15 |
.../files/237-0001-networkctl-display-type.patch | 266 +++++++++++++++++++++ |
16 |
...systemd-237-r1.ebuild => systemd-237-r2.ebuild} | 1 + |
17 |
2 files changed, 267 insertions(+) |
18 |
|
19 |
diff --git a/sys-apps/systemd/files/237-0001-networkctl-display-type.patch b/sys-apps/systemd/files/237-0001-networkctl-display-type.patch |
20 |
new file mode 100644 |
21 |
index 00000000000..e29cf2206aa |
22 |
--- /dev/null |
23 |
+++ b/sys-apps/systemd/files/237-0001-networkctl-display-type.patch |
24 |
@@ -0,0 +1,266 @@ |
25 |
+From a18461bc7d446f8e130e9276de4397d00059267f Mon Sep 17 00:00:00 2001 |
26 |
+From: "Jason A. Donenfeld" <Jason@×××××.com> |
27 |
+Date: Mon, 29 Jan 2018 20:58:24 +0100 |
28 |
+Subject: [PATCH 1/4] networkd: display wireguard devtype |
29 |
+ |
30 |
+It's not useful to simply show "none", when we have more interesting |
31 |
+information to display. |
32 |
+ |
33 |
+Signed-off-by: Jason A. Donenfeld <Jason@×××××.com> |
34 |
+--- |
35 |
+ src/network/networkctl.c | 22 +++++++++++++++------- |
36 |
+ 1 file changed, 15 insertions(+), 7 deletions(-) |
37 |
+ |
38 |
+diff --git a/src/network/networkctl.c b/src/network/networkctl.c |
39 |
+index 59ce098cd1..6ce00dff6d 100644 |
40 |
+--- a/src/network/networkctl.c |
41 |
++++ b/src/network/networkctl.c |
42 |
+@@ -62,18 +62,26 @@ static int link_get_type_string(unsigned short iftype, sd_device *d, char **ret) |
43 |
+ |
44 |
+ assert(ret); |
45 |
+ |
46 |
+- if (iftype == ARPHRD_ETHER && d) { |
47 |
++ if (d) { |
48 |
+ const char *devtype = NULL, *id = NULL; |
49 |
++ |
50 |
++ (void) sd_device_get_devtype(d, &devtype); |
51 |
++ |
52 |
+ /* WLANs have iftype ARPHRD_ETHER, but we want |
53 |
+ * to show a more useful type string for |
54 |
+ * them */ |
55 |
++ if (iftype == ARPHRD_ETHER) { |
56 |
++ if (streq_ptr(devtype, "wlan")) |
57 |
++ id = "wlan"; |
58 |
++ else if (streq_ptr(devtype, "wwan")) |
59 |
++ id = "wwan"; |
60 |
++ } |
61 |
+ |
62 |
+- (void) sd_device_get_devtype(d, &devtype); |
63 |
+- |
64 |
+- if (streq_ptr(devtype, "wlan")) |
65 |
+- id = "wlan"; |
66 |
+- else if (streq_ptr(devtype, "wwan")) |
67 |
+- id = "wwan"; |
68 |
++ /* Likewise, WireGuard has iftype ARPHRD_NONE, |
69 |
++ * since it's layer 3, but we of course want |
70 |
++ * something more useful than that. */ |
71 |
++ if (iftype == ARPHRD_NONE && streq_ptr(devtype, "wireguard")) |
72 |
++ id = "wireguard"; |
73 |
+ |
74 |
+ if (id) { |
75 |
+ p = strdup(id); |
76 |
+ |
77 |
+From f119082e7a1ccfbf50c30a99819b6e303cdf09a1 Mon Sep 17 00:00:00 2001 |
78 |
+From: "Jason A. Donenfeld" <Jason@×××××.com> |
79 |
+Date: Mon, 29 Jan 2018 21:01:46 +0100 |
80 |
+Subject: [PATCH 2/4] networkd: simplify and display all devtypes |
81 |
+ |
82 |
+Every place the kernel actually calls SET_NETDEV_DEVTYPE, it's adding a |
83 |
+piece of information that looks useful and relevant for us to use. So |
84 |
+let's use it when it's there. |
85 |
+ |
86 |
+The previous matching based on the corresponding ARPHRD didn't really |
87 |
+make much sense. The more sensible logic for getting a textual |
88 |
+representation of the link type is to see if the kernel supplies a |
89 |
+devtype. If it does, great. If not, then we can fall back on the ARPHRD, |
90 |
+as before. |
91 |
+ |
92 |
+Signed-off-by: Jason A. Donenfeld <Jason@×××××.com> |
93 |
+--- |
94 |
+ src/network/networkctl.c | 23 +++-------------------- |
95 |
+ 1 file changed, 3 insertions(+), 20 deletions(-) |
96 |
+ |
97 |
+diff --git a/src/network/networkctl.c b/src/network/networkctl.c |
98 |
+index 6ce00dff6d..8a08304240 100644 |
99 |
+--- a/src/network/networkctl.c |
100 |
++++ b/src/network/networkctl.c |
101 |
+@@ -63,28 +63,11 @@ static int link_get_type_string(unsigned short iftype, sd_device *d, char **ret) |
102 |
+ assert(ret); |
103 |
+ |
104 |
+ if (d) { |
105 |
+- const char *devtype = NULL, *id = NULL; |
106 |
++ const char *devtype = NULL; |
107 |
+ |
108 |
+ (void) sd_device_get_devtype(d, &devtype); |
109 |
+- |
110 |
+- /* WLANs have iftype ARPHRD_ETHER, but we want |
111 |
+- * to show a more useful type string for |
112 |
+- * them */ |
113 |
+- if (iftype == ARPHRD_ETHER) { |
114 |
+- if (streq_ptr(devtype, "wlan")) |
115 |
+- id = "wlan"; |
116 |
+- else if (streq_ptr(devtype, "wwan")) |
117 |
+- id = "wwan"; |
118 |
+- } |
119 |
+- |
120 |
+- /* Likewise, WireGuard has iftype ARPHRD_NONE, |
121 |
+- * since it's layer 3, but we of course want |
122 |
+- * something more useful than that. */ |
123 |
+- if (iftype == ARPHRD_NONE && streq_ptr(devtype, "wireguard")) |
124 |
+- id = "wireguard"; |
125 |
+- |
126 |
+- if (id) { |
127 |
+- p = strdup(id); |
128 |
++ if (!isempty(devtype)) { |
129 |
++ p = strdup(devtype); |
130 |
+ if (!p) |
131 |
+ return -ENOMEM; |
132 |
+ |
133 |
+ |
134 |
+From fdce7817b9a27a370c01b7dd9da6a84fcae1038e Mon Sep 17 00:00:00 2001 |
135 |
+From: "Jason A. Donenfeld" <Jason@×××××.com> |
136 |
+Date: Mon, 29 Jan 2018 21:05:36 +0100 |
137 |
+Subject: [PATCH 3/4] networkd: clean up link_get_type_string |
138 |
+ |
139 |
+The return value is always ignored, so get rid of it. |
140 |
+ |
141 |
+Signed-off-by: Jason A. Donenfeld <Jason@×××××.com> |
142 |
+--- |
143 |
+ src/network/networkctl.c | 16 +++++++--------- |
144 |
+ 1 file changed, 7 insertions(+), 9 deletions(-) |
145 |
+ |
146 |
+diff --git a/src/network/networkctl.c b/src/network/networkctl.c |
147 |
+index 8a08304240..7b33e0db17 100644 |
148 |
+--- a/src/network/networkctl.c |
149 |
++++ b/src/network/networkctl.c |
150 |
+@@ -56,7 +56,7 @@ static bool arg_no_pager = false; |
151 |
+ static bool arg_legend = true; |
152 |
+ static bool arg_all = false; |
153 |
+ |
154 |
+-static int link_get_type_string(unsigned short iftype, sd_device *d, char **ret) { |
155 |
++static void link_get_type_string(unsigned short iftype, sd_device *d, char **ret) { |
156 |
+ const char *t; |
157 |
+ char *p; |
158 |
+ |
159 |
+@@ -69,27 +69,25 @@ static int link_get_type_string(unsigned short iftype, sd_device *d, char **ret) |
160 |
+ if (!isempty(devtype)) { |
161 |
+ p = strdup(devtype); |
162 |
+ if (!p) |
163 |
+- return -ENOMEM; |
164 |
++ return; |
165 |
+ |
166 |
+ *ret = p; |
167 |
+- return 1; |
168 |
++ return; |
169 |
+ } |
170 |
+ } |
171 |
+ |
172 |
+ t = arphrd_to_name(iftype); |
173 |
+ if (!t) { |
174 |
+ *ret = NULL; |
175 |
+- return 0; |
176 |
++ return; |
177 |
+ } |
178 |
+ |
179 |
+ p = strdup(t); |
180 |
+ if (!p) |
181 |
+- return -ENOMEM; |
182 |
++ return; |
183 |
+ |
184 |
+ ascii_strlower(p); |
185 |
+ *ret = p; |
186 |
+- |
187 |
+- return 0; |
188 |
+ } |
189 |
+ |
190 |
+ static void operational_state_to_color(const char *state, const char **on, const char **off) { |
191 |
+@@ -314,7 +312,7 @@ static int list_links(int argc, char *argv[], void *userdata) { |
192 |
+ xsprintf(devid, "n%i", links[i].ifindex); |
193 |
+ (void) sd_device_new_from_device_id(&d, devid); |
194 |
+ |
195 |
+- (void) link_get_type_string(links[i].iftype, d, &t); |
196 |
++ link_get_type_string(links[i].iftype, d, &t); |
197 |
+ |
198 |
+ printf("%3i %-16s %-18s %s%-11s%s %s%-10s%s\n", |
199 |
+ links[i].ifindex, links[i].name, strna(t), |
200 |
+@@ -807,7 +805,7 @@ static int link_status_one( |
201 |
+ (void) sd_device_get_property_value(d, "ID_MODEL", &model); |
202 |
+ } |
203 |
+ |
204 |
+- (void) link_get_type_string(info->iftype, d, &t); |
205 |
++ link_get_type_string(info->iftype, d, &t); |
206 |
+ |
207 |
+ (void) sd_network_link_get_network_file(info->ifindex, &network); |
208 |
+ |
209 |
+ |
210 |
+From b55822c349d3e0559c1efc7475fd0f74cf086453 Mon Sep 17 00:00:00 2001 |
211 |
+From: "Jason A. Donenfeld" <Jason@×××××.com> |
212 |
+Date: Mon, 29 Jan 2018 21:08:39 +0100 |
213 |
+Subject: [PATCH 4/4] networkd: clean up link_get_type_string returns |
214 |
+ |
215 |
+It's cleaner and more consistent to actually return what we were |
216 |
+planning on returning. |
217 |
+ |
218 |
+Signed-off-by: Jason A. Donenfeld <Jason@×××××.com> |
219 |
+--- |
220 |
+ src/network/networkctl.c | 28 +++++++++------------------- |
221 |
+ 1 file changed, 9 insertions(+), 19 deletions(-) |
222 |
+ |
223 |
+diff --git a/src/network/networkctl.c b/src/network/networkctl.c |
224 |
+index 7b33e0db17..14d8ecb03f 100644 |
225 |
+--- a/src/network/networkctl.c |
226 |
++++ b/src/network/networkctl.c |
227 |
+@@ -56,38 +56,28 @@ static bool arg_no_pager = false; |
228 |
+ static bool arg_legend = true; |
229 |
+ static bool arg_all = false; |
230 |
+ |
231 |
+-static void link_get_type_string(unsigned short iftype, sd_device *d, char **ret) { |
232 |
++static char *link_get_type_string(unsigned short iftype, sd_device *d) { |
233 |
+ const char *t; |
234 |
+ char *p; |
235 |
+ |
236 |
+- assert(ret); |
237 |
+- |
238 |
+ if (d) { |
239 |
+ const char *devtype = NULL; |
240 |
+ |
241 |
+ (void) sd_device_get_devtype(d, &devtype); |
242 |
+- if (!isempty(devtype)) { |
243 |
+- p = strdup(devtype); |
244 |
+- if (!p) |
245 |
+- return; |
246 |
+- |
247 |
+- *ret = p; |
248 |
+- return; |
249 |
+- } |
250 |
++ if (!isempty(devtype)) |
251 |
++ return strdup(devtype); |
252 |
+ } |
253 |
+ |
254 |
+ t = arphrd_to_name(iftype); |
255 |
+- if (!t) { |
256 |
+- *ret = NULL; |
257 |
+- return; |
258 |
+- } |
259 |
++ if (!t) |
260 |
++ return NULL; |
261 |
+ |
262 |
+ p = strdup(t); |
263 |
+ if (!p) |
264 |
+- return; |
265 |
++ return NULL; |
266 |
+ |
267 |
+ ascii_strlower(p); |
268 |
+- *ret = p; |
269 |
++ return p; |
270 |
+ } |
271 |
+ |
272 |
+ static void operational_state_to_color(const char *state, const char **on, const char **off) { |
273 |
+@@ -312,7 +302,7 @@ static int list_links(int argc, char *argv[], void *userdata) { |
274 |
+ xsprintf(devid, "n%i", links[i].ifindex); |
275 |
+ (void) sd_device_new_from_device_id(&d, devid); |
276 |
+ |
277 |
+- link_get_type_string(links[i].iftype, d, &t); |
278 |
++ t = link_get_type_string(links[i].iftype, d); |
279 |
+ |
280 |
+ printf("%3i %-16s %-18s %s%-11s%s %s%-10s%s\n", |
281 |
+ links[i].ifindex, links[i].name, strna(t), |
282 |
+@@ -805,7 +795,7 @@ static int link_status_one( |
283 |
+ (void) sd_device_get_property_value(d, "ID_MODEL", &model); |
284 |
+ } |
285 |
+ |
286 |
+- link_get_type_string(info->iftype, d, &t); |
287 |
++ t = link_get_type_string(info->iftype, d); |
288 |
+ |
289 |
+ (void) sd_network_link_get_network_file(info->ifindex, &network); |
290 |
+ |
291 |
|
292 |
diff --git a/sys-apps/systemd/systemd-237-r1.ebuild b/sys-apps/systemd/systemd-237-r2.ebuild |
293 |
similarity index 99% |
294 |
rename from sys-apps/systemd/systemd-237-r1.ebuild |
295 |
rename to sys-apps/systemd/systemd-237-r2.ebuild |
296 |
index 97ed32eebe7..71abd1c3359 100644 |
297 |
--- a/sys-apps/systemd/systemd-237-r1.ebuild |
298 |
+++ b/sys-apps/systemd/systemd-237-r2.ebuild |
299 |
@@ -148,6 +148,7 @@ src_unpack() { |
300 |
|
301 |
src_prepare() { |
302 |
local PATCHES=( |
303 |
+ "${FILESDIR}/237-0001-networkctl-display-type.patch" |
304 |
) |
305 |
|
306 |
[[ -d "${WORKDIR}"/patches ]] && PATCHES+=( "${WORKDIR}"/patches ) |