diff options
author | Vlad Yasevich <vyasevich@gmail.com> | 2014-10-03 11:29:16 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-05 21:21:36 -0400 |
commit | 96a20d9d7fff7068a2233b00379f0778a150bf86 (patch) | |
tree | 21abf27f7f18b540f65770d2877c938735b02afe /net/bridge/br_vlan.c | |
parent | e885439f37b0dce404291350f7c0368c2bb97cdb (diff) |
bridge: Add a default_pvid sysfs attribute
This patch allows the user to set and retrieve default_pvid
value. A new value can only be stored when vlan filtering
is disabled.
Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge/br_vlan.c')
-rw-r--r-- | net/bridge/br_vlan.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c index 3ba57fcdcd13..dfa7c9a7e193 100644 --- a/net/bridge/br_vlan.c +++ b/net/bridge/br_vlan.c @@ -499,9 +499,38 @@ err_filt: goto unlock; } +int br_vlan_set_default_pvid(struct net_bridge *br, unsigned long val) +{ + u16 pvid = val; + int err = 0; + + if (!val || val >= VLAN_VID_MASK) + return -EINVAL; + + if (!rtnl_trylock()) + return restart_syscall(); + + if (pvid == br->default_pvid) + goto unlock; + + /* Only allow default pvid change when filtering is disabled */ + if (br->vlan_enabled) { + pr_info_once("Please disable vlan filtering to change default_pvid\n"); + err = -EPERM; + goto unlock; + } + + br->default_pvid = pvid; + +unlock: + rtnl_unlock(); + return err; +} + void br_vlan_init(struct net_bridge *br) { br->vlan_proto = htons(ETH_P_8021Q); + br->default_pvid = 1; } /* Must be protected by RTNL. |