From ffeb717f2d6f456a0f572ae843d8db53f061062c Mon Sep 17 00:00:00 2001 From: Arne Fitzenreiter Date: Tue, 27 Jan 2015 20:21:17 +0100 Subject: [PATCH] add swconfig for lamobo-r1 switch setup. --- config/rootfiles/common/armv5tel/initscripts | 2 + config/rootfiles/common/armv5tel/swconfig | 1 + .../core/86/filelists/armv5tel/swconfig | 1 + lfs/initscripts | 6 +- lfs/linux | 3 + lfs/swconfig | 77 ++++++++++++++++++ make.sh | 1 + src/initscripts/init.d/swconfig | 79 +++++++++++++++++++ 8 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 config/rootfiles/common/armv5tel/swconfig create mode 120000 config/rootfiles/core/86/filelists/armv5tel/swconfig create mode 100644 lfs/swconfig create mode 100644 src/initscripts/init.d/swconfig diff --git a/config/rootfiles/common/armv5tel/initscripts b/config/rootfiles/common/armv5tel/initscripts index 980441599e..60ef0ef19c 100644 --- a/config/rootfiles/common/armv5tel/initscripts +++ b/config/rootfiles/common/armv5tel/initscripts @@ -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 index 0000000000..720791e5c7 --- /dev/null +++ b/config/rootfiles/common/armv5tel/swconfig @@ -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 index 0000000000..e5606edf71 --- /dev/null +++ b/config/rootfiles/core/86/filelists/armv5tel/swconfig @@ -0,0 +1 @@ +../../../../common/armv5tel/swconfig \ No newline at end of file diff --git a/lfs/initscripts b/lfs/initscripts index 4894710ac3..f656c72a74 100644 --- a/lfs/initscripts +++ b/lfs/initscripts @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2010 IPFire Team # +# Copyright (C) 2007-2015 IPFire Team # # # # 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 diff --git a/lfs/linux b/lfs/linux index 0086bfe8bc..2573d0a4d6 100644 --- 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 index 0000000000..81e0b9fbf3 --- /dev/null +++ b/lfs/swconfig @@ -0,0 +1,77 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2015 IPFire Team # +# # +# 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 . # +# # +############################################################################### + +############################################################################### +# 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 18ac3dac2a..531f8dbdd7 100755 --- 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 index 0000000000..be4604da9d --- /dev/null +++ b/src/initscripts/init.d/swconfig @@ -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 + -- 2.39.2