Skip to content

Commit

Permalink
Merge pull request #1159 from javierbrk/fix/get_node_status
Browse files Browse the repository at this point in the history
Fix get node status to work with busybox ip command
  • Loading branch information
G10h4ck authored Dec 27, 2024
2 parents 51294cc + b44625a commit 29b5f66
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions packages/ubus-lime-utils/files/usr/lib/lua/lime/node_status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,24 @@ end

function node_status.dsa_get_link_status(ports)
for _, port in ipairs(ports) do
local dsa = utils.unsafe_shell("ip -j -p link show " .. port['num'])
local dsa_json = json.parse(dsa)

port['device'] = port['num']
port['num'] = dsa_json[1]['ifindex']
port['role'] = dsa_json[1]['link']
if dsa_json[1]['link'] == nil then
port['role'] = dsa_json[1]['ifname']
end
port['link'] = dsa_json[1]['operstate']
if dsa_json[1]['operstate'] == "LOWERLAYERDOWN" then
port['link'] = "DOWN"
end
end
return ports
end
local dsa = utils.unsafe_shell("ip link show " .. port['num'])
-- Match ifindex, ifname, link (optional), and operstate
local ifindex, ifname, link, operstate = dsa:match("^(%d+): ([^:@]+)@?([^:]*):.-state (%S+)")
if ifindex and ifname and operstate then
port['device'] = port['num']
port['num'] = tonumber(ifindex)
port['role'] = link ~= "" and link or nil -- Handle optional link field
if port['role'] == nil then
port['role'] = ifname
end
port['link'] = operstate
if operstate == "LOWERLAYERDOWN" then
port['link'] = "DOWN"
end
end
end
return ports
end


function node_status.swconfig_get_link_status(ports)
Expand Down

0 comments on commit 29b5f66

Please sign in to comment.