Documentation ¶
Index ¶
- Constants
- func RegisterItems(log *base.LogObject, logger *logrus.Logger, ...) error
- type DHCPServer
- type DNSServer
- type Dnsmasq
- type DnsmasqConfigurator
- func (c *DnsmasqConfigurator) Create(ctx context.Context, item dg.Item) error
- func (c *DnsmasqConfigurator) CreateDHCPv4RangeConfig(start, end net.IP) (string, error)
- func (c *DnsmasqConfigurator) CreateDnsmasqConfig(buffer io.Writer, dnsmasq Dnsmasq) error
- func (c *DnsmasqConfigurator) Delete(ctx context.Context, item dg.Item) error
- func (c *DnsmasqConfigurator) Modify(ctx context.Context, oldItem, newItem dg.Item) (err error)
- func (c *DnsmasqConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)
- type HTTPServer
- type HTTPServerConfigurator
- func (c *HTTPServerConfigurator) Create(ctx context.Context, item dg.Item) error
- func (c *HTTPServerConfigurator) Delete(ctx context.Context, item dg.Item) error
- func (c *HTTPServerConfigurator) Modify(ctx context.Context, oldItem, newItem dg.Item) (err error)
- func (c *HTTPServerConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)
- type HostnameToIPs
- type IPRange
- type IPReserve
- type IPReserveConfigurator
- func (c *IPReserveConfigurator) Create(ctx context.Context, item dg.Item) error
- func (c *IPReserveConfigurator) Delete(ctx context.Context, item dg.Item) error
- func (c *IPReserveConfigurator) Modify(ctx context.Context, oldItem, newItem dg.Item) (err error)
- func (c *IPReserveConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)
- type LinuxIPSet
- type MACToIP
- type NetworkIf
- type NetworkIfWithIP
- type Radvd
- type RadvdConfigurator
- func (c *RadvdConfigurator) Create(ctx context.Context, item dg.Item) error
- func (c *RadvdConfigurator) Delete(ctx context.Context, item dg.Item) error
- func (c *RadvdConfigurator) Modify(ctx context.Context, oldItem, newItem dg.Item) (err error)
- func (c *RadvdConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)
- type Uplink
Constants ¶
const ( // IPv4RouteTypename : typename for IPv4 route. // Not implemented in genericitems (implementation specific to network stack). IPv4RouteTypename = "IPv4Route" // IPv6RouteTypename : typename for IPv6 route. // Not implemented in genericitems (implementation specific to network stack). IPv6RouteTypename = "IPv6Route" // UnsupportedRouteTypename : typename which can be used for kinds of routes // not supported/expected by a particular implementation of NIReconciler. UnsupportedRouteTypename = "Unsupported-Route" // IPReserveTypename : typename for reserved IP address (for use with a bridge) IPReserveTypename = "IPReserve" // VIFTypename : typename for VIF. VIFTypename = "VIF" // UplinkTypename : typename for uplink interface. UplinkTypename = "Uplink" // HTTPServerTypename : typename for HTTP server. HTTPServerTypename = "HTTPServer" // DnsmasqTypename : typename for dnsmasq program (DNS and DHCP server). DnsmasqTypename = "Dnsmasq" // RadvdTypename : typename for radvd program (router advertisement daemon). RadvdTypename = "Radvd" // IPSetTypename : typename for Linux IP set (from netfilter). // Implemented in linuxitems. // Type definition is here because it is referenced by dnsmasq // (when used with Linux ipsets). IPSetTypename = "IPSet" )
Variables ¶
This section is empty.
Functions ¶
func RegisterItems ¶
func RegisterItems(log *base.LogObject, logger *logrus.Logger, registry *reconciler.DefaultRegistry) error
RegisterItems : register all configurators implemented by this package.
Types ¶
type DHCPServer ¶
type DHCPServer struct { // Subnet : network address + netmask (IPv4 or IPv6). Subnet *net.IPNet // AllOnesNetmask : if enabled, DHCP server will advertise netmask with all bits // set to one (e.g. /32 for IPv4) instead of using the actual netmask from Subnet. // This together with Classless routes (routing traffic for the actual Subnet) // can be used to force all traffic to go through the configured GatewayIP // (where ACLs could be applied). AllOnesNetmask bool // IPRange : a range of IP addresses to allocate from. // Not applicable for IPv6 (SLAAC is used instead). IPRange IPRange // GatewayIP : address of the default gateway to advertise (DHCP option 3). // Optional argument, leave empty to disable. GatewayIP net.IP // WithDefaultRoute : if enabled, default route is propagated to applications. WithDefaultRoute bool // DomainName : name of the domain assigned to the network. // It is propagated to clients using the DHCP option 15 (24 in DHCPv6). DomainName string // DNSServers : list of IP addresses of DNS servers to announce via DHCP option 6. // dnsmasq itself may or may not be part of this list. If empty, dnsmasq will not // announce itself as a DNS server! DNSServers []net.IP // NTP servers to announce via DHCP option 42 (56 in DHCPv6). NTPServers []net.IP // StaticEntries : list of MAC->(IP,hostname) entries statically configured // for the DHCP server. StaticEntries []MACToIP // PropagateRoutes : IP routes to propagate to applications using the DHCP option 121 // (classless route option). PropagateRoutes []types.IPRoute }
DHCPServer : part of the dnsmasq config specific to DHCP server.
func (DHCPServer) Equal ¶
func (d DHCPServer) Equal(d2 DHCPServer, withStaticEntries bool) bool
Equal compares two DHCPServer instances
type DNSServer ¶
type DNSServer struct { // ListenIP : IP address (assigned to Dnsmasq.ListenIf) on which the DNS server // should listen. ListenIP net.IP // UplinkIf : uplink interface used to contact UpstreamServers. // Optional argument, leave zero value for NI without uplink. UplinkIf NetworkIf // UpstreamServers : list of IP addresses of public DNS servers to forward // requests to (unless there is a static entry). UpstreamServers []net.IP // StaticEntries : list of hostname->IPs entries statically configured // for the DNS server. StaticEntries []HostnameToIPs // LinuxIPSets : netfilter ipsets which dnsmasq will automatically fill with // resolved IPs. // Feature specific to Linux network stack. In zedrouter used for ACLs with hostnames. // For different network stacks we are likely going to need to come up with a different // way of implementing hostname-referencing ACLs. LinuxIPSets []LinuxIPSet }
DNSServer : part of the dnsmasq config specific to DNS server.
type Dnsmasq ¶
type Dnsmasq struct { // ForNI : UUID of the Network Instance for which this Dnsmasq instance is created. // Mostly used just to force re-start of Dnsmasq when one NI is being deleted // and subsequently another is created with the same ListenIf + DNS/DHCP parameters // (ForNI will differ in such case). ForNI uuid.UUID // ListenIf : interface on which dnsmasq should listen. ListenIf NetworkIf // DHCPServer : part of the dnsmasq config specific to DHCP server. DHCPServer DHCPServer // DNSServer : part of the dnsmasq config specific to DNS server. DNSServer DNSServer }
Dnsmasq : DNS and DHCP server (https://thekelleys.org.uk/dnsmasq/doc.html).
func (Dnsmasq) Dependencies ¶
func (d Dnsmasq) Dependencies() (deps []dg.Dependency)
Dependencies returns:
- the (downlink) interface and the IP on which the dnsmasq listens
- the (uplink) interface used by dnsmasq to contact upstream DNS servers (if any)
- every referenced ipset
type DnsmasqConfigurator ¶
DnsmasqConfigurator implements Configurator interface (libs/reconciler) for dnsmasq.
func (*DnsmasqConfigurator) CreateDHCPv4RangeConfig ¶
func (c *DnsmasqConfigurator) CreateDHCPv4RangeConfig(start, end net.IP) (string, error)
CreateDHCPv4RangeConfig prepares a DHCPv4 range config line. The method is exported just to be exercised by unit tests.
func (*DnsmasqConfigurator) CreateDnsmasqConfig ¶
func (c *DnsmasqConfigurator) CreateDnsmasqConfig(buffer io.Writer, dnsmasq Dnsmasq) error
CreateDnsmasqConfig builds configuration for dnsmasq and writes it to the given buffer. The method is exported just to be exercised by unit tests.
func (*DnsmasqConfigurator) Modify ¶
Modify is able to update DHCP/DNS hosts files and apply the changes simply by sending the SIGHUP signal, i.e. without having to restart the dnsmasq process.
func (*DnsmasqConfigurator) NeedsRecreate ¶
func (c *DnsmasqConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)
NeedsRecreate returns false if only DHCP/DNS hosts files have changed.
type HTTPServer ¶
type HTTPServer struct { // ForNI : UUID of the Network Instance for which this HTTP server is created. // Mostly used just to force re-start of the server when one NI is being deleted // and subsequently another is created with the same bridge interface name // and IP address. Since Handler is not comparable, ForNI will do the trick // to make the new HTTP server unequal to the previous one. ForNI uuid.UUID // ListenIP : IP address on which the server should listen. ListenIP net.IP // ListenIf : reference to interface which is expected to have ListenIP assigned. ListenIf NetworkIf // Port : port to listen for HTTP requests. Port uint16 // Handler is used to respond to an HTTP request. Handler http.Handler }
HTTPServer : HTTP server.
func (HTTPServer) Dependencies ¶
func (s HTTPServer) Dependencies() (deps []dg.Dependency)
Dependencies returns the interface on which the HTTP server listens as the only dependency. It is assumed that if the interface is created, it has ListenIP assigned.
func (HTTPServer) Equal ¶
func (s HTTPServer) Equal(other dg.Item) bool
Equal compares two HTTPServer instances However, only HTTP server addresses are compared, skipping Handler attributes This is because:
- not possible to compare (interface)
- HTTPServerConfigurator only cares about starting/stopping the HTTP server and the handlers can freely change without having to restart the server.
func (HTTPServer) Name ¶
func (s HTTPServer) Name() string
Name returns the interface name and port on which the HTTP server listens. This ensures that there cannot be two different HTTP servers that would attempt to listen on the same interface and port at the same time.
type HTTPServerConfigurator ¶
type HTTPServerConfigurator struct { Log *base.LogObject Logger *logrus.Logger // contains filtered or unexported fields }
HTTPServerConfigurator implements Configurator interface (libs/reconciler) for HTTPServer.
func (*HTTPServerConfigurator) Create ¶
Create starts HTTP server. Create executes in the background and is done (from the Reconciler point of view) once net.Listen succeeds - however the same Go routine is used to run the HTTP server (and is stopped only later by Delete()).
func (*HTTPServerConfigurator) NeedsRecreate ¶
func (c *HTTPServerConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)
NeedsRecreate always returns true - Modify is not implemented.
type HostnameToIPs ¶
HostnameToIPs maps hostname to one or more IP addresses.
type IPRange ¶
type IPRange struct { // FromIP : start of the range (includes the address itself). FromIP net.IP // ToIP : end of the range (includes the address itself). ToIP net.IP }
IPRange : a range of IP addresses.
type IPReserve ¶
type IPReserve struct { // AddrWithMask : IP address including mask of the subnet to which it belongs. AddrWithMask *net.IPNet // NetIf : network interface to which the IP address is assigned. NetIf NetworkIf }
IPReserve : an item representing allocation and use of an IP address (for bridge). The purpose of this item is to ensure that the same IP address will not be used by multiple bridges at the same time (incl. inside intermediate reconciliation states). This works by having the bridge depending on the reservation and by requesting re-creation of IPReserve when it changes, thus triggering re-create of bridges and all higher-layers items that depend on it.
func (IPReserve) Dependencies ¶
func (ip IPReserve) Dependencies() (deps []dg.Dependency)
Dependencies returns empty slice.
type IPReserveConfigurator ¶
IPReserveConfigurator implements Configurator interface (libs/reconciler) for IPReserve.
func (*IPReserveConfigurator) Create ¶
Create is NOOP - IPReserve is not an actual config item, it is used only for dependency purposes (to avoid duplicate use of the same IP address).
func (*IPReserveConfigurator) NeedsRecreate ¶
func (c *IPReserveConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)
NeedsRecreate returns true - change in IPReserve.NetIf usage intentionally triggers recreate which cascades to the bridge and other dependent higher-layer items.
type LinuxIPSet ¶
type LinuxIPSet struct { // Domains : list of domains whose resolved IPs will be added to Sets. Domains []string // Sets : ipsets where IPs of Domains will be put into. Sets []string }
LinuxIPSet : see https://www.netfilter.org/projects/ipset/index.html
type MACToIP ¶
type MACToIP struct { MAC net.HardwareAddr IP net.IP Hostname string }
MACToIP maps MAC address to IP address.
type NetworkIf ¶
type NetworkIf struct { // IfName : name of the interface in the network stack. IfName string // ItemRef : reference to config item representing the interface. ItemRef dg.ItemRef }
NetworkIf : network interface used by dnsmasq.
type NetworkIfWithIP ¶
type NetworkIfWithIP interface { // GetAssignedIPs : return IP addresses with subnets currently assigned to the network // interface. GetAssignedIPs() []*net.IPNet }
NetworkIfWithIP should be implemented by the item representing network interface on which dnsmasq is supposed to listen.
type Radvd ¶
type Radvd struct { // ForNI : UUID of the Network Instance for which this radvd instance is created. // Mostly used just to force re-start of radvd when one NI is being deleted // and subsequently another is created for the same bridge interface name // (ForNI will differ in such case). ForNI uuid.UUID // ListenIf : interface on which radvd should listen. ListenIf NetworkIf }
Radvd : router advertisement daemon (https://linux.die.net/man/5/radvd.conf).
func (Radvd) Dependencies ¶
func (r Radvd) Dependencies() (deps []dg.Dependency)
Dependencies returns returns the interface on which radvd listens as the only dependency.
type RadvdConfigurator ¶
RadvdConfigurator implements Configurator interface (libs/reconciler) for radvd.
func (*RadvdConfigurator) NeedsRecreate ¶
func (c *RadvdConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)
NeedsRecreate always returns true - Modify is not implemented.
type Uplink ¶
type Uplink struct { // IfName : name of the interface inside the network stack. IfName string // LogicalLabel used to reference this uplink interface. LogicalLabel string // MasterIfName : name of the master interface under which this Uplink is enslaved. // Only used for uplinks of L2 network instances. MasterIfName string // AdminUp is true if interface is administratively enabled. AdminUp bool // IPAddresses : IP addresses assigned to the uplink interface. IPAddresses []*net.IPNet }
Uplink : uplink interface used by network instance for connectivity to outside networks.
func (Uplink) Dependencies ¶
func (u Uplink) Dependencies() (deps []dg.Dependency)
Dependencies returns nothing (external item).
func (Uplink) External ¶
External returns true - uplinks are physical interfaces, i.e. not created by zedrouter.
func (Uplink) GetAssignedIPs ¶
GetAssignedIPs returns IP addresses assigned to the uplink interface. The function is needed for the definition of dependencies for dnsmasq and HTTP server.