/
config.go
145 lines (127 loc) · 7.75 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// Copyright (c) 2019 Cisco and/or its affiliates.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package config
import (
nodeconfigcrd "github.com/contiv/vpp/plugins/crd/pkg/apis/nodeconfig/v1"
)
// Config represents configuration for the Contiv agent.
// The path to the configuration file can be specified in two ways:
// - using the `-contiv-config=<path to config>` argument, or
// - using the `CONTIV_CONFIG=<path to config>` environment variable
type Config struct {
InterfaceConfig
RoutingConfig
IPNeighborScanConfig
StealFirstNIC bool `json:"stealFirstNIC,omitempty"`
StealInterface string `json:"stealInterface,omitempty"`
STNSocketFile string `json:"stnSocketFile,omitempty"`
STNVersion uint8 `json:"stnVersion,omitempty"`
NatExternalTraffic bool `json:"natExternalTraffic,omitempty"`
EnablePacketTrace bool `json:"enablePacketTrace,omitempty"`
CRDNodeConfigurationDisabled bool `json:"crdNodeConfigurationDisabled,omitempty"`
IPAMConfig IPAMConfig `json:"ipamConfig"`
NodeConfig []NodeConfig `json:"nodeConfig"`
}
// InterfaceConfig contains configuration related to interfaces.
type InterfaceConfig struct {
MTUSize uint32 `json:"mtuSize,omitempty"`
UseTAPInterfaces bool `json:"useTAPInterfaces,omitempty"`
TAPInterfaceVersion uint8 `json:"tapInterfaceVersion,omitempty"`
TAPv2RxRingSize uint16 `json:"tapv2RxRingSize,omitempty"`
TAPv2TxRingSize uint16 `json:"tapv2TxRingSize,omitempty"`
Vmxnet3RxRingSize uint16 `json:"vmxnet3RxRingSize,omitempty"`
Vmxnet3TxRingSize uint16 `json:"vmxnet3TxRingSize,omitempty"`
InterfaceRxMode string `json:"interfaceRxMode,omitempty"` // "" == "default" / "polling" / "interrupt" / "adaptive"
TCPChecksumOffloadDisabled bool `json:"tcpChecksumOffloadDisabled,omitempty"`
EnableGSO bool `json:"enableGSO,omitempty"`
}
// RoutingConfig groups configuration options related to routing.
type RoutingConfig struct {
// VRF IDs
MainVRFID uint32 `json:"mainVRFID,omitempty"`
PodVRFID uint32 `json:"podVRFID,omitempty"`
// Transportation used for node-to-node communication:
// 1. VXLAN overlay ("vxlan") encapsulates/decapsulates traffic between nodes using VXLAN.
// 2. SRv6 overlay ("srv6") encapsulates/decapsulates traffic between nodes using SRv6
// (segment routing based on IPv6).
// SRv6's steering and policy will be on ingress node and SRv6's localsid on egress node. This transportation
// expects ipv6 to be enabled (SRv6 packets=IPv6 packets using SR header extension).
// 3. Using none of the previous mentioned overlays ("nooverlay") and route traffic using routing
// tables/etc., e.g. if the nodes are on the same L2 network.
NodeToNodeTransport string `json:"nodeToNodeTransport,omitempty"`
// Enabled when routing for K8s service should be performed by using SRv6 (segment routing based on IPv6).
// The routing within the routing segments is done as normal IPv6 routing, therefore IPv6 must be enabled.
// This setting handles how packet is transported from service client to service backend, but not how is
// transported response packet(if any) from backend to service client. This is handled by non-service routing
// that uses on node-to-node part of route the "NodeToNodeTransport" setting. To communicate between nodes
// only using SRv6, set it to "srv6" (+ UseSRv6ForServices=true).
UseSRv6ForServices bool `json:"useSRv6ForServices,omitempty"`
// Enabled when Service Function Chaining for K8s service should be performed by using SRv6 (segment routing
// based on IPv6).
UseSRv6ForServiceFunctionChaining bool `json:"useSRv6ForServiceFunctionChaining,omitempty"`
// Enables usage of DX6 end function instead of DT6 end function for node-to-node communication using SRV6.
// This is limited to pod-to-pod communication use case in full IPv6 environment (pods and node fabric is IPv6)
UseDX6ForSrv6NodetoNodeTransport bool `json:"useDX6ForSrv6NodetoNodeTransport,omitempty"`
// when enabled, cluster IP CIDR should be routed towards VPP from Linux
RouteServiceCIDRToVPP bool `json:"routeServiceCIDRToVPP,omitempty"`
}
// IPNeighborScanConfig contains configuration related to IP neighbour scanning.
type IPNeighborScanConfig struct {
// when enabled, IP neighbors should be periodically scanned and probed
// to maintain the ARP table
ScanIPNeighbors bool `json:"scanIPNeighbors,omitempty"`
IPNeighborScanInterval uint8 `json:"ipNeighborScanInterval,omitempty"`
IPNeighborStaleThreshold uint8 `json:"ipNeighborStaleThreshold,omitempty"`
}
// IPAMConfig groups IPAM configuration options as basic data types and with
// JSON tags, ready to be un-marshalled from the configuration.
// The string fields are then parsed to *net.IPNet and returned as such in IPAMConfig
// structure.
type IPAMConfig struct {
UseExternalIPAM bool `json:"useExternalIPAM,omitempty"`
ContivCIDR string `json:"contivCIDR,omitempty"`
ServiceCIDR string `json:"serviceCIDR,omitempty"`
NodeInterconnectDHCP bool `json:"nodeInterconnectDHCP,omitempty"`
PodSubnetCIDR string `json:"podSubnetCIDR,omitempty"`
PodSubnetOneNodePrefixLen uint8 `json:"podSubnetOneNodePrefixLen,omitempty"`
VPPHostSubnetCIDR string `json:"vppHostSubnetCIDR,omitempty"`
VPPHostSubnetOneNodePrefixLen uint8 `json:"vppHostSubnetOneNodePrefixLen,omitempty"`
NodeInterconnectCIDR string `json:"nodeInterconnectCIDR,omitempty"`
VxlanCIDR string `json:"vxlanCIDR,omitempty"`
DefaultGateway string `json:"defaultGateway,omitempty"`
SRv6 SRv6Config `json:"srv6"`
}
// SRv6Config is part of IPAM configuration that configures SID prefixes of SRv6 components
type SRv6Config struct {
ServicePolicyBSIDSubnetCIDR string `json:"servicePolicyBSIDSubnetCIDR,omitempty"`
ServicePodLocalSIDSubnetCIDR string `json:"servicePodLocalSIDSubnetCIDR,omitempty"`
ServiceHostLocalSIDSubnetCIDR string `json:"serviceHostLocalSIDSubnetCIDR,omitempty"`
ServiceNodeLocalSIDSubnetCIDR string `json:"serviceNodeLocalSIDSubnetCIDR,omitempty"`
NodeToNodePodLocalSIDSubnetCIDR string `json:"nodeToNodePodLocalSIDSubnetCIDR,omitempty"`
NodeToNodeHostLocalSIDSubnetCIDR string `json:"nodeToNodeHostLocalSIDSubnetCIDR,omitempty"`
NodeToNodePodPolicySIDSubnetCIDR string `json:"nodeToNodePodPolicySIDSubnetCIDR,omitempty"`
NodeToNodeHostPolicySIDSubnetCIDR string `json:"nodeToNodeHostPolicySIDSubnetCIDR,omitempty"`
SFCPolicyBSIDSubnetCIDR string `json:"sfcPolicyBSIDSubnetCIDR,omitempty"`
SFCServiceFunctionSIDSubnetCIDR string `json:"sfcServiceFunctionSIDSubnetCIDR,omitempty"`
SFCEndLocalSIDSubnetCIDR string `json:"sfcEndLocalSIDSubnetCIDR,omitempty"`
SFCIDLengthUsedInSidForServiceFunction uint8 `json:"sfcIDLengthUsedInSidForServiceFunction,omitempty"`
}
// NodeConfig represents configuration specific to a given node.
type NodeConfig struct {
// name of the node, should match with the hostname
NodeName string `json:"nodeName"`
// node config specification can be defined either via the configuration file
// or using CRD
nodeconfigcrd.NodeConfigSpec
}