routel script gives shift errors

Bug #2018330 reported by Tired Sysadmin
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
iproute2 (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

The routel(8) shell script is meant to format the output of ip(8) commands for human viewing, but the script is not robust enough.

Running 22.04.2 LTS jammy jellyfish, freshly installed on an AWS EC2 instance and then "apt upgrade"d. (It's headless and remote, so it can't submit bug reports. I generated an apport file, but have no other Ubuntu system that could re-parse it to submit the report. But it's here if it would be useful.) The iproute2 package is:

iproute2:
  Installed: 5.15.0-1ubuntu2
  Candidate: 5.15.0-1ubuntu2
  Version table:
 *** 5.15.0-1ubuntu2 500
        500 http://us-east-2.ec2.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
        100 /var/lib/dpkg/status

Here's the raw output of ip(8):
$ ip route list table 0
default via 10.37.67.1 dev eth0 proto dhcp src 10.37.67.187 metric 100
10.37.64.2 via 10.37.67.1 dev eth0 proto dhcp src 10.37.67.187 metric 100
10.37.64.231 via 10.37.67.1 dev eth0 proto dhcp src 10.37.67.187 metric 100
10.37.65.30 via 10.37.67.1 dev eth0 proto dhcp src 10.37.67.187 metric 100
10.37.67.0/24 dev eth0 proto kernel scope link src 10.37.67.187 metric 100
10.37.67.1 dev eth0 proto dhcp scope link src 10.37.67.187 metric 100
local 10.37.67.187 dev eth0 table local proto kernel scope host src 10.37.67.187
broadcast 10.37.67.255 dev eth0 table local proto kernel scope link src 10.37.67.187
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1
::1 dev lo proto kernel metric 256 pref medium
fe80::/64 dev eth0 proto kernel metric 256 pref medium
local ::1 dev lo table local proto kernel metric 0 pref medium
local fe80::458:96ff:fe61:6829 dev eth0 table local proto kernel metric 0 pref medium
multicast ff00::/8 dev eth0 table local proto kernel metric 256 pref medium

Running routel, however, yields this:
$ routel
         target gateway source proto scope dev tbl
        default 10.37.67.1 10.37.67.187 dhcp eth0
     10.37.64.2 10.37.67.1 10.37.67.187 dhcp eth0
   10.37.64.231 10.37.67.1 10.37.67.187 dhcp eth0
    10.37.65.30 10.37.67.1 10.37.67.187 dhcp eth0
    10.37.67.0/ 24 10.37.67.187 kernel link eth0
     10.37.67.1 10.37.67.187 dhcp link eth0
   10.37.67.187 local 10.37.67.187 kernel host eth0 local
   10.37.67.255 broadcast 10.37.67.187 kernel link eth0 local
     127.0.0.0/ 8 local 127.0.0.1 kernel host lo local
      127.0.0.1 local 127.0.0.1 kernel host lo local
127.255.255.255 broadcast 127.0.0.1 kernel link lo local
/usr/bin/routel: 48: shift: ::1 kernel lo
        fe80::/ 64 kernel eth0
            ::1 local kernel lo local
fe80::458:96ff:fe61:6829 local kernel eth0 local
can't shift that many

Splitting stdout and stderr for readability:
$ routel 2> /tmp/err
         target gateway source proto scope dev tbl
        default 10.37.67.1 10.37.67.187 dhcp eth0
     10.37.64.2 10.37.67.1 10.37.67.187 dhcp eth0
   10.37.64.231 10.37.67.1 10.37.67.187 dhcp eth0
    10.37.65.30 10.37.67.1 10.37.67.187 dhcp eth0
    10.37.67.0/ 24 10.37.67.187 kernel link eth0
     10.37.67.1 10.37.67.187 dhcp link eth0
   10.37.67.187 local 10.37.67.187 kernel host eth0 local
   10.37.67.255 broadcast 10.37.67.187 kernel link eth0 local
     127.0.0.0/ 8 local 127.0.0.1 kernel host lo local
      127.0.0.1 local 127.0.0.1 kernel host lo local
127.255.255.255 broadcast 127.0.0.1 kernel link lo local
            ::1 kernel lo
        fe80::/ 64 kernel eth0
            ::1 local kernel lo local
fe80::458:96ff:fe61:6829 local kernel eth0 local
$ cat /tmp/err
/usr/bin/routel: 48: shift: can't shift that many
$

It's giving the same errors as in Debian bug 875476 some six years ago, which was "fixed in upstream" and then apparently broken again.

Revision history for this message
Tired Sysadmin (wearyofallthiscrap) wrote :

Web form kept defaulting to package "avahi" no matter how many times I typed in iproute2...

affects: avahi (Ubuntu) → iproute2 (Ubuntu)
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in iproute2 (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.