dpcreconciler

package
v0.0.0-...-a6598b8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GraphName : name of the graph with the managed state as a whole.
	GraphName = "DeviceConnectivity"
	// GlobalSG : name of the sub-graph with global configuration.
	GlobalSG = "Global"
	// PhysicalIoSG : name of the sub-graph with physical network interfaces.
	PhysicalIoSG = "PhysicalIO"
	// LogicalIoSG : name of the sub-graph with logical network interfaces.
	LogicalIoSG = "LogicalIO"
	// WirelessSG : sub-graph with everything related to wireless connectivity.
	WirelessSG = "Wireless"
	// L3SG : subgraph with configuration items related to Layer3 of the ISO/OSI model.
	L3SG = "L3"
	// AdaptersSG : sub-graph with everything related to adapters.
	AdaptersSG = "Adapters"
	// AdapterAddrsSG : sub-graph with external items representing addresses assigned to adapters.
	AdapterAddrsSG = "AdapterAddrs"
	// IPRulesSG : sub-graph with IP rules.
	IPRulesSG = "IPRules"
	// RoutesSG : sub-graph with IP routes.
	RoutesSG = "Routes"
	// ArpsSG : sub-graph with ARP entries.
	ArpsSG = "ARPs"
	// ACLsSG : sub-graph with device-wide ACLs.
	ACLsSG = "ACLs"
	// IPv4ACLsSG : sub-graph of ACLsSG with IPv4 rules.
	IPv4ACLsSG = "IPv4Rules"
	// IPv6ACLsSG : sub-graph of ACLsSG with IPv6 rules.
	IPv6ACLsSG = "IPv6Rules"
)

Device connectivity configuration is modeled using dependency graph (see libs/depgraph). Config graph with all sub-graphs and config item types used for Linux network stack:

+----------------------------------------------------------------------------------------+
|                                    DeviceConnectivity                                  |
|                                                                                        |
|   +--------------------------------------+    +------------------------------------+   |
|   |              PhysicalIO              |    |                Global              |   |
|   |                                      |    |                                    |   |
|   | +-----------+    +------------+      |    | +-------------+   +-------------+  |   |
|   | | PhysIf    |    | PhysIf     |      |    | | ResolvConf  |   | LocalIPRule |  |   |
|   | | (external)|    | (external) |  ... |    | | (singleton) |   | (singleton) |  |   |
|   | +-----------+    +------------+      |    | +-------------+   +-------------+  |   |
|   +--------------------------------------+    +------------------------------------+   |
|                                                                                        |
|   +--------------------------------------+    +------------------------------------+   |
|   |              LogicalIO (L2)          |    |               Wireless             |   |
|   |                                      |    |                                    |   |
|   |            +----------+              |    | +-------------+   +-------------+  |   |
|   |            | IOHandle | ...          |    | |    Wwan     |   |    Wlan     |  |   |
|   |            +----------+              |    | | (singleton) |   | (singleton) |  |   |
|   |       +------+      +------+         |    | +-------------+   +-------------+  |   |
|   |       | Vlan | ...  | Bond | ...     |    +------------------------------------+   |
|   |       +------+      +------+         |                                             |
|   +--------------------------------------+                                             |
|                                                                                        |
|  +----------------------------------------------------------------------------------+  |
|  |                                         L3                                       |  |
|  |                                                                                  |  |
|  |                                               +-------------------------------+  |  |
|  |                                               |            IPRules            |  |  |
|  |  +----------------------------------------+   |                               |  |  |
|  |  |               Adapters                 |   | +---------+  +----------+     |  |  |
|  |  |                                        |   | |SrcIPRule|  |SrcIPRule | ... |  |  |
|  |  | +---------+      +---------+           |   | +---------+  +----------+     |  |  |
|  |  | | Adapter |      | Adapter |  ...      |   +-------------------------------+  |  |
|  |  | +---------+      +---------+           |                                      |  |
|  |  | +------------+   +------------+        |   +-------------------------------+  |  |
|  |  | | DhcpClient |   | DhcpClient | ...    |   |            Routes             |  |  |
|  |  | +------------+   +------------+        |   |                               |  |  |
|  |  | +------------------------------------+ |   | +-------+  +-------+          |  |  |
|  |  | |            AdapterAddrs            | |   | | Route |  | Route | ...      |  |  |
|  |  | |                                    | |   | +-------+  +-------+          |  |  |
|  |  | |        +--------------+            | |   +-------------------------------+  |  |
|  |  | |        | AdapterAddrs | ...        | |                                      |  |
|  |  | |        |  (external)  |            | |   +-------------------------------+  |  |
|  |  | |        +--------------+            | |   |             ARPs              |  |  |
|  |  | +------------------------------------+ |   |                               |  |  |
|  |  +----------------------------------------+   | +-----+  +-----+              |  |  |
|  |                                               | | Arp |  | Arp | ...          |  |  |
|  |                                               | +-----+  +-----+              |  |  |
|  |                                               +-------------------------------+  |  |
|  |                                                                                  |  |
|  +----------------------------------------------------------------------------------+  |
|                                                                                        |
|  +----------------------------------------------------------------------------------+  |
|  |                                       ACLs                                       |  |
|  |                                                                                  |  |
|  |                                +---------------+                                 |  |
|  |                                |  SSHAuthKeys  |                                 |  |
|  |                                |  (singleton)  |                                 |  |
|  |                                +---------------+                                 |  |
|  |     +--------------------------------+    +--------------------------------+     |  |
|  |     |           IPv4Rules            |    |           IPv6Rules            |     |  |
|  |     |                                |    |                                |     |  |
|  |     |      +---------------+         |    |      +---------------+         |     |  |
|  |     |      | IptablesChain | ...     |    |      | IptablesChain | ...     |     |  |
|  |     |      +---------------+         |    |      +---------------+         |     |  |
|  |     |      +---------------+         |    |      +---------------+         |     |  |
|  |     |      | IptablesRule  | ...     |    |      | IptablesRule  | ...     |     |  |
|  |     |      +---------------+         |    |      +---------------+         |     |  |
|  |     +--------------------------------+    +--------------------------------+     |  |
|  +----------------------------------------------------------------------------------+  |
+----------------------------------------------------------------------------------------+

Variables

This section is empty.

Functions

This section is empty.

Types

type Args

Args : a high-level device configuration received from the controller, further translated by DpcReconciler into the corresponding low-level network configuration and applied into the target network stack.

type DNSStatus

type DNSStatus struct {
	// Non-nil if reconciler failed to apply DNS configuration.
	Error error
	// Configured DNS servers sorted by physical interface name.
	Servers map[string][]net.IP // interface name -> DNS servers
}

DNSStatus : state information related to domain name system (DNS).

type DpcReconciler

type DpcReconciler interface {
	// Reconcile : call to apply the current DPC into the target network stack.
	// Synchronous configuration operations are run from within the caller's Go routine.
	Reconcile(ctx context.Context, args Args) ReconcileStatus
}

DpcReconciler should translate the currently selected Device port configuration (DevicePortConfig struct; abbreviated to DPC) into the corresponding low-level network configuration of the target network stack and apply it using the Reconciler (see libs/reconciler). It is not required for DpcReconciler to be thread-safe.

type LinuxDpcReconciler

type LinuxDpcReconciler struct {
	sync.Mutex

	// Enable to have the current state exported to /run/nim-current-state.dot
	// on every change.
	ExportCurrentState bool
	// Enable to have the intended state exported to /run/nim-intended-state.dot
	// on every change.
	ExportIntendedState bool

	// Note: the exported attributes below should be injected,
	// but most are optional.
	Log                  *base.LogObject // mandatory
	AgentName            string
	NetworkMonitor       netmonitor.NetworkMonitor // mandatory
	SubControllerCert    pubsub.Subscription
	SubEdgeNodeCert      pubsub.Subscription
	PubCipherBlockStatus pubsub.Publication
	CipherMetrics        *cipher.AgentMetrics
	PubWwanConfig        pubsub.Publication

	HVTypeKube bool
	// contains filtered or unexported fields
}

LinuxDpcReconciler is a DPC-reconciler for Linux network stack, i.e. it configures and uses Linux networking to provide device connectivity.

func (*LinuxDpcReconciler) GetCurrentState

func (r *LinuxDpcReconciler) GetCurrentState() (graph dg.GraphR, release func())

GetCurrentState : get the current state (read-only). Exported only for unit-testing purposes.

func (*LinuxDpcReconciler) GetIntendedState

func (r *LinuxDpcReconciler) GetIntendedState() (graph dg.GraphR, release func())

GetIntendedState : get the intended state (read-only). Exported only for unit-testing purposes.

func (*LinuxDpcReconciler) Reconcile

func (r *LinuxDpcReconciler) Reconcile(ctx context.Context, args Args) ReconcileStatus

Reconcile : call to apply the current DPC into the Linux network stack.

type ReconcileStatus

type ReconcileStatus struct {
	// Error summarizing the outcome of the reconciliation.
	Error error
	// True if any async operations are in progress.
	AsyncInProgress bool
	// ResumeReconcile channel is used by DpcReconciler to signal that reconciliation
	// should be triggered (even if Args has not necessarily changed). This is either
	// because some config operation was running asynchronously and has just finalized
	// (and should be followed up on), or because something changed in the current state
	// that DpcReconciler needs to reflect in the applied config.
	ResumeReconcile <-chan struct{}
	// CancelAsyncOps : send cancel signal to all asynchronously running operations.
	CancelAsyncOps func()
	// WaitForAsyncOps : wait for all asynchronously running operations to complete.
	WaitForAsyncOps func()
	// The set of configuration items currently in a failed state.
	// Includes information about the last (failed) operation.
	FailingItems reconciler.OperationLog
	// Radio silence state information.
	RS types.RadioSilence
	// Status of domain name system (DNS) configuration.
	// Not to be confused with device network status
	// (which DPC reconciler does not work with).
	DNS DNSStatus
}

ReconcileStatus : state data related to config reconciliation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL