func NewNetworkConfigController()

in pkg/controllers/netconf/network_config_controller.go [43:72]


func NewNetworkConfigController(enablePolicyRouting, enableSourceValidMark, excludeDNS bool, reconcileInterval time.Duration) *NetworkConfigController {
	var configSet []*config.Set

	configSet = append(configSet, &config.PolicyRoutingConfigSet)

	if enablePolicyRouting {
		config.PolicyRoutingConfigSet.Enabled = true
	}
	if enableSourceValidMark {
		configSet[0].Configs = append(configSet[0].Configs, config.SourceValidMarkConfig)
	}
	if excludeDNS {
		configSet[0].Configs = append(configSet[0].Configs, config.ExcludeDNSIPRuleConfigs...)
	}
	kernelVersion, err := kernel.GetVersion()
	if err != nil {
		glog.Errorf("Could not check kernel version: %v. Skip installing UDP exempt rule.", err)
	} else {
		glog.Infof("Kernel version detected: %v.", kernelVersion)
		if kernelVersion.AtLeast(version.MustParseGeneric(brokenLocalUDPKernelVersionStart)) {
			glog.Infof("Kernel version is impacted by a known issue (start version: %v). Including an IP rule to exempt UDP traffic.", brokenLocalUDPKernelVersionStart)
			configSet[0].Configs = append(configSet[0].Configs, config.ExcludeUDPIPRuleConfig)
		}
	}

	return &NetworkConfigController{
		configSet:         configSet,
		reconcileInterval: reconcileInterval,
	}
}