mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-08 20:58:20 +03:00
network: bridge vlan without PVID (#5899)
this patch makes it possible to configure a vlan aware bridge without the PVID. To configure no PVID set DefaultPVID=none in the [BridgeVLAN] section. fixes #5716
This commit is contained in:
parent
defdbbb6dc
commit
0d6c68eba3
@ -344,7 +344,8 @@
|
||||
<varlistentry>
|
||||
<term><varname>DefaultPVID=</varname></term>
|
||||
<listitem>
|
||||
<para>This specifies the default port VLAN ID of a newly attached bridge port.</para>
|
||||
<para>This specifies the default port VLAN ID of a newly attached bridge port.
|
||||
Set this to an integer in the range 1–4094 or <literal>none</literal> to disable the PVID.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "netlink-util.h"
|
||||
#include "netdev/bridge.h"
|
||||
#include "networkd-manager.h"
|
||||
#include "vlan-util.h"
|
||||
|
||||
/* callback for brige netdev's parameter set */
|
||||
static int netdev_bridge_set_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
@ -102,7 +103,7 @@ static int netdev_bridge_post_create(NetDev *netdev, Link *link, sd_netlink_mess
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_BR_PRIORITY attribute: %m");
|
||||
}
|
||||
|
||||
if (b->default_pvid > 0) {
|
||||
if (b->default_pvid != VLANID_INVALID) {
|
||||
r = sd_netlink_message_append_u16(req, IFLA_BR_VLAN_DEFAULT_PVID, b->default_pvid);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_BR_VLAN_DEFAULT_PVID attribute: %m");
|
||||
@ -160,6 +161,7 @@ static void bridge_init(NetDev *n) {
|
||||
b->mcast_snooping = -1;
|
||||
b->vlan_filtering = -1;
|
||||
b->stp = -1;
|
||||
b->default_pvid = VLANID_INVALID;
|
||||
b->forward_delay = USEC_INFINITY;
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ Bridge.MaxAgeSec, config_parse_sec, 0,
|
||||
Bridge.AgeingTimeSec, config_parse_sec, 0, offsetof(Bridge, ageing_time)
|
||||
Bridge.ForwardDelaySec, config_parse_sec, 0, offsetof(Bridge, forward_delay)
|
||||
Bridge.Priority, config_parse_uint16, 0, offsetof(Bridge, priority)
|
||||
Bridge.DefaultPVID, config_parse_vlanid, 0, offsetof(Bridge, default_pvid)
|
||||
Bridge.DefaultPVID, config_parse_default_port_vlanid, 0, offsetof(Bridge, default_pvid)
|
||||
Bridge.MulticastQuerier, config_parse_tristate, 0, offsetof(Bridge, mcast_querier)
|
||||
Bridge.MulticastSnooping, config_parse_tristate, 0, offsetof(Bridge, mcast_snooping)
|
||||
Bridge.VLANFiltering, config_parse_tristate, 0, offsetof(Bridge, vlan_filtering)
|
||||
|
@ -17,9 +17,10 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "vlan-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "conf-parser.h"
|
||||
#include "parse-util.h"
|
||||
#include "string-util.h"
|
||||
#include "vlan-util.h"
|
||||
|
||||
int parse_vlanid(const char *p, uint16_t *ret) {
|
||||
uint16_t id;
|
||||
@ -35,6 +36,32 @@ int parse_vlanid(const char *p, uint16_t *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_default_port_vlanid(
|
||||
const char *unit,
|
||||
const char *filename,
|
||||
unsigned line,
|
||||
const char *section,
|
||||
unsigned section_line,
|
||||
const char *lvalue,
|
||||
int ltype,
|
||||
const char *rvalue,
|
||||
void *data,
|
||||
void *userdata) {
|
||||
uint16_t *id = data;
|
||||
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
if (streq(rvalue, "none")) {
|
||||
*id = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return config_parse_vlanid(unit, filename, line, section, section_line,
|
||||
lvalue, ltype, rvalue, data, userdata);
|
||||
}
|
||||
|
||||
int config_parse_vlanid(
|
||||
const char *unit,
|
||||
const char *filename,
|
||||
|
@ -32,4 +32,5 @@ static inline bool vlanid_is_valid(uint16_t id) {
|
||||
|
||||
int parse_vlanid(const char *p, uint16_t *ret);
|
||||
|
||||
int config_parse_default_port_vlanid(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
int config_parse_vlanid(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
|
Loading…
x
Reference in New Issue
Block a user