diff mbox series

[iproute2] fix print_0xhex on 32 bit

Message ID 20181210222701.7672-1-stephen@networkplumber.org
State Accepted, archived
Delegated to: stephen hemminger
Headers show
Series [iproute2] fix print_0xhex on 32 bit | expand

Commit Message

Stephen Hemminger Dec. 10, 2018, 10:27 p.m. UTC
The argument to print_0xhex is converted to unsigned long long
so the format string give for normal printout has to be some
variant of %llx. Otherwise, bogus values will be printed on
32 bit platforms.

Reported-by: Hans Dedecker <dedeckeh@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 bridge/link.c            | 2 +-
 ip/ipaddress.c           | 2 +-
 ip/iplink_bridge.c       | 2 +-
 ip/iplink_bridge_slave.c | 6 +++---
 ip/iplink_geneve.c       | 5 ++---
 ip/iplink_vxlan.c        | 8 +++-----
 ip/ipntable.c            | 2 +-
 ip/iproute.c             | 8 ++++----
 ip/iproute_lwtunnel.c    | 2 +-
 ip/iprule.c              | 6 +++---
 ip/iptuntap.c            | 2 +-
 ip/link_gre.c            | 6 +++---
 ip/link_gre6.c           | 4 ++--
 ip/link_ip6tnl.c         | 2 +-
 ip/link_iptnl.c          | 4 ++--
 ip/link_vti.c            | 2 +-
 ip/link_vti6.c           | 2 +-
 tc/m_ife.c               | 2 +-
 tc/q_htb.c               | 2 +-
 tc/q_taprio.c            | 2 +-
 20 files changed, 34 insertions(+), 37 deletions(-)

Comments

Hans Dedecker Dec. 11, 2018, 9:05 a.m. UTC | #1
On Mon, Dec 10, 2018 at 11:29 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> The argument to print_0xhex is converted to unsigned long long
> so the format string give for normal printout has to be some
> variant of %llx. Otherwise, bogus values will be printed on
> 32 bit platforms.
>
> Reported-by: Hans Dedecker <dedeckeh@gmail.com>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Tested-by: Hans Dedecker <dedeckeh@gmail.com>
> ---
>  bridge/link.c            | 2 +-
>  ip/ipaddress.c           | 2 +-
>  ip/iplink_bridge.c       | 2 +-
>  ip/iplink_bridge_slave.c | 6 +++---
>  ip/iplink_geneve.c       | 5 ++---
>  ip/iplink_vxlan.c        | 8 +++-----
>  ip/ipntable.c            | 2 +-
>  ip/iproute.c             | 8 ++++----
>  ip/iproute_lwtunnel.c    | 2 +-
>  ip/iprule.c              | 6 +++---
>  ip/iptuntap.c            | 2 +-
>  ip/link_gre.c            | 6 +++---
>  ip/link_gre6.c           | 4 ++--
>  ip/link_ip6tnl.c         | 2 +-
>  ip/link_iptnl.c          | 4 ++--
>  ip/link_vti.c            | 2 +-
>  ip/link_vti6.c           | 2 +-
>  tc/m_ife.c               | 2 +-
>  tc/q_htb.c               | 2 +-
>  tc/q_taprio.c            | 2 +-
>  20 files changed, 34 insertions(+), 37 deletions(-)
>
> diff --git a/bridge/link.c b/bridge/link.c
> index 3290c16f0951..32317e53b036 100644
> --- a/bridge/link.c
> +++ b/bridge/link.c
> @@ -90,7 +90,7 @@ static void print_hwmode(__u16 mode)
>  {
>         if (mode >= ARRAY_SIZE(hw_mode))
>                 print_0xhex(PRINT_ANY, "hwmode",
> -                           "hwmode %#hx ", mode);
> +                           "hwmode %#llx ", mode);
>         else
>                 print_string(PRINT_ANY, "hwmode",
>                              "hwmode %s ", hw_mode[mode]);
> diff --git a/ip/ipaddress.c b/ip/ipaddress.c
> index 21985a5ee6f3..016662e910e9 100644
> --- a/ip/ipaddress.c
> +++ b/ip/ipaddress.c
> @@ -129,7 +129,7 @@ static void print_operstate(FILE *f, __u8 state)
>                 if (is_json_context())
>                         print_uint(PRINT_JSON, "operstate_index", NULL, state);
>                 else
> -                       print_0xhex(PRINT_FP, NULL, "state %#x", state);
> +                       print_0xhex(PRINT_FP, NULL, "state %#llx", state);
>         } else if (brief) {
>                 print_color_string(PRINT_ANY,
>                                    oper_state_color(state),
> diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c
> index 0ba6be3f47da..fbf8a79bfbbb 100644
> --- a/ip/iplink_bridge.c
> +++ b/ip/iplink_bridge.c
> @@ -524,7 +524,7 @@ static void bridge_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
>         if (tb[IFLA_BR_GROUP_FWD_MASK])
>                 print_0xhex(PRINT_ANY,
>                             "group_fwd_mask",
> -                           "group_fwd_mask %#x ",
> +                           "group_fwd_mask %#llx ",
>                             rta_getattr_u16(tb[IFLA_BR_GROUP_FWD_MASK]));
>
>         if (tb[IFLA_BR_GROUP_ADDR]) {
> diff --git a/ip/iplink_bridge_slave.c b/ip/iplink_bridge_slave.c
> index 8b4f93f265be..85e6b424315f 100644
> --- a/ip/iplink_bridge_slave.c
> +++ b/ip/iplink_bridge_slave.c
> @@ -168,11 +168,11 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
>                              rta_getattr_u8(tb[IFLA_BRPORT_UNICAST_FLOOD]));
>
>         if (tb[IFLA_BRPORT_ID])
> -               print_0xhex(PRINT_ANY, "id", "port_id 0x%x ",
> +               print_0xhex(PRINT_ANY, "id", "port_id %#llx ",
>                             rta_getattr_u16(tb[IFLA_BRPORT_ID]));
>
>         if (tb[IFLA_BRPORT_NO])
> -               print_0xhex(PRINT_ANY, "no", "port_no 0x%x ",
> +               print_0xhex(PRINT_ANY, "no", "port_no %#llx ",
>                            rta_getattr_u16(tb[IFLA_BRPORT_NO]));
>
>         if (tb[IFLA_BRPORT_DESIGNATED_PORT])
> @@ -267,7 +267,7 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
>
>                 fwd_mask = rta_getattr_u16(tb[IFLA_BRPORT_GROUP_FWD_MASK]);
>                 print_0xhex(PRINT_ANY, "group_fwd_mask",
> -                           "group_fwd_mask 0x%x ", fwd_mask);
> +                           "group_fwd_mask %#llx ", fwd_mask);
>                 _bitmask2str(fwd_mask, convbuf, sizeof(convbuf), fwd_mask_tbl);
>                 print_string(PRINT_ANY, "group_fwd_mask_str",
>                              "group_fwd_mask_str %s ", convbuf);
> diff --git a/ip/iplink_geneve.c b/ip/iplink_geneve.c
> index c417842b2a5b..f1a12f454ab7 100644
> --- a/ip/iplink_geneve.c
> +++ b/ip/iplink_geneve.c
> @@ -282,7 +282,7 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
>                 tos = rta_getattr_u8(tb[IFLA_GENEVE_TOS]);
>         if (tos) {
>                 if (is_json_context() || tos != 1)
> -                       print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
> +                       print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
>                 else
>                         print_string(PRINT_FP, NULL, "tos %s ", "inherit");
>         }
> @@ -292,8 +292,7 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
>
>                 if (label)
>                         print_0xhex(PRINT_ANY,
> -                                   "label",
> -                                   "flowlabel %#x ",
> +                                   "label", "flowlabel %#llx ",
>                                     ntohl(label));
>         }
>
> diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c
> index 7fc0e2b4eb06..62e769430c5d 100644
> --- a/ip/iplink_vxlan.c
> +++ b/ip/iplink_vxlan.c
> @@ -522,7 +522,7 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
>                 tos = rta_getattr_u8(tb[IFLA_VXLAN_TOS]);
>         if (tos) {
>                 if (is_json_context() || tos != 1)
> -                       print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
> +                       print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
>                 else
>                         print_string(PRINT_FP, NULL, "tos %s ", "inherit");
>         }
> @@ -542,10 +542,8 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
>                 __u32 label = rta_getattr_u32(tb[IFLA_VXLAN_LABEL]);
>
>                 if (label)
> -                       print_0xhex(PRINT_ANY,
> -                                   "label",
> -                                   "flowlabel %#x ",
> -                                   ntohl(label));
> +                       print_0xhex(PRINT_ANY, "label",
> +                                   "flowlabel %#llx ", ntohl(label));
>         }
>
>         if (tb[IFLA_VXLAN_AGEING]) {
> diff --git a/ip/ipntable.c b/ip/ipntable.c
> index 5b61dd5cb001..50fc949f1fcc 100644
> --- a/ip/ipntable.c
> +++ b/ip/ipntable.c
> @@ -360,7 +360,7 @@ static void print_ndtconfig(const struct ndt_config *ndtc)
>         print_uint(PRINT_ANY, "hash_rnd",
>                    "        hash_rnd %u ", ndtc->ndtc_hash_rnd);
>         print_0xhex(PRINT_ANY, "hash_mask",
> -                   "hash_mask %08x ", ndtc->ndtc_hash_mask);
> +                   "hash_mask %08llx ", ndtc->ndtc_hash_mask);
>
>         print_uint(PRINT_ANY, "hash_chain_gc",
>                    "hash_chain_gc %u ", ndtc->ndtc_hash_chain_gc);
> diff --git a/ip/iproute.c b/ip/iproute.c
> index b039f35b0ccd..fa6a84b59a5c 100644
> --- a/ip/iproute.c
> +++ b/ip/iproute.c
> @@ -346,7 +346,7 @@ static void print_rtax_features(FILE *fp, unsigned int features)
>
>         if (features)
>                 print_0xhex(PRINT_ANY,
> -                           "features", "0x%x ", of);
> +                           "features", "%#llx ", of);
>  }
>
>  static void print_rt_flags(FILE *fp, unsigned int flags)
> @@ -483,10 +483,10 @@ static void print_rta_cacheinfo(FILE *fp, const struct rta_cacheinfo *ci)
>         }
>         if (ci->rta_id)
>                 print_0xhex(PRINT_ANY, "ipid",
> -                           "ipid 0x%04x ", ci->rta_id);
> +                           "ipid 0x%04llx ", ci->rta_id);
>         if (ci->rta_ts || ci->rta_tsage) {
>                 print_0xhex(PRINT_ANY, "ts",
> -                           "ts 0x%x", ci->rta_ts);
> +                           "ts 0x%llx", ci->rta_ts);
>                 print_uint(PRINT_ANY, "tsage",
>                            "tsage %usec ", ci->rta_tsage);
>         }
> @@ -885,7 +885,7 @@ int print_route(struct nlmsghdr *n, void *arg)
>                                 print_uint(PRINT_JSON, "mark", NULL, mark);
>                         else if (mark >= 16)
>                                 print_0xhex(PRINT_FP, NULL,
> -                                           "mark 0x%x ", mark);
> +                                           "mark 0x%llx ", mark);
>                         else
>                                 print_uint(PRINT_FP, NULL,
>                                            "mark %u ", mark);
> diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
> index 85ab13cb3174..aee18ac558b5 100644
> --- a/ip/iproute_lwtunnel.c
> +++ b/ip/iproute_lwtunnel.c
> @@ -115,7 +115,7 @@ static void print_srh(FILE *fp, struct ipv6_sr_hdr *srh)
>
>                 tlv = (struct sr6_tlv_hmac *)((char *)srh + offset);
>                 print_0xhex(PRINT_ANY, "hmac",
> -                           "hmac 0x%X ", ntohl(tlv->hmackeyid));
> +                           "hmac %llX ", ntohl(tlv->hmackeyid));
>         }
>  }
>
> diff --git a/ip/iprule.c b/ip/iprule.c
> index a85a43904e6e..0f8fc6d99136 100644
> --- a/ip/iprule.c
> +++ b/ip/iprule.c
> @@ -263,10 +263,10 @@ int print_rule(struct nlmsghdr *n, void *arg)
>
>                 if (tb[FRA_FWMASK] &&
>                     (mask = rta_getattr_u32(tb[FRA_FWMASK])) != 0xFFFFFFFF) {
> -                       print_0xhex(PRINT_ANY, "fwmark", "fwmark 0x%x", mark);
> -                       print_0xhex(PRINT_ANY, "fwmask", "/0x%x ", mask);
> +                       print_0xhex(PRINT_ANY, "fwmark", "fwmark %#llx", mark);
> +                       print_0xhex(PRINT_ANY, "fwmask", "/%#llx ", mask);
>                 } else {
> -                       print_0xhex(PRINT_ANY, "fwmark", "fwmark 0x%x ", mark);
> +                       print_0xhex(PRINT_ANY, "fwmark", "fwmark %#llx ", mark);
>                 }
>         }
>
> diff --git a/ip/iptuntap.c b/ip/iptuntap.c
> index 528055a0bf46..03238c3f6518 100644
> --- a/ip/iptuntap.c
> +++ b/ip/iptuntap.c
> @@ -254,7 +254,7 @@ static void print_flags(long flags)
>         flags &= ~(IFF_TUN | IFF_TAP | IFF_NO_PI | IFF_ONE_QUEUE |
>                    IFF_VNET_HDR | IFF_PERSIST | IFF_NOFILTER);
>         if (flags)
> -               print_0xhex(PRINT_ANY, NULL, "%#x", flags);
> +               print_0xhex(PRINT_ANY, NULL, "%#llx", flags);
>
>         close_json_array(PRINT_JSON, NULL);
>  }
> diff --git a/ip/link_gre.c b/ip/link_gre.c
> index 1ee7ee13ab6c..d754fa9a3425 100644
> --- a/ip/link_gre.c
> +++ b/ip/link_gre.c
> @@ -463,7 +463,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
>                 tos = rta_getattr_u8(tb[IFLA_GRE_TOS]);
>         if (tos) {
>                 if (is_json_context() || tos != 1)
> -                       print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
> +                       print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
>                 else
>                         print_string(PRINT_FP, NULL, "tos %s ", "inherit");
>         }
> @@ -508,7 +508,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
>
>                 if (fwmark) {
>                         print_0xhex(PRINT_ANY,
> -                                   "fwmark", "fwmark 0x%x ", fwmark);
> +                                   "fwmark", "fwmark %#llx ", fwmark);
>                 }
>         }
>
> @@ -541,7 +541,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
>                 __u16 erspan_hwid = rta_getattr_u16(tb[IFLA_GRE_ERSPAN_HWID]);
>
>                 print_0xhex(PRINT_ANY,
> -                           "erspan_hwid", "erspan_hwid 0x%x ", erspan_hwid);
> +                           "erspan_hwid", "erspan_hwid %#llx ", erspan_hwid);
>         }
>
>         tnl_print_encap(tb,
> diff --git a/ip/link_gre6.c b/ip/link_gre6.c
> index 20f930596027..6c4671e5a820 100644
> --- a/ip/link_gre6.c
> +++ b/ip/link_gre6.c
> @@ -576,7 +576,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
>
>                 if (fwmark) {
>                         print_0xhex(PRINT_ANY,
> -                                   "fwmark", "fwmark 0x%x ", fwmark);
> +                                   "fwmark", "fwmark %#llx ", fwmark);
>                 }
>         }
>
> @@ -609,7 +609,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
>                 __u16 erspan_hwid = rta_getattr_u16(tb[IFLA_GRE_ERSPAN_HWID]);
>
>                 print_0xhex(PRINT_ANY,
> -                           "erspan_hwid", "erspan_hwid 0x%x ", erspan_hwid);
> +                           "erspan_hwid", "erspan_hwid %#llx ", erspan_hwid);
>         }
>
>         tnl_print_encap(tb,
> diff --git a/ip/link_ip6tnl.c b/ip/link_ip6tnl.c
> index cfe2c5aa3724..711988a150a5 100644
> --- a/ip/link_ip6tnl.c
> +++ b/ip/link_ip6tnl.c
> @@ -457,7 +457,7 @@ static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb
>
>                 if (fwmark) {
>                         print_0xhex(PRINT_ANY,
> -                                   "fwmark", "fwmark 0x%x ", fwmark);
> +                                   "fwmark", "fwmark %#llx ", fwmark);
>                 }
>         }
>
> diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c
> index 7ec1594d0716..d4a56de40061 100644
> --- a/ip/link_iptnl.c
> +++ b/ip/link_iptnl.c
> @@ -418,7 +418,7 @@ static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[
>                 tos = rta_getattr_u8(tb[IFLA_IPTUN_TOS]);
>         if (tos) {
>                 if (is_json_context() || tos != 1)
> -                       print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
> +                       print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
>                 else
>                         print_string(PRINT_FP, NULL, "tos %s ", "inherit");
>         }
> @@ -476,7 +476,7 @@ static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[
>
>                 if (fwmark) {
>                         print_0xhex(PRINT_ANY,
> -                                   "fwmark", "fwmark 0x%x ", fwmark);
> +                                   "fwmark", "fwmark %#llx ", fwmark);
>                 }
>         }
>
> diff --git a/ip/link_vti.c b/ip/link_vti.c
> index 3fff4417de11..b974c62b2754 100644
> --- a/ip/link_vti.c
> +++ b/ip/link_vti.c
> @@ -208,7 +208,7 @@ static void vti_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
>
>                 if (fwmark) {
>                         print_0xhex(PRINT_ANY,
> -                                   "fwmark", "fwmark 0x%x ", fwmark);
> +                                   "fwmark", "fwmark %#llx ", fwmark);
>                 }
>         }
>  }
> diff --git a/ip/link_vti6.c b/ip/link_vti6.c
> index f5a267a81d9d..f13c08583103 100644
> --- a/ip/link_vti6.c
> +++ b/ip/link_vti6.c
> @@ -210,7 +210,7 @@ static void vti6_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
>
>                 if (fwmark) {
>                         print_0xhex(PRINT_ANY,
> -                                   "fwmark", "fwmark 0x%x ", fwmark);
> +                                   "fwmark", "fwmark %#llx ", fwmark);
>                 }
>         }
>  }
> diff --git a/tc/m_ife.c b/tc/m_ife.c
> index 20e9c73d9a0e..2bf9f2047b46 100644
> --- a/tc/m_ife.c
> +++ b/tc/m_ife.c
> @@ -247,7 +247,7 @@ static int print_ife(struct action_util *au, FILE *f, struct rtattr *arg)
>         if (tb[TCA_IFE_TYPE]) {
>                 ife_type = rta_getattr_u16(tb[TCA_IFE_TYPE]);
>                 has_optional = 1;
> -               print_0xhex(PRINT_ANY, "type", "type 0x%X ", ife_type);
> +               print_0xhex(PRINT_ANY, "type", "type %#llX ", ife_type);
>         }
>
>         if (has_optional)
> diff --git a/tc/q_htb.c b/tc/q_htb.c
> index 5fb11d28c5c3..520522266e00 100644
> --- a/tc/q_htb.c
> +++ b/tc/q_htb.c
> @@ -332,7 +332,7 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
>                 if (RTA_PAYLOAD(tb[TCA_HTB_INIT])  < sizeof(*gopt)) return -1;
>
>                 print_int(PRINT_ANY, "r2q", "r2q %d", gopt->rate2quantum);
> -               print_0xhex(PRINT_ANY, "default", " default %x", gopt->defcls);
> +               print_0xhex(PRINT_ANY, "default", " default %#llx", gopt->defcls);
>                 print_uint(PRINT_ANY, "direct_packets_stat",
>                            " direct_packets_stat %u", gopt->direct_pkts);
>                 if (show_details) {
> diff --git a/tc/q_taprio.c b/tc/q_taprio.c
> index 562dacb874f0..8f6b263a4141 100644
> --- a/tc/q_taprio.c
> +++ b/tc/q_taprio.c
> @@ -328,7 +328,7 @@ static int print_sched_list(FILE *f, struct rtattr *list)
>                 open_json_object(NULL);
>                 print_uint(PRINT_ANY, "index", "\tindex %u", index);
>                 print_string(PRINT_ANY, "cmd", " cmd %s", entry_cmd_to_str(command));
> -               print_0xhex(PRINT_ANY, "gatemask", " gatemask %#x", gatemask);
> +               print_0xhex(PRINT_ANY, "gatemask", " gatemask %#llx", gatemask);
>                 print_uint(PRINT_ANY, "interval", " interval %u", interval);
>                 close_json_object();
>
> --
> 2.19.2
>
Serhey Popovych Dec. 19, 2018, 8 p.m. UTC | #2
Stephen Hemminger wrote:

> The argument to print_0xhex is converted to unsigned long long
> so the format string give for normal printout has to be some
> variant of %llx. Otherwise, bogus values will be printed on
> 32 bit platforms.

Sorry it is too late and change is merged as commit 90c5c969f0b9
("fix print_0xhex on 32 bit") but I want to ask following:

  $ printf '0x%llx != %#llx\n' 0 0
  0x0 != 0

So we potentially can get "tos 0" vs "tos 0x0" previously. Is that
expected and will not cause any compatibility problems?

It is clear that 0 is always zero, but some code may rely on 0x form
even for zero. What do you think?

Thanks.
Stephen Hemminger Dec. 19, 2018, 10:02 p.m. UTC | #3
On Wed, 19 Dec 2018 22:00:38 +0200
Serhey Popovych <serhe.popovych@gmail.com> wrote:

> Stephen Hemminger wrote:
> 
> > The argument to print_0xhex is converted to unsigned long long
> > so the format string give for normal printout has to be some
> > variant of %llx. Otherwise, bogus values will be printed on
> > 32 bit platforms.  
> 
> Sorry it is too late and change is merged as commit 90c5c969f0b9
> ("fix print_0xhex on 32 bit") but I want to ask following:
> 
>   $ printf '0x%llx != %#llx\n' 0 0
>   0x0 != 0
> 
> So we potentially can get "tos 0" vs "tos 0x0" previously. Is that
> expected and will not cause any compatibility problems?
> 
> It is clear that 0 is always zero, but some code may rely on 0x form
> even for zero. What do you think?
> 
> Thanks.
> 
> 

Hmm. that is a surprise. we can change back if it matters.
Was just trying to be consistent.  Since most code that scraps is going to use strtoul(str, NULL, 16)
it shouldn't matter.
diff mbox series

Patch

diff --git a/bridge/link.c b/bridge/link.c
index 3290c16f0951..32317e53b036 100644
--- a/bridge/link.c
+++ b/bridge/link.c
@@ -90,7 +90,7 @@  static void print_hwmode(__u16 mode)
 {
 	if (mode >= ARRAY_SIZE(hw_mode))
 		print_0xhex(PRINT_ANY, "hwmode",
-			    "hwmode %#hx ", mode);
+			    "hwmode %#llx ", mode);
 	else
 		print_string(PRINT_ANY, "hwmode",
 			     "hwmode %s ", hw_mode[mode]);
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 21985a5ee6f3..016662e910e9 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -129,7 +129,7 @@  static void print_operstate(FILE *f, __u8 state)
 		if (is_json_context())
 			print_uint(PRINT_JSON, "operstate_index", NULL, state);
 		else
-			print_0xhex(PRINT_FP, NULL, "state %#x", state);
+			print_0xhex(PRINT_FP, NULL, "state %#llx", state);
 	} else if (brief) {
 		print_color_string(PRINT_ANY,
 				   oper_state_color(state),
diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c
index 0ba6be3f47da..fbf8a79bfbbb 100644
--- a/ip/iplink_bridge.c
+++ b/ip/iplink_bridge.c
@@ -524,7 +524,7 @@  static void bridge_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 	if (tb[IFLA_BR_GROUP_FWD_MASK])
 		print_0xhex(PRINT_ANY,
 			    "group_fwd_mask",
-			    "group_fwd_mask %#x ",
+			    "group_fwd_mask %#llx ",
 			    rta_getattr_u16(tb[IFLA_BR_GROUP_FWD_MASK]));
 
 	if (tb[IFLA_BR_GROUP_ADDR]) {
diff --git a/ip/iplink_bridge_slave.c b/ip/iplink_bridge_slave.c
index 8b4f93f265be..85e6b424315f 100644
--- a/ip/iplink_bridge_slave.c
+++ b/ip/iplink_bridge_slave.c
@@ -168,11 +168,11 @@  static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
 			     rta_getattr_u8(tb[IFLA_BRPORT_UNICAST_FLOOD]));
 
 	if (tb[IFLA_BRPORT_ID])
-		print_0xhex(PRINT_ANY, "id", "port_id 0x%x ",
+		print_0xhex(PRINT_ANY, "id", "port_id %#llx ",
 			    rta_getattr_u16(tb[IFLA_BRPORT_ID]));
 
 	if (tb[IFLA_BRPORT_NO])
-		print_0xhex(PRINT_ANY, "no", "port_no 0x%x ",
+		print_0xhex(PRINT_ANY, "no", "port_no %#llx ",
 			   rta_getattr_u16(tb[IFLA_BRPORT_NO]));
 
 	if (tb[IFLA_BRPORT_DESIGNATED_PORT])
@@ -267,7 +267,7 @@  static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
 
 		fwd_mask = rta_getattr_u16(tb[IFLA_BRPORT_GROUP_FWD_MASK]);
 		print_0xhex(PRINT_ANY, "group_fwd_mask",
-			    "group_fwd_mask 0x%x ", fwd_mask);
+			    "group_fwd_mask %#llx ", fwd_mask);
 		_bitmask2str(fwd_mask, convbuf, sizeof(convbuf), fwd_mask_tbl);
 		print_string(PRINT_ANY, "group_fwd_mask_str",
 			     "group_fwd_mask_str %s ", convbuf);
diff --git a/ip/iplink_geneve.c b/ip/iplink_geneve.c
index c417842b2a5b..f1a12f454ab7 100644
--- a/ip/iplink_geneve.c
+++ b/ip/iplink_geneve.c
@@ -282,7 +282,7 @@  static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 		tos = rta_getattr_u8(tb[IFLA_GENEVE_TOS]);
 	if (tos) {
 		if (is_json_context() || tos != 1)
-			print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
+			print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
 		else
 			print_string(PRINT_FP, NULL, "tos %s ", "inherit");
 	}
@@ -292,8 +292,7 @@  static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 
 		if (label)
 			print_0xhex(PRINT_ANY,
-				    "label",
-				    "flowlabel %#x ",
+				    "label", "flowlabel %#llx ",
 				    ntohl(label));
 	}
 
diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c
index 7fc0e2b4eb06..62e769430c5d 100644
--- a/ip/iplink_vxlan.c
+++ b/ip/iplink_vxlan.c
@@ -522,7 +522,7 @@  static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 		tos = rta_getattr_u8(tb[IFLA_VXLAN_TOS]);
 	if (tos) {
 		if (is_json_context() || tos != 1)
-			print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
+			print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
 		else
 			print_string(PRINT_FP, NULL, "tos %s ", "inherit");
 	}
@@ -542,10 +542,8 @@  static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 		__u32 label = rta_getattr_u32(tb[IFLA_VXLAN_LABEL]);
 
 		if (label)
-			print_0xhex(PRINT_ANY,
-				    "label",
-				    "flowlabel %#x ",
-				    ntohl(label));
+			print_0xhex(PRINT_ANY, "label",
+				    "flowlabel %#llx ", ntohl(label));
 	}
 
 	if (tb[IFLA_VXLAN_AGEING]) {
diff --git a/ip/ipntable.c b/ip/ipntable.c
index 5b61dd5cb001..50fc949f1fcc 100644
--- a/ip/ipntable.c
+++ b/ip/ipntable.c
@@ -360,7 +360,7 @@  static void print_ndtconfig(const struct ndt_config *ndtc)
 	print_uint(PRINT_ANY, "hash_rnd",
 		   "        hash_rnd %u ", ndtc->ndtc_hash_rnd);
 	print_0xhex(PRINT_ANY, "hash_mask",
-		    "hash_mask %08x ", ndtc->ndtc_hash_mask);
+		    "hash_mask %08llx ", ndtc->ndtc_hash_mask);
 
 	print_uint(PRINT_ANY, "hash_chain_gc",
 		   "hash_chain_gc %u ", ndtc->ndtc_hash_chain_gc);
diff --git a/ip/iproute.c b/ip/iproute.c
index b039f35b0ccd..fa6a84b59a5c 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -346,7 +346,7 @@  static void print_rtax_features(FILE *fp, unsigned int features)
 
 	if (features)
 		print_0xhex(PRINT_ANY,
-			    "features", "0x%x ", of);
+			    "features", "%#llx ", of);
 }
 
 static void print_rt_flags(FILE *fp, unsigned int flags)
@@ -483,10 +483,10 @@  static void print_rta_cacheinfo(FILE *fp, const struct rta_cacheinfo *ci)
 	}
 	if (ci->rta_id)
 		print_0xhex(PRINT_ANY, "ipid",
-			    "ipid 0x%04x ", ci->rta_id);
+			    "ipid 0x%04llx ", ci->rta_id);
 	if (ci->rta_ts || ci->rta_tsage) {
 		print_0xhex(PRINT_ANY, "ts",
-			    "ts 0x%x", ci->rta_ts);
+			    "ts 0x%llx", ci->rta_ts);
 		print_uint(PRINT_ANY, "tsage",
 			   "tsage %usec ", ci->rta_tsage);
 	}
@@ -885,7 +885,7 @@  int print_route(struct nlmsghdr *n, void *arg)
 				print_uint(PRINT_JSON, "mark", NULL, mark);
 			else if (mark >= 16)
 				print_0xhex(PRINT_FP, NULL,
-					    "mark 0x%x ", mark);
+					    "mark 0x%llx ", mark);
 			else
 				print_uint(PRINT_FP, NULL,
 					   "mark %u ", mark);
diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
index 85ab13cb3174..aee18ac558b5 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -115,7 +115,7 @@  static void print_srh(FILE *fp, struct ipv6_sr_hdr *srh)
 
 		tlv = (struct sr6_tlv_hmac *)((char *)srh + offset);
 		print_0xhex(PRINT_ANY, "hmac",
-			    "hmac 0x%X ", ntohl(tlv->hmackeyid));
+			    "hmac %llX ", ntohl(tlv->hmackeyid));
 	}
 }
 
diff --git a/ip/iprule.c b/ip/iprule.c
index a85a43904e6e..0f8fc6d99136 100644
--- a/ip/iprule.c
+++ b/ip/iprule.c
@@ -263,10 +263,10 @@  int print_rule(struct nlmsghdr *n, void *arg)
 
 		if (tb[FRA_FWMASK] &&
 		    (mask = rta_getattr_u32(tb[FRA_FWMASK])) != 0xFFFFFFFF) {
-			print_0xhex(PRINT_ANY, "fwmark", "fwmark 0x%x", mark);
-			print_0xhex(PRINT_ANY, "fwmask", "/0x%x ", mask);
+			print_0xhex(PRINT_ANY, "fwmark", "fwmark %#llx", mark);
+			print_0xhex(PRINT_ANY, "fwmask", "/%#llx ", mask);
 		} else {
-			print_0xhex(PRINT_ANY, "fwmark", "fwmark 0x%x ", mark);
+			print_0xhex(PRINT_ANY, "fwmark", "fwmark %#llx ", mark);
 		}
 	}
 
diff --git a/ip/iptuntap.c b/ip/iptuntap.c
index 528055a0bf46..03238c3f6518 100644
--- a/ip/iptuntap.c
+++ b/ip/iptuntap.c
@@ -254,7 +254,7 @@  static void print_flags(long flags)
 	flags &= ~(IFF_TUN | IFF_TAP | IFF_NO_PI | IFF_ONE_QUEUE |
 		   IFF_VNET_HDR | IFF_PERSIST | IFF_NOFILTER);
 	if (flags)
-		print_0xhex(PRINT_ANY, NULL, "%#x", flags);
+		print_0xhex(PRINT_ANY, NULL, "%#llx", flags);
 
 	close_json_array(PRINT_JSON, NULL);
 }
diff --git a/ip/link_gre.c b/ip/link_gre.c
index 1ee7ee13ab6c..d754fa9a3425 100644
--- a/ip/link_gre.c
+++ b/ip/link_gre.c
@@ -463,7 +463,7 @@  static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 		tos = rta_getattr_u8(tb[IFLA_GRE_TOS]);
 	if (tos) {
 		if (is_json_context() || tos != 1)
-			print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
+			print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
 		else
 			print_string(PRINT_FP, NULL, "tos %s ", "inherit");
 	}
@@ -508,7 +508,7 @@  static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 
 		if (fwmark) {
 			print_0xhex(PRINT_ANY,
-				    "fwmark", "fwmark 0x%x ", fwmark);
+				    "fwmark", "fwmark %#llx ", fwmark);
 		}
 	}
 
@@ -541,7 +541,7 @@  static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 		__u16 erspan_hwid = rta_getattr_u16(tb[IFLA_GRE_ERSPAN_HWID]);
 
 		print_0xhex(PRINT_ANY,
-			    "erspan_hwid", "erspan_hwid 0x%x ", erspan_hwid);
+			    "erspan_hwid", "erspan_hwid %#llx ", erspan_hwid);
 	}
 
 	tnl_print_encap(tb,
diff --git a/ip/link_gre6.c b/ip/link_gre6.c
index 20f930596027..6c4671e5a820 100644
--- a/ip/link_gre6.c
+++ b/ip/link_gre6.c
@@ -576,7 +576,7 @@  static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 
 		if (fwmark) {
 			print_0xhex(PRINT_ANY,
-				    "fwmark", "fwmark 0x%x ", fwmark);
+				    "fwmark", "fwmark %#llx ", fwmark);
 		}
 	}
 
@@ -609,7 +609,7 @@  static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 		__u16 erspan_hwid = rta_getattr_u16(tb[IFLA_GRE_ERSPAN_HWID]);
 
 		print_0xhex(PRINT_ANY,
-			    "erspan_hwid", "erspan_hwid 0x%x ", erspan_hwid);
+			    "erspan_hwid", "erspan_hwid %#llx ", erspan_hwid);
 	}
 
 	tnl_print_encap(tb,
diff --git a/ip/link_ip6tnl.c b/ip/link_ip6tnl.c
index cfe2c5aa3724..711988a150a5 100644
--- a/ip/link_ip6tnl.c
+++ b/ip/link_ip6tnl.c
@@ -457,7 +457,7 @@  static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb
 
 		if (fwmark) {
 			print_0xhex(PRINT_ANY,
-				    "fwmark", "fwmark 0x%x ", fwmark);
+				    "fwmark", "fwmark %#llx ", fwmark);
 		}
 	}
 
diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c
index 7ec1594d0716..d4a56de40061 100644
--- a/ip/link_iptnl.c
+++ b/ip/link_iptnl.c
@@ -418,7 +418,7 @@  static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[
 		tos = rta_getattr_u8(tb[IFLA_IPTUN_TOS]);
 	if (tos) {
 		if (is_json_context() || tos != 1)
-			print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
+			print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
 		else
 			print_string(PRINT_FP, NULL, "tos %s ", "inherit");
 	}
@@ -476,7 +476,7 @@  static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[
 
 		if (fwmark) {
 			print_0xhex(PRINT_ANY,
-				    "fwmark", "fwmark 0x%x ", fwmark);
+				    "fwmark", "fwmark %#llx ", fwmark);
 		}
 	}
 
diff --git a/ip/link_vti.c b/ip/link_vti.c
index 3fff4417de11..b974c62b2754 100644
--- a/ip/link_vti.c
+++ b/ip/link_vti.c
@@ -208,7 +208,7 @@  static void vti_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 
 		if (fwmark) {
 			print_0xhex(PRINT_ANY,
-				    "fwmark", "fwmark 0x%x ", fwmark);
+				    "fwmark", "fwmark %#llx ", fwmark);
 		}
 	}
 }
diff --git a/ip/link_vti6.c b/ip/link_vti6.c
index f5a267a81d9d..f13c08583103 100644
--- a/ip/link_vti6.c
+++ b/ip/link_vti6.c
@@ -210,7 +210,7 @@  static void vti6_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 
 		if (fwmark) {
 			print_0xhex(PRINT_ANY,
-				    "fwmark", "fwmark 0x%x ", fwmark);
+				    "fwmark", "fwmark %#llx ", fwmark);
 		}
 	}
 }
diff --git a/tc/m_ife.c b/tc/m_ife.c
index 20e9c73d9a0e..2bf9f2047b46 100644
--- a/tc/m_ife.c
+++ b/tc/m_ife.c
@@ -247,7 +247,7 @@  static int print_ife(struct action_util *au, FILE *f, struct rtattr *arg)
 	if (tb[TCA_IFE_TYPE]) {
 		ife_type = rta_getattr_u16(tb[TCA_IFE_TYPE]);
 		has_optional = 1;
-		print_0xhex(PRINT_ANY, "type", "type 0x%X ", ife_type);
+		print_0xhex(PRINT_ANY, "type", "type %#llX ", ife_type);
 	}
 
 	if (has_optional)
diff --git a/tc/q_htb.c b/tc/q_htb.c
index 5fb11d28c5c3..520522266e00 100644
--- a/tc/q_htb.c
+++ b/tc/q_htb.c
@@ -332,7 +332,7 @@  static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 		if (RTA_PAYLOAD(tb[TCA_HTB_INIT])  < sizeof(*gopt)) return -1;
 
 		print_int(PRINT_ANY, "r2q", "r2q %d", gopt->rate2quantum);
-		print_0xhex(PRINT_ANY, "default", " default %x", gopt->defcls);
+		print_0xhex(PRINT_ANY, "default", " default %#llx", gopt->defcls);
 		print_uint(PRINT_ANY, "direct_packets_stat",
 			   " direct_packets_stat %u", gopt->direct_pkts);
 		if (show_details) {
diff --git a/tc/q_taprio.c b/tc/q_taprio.c
index 562dacb874f0..8f6b263a4141 100644
--- a/tc/q_taprio.c
+++ b/tc/q_taprio.c
@@ -328,7 +328,7 @@  static int print_sched_list(FILE *f, struct rtattr *list)
 		open_json_object(NULL);
 		print_uint(PRINT_ANY, "index", "\tindex %u", index);
 		print_string(PRINT_ANY, "cmd", " cmd %s", entry_cmd_to_str(command));
-		print_0xhex(PRINT_ANY, "gatemask", " gatemask %#x", gatemask);
+		print_0xhex(PRINT_ANY, "gatemask", " gatemask %#llx", gatemask);
 		print_uint(PRINT_ANY, "interval", " interval %u", interval);
 		close_json_object();