mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-02 09:47:03 +03:00
network: allow setting VLAN protocol on bridges
Signed-off-by: Rubens Figueiredo <rubens.figueiredo@bisdn.de>
This commit is contained in:
parent
cf217a0922
commit
4df4df5b56
@ -408,6 +408,15 @@
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>VLANProtocol=</varname></term>
|
||||
<listitem>
|
||||
<para>Allows setting the protocol used for VLAN filtering. Takes
|
||||
<option>802.1q</option> or,
|
||||
<option>802.1ad</option>, and defaults to unset and kernel's default is used.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>STP=</varname></term>
|
||||
<listitem>
|
||||
|
@ -126,6 +126,12 @@ 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_VLAN_FILTERING attribute: %m");
|
||||
}
|
||||
|
||||
if (b->vlan_protocol >= 0) {
|
||||
r = sd_netlink_message_append_u16(req, IFLA_BR_VLAN_PROTOCOL, b->vlan_protocol);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_BR_VLAN_PROTOCOL attribute: %m");
|
||||
}
|
||||
|
||||
if (b->stp >= 0) {
|
||||
r = sd_netlink_message_append_u32(req, IFLA_BR_STP_STATE, b->stp);
|
||||
if (r < 0)
|
||||
@ -346,6 +352,7 @@ static void bridge_init(NetDev *n) {
|
||||
b->mcast_querier = -1;
|
||||
b->mcast_snooping = -1;
|
||||
b->vlan_filtering = -1;
|
||||
b->vlan_protocol = -1;
|
||||
b->stp = -1;
|
||||
b->default_pvid = VLANID_INVALID;
|
||||
b->forward_delay = USEC_INFINITY;
|
||||
|
@ -13,6 +13,7 @@ typedef struct Bridge {
|
||||
int mcast_querier;
|
||||
int mcast_snooping;
|
||||
int vlan_filtering;
|
||||
int vlan_protocol;
|
||||
int stp;
|
||||
uint16_t priority;
|
||||
uint16_t group_fwd_mask;
|
||||
|
@ -206,6 +206,7 @@ Bridge.DefaultPVID, config_parse_default_port_vlanid,
|
||||
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)
|
||||
Bridge.VLANProtocol, config_parse_vlanprotocol, 0, offsetof(Bridge, vlan_protocol)
|
||||
Bridge.STP, config_parse_tristate, 0, offsetof(Bridge, stp)
|
||||
Bridge.MulticastIGMPVersion, config_parse_uint8, 0, offsetof(Bridge, igmp_version)
|
||||
VRF.TableId, config_parse_uint32, 0, offsetof(Vrf, table) /* deprecated */
|
||||
|
@ -1187,3 +1187,35 @@ int config_parse_permille(const char* unit,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_vlanprotocol(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 *vlan_protocol = data;
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
*vlan_protocol = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (STR_IN_SET(rvalue, "802.1ad", "802.1AD"))
|
||||
*vlan_protocol = ETH_P_8021AD;
|
||||
else if (STR_IN_SET(rvalue, "802.1q", "802.1Q"))
|
||||
*vlan_protocol = ETH_P_8021Q;
|
||||
else {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0,
|
||||
"Failed to parse VLAN protocol value, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -142,6 +142,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_ifnames);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_ip_port);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_mtu);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_rlimit);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_vlanprotocol);
|
||||
|
||||
typedef enum Disabled {
|
||||
DISABLED_CONFIGURATION,
|
||||
|
@ -45,6 +45,7 @@ AgeingTimeSec=
|
||||
Priority=
|
||||
GroupForwardMask=
|
||||
VLANFiltering=
|
||||
VLANProtocol=
|
||||
MulticastIGMPVersion=
|
||||
[VRF]
|
||||
TableId=
|
||||
|
Loading…
x
Reference in New Issue
Block a user