]> git.ipfire.org Git - people/dweismueller/ipfire-2.x.git/commitdiff
add swconfig for lamobo-r1 switch setup.
authorArne Fitzenreiter <arne_f@ipfire.org>
Tue, 27 Jan 2015 19:21:17 +0000 (20:21 +0100)
committerArne Fitzenreiter <arne_f@ipfire.org>
Tue, 27 Jan 2015 19:21:17 +0000 (20:21 +0100)
config/rootfiles/common/armv5tel/initscripts
config/rootfiles/common/armv5tel/swconfig [new file with mode: 0644]
config/rootfiles/core/86/filelists/armv5tel/swconfig [new symlink]
lfs/initscripts
lfs/linux
lfs/swconfig [new file with mode: 0644]
make.sh
src/initscripts/init.d/swconfig [new file with mode: 0644]

index 980441599ec703d158feed8e74cbddf3b5c33077..60ef0ef19c9089375a75ee1790ec8319d0f0c6a2 100644 (file)
@@ -117,6 +117,7 @@ etc/rc.d/init.d/sshd
 etc/rc.d/init.d/static-routes
 #etc/rc.d/init.d/stunnel
 etc/rc.d/init.d/swap
+etc/rc.d/init.d/swconfig
 etc/rc.d/init.d/sysctl
 etc/rc.d/init.d/sysklogd
 etc/rc.d/init.d/teamspeak
@@ -223,6 +224,7 @@ etc/rc.d/rcsysinit.d/S45udev_retry
 etc/rc.d/rcsysinit.d/S50cleanfs
 etc/rc.d/rcsysinit.d/S60setclock
 etc/rc.d/rcsysinit.d/S70console
+etc/rc.d/rcsysinit.d/S73swconfig
 etc/rc.d/rcsysinit.d/S75firstsetup
 etc/rc.d/rcsysinit.d/S80localnet
 etc/rc.d/rcsysinit.d/S85firewall
diff --git a/config/rootfiles/common/armv5tel/swconfig b/config/rootfiles/common/armv5tel/swconfig
new file mode 100644 (file)
index 0000000..720791e
--- /dev/null
@@ -0,0 +1 @@
+usr/bin/swconfig
diff --git a/config/rootfiles/core/86/filelists/armv5tel/swconfig b/config/rootfiles/core/86/filelists/armv5tel/swconfig
new file mode 120000 (symlink)
index 0000000..e5606ed
--- /dev/null
@@ -0,0 +1 @@
+../../../../common/armv5tel/swconfig
\ No newline at end of file
index 4894710ac371923dc6c0921723e69593fbb9f726..f656c72a7458025459f1481a568a1721f4059804 100644 (file)
@@ -1,7 +1,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2010  IPFire Team  <info@ipfire.org>                          #
+# Copyright (C) 2007-2015  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # This program is free software: you can redistribute it and/or modify        #
 # it under the terms of the GNU General Public License as published by        #
@@ -194,10 +194,12 @@ $(TARGET) :
                ln -sf any /etc/rc.d/init.d/networking/$$i; \
        done
 
-       # ARM does not need checkfstab and acpid
+       # ARM does not need checkfstab and acpid, intel no swconfig
 ifeq "$(MACHINE_TYPE)" "arm"
        rm -vf /etc/rc.d/init.d/{acpid,checkfstab}
+       ln -sf ../init.d/swconfig    /etc/rc.d/rcsysinit.d/S73swconfig
 else
+       rm -vf /etc/rc.d/init.d/swconfig
        ln -sf ../init.d/acpid       /etc/rc.d/rc3.d/S12acpid
        ln -sf ../init.d/acpid       /etc/rc.d/rc0.d/K87acpid
        ln -sf ../init.d/acpid       /etc/rc.d/rc6.d/K87acpid
index 0086bfe8bc4032867194d86c7a905fba5e209902..2573d0a4d655b99be5e025f154f33ccc979d1d72 100644 (file)
--- a/lfs/linux
+++ b/lfs/linux
@@ -174,6 +174,9 @@ ifeq "$(KCFG)" "-multi"
 
        # After next kernel update this patch will included to arm7-multi patchset.
        cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.x-lamobo-r1.patch
+
+       # Install switch api userspace header
+       cd $(DIR_APP) && install -v -m644 include/uapi/linux/switch.h /usr/include/linux/
 endif
 
 ifeq "$(KCFG)" "-rpi"
diff --git a/lfs/swconfig b/lfs/swconfig
new file mode 100644 (file)
index 0000000..81e0b9f
--- /dev/null
@@ -0,0 +1,77 @@
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007-2015  IPFire Team  <info@ipfire.org>                     #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+###############################################################################
+# Definitions
+###############################################################################
+
+include Config
+
+VER        = 001
+
+THISAPP    = swconfig-$(VER)
+DL_FILE    = $(THISAPP).tar.xz
+DL_FROM    = $(URL_IPFIRE)
+DIR_APP    = $(DIR_SRC)/$(THISAPP)
+TARGET     = $(DIR_INFO)/$(THISAPP)
+SUP_ARCH   = armv5tel
+
+###############################################################################
+# Top-level Rules
+###############################################################################
+
+objects = $(DL_FILE)
+
+$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
+
+$(DL_FILE)_MD5 = c35919a05fc82b3f8b311da8dfc2cd3e
+
+install : $(TARGET)
+
+check : $(patsubst %,$(DIR_CHK)/%,$(objects))
+
+download :$(patsubst %,$(DIR_DL)/%,$(objects))
+
+md5 : $(subst %,%_MD5,$(objects))
+
+###############################################################################
+# Downloading, checking, md5sum
+###############################################################################
+
+$(patsubst %,$(DIR_CHK)/%,$(objects)) :
+       @$(CHECK)
+
+$(patsubst %,$(DIR_DL)/%,$(objects)) :
+       @$(LOAD)
+
+$(subst %,%_MD5,$(objects)) :
+       @$(MD5)
+
+###############################################################################
+# Installation Details
+###############################################################################
+
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
+       @$(PREBUILD)
+       @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
+       cd $(DIR_APP) && make $(MAKETUNING)
+       cd $(DIR_APP) && install -v -m755 swconfig /usr/bin/
+       @rm -rf $(DIR_APP)
+       @$(POSTBUILD)
diff --git a/make.sh b/make.sh
index 18ac3dac2a2e30f868cdccba2a98699d4eb7c094..531f8dbdd781888c9dfe24dc7a5b92ba21f6b509 100755 (executable)
--- a/make.sh
+++ b/make.sh
@@ -809,6 +809,7 @@ buildipfire() {
   ipfiremake squid-accounting
   ipfiremake pigz
   ipfiremake tmux
+  ipfiremake swconfig
 }
 
 buildinstaller() {
diff --git a/src/initscripts/init.d/swconfig b/src/initscripts/init.d/swconfig
new file mode 100644 (file)
index 0000000..be4604d
--- /dev/null
@@ -0,0 +1,79 @@
+#!/bin/sh
+########################################################################
+# Begin $rc_base/init.d/swconfig
+#
+# Description : Script to setup lan switch.
+#               don't edit this script! If you want change the functions
+#               create an own script called swconfig.user
+########################################################################
+
+. /etc/sysconfig/rc
+. ${rc_functions}
+
+if [ -e /etc/init.d/swconfig.user ]; then
+       /etc/init.d/swconfig.user $*
+       exit ${?}
+fi
+
+if [ -e /var/ipfire/ethernet/swconfig_mac ]; then
+SWMAC=`cat /var/ipfire/ethernet/swconfig_mac`
+else
+# Generate a random local administrated mac address for vlan swconfig.
+SWMAC=`printf "%1x2:%02x:%02x:%02x:%02x" $[RANDOM%16] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256]`
+echo $SWMAC > /var/ipfire/ethernet/swconfig_mac
+fi
+
+case "${1}" in
+       start)
+               case `cat /proc/device-tree/model` in
+                       "Lamobo-R1")
+                               #
+                               # Lamobo R1 aka BPi R1 Routerboard
+                               #
+                               # Speaker | LAN1 | LAN2 | LAN3 | LAN4 || LAN5 | HDMI
+                               # SW-Port |  P2  |  P1  |  P0  |  P4  ||  P3  |
+                               # VLAN    |  11  |  12  |  13  |  14  ||ALL(t)|
+                               #
+                               # Switch-Port P8 - ALL(t) boards internal CPU Port
+                               #
+                               device=`ls /sys/class/net/*/device/stmmac-0* | head -1 | cut -d/ -f5`
+                               ip link set $device up
+                               boot_mesg "Configure vlan-switch on $device ..."
+                               # Reset switch, counter and enable vlan mode
+                               swconfig dev $device set reset 1
+                               swconfig dev $device set reset_mib 1
+                               swconfig dev $device set enable_vlan 1
+                               # configure vlans
+                               swconfig dev $device vlan 11 set ports "2 3t 8t"
+                               swconfig dev $device vlan 12 set ports "1 3t 8t"
+                               swconfig dev $device vlan 13 set ports "0 3t 8t"
+                               swconfig dev $device vlan 14 set ports "4 3t 8t"
+                               # activate new config
+                               swconfig dev $device set apply 1
+                               # create interfaces for the vlan's
+                               modprobe 8021q
+                               vconfig add $device 11
+                               vconfig add $device 12
+                               vconfig add $device 13
+                               vconfig add $device 14
+                               # set local mac addresses.
+                               ip link set dev $device.11 address $SWMAC:11
+                               ip link set dev $device.12 address $SWMAC:12
+                               ip link set dev $device.13 address $SWMAC:13
+                               ip link set dev $device.14 address $SWMAC:14
+                               # need to restart udev...
+                               killall udevd
+                               /etc/init.d/udev start
+                       ;;
+               esac
+               exit 0
+       ;;
+
+       *)
+               echo "Usage: ${0} {start}"
+               exit 1
+       ;;
+esac
+
+# End $rc_base/init.d/swconfig
+