id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
sequencelengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
sequencelengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
163,600
cilium/cilium
pkg/policy/api/zz_generated.deepcopy.go
DeepCopy
func (in *FQDNSelector) DeepCopy() *FQDNSelector { if in == nil { return nil } out := new(FQDNSelector) in.DeepCopyInto(out) return out }
go
func (in *FQDNSelector) DeepCopy() *FQDNSelector { if in == nil { return nil } out := new(FQDNSelector) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "FQDNSelector", ")", "DeepCopy", "(", ")", "*", "FQDNSelector", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "FQDNSelector", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FQDNSelector.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "FQDNSelector", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/zz_generated.deepcopy.go#L283-L290
163,601
cilium/cilium
pkg/policy/api/zz_generated.deepcopy.go
DeepCopy
func (in FQDNSelectorSlice) DeepCopy() FQDNSelectorSlice { if in == nil { return nil } out := new(FQDNSelectorSlice) in.DeepCopyInto(out) return *out }
go
func (in FQDNSelectorSlice) DeepCopy() FQDNSelectorSlice { if in == nil { return nil } out := new(FQDNSelectorSlice) in.DeepCopyInto(out) return *out }
[ "func", "(", "in", "FQDNSelectorSlice", ")", "DeepCopy", "(", ")", "FQDNSelectorSlice", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "FQDNSelectorSlice", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "*", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FQDNSelectorSlice.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "FQDNSelectorSlice", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/zz_generated.deepcopy.go#L303-L310
163,602
cilium/cilium
pkg/policy/api/zz_generated.deepcopy.go
DeepCopy
func (in *K8sServiceNamespace) DeepCopy() *K8sServiceNamespace { if in == nil { return nil } out := new(K8sServiceNamespace) in.DeepCopyInto(out) return out }
go
func (in *K8sServiceNamespace) DeepCopy() *K8sServiceNamespace { if in == nil { return nil } out := new(K8sServiceNamespace) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "K8sServiceNamespace", ")", "DeepCopy", "(", ")", "*", "K8sServiceNamespace", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "K8sServiceNamespace", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new K8sServiceNamespace.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "K8sServiceNamespace", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/zz_generated.deepcopy.go#L380-L387
163,603
cilium/cilium
pkg/policy/api/zz_generated.deepcopy.go
DeepCopy
func (in *K8sServiceSelectorNamespace) DeepCopy() *K8sServiceSelectorNamespace { if in == nil { return nil } out := new(K8sServiceSelectorNamespace) in.DeepCopyInto(out) return out }
go
func (in *K8sServiceSelectorNamespace) DeepCopy() *K8sServiceSelectorNamespace { if in == nil { return nil } out := new(K8sServiceSelectorNamespace) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "K8sServiceSelectorNamespace", ")", "DeepCopy", "(", ")", "*", "K8sServiceSelectorNamespace", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "K8sServiceSelectorNamespace", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new K8sServiceSelectorNamespace.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "K8sServiceSelectorNamespace", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/zz_generated.deepcopy.go#L397-L404
163,604
cilium/cilium
pkg/policy/api/zz_generated.deepcopy.go
DeepCopy
func (in KafkaRole) DeepCopy() KafkaRole { if in == nil { return nil } out := new(KafkaRole) in.DeepCopyInto(out) return *out }
go
func (in KafkaRole) DeepCopy() KafkaRole { if in == nil { return nil } out := new(KafkaRole) in.DeepCopyInto(out) return *out }
[ "func", "(", "in", "KafkaRole", ")", "DeepCopy", "(", ")", "KafkaRole", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "KafkaRole", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "*", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KafkaRole.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "KafkaRole", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/zz_generated.deepcopy.go#L417-L424
163,605
cilium/cilium
pkg/policy/api/zz_generated.deepcopy.go
DeepCopy
func (in *L7Rules) DeepCopy() *L7Rules { if in == nil { return nil } out := new(L7Rules) in.DeepCopyInto(out) return out }
go
func (in *L7Rules) DeepCopy() *L7Rules { if in == nil { return nil } out := new(L7Rules) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "L7Rules", ")", "DeepCopy", "(", ")", "*", "L7Rules", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "L7Rules", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new L7Rules.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "L7Rules", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/zz_generated.deepcopy.go#L465-L472
163,606
cilium/cilium
pkg/policy/api/zz_generated.deepcopy.go
DeepCopy
func (in *PortProtocol) DeepCopy() *PortProtocol { if in == nil { return nil } out := new(PortProtocol) in.DeepCopyInto(out) return out }
go
func (in *PortProtocol) DeepCopy() *PortProtocol { if in == nil { return nil } out := new(PortProtocol) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "PortProtocol", ")", "DeepCopy", "(", ")", "*", "PortProtocol", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "PortProtocol", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortProtocol.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "PortProtocol", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/zz_generated.deepcopy.go#L481-L488
163,607
cilium/cilium
pkg/policy/api/zz_generated.deepcopy.go
DeepCopy
func (in *PortRule) DeepCopy() *PortRule { if in == nil { return nil } out := new(PortRule) in.DeepCopyInto(out) return out }
go
func (in *PortRule) DeepCopy() *PortRule { if in == nil { return nil } out := new(PortRule) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "PortRule", ")", "DeepCopy", "(", ")", "*", "PortRule", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "PortRule", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortRule.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "PortRule", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/zz_generated.deepcopy.go#L507-L514
163,608
cilium/cilium
pkg/policy/api/zz_generated.deepcopy.go
DeepCopy
func (in *PortRuleDNS) DeepCopy() *PortRuleDNS { if in == nil { return nil } out := new(PortRuleDNS) in.DeepCopyInto(out) return out }
go
func (in *PortRuleDNS) DeepCopy() *PortRuleDNS { if in == nil { return nil } out := new(PortRuleDNS) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "PortRuleDNS", ")", "DeepCopy", "(", ")", "*", "PortRuleDNS", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "PortRuleDNS", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortRuleDNS.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "PortRuleDNS", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/zz_generated.deepcopy.go#L523-L530
163,609
cilium/cilium
pkg/policy/api/zz_generated.deepcopy.go
DeepCopy
func (in *PortRuleHTTP) DeepCopy() *PortRuleHTTP { if in == nil { return nil } out := new(PortRuleHTTP) in.DeepCopyInto(out) return out }
go
func (in *PortRuleHTTP) DeepCopy() *PortRuleHTTP { if in == nil { return nil } out := new(PortRuleHTTP) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "PortRuleHTTP", ")", "DeepCopy", "(", ")", "*", "PortRuleHTTP", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "PortRuleHTTP", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortRuleHTTP.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "PortRuleHTTP", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/zz_generated.deepcopy.go#L544-L551
163,610
cilium/cilium
pkg/policy/api/zz_generated.deepcopy.go
DeepCopy
func (in *PortRuleKafka) DeepCopy() *PortRuleKafka { if in == nil { return nil } out := new(PortRuleKafka) in.DeepCopyInto(out) return out }
go
func (in *PortRuleKafka) DeepCopy() *PortRuleKafka { if in == nil { return nil } out := new(PortRuleKafka) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "PortRuleKafka", ")", "DeepCopy", "(", ")", "*", "PortRuleKafka", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "PortRuleKafka", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortRuleKafka.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "PortRuleKafka", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/zz_generated.deepcopy.go#L570-L577
163,611
cilium/cilium
pkg/policy/api/zz_generated.deepcopy.go
DeepCopy
func (in PortRuleL7) DeepCopy() PortRuleL7 { if in == nil { return nil } out := new(PortRuleL7) in.DeepCopyInto(out) return *out }
go
func (in PortRuleL7) DeepCopy() PortRuleL7 { if in == nil { return nil } out := new(PortRuleL7) in.DeepCopyInto(out) return *out }
[ "func", "(", "in", "PortRuleL7", ")", "DeepCopy", "(", ")", "PortRuleL7", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "PortRuleL7", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "*", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortRuleL7.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "PortRuleL7", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/zz_generated.deepcopy.go#L592-L599
163,612
cilium/cilium
pkg/policy/api/zz_generated.deepcopy.go
DeepCopy
func (in Rules) DeepCopy() Rules { if in == nil { return nil } out := new(Rules) in.DeepCopyInto(out) return *out }
go
func (in Rules) DeepCopy() Rules { if in == nil { return nil } out := new(Rules) in.DeepCopyInto(out) return *out }
[ "func", "(", "in", "Rules", ")", "DeepCopy", "(", ")", "Rules", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "Rules", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "*", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Rules.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "Rules", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/zz_generated.deepcopy.go#L650-L657
163,613
cilium/cilium
pkg/policy/api/zz_generated.deepcopy.go
DeepCopy
func (in *ServiceSelector) DeepCopy() *ServiceSelector { if in == nil { return nil } out := new(ServiceSelector) in.DeepCopyInto(out) return out }
go
func (in *ServiceSelector) DeepCopy() *ServiceSelector { if in == nil { return nil } out := new(ServiceSelector) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "ServiceSelector", ")", "DeepCopy", "(", ")", "*", "ServiceSelector", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "ServiceSelector", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceSelector.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "ServiceSelector", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/zz_generated.deepcopy.go#L708-L715
163,614
cilium/cilium
pkg/policy/api/zz_generated.deepcopy.go
DeepCopy
func (in *ToGroups) DeepCopy() *ToGroups { if in == nil { return nil } out := new(ToGroups) in.DeepCopyInto(out) return out }
go
func (in *ToGroups) DeepCopy() *ToGroups { if in == nil { return nil } out := new(ToGroups) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "ToGroups", ")", "DeepCopy", "(", ")", "*", "ToGroups", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "ToGroups", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ToGroups.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "ToGroups", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/zz_generated.deepcopy.go#L729-L736
163,615
cilium/cilium
pkg/maps/configmap/configmap.go
String
func (f Flags) String() string { var buffer bytes.Buffer for i := uint(0); i < 32; i++ { bitVal := int(f & (1 << i)) if bitVal > 0 { if flag, ok := flagsToString[bitVal]; ok { buffer.WriteString(flag) buffer.WriteString(",") continue } } else if bitVal == 0 { if flag, ok := binMap[i]; ok { buffer.WriteString(flag) buffer.WriteString(",") continue } } buffer.WriteString(fmt.Sprintf("%04x,", 1<<i)) } return buffer.String() }
go
func (f Flags) String() string { var buffer bytes.Buffer for i := uint(0); i < 32; i++ { bitVal := int(f & (1 << i)) if bitVal > 0 { if flag, ok := flagsToString[bitVal]; ok { buffer.WriteString(flag) buffer.WriteString(",") continue } } else if bitVal == 0 { if flag, ok := binMap[i]; ok { buffer.WriteString(flag) buffer.WriteString(",") continue } } buffer.WriteString(fmt.Sprintf("%04x,", 1<<i)) } return buffer.String() }
[ "func", "(", "f", "Flags", ")", "String", "(", ")", "string", "{", "var", "buffer", "bytes", ".", "Buffer", "\n", "for", "i", ":=", "uint", "(", "0", ")", ";", "i", "<", "32", ";", "i", "++", "{", "bitVal", ":=", "int", "(", "f", "&", "(", "1", "<<", "i", ")", ")", "\n", "if", "bitVal", ">", "0", "{", "if", "flag", ",", "ok", ":=", "flagsToString", "[", "bitVal", "]", ";", "ok", "{", "buffer", ".", "WriteString", "(", "flag", ")", "\n", "buffer", ".", "WriteString", "(", "\"", "\"", ")", "\n", "continue", "\n", "}", "\n", "}", "else", "if", "bitVal", "==", "0", "{", "if", "flag", ",", "ok", ":=", "binMap", "[", "i", "]", ";", "ok", "{", "buffer", ".", "WriteString", "(", "flag", ")", "\n", "buffer", ".", "WriteString", "(", "\"", "\"", ")", "\n", "continue", "\n", "}", "\n", "}", "\n", "buffer", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "1", "<<", "i", ")", ")", "\n", "}", "\n\n", "return", "buffer", ".", "String", "(", ")", "\n", "}" ]
// String converts the specified flags into a human-readable form.
[ "String", "converts", "the", "specified", "flags", "into", "a", "human", "-", "readable", "form", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/configmap/configmap.go#L62-L83
163,616
cilium/cilium
pkg/maps/configmap/configmap.go
GetConfig
func GetConfig(e endpoint) *EndpointConfig { value := EndpointConfig{} if !e.GetIngressPolicyEnabledLocked() { value.Flags |= SkipPolicyIngress } if !e.GetEgressPolicyEnabledLocked() { value.Flags |= SkipPolicyEgress } return &value }
go
func GetConfig(e endpoint) *EndpointConfig { value := EndpointConfig{} if !e.GetIngressPolicyEnabledLocked() { value.Flags |= SkipPolicyIngress } if !e.GetEgressPolicyEnabledLocked() { value.Flags |= SkipPolicyEgress } return &value }
[ "func", "GetConfig", "(", "e", "endpoint", ")", "*", "EndpointConfig", "{", "value", ":=", "EndpointConfig", "{", "}", "\n", "if", "!", "e", ".", "GetIngressPolicyEnabledLocked", "(", ")", "{", "value", ".", "Flags", "|=", "SkipPolicyIngress", "\n", "}", "\n", "if", "!", "e", ".", "GetEgressPolicyEnabledLocked", "(", ")", "{", "value", ".", "Flags", "|=", "SkipPolicyEgress", "\n", "}", "\n\n", "return", "&", "value", "\n", "}" ]
// GetConfig creates a EndpointConfig structure using the endpoint's // configuration. The endpoint parameter should have its mutex held.
[ "GetConfig", "creates", "a", "EndpointConfig", "structure", "using", "the", "endpoint", "s", "configuration", ".", "The", "endpoint", "parameter", "should", "have", "its", "mutex", "held", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/configmap/configmap.go#L145-L155
163,617
cilium/cilium
pkg/maps/configmap/configmap.go
Update
func (m *EndpointConfigMap) Update(value *EndpointConfig) error { configKey := &Key{Bits: 0} return m.Map.Update(configKey, value) }
go
func (m *EndpointConfigMap) Update(value *EndpointConfig) error { configKey := &Key{Bits: 0} return m.Map.Update(configKey, value) }
[ "func", "(", "m", "*", "EndpointConfigMap", ")", "Update", "(", "value", "*", "EndpointConfig", ")", "error", "{", "configKey", ":=", "&", "Key", "{", "Bits", ":", "0", "}", "\n", "return", "m", ".", "Map", ".", "Update", "(", "configKey", ",", "value", ")", "\n", "}" ]
// Update pushes the configuration options from the specified endpoint into the // configuration map.
[ "Update", "pushes", "the", "configuration", "options", "from", "the", "specified", "endpoint", "into", "the", "configuration", "map", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/configmap/configmap.go#L159-L162
163,618
cilium/cilium
pkg/maps/configmap/configmap.go
OpenMapWithName
func OpenMapWithName(path string) (*EndpointConfigMap, bool, error) { newMap := bpf.NewMap(path, bpf.BPF_MAP_TYPE_ARRAY, int(unsafe.Sizeof(uint32(0))), int(unsafe.Sizeof(EndpointConfig{})), MaxEntries, 0, 0, func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) { k, v := Key{}, EndpointConfig{} if err := bpf.ConvertKeyValue(key, value, &k, &v); err != nil { return nil, nil, err } return &k, &v, nil }).WithCache() isNewMap, err := newMap.OpenOrCreate() if err != nil { return nil, false, err } m := &EndpointConfigMap{Map: newMap, path: path, Fd: newMap.GetFd()} return m, isNewMap, nil }
go
func OpenMapWithName(path string) (*EndpointConfigMap, bool, error) { newMap := bpf.NewMap(path, bpf.BPF_MAP_TYPE_ARRAY, int(unsafe.Sizeof(uint32(0))), int(unsafe.Sizeof(EndpointConfig{})), MaxEntries, 0, 0, func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) { k, v := Key{}, EndpointConfig{} if err := bpf.ConvertKeyValue(key, value, &k, &v); err != nil { return nil, nil, err } return &k, &v, nil }).WithCache() isNewMap, err := newMap.OpenOrCreate() if err != nil { return nil, false, err } m := &EndpointConfigMap{Map: newMap, path: path, Fd: newMap.GetFd()} return m, isNewMap, nil }
[ "func", "OpenMapWithName", "(", "path", "string", ")", "(", "*", "EndpointConfigMap", ",", "bool", ",", "error", ")", "{", "newMap", ":=", "bpf", ".", "NewMap", "(", "path", ",", "bpf", ".", "BPF_MAP_TYPE_ARRAY", ",", "int", "(", "unsafe", ".", "Sizeof", "(", "uint32", "(", "0", ")", ")", ")", ",", "int", "(", "unsafe", ".", "Sizeof", "(", "EndpointConfig", "{", "}", ")", ")", ",", "MaxEntries", ",", "0", ",", "0", ",", "func", "(", "key", "[", "]", "byte", ",", "value", "[", "]", "byte", ")", "(", "bpf", ".", "MapKey", ",", "bpf", ".", "MapValue", ",", "error", ")", "{", "k", ",", "v", ":=", "Key", "{", "}", ",", "EndpointConfig", "{", "}", "\n\n", "if", "err", ":=", "bpf", ".", "ConvertKeyValue", "(", "key", ",", "value", ",", "&", "k", ",", "&", "v", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "return", "&", "k", ",", "&", "v", ",", "nil", "\n", "}", ")", ".", "WithCache", "(", ")", "\n\n", "isNewMap", ",", "err", ":=", "newMap", ".", "OpenOrCreate", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "false", ",", "err", "\n", "}", "\n\n", "m", ":=", "&", "EndpointConfigMap", "{", "Map", ":", "newMap", ",", "path", ":", "path", ",", "Fd", ":", "newMap", ".", "GetFd", "(", ")", "}", "\n\n", "return", "m", ",", "isNewMap", ",", "nil", "\n", "}" ]
// OpenMapWithName attempts to open or create a BPF config map at the specified // path with the specified name. // On success, it returns a map and whether the map was newly created, or // otherwise an error.
[ "OpenMapWithName", "attempts", "to", "open", "or", "create", "a", "BPF", "config", "map", "at", "the", "specified", "path", "with", "the", "specified", "name", ".", "On", "success", "it", "returns", "a", "map", "and", "whether", "the", "map", "was", "newly", "created", "or", "otherwise", "an", "error", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/configmap/configmap.go#L168-L195
163,619
cilium/cilium
pkg/k8s/error_helpers.go
k8sErrorUpdateCheckUnmuteTime
func k8sErrorUpdateCheckUnmuteTime(errstr string, now time.Time) bool { k8sErrMsgMU.Lock() defer k8sErrMsgMU.Unlock() if unmuteDeadline, ok := k8sErrMsg[errstr]; !ok || now.After(unmuteDeadline) { k8sErrMsg[errstr] = now.Add(k8sErrLogTimeout) return true } return false }
go
func k8sErrorUpdateCheckUnmuteTime(errstr string, now time.Time) bool { k8sErrMsgMU.Lock() defer k8sErrMsgMU.Unlock() if unmuteDeadline, ok := k8sErrMsg[errstr]; !ok || now.After(unmuteDeadline) { k8sErrMsg[errstr] = now.Add(k8sErrLogTimeout) return true } return false }
[ "func", "k8sErrorUpdateCheckUnmuteTime", "(", "errstr", "string", ",", "now", "time", ".", "Time", ")", "bool", "{", "k8sErrMsgMU", ".", "Lock", "(", ")", "\n", "defer", "k8sErrMsgMU", ".", "Unlock", "(", ")", "\n\n", "if", "unmuteDeadline", ",", "ok", ":=", "k8sErrMsg", "[", "errstr", "]", ";", "!", "ok", "||", "now", ".", "After", "(", "unmuteDeadline", ")", "{", "k8sErrMsg", "[", "errstr", "]", "=", "now", ".", "Add", "(", "k8sErrLogTimeout", ")", "\n", "return", "true", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
// k8sErrorUpdateCheckUnmuteTime returns a boolean indicating whether we should // log errmsg or not. It manages once-per-k8sErrLogTimeout entry in k8sErrMsg. // When errmsg is new or more than k8sErrLogTimeout has passed since the last // invocation that returned true, it returns true.
[ "k8sErrorUpdateCheckUnmuteTime", "returns", "a", "boolean", "indicating", "whether", "we", "should", "log", "errmsg", "or", "not", ".", "It", "manages", "once", "-", "per", "-", "k8sErrLogTimeout", "entry", "in", "k8sErrMsg", ".", "When", "errmsg", "is", "new", "or", "more", "than", "k8sErrLogTimeout", "has", "passed", "since", "the", "last", "invocation", "that", "returned", "true", "it", "returns", "true", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/error_helpers.go#L37-L47
163,620
cilium/cilium
pkg/k8s/error_helpers.go
K8sErrorHandler
func K8sErrorHandler(e error) { if e == nil { return } // We rate-limit certain categories of error message. These are matched // below, with a default behaviour to print everything else without // rate-limiting. // Note: We also have side-effects in some of the special cases. now := time.Now() errstr := e.Error() switch { // This can occur when cilium comes up before the k8s API server, and keeps // trying to connect. case strings.Contains(errstr, "connection refused"): if k8sErrorUpdateCheckUnmuteTime(errstr, now) { log.WithError(e).Error("k8sError") } // k8s does not allow us to watch both ThirdPartyResource and // CustomResourceDefinition. This would occur when a user mixes these within // the k8s cluster, and might occur when upgrading from versions of cilium // that used ThirdPartyResource to define CiliumNetworkPolicy. case strings.Contains(errstr, "Failed to list *v2.CiliumNetworkPolicy: the server could not find the requested resource"): if k8sErrorUpdateCheckUnmuteTime(errstr, now) { log.WithError(e).Error("Conflicting TPR and CRD resources") log.Warn("Detected conflicting TPR and CRD, please migrate all ThirdPartyResource to CustomResourceDefinition! More info: https://cilium.link/migrate-tpr") log.Warn("Due to conflicting TPR and CRD rules, CiliumNetworkPolicy enforcement can't be guaranteed!") } // fromCIDR and toCIDR used to expect an "ip" subfield (so, they were a YAML // map with one field) but common usage and expectation would simply list the // CIDR ranges and IPs desired as a YAML list. In these cases we would see // this decode error. We have since changed the definition to be a simple // list of strings. case strings.Contains(errstr, "Unable to decode an event from the watch stream: unable to decode watch event"), strings.Contains(errstr, "Failed to list *v1.CiliumNetworkPolicy: only encoded map or array can be decoded into a struct"), strings.Contains(errstr, "Failed to list *v2.CiliumNetworkPolicy: only encoded map or array can be decoded into a struct"), strings.Contains(errstr, "Failed to list *v2.CiliumNetworkPolicy: v2.CiliumNetworkPolicyList:"): if k8sErrorUpdateCheckUnmuteTime(errstr, now) { log.WithError(e).Error("Unable to decode k8s watch event") } default: log.WithError(e).Error("k8sError") } }
go
func K8sErrorHandler(e error) { if e == nil { return } // We rate-limit certain categories of error message. These are matched // below, with a default behaviour to print everything else without // rate-limiting. // Note: We also have side-effects in some of the special cases. now := time.Now() errstr := e.Error() switch { // This can occur when cilium comes up before the k8s API server, and keeps // trying to connect. case strings.Contains(errstr, "connection refused"): if k8sErrorUpdateCheckUnmuteTime(errstr, now) { log.WithError(e).Error("k8sError") } // k8s does not allow us to watch both ThirdPartyResource and // CustomResourceDefinition. This would occur when a user mixes these within // the k8s cluster, and might occur when upgrading from versions of cilium // that used ThirdPartyResource to define CiliumNetworkPolicy. case strings.Contains(errstr, "Failed to list *v2.CiliumNetworkPolicy: the server could not find the requested resource"): if k8sErrorUpdateCheckUnmuteTime(errstr, now) { log.WithError(e).Error("Conflicting TPR and CRD resources") log.Warn("Detected conflicting TPR and CRD, please migrate all ThirdPartyResource to CustomResourceDefinition! More info: https://cilium.link/migrate-tpr") log.Warn("Due to conflicting TPR and CRD rules, CiliumNetworkPolicy enforcement can't be guaranteed!") } // fromCIDR and toCIDR used to expect an "ip" subfield (so, they were a YAML // map with one field) but common usage and expectation would simply list the // CIDR ranges and IPs desired as a YAML list. In these cases we would see // this decode error. We have since changed the definition to be a simple // list of strings. case strings.Contains(errstr, "Unable to decode an event from the watch stream: unable to decode watch event"), strings.Contains(errstr, "Failed to list *v1.CiliumNetworkPolicy: only encoded map or array can be decoded into a struct"), strings.Contains(errstr, "Failed to list *v2.CiliumNetworkPolicy: only encoded map or array can be decoded into a struct"), strings.Contains(errstr, "Failed to list *v2.CiliumNetworkPolicy: v2.CiliumNetworkPolicyList:"): if k8sErrorUpdateCheckUnmuteTime(errstr, now) { log.WithError(e).Error("Unable to decode k8s watch event") } default: log.WithError(e).Error("k8sError") } }
[ "func", "K8sErrorHandler", "(", "e", "error", ")", "{", "if", "e", "==", "nil", "{", "return", "\n", "}", "\n\n", "// We rate-limit certain categories of error message. These are matched", "// below, with a default behaviour to print everything else without", "// rate-limiting.", "// Note: We also have side-effects in some of the special cases.", "now", ":=", "time", ".", "Now", "(", ")", "\n", "errstr", ":=", "e", ".", "Error", "(", ")", "\n", "switch", "{", "// This can occur when cilium comes up before the k8s API server, and keeps", "// trying to connect.", "case", "strings", ".", "Contains", "(", "errstr", ",", "\"", "\"", ")", ":", "if", "k8sErrorUpdateCheckUnmuteTime", "(", "errstr", ",", "now", ")", "{", "log", ".", "WithError", "(", "e", ")", ".", "Error", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// k8s does not allow us to watch both ThirdPartyResource and", "// CustomResourceDefinition. This would occur when a user mixes these within", "// the k8s cluster, and might occur when upgrading from versions of cilium", "// that used ThirdPartyResource to define CiliumNetworkPolicy.", "case", "strings", ".", "Contains", "(", "errstr", ",", "\"", "\"", ")", ":", "if", "k8sErrorUpdateCheckUnmuteTime", "(", "errstr", ",", "now", ")", "{", "log", ".", "WithError", "(", "e", ")", ".", "Error", "(", "\"", "\"", ")", "\n", "log", ".", "Warn", "(", "\"", "\"", ")", "\n", "log", ".", "Warn", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// fromCIDR and toCIDR used to expect an \"ip\" subfield (so, they were a YAML", "// map with one field) but common usage and expectation would simply list the", "// CIDR ranges and IPs desired as a YAML list. In these cases we would see", "// this decode error. We have since changed the definition to be a simple", "// list of strings.", "case", "strings", ".", "Contains", "(", "errstr", ",", "\"", "\"", ")", ",", "strings", ".", "Contains", "(", "errstr", ",", "\"", "\"", ")", ",", "strings", ".", "Contains", "(", "errstr", ",", "\"", "\"", ")", ",", "strings", ".", "Contains", "(", "errstr", ",", "\"", "\"", ")", ":", "if", "k8sErrorUpdateCheckUnmuteTime", "(", "errstr", ",", "now", ")", "{", "log", ".", "WithError", "(", "e", ")", ".", "Error", "(", "\"", "\"", ")", "\n", "}", "\n\n", "default", ":", "log", ".", "WithError", "(", "e", ")", ".", "Error", "(", "\"", "\"", ")", "\n", "}", "\n", "}" ]
// K8sErrorHandler handles the error messages in a non verbose way by omitting // repeated instances of the same error message for a timeout defined with // k8sErrLogTimeout.
[ "K8sErrorHandler", "handles", "the", "error", "messages", "in", "a", "non", "verbose", "way", "by", "omitting", "repeated", "instances", "of", "the", "same", "error", "message", "for", "a", "timeout", "defined", "with", "k8sErrLogTimeout", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/error_helpers.go#L52-L98
163,621
cilium/cilium
pkg/fqdn/rulegen.go
NewRuleGen
func NewRuleGen(config Config) *RuleGen { if config.Cache == nil { config.Cache = NewDNSCache(0) } if config.AddGeneratedRules == nil { config.AddGeneratedRules = func(generatedRules []*api.Rule) error { return nil } } return &RuleGen{ config: config, namesToPoll: make(map[string]struct{}), sourceRules: regexpmap.NewRegexpMap(), allRules: make(map[string]*api.Rule), cache: config.Cache, } }
go
func NewRuleGen(config Config) *RuleGen { if config.Cache == nil { config.Cache = NewDNSCache(0) } if config.AddGeneratedRules == nil { config.AddGeneratedRules = func(generatedRules []*api.Rule) error { return nil } } return &RuleGen{ config: config, namesToPoll: make(map[string]struct{}), sourceRules: regexpmap.NewRegexpMap(), allRules: make(map[string]*api.Rule), cache: config.Cache, } }
[ "func", "NewRuleGen", "(", "config", "Config", ")", "*", "RuleGen", "{", "if", "config", ".", "Cache", "==", "nil", "{", "config", ".", "Cache", "=", "NewDNSCache", "(", "0", ")", "\n", "}", "\n\n", "if", "config", ".", "AddGeneratedRules", "==", "nil", "{", "config", ".", "AddGeneratedRules", "=", "func", "(", "generatedRules", "[", "]", "*", "api", ".", "Rule", ")", "error", "{", "return", "nil", "}", "\n", "}", "\n\n", "return", "&", "RuleGen", "{", "config", ":", "config", ",", "namesToPoll", ":", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ")", ",", "sourceRules", ":", "regexpmap", ".", "NewRegexpMap", "(", ")", ",", "allRules", ":", "make", "(", "map", "[", "string", "]", "*", "api", ".", "Rule", ")", ",", "cache", ":", "config", ".", "Cache", ",", "}", "\n\n", "}" ]
// NewRuleGen creates an initialized RuleGen. // When config.Cache is nil, the global fqdn.DefaultDNSCache is used.
[ "NewRuleGen", "creates", "an", "initialized", "RuleGen", ".", "When", "config", ".", "Cache", "is", "nil", "the", "global", "fqdn", ".", "DefaultDNSCache", "is", "used", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/rulegen.go#L86-L104
163,622
cilium/cilium
pkg/fqdn/rulegen.go
StartManageDNSName
func (gen *RuleGen) StartManageDNSName(sourceRules []*api.Rule) error { gen.Lock() defer gen.Unlock() perRule: for _, sourceRule := range sourceRules { // Note: we rely on MarkToFQDNRules to insert this label. if !sourceRule.Labels.Has(uuidLabelSearchKey) { continue perRule } // Make a copy to avoid breaking the input rules. Strip ToCIDRSet to avoid // re-including IPs we optimistically inserted in MarkToFQDNRules sourceRuleCopy := sourceRule.DeepCopy() stripToCIDRSet(sourceRuleCopy) uuid := getRuleUUIDLabel(sourceRuleCopy) newDNSNames, alreadyExistsDNSNames, err := gen.addRule(uuid, sourceRuleCopy) if err != nil { return err } // only debug print for new names since this function is called // unconditionally, even when we insert generated rules (which aren't new) if len(newDNSNames) > 0 { log.WithFields(logrus.Fields{ "newDNSNames": newDNSNames, "alreadyExistsDNSNames": alreadyExistsDNSNames, "numRules": len(sourceRules), }).Debug("Added FQDN to managed list") } } return nil }
go
func (gen *RuleGen) StartManageDNSName(sourceRules []*api.Rule) error { gen.Lock() defer gen.Unlock() perRule: for _, sourceRule := range sourceRules { // Note: we rely on MarkToFQDNRules to insert this label. if !sourceRule.Labels.Has(uuidLabelSearchKey) { continue perRule } // Make a copy to avoid breaking the input rules. Strip ToCIDRSet to avoid // re-including IPs we optimistically inserted in MarkToFQDNRules sourceRuleCopy := sourceRule.DeepCopy() stripToCIDRSet(sourceRuleCopy) uuid := getRuleUUIDLabel(sourceRuleCopy) newDNSNames, alreadyExistsDNSNames, err := gen.addRule(uuid, sourceRuleCopy) if err != nil { return err } // only debug print for new names since this function is called // unconditionally, even when we insert generated rules (which aren't new) if len(newDNSNames) > 0 { log.WithFields(logrus.Fields{ "newDNSNames": newDNSNames, "alreadyExistsDNSNames": alreadyExistsDNSNames, "numRules": len(sourceRules), }).Debug("Added FQDN to managed list") } } return nil }
[ "func", "(", "gen", "*", "RuleGen", ")", "StartManageDNSName", "(", "sourceRules", "[", "]", "*", "api", ".", "Rule", ")", "error", "{", "gen", ".", "Lock", "(", ")", "\n", "defer", "gen", ".", "Unlock", "(", ")", "\n\n", "perRule", ":", "for", "_", ",", "sourceRule", ":=", "range", "sourceRules", "{", "// Note: we rely on MarkToFQDNRules to insert this label.", "if", "!", "sourceRule", ".", "Labels", ".", "Has", "(", "uuidLabelSearchKey", ")", "{", "continue", "perRule", "\n", "}", "\n\n", "// Make a copy to avoid breaking the input rules. Strip ToCIDRSet to avoid", "// re-including IPs we optimistically inserted in MarkToFQDNRules", "sourceRuleCopy", ":=", "sourceRule", ".", "DeepCopy", "(", ")", "\n", "stripToCIDRSet", "(", "sourceRuleCopy", ")", "\n\n", "uuid", ":=", "getRuleUUIDLabel", "(", "sourceRuleCopy", ")", "\n", "newDNSNames", ",", "alreadyExistsDNSNames", ",", "err", ":=", "gen", ".", "addRule", "(", "uuid", ",", "sourceRuleCopy", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// only debug print for new names since this function is called", "// unconditionally, even when we insert generated rules (which aren't new)", "if", "len", "(", "newDNSNames", ")", ">", "0", "{", "log", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "\"", "\"", ":", "newDNSNames", ",", "\"", "\"", ":", "alreadyExistsDNSNames", ",", "\"", "\"", ":", "len", "(", "sourceRules", ")", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// StartManageDNSName begins managing sourceRules that contain toFQDNs // sections. When the DNS data of the included matchNames changes, RuleGen will // emit a replacement rule that contains the IPs for each matchName. // It only adds rules with the ToFQDN-UUID label, added by MarkToFQDNRules, and // repeat inserts are effectively no-ops.
[ "StartManageDNSName", "begins", "managing", "sourceRules", "that", "contain", "toFQDNs", "sections", ".", "When", "the", "DNS", "data", "of", "the", "included", "matchNames", "changes", "RuleGen", "will", "emit", "a", "replacement", "rule", "that", "contains", "the", "IPs", "for", "each", "matchName", ".", "It", "only", "adds", "rules", "with", "the", "ToFQDN", "-", "UUID", "label", "added", "by", "MarkToFQDNRules", "and", "repeat", "inserts", "are", "effectively", "no", "-", "ops", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/rulegen.go#L182-L216
163,623
cilium/cilium
pkg/fqdn/rulegen.go
GetDNSNames
func (gen *RuleGen) GetDNSNames() (dnsNames []string) { gen.Lock() defer gen.Unlock() for name := range gen.namesToPoll { dnsNames = append(dnsNames, name) } return dnsNames }
go
func (gen *RuleGen) GetDNSNames() (dnsNames []string) { gen.Lock() defer gen.Unlock() for name := range gen.namesToPoll { dnsNames = append(dnsNames, name) } return dnsNames }
[ "func", "(", "gen", "*", "RuleGen", ")", "GetDNSNames", "(", ")", "(", "dnsNames", "[", "]", "string", ")", "{", "gen", ".", "Lock", "(", ")", "\n", "defer", "gen", ".", "Unlock", "(", ")", "\n\n", "for", "name", ":=", "range", "gen", ".", "namesToPoll", "{", "dnsNames", "=", "append", "(", "dnsNames", ",", "name", ")", "\n", "}", "\n\n", "return", "dnsNames", "\n", "}" ]
// GetDNSNames returns a snapshot of the DNS names managed by this RuleGen
[ "GetDNSNames", "returns", "a", "snapshot", "of", "the", "DNS", "names", "managed", "by", "this", "RuleGen" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/rulegen.go#L246-L255
163,624
cilium/cilium
pkg/fqdn/rulegen.go
UpdateGenerateDNS
func (gen *RuleGen) UpdateGenerateDNS(lookupTime time.Time, updatedDNSIPs map[string]*DNSIPRecords) error { // Update IPs in gen uuidsToUpdate, updatedDNSNames := gen.UpdateDNSIPs(lookupTime, updatedDNSIPs) for dnsName, IPs := range updatedDNSNames { log.WithFields(logrus.Fields{ "matchName": dnsName, "IPs": IPs, "uuidsToUpdate": uuidsToUpdate, }).Debug("Updated FQDN with new IPs") } // Generate a new rule for each sourceRule that needs an update. rulesToUpdate, notFoundUUIDs := gen.GetRulesByUUID(uuidsToUpdate) if len(notFoundUUIDs) != 0 { log.WithField("uuid", strings.Join(notFoundUUIDs, ",")). Debug("Did not find all rules during update") } generatedRules, namesMissingIPs := gen.GenerateRulesFromSources(rulesToUpdate) if len(namesMissingIPs) != 0 { log.WithField(logfields.DNSName, strings.Join(namesMissingIPs, ",")). Debug("No IPs to insert when generating DNS name selected by ToFQDN rule") } // no new rules to add, do not call AddGeneratedRules below if len(generatedRules) == 0 { return nil } // emit the new rules return gen.config.AddGeneratedRules(generatedRules) }
go
func (gen *RuleGen) UpdateGenerateDNS(lookupTime time.Time, updatedDNSIPs map[string]*DNSIPRecords) error { // Update IPs in gen uuidsToUpdate, updatedDNSNames := gen.UpdateDNSIPs(lookupTime, updatedDNSIPs) for dnsName, IPs := range updatedDNSNames { log.WithFields(logrus.Fields{ "matchName": dnsName, "IPs": IPs, "uuidsToUpdate": uuidsToUpdate, }).Debug("Updated FQDN with new IPs") } // Generate a new rule for each sourceRule that needs an update. rulesToUpdate, notFoundUUIDs := gen.GetRulesByUUID(uuidsToUpdate) if len(notFoundUUIDs) != 0 { log.WithField("uuid", strings.Join(notFoundUUIDs, ",")). Debug("Did not find all rules during update") } generatedRules, namesMissingIPs := gen.GenerateRulesFromSources(rulesToUpdate) if len(namesMissingIPs) != 0 { log.WithField(logfields.DNSName, strings.Join(namesMissingIPs, ",")). Debug("No IPs to insert when generating DNS name selected by ToFQDN rule") } // no new rules to add, do not call AddGeneratedRules below if len(generatedRules) == 0 { return nil } // emit the new rules return gen.config.AddGeneratedRules(generatedRules) }
[ "func", "(", "gen", "*", "RuleGen", ")", "UpdateGenerateDNS", "(", "lookupTime", "time", ".", "Time", ",", "updatedDNSIPs", "map", "[", "string", "]", "*", "DNSIPRecords", ")", "error", "{", "// Update IPs in gen", "uuidsToUpdate", ",", "updatedDNSNames", ":=", "gen", ".", "UpdateDNSIPs", "(", "lookupTime", ",", "updatedDNSIPs", ")", "\n", "for", "dnsName", ",", "IPs", ":=", "range", "updatedDNSNames", "{", "log", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "\"", "\"", ":", "dnsName", ",", "\"", "\"", ":", "IPs", ",", "\"", "\"", ":", "uuidsToUpdate", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Generate a new rule for each sourceRule that needs an update.", "rulesToUpdate", ",", "notFoundUUIDs", ":=", "gen", ".", "GetRulesByUUID", "(", "uuidsToUpdate", ")", "\n", "if", "len", "(", "notFoundUUIDs", ")", "!=", "0", "{", "log", ".", "WithField", "(", "\"", "\"", ",", "strings", ".", "Join", "(", "notFoundUUIDs", ",", "\"", "\"", ")", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "}", "\n", "generatedRules", ",", "namesMissingIPs", ":=", "gen", ".", "GenerateRulesFromSources", "(", "rulesToUpdate", ")", "\n", "if", "len", "(", "namesMissingIPs", ")", "!=", "0", "{", "log", ".", "WithField", "(", "logfields", ".", "DNSName", ",", "strings", ".", "Join", "(", "namesMissingIPs", ",", "\"", "\"", ")", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// no new rules to add, do not call AddGeneratedRules below", "if", "len", "(", "generatedRules", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "// emit the new rules", "return", "gen", ".", "config", ".", "AddGeneratedRules", "(", "generatedRules", ")", "\n", "}" ]
// UpdateGenerateDNS inserts the new DNS information into the cache. If the IPs // have changed for a name, store which rules must be updated in rulesToUpdate, // regenerate them, and emit via AddGeneratedRules.
[ "UpdateGenerateDNS", "inserts", "the", "new", "DNS", "information", "into", "the", "cache", ".", "If", "the", "IPs", "have", "changed", "for", "a", "name", "store", "which", "rules", "must", "be", "updated", "in", "rulesToUpdate", "regenerate", "them", "and", "emit", "via", "AddGeneratedRules", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/rulegen.go#L260-L290
163,625
cilium/cilium
pkg/fqdn/rulegen.go
ForceGenerateDNS
func (gen *RuleGen) ForceGenerateDNS(namesToRegen []string) error { affectedRulesSet := make(map[string]struct{}, 0) for _, dnsName := range namesToRegen { for _, uuid := range gen.sourceRules.LookupValues(dnsName) { affectedRulesSet[uuid] = struct{}{} } } // Convert the set to a list var uuidsToUpdate []string for uuid := range affectedRulesSet { uuidsToUpdate = append(uuidsToUpdate, uuid) } // Generate a new rule for each sourceRule that needs an update. rulesToUpdate, notFoundUUIDs := gen.GetRulesByUUID(uuidsToUpdate) if len(notFoundUUIDs) != 0 { log.WithField("uuid", strings.Join(notFoundUUIDs, ",")). Debug("Did not find all rules during update") } generatedRules, namesMissingIPs := gen.GenerateRulesFromSources(rulesToUpdate) if len(namesMissingIPs) != 0 { log.WithField(logfields.DNSName, strings.Join(namesMissingIPs, ",")). Debug("No IPs to insert when generating DNS name selected by ToFQDN rule") } // no new rules to add, do not call AddGeneratedRules below if len(generatedRules) == 0 { return nil } // emit the new rules return gen.config.AddGeneratedRules(generatedRules) }
go
func (gen *RuleGen) ForceGenerateDNS(namesToRegen []string) error { affectedRulesSet := make(map[string]struct{}, 0) for _, dnsName := range namesToRegen { for _, uuid := range gen.sourceRules.LookupValues(dnsName) { affectedRulesSet[uuid] = struct{}{} } } // Convert the set to a list var uuidsToUpdate []string for uuid := range affectedRulesSet { uuidsToUpdate = append(uuidsToUpdate, uuid) } // Generate a new rule for each sourceRule that needs an update. rulesToUpdate, notFoundUUIDs := gen.GetRulesByUUID(uuidsToUpdate) if len(notFoundUUIDs) != 0 { log.WithField("uuid", strings.Join(notFoundUUIDs, ",")). Debug("Did not find all rules during update") } generatedRules, namesMissingIPs := gen.GenerateRulesFromSources(rulesToUpdate) if len(namesMissingIPs) != 0 { log.WithField(logfields.DNSName, strings.Join(namesMissingIPs, ",")). Debug("No IPs to insert when generating DNS name selected by ToFQDN rule") } // no new rules to add, do not call AddGeneratedRules below if len(generatedRules) == 0 { return nil } // emit the new rules return gen.config.AddGeneratedRules(generatedRules) }
[ "func", "(", "gen", "*", "RuleGen", ")", "ForceGenerateDNS", "(", "namesToRegen", "[", "]", "string", ")", "error", "{", "affectedRulesSet", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ",", "0", ")", "\n", "for", "_", ",", "dnsName", ":=", "range", "namesToRegen", "{", "for", "_", ",", "uuid", ":=", "range", "gen", ".", "sourceRules", ".", "LookupValues", "(", "dnsName", ")", "{", "affectedRulesSet", "[", "uuid", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "}", "\n\n", "// Convert the set to a list", "var", "uuidsToUpdate", "[", "]", "string", "\n", "for", "uuid", ":=", "range", "affectedRulesSet", "{", "uuidsToUpdate", "=", "append", "(", "uuidsToUpdate", ",", "uuid", ")", "\n", "}", "\n\n", "// Generate a new rule for each sourceRule that needs an update.", "rulesToUpdate", ",", "notFoundUUIDs", ":=", "gen", ".", "GetRulesByUUID", "(", "uuidsToUpdate", ")", "\n", "if", "len", "(", "notFoundUUIDs", ")", "!=", "0", "{", "log", ".", "WithField", "(", "\"", "\"", ",", "strings", ".", "Join", "(", "notFoundUUIDs", ",", "\"", "\"", ")", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "}", "\n", "generatedRules", ",", "namesMissingIPs", ":=", "gen", ".", "GenerateRulesFromSources", "(", "rulesToUpdate", ")", "\n", "if", "len", "(", "namesMissingIPs", ")", "!=", "0", "{", "log", ".", "WithField", "(", "logfields", ".", "DNSName", ",", "strings", ".", "Join", "(", "namesMissingIPs", ",", "\"", "\"", ")", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// no new rules to add, do not call AddGeneratedRules below", "if", "len", "(", "generatedRules", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "// emit the new rules", "return", "gen", ".", "config", ".", "AddGeneratedRules", "(", "generatedRules", ")", "\n", "}" ]
// ForceGenerateDNS unconditionally regenerates all rules that refer to DNS // names in namesToRegen. These names are FQDNs and toFQDNs.matchPatterns or // matchNames that match them will cause these rules to regenerate.
[ "ForceGenerateDNS", "unconditionally", "regenerates", "all", "rules", "that", "refer", "to", "DNS", "names", "in", "namesToRegen", ".", "These", "names", "are", "FQDNs", "and", "toFQDNs", ".", "matchPatterns", "or", "matchNames", "that", "match", "them", "will", "cause", "these", "rules", "to", "regenerate", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/rulegen.go#L295-L328
163,626
cilium/cilium
pkg/fqdn/rulegen.go
addRule
func (gen *RuleGen) addRule(uuid string, sourceRule *api.Rule) (newDNSNames, oldDNSNames []string, err error) { // if we are updating a rule, track which old dnsNames are removed. We store // possible names to stop managing in namesToStopManaging. As we add names // from the new rule below, these are cleared. namesToStopManaging := make(map[string]struct{}) if oldRule, exists := gen.allRules[uuid]; exists { for _, egressRule := range oldRule.Egress { for _, ToFQDN := range egressRule.ToFQDNs { if len(ToFQDN.MatchName) > 0 { dnsName := prepareMatchName(ToFQDN.MatchName) dnsNameAsRE := matchpattern.ToRegexp(dnsName) namesToStopManaging[dnsNameAsRE] = struct{}{} } if len(ToFQDN.MatchPattern) > 0 { dnsPattern := matchpattern.Sanitize(ToFQDN.MatchPattern) dnsPatternAsRE := matchpattern.ToRegexp(dnsPattern) namesToStopManaging[dnsPatternAsRE] = struct{}{} } } } } // Always add to allRules gen.allRules[uuid] = sourceRule // Add a dnsname -> rule reference. We track old/new names by the literal // value in matchName/Pattern. They are inserted into the sourceRules // RegexpMap as regexeps, however, so we can match against them later. for _, egressRule := range sourceRule.Egress { for _, ToFQDN := range egressRule.ToFQDNs { REsToAddForUUID := map[string]string{} if len(ToFQDN.MatchName) > 0 { dnsName := prepareMatchName(ToFQDN.MatchName) dnsNameAsRE := matchpattern.ToRegexp(dnsName) REsToAddForUUID[ToFQDN.MatchName] = dnsNameAsRE gen.namesToPoll[dnsName] = struct{}{} } if len(ToFQDN.MatchPattern) > 0 { dnsPattern := matchpattern.Sanitize(ToFQDN.MatchPattern) dnsPatternAsRE := matchpattern.ToRegexp(dnsPattern) REsToAddForUUID[ToFQDN.MatchPattern] = dnsPatternAsRE } for policyMatchStr, dnsPatternAsRE := range REsToAddForUUID { delete(namesToStopManaging, dnsPatternAsRE) // keep managing this matchName/Pattern // check if this is already managed or not if exists := gen.sourceRules.LookupContainsValue(dnsPatternAsRE, uuid); exists { oldDNSNames = append(oldDNSNames, policyMatchStr) } else { // This ToFQDNs.MatchName/Pattern has not been seen before newDNSNames = append(newDNSNames, policyMatchStr) // Add this egress rule as a dependent on ToFQDNs.MatchPattern, but fixup the literal // name so it can work as a regex if err = gen.sourceRules.Add(dnsPatternAsRE, uuid); err != nil { return nil, nil, err } } } } } // Stop managing names/patterns that remain in shouldStopManaging (i.e. not // seen when iterating .ToFQDNs rules above). The net result is to remove // dnsName -> uuid associations that existed in the older version of the rule // with this UUID, but did not re-occur in the new instance. // When a dnsName has no uuid associations, we remove it from the poll list // outright. for dnsName := range namesToStopManaging { if shouldStopManaging := gen.removeFromDNSName(dnsName, uuid); shouldStopManaging { delete(gen.namesToPoll, dnsName) // A no-op for matchPattern } } return newDNSNames, oldDNSNames, nil }
go
func (gen *RuleGen) addRule(uuid string, sourceRule *api.Rule) (newDNSNames, oldDNSNames []string, err error) { // if we are updating a rule, track which old dnsNames are removed. We store // possible names to stop managing in namesToStopManaging. As we add names // from the new rule below, these are cleared. namesToStopManaging := make(map[string]struct{}) if oldRule, exists := gen.allRules[uuid]; exists { for _, egressRule := range oldRule.Egress { for _, ToFQDN := range egressRule.ToFQDNs { if len(ToFQDN.MatchName) > 0 { dnsName := prepareMatchName(ToFQDN.MatchName) dnsNameAsRE := matchpattern.ToRegexp(dnsName) namesToStopManaging[dnsNameAsRE] = struct{}{} } if len(ToFQDN.MatchPattern) > 0 { dnsPattern := matchpattern.Sanitize(ToFQDN.MatchPattern) dnsPatternAsRE := matchpattern.ToRegexp(dnsPattern) namesToStopManaging[dnsPatternAsRE] = struct{}{} } } } } // Always add to allRules gen.allRules[uuid] = sourceRule // Add a dnsname -> rule reference. We track old/new names by the literal // value in matchName/Pattern. They are inserted into the sourceRules // RegexpMap as regexeps, however, so we can match against them later. for _, egressRule := range sourceRule.Egress { for _, ToFQDN := range egressRule.ToFQDNs { REsToAddForUUID := map[string]string{} if len(ToFQDN.MatchName) > 0 { dnsName := prepareMatchName(ToFQDN.MatchName) dnsNameAsRE := matchpattern.ToRegexp(dnsName) REsToAddForUUID[ToFQDN.MatchName] = dnsNameAsRE gen.namesToPoll[dnsName] = struct{}{} } if len(ToFQDN.MatchPattern) > 0 { dnsPattern := matchpattern.Sanitize(ToFQDN.MatchPattern) dnsPatternAsRE := matchpattern.ToRegexp(dnsPattern) REsToAddForUUID[ToFQDN.MatchPattern] = dnsPatternAsRE } for policyMatchStr, dnsPatternAsRE := range REsToAddForUUID { delete(namesToStopManaging, dnsPatternAsRE) // keep managing this matchName/Pattern // check if this is already managed or not if exists := gen.sourceRules.LookupContainsValue(dnsPatternAsRE, uuid); exists { oldDNSNames = append(oldDNSNames, policyMatchStr) } else { // This ToFQDNs.MatchName/Pattern has not been seen before newDNSNames = append(newDNSNames, policyMatchStr) // Add this egress rule as a dependent on ToFQDNs.MatchPattern, but fixup the literal // name so it can work as a regex if err = gen.sourceRules.Add(dnsPatternAsRE, uuid); err != nil { return nil, nil, err } } } } } // Stop managing names/patterns that remain in shouldStopManaging (i.e. not // seen when iterating .ToFQDNs rules above). The net result is to remove // dnsName -> uuid associations that existed in the older version of the rule // with this UUID, but did not re-occur in the new instance. // When a dnsName has no uuid associations, we remove it from the poll list // outright. for dnsName := range namesToStopManaging { if shouldStopManaging := gen.removeFromDNSName(dnsName, uuid); shouldStopManaging { delete(gen.namesToPoll, dnsName) // A no-op for matchPattern } } return newDNSNames, oldDNSNames, nil }
[ "func", "(", "gen", "*", "RuleGen", ")", "addRule", "(", "uuid", "string", ",", "sourceRule", "*", "api", ".", "Rule", ")", "(", "newDNSNames", ",", "oldDNSNames", "[", "]", "string", ",", "err", "error", ")", "{", "// if we are updating a rule, track which old dnsNames are removed. We store", "// possible names to stop managing in namesToStopManaging. As we add names", "// from the new rule below, these are cleared.", "namesToStopManaging", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ")", "\n", "if", "oldRule", ",", "exists", ":=", "gen", ".", "allRules", "[", "uuid", "]", ";", "exists", "{", "for", "_", ",", "egressRule", ":=", "range", "oldRule", ".", "Egress", "{", "for", "_", ",", "ToFQDN", ":=", "range", "egressRule", ".", "ToFQDNs", "{", "if", "len", "(", "ToFQDN", ".", "MatchName", ")", ">", "0", "{", "dnsName", ":=", "prepareMatchName", "(", "ToFQDN", ".", "MatchName", ")", "\n", "dnsNameAsRE", ":=", "matchpattern", ".", "ToRegexp", "(", "dnsName", ")", "\n", "namesToStopManaging", "[", "dnsNameAsRE", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "if", "len", "(", "ToFQDN", ".", "MatchPattern", ")", ">", "0", "{", "dnsPattern", ":=", "matchpattern", ".", "Sanitize", "(", "ToFQDN", ".", "MatchPattern", ")", "\n", "dnsPatternAsRE", ":=", "matchpattern", ".", "ToRegexp", "(", "dnsPattern", ")", "\n", "namesToStopManaging", "[", "dnsPatternAsRE", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "// Always add to allRules", "gen", ".", "allRules", "[", "uuid", "]", "=", "sourceRule", "\n\n", "// Add a dnsname -> rule reference. We track old/new names by the literal", "// value in matchName/Pattern. They are inserted into the sourceRules", "// RegexpMap as regexeps, however, so we can match against them later.", "for", "_", ",", "egressRule", ":=", "range", "sourceRule", ".", "Egress", "{", "for", "_", ",", "ToFQDN", ":=", "range", "egressRule", ".", "ToFQDNs", "{", "REsToAddForUUID", ":=", "map", "[", "string", "]", "string", "{", "}", "\n\n", "if", "len", "(", "ToFQDN", ".", "MatchName", ")", ">", "0", "{", "dnsName", ":=", "prepareMatchName", "(", "ToFQDN", ".", "MatchName", ")", "\n", "dnsNameAsRE", ":=", "matchpattern", ".", "ToRegexp", "(", "dnsName", ")", "\n", "REsToAddForUUID", "[", "ToFQDN", ".", "MatchName", "]", "=", "dnsNameAsRE", "\n", "gen", ".", "namesToPoll", "[", "dnsName", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n\n", "if", "len", "(", "ToFQDN", ".", "MatchPattern", ")", ">", "0", "{", "dnsPattern", ":=", "matchpattern", ".", "Sanitize", "(", "ToFQDN", ".", "MatchPattern", ")", "\n", "dnsPatternAsRE", ":=", "matchpattern", ".", "ToRegexp", "(", "dnsPattern", ")", "\n", "REsToAddForUUID", "[", "ToFQDN", ".", "MatchPattern", "]", "=", "dnsPatternAsRE", "\n", "}", "\n\n", "for", "policyMatchStr", ",", "dnsPatternAsRE", ":=", "range", "REsToAddForUUID", "{", "delete", "(", "namesToStopManaging", ",", "dnsPatternAsRE", ")", "// keep managing this matchName/Pattern", "\n", "// check if this is already managed or not", "if", "exists", ":=", "gen", ".", "sourceRules", ".", "LookupContainsValue", "(", "dnsPatternAsRE", ",", "uuid", ")", ";", "exists", "{", "oldDNSNames", "=", "append", "(", "oldDNSNames", ",", "policyMatchStr", ")", "\n", "}", "else", "{", "// This ToFQDNs.MatchName/Pattern has not been seen before", "newDNSNames", "=", "append", "(", "newDNSNames", ",", "policyMatchStr", ")", "\n", "// Add this egress rule as a dependent on ToFQDNs.MatchPattern, but fixup the literal", "// name so it can work as a regex", "if", "err", "=", "gen", ".", "sourceRules", ".", "Add", "(", "dnsPatternAsRE", ",", "uuid", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "// Stop managing names/patterns that remain in shouldStopManaging (i.e. not", "// seen when iterating .ToFQDNs rules above). The net result is to remove", "// dnsName -> uuid associations that existed in the older version of the rule", "// with this UUID, but did not re-occur in the new instance.", "// When a dnsName has no uuid associations, we remove it from the poll list", "// outright.", "for", "dnsName", ":=", "range", "namesToStopManaging", "{", "if", "shouldStopManaging", ":=", "gen", ".", "removeFromDNSName", "(", "dnsName", ",", "uuid", ")", ";", "shouldStopManaging", "{", "delete", "(", "gen", ".", "namesToPoll", ",", "dnsName", ")", "// A no-op for matchPattern", "\n", "}", "\n", "}", "\n\n", "return", "newDNSNames", ",", "oldDNSNames", ",", "nil", "\n", "}" ]
// addRule places an api.Rule in the source list for a DNS name. // uuid must be the unique identifier generated for the ToFQDN-UUID label. // newDNSNames and oldDNSNames indicate names that were newly added from this // rule, or that were seen in this rule but were already managed. // If newDNSNames and oldDNSNames are both empty, the rule was not added to the // managed list.
[ "addRule", "places", "an", "api", ".", "Rule", "in", "the", "source", "list", "for", "a", "DNS", "name", ".", "uuid", "must", "be", "the", "unique", "identifier", "generated", "for", "the", "ToFQDN", "-", "UUID", "label", ".", "newDNSNames", "and", "oldDNSNames", "indicate", "names", "that", "were", "newly", "added", "from", "this", "rule", "or", "that", "were", "seen", "in", "this", "rule", "but", "were", "already", "managed", ".", "If", "newDNSNames", "and", "oldDNSNames", "are", "both", "empty", "the", "rule", "was", "not", "added", "to", "the", "managed", "list", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/rulegen.go#L424-L500
163,627
cilium/cilium
pkg/fqdn/rulegen.go
removeRule
func (gen *RuleGen) removeRule(uuid string, sourceRule *api.Rule) (noLongerManaged []string) { // Always delete from allRules delete(gen.allRules, uuid) // Delete dnsname -> rule references for _, egressRule := range sourceRule.Egress { for _, ToFQDN := range egressRule.ToFQDNs { if len(ToFQDN.MatchName) > 0 { dnsName := prepareMatchName(ToFQDN.MatchName) dnsNameAsRE := matchpattern.ToRegexp(dnsName) if shouldStopManaging := gen.removeFromDNSName(dnsNameAsRE, uuid); shouldStopManaging { delete(gen.namesToPoll, dnsName) noLongerManaged = append(noLongerManaged, ToFQDN.MatchName) } } if len(ToFQDN.MatchPattern) > 0 { dnsPattern := matchpattern.Sanitize(ToFQDN.MatchPattern) dnsPatternAsRE := matchpattern.ToRegexp(dnsPattern) if shouldStopManaging := gen.removeFromDNSName(dnsPatternAsRE, uuid); shouldStopManaging { noLongerManaged = append(noLongerManaged, ToFQDN.MatchPattern) } } } } return noLongerManaged }
go
func (gen *RuleGen) removeRule(uuid string, sourceRule *api.Rule) (noLongerManaged []string) { // Always delete from allRules delete(gen.allRules, uuid) // Delete dnsname -> rule references for _, egressRule := range sourceRule.Egress { for _, ToFQDN := range egressRule.ToFQDNs { if len(ToFQDN.MatchName) > 0 { dnsName := prepareMatchName(ToFQDN.MatchName) dnsNameAsRE := matchpattern.ToRegexp(dnsName) if shouldStopManaging := gen.removeFromDNSName(dnsNameAsRE, uuid); shouldStopManaging { delete(gen.namesToPoll, dnsName) noLongerManaged = append(noLongerManaged, ToFQDN.MatchName) } } if len(ToFQDN.MatchPattern) > 0 { dnsPattern := matchpattern.Sanitize(ToFQDN.MatchPattern) dnsPatternAsRE := matchpattern.ToRegexp(dnsPattern) if shouldStopManaging := gen.removeFromDNSName(dnsPatternAsRE, uuid); shouldStopManaging { noLongerManaged = append(noLongerManaged, ToFQDN.MatchPattern) } } } } return noLongerManaged }
[ "func", "(", "gen", "*", "RuleGen", ")", "removeRule", "(", "uuid", "string", ",", "sourceRule", "*", "api", ".", "Rule", ")", "(", "noLongerManaged", "[", "]", "string", ")", "{", "// Always delete from allRules", "delete", "(", "gen", ".", "allRules", ",", "uuid", ")", "\n\n", "// Delete dnsname -> rule references", "for", "_", ",", "egressRule", ":=", "range", "sourceRule", ".", "Egress", "{", "for", "_", ",", "ToFQDN", ":=", "range", "egressRule", ".", "ToFQDNs", "{", "if", "len", "(", "ToFQDN", ".", "MatchName", ")", ">", "0", "{", "dnsName", ":=", "prepareMatchName", "(", "ToFQDN", ".", "MatchName", ")", "\n", "dnsNameAsRE", ":=", "matchpattern", ".", "ToRegexp", "(", "dnsName", ")", "\n", "if", "shouldStopManaging", ":=", "gen", ".", "removeFromDNSName", "(", "dnsNameAsRE", ",", "uuid", ")", ";", "shouldStopManaging", "{", "delete", "(", "gen", ".", "namesToPoll", ",", "dnsName", ")", "\n", "noLongerManaged", "=", "append", "(", "noLongerManaged", ",", "ToFQDN", ".", "MatchName", ")", "\n", "}", "\n", "}", "\n\n", "if", "len", "(", "ToFQDN", ".", "MatchPattern", ")", ">", "0", "{", "dnsPattern", ":=", "matchpattern", ".", "Sanitize", "(", "ToFQDN", ".", "MatchPattern", ")", "\n", "dnsPatternAsRE", ":=", "matchpattern", ".", "ToRegexp", "(", "dnsPattern", ")", "\n", "if", "shouldStopManaging", ":=", "gen", ".", "removeFromDNSName", "(", "dnsPatternAsRE", ",", "uuid", ")", ";", "shouldStopManaging", "{", "noLongerManaged", "=", "append", "(", "noLongerManaged", ",", "ToFQDN", ".", "MatchPattern", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "noLongerManaged", "\n", "}" ]
// removeRule removes an api.Rule from the source rule set for each DNS name, // and from the IPs if no rules depend on that DNS name. // uuid must be a unique identifier for the sourceRule // noLongerManaged indicates that no more rules rely on this DNS target
[ "removeRule", "removes", "an", "api", ".", "Rule", "from", "the", "source", "rule", "set", "for", "each", "DNS", "name", "and", "from", "the", "IPs", "if", "no", "rules", "depend", "on", "that", "DNS", "name", ".", "uuid", "must", "be", "a", "unique", "identifier", "for", "the", "sourceRule", "noLongerManaged", "indicates", "that", "no", "more", "rules", "rely", "on", "this", "DNS", "target" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/rulegen.go#L506-L533
163,628
cilium/cilium
pkg/fqdn/rulegen.go
removeFromDNSName
func (gen *RuleGen) removeFromDNSName(dnsName, uuid string) (shouldStopManaging bool) { // remove the rule from the set of rules that rely on dnsName. // Note: this isn't removing dnsName from gen.sourceRules, that is just // below. return gen.sourceRules.Remove(dnsName, uuid) }
go
func (gen *RuleGen) removeFromDNSName(dnsName, uuid string) (shouldStopManaging bool) { // remove the rule from the set of rules that rely on dnsName. // Note: this isn't removing dnsName from gen.sourceRules, that is just // below. return gen.sourceRules.Remove(dnsName, uuid) }
[ "func", "(", "gen", "*", "RuleGen", ")", "removeFromDNSName", "(", "dnsName", ",", "uuid", "string", ")", "(", "shouldStopManaging", "bool", ")", "{", "// remove the rule from the set of rules that rely on dnsName.", "// Note: this isn't removing dnsName from gen.sourceRules, that is just", "// below.", "return", "gen", ".", "sourceRules", ".", "Remove", "(", "dnsName", ",", "uuid", ")", "\n", "}" ]
// removeFromDNSName removes the uuid from the list attached to a dns name. It // will clean up gen.sourceRules if needed. // shouldStopManaging indicates that no more rules rely on this DNS target
[ "removeFromDNSName", "removes", "the", "uuid", "from", "the", "list", "attached", "to", "a", "dns", "name", ".", "It", "will", "clean", "up", "gen", ".", "sourceRules", "if", "needed", ".", "shouldStopManaging", "indicates", "that", "no", "more", "rules", "rely", "on", "this", "DNS", "target" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/rulegen.go#L538-L543
163,629
cilium/cilium
pkg/fqdn/rulegen.go
updateIPsForName
func (gen *RuleGen) updateIPsForName(lookupTime time.Time, dnsName string, newIPs []net.IP, ttl int) (updated bool) { cacheIPs := gen.cache.Lookup(dnsName) if gen.config.MinTTL > ttl { ttl = gen.config.MinTTL } gen.cache.Update(lookupTime, dnsName, newIPs, ttl) sortedNewIPs := gen.cache.Lookup(dnsName) // DNSCache returns IPs sorted // The 0 checks below account for an unlike race condition where this // function is called with already expired data and if other cache data // from before also expired. return (len(cacheIPs) == 0 && len(sortedNewIPs) == 0) || !sortedIPsAreEqual(sortedNewIPs, cacheIPs) }
go
func (gen *RuleGen) updateIPsForName(lookupTime time.Time, dnsName string, newIPs []net.IP, ttl int) (updated bool) { cacheIPs := gen.cache.Lookup(dnsName) if gen.config.MinTTL > ttl { ttl = gen.config.MinTTL } gen.cache.Update(lookupTime, dnsName, newIPs, ttl) sortedNewIPs := gen.cache.Lookup(dnsName) // DNSCache returns IPs sorted // The 0 checks below account for an unlike race condition where this // function is called with already expired data and if other cache data // from before also expired. return (len(cacheIPs) == 0 && len(sortedNewIPs) == 0) || !sortedIPsAreEqual(sortedNewIPs, cacheIPs) }
[ "func", "(", "gen", "*", "RuleGen", ")", "updateIPsForName", "(", "lookupTime", "time", ".", "Time", ",", "dnsName", "string", ",", "newIPs", "[", "]", "net", ".", "IP", ",", "ttl", "int", ")", "(", "updated", "bool", ")", "{", "cacheIPs", ":=", "gen", ".", "cache", ".", "Lookup", "(", "dnsName", ")", "\n\n", "if", "gen", ".", "config", ".", "MinTTL", ">", "ttl", "{", "ttl", "=", "gen", ".", "config", ".", "MinTTL", "\n", "}", "\n\n", "gen", ".", "cache", ".", "Update", "(", "lookupTime", ",", "dnsName", ",", "newIPs", ",", "ttl", ")", "\n", "sortedNewIPs", ":=", "gen", ".", "cache", ".", "Lookup", "(", "dnsName", ")", "// DNSCache returns IPs sorted", "\n\n", "// The 0 checks below account for an unlike race condition where this", "// function is called with already expired data and if other cache data", "// from before also expired.", "return", "(", "len", "(", "cacheIPs", ")", "==", "0", "&&", "len", "(", "sortedNewIPs", ")", "==", "0", ")", "||", "!", "sortedIPsAreEqual", "(", "sortedNewIPs", ",", "cacheIPs", ")", "\n", "}" ]
// updateIPsName will update the IPs for dnsName. It always retains a copy of // newIPs. // updated is true when the new IPs differ from the old IPs
[ "updateIPsName", "will", "update", "the", "IPs", "for", "dnsName", ".", "It", "always", "retains", "a", "copy", "of", "newIPs", ".", "updated", "is", "true", "when", "the", "new", "IPs", "differ", "from", "the", "old", "IPs" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/rulegen.go#L548-L562
163,630
cilium/cilium
api/v1/client/policy/get_identity_parameters.go
WithTimeout
func (o *GetIdentityParams) WithTimeout(timeout time.Duration) *GetIdentityParams { o.SetTimeout(timeout) return o }
go
func (o *GetIdentityParams) WithTimeout(timeout time.Duration) *GetIdentityParams { o.SetTimeout(timeout) return o }
[ "func", "(", "o", "*", "GetIdentityParams", ")", "WithTimeout", "(", "timeout", "time", ".", "Duration", ")", "*", "GetIdentityParams", "{", "o", ".", "SetTimeout", "(", "timeout", ")", "\n", "return", "o", "\n", "}" ]
// WithTimeout adds the timeout to the get identity params
[ "WithTimeout", "adds", "the", "timeout", "to", "the", "get", "identity", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/get_identity_parameters.go#L79-L82
163,631
cilium/cilium
api/v1/client/policy/get_identity_parameters.go
WithContext
func (o *GetIdentityParams) WithContext(ctx context.Context) *GetIdentityParams { o.SetContext(ctx) return o }
go
func (o *GetIdentityParams) WithContext(ctx context.Context) *GetIdentityParams { o.SetContext(ctx) return o }
[ "func", "(", "o", "*", "GetIdentityParams", ")", "WithContext", "(", "ctx", "context", ".", "Context", ")", "*", "GetIdentityParams", "{", "o", ".", "SetContext", "(", "ctx", ")", "\n", "return", "o", "\n", "}" ]
// WithContext adds the context to the get identity params
[ "WithContext", "adds", "the", "context", "to", "the", "get", "identity", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/get_identity_parameters.go#L90-L93
163,632
cilium/cilium
api/v1/client/policy/get_identity_parameters.go
WithHTTPClient
func (o *GetIdentityParams) WithHTTPClient(client *http.Client) *GetIdentityParams { o.SetHTTPClient(client) return o }
go
func (o *GetIdentityParams) WithHTTPClient(client *http.Client) *GetIdentityParams { o.SetHTTPClient(client) return o }
[ "func", "(", "o", "*", "GetIdentityParams", ")", "WithHTTPClient", "(", "client", "*", "http", ".", "Client", ")", "*", "GetIdentityParams", "{", "o", ".", "SetHTTPClient", "(", "client", ")", "\n", "return", "o", "\n", "}" ]
// WithHTTPClient adds the HTTPClient to the get identity params
[ "WithHTTPClient", "adds", "the", "HTTPClient", "to", "the", "get", "identity", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/get_identity_parameters.go#L101-L104
163,633
cilium/cilium
api/v1/client/policy/get_identity_parameters.go
WithLabels
func (o *GetIdentityParams) WithLabels(labels models.Labels) *GetIdentityParams { o.SetLabels(labels) return o }
go
func (o *GetIdentityParams) WithLabels(labels models.Labels) *GetIdentityParams { o.SetLabels(labels) return o }
[ "func", "(", "o", "*", "GetIdentityParams", ")", "WithLabels", "(", "labels", "models", ".", "Labels", ")", "*", "GetIdentityParams", "{", "o", ".", "SetLabels", "(", "labels", ")", "\n", "return", "o", "\n", "}" ]
// WithLabels adds the labels to the get identity params
[ "WithLabels", "adds", "the", "labels", "to", "the", "get", "identity", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/get_identity_parameters.go#L112-L115
163,634
cilium/cilium
api/v1/health/server/restapi/get_hello.go
NewGetHello
func NewGetHello(ctx *middleware.Context, handler GetHelloHandler) *GetHello { return &GetHello{Context: ctx, Handler: handler} }
go
func NewGetHello(ctx *middleware.Context, handler GetHelloHandler) *GetHello { return &GetHello{Context: ctx, Handler: handler} }
[ "func", "NewGetHello", "(", "ctx", "*", "middleware", ".", "Context", ",", "handler", "GetHelloHandler", ")", "*", "GetHello", "{", "return", "&", "GetHello", "{", "Context", ":", "ctx", ",", "Handler", ":", "handler", "}", "\n", "}" ]
// NewGetHello creates a new http.Handler for the get hello operation
[ "NewGetHello", "creates", "a", "new", "http", ".", "Handler", "for", "the", "get", "hello", "operation" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/server/restapi/get_hello.go#L28-L30
163,635
cilium/cilium
pkg/mac/mac.go
ParseMAC
func ParseMAC(s string) (MAC, error) { ha, err := net.ParseMAC(s) if err != nil { return MAC{}, err } if len(ha) != 6 { return MAC{}, fmt.Errorf("invalid MAC address %s", s) } return MAC(ha), nil }
go
func ParseMAC(s string) (MAC, error) { ha, err := net.ParseMAC(s) if err != nil { return MAC{}, err } if len(ha) != 6 { return MAC{}, fmt.Errorf("invalid MAC address %s", s) } return MAC(ha), nil }
[ "func", "ParseMAC", "(", "s", "string", ")", "(", "MAC", ",", "error", ")", "{", "ha", ",", "err", ":=", "net", ".", "ParseMAC", "(", "s", ")", "\n", "if", "err", "!=", "nil", "{", "return", "MAC", "{", "}", ",", "err", "\n", "}", "\n", "if", "len", "(", "ha", ")", "!=", "6", "{", "return", "MAC", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ")", "\n", "}", "\n\n", "return", "MAC", "(", "ha", ")", ",", "nil", "\n", "}" ]
// ParseMAC parses s only as an IEEE 802 MAC-48.
[ "ParseMAC", "parses", "s", "only", "as", "an", "IEEE", "802", "MAC", "-", "48", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/mac/mac.go#L33-L43
163,636
cilium/cilium
api/v1/server/restapi/ipam/post_ip_a_m_parameters.go
bindFamily
func (o *PostIPAMParams) bindFamily(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: false // AllowEmptyValue: false if raw == "" { // empty values pass all other validations return nil } o.Family = &raw if err := o.validateFamily(formats); err != nil { return err } return nil }
go
func (o *PostIPAMParams) bindFamily(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: false // AllowEmptyValue: false if raw == "" { // empty values pass all other validations return nil } o.Family = &raw if err := o.validateFamily(formats); err != nil { return err } return nil }
[ "func", "(", "o", "*", "PostIPAMParams", ")", "bindFamily", "(", "rawData", "[", "]", "string", ",", "hasKey", "bool", ",", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "raw", "string", "\n", "if", "len", "(", "rawData", ")", ">", "0", "{", "raw", "=", "rawData", "[", "len", "(", "rawData", ")", "-", "1", "]", "\n", "}", "\n\n", "// Required: false", "// AllowEmptyValue: false", "if", "raw", "==", "\"", "\"", "{", "// empty values pass all other validations", "return", "nil", "\n", "}", "\n\n", "o", ".", "Family", "=", "&", "raw", "\n\n", "if", "err", ":=", "o", ".", "validateFamily", "(", "formats", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// bindFamily binds and validates parameter Family from query.
[ "bindFamily", "binds", "and", "validates", "parameter", "Family", "from", "query", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/ipam/post_ip_a_m_parameters.go#L73-L92
163,637
cilium/cilium
api/v1/server/restapi/ipam/post_ip_a_m_parameters.go
validateFamily
func (o *PostIPAMParams) validateFamily(formats strfmt.Registry) error { if err := validate.Enum("family", "query", *o.Family, []interface{}{"ipv4", "ipv6"}); err != nil { return err } return nil }
go
func (o *PostIPAMParams) validateFamily(formats strfmt.Registry) error { if err := validate.Enum("family", "query", *o.Family, []interface{}{"ipv4", "ipv6"}); err != nil { return err } return nil }
[ "func", "(", "o", "*", "PostIPAMParams", ")", "validateFamily", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "if", "err", ":=", "validate", ".", "Enum", "(", "\"", "\"", ",", "\"", "\"", ",", "*", "o", ".", "Family", ",", "[", "]", "interface", "{", "}", "{", "\"", "\"", ",", "\"", "\"", "}", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// validateFamily carries on validations for parameter Family
[ "validateFamily", "carries", "on", "validations", "for", "parameter", "Family" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/ipam/post_ip_a_m_parameters.go#L95-L102
163,638
cilium/cilium
api/v1/server/restapi/ipam/post_ip_a_m_parameters.go
bindOwner
func (o *PostIPAMParams) bindOwner(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: false // AllowEmptyValue: false if raw == "" { // empty values pass all other validations return nil } o.Owner = &raw return nil }
go
func (o *PostIPAMParams) bindOwner(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: false // AllowEmptyValue: false if raw == "" { // empty values pass all other validations return nil } o.Owner = &raw return nil }
[ "func", "(", "o", "*", "PostIPAMParams", ")", "bindOwner", "(", "rawData", "[", "]", "string", ",", "hasKey", "bool", ",", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "raw", "string", "\n", "if", "len", "(", "rawData", ")", ">", "0", "{", "raw", "=", "rawData", "[", "len", "(", "rawData", ")", "-", "1", "]", "\n", "}", "\n\n", "// Required: false", "// AllowEmptyValue: false", "if", "raw", "==", "\"", "\"", "{", "// empty values pass all other validations", "return", "nil", "\n", "}", "\n\n", "o", ".", "Owner", "=", "&", "raw", "\n\n", "return", "nil", "\n", "}" ]
// bindOwner binds and validates parameter Owner from query.
[ "bindOwner", "binds", "and", "validates", "parameter", "Owner", "from", "query", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/ipam/post_ip_a_m_parameters.go#L105-L120
163,639
cilium/cilium
api/v1/server/restapi/policy/get_identity_id_responses.go
WithPayload
func (o *GetIdentityIDOK) WithPayload(payload *models.Identity) *GetIdentityIDOK { o.Payload = payload return o }
go
func (o *GetIdentityIDOK) WithPayload(payload *models.Identity) *GetIdentityIDOK { o.Payload = payload return o }
[ "func", "(", "o", "*", "GetIdentityIDOK", ")", "WithPayload", "(", "payload", "*", "models", ".", "Identity", ")", "*", "GetIdentityIDOK", "{", "o", ".", "Payload", "=", "payload", "\n", "return", "o", "\n", "}" ]
// WithPayload adds the payload to the get identity Id o k response
[ "WithPayload", "adds", "the", "payload", "to", "the", "get", "identity", "Id", "o", "k", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/get_identity_id_responses.go#L38-L41
163,640
cilium/cilium
api/v1/server/restapi/policy/get_identity_id_responses.go
WithPayload
func (o *GetIdentityIDUnreachable) WithPayload(payload models.Error) *GetIdentityIDUnreachable { o.Payload = payload return o }
go
func (o *GetIdentityIDUnreachable) WithPayload(payload models.Error) *GetIdentityIDUnreachable { o.Payload = payload return o }
[ "func", "(", "o", "*", "GetIdentityIDUnreachable", ")", "WithPayload", "(", "payload", "models", ".", "Error", ")", "*", "GetIdentityIDUnreachable", "{", "o", ".", "Payload", "=", "payload", "\n", "return", "o", "\n", "}" ]
// WithPayload adds the payload to the get identity Id unreachable response
[ "WithPayload", "adds", "the", "payload", "to", "the", "get", "identity", "Id", "unreachable", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/get_identity_id_responses.go#L130-L133
163,641
cilium/cilium
api/v1/server/restapi/policy/get_identity_id_responses.go
WithPayload
func (o *GetIdentityIDInvalidStorageFormat) WithPayload(payload models.Error) *GetIdentityIDInvalidStorageFormat { o.Payload = payload return o }
go
func (o *GetIdentityIDInvalidStorageFormat) WithPayload(payload models.Error) *GetIdentityIDInvalidStorageFormat { o.Payload = payload return o }
[ "func", "(", "o", "*", "GetIdentityIDInvalidStorageFormat", ")", "WithPayload", "(", "payload", "models", ".", "Error", ")", "*", "GetIdentityIDInvalidStorageFormat", "{", "o", ".", "Payload", "=", "payload", "\n", "return", "o", "\n", "}" ]
// WithPayload adds the payload to the get identity Id invalid storage format response
[ "WithPayload", "adds", "the", "payload", "to", "the", "get", "identity", "Id", "invalid", "storage", "format", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/get_identity_id_responses.go#L172-L175
163,642
cilium/cilium
api/v1/server/restapi/ipam/post_ip_a_m_ip_responses.go
WithPayload
func (o *PostIPAMIPFailure) WithPayload(payload models.Error) *PostIPAMIPFailure { o.Payload = payload return o }
go
func (o *PostIPAMIPFailure) WithPayload(payload models.Error) *PostIPAMIPFailure { o.Payload = payload return o }
[ "func", "(", "o", "*", "PostIPAMIPFailure", ")", "WithPayload", "(", "payload", "models", ".", "Error", ")", "*", "PostIPAMIPFailure", "{", "o", ".", "Payload", "=", "payload", "\n", "return", "o", "\n", "}" ]
// WithPayload adds the payload to the post Ip a m Ip failure response
[ "WithPayload", "adds", "the", "payload", "to", "the", "post", "Ip", "a", "m", "Ip", "failure", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/ipam/post_ip_a_m_ip_responses.go#L110-L113
163,643
cilium/cilium
bugtool/cmd/root.go
dryRun
func dryRun(configPath string, k8sPods []string, confDir, cmdDir string) { _, err := setupDefaultConfig(configPath, k8sPods, confDir, cmdDir) if err != nil { fmt.Printf("Error: %s", err) os.Exit(1) } }
go
func dryRun(configPath string, k8sPods []string, confDir, cmdDir string) { _, err := setupDefaultConfig(configPath, k8sPods, confDir, cmdDir) if err != nil { fmt.Printf("Error: %s", err) os.Exit(1) } }
[ "func", "dryRun", "(", "configPath", "string", ",", "k8sPods", "[", "]", "string", ",", "confDir", ",", "cmdDir", "string", ")", "{", "_", ",", "err", ":=", "setupDefaultConfig", "(", "configPath", ",", "k8sPods", ",", "confDir", ",", "cmdDir", ")", "\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Printf", "(", "\"", "\"", ",", "err", ")", "\n", "os", ".", "Exit", "(", "1", ")", "\n", "}", "\n", "}" ]
// dryRun creates the configuration file to show the user what would have been run. // The same file can be used to modify what will be run by the bugtool.
[ "dryRun", "creates", "the", "configuration", "file", "to", "show", "the", "user", "what", "would", "have", "been", "run", ".", "The", "same", "file", "can", "be", "used", "to", "modify", "what", "will", "be", "run", "by", "the", "bugtool", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/bugtool/cmd/root.go#L222-L228
163,644
cilium/cilium
bugtool/cmd/root.go
writeCmdToFile
func writeCmdToFile(cmdDir, prompt string, k8sPods []string, enableMarkdown bool) { // Clean up the filename name := strings.Replace(prompt, "/", " ", -1) name = strings.Replace(name, " ", "-", -1) f, err := os.Create(filepath.Join(cmdDir, name+".md")) if err != nil { fmt.Fprintf(os.Stderr, "Could not create file %s\n", err) return } defer f.Close() cmd, args := split(prompt) if len(k8sPods) == 0 { // The command does not exist, abort. if _, err := exec.LookPath(cmd); err != nil { os.Remove(f.Name()) return } } else if len(args) > 5 { // Boundary check is necessary to skip other non exec kubectl // commands. ctx, cancel := context.WithTimeout(context.Background(), execTimeout) defer cancel() if _, err := exec.CommandContext(ctx, "kubectl", "exec", args[1], "-n", args[3], "--", "which", args[5]).CombinedOutput(); err != nil || ctx.Err() == context.DeadlineExceeded { os.Remove(f.Name()) return } } // Write prompt as header and the output as body, and / or error but delete empty output. output, err := execCommand(prompt) if err != nil { fmt.Fprintf(f, fmt.Sprintf("> Error while running '%s': %s\n\n", prompt, err)) } // We deliberately continue in case there was a error but the output // produced might have useful information if strings.Contains(output, "```") || !enableMarkdown { // Already contains Markdown, print as is. fmt.Fprint(f, output) } else if enableMarkdown && len(output) > 0 { fmt.Fprint(f, fmt.Sprintf("# %s\n\n```\n%s\n```\n", prompt, output)) } else { // Empty file os.Remove(f.Name()) } }
go
func writeCmdToFile(cmdDir, prompt string, k8sPods []string, enableMarkdown bool) { // Clean up the filename name := strings.Replace(prompt, "/", " ", -1) name = strings.Replace(name, " ", "-", -1) f, err := os.Create(filepath.Join(cmdDir, name+".md")) if err != nil { fmt.Fprintf(os.Stderr, "Could not create file %s\n", err) return } defer f.Close() cmd, args := split(prompt) if len(k8sPods) == 0 { // The command does not exist, abort. if _, err := exec.LookPath(cmd); err != nil { os.Remove(f.Name()) return } } else if len(args) > 5 { // Boundary check is necessary to skip other non exec kubectl // commands. ctx, cancel := context.WithTimeout(context.Background(), execTimeout) defer cancel() if _, err := exec.CommandContext(ctx, "kubectl", "exec", args[1], "-n", args[3], "--", "which", args[5]).CombinedOutput(); err != nil || ctx.Err() == context.DeadlineExceeded { os.Remove(f.Name()) return } } // Write prompt as header and the output as body, and / or error but delete empty output. output, err := execCommand(prompt) if err != nil { fmt.Fprintf(f, fmt.Sprintf("> Error while running '%s': %s\n\n", prompt, err)) } // We deliberately continue in case there was a error but the output // produced might have useful information if strings.Contains(output, "```") || !enableMarkdown { // Already contains Markdown, print as is. fmt.Fprint(f, output) } else if enableMarkdown && len(output) > 0 { fmt.Fprint(f, fmt.Sprintf("# %s\n\n```\n%s\n```\n", prompt, output)) } else { // Empty file os.Remove(f.Name()) } }
[ "func", "writeCmdToFile", "(", "cmdDir", ",", "prompt", "string", ",", "k8sPods", "[", "]", "string", ",", "enableMarkdown", "bool", ")", "{", "// Clean up the filename", "name", ":=", "strings", ".", "Replace", "(", "prompt", ",", "\"", "\"", ",", "\"", "\"", ",", "-", "1", ")", "\n", "name", "=", "strings", ".", "Replace", "(", "name", ",", "\"", "\"", ",", "\"", "\"", ",", "-", "1", ")", "\n", "f", ",", "err", ":=", "os", ".", "Create", "(", "filepath", ".", "Join", "(", "cmdDir", ",", "name", "+", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Fprintf", "(", "os", ".", "Stderr", ",", "\"", "\\n", "\"", ",", "err", ")", "\n", "return", "\n", "}", "\n", "defer", "f", ".", "Close", "(", ")", "\n\n", "cmd", ",", "args", ":=", "split", "(", "prompt", ")", "\n\n", "if", "len", "(", "k8sPods", ")", "==", "0", "{", "// The command does not exist, abort.", "if", "_", ",", "err", ":=", "exec", ".", "LookPath", "(", "cmd", ")", ";", "err", "!=", "nil", "{", "os", ".", "Remove", "(", "f", ".", "Name", "(", ")", ")", "\n", "return", "\n", "}", "\n", "}", "else", "if", "len", "(", "args", ")", ">", "5", "{", "// Boundary check is necessary to skip other non exec kubectl", "// commands.", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "execTimeout", ")", "\n", "defer", "cancel", "(", ")", "\n", "if", "_", ",", "err", ":=", "exec", ".", "CommandContext", "(", "ctx", ",", "\"", "\"", ",", "\"", "\"", ",", "args", "[", "1", "]", ",", "\"", "\"", ",", "args", "[", "3", "]", ",", "\"", "\"", ",", "\"", "\"", ",", "args", "[", "5", "]", ")", ".", "CombinedOutput", "(", ")", ";", "err", "!=", "nil", "||", "ctx", ".", "Err", "(", ")", "==", "context", ".", "DeadlineExceeded", "{", "os", ".", "Remove", "(", "f", ".", "Name", "(", ")", ")", "\n", "return", "\n", "}", "\n", "}", "\n", "// Write prompt as header and the output as body, and / or error but delete empty output.", "output", ",", "err", ":=", "execCommand", "(", "prompt", ")", "\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Fprintf", "(", "f", ",", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\\n", "\"", ",", "prompt", ",", "err", ")", ")", "\n", "}", "\n", "// We deliberately continue in case there was a error but the output", "// produced might have useful information", "if", "strings", ".", "Contains", "(", "output", ",", "\"", "\"", ")", "||", "!", "enableMarkdown", "{", "// Already contains Markdown, print as is.", "fmt", ".", "Fprint", "(", "f", ",", "output", ")", "\n", "}", "else", "if", "enableMarkdown", "&&", "len", "(", "output", ")", ">", "0", "{", "fmt", ".", "Fprint", "(", "f", ",", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\\n", "\\n", "\\n", "\\n", "\"", ",", "prompt", ",", "output", ")", ")", "\n", "}", "else", "{", "// Empty file", "os", ".", "Remove", "(", "f", ".", "Name", "(", ")", ")", "\n", "}", "\n", "}" ]
// writeCmdToFile will execute command and write markdown output to a file
[ "writeCmdToFile", "will", "execute", "command", "and", "write", "markdown", "output", "to", "a", "file" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/bugtool/cmd/root.go#L328-L375
163,645
cilium/cilium
bugtool/cmd/root.go
split
func split(prompt string) (string, []string) { // Split the command and arguments split := strings.Split(prompt, " ") argc := len(split) var args []string cmd := split[0] if argc > 1 { args = split[1:] } return cmd, args }
go
func split(prompt string) (string, []string) { // Split the command and arguments split := strings.Split(prompt, " ") argc := len(split) var args []string cmd := split[0] if argc > 1 { args = split[1:] } return cmd, args }
[ "func", "split", "(", "prompt", "string", ")", "(", "string", ",", "[", "]", "string", ")", "{", "// Split the command and arguments", "split", ":=", "strings", ".", "Split", "(", "prompt", ",", "\"", "\"", ")", "\n", "argc", ":=", "len", "(", "split", ")", "\n", "var", "args", "[", "]", "string", "\n", "cmd", ":=", "split", "[", "0", "]", "\n\n", "if", "argc", ">", "1", "{", "args", "=", "split", "[", "1", ":", "]", "\n", "}", "\n\n", "return", "cmd", ",", "args", "\n", "}" ]
// split takes a command prompt and returns the command and arguments separately
[ "split", "takes", "a", "command", "prompt", "and", "returns", "the", "command", "and", "arguments", "separately" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/bugtool/cmd/root.go#L378-L390
163,646
cilium/cilium
api/v1/client/daemon/patch_config_parameters.go
WithTimeout
func (o *PatchConfigParams) WithTimeout(timeout time.Duration) *PatchConfigParams { o.SetTimeout(timeout) return o }
go
func (o *PatchConfigParams) WithTimeout(timeout time.Duration) *PatchConfigParams { o.SetTimeout(timeout) return o }
[ "func", "(", "o", "*", "PatchConfigParams", ")", "WithTimeout", "(", "timeout", "time", ".", "Duration", ")", "*", "PatchConfigParams", "{", "o", ".", "SetTimeout", "(", "timeout", ")", "\n", "return", "o", "\n", "}" ]
// WithTimeout adds the timeout to the patch config params
[ "WithTimeout", "adds", "the", "timeout", "to", "the", "patch", "config", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/daemon/patch_config_parameters.go#L75-L78
163,647
cilium/cilium
api/v1/client/daemon/patch_config_parameters.go
WithContext
func (o *PatchConfigParams) WithContext(ctx context.Context) *PatchConfigParams { o.SetContext(ctx) return o }
go
func (o *PatchConfigParams) WithContext(ctx context.Context) *PatchConfigParams { o.SetContext(ctx) return o }
[ "func", "(", "o", "*", "PatchConfigParams", ")", "WithContext", "(", "ctx", "context", ".", "Context", ")", "*", "PatchConfigParams", "{", "o", ".", "SetContext", "(", "ctx", ")", "\n", "return", "o", "\n", "}" ]
// WithContext adds the context to the patch config params
[ "WithContext", "adds", "the", "context", "to", "the", "patch", "config", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/daemon/patch_config_parameters.go#L86-L89
163,648
cilium/cilium
api/v1/client/daemon/patch_config_parameters.go
WithHTTPClient
func (o *PatchConfigParams) WithHTTPClient(client *http.Client) *PatchConfigParams { o.SetHTTPClient(client) return o }
go
func (o *PatchConfigParams) WithHTTPClient(client *http.Client) *PatchConfigParams { o.SetHTTPClient(client) return o }
[ "func", "(", "o", "*", "PatchConfigParams", ")", "WithHTTPClient", "(", "client", "*", "http", ".", "Client", ")", "*", "PatchConfigParams", "{", "o", ".", "SetHTTPClient", "(", "client", ")", "\n", "return", "o", "\n", "}" ]
// WithHTTPClient adds the HTTPClient to the patch config params
[ "WithHTTPClient", "adds", "the", "HTTPClient", "to", "the", "patch", "config", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/daemon/patch_config_parameters.go#L97-L100
163,649
cilium/cilium
api/v1/client/daemon/patch_config_parameters.go
WithConfiguration
func (o *PatchConfigParams) WithConfiguration(configuration *models.DaemonConfigurationSpec) *PatchConfigParams { o.SetConfiguration(configuration) return o }
go
func (o *PatchConfigParams) WithConfiguration(configuration *models.DaemonConfigurationSpec) *PatchConfigParams { o.SetConfiguration(configuration) return o }
[ "func", "(", "o", "*", "PatchConfigParams", ")", "WithConfiguration", "(", "configuration", "*", "models", ".", "DaemonConfigurationSpec", ")", "*", "PatchConfigParams", "{", "o", ".", "SetConfiguration", "(", "configuration", ")", "\n", "return", "o", "\n", "}" ]
// WithConfiguration adds the configuration to the patch config params
[ "WithConfiguration", "adds", "the", "configuration", "to", "the", "patch", "config", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/daemon/patch_config_parameters.go#L108-L111
163,650
cilium/cilium
pkg/policy/policy.go
PolicyTrace
func (s *SearchContext) PolicyTrace(format string, a ...interface{}) { if s.TraceEnabled() { log.Debugf(format, a...) if s.Logging != nil { format = "%-" + s.CallDepth() + "s" + format a = append([]interface{}{""}, a...) s.Logging.Logger.Printf(format, a...) } } }
go
func (s *SearchContext) PolicyTrace(format string, a ...interface{}) { if s.TraceEnabled() { log.Debugf(format, a...) if s.Logging != nil { format = "%-" + s.CallDepth() + "s" + format a = append([]interface{}{""}, a...) s.Logging.Logger.Printf(format, a...) } } }
[ "func", "(", "s", "*", "SearchContext", ")", "PolicyTrace", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "if", "s", ".", "TraceEnabled", "(", ")", "{", "log", ".", "Debugf", "(", "format", ",", "a", "...", ")", "\n", "if", "s", ".", "Logging", "!=", "nil", "{", "format", "=", "\"", "\"", "+", "s", ".", "CallDepth", "(", ")", "+", "\"", "\"", "+", "format", "\n", "a", "=", "append", "(", "[", "]", "interface", "{", "}", "{", "\"", "\"", "}", ",", "a", "...", ")", "\n", "s", ".", "Logging", ".", "Logger", ".", "Printf", "(", "format", ",", "a", "...", ")", "\n", "}", "\n", "}", "\n", "}" ]
// PolicyTrace logs the given message into the SearchContext logger only if // TRACE_ENABLED or TRACE_VERBOSE is enabled in the receiver's SearchContext.
[ "PolicyTrace", "logs", "the", "given", "message", "into", "the", "SearchContext", "logger", "only", "if", "TRACE_ENABLED", "or", "TRACE_VERBOSE", "is", "enabled", "in", "the", "receiver", "s", "SearchContext", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/policy.go#L45-L54
163,651
cilium/cilium
pkg/policy/policy.go
PolicyTraceVerbose
func (s *SearchContext) PolicyTraceVerbose(format string, a ...interface{}) { switch s.Trace { case TRACE_VERBOSE: log.Debugf(format, a...) if s.Logging != nil { s.Logging.Logger.Printf(format, a...) } } }
go
func (s *SearchContext) PolicyTraceVerbose(format string, a ...interface{}) { switch s.Trace { case TRACE_VERBOSE: log.Debugf(format, a...) if s.Logging != nil { s.Logging.Logger.Printf(format, a...) } } }
[ "func", "(", "s", "*", "SearchContext", ")", "PolicyTraceVerbose", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "switch", "s", ".", "Trace", "{", "case", "TRACE_VERBOSE", ":", "log", ".", "Debugf", "(", "format", ",", "a", "...", ")", "\n", "if", "s", ".", "Logging", "!=", "nil", "{", "s", ".", "Logging", ".", "Logger", ".", "Printf", "(", "format", ",", "a", "...", ")", "\n", "}", "\n", "}", "\n", "}" ]
// PolicyTraceVerbose logs the given message into the SearchContext logger only // if TRACE_VERBOSE is enabled in the receiver's SearchContext.
[ "PolicyTraceVerbose", "logs", "the", "given", "message", "into", "the", "SearchContext", "logger", "only", "if", "TRACE_VERBOSE", "is", "enabled", "in", "the", "receiver", "s", "SearchContext", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/policy.go#L58-L66
163,652
cilium/cilium
pkg/policy/policy.go
WithLogger
func (s *SearchContext) WithLogger(log io.Writer) *SearchContext { result := *s result.Logging = logging.NewLogBackend(log, "", 0) if result.Trace == TRACE_DISABLED { result.Trace = TRACE_ENABLED } return &result }
go
func (s *SearchContext) WithLogger(log io.Writer) *SearchContext { result := *s result.Logging = logging.NewLogBackend(log, "", 0) if result.Trace == TRACE_DISABLED { result.Trace = TRACE_ENABLED } return &result }
[ "func", "(", "s", "*", "SearchContext", ")", "WithLogger", "(", "log", "io", ".", "Writer", ")", "*", "SearchContext", "{", "result", ":=", "*", "s", "\n", "result", ".", "Logging", "=", "logging", ".", "NewLogBackend", "(", "log", ",", "\"", "\"", ",", "0", ")", "\n", "if", "result", ".", "Trace", "==", "TRACE_DISABLED", "{", "result", ".", "Trace", "=", "TRACE_ENABLED", "\n", "}", "\n", "return", "&", "result", "\n", "}" ]
// WithLogger returns a shallow copy of the received SearchContext with the // logging set to write to 'log'.
[ "WithLogger", "returns", "a", "shallow", "copy", "of", "the", "received", "SearchContext", "with", "the", "logging", "set", "to", "write", "to", "log", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/policy.go#L116-L123
163,653
cilium/cilium
pkg/datapath/linux/ipsec/ipsec_linux.go
EnableIPv6Forwarding
func EnableIPv6Forwarding() error { ip6ConfPath := "/proc/sys/net/ipv6/conf/" device := "all" forwarding := "forwarding" forwardingOn := "1" path := filepath.Join(ip6ConfPath, device, forwarding) return ioutil.WriteFile(path, []byte(forwardingOn), 0644) }
go
func EnableIPv6Forwarding() error { ip6ConfPath := "/proc/sys/net/ipv6/conf/" device := "all" forwarding := "forwarding" forwardingOn := "1" path := filepath.Join(ip6ConfPath, device, forwarding) return ioutil.WriteFile(path, []byte(forwardingOn), 0644) }
[ "func", "EnableIPv6Forwarding", "(", ")", "error", "{", "ip6ConfPath", ":=", "\"", "\"", "\n", "device", ":=", "\"", "\"", "\n", "forwarding", ":=", "\"", "\"", "\n", "forwardingOn", ":=", "\"", "\"", "\n", "path", ":=", "filepath", ".", "Join", "(", "ip6ConfPath", ",", "device", ",", "forwarding", ")", "\n", "return", "ioutil", ".", "WriteFile", "(", "path", ",", "[", "]", "byte", "(", "forwardingOn", ")", ",", "0644", ")", "\n", "}" ]
// EnableIPv6Forwarding sets proc file to enable IPv6 forwarding
[ "EnableIPv6Forwarding", "sets", "proc", "file", "to", "enable", "IPv6", "forwarding" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/linux/ipsec/ipsec_linux.go#L409-L416
163,654
cilium/cilium
pkg/kvstore/dummy.go
SetupDummy
func SetupDummy(dummyBackend string) { module := getBackend(dummyBackend) if module == nil { log.Panicf("Unknown dummy kvstore backend %s", dummyBackend) } module.setConfigDummy() if err := initClient(module, nil); err != nil { log.WithError(err).Panic("Unable to initialize kvstore client") } }
go
func SetupDummy(dummyBackend string) { module := getBackend(dummyBackend) if module == nil { log.Panicf("Unknown dummy kvstore backend %s", dummyBackend) } module.setConfigDummy() if err := initClient(module, nil); err != nil { log.WithError(err).Panic("Unable to initialize kvstore client") } }
[ "func", "SetupDummy", "(", "dummyBackend", "string", ")", "{", "module", ":=", "getBackend", "(", "dummyBackend", ")", "\n", "if", "module", "==", "nil", "{", "log", ".", "Panicf", "(", "\"", "\"", ",", "dummyBackend", ")", "\n", "}", "\n\n", "module", ".", "setConfigDummy", "(", ")", "\n\n", "if", "err", ":=", "initClient", "(", "module", ",", "nil", ")", ";", "err", "!=", "nil", "{", "log", ".", "WithError", "(", "err", ")", ".", "Panic", "(", "\"", "\"", ")", "\n", "}", "\n", "}" ]
// SetupDummy sets up kvstore for tests
[ "SetupDummy", "sets", "up", "kvstore", "for", "tests" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/dummy.go#L18-L29
163,655
cilium/cilium
pkg/workloads/kubernetes.go
fetchK8sLabels
func fetchK8sLabels(containerID string, containerLbls map[string]string) (map[string]string, error) { if !k8s.IsEnabled() { return nil, nil } podName := k8sDockerLbls.GetPodName(containerLbls) if podName == "" { return nil, nil } ns := k8sDockerLbls.GetPodNamespace(containerLbls) if ns == "" { ns = "default" } return k8s.GetPodLabels(ns, podName) }
go
func fetchK8sLabels(containerID string, containerLbls map[string]string) (map[string]string, error) { if !k8s.IsEnabled() { return nil, nil } podName := k8sDockerLbls.GetPodName(containerLbls) if podName == "" { return nil, nil } ns := k8sDockerLbls.GetPodNamespace(containerLbls) if ns == "" { ns = "default" } return k8s.GetPodLabels(ns, podName) }
[ "func", "fetchK8sLabels", "(", "containerID", "string", ",", "containerLbls", "map", "[", "string", "]", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "if", "!", "k8s", ".", "IsEnabled", "(", ")", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "podName", ":=", "k8sDockerLbls", ".", "GetPodName", "(", "containerLbls", ")", "\n", "if", "podName", "==", "\"", "\"", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "ns", ":=", "k8sDockerLbls", ".", "GetPodNamespace", "(", "containerLbls", ")", "\n", "if", "ns", "==", "\"", "\"", "{", "ns", "=", "\"", "\"", "\n", "}", "\n", "return", "k8s", ".", "GetPodLabels", "(", "ns", ",", "podName", ")", "\n", "}" ]
// fetchK8sLabels returns the kubernetes labels from the given container labels
[ "fetchK8sLabels", "returns", "the", "kubernetes", "labels", "from", "the", "given", "container", "labels" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/workloads/kubernetes.go#L24-L37
163,656
cilium/cilium
pkg/workloads/config.go
setOpts
func setOpts(opts map[string]string, supportedOpts workloadRuntimeOpts) error { errors := 0 for key, val := range opts { opt, ok := supportedOpts[key] if !ok { errors++ log.Errorf("unknown workload runtime configuration key %q", key) continue } if opt.validate != nil { if err := opt.validate(val); err != nil { log.Errorf("invalid value for key %s: %s", key, err) errors++ } } } // if errors have occurred, print the supported configuration keys to // the log if errors > 0 { log.Error("Supported configuration keys:") for key, val := range supportedOpts { log.Errorf(" %-12s %s", key, val.description) } return fmt.Errorf("invalid workload runtime configuration, see log for details") } // modify the configuration atomically after verification for key, val := range opts { supportedOpts[key].value = val } return nil }
go
func setOpts(opts map[string]string, supportedOpts workloadRuntimeOpts) error { errors := 0 for key, val := range opts { opt, ok := supportedOpts[key] if !ok { errors++ log.Errorf("unknown workload runtime configuration key %q", key) continue } if opt.validate != nil { if err := opt.validate(val); err != nil { log.Errorf("invalid value for key %s: %s", key, err) errors++ } } } // if errors have occurred, print the supported configuration keys to // the log if errors > 0 { log.Error("Supported configuration keys:") for key, val := range supportedOpts { log.Errorf(" %-12s %s", key, val.description) } return fmt.Errorf("invalid workload runtime configuration, see log for details") } // modify the configuration atomically after verification for key, val := range opts { supportedOpts[key].value = val } return nil }
[ "func", "setOpts", "(", "opts", "map", "[", "string", "]", "string", ",", "supportedOpts", "workloadRuntimeOpts", ")", "error", "{", "errors", ":=", "0", "\n\n", "for", "key", ",", "val", ":=", "range", "opts", "{", "opt", ",", "ok", ":=", "supportedOpts", "[", "key", "]", "\n", "if", "!", "ok", "{", "errors", "++", "\n", "log", ".", "Errorf", "(", "\"", "\"", ",", "key", ")", "\n", "continue", "\n", "}", "\n\n", "if", "opt", ".", "validate", "!=", "nil", "{", "if", "err", ":=", "opt", ".", "validate", "(", "val", ")", ";", "err", "!=", "nil", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", "key", ",", "err", ")", "\n", "errors", "++", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "// if errors have occurred, print the supported configuration keys to", "// the log", "if", "errors", ">", "0", "{", "log", ".", "Error", "(", "\"", "\"", ")", "\n", "for", "key", ",", "val", ":=", "range", "supportedOpts", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", "key", ",", "val", ".", "description", ")", "\n", "}", "\n\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// modify the configuration atomically after verification", "for", "key", ",", "val", ":=", "range", "opts", "{", "supportedOpts", "[", "key", "]", ".", "value", "=", "val", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// setOpts validates the specified options against the selected workload runtime // and then modifies the configuration
[ "setOpts", "validates", "the", "specified", "options", "against", "the", "selected", "workload", "runtime", "and", "then", "modifies", "the", "configuration" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/workloads/config.go#L27-L64
163,657
cilium/cilium
pkg/workloads/config.go
Setup
func Setup(a allocatorInterface, workloadRuntimes []string, opts map[WorkloadRuntimeType]map[string]string) error { return setup(a, workloadRuntimes, opts, false) }
go
func Setup(a allocatorInterface, workloadRuntimes []string, opts map[WorkloadRuntimeType]map[string]string) error { return setup(a, workloadRuntimes, opts, false) }
[ "func", "Setup", "(", "a", "allocatorInterface", ",", "workloadRuntimes", "[", "]", "string", ",", "opts", "map", "[", "WorkloadRuntimeType", "]", "map", "[", "string", "]", "string", ")", "error", "{", "return", "setup", "(", "a", ",", "workloadRuntimes", ",", "opts", ",", "false", ")", "\n", "}" ]
// Setup sets up the workload runtime specified in workloadRuntime and configures it // with the options provided in opts
[ "Setup", "sets", "up", "the", "workload", "runtime", "specified", "in", "workloadRuntime", "and", "configures", "it", "with", "the", "options", "provided", "in", "opts" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/workloads/config.go#L100-L102
163,658
cilium/cilium
pkg/loadbalancer/loadbalancer.go
AddService
func (lb *LoadBalancer) AddService(svc LBSVC) bool { scopedLog := log.WithFields(logrus.Fields{ logfields.ServiceName: svc.FE.String(), logfields.SHA: svc.Sha256, }) oldSvc, ok := lb.SVCMapID[ServiceID(svc.FE.ID)] if ok { // If service already existed, remove old entry from Cilium's map scopedLog.Debug("service is already in lb.SVCMapID; deleting old entry and updating it with new entry") delete(lb.SVCMap, oldSvc.Sha256) updateMetric.Inc() } else { addMetric.Inc() } scopedLog.Debug("adding service to loadbalancer") lb.SVCMap[svc.Sha256] = svc lb.SVCMapID[ServiceID(svc.FE.ID)] = &svc return !ok }
go
func (lb *LoadBalancer) AddService(svc LBSVC) bool { scopedLog := log.WithFields(logrus.Fields{ logfields.ServiceName: svc.FE.String(), logfields.SHA: svc.Sha256, }) oldSvc, ok := lb.SVCMapID[ServiceID(svc.FE.ID)] if ok { // If service already existed, remove old entry from Cilium's map scopedLog.Debug("service is already in lb.SVCMapID; deleting old entry and updating it with new entry") delete(lb.SVCMap, oldSvc.Sha256) updateMetric.Inc() } else { addMetric.Inc() } scopedLog.Debug("adding service to loadbalancer") lb.SVCMap[svc.Sha256] = svc lb.SVCMapID[ServiceID(svc.FE.ID)] = &svc return !ok }
[ "func", "(", "lb", "*", "LoadBalancer", ")", "AddService", "(", "svc", "LBSVC", ")", "bool", "{", "scopedLog", ":=", "log", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "ServiceName", ":", "svc", ".", "FE", ".", "String", "(", ")", ",", "logfields", ".", "SHA", ":", "svc", ".", "Sha256", ",", "}", ")", "\n\n", "oldSvc", ",", "ok", ":=", "lb", ".", "SVCMapID", "[", "ServiceID", "(", "svc", ".", "FE", ".", "ID", ")", "]", "\n", "if", "ok", "{", "// If service already existed, remove old entry from Cilium's map", "scopedLog", ".", "Debug", "(", "\"", "\"", ")", "\n", "delete", "(", "lb", ".", "SVCMap", ",", "oldSvc", ".", "Sha256", ")", "\n", "updateMetric", ".", "Inc", "(", ")", "\n", "}", "else", "{", "addMetric", ".", "Inc", "(", ")", "\n", "}", "\n", "scopedLog", ".", "Debug", "(", "\"", "\"", ")", "\n", "lb", ".", "SVCMap", "[", "svc", ".", "Sha256", "]", "=", "svc", "\n", "lb", ".", "SVCMapID", "[", "ServiceID", "(", "svc", ".", "FE", ".", "ID", ")", "]", "=", "&", "svc", "\n", "return", "!", "ok", "\n", "}" ]
// AddService adds a service to list of loadbalancers and returns true if created.
[ "AddService", "adds", "a", "service", "to", "list", "of", "loadbalancers", "and", "returns", "true", "if", "created", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/loadbalancer/loadbalancer.go#L142-L161
163,659
cilium/cilium
pkg/loadbalancer/loadbalancer.go
DeleteService
func (lb *LoadBalancer) DeleteService(svc *LBSVC) { log.WithFields(logrus.Fields{ logfields.ServiceName: svc.FE.String(), logfields.SHA: svc.Sha256, }).Debug("deleting service from loadbalancer") delete(lb.SVCMap, svc.Sha256) delete(lb.SVCMapID, ServiceID(svc.FE.ID)) deleteMetric.Inc() }
go
func (lb *LoadBalancer) DeleteService(svc *LBSVC) { log.WithFields(logrus.Fields{ logfields.ServiceName: svc.FE.String(), logfields.SHA: svc.Sha256, }).Debug("deleting service from loadbalancer") delete(lb.SVCMap, svc.Sha256) delete(lb.SVCMapID, ServiceID(svc.FE.ID)) deleteMetric.Inc() }
[ "func", "(", "lb", "*", "LoadBalancer", ")", "DeleteService", "(", "svc", "*", "LBSVC", ")", "{", "log", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "ServiceName", ":", "svc", ".", "FE", ".", "String", "(", ")", ",", "logfields", ".", "SHA", ":", "svc", ".", "Sha256", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "delete", "(", "lb", ".", "SVCMap", ",", "svc", ".", "Sha256", ")", "\n", "delete", "(", "lb", ".", "SVCMapID", ",", "ServiceID", "(", "svc", ".", "FE", ".", "ID", ")", ")", "\n", "deleteMetric", ".", "Inc", "(", ")", "\n", "}" ]
// DeleteService deletes svc from lb's SVCMap and SVCMapID.
[ "DeleteService", "deletes", "svc", "from", "lb", "s", "SVCMap", "and", "SVCMapID", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/loadbalancer/loadbalancer.go#L164-L172
163,660
cilium/cilium
pkg/loadbalancer/loadbalancer.go
NewL4Addr
func NewL4Addr(protocol L4Type, number uint16) *L4Addr { return &L4Addr{Protocol: protocol, Port: number} }
go
func NewL4Addr(protocol L4Type, number uint16) *L4Addr { return &L4Addr{Protocol: protocol, Port: number} }
[ "func", "NewL4Addr", "(", "protocol", "L4Type", ",", "number", "uint16", ")", "*", "L4Addr", "{", "return", "&", "L4Addr", "{", "Protocol", ":", "protocol", ",", "Port", ":", "number", "}", "\n", "}" ]
// NewL4Addr creates a new L4Addr.
[ "NewL4Addr", "creates", "a", "new", "L4Addr", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/loadbalancer/loadbalancer.go#L202-L204
163,661
cilium/cilium
pkg/loadbalancer/loadbalancer.go
Equals
func (l *L4Addr) Equals(o *L4Addr) bool { switch { case (l == nil) != (o == nil): return false case (l == nil) && (o == nil): return true } return l.Port == o.Port && l.Protocol == o.Protocol }
go
func (l *L4Addr) Equals(o *L4Addr) bool { switch { case (l == nil) != (o == nil): return false case (l == nil) && (o == nil): return true } return l.Port == o.Port && l.Protocol == o.Protocol }
[ "func", "(", "l", "*", "L4Addr", ")", "Equals", "(", "o", "*", "L4Addr", ")", "bool", "{", "switch", "{", "case", "(", "l", "==", "nil", ")", "!=", "(", "o", "==", "nil", ")", ":", "return", "false", "\n", "case", "(", "l", "==", "nil", ")", "&&", "(", "o", "==", "nil", ")", ":", "return", "true", "\n", "}", "\n", "return", "l", ".", "Port", "==", "o", ".", "Port", "&&", "l", ".", "Protocol", "==", "o", ".", "Protocol", "\n", "}" ]
// Equals returns true if both L4Addr are considered equal.
[ "Equals", "returns", "true", "if", "both", "L4Addr", "are", "considered", "equal", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/loadbalancer/loadbalancer.go#L207-L215
163,662
cilium/cilium
pkg/loadbalancer/loadbalancer.go
DeepCopy
func (l *L4Addr) DeepCopy() *L4Addr { return &L4Addr{ Port: l.Port, Protocol: l.Protocol, } }
go
func (l *L4Addr) DeepCopy() *L4Addr { return &L4Addr{ Port: l.Port, Protocol: l.Protocol, } }
[ "func", "(", "l", "*", "L4Addr", ")", "DeepCopy", "(", ")", "*", "L4Addr", "{", "return", "&", "L4Addr", "{", "Port", ":", "l", ".", "Port", ",", "Protocol", ":", "l", ".", "Protocol", ",", "}", "\n", "}" ]
// DeepCopy returns a DeepCopy of the given L4Addr.
[ "DeepCopy", "returns", "a", "DeepCopy", "of", "the", "given", "L4Addr", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/loadbalancer/loadbalancer.go#L218-L223
163,663
cilium/cilium
pkg/loadbalancer/loadbalancer.go
NewFEPort
func NewFEPort(protocol L4Type, portNumber uint16) *FEPort { return &FEPort{L4Addr: NewL4Addr(protocol, portNumber)} }
go
func NewFEPort(protocol L4Type, portNumber uint16) *FEPort { return &FEPort{L4Addr: NewL4Addr(protocol, portNumber)} }
[ "func", "NewFEPort", "(", "protocol", "L4Type", ",", "portNumber", "uint16", ")", "*", "FEPort", "{", "return", "&", "FEPort", "{", "L4Addr", ":", "NewL4Addr", "(", "protocol", ",", "portNumber", ")", "}", "\n", "}" ]
// NewFEPort creates a new FEPort with the ID set to 0.
[ "NewFEPort", "creates", "a", "new", "FEPort", "with", "the", "ID", "set", "to", "0", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/loadbalancer/loadbalancer.go#L232-L234
163,664
cilium/cilium
pkg/loadbalancer/loadbalancer.go
EqualsIgnoreID
func (f *FEPort) EqualsIgnoreID(o *FEPort) bool { switch { case (f == nil) != (o == nil): return false case (f == nil) && (o == nil): return true } return f.L4Addr.Equals(o.L4Addr) }
go
func (f *FEPort) EqualsIgnoreID(o *FEPort) bool { switch { case (f == nil) != (o == nil): return false case (f == nil) && (o == nil): return true } return f.L4Addr.Equals(o.L4Addr) }
[ "func", "(", "f", "*", "FEPort", ")", "EqualsIgnoreID", "(", "o", "*", "FEPort", ")", "bool", "{", "switch", "{", "case", "(", "f", "==", "nil", ")", "!=", "(", "o", "==", "nil", ")", ":", "return", "false", "\n", "case", "(", "f", "==", "nil", ")", "&&", "(", "o", "==", "nil", ")", ":", "return", "true", "\n", "}", "\n", "return", "f", ".", "L4Addr", ".", "Equals", "(", "o", ".", "L4Addr", ")", "\n", "}" ]
// EqualsIgnoreID returns true if both L4Addr are considered equal without // comparing its ID.
[ "EqualsIgnoreID", "returns", "true", "if", "both", "L4Addr", "are", "considered", "equal", "without", "comparing", "its", "ID", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/loadbalancer/loadbalancer.go#L238-L246
163,665
cilium/cilium
pkg/loadbalancer/loadbalancer.go
NewL3n4Addr
func NewL3n4Addr(protocol L4Type, ip net.IP, portNumber uint16) *L3n4Addr { lbport := NewL4Addr(protocol, portNumber) addr := L3n4Addr{IP: ip, L4Addr: *lbport} log.WithField(logfields.IPAddr, addr).Debug("created new L3n4Addr") return &addr }
go
func NewL3n4Addr(protocol L4Type, ip net.IP, portNumber uint16) *L3n4Addr { lbport := NewL4Addr(protocol, portNumber) addr := L3n4Addr{IP: ip, L4Addr: *lbport} log.WithField(logfields.IPAddr, addr).Debug("created new L3n4Addr") return &addr }
[ "func", "NewL3n4Addr", "(", "protocol", "L4Type", ",", "ip", "net", ".", "IP", ",", "portNumber", "uint16", ")", "*", "L3n4Addr", "{", "lbport", ":=", "NewL4Addr", "(", "protocol", ",", "portNumber", ")", "\n\n", "addr", ":=", "L3n4Addr", "{", "IP", ":", "ip", ",", "L4Addr", ":", "*", "lbport", "}", "\n", "log", ".", "WithField", "(", "logfields", ".", "IPAddr", ",", "addr", ")", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "return", "&", "addr", "\n", "}" ]
// NewL3n4Addr creates a new L3n4Addr.
[ "NewL3n4Addr", "creates", "a", "new", "L3n4Addr", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/loadbalancer/loadbalancer.go#L266-L273
163,666
cilium/cilium
pkg/loadbalancer/loadbalancer.go
NewLBBackEnd
func NewLBBackEnd(id BackendID, protocol L4Type, ip net.IP, portNumber uint16, weight uint16) *LBBackEnd { lbport := NewL4Addr(protocol, portNumber) lbbe := LBBackEnd{ ID: BackendID(id), L3n4Addr: L3n4Addr{IP: ip, L4Addr: *lbport}, Weight: weight, } log.WithField("backend", lbbe).Debug("created new LBBackend") return &lbbe }
go
func NewLBBackEnd(id BackendID, protocol L4Type, ip net.IP, portNumber uint16, weight uint16) *LBBackEnd { lbport := NewL4Addr(protocol, portNumber) lbbe := LBBackEnd{ ID: BackendID(id), L3n4Addr: L3n4Addr{IP: ip, L4Addr: *lbport}, Weight: weight, } log.WithField("backend", lbbe).Debug("created new LBBackend") return &lbbe }
[ "func", "NewLBBackEnd", "(", "id", "BackendID", ",", "protocol", "L4Type", ",", "ip", "net", ".", "IP", ",", "portNumber", "uint16", ",", "weight", "uint16", ")", "*", "LBBackEnd", "{", "lbport", ":=", "NewL4Addr", "(", "protocol", ",", "portNumber", ")", "\n", "lbbe", ":=", "LBBackEnd", "{", "ID", ":", "BackendID", "(", "id", ")", ",", "L3n4Addr", ":", "L3n4Addr", "{", "IP", ":", "ip", ",", "L4Addr", ":", "*", "lbport", "}", ",", "Weight", ":", "weight", ",", "}", "\n", "log", ".", "WithField", "(", "\"", "\"", ",", "lbbe", ")", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "return", "&", "lbbe", "\n", "}" ]
// NewLBBackEnd creates the LBBackEnd struct instance from given params.
[ "NewLBBackEnd", "creates", "the", "LBBackEnd", "struct", "instance", "from", "given", "params", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/loadbalancer/loadbalancer.go#L303-L313
163,667
cilium/cilium
pkg/loadbalancer/loadbalancer.go
DeepCopy
func (a *L3n4Addr) DeepCopy() *L3n4Addr { copyIP := make(net.IP, len(a.IP)) copy(copyIP, a.IP) return &L3n4Addr{ IP: copyIP, L4Addr: *a.L4Addr.DeepCopy(), } }
go
func (a *L3n4Addr) DeepCopy() *L3n4Addr { copyIP := make(net.IP, len(a.IP)) copy(copyIP, a.IP) return &L3n4Addr{ IP: copyIP, L4Addr: *a.L4Addr.DeepCopy(), } }
[ "func", "(", "a", "*", "L3n4Addr", ")", "DeepCopy", "(", ")", "*", "L3n4Addr", "{", "copyIP", ":=", "make", "(", "net", ".", "IP", ",", "len", "(", "a", ".", "IP", ")", ")", "\n", "copy", "(", "copyIP", ",", "a", ".", "IP", ")", "\n", "return", "&", "L3n4Addr", "{", "IP", ":", "copyIP", ",", "L4Addr", ":", "*", "a", ".", "L4Addr", ".", "DeepCopy", "(", ")", ",", "}", "\n", "}" ]
// DeepCopy returns a DeepCopy of the given L3n4Addr.
[ "DeepCopy", "returns", "a", "DeepCopy", "of", "the", "given", "L3n4Addr", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/loadbalancer/loadbalancer.go#L397-L404
163,668
cilium/cilium
pkg/loadbalancer/loadbalancer.go
SHA256Sum
func (a L3n4Addr) SHA256Sum() string { // FIXME: Remove Protocol's omission once we care about protocols. protoBak := a.Protocol a.Protocol = "" defer func() { a.Protocol = protoBak }() str := []byte(fmt.Sprintf("%+v", a)) return fmt.Sprintf("%x", sha512.Sum512_256(str)) }
go
func (a L3n4Addr) SHA256Sum() string { // FIXME: Remove Protocol's omission once we care about protocols. protoBak := a.Protocol a.Protocol = "" defer func() { a.Protocol = protoBak }() str := []byte(fmt.Sprintf("%+v", a)) return fmt.Sprintf("%x", sha512.Sum512_256(str)) }
[ "func", "(", "a", "L3n4Addr", ")", "SHA256Sum", "(", ")", "string", "{", "// FIXME: Remove Protocol's omission once we care about protocols.", "protoBak", ":=", "a", ".", "Protocol", "\n", "a", ".", "Protocol", "=", "\"", "\"", "\n", "defer", "func", "(", ")", "{", "a", ".", "Protocol", "=", "protoBak", "\n", "}", "(", ")", "\n\n", "str", ":=", "[", "]", "byte", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "a", ")", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "sha512", ".", "Sum512_256", "(", "str", ")", ")", "\n", "}" ]
// SHA256Sum calculates L3n4Addr's internal SHA256Sum.
[ "SHA256Sum", "calculates", "L3n4Addr", "s", "internal", "SHA256Sum", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/loadbalancer/loadbalancer.go#L407-L417
163,669
cilium/cilium
pkg/loadbalancer/loadbalancer.go
NewL3n4AddrID
func NewL3n4AddrID(protocol L4Type, ip net.IP, portNumber uint16, id ID) *L3n4AddrID { l3n4Addr := NewL3n4Addr(protocol, ip, portNumber) return &L3n4AddrID{L3n4Addr: *l3n4Addr, ID: id} }
go
func NewL3n4AddrID(protocol L4Type, ip net.IP, portNumber uint16, id ID) *L3n4AddrID { l3n4Addr := NewL3n4Addr(protocol, ip, portNumber) return &L3n4AddrID{L3n4Addr: *l3n4Addr, ID: id} }
[ "func", "NewL3n4AddrID", "(", "protocol", "L4Type", ",", "ip", "net", ".", "IP", ",", "portNumber", "uint16", ",", "id", "ID", ")", "*", "L3n4AddrID", "{", "l3n4Addr", ":=", "NewL3n4Addr", "(", "protocol", ",", "ip", ",", "portNumber", ")", "\n", "return", "&", "L3n4AddrID", "{", "L3n4Addr", ":", "*", "l3n4Addr", ",", "ID", ":", "id", "}", "\n", "}" ]
// NewL3n4AddrID creates a new L3n4AddrID.
[ "NewL3n4AddrID", "creates", "a", "new", "L3n4AddrID", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/loadbalancer/loadbalancer.go#L432-L435
163,670
cilium/cilium
pkg/loadbalancer/loadbalancer.go
DeepCopy
func (l *L3n4AddrID) DeepCopy() *L3n4AddrID { return &L3n4AddrID{ L3n4Addr: *l.L3n4Addr.DeepCopy(), ID: l.ID, } }
go
func (l *L3n4AddrID) DeepCopy() *L3n4AddrID { return &L3n4AddrID{ L3n4Addr: *l.L3n4Addr.DeepCopy(), ID: l.ID, } }
[ "func", "(", "l", "*", "L3n4AddrID", ")", "DeepCopy", "(", ")", "*", "L3n4AddrID", "{", "return", "&", "L3n4AddrID", "{", "L3n4Addr", ":", "*", "l", ".", "L3n4Addr", ".", "DeepCopy", "(", ")", ",", "ID", ":", "l", ".", "ID", ",", "}", "\n\n", "}" ]
// DeepCopy returns a DeepCopy of the given L3n4AddrID.
[ "DeepCopy", "returns", "a", "DeepCopy", "of", "the", "given", "L3n4AddrID", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/loadbalancer/loadbalancer.go#L438-L444
163,671
cilium/cilium
pkg/loadbalancer/loadbalancer.go
AddFEnBE
func (svcs SVCMap) AddFEnBE(fe *L3n4AddrID, be *LBBackEnd, beIndex int) *LBSVC { log.WithFields(logrus.Fields{ "frontend": fe, "backend": be, "backendIndex": beIndex, }).Debug("adding frontend and backend to SVCMap") sha := fe.SHA256Sum() var lbsvc LBSVC lbsvc, ok := svcs[sha] if !ok { var bes []LBBackEnd if beIndex == 0 { bes = make([]LBBackEnd, 1) bes[0] = *be } else { bes = make([]LBBackEnd, beIndex) bes[beIndex-1] = *be } lbsvc = LBSVC{ FE: *fe, BES: bes, } } else { var bes []LBBackEnd if len(lbsvc.BES) < beIndex { bes = make([]LBBackEnd, beIndex) for i, lbsvcBE := range lbsvc.BES { bes[i] = lbsvcBE } lbsvc.BES = bes } if beIndex == 0 { lbsvc.BES = append(lbsvc.BES, *be) } else { lbsvc.BES[beIndex-1] = *be } } lbsvc.Sha256 = sha svcs[sha] = lbsvc return &lbsvc }
go
func (svcs SVCMap) AddFEnBE(fe *L3n4AddrID, be *LBBackEnd, beIndex int) *LBSVC { log.WithFields(logrus.Fields{ "frontend": fe, "backend": be, "backendIndex": beIndex, }).Debug("adding frontend and backend to SVCMap") sha := fe.SHA256Sum() var lbsvc LBSVC lbsvc, ok := svcs[sha] if !ok { var bes []LBBackEnd if beIndex == 0 { bes = make([]LBBackEnd, 1) bes[0] = *be } else { bes = make([]LBBackEnd, beIndex) bes[beIndex-1] = *be } lbsvc = LBSVC{ FE: *fe, BES: bes, } } else { var bes []LBBackEnd if len(lbsvc.BES) < beIndex { bes = make([]LBBackEnd, beIndex) for i, lbsvcBE := range lbsvc.BES { bes[i] = lbsvcBE } lbsvc.BES = bes } if beIndex == 0 { lbsvc.BES = append(lbsvc.BES, *be) } else { lbsvc.BES[beIndex-1] = *be } } lbsvc.Sha256 = sha svcs[sha] = lbsvc return &lbsvc }
[ "func", "(", "svcs", "SVCMap", ")", "AddFEnBE", "(", "fe", "*", "L3n4AddrID", ",", "be", "*", "LBBackEnd", ",", "beIndex", "int", ")", "*", "LBSVC", "{", "log", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "\"", "\"", ":", "fe", ",", "\"", "\"", ":", "be", ",", "\"", "\"", ":", "beIndex", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "sha", ":=", "fe", ".", "SHA256Sum", "(", ")", "\n\n", "var", "lbsvc", "LBSVC", "\n", "lbsvc", ",", "ok", ":=", "svcs", "[", "sha", "]", "\n", "if", "!", "ok", "{", "var", "bes", "[", "]", "LBBackEnd", "\n", "if", "beIndex", "==", "0", "{", "bes", "=", "make", "(", "[", "]", "LBBackEnd", ",", "1", ")", "\n", "bes", "[", "0", "]", "=", "*", "be", "\n", "}", "else", "{", "bes", "=", "make", "(", "[", "]", "LBBackEnd", ",", "beIndex", ")", "\n", "bes", "[", "beIndex", "-", "1", "]", "=", "*", "be", "\n", "}", "\n", "lbsvc", "=", "LBSVC", "{", "FE", ":", "*", "fe", ",", "BES", ":", "bes", ",", "}", "\n", "}", "else", "{", "var", "bes", "[", "]", "LBBackEnd", "\n", "if", "len", "(", "lbsvc", ".", "BES", ")", "<", "beIndex", "{", "bes", "=", "make", "(", "[", "]", "LBBackEnd", ",", "beIndex", ")", "\n", "for", "i", ",", "lbsvcBE", ":=", "range", "lbsvc", ".", "BES", "{", "bes", "[", "i", "]", "=", "lbsvcBE", "\n", "}", "\n", "lbsvc", ".", "BES", "=", "bes", "\n", "}", "\n", "if", "beIndex", "==", "0", "{", "lbsvc", ".", "BES", "=", "append", "(", "lbsvc", ".", "BES", ",", "*", "be", ")", "\n", "}", "else", "{", "lbsvc", ".", "BES", "[", "beIndex", "-", "1", "]", "=", "*", "be", "\n", "}", "\n", "}", "\n\n", "lbsvc", ".", "Sha256", "=", "sha", "\n", "svcs", "[", "sha", "]", "=", "lbsvc", "\n", "return", "&", "lbsvc", "\n", "}" ]
// AddFEnBE adds the given 'fe' and 'be' to the SVCMap. If 'fe' exists and beIndex is 0, // the new 'be' will be appended to the list of existing backends. If beIndex is bigger // than the size of existing backends slice, it will be created a new array with size of // beIndex and the new 'be' will be inserted on index beIndex-1 of that new array. All // remaining be elements will be kept on the same index and, in case the new array is // larger than the number of backends, some elements will be empty.
[ "AddFEnBE", "adds", "the", "given", "fe", "and", "be", "to", "the", "SVCMap", ".", "If", "fe", "exists", "and", "beIndex", "is", "0", "the", "new", "be", "will", "be", "appended", "to", "the", "list", "of", "existing", "backends", ".", "If", "beIndex", "is", "bigger", "than", "the", "size", "of", "existing", "backends", "slice", "it", "will", "be", "created", "a", "new", "array", "with", "size", "of", "beIndex", "and", "the", "new", "be", "will", "be", "inserted", "on", "index", "beIndex", "-", "1", "of", "that", "new", "array", ".", "All", "remaining", "be", "elements", "will", "be", "kept", "on", "the", "same", "index", "and", "in", "case", "the", "new", "array", "is", "larger", "than", "the", "number", "of", "backends", "some", "elements", "will", "be", "empty", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/loadbalancer/loadbalancer.go#L457-L499
163,672
cilium/cilium
pkg/bpf/perf_linux.go
allocateBuffers
func (e *PerfEvent) allocateBuffers() { // C.malloc() will crash the program if allocation fails, skip check: // https://golang.org/cmd/cgo/ e.state = C.malloc(C.size_t(unsafe.Sizeof(C.struct_read_state{}))) e.buf = C.malloc(C.size_t(e.pagesize)) }
go
func (e *PerfEvent) allocateBuffers() { // C.malloc() will crash the program if allocation fails, skip check: // https://golang.org/cmd/cgo/ e.state = C.malloc(C.size_t(unsafe.Sizeof(C.struct_read_state{}))) e.buf = C.malloc(C.size_t(e.pagesize)) }
[ "func", "(", "e", "*", "PerfEvent", ")", "allocateBuffers", "(", ")", "{", "// C.malloc() will crash the program if allocation fails, skip check:", "// https://golang.org/cmd/cgo/", "e", ".", "state", "=", "C", ".", "malloc", "(", "C", ".", "size_t", "(", "unsafe", ".", "Sizeof", "(", "C", ".", "struct_read_state", "{", "}", ")", ")", ")", "\n", "e", ".", "buf", "=", "C", ".", "malloc", "(", "C", ".", "size_t", "(", "e", ".", "pagesize", ")", ")", "\n", "}" ]
// allocateBuffers initializes the buffers for sharing between Golang and C.
[ "allocateBuffers", "initializes", "the", "buffers", "for", "sharing", "between", "Golang", "and", "C", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/perf_linux.go#L374-L379
163,673
cilium/cilium
pkg/bpf/perf_linux.go
Debug
func (e *PerfEvent) Debug() string { return fmt.Sprintf("cpu: %d, Fd: %d, pagesize: %d, npages: %d, lost: %d, unknown: %d, state: %v", e.cpu, e.Fd, e.pagesize, e.npages, e.lost, e.unknown, C.GoBytes(e.state, C.sizeof_struct_read_state)) }
go
func (e *PerfEvent) Debug() string { return fmt.Sprintf("cpu: %d, Fd: %d, pagesize: %d, npages: %d, lost: %d, unknown: %d, state: %v", e.cpu, e.Fd, e.pagesize, e.npages, e.lost, e.unknown, C.GoBytes(e.state, C.sizeof_struct_read_state)) }
[ "func", "(", "e", "*", "PerfEvent", ")", "Debug", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "cpu", ",", "e", ".", "Fd", ",", "e", ".", "pagesize", ",", "e", ".", "npages", ",", "e", ".", "lost", ",", "e", ".", "unknown", ",", "C", ".", "GoBytes", "(", "e", ".", "state", ",", "C", ".", "sizeof_struct_read_state", ")", ")", "\n", "}" ]
// Debug returns string with internal information about PerfEvent
[ "Debug", "returns", "string", "with", "internal", "information", "about", "PerfEvent" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/perf_linux.go#L497-L499
163,674
cilium/cilium
pkg/bpf/perf_linux.go
ReadAll
func (e *PerCpuEvents) ReadAll(receive ReceiveFunc, lost LostFunc, handleError ErrorFunc) error { for i := 0; i < e.poll.nfds; i++ { fd := int(e.poll.events[i].Fd) if event, ok := e.event[fd]; ok { event.Read(receive, lost, handleError) } } return nil }
go
func (e *PerCpuEvents) ReadAll(receive ReceiveFunc, lost LostFunc, handleError ErrorFunc) error { for i := 0; i < e.poll.nfds; i++ { fd := int(e.poll.events[i].Fd) if event, ok := e.event[fd]; ok { event.Read(receive, lost, handleError) } } return nil }
[ "func", "(", "e", "*", "PerCpuEvents", ")", "ReadAll", "(", "receive", "ReceiveFunc", ",", "lost", "LostFunc", ",", "handleError", "ErrorFunc", ")", "error", "{", "for", "i", ":=", "0", ";", "i", "<", "e", ".", "poll", ".", "nfds", ";", "i", "++", "{", "fd", ":=", "int", "(", "e", ".", "poll", ".", "events", "[", "i", "]", ".", "Fd", ")", "\n", "if", "event", ",", "ok", ":=", "e", ".", "event", "[", "fd", "]", ";", "ok", "{", "event", ".", "Read", "(", "receive", ",", "lost", ",", "handleError", ")", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// ReadAll reads perf events
[ "ReadAll", "reads", "perf", "events" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/perf_linux.go#L640-L649
163,675
cilium/cilium
pkg/bpf/perf_linux.go
decode
func decode(i interface{}, reader io.ReadSeeker) error { value := reflect.ValueOf(i).Elem() decodeSize := int64(reflect.TypeOf(value).Size()) if _, err := reader.Seek(decodeSize, io.SeekStart); err != nil { return fmt.Errorf("failed to seek into reader %d bytes", decodeSize) } _, _ = reader.Seek(0, io.SeekStart) for i := 0; i < value.NumField(); i++ { if err := binary.Read(reader, binary.LittleEndian, value.Field(i).Addr().Interface()); err != nil { return fmt.Errorf("failed to decode field %d", i) } } return nil }
go
func decode(i interface{}, reader io.ReadSeeker) error { value := reflect.ValueOf(i).Elem() decodeSize := int64(reflect.TypeOf(value).Size()) if _, err := reader.Seek(decodeSize, io.SeekStart); err != nil { return fmt.Errorf("failed to seek into reader %d bytes", decodeSize) } _, _ = reader.Seek(0, io.SeekStart) for i := 0; i < value.NumField(); i++ { if err := binary.Read(reader, binary.LittleEndian, value.Field(i).Addr().Interface()); err != nil { return fmt.Errorf("failed to decode field %d", i) } } return nil }
[ "func", "decode", "(", "i", "interface", "{", "}", ",", "reader", "io", ".", "ReadSeeker", ")", "error", "{", "value", ":=", "reflect", ".", "ValueOf", "(", "i", ")", ".", "Elem", "(", ")", "\n", "decodeSize", ":=", "int64", "(", "reflect", ".", "TypeOf", "(", "value", ")", ".", "Size", "(", ")", ")", "\n", "if", "_", ",", "err", ":=", "reader", ".", "Seek", "(", "decodeSize", ",", "io", ".", "SeekStart", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "decodeSize", ")", "\n", "}", "\n", "_", ",", "_", "=", "reader", ".", "Seek", "(", "0", ",", "io", ".", "SeekStart", ")", "\n\n", "for", "i", ":=", "0", ";", "i", "<", "value", ".", "NumField", "(", ")", ";", "i", "++", "{", "if", "err", ":=", "binary", ".", "Read", "(", "reader", ",", "binary", ".", "LittleEndian", ",", "value", ".", "Field", "(", "i", ")", ".", "Addr", "(", ")", ".", "Interface", "(", ")", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "i", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// decode uses reflection to read bytes directly from 'reader' into the object // pointed to from 'i'. Assumes that 'i' is a pointer. // // This function should not be used from performance-sensitive code.
[ "decode", "uses", "reflection", "to", "read", "bytes", "directly", "from", "reader", "into", "the", "object", "pointed", "to", "from", "i", ".", "Assumes", "that", "i", "is", "a", "pointer", ".", "This", "function", "should", "not", "be", "used", "from", "performance", "-", "sensitive", "code", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/perf_linux.go#L685-L699
163,676
cilium/cilium
pkg/bpf/perf_linux.go
Decode
func (r *ReadState) Decode(reader io.ReadSeeker) error { return decode(r, reader) }
go
func (r *ReadState) Decode(reader io.ReadSeeker) error { return decode(r, reader) }
[ "func", "(", "r", "*", "ReadState", ")", "Decode", "(", "reader", "io", ".", "ReadSeeker", ")", "error", "{", "return", "decode", "(", "r", ",", "reader", ")", "\n", "}" ]
// Decode populates 'r' based on the bytes read from the specified reader. // // This function should not be used from performance-sensitive code.
[ "Decode", "populates", "r", "based", "on", "the", "bytes", "read", "from", "the", "specified", "reader", ".", "This", "function", "should", "not", "be", "used", "from", "performance", "-", "sensitive", "code", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/perf_linux.go#L711-L713
163,677
cilium/cilium
pkg/bpf/perf_linux.go
Decode
func (p *PerfEventMmapPage) Decode(reader io.ReadSeeker) error { return decode(p, reader) }
go
func (p *PerfEventMmapPage) Decode(reader io.ReadSeeker) error { return decode(p, reader) }
[ "func", "(", "p", "*", "PerfEventMmapPage", ")", "Decode", "(", "reader", "io", ".", "ReadSeeker", ")", "error", "{", "return", "decode", "(", "p", ",", "reader", ")", "\n", "}" ]
// Decode populates 'p' base on the bytes read from the specified reader. // // This function should not be used from performance-sensitive code.
[ "Decode", "populates", "p", "base", "on", "the", "bytes", "read", "from", "the", "specified", "reader", ".", "This", "function", "should", "not", "be", "used", "from", "performance", "-", "sensitive", "code", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/perf_linux.go#L761-L763
163,678
cilium/cilium
pkg/cgroups/cgroups.go
mountCgroup
func mountCgroup() error { cgroupRootStat, err := os.Stat(cgroupRoot) if err != nil { if os.IsNotExist(err) { if err := os.MkdirAll(cgroupRoot, 0755); err != nil { return fmt.Errorf("Unable to create cgroup mount directory: %s", err) } } else { return fmt.Errorf("Failed to stat the mount path %s: %s", cgroupRoot, err) } } else if !cgroupRootStat.IsDir() { return fmt.Errorf("%s is a file which is not a directory", cgroupRoot) } if err := syscall.Mount("none", cgroupRoot, mountinfo.FilesystemTypeCgroup2, 0, ""); err != nil { return fmt.Errorf("failed to mount %s: %s", cgroupRoot, err) } return nil }
go
func mountCgroup() error { cgroupRootStat, err := os.Stat(cgroupRoot) if err != nil { if os.IsNotExist(err) { if err := os.MkdirAll(cgroupRoot, 0755); err != nil { return fmt.Errorf("Unable to create cgroup mount directory: %s", err) } } else { return fmt.Errorf("Failed to stat the mount path %s: %s", cgroupRoot, err) } } else if !cgroupRootStat.IsDir() { return fmt.Errorf("%s is a file which is not a directory", cgroupRoot) } if err := syscall.Mount("none", cgroupRoot, mountinfo.FilesystemTypeCgroup2, 0, ""); err != nil { return fmt.Errorf("failed to mount %s: %s", cgroupRoot, err) } return nil }
[ "func", "mountCgroup", "(", ")", "error", "{", "cgroupRootStat", ",", "err", ":=", "os", ".", "Stat", "(", "cgroupRoot", ")", "\n", "if", "err", "!=", "nil", "{", "if", "os", ".", "IsNotExist", "(", "err", ")", "{", "if", "err", ":=", "os", ".", "MkdirAll", "(", "cgroupRoot", ",", "0755", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "}", "else", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "cgroupRoot", ",", "err", ")", "\n", "}", "\n", "}", "else", "if", "!", "cgroupRootStat", ".", "IsDir", "(", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "cgroupRoot", ")", "\n", "}", "\n\n", "if", "err", ":=", "syscall", ".", "Mount", "(", "\"", "\"", ",", "cgroupRoot", ",", "mountinfo", ".", "FilesystemTypeCgroup2", ",", "0", ",", "\"", "\"", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "cgroupRoot", ",", "err", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// mountCgroup mounts the Cgroup v2 filesystem into the desired cgroupRoot directory.
[ "mountCgroup", "mounts", "the", "Cgroup", "v2", "filesystem", "into", "the", "desired", "cgroupRoot", "directory", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/cgroups/cgroups.go#L50-L69
163,679
cilium/cilium
pkg/cgroups/cgroups.go
CheckOrMountCgrpFS
func CheckOrMountCgrpFS(mapRoot string) { cgrpMountOnce.Do(func() { if mapRoot == "" { mapRoot = cgroupRoot } err := cgrpCheckOrMountLocation(mapRoot) // Failed cgroup2 mount is not a fatal error, sockmap will be disabled however if err == nil { log.Infof("Mounted cgroupv2 filesystem at %s", mapRoot) } }) }
go
func CheckOrMountCgrpFS(mapRoot string) { cgrpMountOnce.Do(func() { if mapRoot == "" { mapRoot = cgroupRoot } err := cgrpCheckOrMountLocation(mapRoot) // Failed cgroup2 mount is not a fatal error, sockmap will be disabled however if err == nil { log.Infof("Mounted cgroupv2 filesystem at %s", mapRoot) } }) }
[ "func", "CheckOrMountCgrpFS", "(", "mapRoot", "string", ")", "{", "cgrpMountOnce", ".", "Do", "(", "func", "(", ")", "{", "if", "mapRoot", "==", "\"", "\"", "{", "mapRoot", "=", "cgroupRoot", "\n", "}", "\n", "err", ":=", "cgrpCheckOrMountLocation", "(", "mapRoot", ")", "\n", "// Failed cgroup2 mount is not a fatal error, sockmap will be disabled however", "if", "err", "==", "nil", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "mapRoot", ")", "\n", "}", "\n", "}", ")", "\n", "}" ]
// CheckOrMountCgrpFS this checks if the cilium cgroup2 root mount point is // mounted and if not mounts it. If mapRoot is "" it will mount the default // location. It is harmless to have multiple cgroupv2 root mounts so unlike // BPFFS case we simply mount at the cilium default regardless if the system // has another mount created by systemd or otherwise.
[ "CheckOrMountCgrpFS", "this", "checks", "if", "the", "cilium", "cgroup2", "root", "mount", "point", "is", "mounted", "and", "if", "not", "mounts", "it", ".", "If", "mapRoot", "is", "it", "will", "mount", "the", "default", "location", ".", "It", "is", "harmless", "to", "have", "multiple", "cgroupv2", "root", "mounts", "so", "unlike", "BPFFS", "case", "we", "simply", "mount", "at", "the", "cilium", "default", "regardless", "if", "the", "system", "has", "another", "mount", "created", "by", "systemd", "or", "otherwise", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/cgroups/cgroups.go#L100-L111
163,680
cilium/cilium
pkg/proxy/logger/logger.go
fillEndpointInfo
func (lr *LogRecord) fillEndpointInfo(info *accesslog.EndpointInfo, ip net.IP) { if ip.To4() != nil { info.IPv4 = ip.String() // first we try to resolve and check if the IP is // same as Host if node.IsHostIPv4(ip) { lr.endpointInfoRegistry.FillEndpointIdentityByID(identity.ReservedIdentityHost, info) } else if !lr.endpointInfoRegistry.FillEndpointIdentityByIP(ip, info) { // If we are unable to resolve the HostIP as well // as the cluster IP we mark this as a 'world' identity. lr.endpointInfoRegistry.FillEndpointIdentityByID(identity.ReservedIdentityWorld, info) } } else { info.IPv6 = ip.String() if node.IsHostIPv6(ip) { lr.endpointInfoRegistry.FillEndpointIdentityByID(identity.ReservedIdentityHost, info) } else if !lr.endpointInfoRegistry.FillEndpointIdentityByIP(ip, info) { lr.endpointInfoRegistry.FillEndpointIdentityByID(identity.ReservedIdentityWorld, info) } } }
go
func (lr *LogRecord) fillEndpointInfo(info *accesslog.EndpointInfo, ip net.IP) { if ip.To4() != nil { info.IPv4 = ip.String() // first we try to resolve and check if the IP is // same as Host if node.IsHostIPv4(ip) { lr.endpointInfoRegistry.FillEndpointIdentityByID(identity.ReservedIdentityHost, info) } else if !lr.endpointInfoRegistry.FillEndpointIdentityByIP(ip, info) { // If we are unable to resolve the HostIP as well // as the cluster IP we mark this as a 'world' identity. lr.endpointInfoRegistry.FillEndpointIdentityByID(identity.ReservedIdentityWorld, info) } } else { info.IPv6 = ip.String() if node.IsHostIPv6(ip) { lr.endpointInfoRegistry.FillEndpointIdentityByID(identity.ReservedIdentityHost, info) } else if !lr.endpointInfoRegistry.FillEndpointIdentityByIP(ip, info) { lr.endpointInfoRegistry.FillEndpointIdentityByID(identity.ReservedIdentityWorld, info) } } }
[ "func", "(", "lr", "*", "LogRecord", ")", "fillEndpointInfo", "(", "info", "*", "accesslog", ".", "EndpointInfo", ",", "ip", "net", ".", "IP", ")", "{", "if", "ip", ".", "To4", "(", ")", "!=", "nil", "{", "info", ".", "IPv4", "=", "ip", ".", "String", "(", ")", "\n\n", "// first we try to resolve and check if the IP is", "// same as Host", "if", "node", ".", "IsHostIPv4", "(", "ip", ")", "{", "lr", ".", "endpointInfoRegistry", ".", "FillEndpointIdentityByID", "(", "identity", ".", "ReservedIdentityHost", ",", "info", ")", "\n", "}", "else", "if", "!", "lr", ".", "endpointInfoRegistry", ".", "FillEndpointIdentityByIP", "(", "ip", ",", "info", ")", "{", "// If we are unable to resolve the HostIP as well", "// as the cluster IP we mark this as a 'world' identity.", "lr", ".", "endpointInfoRegistry", ".", "FillEndpointIdentityByID", "(", "identity", ".", "ReservedIdentityWorld", ",", "info", ")", "\n", "}", "\n", "}", "else", "{", "info", ".", "IPv6", "=", "ip", ".", "String", "(", ")", "\n\n", "if", "node", ".", "IsHostIPv6", "(", "ip", ")", "{", "lr", ".", "endpointInfoRegistry", ".", "FillEndpointIdentityByID", "(", "identity", ".", "ReservedIdentityHost", ",", "info", ")", "\n", "}", "else", "if", "!", "lr", ".", "endpointInfoRegistry", ".", "FillEndpointIdentityByIP", "(", "ip", ",", "info", ")", "{", "lr", ".", "endpointInfoRegistry", ".", "FillEndpointIdentityByID", "(", "identity", ".", "ReservedIdentityWorld", ",", "info", ")", "\n", "}", "\n", "}", "\n", "}" ]
// fillEndpointInfo tries to resolve the IP address and fills the EndpointInfo // fields with either ReservedIdentityHost or ReservedIdentityWorld
[ "fillEndpointInfo", "tries", "to", "resolve", "the", "IP", "address", "and", "fills", "the", "EndpointInfo", "fields", "with", "either", "ReservedIdentityHost", "or", "ReservedIdentityWorld" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/logger/logger.go#L122-L144
163,681
cilium/cilium
pkg/proxy/logger/logger.go
fillIngressSourceInfo
func (lr *LogRecord) fillIngressSourceInfo(info *accesslog.EndpointInfo, ip *net.IP, srcIdentity uint32) { if srcIdentity != 0 { if ip != nil { if ip.To4() != nil { info.IPv4 = ip.String() } else { info.IPv6 = ip.String() } } lr.endpointInfoRegistry.FillEndpointIdentityByID(identity.NumericIdentity(srcIdentity), info) } else { // source security identity 0 is possible when somebody else other than // the BPF datapath attempts to // connect to the proxy. // We should try to resolve if the identity belongs to reserved_host // or reserved_world. if ip != nil { lr.fillEndpointInfo(info, *ip) } else { log.Warn("Missing security identity in source endpoint info") } } }
go
func (lr *LogRecord) fillIngressSourceInfo(info *accesslog.EndpointInfo, ip *net.IP, srcIdentity uint32) { if srcIdentity != 0 { if ip != nil { if ip.To4() != nil { info.IPv4 = ip.String() } else { info.IPv6 = ip.String() } } lr.endpointInfoRegistry.FillEndpointIdentityByID(identity.NumericIdentity(srcIdentity), info) } else { // source security identity 0 is possible when somebody else other than // the BPF datapath attempts to // connect to the proxy. // We should try to resolve if the identity belongs to reserved_host // or reserved_world. if ip != nil { lr.fillEndpointInfo(info, *ip) } else { log.Warn("Missing security identity in source endpoint info") } } }
[ "func", "(", "lr", "*", "LogRecord", ")", "fillIngressSourceInfo", "(", "info", "*", "accesslog", ".", "EndpointInfo", ",", "ip", "*", "net", ".", "IP", ",", "srcIdentity", "uint32", ")", "{", "if", "srcIdentity", "!=", "0", "{", "if", "ip", "!=", "nil", "{", "if", "ip", ".", "To4", "(", ")", "!=", "nil", "{", "info", ".", "IPv4", "=", "ip", ".", "String", "(", ")", "\n", "}", "else", "{", "info", ".", "IPv6", "=", "ip", ".", "String", "(", ")", "\n", "}", "\n", "}", "\n", "lr", ".", "endpointInfoRegistry", ".", "FillEndpointIdentityByID", "(", "identity", ".", "NumericIdentity", "(", "srcIdentity", ")", ",", "info", ")", "\n", "}", "else", "{", "// source security identity 0 is possible when somebody else other than", "// the BPF datapath attempts to", "// connect to the proxy.", "// We should try to resolve if the identity belongs to reserved_host", "// or reserved_world.", "if", "ip", "!=", "nil", "{", "lr", ".", "fillEndpointInfo", "(", "info", ",", "*", "ip", ")", "\n", "}", "else", "{", "log", ".", "Warn", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "}" ]
// fillIngressSourceInfo fills the EndpointInfo fields using identity sent by // source. This is needed in ingress proxy while logging the source endpoint // info. Since there will be 2 proxies on the same host, if both egress and // ingress policies are set, the ingress policy cannot determine the source // endpoint info based on ip address, as the ip address would be that of the // egress proxy i.e host.
[ "fillIngressSourceInfo", "fills", "the", "EndpointInfo", "fields", "using", "identity", "sent", "by", "source", ".", "This", "is", "needed", "in", "ingress", "proxy", "while", "logging", "the", "source", "endpoint", "info", ".", "Since", "there", "will", "be", "2", "proxies", "on", "the", "same", "host", "if", "both", "egress", "and", "ingress", "policies", "are", "set", "the", "ingress", "policy", "cannot", "determine", "the", "source", "endpoint", "info", "based", "on", "ip", "address", "as", "the", "ip", "address", "would", "be", "that", "of", "the", "egress", "proxy", "i", ".", "e", "host", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/logger/logger.go#L152-L174
163,682
cilium/cilium
pkg/proxy/logger/logger.go
fillEgressDestinationInfo
func (lr *LogRecord) fillEgressDestinationInfo(info *accesslog.EndpointInfo, ipstr string) { ip := net.ParseIP(ipstr) if ip != nil { lr.fillEndpointInfo(info, ip) } }
go
func (lr *LogRecord) fillEgressDestinationInfo(info *accesslog.EndpointInfo, ipstr string) { ip := net.ParseIP(ipstr) if ip != nil { lr.fillEndpointInfo(info, ip) } }
[ "func", "(", "lr", "*", "LogRecord", ")", "fillEgressDestinationInfo", "(", "info", "*", "accesslog", ".", "EndpointInfo", ",", "ipstr", "string", ")", "{", "ip", ":=", "net", ".", "ParseIP", "(", "ipstr", ")", "\n", "if", "ip", "!=", "nil", "{", "lr", ".", "fillEndpointInfo", "(", "info", ",", "ip", ")", "\n", "}", "\n", "}" ]
// fillEgressDestinationInfo returns the destination EndpointInfo for a flow // leaving the proxy at egress.
[ "fillEgressDestinationInfo", "returns", "the", "destination", "EndpointInfo", "for", "a", "flow", "leaving", "the", "proxy", "at", "egress", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/logger/logger.go#L178-L183
163,683
cilium/cilium
pkg/proxy/logger/logger.go
Verdict
func (logTags) Verdict(v accesslog.FlowVerdict, info string) LogTag { return func(lr *LogRecord) { lr.Verdict = v lr.Info = info } }
go
func (logTags) Verdict(v accesslog.FlowVerdict, info string) LogTag { return func(lr *LogRecord) { lr.Verdict = v lr.Info = info } }
[ "func", "(", "logTags", ")", "Verdict", "(", "v", "accesslog", ".", "FlowVerdict", ",", "info", "string", ")", "LogTag", "{", "return", "func", "(", "lr", "*", "LogRecord", ")", "{", "lr", ".", "Verdict", "=", "v", "\n", "lr", ".", "Info", "=", "info", "\n", "}", "\n", "}" ]
// Verdict attachs verdict information to the log record
[ "Verdict", "attachs", "verdict", "information", "to", "the", "log", "record" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/logger/logger.go#L195-L200
163,684
cilium/cilium
pkg/proxy/logger/logger.go
Timestamp
func (logTags) Timestamp(ts time.Time) LogTag { return func(lr *LogRecord) { lr.Timestamp = ts.UTC().Format(time.RFC3339Nano) } }
go
func (logTags) Timestamp(ts time.Time) LogTag { return func(lr *LogRecord) { lr.Timestamp = ts.UTC().Format(time.RFC3339Nano) } }
[ "func", "(", "logTags", ")", "Timestamp", "(", "ts", "time", ".", "Time", ")", "LogTag", "{", "return", "func", "(", "lr", "*", "LogRecord", ")", "{", "lr", ".", "Timestamp", "=", "ts", ".", "UTC", "(", ")", ".", "Format", "(", "time", ".", "RFC3339Nano", ")", "\n", "}", "\n", "}" ]
// Timestamp overwrites the starting timestamp of the log record
[ "Timestamp", "overwrites", "the", "starting", "timestamp", "of", "the", "log", "record" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/logger/logger.go#L203-L207
163,685
cilium/cilium
pkg/proxy/logger/logger.go
Addressing
func (logTags) Addressing(i AddressingInfo) LogTag { return func(lr *LogRecord) { switch lr.ObservationPoint { case accesslog.Ingress: lr.DestinationEndpoint = *lr.localEndpointInfo case accesslog.Egress: lr.SourceEndpoint = *lr.localEndpointInfo } ipstr, port, err := net.SplitHostPort(i.SrcIPPort) if err == nil { ip := net.ParseIP(ipstr) if ip != nil && ip.To4() == nil { lr.IPVersion = accesslog.VersionIPV6 } p, err := strconv.ParseUint(port, 10, 16) if err == nil { lr.SourceEndpoint.Port = uint16(p) if lr.ObservationPoint == accesslog.Ingress { lr.fillIngressSourceInfo(&lr.SourceEndpoint, &ip, i.SrcIdentity) } } } ipstr, port, err = net.SplitHostPort(i.DstIPPort) if err == nil { p, err := strconv.ParseUint(port, 10, 16) if err == nil { lr.DestinationEndpoint.Port = uint16(p) if lr.ObservationPoint == accesslog.Egress { lr.fillEgressDestinationInfo(&lr.DestinationEndpoint, ipstr) } } } } }
go
func (logTags) Addressing(i AddressingInfo) LogTag { return func(lr *LogRecord) { switch lr.ObservationPoint { case accesslog.Ingress: lr.DestinationEndpoint = *lr.localEndpointInfo case accesslog.Egress: lr.SourceEndpoint = *lr.localEndpointInfo } ipstr, port, err := net.SplitHostPort(i.SrcIPPort) if err == nil { ip := net.ParseIP(ipstr) if ip != nil && ip.To4() == nil { lr.IPVersion = accesslog.VersionIPV6 } p, err := strconv.ParseUint(port, 10, 16) if err == nil { lr.SourceEndpoint.Port = uint16(p) if lr.ObservationPoint == accesslog.Ingress { lr.fillIngressSourceInfo(&lr.SourceEndpoint, &ip, i.SrcIdentity) } } } ipstr, port, err = net.SplitHostPort(i.DstIPPort) if err == nil { p, err := strconv.ParseUint(port, 10, 16) if err == nil { lr.DestinationEndpoint.Port = uint16(p) if lr.ObservationPoint == accesslog.Egress { lr.fillEgressDestinationInfo(&lr.DestinationEndpoint, ipstr) } } } } }
[ "func", "(", "logTags", ")", "Addressing", "(", "i", "AddressingInfo", ")", "LogTag", "{", "return", "func", "(", "lr", "*", "LogRecord", ")", "{", "switch", "lr", ".", "ObservationPoint", "{", "case", "accesslog", ".", "Ingress", ":", "lr", ".", "DestinationEndpoint", "=", "*", "lr", ".", "localEndpointInfo", "\n", "case", "accesslog", ".", "Egress", ":", "lr", ".", "SourceEndpoint", "=", "*", "lr", ".", "localEndpointInfo", "\n", "}", "\n\n", "ipstr", ",", "port", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "i", ".", "SrcIPPort", ")", "\n", "if", "err", "==", "nil", "{", "ip", ":=", "net", ".", "ParseIP", "(", "ipstr", ")", "\n", "if", "ip", "!=", "nil", "&&", "ip", ".", "To4", "(", ")", "==", "nil", "{", "lr", ".", "IPVersion", "=", "accesslog", ".", "VersionIPV6", "\n", "}", "\n\n", "p", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "port", ",", "10", ",", "16", ")", "\n", "if", "err", "==", "nil", "{", "lr", ".", "SourceEndpoint", ".", "Port", "=", "uint16", "(", "p", ")", "\n", "if", "lr", ".", "ObservationPoint", "==", "accesslog", ".", "Ingress", "{", "lr", ".", "fillIngressSourceInfo", "(", "&", "lr", ".", "SourceEndpoint", ",", "&", "ip", ",", "i", ".", "SrcIdentity", ")", "\n", "}", "\n", "}", "\n", "}", "\n\n", "ipstr", ",", "port", ",", "err", "=", "net", ".", "SplitHostPort", "(", "i", ".", "DstIPPort", ")", "\n", "if", "err", "==", "nil", "{", "p", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "port", ",", "10", ",", "16", ")", "\n", "if", "err", "==", "nil", "{", "lr", ".", "DestinationEndpoint", ".", "Port", "=", "uint16", "(", "p", ")", "\n", "if", "lr", ".", "ObservationPoint", "==", "accesslog", ".", "Egress", "{", "lr", ".", "fillEgressDestinationInfo", "(", "&", "lr", ".", "DestinationEndpoint", ",", "ipstr", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "}" ]
// Addressing attaches addressing information about the source and destination // to the logrecord
[ "Addressing", "attaches", "addressing", "information", "about", "the", "source", "and", "destination", "to", "the", "logrecord" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/logger/logger.go#L218-L254
163,686
cilium/cilium
pkg/proxy/logger/logger.go
HTTP
func (logTags) HTTP(h *accesslog.LogRecordHTTP) LogTag { return func(lr *LogRecord) { lr.HTTP = h } }
go
func (logTags) HTTP(h *accesslog.LogRecordHTTP) LogTag { return func(lr *LogRecord) { lr.HTTP = h } }
[ "func", "(", "logTags", ")", "HTTP", "(", "h", "*", "accesslog", ".", "LogRecordHTTP", ")", "LogTag", "{", "return", "func", "(", "lr", "*", "LogRecord", ")", "{", "lr", ".", "HTTP", "=", "h", "\n", "}", "\n", "}" ]
// HTTP attaches HTTP information to the log record
[ "HTTP", "attaches", "HTTP", "information", "to", "the", "log", "record" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/logger/logger.go#L257-L261
163,687
cilium/cilium
pkg/proxy/logger/logger.go
Kafka
func (logTags) Kafka(k *accesslog.LogRecordKafka) LogTag { return func(lr *LogRecord) { lr.Kafka = k } }
go
func (logTags) Kafka(k *accesslog.LogRecordKafka) LogTag { return func(lr *LogRecord) { lr.Kafka = k } }
[ "func", "(", "logTags", ")", "Kafka", "(", "k", "*", "accesslog", ".", "LogRecordKafka", ")", "LogTag", "{", "return", "func", "(", "lr", "*", "LogRecord", ")", "{", "lr", ".", "Kafka", "=", "k", "\n", "}", "\n", "}" ]
// Kafka attaches Kafka information to the log record
[ "Kafka", "attaches", "Kafka", "information", "to", "the", "log", "record" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/logger/logger.go#L264-L268
163,688
cilium/cilium
pkg/proxy/logger/logger.go
DNS
func (logTags) DNS(d *accesslog.LogRecordDNS) LogTag { return func(lr *LogRecord) { lr.DNS = d } }
go
func (logTags) DNS(d *accesslog.LogRecordDNS) LogTag { return func(lr *LogRecord) { lr.DNS = d } }
[ "func", "(", "logTags", ")", "DNS", "(", "d", "*", "accesslog", ".", "LogRecordDNS", ")", "LogTag", "{", "return", "func", "(", "lr", "*", "LogRecord", ")", "{", "lr", ".", "DNS", "=", "d", "\n", "}", "\n", "}" ]
// DNS attaches DNS information to the log record
[ "DNS", "attaches", "DNS", "information", "to", "the", "log", "record" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/logger/logger.go#L271-L275
163,689
cilium/cilium
pkg/proxy/logger/logger.go
L7
func (logTags) L7(h *accesslog.LogRecordL7) LogTag { return func(lr *LogRecord) { lr.L7 = h } }
go
func (logTags) L7(h *accesslog.LogRecordL7) LogTag { return func(lr *LogRecord) { lr.L7 = h } }
[ "func", "(", "logTags", ")", "L7", "(", "h", "*", "accesslog", ".", "LogRecordL7", ")", "LogTag", "{", "return", "func", "(", "lr", "*", "LogRecord", ")", "{", "lr", ".", "L7", "=", "h", "\n", "}", "\n", "}" ]
// L7 attaches generic L7 information to the log record
[ "L7", "attaches", "generic", "L7", "information", "to", "the", "log", "record" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/logger/logger.go#L278-L282
163,690
cilium/cilium
pkg/proxy/logger/logger.go
Log
func (lr *LogRecord) Log() { flowdebug.Log(lr.getLogFields(), "Logging flow record") // Lock while writing access log so we serialize writes as we may have // to reopen the logfile and parallel writes could fail because of that logMutex.Lock() defer logMutex.Unlock() lr.Metadata = metadata if notifier != nil { notifier.NewProxyLogRecord(lr) } if logger == nil { flowdebug.Log(log.WithField(FieldFilePath, logPath), "Skipping writing to access log (logger nil)") return } if _, err := logger.Write(lr.getRawLogMessage()); err != nil { log.WithError(err).WithField(FieldFilePath, logPath). Errorf("Error writing to access file") } }
go
func (lr *LogRecord) Log() { flowdebug.Log(lr.getLogFields(), "Logging flow record") // Lock while writing access log so we serialize writes as we may have // to reopen the logfile and parallel writes could fail because of that logMutex.Lock() defer logMutex.Unlock() lr.Metadata = metadata if notifier != nil { notifier.NewProxyLogRecord(lr) } if logger == nil { flowdebug.Log(log.WithField(FieldFilePath, logPath), "Skipping writing to access log (logger nil)") return } if _, err := logger.Write(lr.getRawLogMessage()); err != nil { log.WithError(err).WithField(FieldFilePath, logPath). Errorf("Error writing to access file") } }
[ "func", "(", "lr", "*", "LogRecord", ")", "Log", "(", ")", "{", "flowdebug", ".", "Log", "(", "lr", ".", "getLogFields", "(", ")", ",", "\"", "\"", ")", "\n\n", "// Lock while writing access log so we serialize writes as we may have", "// to reopen the logfile and parallel writes could fail because of that", "logMutex", ".", "Lock", "(", ")", "\n", "defer", "logMutex", ".", "Unlock", "(", ")", "\n\n", "lr", ".", "Metadata", "=", "metadata", "\n\n", "if", "notifier", "!=", "nil", "{", "notifier", ".", "NewProxyLogRecord", "(", "lr", ")", "\n", "}", "\n\n", "if", "logger", "==", "nil", "{", "flowdebug", ".", "Log", "(", "log", ".", "WithField", "(", "FieldFilePath", ",", "logPath", ")", ",", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "if", "_", ",", "err", ":=", "logger", ".", "Write", "(", "lr", ".", "getRawLogMessage", "(", ")", ")", ";", "err", "!=", "nil", "{", "log", ".", "WithError", "(", "err", ")", ".", "WithField", "(", "FieldFilePath", ",", "logPath", ")", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "}" ]
// Log logs a record to the logfile and flushes the buffer
[ "Log", "logs", "a", "record", "to", "the", "logfile", "and", "flushes", "the", "buffer" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/logger/logger.go#L333-L357
163,691
cilium/cilium
pkg/proxy/logger/logger.go
openLogfileLocked
func openLogfileLocked(lf string) error { logPath = lf log.WithField(FieldFilePath, logPath).Info("Opened access log") logger = &lumberjack.Logger{ Filename: lf, MaxSize: 100, // megabytes MaxBackups: 3, MaxAge: 28, //days Compress: true, // disabled by default } return nil }
go
func openLogfileLocked(lf string) error { logPath = lf log.WithField(FieldFilePath, logPath).Info("Opened access log") logger = &lumberjack.Logger{ Filename: lf, MaxSize: 100, // megabytes MaxBackups: 3, MaxAge: 28, //days Compress: true, // disabled by default } return nil }
[ "func", "openLogfileLocked", "(", "lf", "string", ")", "error", "{", "logPath", "=", "lf", "\n", "log", ".", "WithField", "(", "FieldFilePath", ",", "logPath", ")", ".", "Info", "(", "\"", "\"", ")", "\n\n", "logger", "=", "&", "lumberjack", ".", "Logger", "{", "Filename", ":", "lf", ",", "MaxSize", ":", "100", ",", "// megabytes", "MaxBackups", ":", "3", ",", "MaxAge", ":", "28", ",", "//days", "Compress", ":", "true", ",", "// disabled by default", "}", "\n\n", "return", "nil", "\n", "}" ]
// Called with lock held
[ "Called", "with", "lock", "held" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/logger/logger.go#L360-L373
163,692
cilium/cilium
pkg/proxy/logger/logger.go
OpenLogfile
func OpenLogfile(lf string) error { logMutex.Lock() defer logMutex.Unlock() return openLogfileLocked(lf) }
go
func OpenLogfile(lf string) error { logMutex.Lock() defer logMutex.Unlock() return openLogfileLocked(lf) }
[ "func", "OpenLogfile", "(", "lf", "string", ")", "error", "{", "logMutex", ".", "Lock", "(", ")", "\n", "defer", "logMutex", ".", "Unlock", "(", ")", "\n\n", "return", "openLogfileLocked", "(", "lf", ")", "\n", "}" ]
// OpenLogfile opens a file for logging
[ "OpenLogfile", "opens", "a", "file", "for", "logging" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/logger/logger.go#L382-L387
163,693
cilium/cilium
pkg/endpoint/endpoint_status.go
GetCiliumEndpointStatus
func (e *Endpoint) GetCiliumEndpointStatus() *cilium_v2.EndpointStatus { e.mutex.RLock() defer e.mutex.RUnlock() model := e.GetModelRLocked() modelStatus := model.Status controllers := getEndpointStatusControllers(modelStatus) identity := getEndpointIdentity(modelStatus) log := e.getEndpointStatusLog() networking := getEndpointNetworking(modelStatus) return &cilium_v2.EndpointStatus{ ID: int64(e.ID), ExternalIdentifiers: modelStatus.ExternalIdentifiers, Controllers: controllers, Identity: identity, Log: log, Networking: networking, Health: modelStatus.Health, State: string(modelStatus.State), Policy: e.getEndpointPolicy(), // Scheduled for deprecation in 1.5 // // Status is deprecated but we have some users depending on // these fields so they continue to be populated until version // 1.5 Status: &cilium_v2.DeprecatedEndpointStatus{ Controllers: controllers, Identity: identity, Log: log, Networking: networking, }, } }
go
func (e *Endpoint) GetCiliumEndpointStatus() *cilium_v2.EndpointStatus { e.mutex.RLock() defer e.mutex.RUnlock() model := e.GetModelRLocked() modelStatus := model.Status controllers := getEndpointStatusControllers(modelStatus) identity := getEndpointIdentity(modelStatus) log := e.getEndpointStatusLog() networking := getEndpointNetworking(modelStatus) return &cilium_v2.EndpointStatus{ ID: int64(e.ID), ExternalIdentifiers: modelStatus.ExternalIdentifiers, Controllers: controllers, Identity: identity, Log: log, Networking: networking, Health: modelStatus.Health, State: string(modelStatus.State), Policy: e.getEndpointPolicy(), // Scheduled for deprecation in 1.5 // // Status is deprecated but we have some users depending on // these fields so they continue to be populated until version // 1.5 Status: &cilium_v2.DeprecatedEndpointStatus{ Controllers: controllers, Identity: identity, Log: log, Networking: networking, }, } }
[ "func", "(", "e", "*", "Endpoint", ")", "GetCiliumEndpointStatus", "(", ")", "*", "cilium_v2", ".", "EndpointStatus", "{", "e", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "e", ".", "mutex", ".", "RUnlock", "(", ")", "\n\n", "model", ":=", "e", ".", "GetModelRLocked", "(", ")", "\n", "modelStatus", ":=", "model", ".", "Status", "\n\n", "controllers", ":=", "getEndpointStatusControllers", "(", "modelStatus", ")", "\n", "identity", ":=", "getEndpointIdentity", "(", "modelStatus", ")", "\n", "log", ":=", "e", ".", "getEndpointStatusLog", "(", ")", "\n", "networking", ":=", "getEndpointNetworking", "(", "modelStatus", ")", "\n\n", "return", "&", "cilium_v2", ".", "EndpointStatus", "{", "ID", ":", "int64", "(", "e", ".", "ID", ")", ",", "ExternalIdentifiers", ":", "modelStatus", ".", "ExternalIdentifiers", ",", "Controllers", ":", "controllers", ",", "Identity", ":", "identity", ",", "Log", ":", "log", ",", "Networking", ":", "networking", ",", "Health", ":", "modelStatus", ".", "Health", ",", "State", ":", "string", "(", "modelStatus", ".", "State", ")", ",", "Policy", ":", "e", ".", "getEndpointPolicy", "(", ")", ",", "// Scheduled for deprecation in 1.5", "//", "// Status is deprecated but we have some users depending on", "// these fields so they continue to be populated until version", "// 1.5", "Status", ":", "&", "cilium_v2", ".", "DeprecatedEndpointStatus", "{", "Controllers", ":", "controllers", ",", "Identity", ":", "identity", ",", "Log", ":", "log", ",", "Networking", ":", "networking", ",", "}", ",", "}", "\n", "}" ]
// GetCiliumEndpointStatus creates a cilium_v2.EndpointStatus of an endpoint. // See cilium_v2.EndpointStatus for a detailed explanation of each field.
[ "GetCiliumEndpointStatus", "creates", "a", "cilium_v2", ".", "EndpointStatus", "of", "an", "endpoint", ".", "See", "cilium_v2", ".", "EndpointStatus", "for", "a", "detailed", "explanation", "of", "each", "field", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint_status.go#L216-L251
163,694
cilium/cilium
api/v1/client/daemon/get_map_name_parameters.go
WithTimeout
func (o *GetMapNameParams) WithTimeout(timeout time.Duration) *GetMapNameParams { o.SetTimeout(timeout) return o }
go
func (o *GetMapNameParams) WithTimeout(timeout time.Duration) *GetMapNameParams { o.SetTimeout(timeout) return o }
[ "func", "(", "o", "*", "GetMapNameParams", ")", "WithTimeout", "(", "timeout", "time", ".", "Duration", ")", "*", "GetMapNameParams", "{", "o", ".", "SetTimeout", "(", "timeout", ")", "\n", "return", "o", "\n", "}" ]
// WithTimeout adds the timeout to the get map name params
[ "WithTimeout", "adds", "the", "timeout", "to", "the", "get", "map", "name", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/daemon/get_map_name_parameters.go#L76-L79
163,695
cilium/cilium
api/v1/client/daemon/get_map_name_parameters.go
WithContext
func (o *GetMapNameParams) WithContext(ctx context.Context) *GetMapNameParams { o.SetContext(ctx) return o }
go
func (o *GetMapNameParams) WithContext(ctx context.Context) *GetMapNameParams { o.SetContext(ctx) return o }
[ "func", "(", "o", "*", "GetMapNameParams", ")", "WithContext", "(", "ctx", "context", ".", "Context", ")", "*", "GetMapNameParams", "{", "o", ".", "SetContext", "(", "ctx", ")", "\n", "return", "o", "\n", "}" ]
// WithContext adds the context to the get map name params
[ "WithContext", "adds", "the", "context", "to", "the", "get", "map", "name", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/daemon/get_map_name_parameters.go#L87-L90
163,696
cilium/cilium
api/v1/client/daemon/get_map_name_parameters.go
WithHTTPClient
func (o *GetMapNameParams) WithHTTPClient(client *http.Client) *GetMapNameParams { o.SetHTTPClient(client) return o }
go
func (o *GetMapNameParams) WithHTTPClient(client *http.Client) *GetMapNameParams { o.SetHTTPClient(client) return o }
[ "func", "(", "o", "*", "GetMapNameParams", ")", "WithHTTPClient", "(", "client", "*", "http", ".", "Client", ")", "*", "GetMapNameParams", "{", "o", ".", "SetHTTPClient", "(", "client", ")", "\n", "return", "o", "\n", "}" ]
// WithHTTPClient adds the HTTPClient to the get map name params
[ "WithHTTPClient", "adds", "the", "HTTPClient", "to", "the", "get", "map", "name", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/daemon/get_map_name_parameters.go#L98-L101
163,697
cilium/cilium
api/v1/client/daemon/get_map_name_parameters.go
WithName
func (o *GetMapNameParams) WithName(name string) *GetMapNameParams { o.SetName(name) return o }
go
func (o *GetMapNameParams) WithName(name string) *GetMapNameParams { o.SetName(name) return o }
[ "func", "(", "o", "*", "GetMapNameParams", ")", "WithName", "(", "name", "string", ")", "*", "GetMapNameParams", "{", "o", ".", "SetName", "(", "name", ")", "\n", "return", "o", "\n", "}" ]
// WithName adds the name to the get map name params
[ "WithName", "adds", "the", "name", "to", "the", "get", "map", "name", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/daemon/get_map_name_parameters.go#L109-L112
163,698
cilium/cilium
pkg/maps/sockmap/sockmap.go
NewSockmapKey
func NewSockmapKey(dip, sip net.IP, sport, dport uint32) SockmapKey { result := SockmapKey{} if sip4 := sip.To4(); sip4 != nil { result.Family = bpf.EndpointKeyIPv4 copy(result.SIP[:], sip4) } else { result.Family = bpf.EndpointKeyIPv6 copy(result.SIP[:], sip) } if dip4 := dip.To4(); dip4 != nil { result.Family = bpf.EndpointKeyIPv4 copy(result.SIP[:], dip4) } else { result.Family = bpf.EndpointKeyIPv6 copy(result.DIP[:], dip) } result.DPort = dport result.SPort = sport return result }
go
func NewSockmapKey(dip, sip net.IP, sport, dport uint32) SockmapKey { result := SockmapKey{} if sip4 := sip.To4(); sip4 != nil { result.Family = bpf.EndpointKeyIPv4 copy(result.SIP[:], sip4) } else { result.Family = bpf.EndpointKeyIPv6 copy(result.SIP[:], sip) } if dip4 := dip.To4(); dip4 != nil { result.Family = bpf.EndpointKeyIPv4 copy(result.SIP[:], dip4) } else { result.Family = bpf.EndpointKeyIPv6 copy(result.DIP[:], dip) } result.DPort = dport result.SPort = sport return result }
[ "func", "NewSockmapKey", "(", "dip", ",", "sip", "net", ".", "IP", ",", "sport", ",", "dport", "uint32", ")", "SockmapKey", "{", "result", ":=", "SockmapKey", "{", "}", "\n\n", "if", "sip4", ":=", "sip", ".", "To4", "(", ")", ";", "sip4", "!=", "nil", "{", "result", ".", "Family", "=", "bpf", ".", "EndpointKeyIPv4", "\n", "copy", "(", "result", ".", "SIP", "[", ":", "]", ",", "sip4", ")", "\n", "}", "else", "{", "result", ".", "Family", "=", "bpf", ".", "EndpointKeyIPv6", "\n", "copy", "(", "result", ".", "SIP", "[", ":", "]", ",", "sip", ")", "\n", "}", "\n\n", "if", "dip4", ":=", "dip", ".", "To4", "(", ")", ";", "dip4", "!=", "nil", "{", "result", ".", "Family", "=", "bpf", ".", "EndpointKeyIPv4", "\n", "copy", "(", "result", ".", "SIP", "[", ":", "]", ",", "dip4", ")", "\n", "}", "else", "{", "result", ".", "Family", "=", "bpf", ".", "EndpointKeyIPv6", "\n", "copy", "(", "result", ".", "DIP", "[", ":", "]", ",", "dip", ")", "\n", "}", "\n\n", "result", ".", "DPort", "=", "dport", "\n", "result", ".", "SPort", "=", "sport", "\n", "return", "result", "\n", "}" ]
// NewSockmapKey returns a new key using 5-tuple input.
[ "NewSockmapKey", "returns", "a", "new", "key", "using", "5", "-", "tuple", "input", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/sockmap/sockmap.go#L65-L87
163,699
cilium/cilium
api/v1/server/restapi/policy/delete_policy.go
NewDeletePolicy
func NewDeletePolicy(ctx *middleware.Context, handler DeletePolicyHandler) *DeletePolicy { return &DeletePolicy{Context: ctx, Handler: handler} }
go
func NewDeletePolicy(ctx *middleware.Context, handler DeletePolicyHandler) *DeletePolicy { return &DeletePolicy{Context: ctx, Handler: handler} }
[ "func", "NewDeletePolicy", "(", "ctx", "*", "middleware", ".", "Context", ",", "handler", "DeletePolicyHandler", ")", "*", "DeletePolicy", "{", "return", "&", "DeletePolicy", "{", "Context", ":", "ctx", ",", "Handler", ":", "handler", "}", "\n", "}" ]
// NewDeletePolicy creates a new http.Handler for the delete policy operation
[ "NewDeletePolicy", "creates", "a", "new", "http", ".", "Handler", "for", "the", "delete", "policy", "operation" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/delete_policy.go#L28-L30