Skip to content

Commit c8b2118

Browse files
ssahanipoettering
authored andcommitted
networkd: vlan add GVRP support (systemd#5761)
Add support to configure GVRP. Closes systemd#5760
1 parent 41c237a commit c8b2118

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

man/systemd.netdev.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,15 @@
399399
This option is compulsory.</para>
400400
</listitem>
401401
</varlistentry>
402+
<varlistentry>
403+
<term><varname>GVRP=</varname></term>
404+
<listitem>
405+
<para>The Generic VLAN Registration Protocol (GVRP) is a protocol that
406+
allows automatic learning of VLANs on a network. A boolean. When unset,
407+
the kernel's default setting applies.</para>
408+
</listitem>
409+
</varlistentry>
402410
</variablelist>
403-
404411
</refsect1>
405412

406413
<refsect1>

src/network/netdev/netdev-gperf.gperf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ NetDev.Kind, config_parse_netdev_kind, 0,
3636
NetDev.MTUBytes, config_parse_iec_size, 0, offsetof(NetDev, mtu)
3737
NetDev.MACAddress, config_parse_hwaddr, 0, offsetof(NetDev, mac)
3838
VLAN.Id, config_parse_vlanid, 0, offsetof(VLan, id)
39+
VLAN.GVRP, config_parse_tristate, 0, offsetof(VLan, gvrp)
3940
MACVLAN.Mode, config_parse_macvlan_mode, 0, offsetof(MacVlan, mode)
4041
MACVTAP.Mode, config_parse_macvlan_mode, 0, offsetof(MacVlan, mode)
4142
IPVLAN.Mode, config_parse_ipvlan_mode, 0, offsetof(IPVlan, mode)

src/network/netdev/vlan.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
along with systemd; If not, see <http://www.gnu.org/licenses/>.
1818
***/
1919

20+
#include <linux/if_vlan.h>
2021
#include <net/if.h>
2122

2223
#include "netdev/vlan.h"
2324
#include "vlan-util.h"
2425

2526
static int netdev_vlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *req) {
27+
struct ifla_vlan_flags flags = {};
2628
VLan *v;
2729
int r;
2830

@@ -38,6 +40,19 @@ static int netdev_vlan_fill_message_create(NetDev *netdev, Link *link, sd_netlin
3840
if (r < 0)
3941
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VLAN_ID attribute: %m");
4042

43+
if (v->gvrp != -1) {
44+
flags.mask |= VLAN_FLAG_GVRP;
45+
46+
if (v->gvrp)
47+
flags.flags |= VLAN_FLAG_GVRP;
48+
else
49+
flags.flags &= ~VLAN_FLAG_GVRP;
50+
}
51+
52+
r = sd_netlink_message_append_data(req, IFLA_VLAN_FLAGS, &flags, sizeof(struct ifla_vlan_flags));
53+
if (r < 0)
54+
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VLAN_FLAGS attribute: %m");
55+
4156
return 0;
4257
}
4358

@@ -66,6 +81,7 @@ static void vlan_init(NetDev *netdev) {
6681
assert(v);
6782

6883
v->id = VLANID_INVALID;
84+
v->gvrp = -1;
6985
}
7086

7187
const NetDevVTable vlan_vtable = {

src/network/netdev/vlan.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ struct VLan {
2727
NetDev meta;
2828

2929
uint16_t id;
30+
31+
int gvrp;
3032
};
3133

3234
DEFINE_NETDEV_CAST(VLAN, VLan);

0 commit comments

Comments
 (0)