Commit Graph

38 Commits (35ab804ea7fa9e92a5e09f9a41a03768b3cd0a82)

Author SHA1 Message Date
Mathias Kresin 35ab804ea7 kernel: swconfig: make compatible with kernel 5.2
Since kernel 5.2 within netlink messages the NLA_F_NESTED nested flag is
validated. But swconfig/swlib doesn't set the flag for
SWITCH_ATTR_OP_VALUE_PORTS related netlink messages and assigning ports
to vlans via

  swconfig dev switch0 vlan 1 set ports '0 1 2 3 4 6t'

Errors put with "Failed to set attribute: Invalid input data or
parameter".

Relax the validation rules and use the deprecated functions, to use the
same level of validation as it was till kernel 5.1. Depending on who has
swconfig related netlink messages implemented, there might be more
broken tools out there and we should keep backward compatibility if
possible.

Signed-off-by: Mathias Kresin <dev@kresin.me>
Tested-by: Rafał Miłecki <rafal@milecki.pl>
4 years ago
Tobias Schramm 8f9cd1af0f swconfig: fix Broadcom b53 support
This commit fixes a bug in the main swconfig patch where a function
needed by the b53 driver is not exported.
Additionally it adds OF support to the b53_mdio driver for devicetree-
based probing

Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
4 years ago
Rafał Miłecki b49f2113cc kernel: fix swconfig compilation with kernels 5.2+
This is related to the upstream kernel change 3b0f31f2b8c9 ("genetlink:
make policy common to family").

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
5 years ago
Felix Fietkau ed3860c3e3 swconfig: convert swdevs_lock from spinlock to mutex
Should fix some sleep-while-atomic issues

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Hauke Mehrtens b3f95490b9 kernel: generic: Add kernel 4.14 support
This adds initial support for kernel 4.14 based on the patches for
kernel 4.9.

In the configuration I deactivated some of the new possible security
features like:
CONFIG_REFCOUNT_FULL
CONFIG_SLAB_FREELIST_HARDENED
CONFIG_SOFTLOCKUP_DETECTOR
CONFIG_WARN_ALL_UNSEEDED_RANDOM

And these overlay FS options are also deactivated:
CONFIG_OVERLAY_FS_INDEX
CONFIG_OVERLAY_FS_REDIRECT_DIR

I activated this:
CONFIG_FORTIFY_SOURCE
CONFIG_POSIX_TIMERS
CONFIG_SLAB_MERGE_DEFAULT
CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED

I am not sure if I did the porting correct for the following patches:
target/linux/generic/backport-4.14/020-backport_netfilter_rtcache.patch
target/linux/generic/hack-4.14/220-gc_sections.patch
target/linux/generic/hack-4.14/321-powerpc_crtsavres_prereq.patch
target/linux/generic/pending-4.14/305-mips_module_reloc.patch
target/linux/generic/pending-4.14/611-netfilter_match_bypass_default_table.patch
target/linux/generic/pending-4.14/680-NET-skip-GRO-for-foreign-MAC-addresses.patch

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
7 years ago
Alexander Couzens 878cd77026 linux/swconfig_get_attr: fix leak of msg in case of error
Found-by: Coverity Scan #1330102
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
7 years ago
Pavel Kubelun 5a69f59602 net: ar8216: address security vulnerabilities in swconfig & ar8216
Imported from e1aaf7ec00%5E%21/#F0
Signed-off-by: Pavel Kubelun <be.dissent@gmail.com>

CHROMIUM: net: ar8216: address security vulnerabilities in swconfig & ar8216

This patch does the following changes:
*address the security vulnerabilities in both swconfig framework and in
 ar8216 driver (many bound check additions, and turned swconfig structure
 signed element into unsigned when applicable)
*address a couple of whitespaces and indendation issues

BUG=chrome-os-partner:33096
TEST=none

Change-Id: I94ea78fcce8c1932cc584d1508c6e3b5dfb93ce9
Signed-off-by: Mathieu Olivari <mathieu@codeaurora.org>
Reviewed-on: https://chromium-review.googlesource.com/236490
Reviewed-by: Toshi Kikuchi <toshik@chromium.org>
Commit-Queue: Toshi Kikuchi <toshik@chromium.org>
Tested-by: Toshi Kikuchi <toshik@chromium.org>
8 years ago
John Crispin 99a1888287 swconfig: revert the portmapping patches, they seem to cause a segfault
Revert "kernel/swconfig: remove obsolete portmapping feature from swconfig"

This reverts commit 675407baa4.

Revert "swconfig: remove obsolete portmapping feature"

This reverts commit fca1eb349e.

Signed-off-by: John Crispin <john@phrozen.org>
8 years ago
John Crispin 675407baa4 kernel/swconfig: remove obsolete portmapping feature from swconfig
Signed-off-by: John Crispin <john@phrozen.org>
8 years ago
Felix Fietkau 37cfc23cb7 kernel: require admin permissions for swconfig set operations
Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years ago
Jo-Philipp Wich 442db0d6d8 kernel: deny swconfig set requests for unprivileged users
The swconfig kernel infrastructure fails to do any permissions checks when
changing settings. As such an ordinary user account on a device with a
switch can change switch settings without any special permissions.
Routers generally have few non-admin users so this isn't a big hole, but it
is a security hole. Likely the greatest danger is for multifunction devices
which have a lot of extra daemons, compromising a low-security daemon would
allow one to modify switch settings and cause the router/switch to appear to
lock-up (or cause other sorts of troublesome nyetwork behavior).

Implement a check for CAP_NET_ADMIN in swconfig_set_attr() and deny any
requests originating from user contexts lacking this capability.

Reported-by: Elliott Mitchell <ehem+openwrt@m5p.com>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
8 years ago
Felix Fietkau 7eeb254cc4 treewide: replace nbd@openwrt.org with nbd@nbd.name
Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years ago
Rafał Miłecki 19b9e14c47 swconfig: add (PHY) generic helper setting port link
It's quite common for switches to have PHY per port so adding a generic
helper setting link state will help many drivers. It just needs an API
to access PHYs which this patch also adds.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>

SVN-Revision: 48621
8 years ago
Jonas Gorski a9b4952be1 swconfig: simplify init code
Directly return the return value of genl_register_family_with_ops()
instead of storing it in a temporary variable, then returning it.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>

SVN-Revision: 48472
9 years ago
Jonas Gorski 38719ecca4 swconfig: drop linux < 3.13 code paths
The oldest kernel we support is 3.18, no need to keep code paths
for older kernels.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>

SVN-Revision: 48471
9 years ago
Rafał Miłecki 5f69279dd6 swconfig: add API for setting port link speed
Some switches can force link speed for a port. Let's add API that will
allow drivers to export this feature.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>

SVN-Revision: 48142
9 years ago
John Crispin 71cd537a8a swconfig: switch kernel PORT_LINK support to SWITCH_TYPE_LINK
As explained earlier, using SWITCH_TYPE_LINK gives more flexibility,
it doesn't require e.g. string parsing to read some data.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>

SVN-Revision: 47999
9 years ago
John Crispin 67e10d757f swconfig: add SWITCH_TYPE_LINK and support sending link info to user space
So far we were sending link data as a string. It got some drawbacks:
1) Didn't allow writing clean user space apps reading link state. It was
   needed to do some screen scraping.
2) Forced whole PORT_LINK communication to be string based. Adding
   support for *setting* port link required passing string and parting
   it in the kernel space.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>

SVN-Revision: 47997
9 years ago
John Crispin 57c7bed820 swconfig: fix build with linux 4.0
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>

SVN-Revision: 44617
9 years ago
Felix Fietkau 53c0c6054f ar8216: add 802.3az EEE info to swconfig get_link attribute
AR8327/AR8337 allow to read the result of EEE autonegotiation.
If EEE is autonegotiated between the link partners, display
this as part of the swconfig get_link attribute.

eee100:  100MBit EEE supported by both link partners
eee1000: 1GBit EEE supported by both link partners

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

SVN-Revision: 44022
10 years ago
John Crispin 62107ff367 swconfig: last vs tail
sorry .....

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 43107
10 years ago
John Crispin ab5d70e046 swconfig: "swconfig list" shows devices in reverse order
Boards that have more than one swconfig enabled switch will show the devices in
reverse order when call swconfig list. Fix this by using list_add_tail().

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 43106
10 years ago
Hauke Mehrtens 100e795bcc kernel: fix warning in swconfig.c with kernel 3.14
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

SVN-Revision: 40733
10 years ago
Zoltan Herpai f3c07b8621 modules: swconfig.c: update the error path on 3.13, and behave nicely with return
Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu>

SVN-Revision: 39360
11 years ago
Zoltan Herpai 4d26250db1 modules: update swconfig.c to compile on 3.13 (compile-tested)
Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu>

SVN-Revision: 39359
11 years ago
Florian Fainelli 857a7a0124 kernel: make swconfig checkpath compliant
Fix the warnings and errors reported by checkpatch on swconfig.c

Signed-off-by: Florian Fainelli <florian@openwrt.org>

SVN-Revision: 38523
11 years ago
John Crispin fb47fd0d6b unbreak portmapping - typo fix
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 36293
11 years ago
John Crispin fff58a5801 allow loading port maps from OF
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 36283
11 years ago
Gabor Juhos 10d30f2d2d swconfig: make it compatible with 3.7
swconfig does not compile with 3.7 because

struct netlink_notify->pid    has been renamed to
struct netlink_notify->portid

and

struct genl_info->snd_pid     has been renamed to
struct genl_info->snd_portid

Use the new names and add compatibility patches
to 3.3 and 3.6.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

SVN-Revision: 34288
12 years ago
Florian Fainelli 4afb91a12f swconfig: get rid of the NLA_PUT_* macros
Upstream kernel 3.6 has removed this usage, use the plain functions directly as
intended.

SVN-Revision: 33906
12 years ago
Felix Fietkau b957208807 swconfig: use a mutex instead of a spinlock, many swconfig calls sleep
SVN-Revision: 30952
12 years ago
Gabor Juhos 759c341e68 generic: swconfig: add a generic get_port_link implementation
SVN-Revision: 30839
12 years ago
Gabor Juhos 5fa65cba6e kernel: swconfig: introduce a generic switch LED trigger
SVN-Revision: 29627
13 years ago
Gabor Juhos 297ac9a7f1 kernel: swconfig: add a missing unlock in error path
SVN-Revision: 28753
13 years ago
Jonas Gorski eaa935658b swconfig: Add generic switch identifiers
Also make switches available under a generic name "switch<num>" for device
name agnostic access. The old device name is used as an alias for backward
compatibility.

SVN-Revision: 27800
13 years ago
Felix Fietkau 9e8cd78944 swconfig: Replace SPIN_LOCK_UNLOCKED with DEFINE_SPINLOCK
SPIN_LOCK_UNLOCKED has been deprecated since 2.6.19 and will get removed
in 2.6.39, so replace it with DEFINE_SPINLOCK().

Signed-off-by: Jonas Gorski <jonas.gorski+openwrt@gmail.com>

SVN-Revision: 26770
13 years ago
Felix Fietkau bd6324190f swconfig: cleanup of kernel drivers and interface - add some comments to a few data structures - add a switch_dev_ops data structure for attributes and callback to replace the stupid template memcpy - get rid of the switch_dev.priv pointer - using container_of() is better
SVN-Revision: 22476
14 years ago
Felix Fietkau da1bb88a2b rename target/linux/generic-2.6 to generic
SVN-Revision: 21952
14 years ago