Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions src/middlewared/middlewared/plugins/interface/addresses.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import ipaddress
import os
import socket

from truenas_pynetif.address.address import add_address, remove_address, replace_address
Expand All @@ -11,6 +12,7 @@

from middlewared.plugins.interface.dhcp import dhcp_leases, dhcp_status, dhcp_stop
from middlewared.service import ServiceContext
from middlewared.utils.interface import NETIF_COMPLETE_SENTINEL

from .sync_data import SyncData

Expand Down Expand Up @@ -170,17 +172,6 @@ def configure_addresses_impl(
"tunable.set_sysctl", f"net.ipv6.conf.{name}.autoconf", autoconf
)

# Handle keepalived for VIPs
if vip or alias_vips:
if not ctx.middleware.call_sync("service.started", "keepalived"):
ctx.middleware.call_sync(
"service.control", "START", "keepalived"
).wait_sync(raise_error=True)
else:
ctx.middleware.call_sync(
"service.control", "RELOAD", "keepalived"
).wait_sync(raise_error=True)

# Add addresses in database but not configured
for addr in addrs_database - addrs_configured:
address = addr.address
Expand All @@ -195,6 +186,27 @@ def configure_addresses_impl(
broadcast=addr.broadcast,
)

# Bring interface up
if not (link.flags & IFFlags.UP):
set_link_up(sock, index=link_index)

# Handle keepalived for VIPs. Skip the START during early boot (when called
# from ix-netif.service) because keepalived requires network-online.target
# which cannot be reached until ix-netif.service itself completes — starting
# it here would deadlock for 95s. The sentinel is written by ix-netif.service
# on successful completion, so its presence means the network is up.
if vip or alias_vips:
if ctx.middleware.call_sync("service.started", "keepalived"):
ctx.middleware.call_sync(
"service.control", "RELOAD", "keepalived"
).wait_sync(raise_error=True)
elif os.path.exists(NETIF_COMPLETE_SENTINEL):
ctx.middleware.call_sync(
"service.control", "START", "keepalived"
).wait_sync(raise_error=True)
# else: early boot call from ix-netif.service; keepalived will be
# started later once network-online.target is satisfied.

# Configure MTU (skip for bond members)
skip_mtu = sync_data.is_bond_member(name)
if not skip_mtu:
Expand All @@ -213,9 +225,5 @@ def configure_addresses_impl(
"Failed to set interface description on %s", name, exc_info=True
)

# Bring interface up
if not (link.flags & IFFlags.UP):
set_link_up(sock, index=link_index)

# Return True if DHCP should be started
return not status.running and data["int_dhcp"]
2 changes: 1 addition & 1 deletion src/middlewared/middlewared/plugins/smb.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
from middlewared.service import ConfigService, ValidationError, ValidationErrors
from middlewared.service_exception import CallError, MatchNotFound
from middlewared.plugins.smb_.constants import (
NETIF_COMPLETE_SENTINEL,
CONFIGURED_SENTINEL,
SMB_AUDIT_DEFAULTS,
SMBCmd,
SMBPath,
)
from middlewared.utils.interface import NETIF_COMPLETE_SENTINEL
from middlewared.plugins.smb_.constants import VEEAM_REPO_BLOCKSIZE
from middlewared.plugins.smb_.constants import SMBShareField as share_field
from middlewared.plugins.smb_.sharesec import remove_share_acl
Expand Down
2 changes: 0 additions & 2 deletions src/middlewared/middlewared/plugins/smb_/constants.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import enum
import os
from middlewared.utils import ctdb
from middlewared.utils import MIDDLEWARE_RUN_DIR
from middlewared.utils.directoryservices.krb5_constants import SAMBA_KEYTAB_DIR


NETIF_COMPLETE_SENTINEL = f"{MIDDLEWARE_RUN_DIR}/ix-netif-complete"
CONFIGURED_SENTINEL = '/var/run/samba/.configured'
SMB_AUDIT_DEFAULTS = {'enable': False, 'watch_list': [], 'ignore_list': []}
VEEAM_REPO_BLOCKSIZE = 131072
Expand Down
3 changes: 3 additions & 0 deletions src/middlewared/middlewared/utils/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
import os
import time

from middlewared.utils import MIDDLEWARE_RUN_DIR


IFACE_LINK_STATE_MAX_WAIT: int = 60
NETIF_COMPLETE_SENTINEL = f"{MIDDLEWARE_RUN_DIR}/ix-netif-complete"
RTF_GATEWAY: int = 0x0002
RTF_UP: int = 0x0001

Expand Down
Loading