RE: build problems in layerscape target kernel

2020-07-07 Thread Y.b. Lu
Hi Hauke,

I had sent out a patch to fix the build issue temporarily.
https://github.com/openwrt/openwrt/pull/3179

Once the proper fix-up patches are developed, verified and ready. I will send 
them instead.
Thanks.

Best regards,
Yangbo Lu

> -Original Message-
> From: Y.b. Lu
> Sent: Tuesday, July 7, 2020 4:13 PM
> To: Hauke Mehrtens 
> Cc: LEDE Development List ; Jiafei Pan
> 
> Subject: RE: build problems in layerscape target kernel
> 
> Hi Hauke,
> 
> This headers installing issue is because of the introducing of below linux
> upstream patch.
> 
> 5967577 scripts: headers_install: Exit with error on config leak
> 
> I have reported this issue to our FMD Software owner to fix these headers. He
> will work on the patches but he has other urgent work now.
> Can I send a reversed patch for layerscape for now?
> 
> Regarding to the second issue, I haven't reproduced it actually at that 
> commit.
> https://buildbot.openwrt.org/master/images/builders/layerscape%2Farmv8_6
> 4b/builds/422
> 
> May I confirm whether below config was used for build test?
> printf
> 'CONFIG_TARGET_layerscape=y\nCONFIG_TARGET_layerscape_armv8_64b=y\
> nCONFIG_SIGNED_PACKAGES=y\n' >> .config
> 
> Thanks a lot.
> 
> Best regards,
> Yangbo Lu
> 
> > -Original Message-
> > From: Y.b. Lu
> > Sent: Monday, July 6, 2020 4:46 PM
> > To: 'Hauke Mehrtens' 
> > Cc: LEDE Development List 
> > Subject: RE: build problems in layerscape target kernel
> >
> > Thanks Huake.
> > Let me try to fix this issue.
> >
> > Best regards,
> > Yangbo Lu
> >
> > > -Original Message-
> > > From: Hauke Mehrtens 
> > > Sent: Sunday, July 5, 2020 6:34 PM
> > > To: Y.b. Lu 
> > > Cc: LEDE Development List 
> > > Subject: build problems in layerscape target kernel
> > >
> > > Hi Yangbo Lu,
> > >
> > > I see some build problem with the layerscape target in the OpenWrt build
> > > bots recently.
> > >
> > > Since the update to kernel 5.4.50 the scripts/headers_install.sh script
> > > complains that include/linux/fmd/Peripherals/fm_port_ioctls.h includes
> > > CONFIG_COMPAT. This is a problem when some user space application
> > > includes this file, because user space applications do not know of the
> > > kernel configuration and normally none of these CONFIG_ symbols is set.
> > >
> > > This happens when changing the Linux kernel from version 45.4.48 to
> > > 5.4.49, but I do not know why this change is triggering this error and
> > > why it did not happen before.
> > >
> > > This is the error message:
> > >   HDRINST usr/include/linux/fmd/integrations/integration_ioctls.h
> > >   HDRINST usr/include/linux/fmd/Peripherals/fm_port_ioctls.h
> > > error: include/uapi/linux/fmd/Peripherals/fm_port_ioctls.h: leak
> > > CONFIG_COMPAT to user-space
> > > scripts/Makefile.headersinst:63: recipe for target
> > > 'usr/include/linux/fmd/Peripherals/fm_port_ioctls.h' failed
> > > make[5]: *** [usr/include/linux/fmd/Peripherals/fm_port_ioctls.h] Error 1
> > > Makefile:1198: recipe for target 'headers' failed
> > > make[4]: *** [headers] Error 2
> > >
> > >
> >
> https://buildbot.openwrt.org/master/images/builders/layerscape%2Farmv7/b
> > > uilds/349
> > >
> > > It is happening since:
> > > https://git.openwrt.org/68d9cb82143b864d70e4fb3d7cbb7068f82216a1
> > >
> > > --
> > >
> > > Before we saw this problem the layerscape target in the linking of the
> > > kernel image. It shows this error message.
> > >
> > >   LD  vmlinux
> > >   SORTEX  vmlinux
> > >   SYSMAP  System.map
> > > Inconsistent kallsyms data
> > > Try make KALLSYMS_EXTRA_PASS=1 as a workaround
> > > Makefile:1081: recipe for target 'vmlinux' failed
> > > make[4]: *** [vmlinux] Error 1
> > >
> > > This is happening since this build bot run, the changes since the
> > > previous build are listed in the log:
> > >
> >
> https://buildbot.openwrt.org/master/images/builders/layerscape%2Farmv8_6
> > > 4b/builds/422
> > >
> > > I haven't looked closer into this problem.
> > >
> > >
> > > Hauke

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[RFC PATCH v2 1/1] dsaconfig: introduce package for UCI configuration of VLAN filter rules

2020-07-07 Thread Jo-Philipp Wich
This package provides the necessary files to translate `config dsa_vlan`
and `config dsa_port` sections  of `/etc/config/network` into appropriate
bridge vlan filter rules.

The approach of the configuration is to bridge all DSA ports into a logical
bridge device, called "switch0" by default, and to set VLAN port membership,
tagging state and PVID as specified by UCI on each port and on the switch
bridge device itself, allowing logical interfaces to reference port VLAN
groups by using "switch0.N" as ifname, where N denotes the VLAN ID.

Signed-off-by: Jo-Philipp Wich 
---
 package/network/config/dsaconfig/Makefile |  40 +++
 .../config/dsaconfig/files/dsaconfig.hotplug  |   7 +
 .../config/dsaconfig/files/dsaconfig.include  |  11 +
 .../config/dsaconfig/files/dsaconfig.sh   | 306 ++
 4 files changed, 364 insertions(+)
 create mode 100644 package/network/config/dsaconfig/Makefile
 create mode 100644 package/network/config/dsaconfig/files/dsaconfig.hotplug
 create mode 100755 package/network/config/dsaconfig/files/dsaconfig.include
 create mode 100755 package/network/config/dsaconfig/files/dsaconfig.sh

diff --git a/package/network/config/dsaconfig/Makefile 
b/package/network/config/dsaconfig/Makefile
new file mode 100644
index 00..406904
--- /dev/null
+++ b/package/network/config/dsaconfig/Makefile
@@ -0,0 +1,40 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=dsaconfig
+PKG_RELEASE:=1
+PKG_LICENSE:=GPL-2.0
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/dsaconfig
+  SECTION:=net
+  CATEGORY:=Network
+  MAINTAINER:=Jo-Philipp Wich 
+  TITLE:=UCI configuration support for DSA switch VLAN filtering
+  DEPENDS:= +ip-bridge +ip-full
+  PKGARCH:=all
+endef
+
+define Package/dsaconfig/description
+ This package provides UCI configuration abstraction for VLAN filter rules
+ on top of DSA switches.
+endef
+
+define Build/Compile
+endef
+
+define Build/Configure
+endef
+
+define Package/dsaconfig/install
+   $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+   $(INSTALL_DATA) ./files/dsaconfig.hotplug 
$(1)/etc/hotplug.d/iface/01-dsaconfig
+
+   $(INSTALL_DIR) $(1)/lib/network
+   $(INSTALL_DATA) ./files/dsaconfig.include $(1)/lib/network/dsaconfig.sh
+
+   $(INSTALL_DIR) $(1)/sbin
+   $(INSTALL_BIN) ./files/dsaconfig.sh $(1)/sbin/dsaconfig
+endef
+
+$(eval $(call BuildPackage,dsaconfig))
diff --git a/package/network/config/dsaconfig/files/dsaconfig.hotplug 
b/package/network/config/dsaconfig/files/dsaconfig.hotplug
new file mode 100644
index 00..fc2a489dea
--- /dev/null
+++ b/package/network/config/dsaconfig/files/dsaconfig.hotplug
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+if [ "$ACTION" = ifup ] && [ "$INTERFACE" = loopback ]; then
+   . /lib/network/dsaconfig.sh
+   setup_switch
+fi
+
diff --git a/package/network/config/dsaconfig/files/dsaconfig.include 
b/package/network/config/dsaconfig/files/dsaconfig.include
new file mode 100755
index 00..4ac11d8061
--- /dev/null
+++ b/package/network/config/dsaconfig/files/dsaconfig.include
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+setup_switch() {
+   # Skip switch setup on network restart. The netifd process
+   # will be started afterwards and remove all interfaces again...
+   if [ "$initscript" = /etc/init.d/network ] && [ "$action" = restart ]; 
then
+   return 0
+   fi
+
+   /sbin/dsaconfig apply 2>&1 | logger -t dsaconfig
+}
diff --git a/package/network/config/dsaconfig/files/dsaconfig.sh 
b/package/network/config/dsaconfig/files/dsaconfig.sh
new file mode 100755
index 00..e54bb81558
--- /dev/null
+++ b/package/network/config/dsaconfig/files/dsaconfig.sh
@@ -0,0 +1,306 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. /lib/functions/network.sh
+
+switch_names=""
+
+warn() {
+   echo "$@" >&2
+}
+
+clear_port_vlans() {
+   local port=$1
+   local self=$2
+   local vlans=$(bridge vlan show dev "$port" | sed -ne 's#^[^ ]* 
\+\([0-9]\+\).*$#\1#p')
+
+   local vlan
+   for vlan in $vlans; do
+   bridge vlan del vid "$vlan" dev "$port" $self
+   done
+}
+
+lookup_switch() {
+   local cfg=$1
+   local swname
+
+   config_get swname "$cfg" switch
+
+   # Auto-determine switch if not specified ...
+   if [ -z "$swname" ]; then
+   case "$switch_names" in
+   *\ *)
+   warn "VLAN section '$cfg' does not specify a 
switch but multiple switches present, using first one"
+   swname=${switch_names%% *}
+   ;;
+   *)
+   swname=${switch_names}
+   ;;
+   esac
+
+   # ... otherwise check if the referenced switch is declared
+   else
+   case " $switch_names " in
+   *" $swname "*) : ;;
+   *)
+   warn "Switch '$swname' specified by VLAN 
section '$cfg' does not exist"
+ 

[RFC PATCH v2 0/1] Introduce UCI support for configuring DSA VLAN filter rules

2020-07-07 Thread Jo-Philipp Wich
This patch series introduces a new package "dsaconfig" which provides the
necessary logic to allow configuration of bridge vlan filter rules for
DSA switches.

While well supported DSA switches can be programmed by solely bridging
per-port netdevices together, explicit bridge VLAN filter rules are needed
for more complex scenarios or for DSA switches that do not support a
tagging protocol.

The UCI configuration interpreted by the dsaconfig package closely follows
the structure and semantics of the legacy swconfig architecture, honouring
"dsa", "dsa_vlan" and "dsa_port" sections within the
/etc/config/network file. The only difference compared to swconfig is
that "dsa" sections are optional and that the syntax of ports within
the "dsa_vlan" section differs, instead of ?, e.g.
"0t", "1u" or "2", it is now (.)?, e.g. "wan.u", "lan1.t"
or "lan2".

The dsaconfig package will spawn a bridge device named "switchN" for each
DSA switch, where N denotes the number of the switch. In contrast to
swconfig, interfaces do not use the CPU port to target VLAN port groups on
the switch but reference a VLAN on top of the switch, e.g.
"option ifname switch0.1" to use the VLAN 1 port group on the first DSA
switch.

A complete configuration example for a simple LAN/WAN setup might look
like below. Note that this configuration should be equivalent to just
bridging lan1..lan4 without any VLAN filter rules.

-- 8< --
config dsa_vlan
  option vlan 1
  option ports 'lan1 lan2 lan3 lan4'

config dsa_vlan
  option vlan 2
  option ports 'wan'

config interface lan
  option ifname switch0.1
  option proto static
  option ipaddr 192.168.1.1/24

config interface wan
  option ifname switch0.2
  option proto dhcp
-- >8 --

A slightly more complex example that uses multiple tagged VLANs on different
ports would look like this:

-- 8< --
config dsa switch0
  ## Override CPU port. Normally it is auto-discovered.
  #option cpu_port eth0

config dsa_vlan
  ## Specify the switch this vlan belongs to.
  ## If there is only one switch on the system, it may be omitted.
  #option device switch0
  option vlan 1
  option ports 'lan1 lan2.t'

config dsa_vlan
  #option device switch0
  option vlan 2
  option ports 'wan'

config dsa_vlan
  #option device switch0
  option vlan 5
  option ports 'lan2.t lan3'

config dsa_vlan
  #option device switch0
  option vlan 8
  option ports 'lan2.t lan4'

config dsa_vlan
  #option device switch0
  option vlan 11
  option ports 'lan2.t lan4.t'

config dsa_port
  #option device switch0
  option port lan2
  ## By default, the port PVID is set to the ID of the first
  ## untagged VLAN the port is member of. It can be overriden here.
  option pvid 5

config interface lan
  option type bridge
  option ifname 'switch0.1 wlan0'
  option proto static
  option ipaddr 192.168.1.1/24

config interface wan
  option ifname switch0.2
  option proto dhcp

config interface vlan5
  option ifname switch0.5
  option proto static
  option ipaddr 10.255.5.1/24

config interface vlan8
  option ifname switch0.8
  option proto static
  option ipaddr 10.255.8.1/24

config interface vlan11
  option ifname switch0.11
  option proto static
  option ipaddr 10.255.11.1/24
-- >8 --

Additionally, the "dsaconfig" executable provided by this package implements
a "show" option to display the current switch port states and their VLAN
memberships in a compact manner. For the latter configuration example above,
the utility would produce an output similar to the following:

-- 8< --
root@OpenWrt:~# dsaconfig show
Switch: switch0
VLAN/ | lan1  | lan2  | lan3  | lan4  | wan   |
Link: | down  | 1000F | down  | 1000F | down  |
   1  |  u*   |  t|   |   |   |
   2  |   |   |   |   |  u*   |
   5  |   |  t*   |  u*   |   |   |
   8  |  t|  t|   |  u*   |   |
  11  |   |  t|   |  t|   |

-- >8 --

This code has been tested on a WRT3200ACM and a Mir3G but is supposed to
work with any DSA switch. It requires wider testing before it is suitable
for inclusion.

Once the configuration format is and rule logic is finalized, the shell
script code provided by this package should be implemented directly in
netifd C code to reduce the amount of required external dependencies and
to allow for improved performance when processing large configurations.

Open questions/topics:

 - Ensure that the chosen configuration approach actually works with
   DSA_TAG_PROTO_NONE switches

 - Investigate potential MTU issues regarding the CPU port

Changes since v1:

 - Rename switch, switch_vlan and switch_port sections to dsa, dsa_vlan
   and dsa_port respectively

 - Forcibly move DSA ports to the switch bridge if they're part of another
   bridge yet

 - Disallow VLAN ID 0

 - Properly display unassigned ports as empty in "dsaconfig show"

 - Handle implicit switch0 in "dsaconfig show"

Jo-Philipp Wich (1):
  dsaconfig: introduce package for UCI configuration of VLAN filter
rules

 package/network/conf

Re: [RFC PATCH] Introduce UCI support for configuring DSA VLAN filter rules

2020-07-07 Thread Etienne Champetier
Le mar. 7 juil. 2020 à 09:36, Jo-Philipp Wich  a écrit :
>
> This patch series introduces a new package "dsaconfig" which provides the
> necessary logic to allow configuration of bridge vlan filter rules for
> DSA switches.

Nice !
[...]

>
> Open questions/topics:
>
>  - Ensure that the chosen configuration approach actually works with
>DSA_TAG_PROTO_NONE switches

Is there an easy way to find which hardware is DSA_TAG_PROTO_NONE

>  - Consider changing the types of the UCI sections from
>switch/switch_vlan/switch_port to dsa/dsa_vlan/dsa_port

Using dsa/dsa_vlan/dsa_port would remove a lot of end user confusion
and make googling easier IMO

Cheers
Etienne

>  - Investigate potential MTU issues regarding the CPU port
>
> Jo-Philipp Wich (1):

[...]

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


RE: [RFC PATCH] Introduce UCI support for configuring DSA VLAN filter rules

2020-07-07 Thread mail
> -Original Message-
> From: openwrt-devel [mailto:openwrt-devel-boun...@lists.openwrt.org]
> On Behalf Of Jo-Philipp Wich
> Sent: Dienstag, 7. Juli 2020 15:35
> To: j...@mein.io; openwrt-devel@lists.openwrt.org
> Subject: [RFC PATCH] Introduce UCI support for configuring DSA VLAN filter
> rules
> 
> This patch series introduces a new package "dsaconfig" which provides the
> necessary logic to allow configuration of bridge vlan filter rules for DSA
> switches.

Hi, thanks for taking care of that.

[...]

>  - Consider changing the types of the UCI sections from
>switch/switch_vlan/switch_port to dsa/dsa_vlan/dsa_port

Using new names for DSA would have the benefit that migration would be much 
easier, as we always knew what the config is meant for (and we wouldn't need 
another migration_done=1 variable or similar.)
However, it might create some code duplication in other tools/packages that 
alter uci network config. This might be seen as drawback (duplication) or 
advantage (separate code based on separate setup, as there might be differences 
anyway).

I currently have a weak to moderate tendency for the dsa_* scheme.

Best

Adrian

> 
>  - Investigate potential MTU issues regarding the CPU port
> 
> Jo-Philipp Wich (1):
>   dsaconfig: introduce package for UCI configuration of VLAN filter
> rules
> 
>  package/network/config/dsaconfig/Makefile |  40 +++
>  .../config/dsaconfig/files/dsaconfig.hotplug  |   7 +
>  .../config/dsaconfig/files/dsaconfig.include  |  11 +
>  .../config/dsaconfig/files/dsaconfig.sh   | 296 ++
>  4 files changed, 354 insertions(+)
>  create mode 100644 package/network/config/dsaconfig/Makefile
>  create mode 100644
> package/network/config/dsaconfig/files/dsaconfig.hotplug
>  create mode 100755
> package/network/config/dsaconfig/files/dsaconfig.include
>  create mode 100755 package/network/config/dsaconfig/files/dsaconfig.sh
> 
> --
> 2.20.1
> 
> 
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel


openpgp-digital-signature.asc
Description: PGP signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH 1/1] dsaconfig: introduce package for UCI configuration of VLAN filter rules

2020-07-07 Thread John Crispin


On 07.07.20 15:34, Jo-Philipp Wich wrote:

This package provides the necessary files to translate `config switch_vlan`
and `config switch_port` sections  of `/etc/config/network` into appropriate
bridge vlan filter rules.

The approach of the configuration is to bridge all DSA ports into a logical
bridge device, called "switch0" by default, and to set VLAN port membership,
tagging state and PVID as specified by UCI on each port and on the switch
bridge device itself, allowing logical interfaces to reference port VLAN
groups by using "switch0.N" as ifname, where N denotes the VLAN ID.

Signed-off-by: Jo-Philipp Wich 



very nice, now we need to move this to netifd :-)

    John


---
  package/network/config/dsaconfig/Makefile |  40 +++
  .../config/dsaconfig/files/dsaconfig.hotplug  |   7 +
  .../config/dsaconfig/files/dsaconfig.include  |  11 +
  .../config/dsaconfig/files/dsaconfig.sh   | 296 ++
  4 files changed, 354 insertions(+)
  create mode 100644 package/network/config/dsaconfig/Makefile
  create mode 100644 package/network/config/dsaconfig/files/dsaconfig.hotplug
  create mode 100755 package/network/config/dsaconfig/files/dsaconfig.include
  create mode 100755 package/network/config/dsaconfig/files/dsaconfig.sh

diff --git a/package/network/config/dsaconfig/Makefile 
b/package/network/config/dsaconfig/Makefile
new file mode 100644
index 00..406904
--- /dev/null
+++ b/package/network/config/dsaconfig/Makefile
@@ -0,0 +1,40 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=dsaconfig
+PKG_RELEASE:=1
+PKG_LICENSE:=GPL-2.0
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/dsaconfig
+  SECTION:=net
+  CATEGORY:=Network
+  MAINTAINER:=Jo-Philipp Wich 
+  TITLE:=UCI configuration support for DSA switch VLAN filtering
+  DEPENDS:= +ip-bridge +ip-full
+  PKGARCH:=all
+endef
+
+define Package/dsaconfig/description
+ This package provides UCI configuration abstraction for VLAN filter rules
+ on top of DSA switches.
+endef
+
+define Build/Compile
+endef
+
+define Build/Configure
+endef
+
+define Package/dsaconfig/install
+   $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+   $(INSTALL_DATA) ./files/dsaconfig.hotplug 
$(1)/etc/hotplug.d/iface/01-dsaconfig
+
+   $(INSTALL_DIR) $(1)/lib/network
+   $(INSTALL_DATA) ./files/dsaconfig.include $(1)/lib/network/dsaconfig.sh
+
+   $(INSTALL_DIR) $(1)/sbin
+   $(INSTALL_BIN) ./files/dsaconfig.sh $(1)/sbin/dsaconfig
+endef
+
+$(eval $(call BuildPackage,dsaconfig))
diff --git a/package/network/config/dsaconfig/files/dsaconfig.hotplug 
b/package/network/config/dsaconfig/files/dsaconfig.hotplug
new file mode 100644
index 00..fc2a489dea
--- /dev/null
+++ b/package/network/config/dsaconfig/files/dsaconfig.hotplug
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+if [ "$ACTION" = ifup ] && [ "$INTERFACE" = loopback ]; then
+   . /lib/network/dsaconfig.sh
+   setup_switch
+fi
+
diff --git a/package/network/config/dsaconfig/files/dsaconfig.include 
b/package/network/config/dsaconfig/files/dsaconfig.include
new file mode 100755
index 00..4ac11d8061
--- /dev/null
+++ b/package/network/config/dsaconfig/files/dsaconfig.include
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+setup_switch() {
+   # Skip switch setup on network restart. The netifd process
+   # will be started afterwards and remove all interfaces again...
+   if [ "$initscript" = /etc/init.d/network ] && [ "$action" = restart ]; 
then
+   return 0
+   fi
+
+   /sbin/dsaconfig apply 2>&1 | logger -t dsaconfig
+}
diff --git a/package/network/config/dsaconfig/files/dsaconfig.sh 
b/package/network/config/dsaconfig/files/dsaconfig.sh
new file mode 100755
index 00..0182f340ba
--- /dev/null
+++ b/package/network/config/dsaconfig/files/dsaconfig.sh
@@ -0,0 +1,296 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. /lib/functions/network.sh
+
+switch_names=""
+
+warn() {
+   echo "$@" >&2
+}
+
+clear_port_vlans() {
+   local port=$1
+   local self=$2
+   local vlans=$(bridge vlan show dev "$port" | sed -ne 's#^[^ ]* 
\+\([0-9]\+\).*$#\1#p')
+
+   local vlan
+   for vlan in $vlans; do
+   bridge vlan del vid "$vlan" dev "$port" $self
+   done
+}
+
+lookup_switch() {
+   local cfg=$1
+   local swname
+
+   config_get swname "$cfg" switch
+
+   # Auto-determine switch if not specified ...
+   if [ -z "$swname" ]; then
+   case "$switch_names" in
+   *\ *)
+   warn "VLAN section '$cfg' does not specify a switch 
but multiple switches present, using first one"
+   swname=${switch_names%% *}
+   ;;
+   *)
+   swname=${switch_names}
+   ;;
+   esac
+
+   # ... otherwise check if the referenced switch is declared
+   else
+   case " $switch_names " in
+   *" $swname "*) : ;;
+

[PATCH 1/1] dsaconfig: introduce package for UCI configuration of VLAN filter rules

2020-07-07 Thread Jo-Philipp Wich
This package provides the necessary files to translate `config switch_vlan`
and `config switch_port` sections  of `/etc/config/network` into appropriate
bridge vlan filter rules.

The approach of the configuration is to bridge all DSA ports into a logical
bridge device, called "switch0" by default, and to set VLAN port membership,
tagging state and PVID as specified by UCI on each port and on the switch
bridge device itself, allowing logical interfaces to reference port VLAN
groups by using "switch0.N" as ifname, where N denotes the VLAN ID.

Signed-off-by: Jo-Philipp Wich 
---
 package/network/config/dsaconfig/Makefile |  40 +++
 .../config/dsaconfig/files/dsaconfig.hotplug  |   7 +
 .../config/dsaconfig/files/dsaconfig.include  |  11 +
 .../config/dsaconfig/files/dsaconfig.sh   | 296 ++
 4 files changed, 354 insertions(+)
 create mode 100644 package/network/config/dsaconfig/Makefile
 create mode 100644 package/network/config/dsaconfig/files/dsaconfig.hotplug
 create mode 100755 package/network/config/dsaconfig/files/dsaconfig.include
 create mode 100755 package/network/config/dsaconfig/files/dsaconfig.sh

diff --git a/package/network/config/dsaconfig/Makefile 
b/package/network/config/dsaconfig/Makefile
new file mode 100644
index 00..406904
--- /dev/null
+++ b/package/network/config/dsaconfig/Makefile
@@ -0,0 +1,40 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=dsaconfig
+PKG_RELEASE:=1
+PKG_LICENSE:=GPL-2.0
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/dsaconfig
+  SECTION:=net
+  CATEGORY:=Network
+  MAINTAINER:=Jo-Philipp Wich 
+  TITLE:=UCI configuration support for DSA switch VLAN filtering
+  DEPENDS:= +ip-bridge +ip-full
+  PKGARCH:=all
+endef
+
+define Package/dsaconfig/description
+ This package provides UCI configuration abstraction for VLAN filter rules
+ on top of DSA switches.
+endef
+
+define Build/Compile
+endef
+
+define Build/Configure
+endef
+
+define Package/dsaconfig/install
+   $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+   $(INSTALL_DATA) ./files/dsaconfig.hotplug 
$(1)/etc/hotplug.d/iface/01-dsaconfig
+
+   $(INSTALL_DIR) $(1)/lib/network
+   $(INSTALL_DATA) ./files/dsaconfig.include $(1)/lib/network/dsaconfig.sh
+
+   $(INSTALL_DIR) $(1)/sbin
+   $(INSTALL_BIN) ./files/dsaconfig.sh $(1)/sbin/dsaconfig
+endef
+
+$(eval $(call BuildPackage,dsaconfig))
diff --git a/package/network/config/dsaconfig/files/dsaconfig.hotplug 
b/package/network/config/dsaconfig/files/dsaconfig.hotplug
new file mode 100644
index 00..fc2a489dea
--- /dev/null
+++ b/package/network/config/dsaconfig/files/dsaconfig.hotplug
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+if [ "$ACTION" = ifup ] && [ "$INTERFACE" = loopback ]; then
+   . /lib/network/dsaconfig.sh
+   setup_switch
+fi
+
diff --git a/package/network/config/dsaconfig/files/dsaconfig.include 
b/package/network/config/dsaconfig/files/dsaconfig.include
new file mode 100755
index 00..4ac11d8061
--- /dev/null
+++ b/package/network/config/dsaconfig/files/dsaconfig.include
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+setup_switch() {
+   # Skip switch setup on network restart. The netifd process
+   # will be started afterwards and remove all interfaces again...
+   if [ "$initscript" = /etc/init.d/network ] && [ "$action" = restart ]; 
then
+   return 0
+   fi
+
+   /sbin/dsaconfig apply 2>&1 | logger -t dsaconfig
+}
diff --git a/package/network/config/dsaconfig/files/dsaconfig.sh 
b/package/network/config/dsaconfig/files/dsaconfig.sh
new file mode 100755
index 00..0182f340ba
--- /dev/null
+++ b/package/network/config/dsaconfig/files/dsaconfig.sh
@@ -0,0 +1,296 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. /lib/functions/network.sh
+
+switch_names=""
+
+warn() {
+   echo "$@" >&2
+}
+
+clear_port_vlans() {
+   local port=$1
+   local self=$2
+   local vlans=$(bridge vlan show dev "$port" | sed -ne 's#^[^ ]* 
\+\([0-9]\+\).*$#\1#p')
+
+   local vlan
+   for vlan in $vlans; do
+   bridge vlan del vid "$vlan" dev "$port" $self
+   done
+}
+
+lookup_switch() {
+   local cfg=$1
+   local swname
+
+   config_get swname "$cfg" switch
+
+   # Auto-determine switch if not specified ...
+   if [ -z "$swname" ]; then
+   case "$switch_names" in
+   *\ *)
+   warn "VLAN section '$cfg' does not specify a 
switch but multiple switches present, using first one"
+   swname=${switch_names%% *}
+   ;;
+   *)
+   swname=${switch_names}
+   ;;
+   esac
+
+   # ... otherwise check if the referenced switch is declared
+   else
+   case " $switch_names " in
+   *" $swname "*) : ;;
+   *)
+   warn "Switch '$swname' specified by VLAN 
section '$cfg' does not exi

[RFC PATCH] Introduce UCI support for configuring DSA VLAN filter rules

2020-07-07 Thread Jo-Philipp Wich
This patch series introduces a new package "dsaconfig" which provides the
necessary logic to allow configuration of bridge vlan filter rules for
DSA switches.

While well supported DSA switches can be programmed by solely bridging
per-port netdevices together, explicit bridge VLAN filter rules are needed
for more complex scenarios or for DSA switches that do not support a
tagging protocol.

The UCI configuration interpreted by the dsaconfig package closely follows
the structure and semantics of the legacy swconfig architecture, honouring
"switch", "switch_vlan" and "switch_port" sections within the
/etc/config/network file. The only difference compared to swconfig is
that "switch" sections are optional and that the syntax of ports within
the "switch_vlan" section differs, instead of ?, e.g.
"0t", "1u" or "2", it is now (.)?, e.g. "wan.u", "lan1.t"
or "lan2".

The dsaconfig package will spawn a bridge device named "switchN" for each
DSA switch, where N denotes the number of the switch. In contrast to
swconfig, interfaces do not use the CPU port to target VLAN port groups on
the switch but reference a VLAN on top of the switch, e.g.
"option ifname switch0.1" to use the VLAN 1 port group on the first DSA
switch.

A complete configuration example for a simple LAN/WAN setup might look
like below. Note that this configuration should be equivalent to just
bridging lan1..lan4 without any VLAN filter rules.

-- 8< --
config switch_vlan
  option vlan 1
  option ports 'lan1 lan2 lan3 lan4'

config switch_vlan
  option vlan 2
  option ports 'wan'

config interface lan
  option ifname switch0.1
  option proto static
  option ipaddr 192.168.1.1/24

config interface wan
  option ifname switch0.2
  option proto dhcp
-- >8 --

A slightly more complex example that uses multiple tagged VLANs on different
ports would look like this:

-- 8< --
config switch switch0
  ## Override CPU port. Normally it is auto-discovered.
  #option cpu_port eth0

config switch_vlan
  ## Specify the switch this vlan belongs to.
  ## If there is only one switch on the system, it may be omitted.
  #option device switch0
  option vlan 1
  option ports 'lan1 lan2.t'

config switch_vlan
  #option device switch0
  option vlan 2
  option ports 'wan'

config switch_vlan
  #option device switch0
  option vlan 5
  option ports 'lan2.t lan3'

config switch_vlan
  #option device switch0
  option vlan 8
  option ports 'lan2.t lan4'

config switch_vlan
  #option device switch0
  option vlan 11
  option ports 'lan2.t lan4.t'

config switch_port
  #option device switch0
  option port lan2
  ## By default, the port PVID is set to the ID of the first
  ## untagged VLAN the port is member of. It can be overriden here.
  option pvid 5

config interface lan
  option type bridge
  option ifname 'switch0.1 wlan0'
  option proto static
  option ipaddr 192.168.1.1/24

config interface wan
  option ifname switch0.2
  option proto dhcp

config interface vlan5
  option ifname switch0.5
  option proto static
  option ipaddr 10.255.5.1/24

config interface vlan8
  option ifname switch0.8
  option proto static
  option ipaddr 10.255.8.1/24

config interface vlan11
  option ifname switch0.11
  option proto static
  option ipaddr 10.255.11.1/24
-- >8 --

Additionally, the "dsaconfig" executable provided by this package implements
a "show" option to display the current switch port states and their VLAN
memberships in a compact manner. For the latter configuration example above,
the utility would produce an output similar to the following:

-- 8< --
root@OpenWrt:~# dsaconfig show
Switch: switch0
VLAN/ | lan1  | lan2  | lan3  | lan4  | wan   |
Link: | down  | 1000F | down  | 1000F | down  |
   1  |  u*   |  t|  t|  t|  t|
   2  |  t|  t|  t|  t|  u*   |
   5  |  t|  t*   |  u*   |  t|  t|
   8  |  t|  t|  t|  u*   |  t|
  11  |  t|  t|  t|  t|  t|

-- >8 --

This code has been tested on a WRT3200ACM but is supposed to work with any
DSA switch. It requires wider testing before it is suitable for inclusion.

Once the configuration format is and rule logic is finalized, the shell
script code provided by this package should be implemented directly in
netifd C code to reduce the amount of required external dependencies and
to allow for improved performance when processing large configurations.

Open questions/topics:

 - Ensure that the chosen configuration approach actually works with
   DSA_TAG_PROTO_NONE switches

 - Consider changing the types of the UCI sections from
   switch/switch_vlan/switch_port to dsa/dsa_vlan/dsa_port

 - Investigate potential MTU issues regarding the CPU port

Jo-Philipp Wich (1):
  dsaconfig: introduce package for UCI configuration of VLAN filter
rules

 package/network/config/dsaconfig/Makefile |  40 +++
 .../config/dsaconfig/files/dsaconfig.hotplug  |   7 +
 .../config/dsaconfig/files/dsaconfig.include  |  11 +
 .../config/dsaconfig/files/dsaconfig.sh   | 296 

[PATCH] busybox: store applet usage messages uncompressed

2020-07-07 Thread Rui Salvaterra
The rootfs squashfs is already highly (XZ) compressed. Storing the applet
messages in compressed form will increase the entropy and reduce the overall
image compression ratio.

Signed-off-by: Rui Salvaterra 
---
 package/utils/busybox/Config-defaults.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/utils/busybox/Config-defaults.in 
b/package/utils/busybox/Config-defaults.in
index 91c9b9b5b9..b45cf981ea 100644
--- a/package/utils/busybox/Config-defaults.in
+++ b/package/utils/busybox/Config-defaults.in
@@ -24,7 +24,7 @@ config BUSYBOX_DEFAULT_FEATURE_VERBOSE_USAGE
default y
 config BUSYBOX_DEFAULT_FEATURE_COMPRESS_USAGE
bool
-   default y
+   default n
 config BUSYBOX_DEFAULT_LFS
bool
default y
-- 
2.27.0


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


RE: build problems in layerscape target kernel

2020-07-07 Thread Y.b. Lu
Hi Hauke,

This headers installing issue is because of the introducing of below linux 
upstream patch.

5967577 scripts: headers_install: Exit with error on config leak

I have reported this issue to our FMD Software owner to fix these headers. He 
will work on the patches but he has other urgent work now.
Can I send a reversed patch for layerscape for now?

Regarding to the second issue, I haven't reproduced it actually at that commit.
https://buildbot.openwrt.org/master/images/builders/layerscape%2Farmv8_64b/builds/422

May I confirm whether below config was used for build test?
printf 
'CONFIG_TARGET_layerscape=y\nCONFIG_TARGET_layerscape_armv8_64b=y\nCONFIG_SIGNED_PACKAGES=y\n'
 >> .config

Thanks a lot.

Best regards,
Yangbo Lu

> -Original Message-
> From: Y.b. Lu
> Sent: Monday, July 6, 2020 4:46 PM
> To: 'Hauke Mehrtens' 
> Cc: LEDE Development List 
> Subject: RE: build problems in layerscape target kernel
> 
> Thanks Huake.
> Let me try to fix this issue.
> 
> Best regards,
> Yangbo Lu
> 
> > -Original Message-
> > From: Hauke Mehrtens 
> > Sent: Sunday, July 5, 2020 6:34 PM
> > To: Y.b. Lu 
> > Cc: LEDE Development List 
> > Subject: build problems in layerscape target kernel
> >
> > Hi Yangbo Lu,
> >
> > I see some build problem with the layerscape target in the OpenWrt build
> > bots recently.
> >
> > Since the update to kernel 5.4.50 the scripts/headers_install.sh script
> > complains that include/linux/fmd/Peripherals/fm_port_ioctls.h includes
> > CONFIG_COMPAT. This is a problem when some user space application
> > includes this file, because user space applications do not know of the
> > kernel configuration and normally none of these CONFIG_ symbols is set.
> >
> > This happens when changing the Linux kernel from version 45.4.48 to
> > 5.4.49, but I do not know why this change is triggering this error and
> > why it did not happen before.
> >
> > This is the error message:
> >   HDRINST usr/include/linux/fmd/integrations/integration_ioctls.h
> >   HDRINST usr/include/linux/fmd/Peripherals/fm_port_ioctls.h
> > error: include/uapi/linux/fmd/Peripherals/fm_port_ioctls.h: leak
> > CONFIG_COMPAT to user-space
> > scripts/Makefile.headersinst:63: recipe for target
> > 'usr/include/linux/fmd/Peripherals/fm_port_ioctls.h' failed
> > make[5]: *** [usr/include/linux/fmd/Peripherals/fm_port_ioctls.h] Error 1
> > Makefile:1198: recipe for target 'headers' failed
> > make[4]: *** [headers] Error 2
> >
> >
> https://buildbot.openwrt.org/master/images/builders/layerscape%2Farmv7/b
> > uilds/349
> >
> > It is happening since:
> > https://git.openwrt.org/68d9cb82143b864d70e4fb3d7cbb7068f82216a1
> >
> > --
> >
> > Before we saw this problem the layerscape target in the linking of the
> > kernel image. It shows this error message.
> >
> >   LD  vmlinux
> >   SORTEX  vmlinux
> >   SYSMAP  System.map
> > Inconsistent kallsyms data
> > Try make KALLSYMS_EXTRA_PASS=1 as a workaround
> > Makefile:1081: recipe for target 'vmlinux' failed
> > make[4]: *** [vmlinux] Error 1
> >
> > This is happening since this build bot run, the changes since the
> > previous build are listed in the log:
> >
> https://buildbot.openwrt.org/master/images/builders/layerscape%2Farmv8_6
> > 4b/builds/422
> >
> > I haven't looked closer into this problem.
> >
> >
> > Hauke

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel