linuxrouting

package
v1.15.4 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 18 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(ip netip.Addr, compat bool) error

Delete removes the ingress and egress rules that control traffic for endpoints. Note that the routes referenced by the rules are not deleted as they can be reused when another endpoint is created on the same node. The compat flag controls which egress priority to consider when deleting the egress rules (see option.Config.EgressMultiHomeIPRuleCompat).

Note that one or more IPs may share the same route table, as identified by the interface number of the corresponding device. This function only removes the ingress and egress rules to disconnect the per-ENI egress routes from a specific local IP, and does not remove the corresponding route table as other IPs may still be using that table.

The search for both the ingress & egress rule corresponding to this IP is a best-effort based on the respective priority that Cilium uses, which we assume full control over. The search for the ingress rule is more likely to succeed (albeit very rarely that egress deletion fails) because we are able to perform a narrower search on the rule because we know it references the main routing table. Due to multiple routing CIDRs, there might be more than one egress rule. Deletion of any rule only proceeds if the rule matches the IP & priority. If more than one rule matches, then deletion is skipped.

func NewMigrator

func NewMigrator(getter interfaceDB) *migrator

NewMigrator constructs a migrator object with the default implementation to use the underlying upstream netlink library to manipulate the Linux RPDB. It accepts a getter for retrieving the interface number by MAC address and vice versa.

Types

type RoutingInfo

type RoutingInfo struct {
	// IPv4Gateway is the gateway where outbound/egress traffic is directed.
	IPv4Gateway net.IP

	// IPv4CIDRs is a list of CIDRs which the interface has access to. In most
	// cases, it'll at least contain the CIDR of the IPv4Gateway IP address.
	IPv4CIDRs []net.IPNet

	// MasterIfMAC is the MAC address of the master interface that egress
	// traffic is directed to. This is the MAC of the interface itself which
	// corresponds to the IPv4Gateway IP addr.
	MasterIfMAC mac.MAC

	// Masquerade represents whether masquerading is enabled or not.
	Masquerade bool

	// InterfaceNumber is the generic number of the master interface that
	// egress traffic is directed to. This is used to compute the table ID for
	// the per-ENI tables.
	InterfaceNumber int

	// IpamMode tells us which IPAM mode is being used (e.g., ENI, AKS).
	IpamMode string
}

RoutingInfo represents information that's required to enable connectivity via the local rule and route tables while in ENI or Azure IPAM mode. The information in this struct is used to create rules and routes which direct traffic out of the interface (egress).

This struct is mostly derived from the `ipam.AllocationResult` as the information comes from IPAM.

func NewRoutingInfo

func NewRoutingInfo(gateway string, cidrs []string, mac, ifaceNum, ipamMode string, masquerade bool) (*RoutingInfo, error)

NewRoutingInfo creates a new RoutingInfo struct, from data that will be parsed and validated. Note, this code assumes IPv4 values because IPv4 (on either ENI or Azure interface) is the only supported path currently. Azure does not support masquerade yet (subnets CIDRs aren't provided): until it does, we forward a masquerade bool to opt out ipam.Cidrs use.

func (*RoutingInfo) Configure

func (info *RoutingInfo) Configure(ip net.IP, mtu int, compat bool, host bool) error

Configure sets up the rules and routes needed when running in ENI or Azure IPAM mode. These rules and routes direct egress traffic out of the interface and ingress traffic back to the endpoint (`ip`). The compat flag controls which egress priority to consider when deleting the egress rules (see option.Config.EgressMultiHomeIPRuleCompat).

ip: The endpoint IP address to direct traffic out / from interface. info: The interface routing info used to create rules and routes. mtu: The interface MTU. compat: Whether to use the compat egress priority or not. host: Whether the IP is a host IP and needs to be routed via the 'local' table

func (*RoutingInfo) GetIPv4CIDRs

func (info *RoutingInfo) GetIPv4CIDRs() []net.IPNet

Jump to

Keyboard shortcuts

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