Skip to content

Commit 777650b

Browse files
committed
confd: add tunnel ttl, tos, and pmtu-discovery settings
Adds support for configuring TTL, ToS/DSCP, and Path MTU Discovery on GRE and VXLAN tunnels. TTL defaults to 64 instead of inherit to prevent issues with routing protocols like OSPF that use TTL=1. Refactors tunnel YANG models by merging local-remote into a unified tunnel-common grouping for cleaner organization. Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 0b8e510 commit 777650b

File tree

10 files changed

+169
-13
lines changed

10 files changed

+169
-13
lines changed

doc/tunnels.md

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,60 @@ configuration, see [Routing Configuration](routing.md).
106106
> overhead (typically 24 bytes for IPv4, 44 bytes for IPv6) to avoid
107107
> fragmentation issues.
108108
109+
110+
### Advanced Tunnel Settings
111+
112+
All tunnel types support common parameters for controlling tunnel behavior
113+
and performance.
114+
115+
#### Time To Live (TTL)
116+
117+
The TTL setting controls the Time To Live value for the outer tunnel packets.
118+
By default, tunnels use a fixed TTL of 64, which allows packets to traverse
119+
multiple hops between tunnel endpoints.
120+
121+
```
122+
admin@example:/config/> edit interface gre0
123+
admin@example:/config/interface/gre0/> set gre ttl 255
124+
admin@example:/config/interface/gre0/> leave
125+
```
126+
127+
Valid values are 1-255, or the special value `inherit` which copies the TTL
128+
from the encapsulated packet.
129+
130+
> [!IMPORTANT]
131+
> The `inherit` mode can cause problems with routing protocols like OSPF
132+
> that use TTL=1 for their packets. For tunnels carrying routing protocols,
133+
> always use a fixed TTL value (typically 64 or 255).
134+
135+
#### Type of Service (ToS)
136+
137+
The ToS setting controls QoS marking for tunnel traffic:
138+
139+
```
140+
admin@example:/config/> edit interface gre0
141+
admin@example:/config/interface/gre0/> set gre tos 0x10
142+
admin@example:/config/interface/gre0/> leave
143+
```
144+
145+
Valid values are 0-255 for fixed ToS/DSCP marking, or `inherit` (default)
146+
to copy the ToS value from the encapsulated packet.
147+
148+
#### Path MTU Discovery (GRE only)
149+
150+
The `pmtu-discovery` setting can be used to control the Path MTU Discovery on
151+
GRE tunnels. When enabled (default), the tunnel respects the Don't Fragment
152+
(DF) bit and performs PMTU discovery:
153+
154+
```
155+
admin@example:/config/> edit interface gre0
156+
admin@example:/config/interface/gre0/> set gre pmtudisc false
157+
admin@example:/config/interface/gre0/> leave
158+
```
159+
160+
Disabling PMTU discovery may be necessary in networks with broken ICMP
161+
filtering but can lead to suboptimal performance and fragmentation.
162+
109163
## Virtual eXtensible Local Area Network (VXLAN)
110164

111165
VXLAN is a network virtualization technology that encapsulates Layer 2
@@ -117,6 +171,10 @@ Infix supports both IPv4 and IPv6 for VXLAN tunnel endpoints.
117171

118172
### Basic VXLAN Configuration
119173

174+
> [!TIP]
175+
> If you name your VXLAN interface `vxlanN`, where `N` is a number, the
176+
> CLI infers the interface type automatically.
177+
120178
```
121179
admin@example:/> configure
122180
admin@example:/config/> edit interface vxlan100
@@ -149,6 +207,6 @@ admin@example:/>
149207
The remote-port setting allows interoperability with systems using
150208
non-standard VXLAN ports.
151209

152-
> [!TIP]
153-
> If you name your VXLAN interface `vxlanN`, where `N` is a number, the
154-
> CLI infers the interface type automatically.
210+
> [!NOTE]
211+
> VXLAN tunnels also support the `ttl` and `tos` settings described in
212+
> the [Advanced Tunnel Settings](#advanced-tunnel-settings) section above.

src/confd/src/infix-if-gre.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
int gre_gen(struct lyd_node *dif, struct lyd_node *cif, FILE *ip)
77
{
8-
const char *local, *remote;
8+
const char *local, *remote, *ttl, *tos, *pmtudisc;
99
struct lyd_node *gre;
1010
int ipv6;
1111

@@ -30,6 +30,20 @@ int gre_gen(struct lyd_node *dif, struct lyd_node *cif, FILE *ip)
3030
return -EINVAL;
3131
}
3232

33-
fprintf(ip, " local %s remote %s\n", local, remote);
33+
fprintf(ip, " local %s remote %s", local, remote);
34+
35+
ttl = lydx_get_cattr(gre, "ttl");
36+
if (ttl)
37+
fprintf(ip, " ttl %s", ttl);
38+
39+
tos = lydx_get_cattr(gre, "tos");
40+
if (tos)
41+
fprintf(ip, " tos %s", tos);
42+
43+
pmtudisc = lydx_get_cattr(gre, "pmtu-discovery");
44+
if (pmtudisc && !strcmp(pmtudisc, "false"))
45+
fprintf(ip, " nopmtudisc");
46+
47+
fputc('\n', ip);
3448
return 0;
3549
}

src/confd/src/infix-if-vxlan.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
int vxlan_gen(struct lyd_node *dif, struct lyd_node *cif, FILE *ip)
77
{
88
struct lyd_node *vxlan = NULL;
9+
const char *ttl, *tos;
910

1011
vxlan = lydx_get_descendant(lyd_child(cif), "vxlan", NULL);
1112
if (!vxlan)
@@ -18,6 +19,14 @@ int vxlan_gen(struct lyd_node *dif, struct lyd_node *cif, FILE *ip)
1819
lydx_get_cattr(vxlan, "remote"),
1920
lydx_get_cattr(vxlan, "remote-port"));
2021

22+
ttl = lydx_get_cattr(vxlan, "ttl");
23+
if (ttl)
24+
fprintf(ip, " ttl %s", ttl);
25+
26+
tos = lydx_get_cattr(vxlan, "tos");
27+
if (tos)
28+
fprintf(ip, " tos %s", tos);
29+
2130
link_gen_address(cif, ip);
2231

2332
fputc('\n', ip);

src/confd/yang/confd.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ MODULES=(
3737
3838
3939
40-
"infix-interfaces@2025-06-17.yang -e vlan-filtering"
40+
"infix-interfaces@2025-11-06.yang -e vlan-filtering"
4141
"ietf-crypto-types -e cleartext-symmetric-keys"
4242
4343
"ietf-keystore -e symmetric-keys"

src/confd/yang/confd/infix-if-gre.yang

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ submodule infix-if-gre {
1616
contact "[email protected]";
1717
description "GRE and GRETAP tunnel extension for ietf-interfaces";
1818

19+
revision 2025-11-06 {
20+
description "Use tunnel-common grouping for local, remote, TTL, and TOS/DSCP.
21+
Add GRE-specific pmtu-discovery setting.";
22+
reference "internal";
23+
}
24+
1925
revision 2024-12-20 {
2026
description "Initial revision.";
2127
reference "internal";
@@ -29,7 +35,21 @@ submodule infix-if-gre {
2935

3036
description "Augments the interface model with GRE tunnels.";
3137
container gre {
32-
uses local-remote;
38+
uses tunnel-common;
39+
40+
leaf pmtu-discovery {
41+
type boolean;
42+
default true;
43+
description
44+
"Enable or disable Path MTU Discovery on the tunnel.
45+
46+
When enabled (default), the tunnel respects the Don't Fragment (DF)
47+
bit and performs PMTU discovery. When disabled, the tunnel will
48+
fragment packets as needed.
49+
50+
Disabling PMTU discovery may be necessary in networks with broken
51+
ICMP filtering but can lead to suboptimal performance.";
52+
}
3353
}
3454
}
3555
}

src/confd/yang/confd/infix-if-vxlan.yang

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ submodule infix-if-vxlan {
2020
contact "[email protected]";
2121
description "VXLAN tunnel extension for ietf-interfaces";
2222

23+
revision 2025-11-06 {
24+
description "Use new tunnel-common grouping for local, remote, ttl, and tos.";
25+
reference "internal";
26+
}
27+
2328
revision 2025-01-13 {
2429
description "Initial revision.";
2530
reference "internal";
@@ -36,18 +41,19 @@ submodule infix-if-vxlan {
3641
}
3742
description "Augments the interface model with VXLAN tunnels.";
3843
container vxlan {
39-
uses local-remote;
44+
uses tunnel-common;
45+
4046
leaf remote-port {
4147
type inet-types:port-number;
4248
default 4789;
4349
description
44-
"VXLAN destination UDP port. Valid range: 0..65535. Default is 4789 (IANA-assigned VXLAN UDP port).";
50+
"VXLAN destination UDP port, valid range: 0..65535.";
4551
}
4652
leaf vni {
4753
type vni;
4854
mandatory true;
4955
description
50-
"VXLAN Network Identifier (VNI), valid values are 0 to 16777215.";
56+
"VXLAN Network Identifier (VNI), valid range: 0..16777215.";
5157
}
5258
}
5359
}

src/confd/yang/confd/infix-interfaces.yang

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ module infix-interfaces {
3333
contact "[email protected]";
3434
description "Linux bridge and lag extensions for ietf-interfaces.";
3535

36+
revision 2025-11-06 {
37+
description "Use new tunnel-common grouping for local, remote, ttl, and tos.";
38+
reference "internal";
39+
}
40+
3641
revision 2025-06-17 {
3742
description "Add support for Wi-Fi client.";
3843
reference "internal";
@@ -106,21 +111,65 @@ module infix-interfaces {
106111
reference "internal";
107112
}
108113

109-
grouping local-remote {
110-
description "Local address to use as source address";
114+
grouping tunnel-common {
115+
description "Common tunnel parameters applicable to all tunnel types.";
116+
111117
leaf local {
112118
type inet:ip-address;
113119
mandatory true;
120+
description "Local address to use as source address for the tunnel.";
114121
}
122+
115123
leaf remote {
116-
description "Peer address";
117124
type inet:ip-address;
118125
must "(contains(../local, ':') and contains(., ':'))
119126
or (not(contains(../local, ':')) and not(contains(., ':')))" {
120127
error-message
121128
"Local and remote must be both IPv4 or both IPv6 addresses.";
122129
}
123130
mandatory true;
131+
description "Remote peer address for the tunnel.";
132+
}
133+
134+
leaf ttl {
135+
type union {
136+
type uint8 {
137+
range "1..255";
138+
}
139+
type enumeration {
140+
enum inherit {
141+
description
142+
"Copy TTL from inner packet (default kernel behavior).
143+
WARNING: This can cause issues with protocols like OSPF
144+
that use TTL=1 for their packets.";
145+
}
146+
}
147+
}
148+
default 64;
149+
description
150+
"Time To Live (TTL) for IPv4 or Hop Limit for IPv6 tunnel packets.
151+
A fixed value (1-255) sets the outer packet TTL regardless of inner
152+
packet TTL. The 'inherit' mode copies TTL from the encapsulated packet.
153+
154+
For OSPF and other routing protocols over tunnels, a fixed value
155+
(typically 64 or 255) should be used to ensure packets can traverse
156+
multiple hops between tunnel endpoints.";
157+
}
158+
159+
leaf tos {
160+
type union {
161+
type uint8;
162+
type enumeration {
163+
enum inherit {
164+
description "Copy ToS/DSCP from inner packet.";
165+
}
166+
}
167+
}
168+
default "inherit";
169+
description
170+
"Type of Service (IPv4) or Traffic Class (IPv6) for tunnel packets.
171+
Can be a fixed value (0-255) for QoS marking, or 'inherit' to copy
172+
from the encapsulated packet.";
124173
}
125174
}
126175

0 commit comments

Comments
 (0)