lantiq: xrx200: rename nas0/ptm0 to dsl0
authorMartin Schiller <ms@dev.tdt.de>
Mon, 9 Oct 2017 06:26:01 +0000 (08:26 +0200)
committerMathias Kresin <dev@kresin.me>
Sun, 15 Oct 2017 09:11:29 +0000 (11:11 +0200)
This change makes it possible to configure the wan/dsl ppp interface
settings independantly from the used TC-Layer (ATM/PTM).

Now you can move a device from an ADSL/ATM port to an VDSL/PTM port
without any configuration changes for example.

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
[use the dsl0 interface name for the default netdev trigger in 01_led,
add ip dependency]
Signed-off-by: Mathias Kresin <dev@kresin.me>
package/network/config/ltq-vdsl-app/Makefile
package/network/config/ltq-vdsl-app/files/10-xdsl_rename [new file with mode: 0644]
target/linux/lantiq/base-files/etc/board.d/01_leds
target/linux/lantiq/base-files/etc/board.d/02_network
target/linux/lantiq/base-files/etc/uci-defaults/02_migrate_xdsl_iface [new file with mode: 0644]

index 20b506c48e079d708f27b00aeac298e0e769bd4e..baf63f9d1305e0023d530f9df13ec0ca06e24ae6 100644 (file)
@@ -28,7 +28,7 @@ define Package/ltq-vdsl-app
   CATEGORY:=Network
   TITLE:=Lantiq VDSL userland tool
   URL:=http://www.lantiq.com/
-  DEPENDS:=@TARGET_lantiq_xrx200 +libpthread +librt
+  DEPENDS:=@TARGET_lantiq_xrx200 +libpthread +librt +ip
 endef
 
 define Package/ltq-vdsl-app/description
@@ -58,10 +58,11 @@ CONFIGURE_ARGS += \
 #CONFIGURE_ARGS += --enable-model=debug
 
 define Package/ltq-vdsl-app/install
-       $(INSTALL_DIR) $(1)/etc/init.d $(1)/sbin $(1)/etc/hotplug.d/dsl
+       $(INSTALL_DIR) $(1)/etc/init.d $(1)/sbin $(1)/etc/hotplug.d/dsl $(1)/etc/hotplug.d/net
        $(INSTALL_BIN) ./files/dsl_control $(1)/etc/init.d/
        $(INSTALL_BIN) ./files/10_atm.sh $(1)/etc/hotplug.d/dsl
        $(INSTALL_BIN) ./files/10_ptm.sh $(1)/etc/hotplug.d/dsl
+       $(INSTALL_BIN) ./files/10-xdsl_rename $(1)/etc/hotplug.d/net
 
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/dsl_cpe_control $(1)/sbin/vdsl_cpe_control
        $(INSTALL_BIN) ./files/dsl_cpe_pipe.sh $(1)/sbin/
diff --git a/package/network/config/ltq-vdsl-app/files/10-xdsl_rename b/package/network/config/ltq-vdsl-app/files/10-xdsl_rename
new file mode 100644 (file)
index 0000000..faa5911
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+if [ "$ACTION" = add ]; then
+       [ "$DEVICENAME" = "nas0" ] ||[ "$DEVICENAME" = "ptm0" ] || exit
+
+       ip link set $DEVICENAME name dsl0
+fi
index 817e2e91c5bdc094fd2370fe6e08147e0dd8915b..3584b0be60e3171a6785991ab111feb5a33ddaec 100755 (executable)
@@ -21,7 +21,7 @@ led_usb2="$(lantiq_get_dt_led usb2)"
 led_dsl="$(lantiq_get_dt_led dsl)"
 [ -n "$led_dsl" ] && {
        interface="nas0"
-       lantiq_is_vdsl_system && interface="ptm0"
+       lantiq_is_vdsl_system && interface="dsl0"
 
        led_internet="$(lantiq_get_dt_led internet)"
        if [ -n "$led_internet" ]; then
index 2feeb9c208b3ee86ba4a6fc674035a8f68a07d96..bc5c410e65fb108569be811612be187fd303d731 100755 (executable)
@@ -199,7 +199,7 @@ ls /lib/modules/$(uname -r)/ltq_atm* 1> /dev/null 2>&1 && \
        ucidef_add_atm_bridge "$vpi" "$vci" "$encaps" "$payload"
 
 if lantiq_is_vdsl_system; then
-       interface_wan="ptm0"
+       interface_wan="dsl0"
        ucidef_add_vdsl_modem "$annex" "$tone" "$xfer_mode"
 else
        interface_wan="nas0"
diff --git a/target/linux/lantiq/base-files/etc/uci-defaults/02_migrate_xdsl_iface b/target/linux/lantiq/base-files/etc/uci-defaults/02_migrate_xdsl_iface
new file mode 100644 (file)
index 0000000..1a7cd33
--- /dev/null
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. /lib/functions/lantiq.sh
+
+IFNAME_CHANGED=0
+
+rename_xdsl_ifname()
+{
+       local cfg="$1"
+       local section="$2"
+       local option="$3"
+       local name
+
+       config_get name ${section} $option
+       case $name in
+               nas0*)
+                       name=${name/nas0/dsl0}
+                       ;;
+               ptm0*)
+                       name=${name/ptm0/dsl0}
+                       ;;
+               *)
+                       return
+                       ;;
+       esac
+
+       uci set ${cfg}.${section}.$option=$name
+       IFNAME_CHANGED=1
+}
+
+migrate_network_xdsl_ifname()
+{
+       rename_xdsl_ifname network "$1" ifname
+       rename_xdsl_ifname network "$1" name
+}
+
+migrate_led_xdsl_ifname()
+{
+       rename_xdsl_ifname system "$1" dev
+}
+
+lantiq_is_vdsl_system || exit 0
+
+config_load network
+config_foreach migrate_network_xdsl_ifname
+
+[ "$IFNAME_CHANGED" = "1" ] && uci commit network
+
+IFNAME_CHANGED=0
+
+config_load system
+config_foreach migrate_led_xdsl_ifname led
+
+[ "$IFNAME_CHANGED" = "1" ] && uci commit system
+
+exit 0