Skip to content

Commit dc400c5

Browse files
[bot] AutoMerging: merge all upstream's changes:
* https://github.com/coolsnowwolf/lede: autocore: ethinfo: rewritten in lua umbim: fixes build with gcc 11 (coolsnowwolf#10163)
2 parents 672cadc + 4f056f8 commit dc400c5

File tree

2 files changed

+39
-41
lines changed

2 files changed

+39
-41
lines changed
+37-39
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
1-
#!/bin/sh
2-
3-
a=$(ls /sys/class/net/*/device/uevent | grep eth | awk -F '/' '{print $5}')
4-
b=$(echo "$a" | wc -l)
5-
rm -f /tmp/state/ethinfo
6-
7-
echo -n "[" > /tmp/state/ethinfo
8-
9-
for i in $(seq 1 $b)
10-
do
11-
h=$(echo '{"name":' )
12-
c=$(echo "$a" | sed -n ${i}p)
13-
d=$(ethtool $c)
14-
15-
e=$(echo "$d" | grep "Link detected" | awk -F: '{printf $2}' | sed 's/^[ \t]*//g')
16-
if [ $e = yes ]; then
17-
l=1
18-
else
19-
l=0
20-
fi
21-
22-
f=$(echo "$d" | grep "Speed" | awk -F: '{printf $2}' | sed 's/^[ \t]*//g' | tr -d "Unknown!")
23-
[ -z "$f" ] && f=" - "
24-
25-
g=$(echo "$d" | grep "Duplex" | awk -F: '{printf $2}' | sed 's/^[ \t]*//g')
26-
if [ "$g" == "Full" ]; then
27-
x=1
28-
else
29-
x=0
30-
fi
31-
32-
echo -n "$h \"$c\", \"status\": $l, \"speed\": \"$f\", \"duplex\": $x}," >> /tmp/state/ethinfo
33-
done
34-
35-
sed -i 's/.$//' /tmp/state/ethinfo
36-
37-
echo -n "]" >> /tmp/state/ethinfo
38-
39-
cat /tmp/state/ethinfo
1+
#!/usr/bin/lua
2+
-- Copyright (C) 2022 Tianling Shen <[email protected]>
3+
4+
local util = require "luci.util"
5+
local jsonc = require "luci.jsonc"
6+
7+
local eth_info = {}
8+
local ifname, stat
9+
for ifname, stat in pairs(util.ubus("network.device", "status")) do
10+
if ifname:match("^(eth%d+)$") == ifname then
11+
local status, speed, duplex
12+
13+
status = stat.carrier and 1 or 0
14+
15+
if stat.speed:sub(1, 1) == "-" then
16+
speed = " - "
17+
else
18+
speed = stat.speed:sub(1, -2) .. "Mb/s"
19+
end
20+
21+
if stat.carrier and stat.speed:sub(-1) == "F" then
22+
duplex = 1
23+
else
24+
duplex = 0
25+
end
26+
27+
eth_info[#eth_info+1] = { name = ifname, status = status,
28+
speed = speed, duplex = duplex }
29+
end
30+
end
31+
32+
table.sort(eth_info,
33+
function(a, b)
34+
return a.name < b.name
35+
end)
36+
37+
print(jsonc.stringify(eth_info))

package/network/utils/umbim/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include $(TOPDIR)/rules.mk
22

33
PKG_NAME:=umbim
4-
PKG_RELEASE:=2
4+
PKG_RELEASE:=3
55

66
PKG_SOURCE_PROTO:=git
77
PKG_SOURCE_URL=$(PROJECT_GIT)/project/umbim.git
@@ -34,7 +34,7 @@ define Package/umbim/description
3434
endef
3535

3636
TARGET_CFLAGS += \
37-
-I$(STAGING_DIR)/usr/include -ffunction-sections -fdata-sections
37+
-I$(STAGING_DIR)/usr/include -ffunction-sections -fdata-sections -Wno-address-of-packed-member
3838

3939
TARGET_LDFLAGS += -Wl,--gc-sections
4040

0 commit comments

Comments
 (0)