From: Susant Sahani Date: Fri, 21 Apr 2017 09:01:59 +0000 (+0530) Subject: networkd: vlan add GVRP support (#5761) X-Git-Tag: v234~311 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c8b21184052cc445a45f797ec11dae5e6a1d2b54;p=platform%2Fupstream%2Fsystemd.git networkd: vlan add GVRP support (#5761) Add support to configure GVRP. Closes #5760 --- diff --git a/man/systemd.netdev.xml b/man/systemd.netdev.xml index de22a6d..4ec672f 100644 --- a/man/systemd.netdev.xml +++ b/man/systemd.netdev.xml @@ -399,8 +399,15 @@ This option is compulsory. + + GVRP= + + The Generic VLAN Registration Protocol (GVRP) is a protocol that + allows automatic learning of VLANs on a network. A boolean. When unset, + the kernel's default setting applies. + + - diff --git a/src/network/netdev/netdev-gperf.gperf b/src/network/netdev/netdev-gperf.gperf index 925af1c..077fbc1 100644 --- a/src/network/netdev/netdev-gperf.gperf +++ b/src/network/netdev/netdev-gperf.gperf @@ -36,6 +36,7 @@ NetDev.Kind, config_parse_netdev_kind, 0, NetDev.MTUBytes, config_parse_iec_size, 0, offsetof(NetDev, mtu) NetDev.MACAddress, config_parse_hwaddr, 0, offsetof(NetDev, mac) VLAN.Id, config_parse_vlanid, 0, offsetof(VLan, id) +VLAN.GVRP, config_parse_tristate, 0, offsetof(VLan, gvrp) MACVLAN.Mode, config_parse_macvlan_mode, 0, offsetof(MacVlan, mode) MACVTAP.Mode, config_parse_macvlan_mode, 0, offsetof(MacVlan, mode) IPVLAN.Mode, config_parse_ipvlan_mode, 0, offsetof(IPVlan, mode) diff --git a/src/network/netdev/vlan.c b/src/network/netdev/vlan.c index 28c061f..718b627 100644 --- a/src/network/netdev/vlan.c +++ b/src/network/netdev/vlan.c @@ -17,12 +17,14 @@ along with systemd; If not, see . ***/ +#include #include #include "netdev/vlan.h" #include "vlan-util.h" static int netdev_vlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *req) { + struct ifla_vlan_flags flags = {}; VLan *v; int r; @@ -38,6 +40,19 @@ static int netdev_vlan_fill_message_create(NetDev *netdev, Link *link, sd_netlin if (r < 0) return log_netdev_error_errno(netdev, r, "Could not append IFLA_VLAN_ID attribute: %m"); + if (v->gvrp != -1) { + flags.mask |= VLAN_FLAG_GVRP; + + if (v->gvrp) + flags.flags |= VLAN_FLAG_GVRP; + else + flags.flags &= ~VLAN_FLAG_GVRP; + } + + r = sd_netlink_message_append_data(req, IFLA_VLAN_FLAGS, &flags, sizeof(struct ifla_vlan_flags)); + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VLAN_FLAGS attribute: %m"); + return 0; } @@ -66,6 +81,7 @@ static void vlan_init(NetDev *netdev) { assert(v); v->id = VLANID_INVALID; + v->gvrp = -1; } const NetDevVTable vlan_vtable = { diff --git a/src/network/netdev/vlan.h b/src/network/netdev/vlan.h index fade899..19a62b7 100644 --- a/src/network/netdev/vlan.h +++ b/src/network/netdev/vlan.h @@ -27,6 +27,8 @@ struct VLan { NetDev meta; uint16_t id; + + int gvrp; }; DEFINE_NETDEV_CAST(VLAN, VLan);