25994b417325e0b9d0a86085266d61a4de5a9aff
[openwrt/staging/mkresin.git] / package / network / utils / iproute2 / patches / 001-fix-print_0xhex-on-32-bit.patch
1 From 90c5c969f0b9a2fbb0016b955fecc359aa884220 Mon Sep 17 00:00:00 2001
2 From: Stephen Hemminger <stephen@networkplumber.org>
3 Date: Mon, 10 Dec 2018 14:20:32 -0800
4 Subject: [PATCH] fix print_0xhex on 32 bit
5
6 The argument to print_0xhex is converted to unsigned long long
7 so the format string give for normal printout has to be some
8 variant of %llx. Otherwise, bogus values will be printed on
9 32 bit platforms.
10
11 Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
12 ---
13 bridge/link.c | 2 +-
14 ip/ipaddress.c | 2 +-
15 ip/iplink_bridge.c | 2 +-
16 ip/iplink_bridge_slave.c | 6 +++---
17 ip/iplink_geneve.c | 5 ++---
18 ip/iplink_vxlan.c | 8 +++-----
19 ip/ipntable.c | 2 +-
20 ip/iproute.c | 8 ++++----
21 ip/iproute_lwtunnel.c | 2 +-
22 ip/iprule.c | 6 +++---
23 ip/iptuntap.c | 2 +-
24 ip/link_gre.c | 6 +++---
25 ip/link_gre6.c | 4 ++--
26 ip/link_ip6tnl.c | 2 +-
27 ip/link_iptnl.c | 4 ++--
28 ip/link_vti.c | 2 +-
29 ip/link_vti6.c | 2 +-
30 tc/m_ife.c | 2 +-
31 tc/q_htb.c | 2 +-
32 tc/q_taprio.c | 2 +-
33 20 files changed, 34 insertions(+), 37 deletions(-)
34
35 --- a/bridge/link.c
36 +++ b/bridge/link.c
37 @@ -90,7 +90,7 @@ static void print_hwmode(__u16 mode)
38 {
39 if (mode >= ARRAY_SIZE(hw_mode))
40 print_0xhex(PRINT_ANY, "hwmode",
41 - "hwmode %#hx ", mode);
42 + "hwmode %#llx ", mode);
43 else
44 print_string(PRINT_ANY, "hwmode",
45 "hwmode %s ", hw_mode[mode]);
46 --- a/ip/ipaddress.c
47 +++ b/ip/ipaddress.c
48 @@ -129,7 +129,7 @@ static void print_operstate(FILE *f, __u
49 if (is_json_context())
50 print_uint(PRINT_JSON, "operstate_index", NULL, state);
51 else
52 - print_0xhex(PRINT_FP, NULL, "state %#x", state);
53 + print_0xhex(PRINT_FP, NULL, "state %#llx", state);
54 } else if (brief) {
55 print_color_string(PRINT_ANY,
56 oper_state_color(state),
57 --- a/ip/iplink_bridge.c
58 +++ b/ip/iplink_bridge.c
59 @@ -524,7 +524,7 @@ static void bridge_print_opt(struct link
60 if (tb[IFLA_BR_GROUP_FWD_MASK])
61 print_0xhex(PRINT_ANY,
62 "group_fwd_mask",
63 - "group_fwd_mask %#x ",
64 + "group_fwd_mask %#llx ",
65 rta_getattr_u16(tb[IFLA_BR_GROUP_FWD_MASK]));
66
67 if (tb[IFLA_BR_GROUP_ADDR]) {
68 --- a/ip/iplink_bridge_slave.c
69 +++ b/ip/iplink_bridge_slave.c
70 @@ -167,11 +167,11 @@ static void bridge_slave_print_opt(struc
71 rta_getattr_u8(tb[IFLA_BRPORT_UNICAST_FLOOD]));
72
73 if (tb[IFLA_BRPORT_ID])
74 - print_0xhex(PRINT_ANY, "id", "port_id 0x%x ",
75 + print_0xhex(PRINT_ANY, "id", "port_id %#llx ",
76 rta_getattr_u16(tb[IFLA_BRPORT_ID]));
77
78 if (tb[IFLA_BRPORT_NO])
79 - print_0xhex(PRINT_ANY, "no", "port_no 0x%x ",
80 + print_0xhex(PRINT_ANY, "no", "port_no %#llx ",
81 rta_getattr_u16(tb[IFLA_BRPORT_NO]));
82
83 if (tb[IFLA_BRPORT_DESIGNATED_PORT])
84 @@ -266,7 +266,7 @@ static void bridge_slave_print_opt(struc
85
86 fwd_mask = rta_getattr_u16(tb[IFLA_BRPORT_GROUP_FWD_MASK]);
87 print_0xhex(PRINT_ANY, "group_fwd_mask",
88 - "group_fwd_mask 0x%x ", fwd_mask);
89 + "group_fwd_mask %#llx ", fwd_mask);
90 _bitmask2str(fwd_mask, convbuf, sizeof(convbuf), fwd_mask_tbl);
91 print_string(PRINT_ANY, "group_fwd_mask_str",
92 "group_fwd_mask_str %s ", convbuf);
93 --- a/ip/iplink_geneve.c
94 +++ b/ip/iplink_geneve.c
95 @@ -276,7 +276,7 @@ static void geneve_print_opt(struct link
96 tos = rta_getattr_u8(tb[IFLA_GENEVE_TOS]);
97 if (tos) {
98 if (is_json_context() || tos != 1)
99 - print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
100 + print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
101 else
102 print_string(PRINT_FP, NULL, "tos %s ", "inherit");
103 }
104 @@ -286,8 +286,7 @@ static void geneve_print_opt(struct link
105
106 if (label)
107 print_0xhex(PRINT_ANY,
108 - "label",
109 - "flowlabel %#x ",
110 + "label", "flowlabel %#llx ",
111 ntohl(label));
112 }
113
114 --- a/ip/iplink_vxlan.c
115 +++ b/ip/iplink_vxlan.c
116 @@ -522,7 +522,7 @@ static void vxlan_print_opt(struct link_
117 tos = rta_getattr_u8(tb[IFLA_VXLAN_TOS]);
118 if (tos) {
119 if (is_json_context() || tos != 1)
120 - print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
121 + print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
122 else
123 print_string(PRINT_FP, NULL, "tos %s ", "inherit");
124 }
125 @@ -542,10 +542,8 @@ static void vxlan_print_opt(struct link_
126 __u32 label = rta_getattr_u32(tb[IFLA_VXLAN_LABEL]);
127
128 if (label)
129 - print_0xhex(PRINT_ANY,
130 - "label",
131 - "flowlabel %#x ",
132 - ntohl(label));
133 + print_0xhex(PRINT_ANY, "label",
134 + "flowlabel %#llx ", ntohl(label));
135 }
136
137 if (tb[IFLA_VXLAN_AGEING]) {
138 --- a/ip/ipntable.c
139 +++ b/ip/ipntable.c
140 @@ -360,7 +360,7 @@ static void print_ndtconfig(const struct
141 print_uint(PRINT_ANY, "hash_rnd",
142 " hash_rnd %u ", ndtc->ndtc_hash_rnd);
143 print_0xhex(PRINT_ANY, "hash_mask",
144 - "hash_mask %08x ", ndtc->ndtc_hash_mask);
145 + "hash_mask %08llx ", ndtc->ndtc_hash_mask);
146
147 print_uint(PRINT_ANY, "hash_chain_gc",
148 "hash_chain_gc %u ", ndtc->ndtc_hash_chain_gc);
149 --- a/ip/iproute.c
150 +++ b/ip/iproute.c
151 @@ -346,7 +346,7 @@ static void print_rtax_features(FILE *fp
152
153 if (features)
154 print_0xhex(PRINT_ANY,
155 - "features", "0x%x ", of);
156 + "features", "%#llx ", of);
157 }
158
159 static void print_rt_flags(FILE *fp, unsigned int flags)
160 @@ -483,10 +483,10 @@ static void print_rta_cacheinfo(FILE *fp
161 }
162 if (ci->rta_id)
163 print_0xhex(PRINT_ANY, "ipid",
164 - "ipid 0x%04x ", ci->rta_id);
165 + "ipid 0x%04llx ", ci->rta_id);
166 if (ci->rta_ts || ci->rta_tsage) {
167 print_0xhex(PRINT_ANY, "ts",
168 - "ts 0x%x", ci->rta_ts);
169 + "ts 0x%llx", ci->rta_ts);
170 print_uint(PRINT_ANY, "tsage",
171 "tsage %usec ", ci->rta_tsage);
172 }
173 @@ -885,7 +885,7 @@ int print_route(const struct sockaddr_nl
174 print_uint(PRINT_JSON, "mark", NULL, mark);
175 else if (mark >= 16)
176 print_0xhex(PRINT_FP, NULL,
177 - "mark 0x%x ", mark);
178 + "mark 0x%llx ", mark);
179 else
180 print_uint(PRINT_FP, NULL,
181 "mark %u ", mark);
182 --- a/ip/iproute_lwtunnel.c
183 +++ b/ip/iproute_lwtunnel.c
184 @@ -115,7 +115,7 @@ static void print_srh(FILE *fp, struct i
185
186 tlv = (struct sr6_tlv_hmac *)((char *)srh + offset);
187 print_0xhex(PRINT_ANY, "hmac",
188 - "hmac 0x%X ", ntohl(tlv->hmackeyid));
189 + "hmac %llX ", ntohl(tlv->hmackeyid));
190 }
191 }
192
193 --- a/ip/iprule.c
194 +++ b/ip/iprule.c
195 @@ -263,10 +263,10 @@ int print_rule(const struct sockaddr_nl
196
197 if (tb[FRA_FWMASK] &&
198 (mask = rta_getattr_u32(tb[FRA_FWMASK])) != 0xFFFFFFFF) {
199 - print_0xhex(PRINT_ANY, "fwmark", "fwmark 0x%x", mark);
200 - print_0xhex(PRINT_ANY, "fwmask", "/0x%x ", mask);
201 + print_0xhex(PRINT_ANY, "fwmark", "fwmark %#llx", mark);
202 + print_0xhex(PRINT_ANY, "fwmask", "/%#llx ", mask);
203 } else {
204 - print_0xhex(PRINT_ANY, "fwmark", "fwmark 0x%x ", mark);
205 + print_0xhex(PRINT_ANY, "fwmark", "fwmark %#llx ", mark);
206 }
207 }
208
209 --- a/ip/iptuntap.c
210 +++ b/ip/iptuntap.c
211 @@ -254,7 +254,7 @@ static void print_flags(long flags)
212 flags &= ~(IFF_TUN | IFF_TAP | IFF_NO_PI | IFF_ONE_QUEUE |
213 IFF_VNET_HDR | IFF_PERSIST | IFF_NOFILTER);
214 if (flags)
215 - print_0xhex(PRINT_ANY, NULL, "%#x", flags);
216 + print_0xhex(PRINT_ANY, NULL, "%#llx", flags);
217
218 close_json_array(PRINT_JSON, NULL);
219 }
220 --- a/ip/link_gre.c
221 +++ b/ip/link_gre.c
222 @@ -463,7 +463,7 @@ static void gre_print_opt(struct link_ut
223 tos = rta_getattr_u8(tb[IFLA_GRE_TOS]);
224 if (tos) {
225 if (is_json_context() || tos != 1)
226 - print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
227 + print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
228 else
229 print_string(PRINT_FP, NULL, "tos %s ", "inherit");
230 }
231 @@ -508,7 +508,7 @@ static void gre_print_opt(struct link_ut
232
233 if (fwmark) {
234 print_0xhex(PRINT_ANY,
235 - "fwmark", "fwmark 0x%x ", fwmark);
236 + "fwmark", "fwmark %#llx ", fwmark);
237 }
238 }
239
240 @@ -541,7 +541,7 @@ static void gre_print_opt(struct link_ut
241 __u16 erspan_hwid = rta_getattr_u16(tb[IFLA_GRE_ERSPAN_HWID]);
242
243 print_0xhex(PRINT_ANY,
244 - "erspan_hwid", "erspan_hwid 0x%x ", erspan_hwid);
245 + "erspan_hwid", "erspan_hwid %#llx ", erspan_hwid);
246 }
247
248 tnl_print_encap(tb,
249 --- a/ip/link_gre6.c
250 +++ b/ip/link_gre6.c
251 @@ -576,7 +576,7 @@ static void gre_print_opt(struct link_ut
252
253 if (fwmark) {
254 print_0xhex(PRINT_ANY,
255 - "fwmark", "fwmark 0x%x ", fwmark);
256 + "fwmark", "fwmark %#llx ", fwmark);
257 }
258 }
259
260 @@ -609,7 +609,7 @@ static void gre_print_opt(struct link_ut
261 __u16 erspan_hwid = rta_getattr_u16(tb[IFLA_GRE_ERSPAN_HWID]);
262
263 print_0xhex(PRINT_ANY,
264 - "erspan_hwid", "erspan_hwid 0x%x ", erspan_hwid);
265 + "erspan_hwid", "erspan_hwid %#llx ", erspan_hwid);
266 }
267
268 tnl_print_encap(tb,
269 --- a/ip/link_ip6tnl.c
270 +++ b/ip/link_ip6tnl.c
271 @@ -457,7 +457,7 @@ static void ip6tunnel_print_opt(struct l
272
273 if (fwmark) {
274 print_0xhex(PRINT_ANY,
275 - "fwmark", "fwmark 0x%x ", fwmark);
276 + "fwmark", "fwmark %#llx ", fwmark);
277 }
278 }
279
280 --- a/ip/link_iptnl.c
281 +++ b/ip/link_iptnl.c
282 @@ -418,7 +418,7 @@ static void iptunnel_print_opt(struct li
283 tos = rta_getattr_u8(tb[IFLA_IPTUN_TOS]);
284 if (tos) {
285 if (is_json_context() || tos != 1)
286 - print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
287 + print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
288 else
289 print_string(PRINT_FP, NULL, "tos %s ", "inherit");
290 }
291 @@ -476,7 +476,7 @@ static void iptunnel_print_opt(struct li
292
293 if (fwmark) {
294 print_0xhex(PRINT_ANY,
295 - "fwmark", "fwmark 0x%x ", fwmark);
296 + "fwmark", "fwmark %#llx ", fwmark);
297 }
298 }
299
300 --- a/ip/link_vti.c
301 +++ b/ip/link_vti.c
302 @@ -208,7 +208,7 @@ static void vti_print_opt(struct link_ut
303
304 if (fwmark) {
305 print_0xhex(PRINT_ANY,
306 - "fwmark", "fwmark 0x%x ", fwmark);
307 + "fwmark", "fwmark %#llx ", fwmark);
308 }
309 }
310 }
311 --- a/ip/link_vti6.c
312 +++ b/ip/link_vti6.c
313 @@ -210,7 +210,7 @@ static void vti6_print_opt(struct link_u
314
315 if (fwmark) {
316 print_0xhex(PRINT_ANY,
317 - "fwmark", "fwmark 0x%x ", fwmark);
318 + "fwmark", "fwmark %#llx ", fwmark);
319 }
320 }
321 }
322 --- a/tc/m_ife.c
323 +++ b/tc/m_ife.c
324 @@ -247,7 +247,7 @@ static int print_ife(struct action_util
325 if (tb[TCA_IFE_TYPE]) {
326 ife_type = rta_getattr_u16(tb[TCA_IFE_TYPE]);
327 has_optional = 1;
328 - print_0xhex(PRINT_ANY, "type", "type 0x%X ", ife_type);
329 + print_0xhex(PRINT_ANY, "type", "type %#llX ", ife_type);
330 }
331
332 if (has_optional)
333 --- a/tc/q_htb.c
334 +++ b/tc/q_htb.c
335 @@ -332,7 +332,7 @@ static int htb_print_opt(struct qdisc_ut
336 if (RTA_PAYLOAD(tb[TCA_HTB_INIT]) < sizeof(*gopt)) return -1;
337
338 print_int(PRINT_ANY, "r2q", "r2q %d", gopt->rate2quantum);
339 - print_0xhex(PRINT_ANY, "default", " default %x", gopt->defcls);
340 + print_0xhex(PRINT_ANY, "default", " default %#llx", gopt->defcls);
341 print_uint(PRINT_ANY, "direct_packets_stat",
342 " direct_packets_stat %u", gopt->direct_pkts);
343 if (show_details) {