networkd: add support for vxlan Remote and Local.

This patch add supports to configure IFLA_VXLAN_LOCAL
and IFLA_VXLAN_GROUP.

The "Group" is renamed to "Remote" which is a multicast address.`

```
Description=vxlan-test
Name=vxlan1
Kind=vxlan

[VXLAN]
Id=33
Local=2001:db8:2f4:4bff:fa71:1a56
Remote=FF02:0:0:0:0:0:1:9
```

output
```
ip -d link show vxlan1
16: vxlan1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1430 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether fe:b4:97:03:f8:e5 brd ff:ff:ff:ff:ff:ff promiscuity 0
    vxlan id 33 group ff02::1:9 local 2001:db8:02f4:4bff:fa71:1a56 dev enp0s3 srcport 0 0 dstport 8472 ageing 300 noudpcsum noudp6zerocsumtx noudp6zerocsumrx addrgenmode none numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535

```
This commit is contained in:
Susant Sahani 2017-02-25 00:31:47 +05:30
parent 5564545b4d
commit d35e5d3763
4 changed files with 168 additions and 123 deletions

View file

@ -469,9 +469,15 @@
</listitem>
</varlistentry>
<varlistentry>
<term><varname>Group=</varname></term>
<term><varname>Remote=</varname></term>
<listitem>
<para>An assigned multicast group IP address.</para>
<para>Configures destination multicast group IP address.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>Local=</varname></term>
<listitem>
<para>Configures local IP address.</para>
</listitem>
</varlistentry>
<varlistentry>

View file

@ -54,7 +54,9 @@ Tunnel.EncapsulationLimit, config_parse_encap_limit, 0,
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.Group, config_parse_vxlan_address, 0, offsetof(VxLan, remote)
VXLAN.Local, config_parse_vxlan_address, 0, offsetof(VxLan, local)
VXLAN.Remote, config_parse_vxlan_address, 0, offsetof(VxLan, remote)
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)

View file

@ -24,6 +24,8 @@
#include "conf-parser.h"
#include "alloc-util.h"
#include "extract-word.h"
#include "string-util.h"
#include "strv.h"
#include "parse-util.h"
#include "missing.h"
@ -48,10 +50,30 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_netli
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_ID attribute: %m");
}
r = sd_netlink_message_append_in_addr(m, IFLA_VXLAN_GROUP, &v->group.in);
if (!in_addr_is_null(v->remote_family, &v->remote)) {
if (v->remote_family == AF_INET)
r = sd_netlink_message_append_in_addr(m, IFLA_VXLAN_GROUP, &v->remote.in);
else
r = sd_netlink_message_append_in6_addr(m, IFLA_VXLAN_GROUP6, &v->remote.in6);
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_GROUP attribute: %m");
}
if (!in_addr_is_null(v->local_family, &v->local)) {
if (v->local_family == AF_INET)
r = sd_netlink_message_append_in_addr(m, IFLA_VXLAN_LOCAL, &v->local.in);
else
r = sd_netlink_message_append_in6_addr(m, IFLA_VXLAN_LOCAL6, &v->local.in6);
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_LOCAL attribute: %m");
}
r = sd_netlink_message_append_u32(m, IFLA_VXLAN_LINK, link->ifindex);
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_LINK attribute: %m");
@ -144,7 +166,7 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_netli
return r;
}
int config_parse_vxlan_group_address(const char *unit,
int config_parse_vxlan_address(const char *unit,
const char *filename,
unsigned line,
const char *section,
@ -165,16 +187,28 @@ int config_parse_vxlan_group_address(const char *unit,
r = in_addr_from_string_auto(rvalue, &f, &buffer);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "vxlan multicast group address is invalid, ignoring assignment: %s", rvalue);
log_syntax(unit, LOG_ERR, filename, line, r, "vxlan '%s' address is invalid, ignoring assignment: %s", lvalue, rvalue);
return 0;
}
if (v->family != AF_UNSPEC && v->family != f) {
log_syntax(unit, LOG_ERR, filename, line, 0, "vxlan multicast group incompatible, ignoring assignment: %s", rvalue);
r = in_addr_is_multicast(f, &buffer);
if (STR_IN_SET(lvalue, "Group", "Remote")) {
if (r <= 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "vxlan invalid multicast '%s' address, ignoring assignment: %s", lvalue, rvalue);
return 0;
}
v->family = f;
v->remote_family = f;
} else {
if (r > 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "vxlan %s can not be multicast address, ignoring assignment: %s", lvalue, rvalue);
return 0;
}
v->local_family = f;
}
*addr = buffer;
return 0;

View file

@ -31,8 +31,11 @@ struct VxLan {
uint64_t id;
int family;
union in_addr_union group;
int remote_family;
int local_family;
union in_addr_union remote;
union in_addr_union local;
unsigned tos;
unsigned ttl;
@ -60,7 +63,7 @@ struct VxLan {
DEFINE_NETDEV_CAST(VXLAN, VxLan);
extern const NetDevVTable vxlan_vtable;
int config_parse_vxlan_group_address(const char *unit,
int config_parse_vxlan_address(const char *unit,
const char *filename,
unsigned line,
const char *section,