Skip to content

Commit cbbb3f0

Browse files
authored
Merge pull request #3874 from stgraber/network
Support disabling IPv6 RA on Incus managed networks
2 parents 616723c + 35a6f37 commit cbbb3f0

6 files changed

Lines changed: 66 additions & 4 deletions

File tree

doc/api-extensions.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3391,3 +3391,8 @@ sustained counterparts and define the rate the device may reach while bursting.
33913391
The new `limits.read.burst.length`, `limits.write.burst.length` and
33923392
`limits.max.burst.length` keys define how long the burst rate may be
33933393
sustained for, defaulting to one second.
3394+
3395+
## `network_ipv6_ra`
3396+
3397+
Adds a new `ipv6.ra` configuration key to both `bridge` and `ovn` networks,
3398+
controlling whether IPv6 router advertisements are sent on the network.

doc/config_options.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3844,6 +3844,14 @@ User keys can be used in search.
38443844

38453845
```
38463846

3847+
```{config:option} ipv6.ra network_bridge-common
3848+
:condition: "IPv6 address"
3849+
:default: "`true`"
3850+
:shortdesc: "Whether to send IPv6 router advertisements"
3851+
:type: "bool"
3852+
3853+
```
3854+
38473855
```{config:option} ipv6.routes network_bridge-common
38483856
:condition: "IPv6 address"
38493857
:default: "-"
@@ -4330,6 +4338,14 @@ User keys can be used in search.
43304338

43314339
```
43324340

4341+
```{config:option} ipv6.ra network_ovn-common
4342+
:condition: "IPv6 address"
4343+
:default: "`true`"
4344+
:shortdesc: "Whether to send IPv6 router advertisements"
4345+
:type: "bool"
4346+
4347+
```
4348+
43334349
```{config:option} network network_ovn-common
43344350
:shortdesc: "Uplink network to use for external network access or `none` to keep isolated"
43354351
:type: "string"

internal/server/metadata/configuration.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4269,6 +4269,15 @@
42694269
"type": "string"
42704270
}
42714271
},
4272+
{
4273+
"ipv6.ra": {
4274+
"condition": "IPv6 address",
4275+
"default": "`true`",
4276+
"longdesc": "",
4277+
"shortdesc": "Whether to send IPv6 router advertisements",
4278+
"type": "bool"
4279+
}
4280+
},
42724281
{
42734282
"ipv6.routes": {
42744283
"condition": "IPv6 address",
@@ -4837,6 +4846,15 @@
48374846
"type": "string"
48384847
}
48394848
},
4849+
{
4850+
"ipv6.ra": {
4851+
"condition": "IPv6 address",
4852+
"default": "`true`",
4853+
"longdesc": "",
4854+
"shortdesc": "Whether to send IPv6 router advertisements",
4855+
"type": "bool"
4856+
}
4857+
},
48404858
{
48414859
"network": {
48424860
"longdesc": "",

internal/server/network/driver_bridge.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,15 @@ func (n *bridge) Validate(config map[string]string, clientType request.ClientTyp
473473
// shortdesc: Comma-separated list of IPv6 ranges to use for DHCP (FIRST-LAST format)
474474
"ipv6.dhcp.ranges": validate.Optional(validate.IsListOf(validate.IsNetworkRangeV6)),
475475

476+
// gendoc:generate(entity=network_bridge, group=common, key=ipv6.ra)
477+
//
478+
// ---
479+
// type: bool
480+
// condition: IPv6 address
481+
// default: `true`
482+
// shortdesc: Whether to send IPv6 router advertisements
483+
"ipv6.ra": validate.Optional(validate.IsBool),
484+
476485
// gendoc:generate(entity=network_bridge, group=common, key=ipv6.routes)
477486
//
478487
// ---
@@ -1624,7 +1633,11 @@ func (n *bridge) setup(oldConfig map[string]string) error {
16241633
}
16251634

16261635
// Update the dnsmasq config.
1627-
dnsmasqCmd = append(dnsmasqCmd, []string{fmt.Sprintf("--listen-address=%s", ipAddress.String()), "--enable-ra"}...)
1636+
dnsmasqCmd = append(dnsmasqCmd, fmt.Sprintf("--listen-address=%s", ipAddress.String()))
1637+
if util.IsTrueOrEmpty(n.config["ipv6.ra"]) {
1638+
dnsmasqCmd = append(dnsmasqCmd, "--enable-ra")
1639+
}
1640+
16281641
if n.DHCPv6Subnet() != nil {
16291642
if n.hasIPv6Firewall() {
16301643
fwOpts.FeaturesV6.ICMPDHCPDNSAccess = true
@@ -1649,10 +1662,10 @@ func (n *bridge) setup(oldConfig map[string]string) error {
16491662
} else {
16501663
dnsmasqCmd = append(dnsmasqCmd, []string{"--dhcp-range", fmt.Sprintf("%s,%s,%d,%s", dhcpalloc.GetIP(subnet, 2), dhcpalloc.GetIP(subnet, -1), subnetSize, expiry)}...)
16511664
}
1652-
} else {
1665+
} else if util.IsTrueOrEmpty(n.config["ipv6.ra"]) {
16531666
dnsmasqCmd = append(dnsmasqCmd, []string{"--dhcp-range", fmt.Sprintf("::,constructor:%s,ra-stateless,ra-names", n.name)}...)
16541667
}
1655-
} else {
1668+
} else if util.IsTrueOrEmpty(n.config["ipv6.ra"]) {
16561669
dnsmasqCmd = append(dnsmasqCmd, []string{"--dhcp-range", fmt.Sprintf("::,constructor:%s,ra-only", n.name)}...)
16571670
}
16581671

internal/server/network/driver_ovn.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,15 @@ func (n *ovn) Validate(config map[string]string, clientType request.ClientType)
616616
// default: `false`
617617
"ipv6.dhcp.stateful": validate.Optional(validate.IsBool),
618618

619+
// gendoc:generate(entity=network_ovn, group=common, key=ipv6.ra)
620+
//
621+
// ---
622+
// type: bool
623+
// condition: IPv6 address
624+
// default: `true`
625+
// shortdesc: Whether to send IPv6 router advertisements
626+
"ipv6.ra": validate.Optional(validate.IsBool),
627+
619628
// gendoc:generate(entity=network_ovn, group=common, key=ipv4.nat)
620629
//
621630
// ---
@@ -3371,7 +3380,7 @@ func (n *ovn) setup(update bool) error {
33713380
}
33723381

33733382
// Set IPv6 router advertisement settings.
3374-
if routerIntPortIPv6Net != nil {
3383+
if routerIntPortIPv6Net != nil && util.IsTrueOrEmpty(n.config["ipv6.ra"]) {
33753384
adressMode := networkOVN.OVNIPv6AddressModeSLAAC
33763385
if dhcpV6Subnet != nil {
33773386
adressMode = networkOVN.OVNIPv6AddressModeDHCPStateless

internal/version/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ var APIExtensions = []string{
568568
"image_locations",
569569
"network_ovn_multicast",
570570
"device_burst_limits",
571+
"network_ipv6_ra",
571572
}
572573

573574
// APIExtensionsCount returns the number of available API extensions.

0 commit comments

Comments
 (0)