Skip to content

Commit

Permalink
confd: sort interfaces according to length and name
Browse files Browse the repository at this point in the history
A list of interfaces: x10 x9 x8 x7 x6 x5 x4 x1 x2 x3 should be sorted in
order with x10 last.  This hack accounts for the length that a regular
'sort -n' would otherwise generate: x1 x10 x2 ...

This way we can ensure that the order of bridge ports is natural and
what end users expect.

Signed-off-by: Joachim Wiberg <[email protected]>
  • Loading branch information
troglobit committed Oct 26, 2023
1 parent 9593bfd commit ae199f7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/confd/bin/gen-interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ phys_ifaces=$(ip -d -j link show | jq -r '
select(.link_type == "ether") |
select(.group != "internal") |
select(has("parentbus")) |
.ifname')
.ifname' | awk '{print length($0), $0}' | sort -n | cut -d' ' -f2-)
ports=$(ip -d -j link show group port | jq -r '
.[] |
select(.link_type == "ether") |
select(.group != "internal") |
select(has("parentbus")) |
.ifname')
.ifname' | awk '{print length($0), $0}' | sort -n | cut -d' ' -f2-)
ifaces=""
for phy in $phys_ifaces; do
found=""
Expand Down

0 comments on commit ae199f7

Please sign in to comment.