Skip to content

Commit 1189c00

Browse files
ssahaniyuwata
authored andcommitted
networkd: VXLAN add support to configure IP Don't fragment.
Allow users to set the IPv4 DF bit in outgoing packets, or to inherit its value from the IPv4 inner header. If the encapsulated protocol is IPv6 and DF is configured to be inherited, always set it.
1 parent 2a36d40 commit 1189c00

File tree

5 files changed

+44
-0
lines changed

5 files changed

+44
-0
lines changed

man/systemd.netdev.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,15 @@
691691
The valid range is 0-1048575.
692692
</para>
693693
</listitem>
694+
</varlistentry>
695+
<varlistentry>
696+
<term><varname>IPDoNotFragment=</varname></term>
697+
<listitem>
698+
<para>Allows to set the IPv4 Do not Fragment (DF) bit in outgoing packets, or to inherit its
699+
value from the IPv4 inner header. Takes a boolean value, or <literal>inherit</literal>. Set
700+
to <literal>inherit</literal> if the encapsulated protocol is IPv6. When unset, the kernel's
701+
default will be used.</para>
702+
</listitem>
694703
</varlistentry>
695704
</variablelist>
696705
</refsect1>

src/network/netdev/netdev-gperf.gperf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ VXLAN.MaximumFDBEntries, config_parse_unsigned,
124124
VXLAN.PortRange, config_parse_port_range, 0, 0
125125
VXLAN.DestinationPort, config_parse_ip_port, 0, offsetof(VxLan, dest_port)
126126
VXLAN.FlowLabel, config_parse_flow_label, 0, 0
127+
VXLAN.IPDoNotFragment, config_parse_df, 0, offsetof(VxLan, df)
127128
GENEVE.Id, config_parse_geneve_vni, 0, offsetof(Geneve, id)
128129
GENEVE.Remote, config_parse_geneve_address, 0, offsetof(Geneve, remote)
129130
GENEVE.TOS, config_parse_uint8, 0, offsetof(Geneve, tos)

src/network/netdev/vxlan.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "conf-parser.h"
88
#include "alloc-util.h"
99
#include "extract-word.h"
10+
#include "string-table.h"
1011
#include "string-util.h"
1112
#include "strv.h"
1213
#include "parse-util.h"
@@ -15,6 +16,15 @@
1516
#include "networkd-link.h"
1617
#include "netdev/vxlan.h"
1718

19+
static const char* const df_table[_NETDEV_VXLAN_DF_MAX] = {
20+
[NETDEV_VXLAN_DF_NO] = "no",
21+
[NETDEV_VXLAN_DF_YES] = "yes",
22+
[NETDEV_VXLAN_DF_INHERIT] = "inherit",
23+
};
24+
25+
DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(df, VxLanDF, NETDEV_VXLAN_DF_YES);
26+
DEFINE_CONFIG_PARSE_ENUM(config_parse_df, df, VxLanDF, "Failed to parse VXLAN IPDoNotFragment= setting");
27+
1828
static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) {
1929
VxLan *v;
2030
int r;
@@ -150,6 +160,12 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_netli
150160
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_GPE attribute: %m");
151161
}
152162

163+
if (v->df != _NETDEV_VXLAN_DF_INVALID) {
164+
r = sd_netlink_message_append_u8(m, IFLA_VXLAN_DF, v->df);
165+
if (r < 0)
166+
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_DF attribute: %m");
167+
}
168+
153169
return r;
154170
}
155171

@@ -305,6 +321,7 @@ static void vxlan_init(NetDev *netdev) {
305321
assert(v);
306322

307323
v->vni = VXLAN_VID_MAX + 1;
324+
v->df = _NETDEV_VXLAN_DF_INVALID;
308325
v->learning = true;
309326
v->udpcsum = false;
310327
v->udp6zerocsumtx = false;

src/network/netdev/vxlan.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@
33

44
typedef struct VxLan VxLan;
55

6+
#include <linux/if_link.h>
7+
68
#include "in-addr-util.h"
79
#include "netdev/netdev.h"
810

911
#define VXLAN_VID_MAX (1u << 24) - 1
1012
#define VXLAN_FLOW_LABEL_MAX_MASK 0xFFFFFU
1113

14+
typedef enum VxLanDF {
15+
NETDEV_VXLAN_DF_NO = VXLAN_DF_UNSET,
16+
NETDEV_VXLAN_DF_YES = VXLAN_DF_SET,
17+
NETDEV_VXLAN_DF_INHERIT = VXLAN_DF_INHERIT,
18+
_NETDEV_VXLAN_DF_MAX,
19+
_NETDEV_VXLAN_DF_INVALID = -1
20+
} VxLanDF;
21+
1222
struct VxLan {
1323
NetDev meta;
1424

@@ -18,6 +28,8 @@ struct VxLan {
1828
int local_family;
1929
int group_family;
2030

31+
VxLanDF df;
32+
2133
union in_addr_union remote;
2234
union in_addr_union local;
2335
union in_addr_union group;
@@ -50,6 +62,10 @@ struct VxLan {
5062
DEFINE_NETDEV_CAST(VXLAN, VxLan);
5163
extern const NetDevVTable vxlan_vtable;
5264

65+
const char *df_to_string(VxLanDF d) _const_;
66+
VxLanDF df_from_string(const char *d) _pure_;
67+
5368
CONFIG_PARSER_PROTOTYPE(config_parse_vxlan_address);
5469
CONFIG_PARSER_PROTOTYPE(config_parse_port_range);
5570
CONFIG_PARSER_PROTOTYPE(config_parse_flow_label);
71+
CONFIG_PARSER_PROTOTYPE(config_parse_df);

test/fuzz/fuzz-netdev-parser/directives.netdev

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ ReduceARPProxy=
109109
PortRange=
110110
UDPChecksum=
111111
UDP6ZeroCheckSumTx=
112+
IPDoNotFragment=
112113
[VXCAN]
113114
Peer=
114115
[Bond]

0 commit comments

Comments
 (0)