Skip to content

Commit d865394

Browse files
committed
networkd: vxlan support setting IPv6 flow labe
This work adds support for setting the IPv6 flow label for vxlan. vxlan.netdev NetDev] Description=vxlan-test Name=vxlan1 Kind=vxlan [VXLAN] Id=33 Local=2405:204:920b:29ac:7e7a:91ff:fe6d:ffe2 Remote=FF02:0:0:0:0:0:1:9 FlowLabel=104 ip -d link show vxlan1 8: vxlan1: <BROADCAST,MULTICAST> mtu 1430 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether be:83:aa:db:6b:cb brd ff:ff:ff:ff:ff:ff promiscuity 0 vxlan id 33 group ff02::1:9 local 2405:204:920b:29ac:7e7a:91ff:fe6d:ffe2 dev enp0s25 srcport 0 0 dstport 8472 flowlabel 0x68 ageing 300 noudpcsum noudp6zerocsumtx noudp6zerocsumrx addrgenmode eui64 numtxqueues 1 numrxqueues 1
1 parent 6d21646 commit d865394

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

man/systemd.netdev.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,14 @@
604604
ports, and allows overriding via configuration.</para>
605605
</listitem>
606606
</varlistentry>
607+
<varlistentry>
608+
<term><varname>FlowLabel=</varname></term>
609+
<listitem>
610+
<para>Specifies the flow label to use in outgoing packets.
611+
The valid range is 0-1048575.
612+
</para>
613+
</listitem>
614+
</varlistentry>
607615
</variablelist>
608616
</refsect1>
609617
<refsect1>

src/network/netdev/netdev-gperf.gperf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ VXLAN.GroupPolicyExtension, config_parse_bool, 0,
7878
VXLAN.MaximumFDBEntries, config_parse_unsigned, 0, offsetof(VxLan, max_fdb)
7979
VXLAN.PortRange, config_parse_port_range, 0, 0
8080
VXLAN.DestinationPort, config_parse_destination_port, 0, offsetof(VxLan, dest_port)
81+
VXLAN.FlowLabel, config_parse_flow_label, 0, 0
8182
Tun.OneQueue, config_parse_bool, 0, offsetof(TunTap, one_queue)
8283
Tun.MultiQueue, config_parse_bool, 0, offsetof(TunTap, multi_queue)
8384
Tun.PacketInfo, config_parse_bool, 0, offsetof(TunTap, packet_info)

src/network/netdev/vxlan.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_netli
157157
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_PORT_RANGE attribute: %m");
158158
}
159159

160+
r = sd_netlink_message_append_u32(m, IFLA_VXLAN_LABEL, htobe32(v->flow_label));
161+
if (r < 0)
162+
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_LABEL attribute: %m");
163+
160164
if (v->group_policy) {
161165
r = sd_netlink_message_append_flag(m, IFLA_VXLAN_GBP);
162166
if (r < 0)
@@ -297,6 +301,42 @@ int config_parse_destination_port(const char *unit,
297301
return 0;
298302
}
299303

304+
int config_parse_flow_label(const char *unit,
305+
const char *filename,
306+
unsigned line,
307+
const char *section,
308+
unsigned section_line,
309+
const char *lvalue,
310+
int ltype,
311+
const char *rvalue,
312+
void *data,
313+
void *userdata) {
314+
VxLan *v = userdata;
315+
unsigned f;
316+
int r;
317+
318+
assert(filename);
319+
assert(lvalue);
320+
assert(rvalue);
321+
assert(data);
322+
323+
r = safe_atou(rvalue, &f);
324+
if (r < 0) {
325+
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse VXLAN flow label '%s'.", rvalue);
326+
return 0;
327+
}
328+
329+
if (f & ~VXLAN_FLOW_LABEL_MAX_MASK) {
330+
log_syntax(unit, LOG_ERR, filename, line, r,
331+
"VXLAN flow label '%s' not valid. Flow label range should be [0-1048575].", rvalue);
332+
return 0;
333+
}
334+
335+
v->flow_label = f;
336+
337+
return 0;
338+
}
339+
300340
static int netdev_vxlan_verify(NetDev *netdev, const char *filename) {
301341
VxLan *v = VXLAN(netdev);
302342

src/network/netdev/vxlan.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ typedef struct VxLan VxLan;
2525
#include "netdev/netdev.h"
2626

2727
#define VXLAN_VID_MAX (1u << 24) - 1
28+
#define VXLAN_FLOW_LABEL_MAX_MASK 0xFFFFFU
2829

2930
struct VxLan {
3031
NetDev meta;
@@ -40,6 +41,7 @@ struct VxLan {
4041
unsigned tos;
4142
unsigned ttl;
4243
unsigned max_fdb;
44+
unsigned flow_label;
4345

4446
uint16_t dest_port;
4547

@@ -94,3 +96,14 @@ int config_parse_destination_port(const char *unit,
9496
const char *rvalue,
9597
void *data,
9698
void *userdata);
99+
100+
int config_parse_flow_label(const char *unit,
101+
const char *filename,
102+
unsigned line,
103+
const char *section,
104+
unsigned section_line,
105+
const char *lvalue,
106+
int ltype,
107+
const char *rvalue,
108+
void *data,
109+
void *userdata);

0 commit comments

Comments
 (0)