Skip to main content
added 1392 characters in body
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k

iproute2: raw and buggy

For ip link at least, even control characters 0x1 .. 0x1f (only some of which are not allowed in interface names) are output raw which is invalid in JSON.

$ ifname=$'\1\xe9' $ sudo ip link add name $ifname type dummy $ sudo ip link add name $ifname type dummy 

(added twice! First time got renamed to __).

$ ip l [...] 14: __: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 12:22:77:40:6f:8c brd ff:ff:ff:ff:ff:ff 15: �: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 12:22:77:40:6f:8c brd ff:ff:ff:ff:ff:ff $ ip -j l | sed -n l [...] dcast":"ff:ff:ff:ff:ff:ff"},{"ifindex":14,"ifname":"__","flags":["BRO\ ADCAST","NOARP"],"mtu":1500,"qdisc":"noop","operstate":"DOWN","linkmo\ de":"DEFAULT","group":"default","txqlen":1000,"link_type":"ether","ad\ dress":"12:22:77:40:6f:8c","broadcast":"ff:ff:ff:ff:ff:ff"},{"ifindex\ ":15,"ifname":"\001\351","flags":["BROADCAST","NOARP"],"mtu":1500,"qd\ isc":"noop","operstate":"DOWN","linkmode":"DEFAULT","group":"default"\ ,"txqlen":1000,"link_type":"ether","address":"12:22:77:40:6f:8c","bro\ adcast":"ff:ff:ff:ff:ff:ff"}]$ 
$ ip -V ip utility, iproute2-6.5.0, libbpf 1.2.2 

iproute2: raw and buggy

For ip link at least, even control characters 0x1 .. 0x1f (only some of which are not allowed in interface names) are output raw which is invalid in JSON.

$ ifname=$'\1\xe9' $ sudo ip link add name $ifname type dummy $ sudo ip link add name $ifname type dummy 

(added twice! First time got renamed to __).

$ ip l [...] 14: __: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 12:22:77:40:6f:8c brd ff:ff:ff:ff:ff:ff 15: �: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 12:22:77:40:6f:8c brd ff:ff:ff:ff:ff:ff $ ip -j l | sed -n l [...] dcast":"ff:ff:ff:ff:ff:ff"},{"ifindex":14,"ifname":"__","flags":["BRO\ ADCAST","NOARP"],"mtu":1500,"qdisc":"noop","operstate":"DOWN","linkmo\ de":"DEFAULT","group":"default","txqlen":1000,"link_type":"ether","ad\ dress":"12:22:77:40:6f:8c","broadcast":"ff:ff:ff:ff:ff:ff"},{"ifindex\ ":15,"ifname":"\001\351","flags":["BROADCAST","NOARP"],"mtu":1500,"qd\ isc":"noop","operstate":"DOWN","linkmode":"DEFAULT","group":"default"\ ,"txqlen":1000,"link_type":"ether","address":"12:22:77:40:6f:8c","bro\ adcast":"ff:ff:ff:ff:ff:ff"}]$ 
$ ip -V ip utility, iproute2-6.5.0, libbpf 1.2.2 

added 2 characters in body
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k
  • does that JSON format with strings not properly UTF-8 encoded (with some byte values >= 0x80 that don't form part of valid UTF-8-encoded charactercharacters) have a name?
  • Are there any tools or programming language modules (preferably perl, but I'm open to others) that can process that format reliably?
  • Or can that format be converted to/from valid JSON so it can be processed by JSON processing utilities such as jq, json_xs, mlr... Preferably in a way that preserves valid JSON strings and without losing information?

@raf@raf's rawhide: raw

  • does that JSON format with strings not properly UTF-8 encoded (with some byte values >= 0x80 that don't form part of valid UTF-8-encoded character) have a name?
  • Are there any tools or programming language modules (preferably perl, but I'm open to others) that can process that format reliably?
  • Or can that format be converted to/from valid JSON so it can be processed by JSON processing utilities such as jq, json_xs, mlr... Preferably in a way that preserves valid JSON strings and without losing information?

@raf's rawhide: raw

  • does that JSON format with strings not properly UTF-8 encoded (with some byte values >= 0x80 that don't form part of valid UTF-8-encoded characters) have a name?
  • Are there any tools or programming language modules (preferably perl, but I'm open to others) that can process that format reliably?
  • Or can that format be converted to/from valid JSON so it can be processed by JSON processing utilities such as jq, json_xs, mlr... Preferably in a way that preserves valid JSON strings and without losing information?

@raf's rawhide: raw

added 263 characters in body
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k

@raf's rawhide: raw

$ rh -j | sed -n l [...] {"path":"./St\351phane", "name":"St\351phane", "start":".", "depth":1\ [...] 

@raf's rawhide: raw

$ rh -j | sed -n l [...] {"path":"./St\351phane", "name":"St\351phane", "start":".", "depth":1\ [...] 

added 1 character in body
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k
Loading
added 419 characters in body
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k
Loading
added 8 characters in body
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k
Loading
added 9 characters in body
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k
Loading
added 87 characters in body
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k
Loading
added 9 characters in body
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k
Loading
added 672 characters in body
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k
Loading
added 184 characters in body
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k
Loading
added 392 characters in body
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k
Loading
Source Link
Stéphane Chazelas
  • 586.2k
  • 96
  • 1.1k
  • 1.7k
Loading