[systemd-devel] [PATCH] networkd: support vxlan parameters
Tom Gundersen
teg at jklm.no
Thu Dec 4 02:13:13 PST 2014
Applied. Thanks!
On Sat, Nov 15, 2014 at 3:54 AM, Susant Sahani <susant at redhat.com> wrote:
> V3: fix copy paste error
> V4: Make manual and config more readable
>
> Add vxlan paramertes to config.
> ---
> man/systemd.netdev.xml | 30 ++++++++++++
> src/network/networkd-netdev-gperf.gperf | 83 +++++++++++++++++----------------
> src/network/networkd-netdev-vxlan.c | 81 ++++++++++++++++++++++++++++++++
> src/network/networkd-netdev-vxlan.h | 10 ++++
> src/network/networkd.h | 11 +++++
> 5 files changed, 176 insertions(+), 39 deletions(-)
>
> diff --git a/man/systemd.netdev.xml b/man/systemd.netdev.xml
> index 275ee52..45934f2 100644
> --- a/man/systemd.netdev.xml
> +++ b/man/systemd.netdev.xml
> @@ -272,6 +272,36 @@
> to discover remote MAC addresses.</para>
> </listitem>
> </varlistentry>
> + <varlistentry>
> + <term><varname>FDBAgeingSec=</varname></term>
> + <listitem>
> + <para>The lifetime of Forwarding Database entry learnt by the kernel in seconds.</para>
> + </listitem>
> + </varlistentry>
> + <varlistentry>
> + <term><varname>ARPProxy=</varname></term>
> + <listitem>
> + <para>A boolean. When true, enables ARP proxy.</para>
> + </listitem>
> + </varlistentry>
> + <varlistentry>
> + <term><varname>L2MissNotification=</varname></term>
> + <listitem>
> + <para>A boolean. When true, enables netlink LLADDR miss notifications.</para>
> + </listitem>
> + </varlistentry>
> + <varlistentry>
> + <term><varname>L3MissNotification=</varname></term>
> + <listitem>
> + <para>A boolean. When true, enables netlink IP ADDR miss notifications.</para>
> + </listitem>
> + </varlistentry>
> + <varlistentry>
> + <term><varname>RouteShortCircuit=</varname></term>
> + <listitem>
> + <para>A boolean. When true route short circuit is turned on.</para>
> + </listitem>
> + </varlistentry>
> </variablelist>
> </refsect1>
> <refsect1>
> diff --git a/src/network/networkd-netdev-gperf.gperf b/src/network/networkd-netdev-gperf.gperf
> index c524ee5..b311ebe 100644
> --- a/src/network/networkd-netdev-gperf.gperf
> +++ b/src/network/networkd-netdev-gperf.gperf
> @@ -18,42 +18,47 @@ struct ConfigPerfItem;
> %struct-type
> %includes
> %%
> -Match.Host, config_parse_net_condition, CONDITION_HOST, offsetof(NetDev, match_host)
> -Match.Virtualization, config_parse_net_condition, CONDITION_VIRTUALIZATION, offsetof(NetDev, match_virt)
> -Match.KernelCommandLine, config_parse_net_condition, CONDITION_KERNEL_COMMAND_LINE, offsetof(NetDev, match_kernel)
> -Match.Architecture, config_parse_net_condition, CONDITION_ARCHITECTURE, offsetof(NetDev, match_arch)
> -NetDev.Description, config_parse_string, 0, offsetof(NetDev, description)
> -NetDev.Name, config_parse_ifname, 0, offsetof(NetDev, ifname)
> -NetDev.Kind, config_parse_netdev_kind, 0, offsetof(NetDev, kind)
> -NetDev.MTUBytes, config_parse_iec_size, 0, offsetof(NetDev, mtu)
> -NetDev.MACAddress, config_parse_hwaddr, 0, offsetof(NetDev, mac)
> -VLAN.Id, config_parse_uint64, 0, offsetof(VLan, id)
> -MACVLAN.Mode, config_parse_macvlan_mode, 0, offsetof(MacVlan, mode)
> -Tunnel.Local, config_parse_tunnel_address, 0, offsetof(Tunnel, local)
> -Tunnel.Remote, config_parse_tunnel_address, 0, offsetof(Tunnel, remote)
> -Tunnel.TOS, config_parse_unsigned, 0, offsetof(Tunnel, tos)
> -Tunnel.TTL, config_parse_unsigned, 0, offsetof(Tunnel, ttl)
> -Tunnel.DiscoverPathMTU, config_parse_bool, 0, offsetof(Tunnel, pmtudisc)
> -Peer.Name, config_parse_ifname, 0, offsetof(Veth, ifname_peer)
> -Peer.MACAddress, config_parse_hwaddr, 0, offsetof(Veth, mac_peer)
> -VXLAN.Id, config_parse_uint64, 0, offsetof(VxLan, id)
> -VXLAN.Group, config_parse_tunnel_address, 0, offsetof(VxLan, group)
> -VXLAN.TOS, config_parse_unsigned, 0, offsetof(VxLan, tos)
> -VXLAN.TTL, config_parse_unsigned, 0, offsetof(VxLan, ttl)
> -VXLAN.MacLearning, config_parse_bool, 0, offsetof(VxLan, learning)
> -Tun.OneQueue, config_parse_bool, 0, offsetof(TunTap, one_queue)
> -Tun.MultiQueue, config_parse_bool, 0, offsetof(TunTap, multi_queue)
> -Tun.PacketInfo, config_parse_bool, 0, offsetof(TunTap, packet_info)
> -Tun.User, config_parse_string, 0, offsetof(TunTap, user_name)
> -Tun.Group, config_parse_string, 0, offsetof(TunTap, group_name)
> -Tap.OneQueue, config_parse_bool, 0, offsetof(TunTap, one_queue)
> -Tap.MultiQueue, config_parse_bool, 0, offsetof(TunTap, multi_queue)
> -Tap.PacketInfo, config_parse_bool, 0, offsetof(TunTap, packet_info)
> -Tap.User, config_parse_string, 0, offsetof(TunTap, user_name)
> -Tap.Group, config_parse_string, 0, offsetof(TunTap, group_name)
> -Bond.Mode, config_parse_bond_mode, 0, offsetof(Bond, mode)
> -Bond.TransmitHashPolicy, config_parse_bond_xmit_hash_policy, 0, offsetof(Bond, xmit_hash_policy)
> -Bond.LACPTransmitRate, config_parse_bond_lacp_rate, 0, offsetof(Bond, lacp_rate)
> -Bond.MIIMonitorSec, config_parse_sec, 0, offsetof(Bond, miimon)
> -Bond.UpDelaySec, config_parse_sec, 0, offsetof(Bond, updelay)
> -Bond.DownDelaySec, config_parse_sec, 0, offsetof(Bond, downdelay)
> +Match.Host, config_parse_net_condition, CONDITION_HOST, offsetof(NetDev, match_host)
> +Match.Virtualization, config_parse_net_condition, CONDITION_VIRTUALIZATION, offsetof(NetDev, match_virt)
> +Match.KernelCommandLine, config_parse_net_condition, CONDITION_KERNEL_COMMAND_LINE, offsetof(NetDev, match_kernel)
> +Match.Architecture, config_parse_net_condition, CONDITION_ARCHITECTURE, offsetof(NetDev, match_arch)
> +NetDev.Description, config_parse_string, 0, offsetof(NetDev, description)
> +NetDev.Name, config_parse_ifname, 0, offsetof(NetDev, ifname)
> +NetDev.Kind, config_parse_netdev_kind, 0, offsetof(NetDev, kind)
> +NetDev.MTUBytes, config_parse_iec_size, 0, offsetof(NetDev, mtu)
> +NetDev.MACAddress, config_parse_hwaddr, 0, offsetof(NetDev, mac)
> +VLAN.Id, config_parse_uint64, 0, offsetof(VLan, id)
> +MACVLAN.Mode, config_parse_macvlan_mode, 0, offsetof(MacVlan, mode)
> +Tunnel.Local, config_parse_tunnel_address, 0, offsetof(Tunnel, local)
> +Tunnel.Remote, config_parse_tunnel_address, 0, offsetof(Tunnel, remote)
> +Tunnel.TOS, config_parse_unsigned, 0, offsetof(Tunnel, tos)
> +Tunnel.TTL, config_parse_unsigned, 0, offsetof(Tunnel, ttl)
> +Tunnel.DiscoverPathMTU, config_parse_bool, 0, offsetof(Tunnel, pmtudisc)
> +Peer.Name, config_parse_ifname, 0, offsetof(Veth, ifname_peer)
> +Peer.MACAddress, config_parse_hwaddr, 0, offsetof(Veth, mac_peer)
> +VXLAN.Id, config_parse_uint64, 0, offsetof(VxLan, id)
> +VXLAN.Group, config_parse_vxlan_group_address, 0, offsetof(VxLan, group)
> +VXLAN.TOS, config_parse_unsigned, 0, offsetof(VxLan, tos)
> +VXLAN.TTL, config_parse_unsigned, 0, offsetof(VxLan, ttl)
> +VXLAN.MacLearning, config_parse_bool, 0, offsetof(VxLan, learning)
> +VXLAN.ARPProxy, config_parse_bool, 0, offsetof(VxLan, arp_proxy)
> +VXLAN.L2MissNotification, config_parse_bool, 0, offsetof(VxLan, l2miss)
> +VXLAN.L3MissNotification, config_parse_bool, 0, offsetof(VxLan, l3miss)
> +VXLAN.RouteShortCircuit, config_parse_bool, 0, offsetof(VxLan, route_short_circuit)
> +VXLAN.FDBAgeingSec, config_parse_sec, 0, offsetof(VxLan, fdb_ageing)
> +Tun.OneQueue, config_parse_bool, 0, offsetof(TunTap, one_queue)
> +Tun.MultiQueue, config_parse_bool, 0, offsetof(TunTap, multi_queue)
> +Tun.PacketInfo, config_parse_bool, 0, offsetof(TunTap, packet_info)
> +Tun.User, config_parse_string, 0, offsetof(TunTap, user_name)
> +Tun.Group, config_parse_string, 0, offsetof(TunTap, group_name)
> +Tap.OneQueue, config_parse_bool, 0, offsetof(TunTap, one_queue)
> +Tap.MultiQueue, config_parse_bool, 0, offsetof(TunTap, multi_queue)
> +Tap.PacketInfo, config_parse_bool, 0, offsetof(TunTap, packet_info)
> +Tap.User, config_parse_string, 0, offsetof(TunTap, user_name)
> +Tap.Group, config_parse_string, 0, offsetof(TunTap, group_name)
> +Bond.Mode, config_parse_bond_mode, 0, offsetof(Bond, mode)
> +Bond.TransmitHashPolicy, config_parse_bond_xmit_hash_policy, 0, offsetof(Bond, xmit_hash_policy)
> +Bond.LACPTransmitRate, config_parse_bond_lacp_rate, 0, offsetof(Bond, lacp_rate)
> +Bond.MIIMonitorSec, config_parse_sec, 0, offsetof(Bond, miimon)
> +Bond.UpDelaySec, config_parse_sec, 0, offsetof(Bond, updelay)
> +Bond.DownDelaySec, config_parse_sec, 0, offsetof(Bond, downdelay)
> diff --git a/src/network/networkd-netdev-vxlan.c b/src/network/networkd-netdev-vxlan.c
> index 326ac54..69e477a 100644
> --- a/src/network/networkd-netdev-vxlan.c
> +++ b/src/network/networkd-netdev-vxlan.c
> @@ -26,6 +26,7 @@
> #include "sd-rtnl.h"
> #include "networkd-netdev-vxlan.h"
> #include "networkd-link.h"
> +#include "conf-parser.h"
> #include "missing.h"
>
> static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_message *m) {
> @@ -92,9 +93,89 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_
> return r;
> }
>
> + r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_RSC, v->route_short_circuit);
> + if (r < 0) {
> + log_error_netdev(netdev,
> + "Could not append IFLA_VXLAN_RSC attribute: %s",
> + strerror(-r));
> + return r;
> + }
> +
> + r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_PROXY, v->arp_proxy);
> + if (r < 0) {
> + log_error_netdev(netdev,
> + "Could not append IFLA_VXLAN_PROXY attribute: %s",
> + strerror(-r));
> + return r;
> + }
> +
> + r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_L2MISS, v->l2miss);
> + if (r < 0) {
> + log_error_netdev(netdev,
> + "Could not append IFLA_VXLAN_L2MISS attribute: %s",
> + strerror(-r));
> + return r;
> + }
> +
> + r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_L3MISS, v->l3miss);
> + if (r < 0) {
> + log_error_netdev(netdev,
> + "Could not append IFLA_VXLAN_L3MISS attribute: %s",
> + strerror(-r));
> + return r;
> + }
> +
> + if(v->fdb_ageing) {
> + r = sd_rtnl_message_append_u32(m, IFLA_VXLAN_AGEING, v->fdb_ageing / USEC_PER_SEC);
> + if (r < 0) {
> + log_error_netdev(netdev,
> + "Could not append IFLA_VXLAN_AGEING attribute: %s",
> + strerror(-r));
> + return r;
> + }
> + }
> +
> return r;
> }
>
> +int config_parse_vxlan_group_address(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) {
> + VxLan *v = userdata;
> + union in_addr_union *addr = data, buffer;
> + int r, f;
> +
> + assert(filename);
> + assert(lvalue);
> + assert(rvalue);
> + assert(data);
> +
> + r = in_addr_from_string_auto(rvalue, &f, &buffer);
> + if (r < 0) {
> + log_syntax(unit, LOG_ERR, filename, line, EINVAL,
> + "vxlan multicast group address is invalid, ignoring assignment: %s", rvalue);
> + return 0;
> + }
> +
> + if(v->family != AF_UNSPEC && v->family != f) {
> + log_syntax(unit, LOG_ERR, filename, line, EINVAL,
> + "vxlan multicast group incompatible, ignoring assignment: %s", rvalue);
> + return 0;
> + }
> +
> + v->family = f;
> + *addr = buffer;
> +
> + return 0;
> +}
> +
> static int netdev_vxlan_verify(NetDev *netdev, const char *filename) {
> VxLan *v = VXLAN(netdev);
>
> diff --git a/src/network/networkd-netdev-vxlan.h b/src/network/networkd-netdev-vxlan.h
> index 8c906f1..6339af9 100644
> --- a/src/network/networkd-netdev-vxlan.h
> +++ b/src/network/networkd-netdev-vxlan.h
> @@ -33,10 +33,20 @@ struct VxLan {
> NetDev meta;
>
> uint64_t id;
> +
> + int family;
> union in_addr_union group;
> +
> unsigned tos;
> unsigned ttl;
> +
> + usec_t fdb_ageing;
> +
> bool learning;
> + bool arp_proxy;
> + bool route_short_circuit;
> + bool l2miss;
> + bool l3miss;
> };
>
> extern const NetDevVTable vxlan_vtable;
> diff --git a/src/network/networkd.h b/src/network/networkd.h
> index 19a661e..791f8a7 100644
> --- a/src/network/networkd.h
> +++ b/src/network/networkd.h
> @@ -259,6 +259,17 @@ int config_parse_tunnel_address(const char *unit,
> void *data,
> void *userdata);
>
> +int config_parse_vxlan_group_address(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);
> +
> /* gperf */
> const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, unsigned length);
>
> --
> 2.1.0
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
More information about the systemd-devel
mailing list