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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
163,300 | cilium/cilium | api/v1/client/service/get_service_id_parameters.go | WithTimeout | func (o *GetServiceIDParams) WithTimeout(timeout time.Duration) *GetServiceIDParams {
o.SetTimeout(timeout)
return o
} | go | func (o *GetServiceIDParams) WithTimeout(timeout time.Duration) *GetServiceIDParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"GetServiceIDParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"GetServiceIDParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the get service ID params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"get",
"service",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/service/get_service_id_parameters.go#L77-L80 |
163,301 | cilium/cilium | api/v1/client/service/get_service_id_parameters.go | WithContext | func (o *GetServiceIDParams) WithContext(ctx context.Context) *GetServiceIDParams {
o.SetContext(ctx)
return o
} | go | func (o *GetServiceIDParams) WithContext(ctx context.Context) *GetServiceIDParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"GetServiceIDParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"GetServiceIDParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the get service ID params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"get",
"service",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/service/get_service_id_parameters.go#L88-L91 |
163,302 | cilium/cilium | api/v1/client/service/get_service_id_parameters.go | WithHTTPClient | func (o *GetServiceIDParams) WithHTTPClient(client *http.Client) *GetServiceIDParams {
o.SetHTTPClient(client)
return o
} | go | func (o *GetServiceIDParams) WithHTTPClient(client *http.Client) *GetServiceIDParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"GetServiceIDParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"GetServiceIDParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the get service ID params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"get",
"service",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/service/get_service_id_parameters.go#L99-L102 |
163,303 | cilium/cilium | api/v1/client/service/get_service_id_parameters.go | WithID | func (o *GetServiceIDParams) WithID(id int64) *GetServiceIDParams {
o.SetID(id)
return o
} | go | func (o *GetServiceIDParams) WithID(id int64) *GetServiceIDParams {
o.SetID(id)
return o
} | [
"func",
"(",
"o",
"*",
"GetServiceIDParams",
")",
"WithID",
"(",
"id",
"int64",
")",
"*",
"GetServiceIDParams",
"{",
"o",
".",
"SetID",
"(",
"id",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithID adds the id to the get service ID params | [
"WithID",
"adds",
"the",
"id",
"to",
"the",
"get",
"service",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/service/get_service_id_parameters.go#L110-L113 |
163,304 | cilium/cilium | pkg/k8s/apis/cilium.io/utils/utils.go | GetPolicyLabels | func GetPolicyLabels(ns, name string, uid types.UID, derivedFrom string) labels.LabelArray {
// Keep labels sorted by the key.
return labels.LabelArray{
labels.NewLabel(k8sConst.PolicyLabelDerivedFrom, derivedFrom, labels.LabelSourceK8s),
labels.NewLabel(k8sConst.PolicyLabelName, name, labels.LabelSourceK8s),
labels.NewLabel(k8sConst.PolicyLabelNamespace, ns, labels.LabelSourceK8s),
labels.NewLabel(k8sConst.PolicyLabelUID, string(uid), labels.LabelSourceK8s),
}
} | go | func GetPolicyLabels(ns, name string, uid types.UID, derivedFrom string) labels.LabelArray {
// Keep labels sorted by the key.
return labels.LabelArray{
labels.NewLabel(k8sConst.PolicyLabelDerivedFrom, derivedFrom, labels.LabelSourceK8s),
labels.NewLabel(k8sConst.PolicyLabelName, name, labels.LabelSourceK8s),
labels.NewLabel(k8sConst.PolicyLabelNamespace, ns, labels.LabelSourceK8s),
labels.NewLabel(k8sConst.PolicyLabelUID, string(uid), labels.LabelSourceK8s),
}
} | [
"func",
"GetPolicyLabels",
"(",
"ns",
",",
"name",
"string",
",",
"uid",
"types",
".",
"UID",
",",
"derivedFrom",
"string",
")",
"labels",
".",
"LabelArray",
"{",
"// Keep labels sorted by the key.",
"return",
"labels",
".",
"LabelArray",
"{",
"labels",
".",
"... | // GetPolicyLabels returns a LabelArray for the given namespace and name. | [
"GetPolicyLabels",
"returns",
"a",
"LabelArray",
"for",
"the",
"given",
"namespace",
"and",
"name",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/utils/utils.go#L55-L63 |
163,305 | cilium/cilium | pkg/k8s/apis/cilium.io/utils/utils.go | getEndpointSelector | func getEndpointSelector(namespace string, labelSelector *metav1.LabelSelector, addK8sPrefix, matchesInit bool) api.EndpointSelector {
es := api.NewESFromK8sLabelSelector("", labelSelector)
// The k8s prefix must not be added to reserved labels.
if addK8sPrefix && es.HasKeyPrefix(labels.LabelSourceReservedKeyPrefix) {
return es
}
// The user can explicitly specify the namespace in the
// FromEndpoints selector. If omitted, we limit the
// scope to the namespace the policy lives in.
//
// Policies applying on initializing pods are a special case.
// Those pods don't have any labels, so they don't have a namespace label either.
// Don't add a namespace label to those endpoint selectors, or we wouldn't be
// able to match on those pods.
if !matchesInit && !es.HasKey(podPrefixLbl) && !es.HasKey(podAnyPrefixLbl) {
es.AddMatch(podPrefixLbl, namespace)
}
return es
} | go | func getEndpointSelector(namespace string, labelSelector *metav1.LabelSelector, addK8sPrefix, matchesInit bool) api.EndpointSelector {
es := api.NewESFromK8sLabelSelector("", labelSelector)
// The k8s prefix must not be added to reserved labels.
if addK8sPrefix && es.HasKeyPrefix(labels.LabelSourceReservedKeyPrefix) {
return es
}
// The user can explicitly specify the namespace in the
// FromEndpoints selector. If omitted, we limit the
// scope to the namespace the policy lives in.
//
// Policies applying on initializing pods are a special case.
// Those pods don't have any labels, so they don't have a namespace label either.
// Don't add a namespace label to those endpoint selectors, or we wouldn't be
// able to match on those pods.
if !matchesInit && !es.HasKey(podPrefixLbl) && !es.HasKey(podAnyPrefixLbl) {
es.AddMatch(podPrefixLbl, namespace)
}
return es
} | [
"func",
"getEndpointSelector",
"(",
"namespace",
"string",
",",
"labelSelector",
"*",
"metav1",
".",
"LabelSelector",
",",
"addK8sPrefix",
",",
"matchesInit",
"bool",
")",
"api",
".",
"EndpointSelector",
"{",
"es",
":=",
"api",
".",
"NewESFromK8sLabelSelector",
"(... | // getEndpointSelector converts the provided labelSelector into an EndpointSelector,
// adding the relevant matches for namespaces based on the provided options. | [
"getEndpointSelector",
"converts",
"the",
"provided",
"labelSelector",
"into",
"an",
"EndpointSelector",
"adding",
"the",
"relevant",
"matches",
"for",
"namespaces",
"based",
"on",
"the",
"provided",
"options",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/utils/utils.go#L67-L88 |
163,306 | cilium/cilium | pkg/k8s/apis/cilium.io/utils/utils.go | namespacesAreValid | func namespacesAreValid(namespace string, userNamespaces []string) bool {
return len(userNamespaces) == 0 ||
(len(userNamespaces) == 1 && userNamespaces[0] == namespace)
} | go | func namespacesAreValid(namespace string, userNamespaces []string) bool {
return len(userNamespaces) == 0 ||
(len(userNamespaces) == 1 && userNamespaces[0] == namespace)
} | [
"func",
"namespacesAreValid",
"(",
"namespace",
"string",
",",
"userNamespaces",
"[",
"]",
"string",
")",
"bool",
"{",
"return",
"len",
"(",
"userNamespaces",
")",
"==",
"0",
"||",
"(",
"len",
"(",
"userNamespaces",
")",
"==",
"1",
"&&",
"userNamespaces",
... | // namespacesAreValid checks the set of namespaces from a rule returns true if
// they are not specified, or if they are specified and match the namespace
// where the rule is being inserted. | [
"namespacesAreValid",
"checks",
"the",
"set",
"of",
"namespaces",
"from",
"a",
"rule",
"returns",
"true",
"if",
"they",
"are",
"not",
"specified",
"or",
"if",
"they",
"are",
"specified",
"and",
"match",
"the",
"namespace",
"where",
"the",
"rule",
"is",
"bein... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/utils/utils.go#L197-L200 |
163,307 | cilium/cilium | pkg/k8s/apis/cilium.io/utils/utils.go | ParseToCiliumRule | func ParseToCiliumRule(namespace, name string, uid types.UID, r *api.Rule) *api.Rule {
retRule := &api.Rule{}
if r.EndpointSelector.LabelSelector != nil {
retRule.EndpointSelector = api.NewESFromK8sLabelSelector("", r.EndpointSelector.LabelSelector)
// The PodSelector should only reflect to the same namespace
// the policy is being stored, thus we add the namespace to
// the MatchLabels map.
//
// Policies applying on initializing pods are a special case.
// Those pods don't have any labels, so they don't have a namespace label either.
// Don't add a namespace label to those endpoint selectors, or we wouldn't be
// able to match on those pods.
if !retRule.EndpointSelector.HasKey(podInitLbl) {
userNamespace, present := r.EndpointSelector.GetMatch(podPrefixLbl)
if present && !namespacesAreValid(namespace, userNamespace) {
log.WithFields(logrus.Fields{
logfields.K8sNamespace: namespace,
logfields.CiliumNetworkPolicyName: name,
logfields.K8sNamespace + ".illegal": userNamespace,
}).Warn("CiliumNetworkPolicy contains illegal namespace match in EndpointSelector." +
" EndpointSelector always applies in namespace of the policy resource, removing illegal namespace match'.")
}
retRule.EndpointSelector.AddMatch(podPrefixLbl, namespace)
}
}
parseToCiliumIngressRule(namespace, r, retRule)
parseToCiliumEgressRule(namespace, r, retRule)
retRule.Labels = ParseToCiliumLabels(namespace, name, uid, r.Labels)
retRule.Description = r.Description
return retRule
} | go | func ParseToCiliumRule(namespace, name string, uid types.UID, r *api.Rule) *api.Rule {
retRule := &api.Rule{}
if r.EndpointSelector.LabelSelector != nil {
retRule.EndpointSelector = api.NewESFromK8sLabelSelector("", r.EndpointSelector.LabelSelector)
// The PodSelector should only reflect to the same namespace
// the policy is being stored, thus we add the namespace to
// the MatchLabels map.
//
// Policies applying on initializing pods are a special case.
// Those pods don't have any labels, so they don't have a namespace label either.
// Don't add a namespace label to those endpoint selectors, or we wouldn't be
// able to match on those pods.
if !retRule.EndpointSelector.HasKey(podInitLbl) {
userNamespace, present := r.EndpointSelector.GetMatch(podPrefixLbl)
if present && !namespacesAreValid(namespace, userNamespace) {
log.WithFields(logrus.Fields{
logfields.K8sNamespace: namespace,
logfields.CiliumNetworkPolicyName: name,
logfields.K8sNamespace + ".illegal": userNamespace,
}).Warn("CiliumNetworkPolicy contains illegal namespace match in EndpointSelector." +
" EndpointSelector always applies in namespace of the policy resource, removing illegal namespace match'.")
}
retRule.EndpointSelector.AddMatch(podPrefixLbl, namespace)
}
}
parseToCiliumIngressRule(namespace, r, retRule)
parseToCiliumEgressRule(namespace, r, retRule)
retRule.Labels = ParseToCiliumLabels(namespace, name, uid, r.Labels)
retRule.Description = r.Description
return retRule
} | [
"func",
"ParseToCiliumRule",
"(",
"namespace",
",",
"name",
"string",
",",
"uid",
"types",
".",
"UID",
",",
"r",
"*",
"api",
".",
"Rule",
")",
"*",
"api",
".",
"Rule",
"{",
"retRule",
":=",
"&",
"api",
".",
"Rule",
"{",
"}",
"\n",
"if",
"r",
".",... | // ParseToCiliumRule returns an api.Rule with all the labels parsed into cilium
// labels. | [
"ParseToCiliumRule",
"returns",
"an",
"api",
".",
"Rule",
"with",
"all",
"the",
"labels",
"parsed",
"into",
"cilium",
"labels",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/utils/utils.go#L204-L238 |
163,308 | cilium/cilium | pkg/k8s/apis/cilium.io/utils/utils.go | ParseToCiliumLabels | func ParseToCiliumLabels(namespace, name string, uid types.UID, ruleLbs labels.LabelArray) labels.LabelArray {
policyLbls := GetPolicyLabels(namespace, name, uid, ResourceTypeCiliumNetworkPolicy)
return append(policyLbls, ruleLbs...).Sort()
} | go | func ParseToCiliumLabels(namespace, name string, uid types.UID, ruleLbs labels.LabelArray) labels.LabelArray {
policyLbls := GetPolicyLabels(namespace, name, uid, ResourceTypeCiliumNetworkPolicy)
return append(policyLbls, ruleLbs...).Sort()
} | [
"func",
"ParseToCiliumLabels",
"(",
"namespace",
",",
"name",
"string",
",",
"uid",
"types",
".",
"UID",
",",
"ruleLbs",
"labels",
".",
"LabelArray",
")",
"labels",
".",
"LabelArray",
"{",
"policyLbls",
":=",
"GetPolicyLabels",
"(",
"namespace",
",",
"name",
... | // ParseToCiliumLabels returns all ruleLbls appended with a specific label that
// represents the given namespace and name along with a label that specifies
// these labels were derived from a CiliumNetworkPolicy. | [
"ParseToCiliumLabels",
"returns",
"all",
"ruleLbls",
"appended",
"with",
"a",
"specific",
"label",
"that",
"represents",
"the",
"given",
"namespace",
"and",
"name",
"along",
"with",
"a",
"label",
"that",
"specifies",
"these",
"labels",
"were",
"derived",
"from",
... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/utils/utils.go#L243-L246 |
163,309 | cilium/cilium | pkg/datapath/iptables/iptables.go | Init | func (m *IptablesManager) Init() {
modulesManager := &modules.ModulesManager{}
ip6tables := true
if err := modulesManager.Init(); err != nil {
log.WithError(err).Fatal(
"Unable to get information about kernel modules")
}
if err := modulesManager.FindOrLoadModules(
"ip_tables", "iptable_nat", "iptable_mangle", "iptable_raw",
"iptable_filter"); err != nil {
log.WithError(err).Warning(
"iptables modules could not be initialized. It probably means that iptables is not available on this system")
}
if err := modulesManager.FindOrLoadModules(
"ip6_tables", "ip6table_mangle", "ip6table_raw"); err != nil {
if option.Config.EnableIPv6 {
log.WithError(err).Fatal(
"IPv6 is enabled and ip6tables modules could not be initialized")
}
log.WithError(err).Debug(
"ip6tables kernel modules could not be loaded, so IPv6 cannot be used")
ip6tables = false
}
m.ip6tables = ip6tables
} | go | func (m *IptablesManager) Init() {
modulesManager := &modules.ModulesManager{}
ip6tables := true
if err := modulesManager.Init(); err != nil {
log.WithError(err).Fatal(
"Unable to get information about kernel modules")
}
if err := modulesManager.FindOrLoadModules(
"ip_tables", "iptable_nat", "iptable_mangle", "iptable_raw",
"iptable_filter"); err != nil {
log.WithError(err).Warning(
"iptables modules could not be initialized. It probably means that iptables is not available on this system")
}
if err := modulesManager.FindOrLoadModules(
"ip6_tables", "ip6table_mangle", "ip6table_raw"); err != nil {
if option.Config.EnableIPv6 {
log.WithError(err).Fatal(
"IPv6 is enabled and ip6tables modules could not be initialized")
}
log.WithError(err).Debug(
"ip6tables kernel modules could not be loaded, so IPv6 cannot be used")
ip6tables = false
}
m.ip6tables = ip6tables
} | [
"func",
"(",
"m",
"*",
"IptablesManager",
")",
"Init",
"(",
")",
"{",
"modulesManager",
":=",
"&",
"modules",
".",
"ModulesManager",
"{",
"}",
"\n",
"ip6tables",
":=",
"true",
"\n",
"if",
"err",
":=",
"modulesManager",
".",
"Init",
"(",
")",
";",
"err"... | // Init initializes the iptables manager and checks for iptables kernel modules
// availability. | [
"Init",
"initializes",
"the",
"iptables",
"manager",
"and",
"checks",
"for",
"iptables",
"kernel",
"modules",
"availability",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/iptables/iptables.go#L242-L266 |
163,310 | cilium/cilium | pkg/datapath/iptables/iptables.go | RemoveRules | func (m *IptablesManager) RemoveRules() {
// Set of tables that have had iptables rules in any Cilium version
tables := []string{"nat", "mangle", "raw", "filter"}
for _, t := range tables {
removeCiliumRules(t, "iptables")
}
// Set of tables that have had ip6tables rules in any Cilium version
if m.ip6tables {
tables6 := []string{"mangle", "raw"}
for _, t := range tables6 {
removeCiliumRules(t, "ip6tables")
}
}
for _, c := range ciliumChains {
c.remove()
}
} | go | func (m *IptablesManager) RemoveRules() {
// Set of tables that have had iptables rules in any Cilium version
tables := []string{"nat", "mangle", "raw", "filter"}
for _, t := range tables {
removeCiliumRules(t, "iptables")
}
// Set of tables that have had ip6tables rules in any Cilium version
if m.ip6tables {
tables6 := []string{"mangle", "raw"}
for _, t := range tables6 {
removeCiliumRules(t, "ip6tables")
}
}
for _, c := range ciliumChains {
c.remove()
}
} | [
"func",
"(",
"m",
"*",
"IptablesManager",
")",
"RemoveRules",
"(",
")",
"{",
"// Set of tables that have had iptables rules in any Cilium version",
"tables",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"... | // RemoveRules removes iptables rules installed by Cilium. | [
"RemoveRules",
"removes",
"iptables",
"rules",
"installed",
"by",
"Cilium",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/iptables/iptables.go#L269-L287 |
163,311 | cilium/cilium | pkg/datapath/iptables/iptables.go | iptProxyRules | func iptProxyRules(cmd string, proxyPort uint16, ingress bool, name string) error {
// Redirect packets to the host proxy via TPROXY, as directed by the Cilium
// datapath bpf programs via skb marks (egress) or DSCP (ingress).
if ingress {
if err := iptIngressProxyRule(cmd, "tcp", proxyPort, name); err != nil {
return err
}
if err := iptIngressProxyRule(cmd, "udp", proxyPort, name); err != nil {
return err
}
} else {
if err := iptEgressProxyRule(cmd, "tcp", proxyPort, name); err != nil {
return err
}
if err := iptEgressProxyRule(cmd, "udp", proxyPort, name); err != nil {
return err
}
}
return nil
} | go | func iptProxyRules(cmd string, proxyPort uint16, ingress bool, name string) error {
// Redirect packets to the host proxy via TPROXY, as directed by the Cilium
// datapath bpf programs via skb marks (egress) or DSCP (ingress).
if ingress {
if err := iptIngressProxyRule(cmd, "tcp", proxyPort, name); err != nil {
return err
}
if err := iptIngressProxyRule(cmd, "udp", proxyPort, name); err != nil {
return err
}
} else {
if err := iptEgressProxyRule(cmd, "tcp", proxyPort, name); err != nil {
return err
}
if err := iptEgressProxyRule(cmd, "udp", proxyPort, name); err != nil {
return err
}
}
return nil
} | [
"func",
"iptProxyRules",
"(",
"cmd",
"string",
",",
"proxyPort",
"uint16",
",",
"ingress",
"bool",
",",
"name",
"string",
")",
"error",
"{",
"// Redirect packets to the host proxy via TPROXY, as directed by the Cilium",
"// datapath bpf programs via skb marks (egress) or DSCP (in... | // install or remove rules for a single proxy port | [
"install",
"or",
"remove",
"rules",
"for",
"a",
"single",
"proxy",
"port"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/iptables/iptables.go#L433-L452 |
163,312 | cilium/cilium | api/v1/models/endpoint_health.go | Validate | func (m *EndpointHealth) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateBpf(formats); err != nil {
res = append(res, err)
}
if err := m.validateOverallHealth(formats); err != nil {
res = append(res, err)
}
if err := m.validatePolicy(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *EndpointHealth) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateBpf(formats); err != nil {
res = append(res, err)
}
if err := m.validateOverallHealth(formats); err != nil {
res = append(res, err)
}
if err := m.validatePolicy(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"EndpointHealth",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateBpf",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",... | // Validate validates this endpoint health | [
"Validate",
"validates",
"this",
"endpoint",
"health"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/endpoint_health.go#L33-L52 |
163,313 | cilium/cilium | api/v1/models/prefilter_status.go | Validate | func (m *PrefilterStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateRealized(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *PrefilterStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateRealized(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"PrefilterStatus",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateRealized",
"(",
"formats",
")",
";",
"err",
"!=",
... | // Validate validates this prefilter status | [
"Validate",
"validates",
"this",
"prefilter",
"status"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/prefilter_status.go#L24-L35 |
163,314 | cilium/cilium | api/v1/server/restapi/metrics/get_metrics.go | NewGetMetrics | func NewGetMetrics(ctx *middleware.Context, handler GetMetricsHandler) *GetMetrics {
return &GetMetrics{Context: ctx, Handler: handler}
} | go | func NewGetMetrics(ctx *middleware.Context, handler GetMetricsHandler) *GetMetrics {
return &GetMetrics{Context: ctx, Handler: handler}
} | [
"func",
"NewGetMetrics",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"GetMetricsHandler",
")",
"*",
"GetMetrics",
"{",
"return",
"&",
"GetMetrics",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewGetMetrics creates a new http.Handler for the get metrics operation | [
"NewGetMetrics",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"get",
"metrics",
"operation"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/metrics/get_metrics.go#L28-L30 |
163,315 | cilium/cilium | api/v1/client/ipam/post_ip_a_m_parameters.go | WithTimeout | func (o *PostIPAMParams) WithTimeout(timeout time.Duration) *PostIPAMParams {
o.SetTimeout(timeout)
return o
} | go | func (o *PostIPAMParams) WithTimeout(timeout time.Duration) *PostIPAMParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"PostIPAMParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"PostIPAMParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the post IP a m params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"post",
"IP",
"a",
"m",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/ipam/post_ip_a_m_parameters.go#L75-L78 |
163,316 | cilium/cilium | api/v1/client/ipam/post_ip_a_m_parameters.go | WithContext | func (o *PostIPAMParams) WithContext(ctx context.Context) *PostIPAMParams {
o.SetContext(ctx)
return o
} | go | func (o *PostIPAMParams) WithContext(ctx context.Context) *PostIPAMParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"PostIPAMParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"PostIPAMParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the post IP a m params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"post",
"IP",
"a",
"m",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/ipam/post_ip_a_m_parameters.go#L86-L89 |
163,317 | cilium/cilium | api/v1/client/ipam/post_ip_a_m_parameters.go | WithHTTPClient | func (o *PostIPAMParams) WithHTTPClient(client *http.Client) *PostIPAMParams {
o.SetHTTPClient(client)
return o
} | go | func (o *PostIPAMParams) WithHTTPClient(client *http.Client) *PostIPAMParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"PostIPAMParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"PostIPAMParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the post IP a m params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"post",
"IP",
"a",
"m",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/ipam/post_ip_a_m_parameters.go#L97-L100 |
163,318 | cilium/cilium | api/v1/client/ipam/post_ip_a_m_parameters.go | WithFamily | func (o *PostIPAMParams) WithFamily(family *string) *PostIPAMParams {
o.SetFamily(family)
return o
} | go | func (o *PostIPAMParams) WithFamily(family *string) *PostIPAMParams {
o.SetFamily(family)
return o
} | [
"func",
"(",
"o",
"*",
"PostIPAMParams",
")",
"WithFamily",
"(",
"family",
"*",
"string",
")",
"*",
"PostIPAMParams",
"{",
"o",
".",
"SetFamily",
"(",
"family",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithFamily adds the family to the post IP a m params | [
"WithFamily",
"adds",
"the",
"family",
"to",
"the",
"post",
"IP",
"a",
"m",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/ipam/post_ip_a_m_parameters.go#L108-L111 |
163,319 | cilium/cilium | api/v1/client/ipam/post_ip_a_m_parameters.go | WithOwner | func (o *PostIPAMParams) WithOwner(owner *string) *PostIPAMParams {
o.SetOwner(owner)
return o
} | go | func (o *PostIPAMParams) WithOwner(owner *string) *PostIPAMParams {
o.SetOwner(owner)
return o
} | [
"func",
"(",
"o",
"*",
"PostIPAMParams",
")",
"WithOwner",
"(",
"owner",
"*",
"string",
")",
"*",
"PostIPAMParams",
"{",
"o",
".",
"SetOwner",
"(",
"owner",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithOwner adds the owner to the post IP a m params | [
"WithOwner",
"adds",
"the",
"owner",
"to",
"the",
"post",
"IP",
"a",
"m",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/ipam/post_ip_a_m_parameters.go#L119-L122 |
163,320 | cilium/cilium | pkg/policy/api/rule.go | WithEndpointSelector | func (r *Rule) WithEndpointSelector(es EndpointSelector) *Rule {
r.EndpointSelector = es
return r
} | go | func (r *Rule) WithEndpointSelector(es EndpointSelector) *Rule {
r.EndpointSelector = es
return r
} | [
"func",
"(",
"r",
"*",
"Rule",
")",
"WithEndpointSelector",
"(",
"es",
"EndpointSelector",
")",
"*",
"Rule",
"{",
"r",
".",
"EndpointSelector",
"=",
"es",
"\n",
"return",
"r",
"\n",
"}"
] | // WithEndpointSelector configures the Rule with the specified selector. | [
"WithEndpointSelector",
"configures",
"the",
"Rule",
"with",
"the",
"specified",
"selector",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/rule.go#L71-L74 |
163,321 | cilium/cilium | pkg/policy/api/rule.go | WithIngressRules | func (r *Rule) WithIngressRules(rules []IngressRule) *Rule {
r.Ingress = rules
return r
} | go | func (r *Rule) WithIngressRules(rules []IngressRule) *Rule {
r.Ingress = rules
return r
} | [
"func",
"(",
"r",
"*",
"Rule",
")",
"WithIngressRules",
"(",
"rules",
"[",
"]",
"IngressRule",
")",
"*",
"Rule",
"{",
"r",
".",
"Ingress",
"=",
"rules",
"\n",
"return",
"r",
"\n",
"}"
] | // WithIngressRules configures the Rule with the specified rules. | [
"WithIngressRules",
"configures",
"the",
"Rule",
"with",
"the",
"specified",
"rules",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/rule.go#L77-L80 |
163,322 | cilium/cilium | pkg/policy/api/rule.go | WithEgressRules | func (r *Rule) WithEgressRules(rules []EgressRule) *Rule {
r.Egress = rules
return r
} | go | func (r *Rule) WithEgressRules(rules []EgressRule) *Rule {
r.Egress = rules
return r
} | [
"func",
"(",
"r",
"*",
"Rule",
")",
"WithEgressRules",
"(",
"rules",
"[",
"]",
"EgressRule",
")",
"*",
"Rule",
"{",
"r",
".",
"Egress",
"=",
"rules",
"\n",
"return",
"r",
"\n",
"}"
] | // WithEgressRules configures the Rule with the specified rules. | [
"WithEgressRules",
"configures",
"the",
"Rule",
"with",
"the",
"specified",
"rules",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/rule.go#L83-L86 |
163,323 | cilium/cilium | pkg/policy/api/rule.go | WithLabels | func (r *Rule) WithLabels(labels labels.LabelArray) *Rule {
r.Labels = labels
return r
} | go | func (r *Rule) WithLabels(labels labels.LabelArray) *Rule {
r.Labels = labels
return r
} | [
"func",
"(",
"r",
"*",
"Rule",
")",
"WithLabels",
"(",
"labels",
"labels",
".",
"LabelArray",
")",
"*",
"Rule",
"{",
"r",
".",
"Labels",
"=",
"labels",
"\n",
"return",
"r",
"\n",
"}"
] | // WithLabels configures the Rule with the specified labels metadata. | [
"WithLabels",
"configures",
"the",
"Rule",
"with",
"the",
"specified",
"labels",
"metadata",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/rule.go#L89-L92 |
163,324 | cilium/cilium | pkg/policy/api/rule.go | WithDescription | func (r *Rule) WithDescription(desc string) *Rule {
r.Description = desc
return r
} | go | func (r *Rule) WithDescription(desc string) *Rule {
r.Description = desc
return r
} | [
"func",
"(",
"r",
"*",
"Rule",
")",
"WithDescription",
"(",
"desc",
"string",
")",
"*",
"Rule",
"{",
"r",
".",
"Description",
"=",
"desc",
"\n",
"return",
"r",
"\n",
"}"
] | // WithDescription configures the Rule with the specified description metadata. | [
"WithDescription",
"configures",
"the",
"Rule",
"with",
"the",
"specified",
"description",
"metadata",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/rule.go#L95-L98 |
163,325 | cilium/cilium | pkg/policy/api/rule.go | RequiresDerivative | func (r *Rule) RequiresDerivative() bool {
for _, rule := range r.Egress {
if rule.RequiresDerivative() {
return true
}
}
return false
} | go | func (r *Rule) RequiresDerivative() bool {
for _, rule := range r.Egress {
if rule.RequiresDerivative() {
return true
}
}
return false
} | [
"func",
"(",
"r",
"*",
"Rule",
")",
"RequiresDerivative",
"(",
")",
"bool",
"{",
"for",
"_",
",",
"rule",
":=",
"range",
"r",
".",
"Egress",
"{",
"if",
"rule",
".",
"RequiresDerivative",
"(",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
... | // RequiresDerivative it return true if the rule has a derivative rule. | [
"RequiresDerivative",
"it",
"return",
"true",
"if",
"the",
"rule",
"has",
"a",
"derivative",
"rule",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/rule.go#L101-L108 |
163,326 | cilium/cilium | pkg/policy/api/rule.go | CreateDerivative | func (r *Rule) CreateDerivative() (*Rule, error) {
newRule := r.DeepCopy()
newRule.Egress = []EgressRule{}
for _, egressRule := range r.Egress {
derivativeEgressRule, err := egressRule.CreateDerivative()
if err != nil {
return newRule, err
}
newRule.Egress = append(newRule.Egress, *derivativeEgressRule)
}
return newRule, nil
} | go | func (r *Rule) CreateDerivative() (*Rule, error) {
newRule := r.DeepCopy()
newRule.Egress = []EgressRule{}
for _, egressRule := range r.Egress {
derivativeEgressRule, err := egressRule.CreateDerivative()
if err != nil {
return newRule, err
}
newRule.Egress = append(newRule.Egress, *derivativeEgressRule)
}
return newRule, nil
} | [
"func",
"(",
"r",
"*",
"Rule",
")",
"CreateDerivative",
"(",
")",
"(",
"*",
"Rule",
",",
"error",
")",
"{",
"newRule",
":=",
"r",
".",
"DeepCopy",
"(",
")",
"\n",
"newRule",
".",
"Egress",
"=",
"[",
"]",
"EgressRule",
"{",
"}",
"\n\n",
"for",
"_"... | // CreateDerivative will return a new Rule with the new data based gather
// by the rules that autogenerated new Rule | [
"CreateDerivative",
"will",
"return",
"a",
"new",
"Rule",
"with",
"the",
"new",
"data",
"based",
"gather",
"by",
"the",
"rules",
"that",
"autogenerated",
"new",
"Rule"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/rule.go#L112-L124 |
163,327 | cilium/cilium | pkg/endpoint/bpf.go | PolicyMapPathLocked | func (e *Endpoint) PolicyMapPathLocked() string {
return bpf.LocalMapPath(policymap.MapName, e.ID)
} | go | func (e *Endpoint) PolicyMapPathLocked() string {
return bpf.LocalMapPath(policymap.MapName, e.ID)
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"PolicyMapPathLocked",
"(",
")",
"string",
"{",
"return",
"bpf",
".",
"LocalMapPath",
"(",
"policymap",
".",
"MapName",
",",
"e",
".",
"ID",
")",
"\n",
"}"
] | // PolicyMapPathLocked returns the path to the policy map of endpoint. | [
"PolicyMapPathLocked",
"returns",
"the",
"path",
"to",
"the",
"policy",
"map",
"of",
"endpoint",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/bpf.go#L55-L57 |
163,328 | cilium/cilium | pkg/endpoint/bpf.go | CallsMapPathLocked | func (e *Endpoint) CallsMapPathLocked() string {
return bpf.LocalMapPath(loader.CallsMapName, e.ID)
} | go | func (e *Endpoint) CallsMapPathLocked() string {
return bpf.LocalMapPath(loader.CallsMapName, e.ID)
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"CallsMapPathLocked",
"(",
")",
"string",
"{",
"return",
"bpf",
".",
"LocalMapPath",
"(",
"loader",
".",
"CallsMapName",
",",
"e",
".",
"ID",
")",
"\n",
"}"
] | // CallsMapPathLocked returns the path to cilium tail calls map of an endpoint. | [
"CallsMapPathLocked",
"returns",
"the",
"path",
"to",
"cilium",
"tail",
"calls",
"map",
"of",
"an",
"endpoint",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/bpf.go#L60-L62 |
163,329 | cilium/cilium | pkg/endpoint/bpf.go | BPFConfigMapPath | func (e *Endpoint) BPFConfigMapPath() string {
return bpf.LocalMapPath(bpfconfig.MapNamePrefix, e.ID)
} | go | func (e *Endpoint) BPFConfigMapPath() string {
return bpf.LocalMapPath(bpfconfig.MapNamePrefix, e.ID)
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"BPFConfigMapPath",
"(",
")",
"string",
"{",
"return",
"bpf",
".",
"LocalMapPath",
"(",
"bpfconfig",
".",
"MapNamePrefix",
",",
"e",
".",
"ID",
")",
"\n",
"}"
] | // BPFConfigMapPath returns the path to the BPF config map of endpoint. | [
"BPFConfigMapPath",
"returns",
"the",
"path",
"to",
"the",
"BPF",
"config",
"map",
"of",
"endpoint",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/bpf.go#L65-L67 |
163,330 | cilium/cilium | pkg/endpoint/bpf.go | addNewRedirects | func (e *Endpoint) addNewRedirects(owner Owner, m *policy.L4Policy, proxyWaitGroup *completion.WaitGroup) (desiredRedirects map[string]bool, err error, finalizeFunc revert.FinalizeFunc, revertFunc revert.RevertFunc) {
desiredRedirects = make(map[string]bool)
var finalizeList revert.FinalizeList
var revertStack revert.RevertStack
var ff revert.FinalizeFunc
var rf revert.RevertFunc
err, ff, rf = e.addNewRedirectsFromMap(owner, m.Ingress, desiredRedirects, proxyWaitGroup)
if err != nil {
return desiredRedirects, fmt.Errorf("unable to allocate ingress redirects: %s", err), nil, nil
}
finalizeList.Append(ff)
revertStack.Push(rf)
err, ff, rf = e.addNewRedirectsFromMap(owner, m.Egress, desiredRedirects, proxyWaitGroup)
if err != nil {
revertStack.Revert() // Ignore errors while reverting. This is best-effort.
return desiredRedirects, fmt.Errorf("unable to allocate egress redirects: %s", err), nil, nil
}
finalizeList.Append(ff)
revertStack.Push(rf)
return desiredRedirects, nil, finalizeList.Finalize, func() error {
e.getLogger().Debug("Reverting proxy redirect additions")
err := revertStack.Revert()
e.getLogger().Debug("Finished reverting proxy redirect additions")
return err
}
} | go | func (e *Endpoint) addNewRedirects(owner Owner, m *policy.L4Policy, proxyWaitGroup *completion.WaitGroup) (desiredRedirects map[string]bool, err error, finalizeFunc revert.FinalizeFunc, revertFunc revert.RevertFunc) {
desiredRedirects = make(map[string]bool)
var finalizeList revert.FinalizeList
var revertStack revert.RevertStack
var ff revert.FinalizeFunc
var rf revert.RevertFunc
err, ff, rf = e.addNewRedirectsFromMap(owner, m.Ingress, desiredRedirects, proxyWaitGroup)
if err != nil {
return desiredRedirects, fmt.Errorf("unable to allocate ingress redirects: %s", err), nil, nil
}
finalizeList.Append(ff)
revertStack.Push(rf)
err, ff, rf = e.addNewRedirectsFromMap(owner, m.Egress, desiredRedirects, proxyWaitGroup)
if err != nil {
revertStack.Revert() // Ignore errors while reverting. This is best-effort.
return desiredRedirects, fmt.Errorf("unable to allocate egress redirects: %s", err), nil, nil
}
finalizeList.Append(ff)
revertStack.Push(rf)
return desiredRedirects, nil, finalizeList.Finalize, func() error {
e.getLogger().Debug("Reverting proxy redirect additions")
err := revertStack.Revert()
e.getLogger().Debug("Finished reverting proxy redirect additions")
return err
}
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"addNewRedirects",
"(",
"owner",
"Owner",
",",
"m",
"*",
"policy",
".",
"L4Policy",
",",
"proxyWaitGroup",
"*",
"completion",
".",
"WaitGroup",
")",
"(",
"desiredRedirects",
"map",
"[",
"string",
"]",
"bool",
",",
... | // addNewRedirects must be called while holding the endpoint lock for writing.
// On success, returns nil; otherwise, returns an error indicating the problem
// that occurred while adding an l7 redirect for the specified policy.
// The returned map contains the exact set of IDs of proxy redirects that is
// required to implement the given L4 policy.
// Must be called with endpoint.Mutex held. | [
"addNewRedirects",
"must",
"be",
"called",
"while",
"holding",
"the",
"endpoint",
"lock",
"for",
"writing",
".",
"On",
"success",
"returns",
"nil",
";",
"otherwise",
"returns",
"an",
"error",
"indicating",
"the",
"problem",
"that",
"occurred",
"while",
"adding",... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/bpf.go#L256-L288 |
163,331 | cilium/cilium | pkg/endpoint/bpf.go | removeOldRedirects | func (e *Endpoint) removeOldRedirects(owner Owner, desiredRedirects map[string]bool, proxyWaitGroup *completion.WaitGroup) (revert.FinalizeFunc, revert.RevertFunc) {
if option.Config.DryMode {
return nil, nil
}
var finalizeList revert.FinalizeList
var revertStack revert.RevertStack
removedRedirects := make(map[string]uint16, len(e.realizedRedirects))
updatedStats := make(map[uint16]*models.ProxyStatistics, len(e.realizedRedirects))
for id, redirectPort := range e.realizedRedirects {
// Remove only the redirects that are not required.
if desiredRedirects[id] {
continue
}
err, finalizeFunc, revertFunc := owner.RemoveProxyRedirect(e, id, proxyWaitGroup)
if err != nil {
e.getLogger().WithError(err).WithField(logfields.L4PolicyID, id).Warn("Error while removing proxy redirect")
continue
}
finalizeList.Append(finalizeFunc)
revertStack.Push(revertFunc)
delete(e.realizedRedirects, id)
removedRedirects[id] = redirectPort
// Update the endpoint API model to report that no redirect is
// active or known for that port anymore. We never delete stats
// until an endpoint is deleted, so we only set the redirect port
// to 0.
//
// We don't know the L7 protocol of the redirect, so we can't just
// build a ProxyStatistics and lookup e.proxyStatistics by key.
// We have to loop to find which entry has the same redirect port.
// Looping is acceptable since there should be only a few redirects
// for each endpoint.
e.proxyStatisticsMutex.Lock()
for _, stats := range e.proxyStatistics {
if stats.AllocatedProxyPort == int64(redirectPort) {
updatedStats[redirectPort] = stats
stats.AllocatedProxyPort = 0
break
}
}
e.proxyStatisticsMutex.Unlock()
}
return finalizeList.Finalize,
func() error {
e.getLogger().Debug("Reverting proxy redirect removals")
// Restore the proxy stats.
e.proxyStatisticsMutex.Lock()
for redirectPort, stats := range updatedStats {
stats.AllocatedProxyPort = int64(redirectPort)
}
e.proxyStatisticsMutex.Unlock()
for id, redirectPort := range removedRedirects {
e.realizedRedirects[id] = redirectPort
}
err := revertStack.Revert()
e.getLogger().Debug("Finished reverting proxy redirect removals")
return err
}
} | go | func (e *Endpoint) removeOldRedirects(owner Owner, desiredRedirects map[string]bool, proxyWaitGroup *completion.WaitGroup) (revert.FinalizeFunc, revert.RevertFunc) {
if option.Config.DryMode {
return nil, nil
}
var finalizeList revert.FinalizeList
var revertStack revert.RevertStack
removedRedirects := make(map[string]uint16, len(e.realizedRedirects))
updatedStats := make(map[uint16]*models.ProxyStatistics, len(e.realizedRedirects))
for id, redirectPort := range e.realizedRedirects {
// Remove only the redirects that are not required.
if desiredRedirects[id] {
continue
}
err, finalizeFunc, revertFunc := owner.RemoveProxyRedirect(e, id, proxyWaitGroup)
if err != nil {
e.getLogger().WithError(err).WithField(logfields.L4PolicyID, id).Warn("Error while removing proxy redirect")
continue
}
finalizeList.Append(finalizeFunc)
revertStack.Push(revertFunc)
delete(e.realizedRedirects, id)
removedRedirects[id] = redirectPort
// Update the endpoint API model to report that no redirect is
// active or known for that port anymore. We never delete stats
// until an endpoint is deleted, so we only set the redirect port
// to 0.
//
// We don't know the L7 protocol of the redirect, so we can't just
// build a ProxyStatistics and lookup e.proxyStatistics by key.
// We have to loop to find which entry has the same redirect port.
// Looping is acceptable since there should be only a few redirects
// for each endpoint.
e.proxyStatisticsMutex.Lock()
for _, stats := range e.proxyStatistics {
if stats.AllocatedProxyPort == int64(redirectPort) {
updatedStats[redirectPort] = stats
stats.AllocatedProxyPort = 0
break
}
}
e.proxyStatisticsMutex.Unlock()
}
return finalizeList.Finalize,
func() error {
e.getLogger().Debug("Reverting proxy redirect removals")
// Restore the proxy stats.
e.proxyStatisticsMutex.Lock()
for redirectPort, stats := range updatedStats {
stats.AllocatedProxyPort = int64(redirectPort)
}
e.proxyStatisticsMutex.Unlock()
for id, redirectPort := range removedRedirects {
e.realizedRedirects[id] = redirectPort
}
err := revertStack.Revert()
e.getLogger().Debug("Finished reverting proxy redirect removals")
return err
}
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"removeOldRedirects",
"(",
"owner",
"Owner",
",",
"desiredRedirects",
"map",
"[",
"string",
"]",
"bool",
",",
"proxyWaitGroup",
"*",
"completion",
".",
"WaitGroup",
")",
"(",
"revert",
".",
"FinalizeFunc",
",",
"revert... | // Must be called with endpoint.Mutex held. | [
"Must",
"be",
"called",
"with",
"endpoint",
".",
"Mutex",
"held",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/bpf.go#L291-L360 |
163,332 | cilium/cilium | pkg/endpoint/bpf.go | DeleteMapsLocked | func (e *Endpoint) DeleteMapsLocked() []error {
var errors []error
maps := map[string]string{
"config": e.BPFConfigMapPath(),
"policy": e.PolicyMapPathLocked(),
"calls": e.CallsMapPathLocked(),
"egress": e.BPFIpvlanMapPath(),
}
for name, path := range maps {
if err := os.RemoveAll(path); err != nil {
errors = append(errors, fmt.Errorf("unable to remove %s map file %s: %s", name, path, err))
}
}
if e.ConntrackLocalLocked() {
// Remove local connection tracking maps
for _, m := range ctmap.LocalMaps(e, option.Config.EnableIPv4, option.Config.EnableIPv6) {
ctPath, err := m.Path()
if err == nil {
err = os.RemoveAll(ctPath)
}
if err != nil {
errors = append(errors, fmt.Errorf("unable to remove CT map %s: %s", ctPath, err))
}
}
}
// Remove handle_policy() tail call entry for EP
if err := policymap.RemoveGlobalMapping(uint32(e.ID)); err != nil {
errors = append(errors, fmt.Errorf("unable to remove endpoint from global policy map: %s", err))
}
return errors
} | go | func (e *Endpoint) DeleteMapsLocked() []error {
var errors []error
maps := map[string]string{
"config": e.BPFConfigMapPath(),
"policy": e.PolicyMapPathLocked(),
"calls": e.CallsMapPathLocked(),
"egress": e.BPFIpvlanMapPath(),
}
for name, path := range maps {
if err := os.RemoveAll(path); err != nil {
errors = append(errors, fmt.Errorf("unable to remove %s map file %s: %s", name, path, err))
}
}
if e.ConntrackLocalLocked() {
// Remove local connection tracking maps
for _, m := range ctmap.LocalMaps(e, option.Config.EnableIPv4, option.Config.EnableIPv6) {
ctPath, err := m.Path()
if err == nil {
err = os.RemoveAll(ctPath)
}
if err != nil {
errors = append(errors, fmt.Errorf("unable to remove CT map %s: %s", ctPath, err))
}
}
}
// Remove handle_policy() tail call entry for EP
if err := policymap.RemoveGlobalMapping(uint32(e.ID)); err != nil {
errors = append(errors, fmt.Errorf("unable to remove endpoint from global policy map: %s", err))
}
return errors
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"DeleteMapsLocked",
"(",
")",
"[",
"]",
"error",
"{",
"var",
"errors",
"[",
"]",
"error",
"\n\n",
"maps",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"e",
".",
"BPFConfigMapPath",
"(",
")... | // DeleteMapsLocked releases references to all BPF maps associated with this
// endpoint.
//
// For each error that occurs while releasing these references, an error is
// added to the resulting error slice which is returned.
//
// Returns nil on success. | [
"DeleteMapsLocked",
"releases",
"references",
"to",
"all",
"BPF",
"maps",
"associated",
"with",
"this",
"endpoint",
".",
"For",
"each",
"error",
"that",
"occurs",
"while",
"releasing",
"these",
"references",
"an",
"error",
"is",
"added",
"to",
"the",
"resulting"... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/bpf.go#L769-L803 |
163,333 | cilium/cilium | pkg/endpoint/bpf.go | DeleteBPFProgramLocked | func (e *Endpoint) DeleteBPFProgramLocked() error {
e.getLogger().Debug("deleting bpf program from endpoint")
return loader.DeleteDatapath(context.TODO(), e.IfName, "ingress")
} | go | func (e *Endpoint) DeleteBPFProgramLocked() error {
e.getLogger().Debug("deleting bpf program from endpoint")
return loader.DeleteDatapath(context.TODO(), e.IfName, "ingress")
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"DeleteBPFProgramLocked",
"(",
")",
"error",
"{",
"e",
".",
"getLogger",
"(",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"loader",
".",
"DeleteDatapath",
"(",
"context",
".",
"TODO",
"(",
")",
","... | // DeleteBPFProgramLocked delete the BPF program associated with the endpoint's
// veth interface. | [
"DeleteBPFProgramLocked",
"delete",
"the",
"BPF",
"program",
"associated",
"with",
"the",
"endpoint",
"s",
"veth",
"interface",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/bpf.go#L807-L810 |
163,334 | cilium/cilium | pkg/endpoint/bpf.go | SkipStateClean | func (e *Endpoint) SkipStateClean() {
// Mark conntrack as already cleaned
e.UnconditionalLock()
e.ctCleaned = true
e.Unlock()
} | go | func (e *Endpoint) SkipStateClean() {
// Mark conntrack as already cleaned
e.UnconditionalLock()
e.ctCleaned = true
e.Unlock()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"SkipStateClean",
"(",
")",
"{",
"// Mark conntrack as already cleaned",
"e",
".",
"UnconditionalLock",
"(",
")",
"\n",
"e",
".",
"ctCleaned",
"=",
"true",
"\n",
"e",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // SkipStateClean can be called on a endpoint before its first build to skip
// the cleaning of state such as the conntrack table. This is useful when an
// endpoint is being restored from state and the datapath state should not be
// claned.
//
// The endpoint lock must NOT be held. | [
"SkipStateClean",
"can",
"be",
"called",
"on",
"a",
"endpoint",
"before",
"its",
"first",
"build",
"to",
"skip",
"the",
"cleaning",
"of",
"state",
"such",
"as",
"the",
"conntrack",
"table",
".",
"This",
"is",
"useful",
"when",
"an",
"endpoint",
"is",
"bein... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/bpf.go#L862-L867 |
163,335 | cilium/cilium | pkg/endpoint/bpf.go | GetBPFKeys | func (e *Endpoint) GetBPFKeys() []*lxcmap.EndpointKey {
keys := []*lxcmap.EndpointKey{}
if e.IPv6.IsSet() {
keys = append(keys, lxcmap.NewEndpointKey(e.IPv6.IP()))
}
if e.IPv4.IsSet() {
keys = append(keys, lxcmap.NewEndpointKey(e.IPv4.IP()))
}
return keys
} | go | func (e *Endpoint) GetBPFKeys() []*lxcmap.EndpointKey {
keys := []*lxcmap.EndpointKey{}
if e.IPv6.IsSet() {
keys = append(keys, lxcmap.NewEndpointKey(e.IPv6.IP()))
}
if e.IPv4.IsSet() {
keys = append(keys, lxcmap.NewEndpointKey(e.IPv4.IP()))
}
return keys
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"GetBPFKeys",
"(",
")",
"[",
"]",
"*",
"lxcmap",
".",
"EndpointKey",
"{",
"keys",
":=",
"[",
"]",
"*",
"lxcmap",
".",
"EndpointKey",
"{",
"}",
"\n",
"if",
"e",
".",
"IPv6",
".",
"IsSet",
"(",
")",
"{",
"k... | // GetBPFKeys returns all keys which should represent this endpoint in the BPF
// endpoints map | [
"GetBPFKeys",
"returns",
"all",
"keys",
"which",
"should",
"represent",
"this",
"endpoint",
"in",
"the",
"BPF",
"endpoints",
"map"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/bpf.go#L871-L882 |
163,336 | cilium/cilium | pkg/endpoint/bpf.go | GetBPFValue | func (e *Endpoint) GetBPFValue() (*lxcmap.EndpointInfo, error) {
mac, err := e.LXCMAC.Uint64()
if err != nil {
return nil, fmt.Errorf("invalid LXC MAC: %v", err)
}
nodeMAC, err := e.NodeMAC.Uint64()
if err != nil {
return nil, fmt.Errorf("invalid node MAC: %v", err)
}
info := &lxcmap.EndpointInfo{
IfIndex: uint32(e.IfIndex),
// Store security identity in network byte order so it can be
// written into the packet without an additional byte order
// conversion.
LxcID: e.ID,
MAC: lxcmap.MAC(mac),
NodeMAC: lxcmap.MAC(nodeMAC),
}
return info, nil
} | go | func (e *Endpoint) GetBPFValue() (*lxcmap.EndpointInfo, error) {
mac, err := e.LXCMAC.Uint64()
if err != nil {
return nil, fmt.Errorf("invalid LXC MAC: %v", err)
}
nodeMAC, err := e.NodeMAC.Uint64()
if err != nil {
return nil, fmt.Errorf("invalid node MAC: %v", err)
}
info := &lxcmap.EndpointInfo{
IfIndex: uint32(e.IfIndex),
// Store security identity in network byte order so it can be
// written into the packet without an additional byte order
// conversion.
LxcID: e.ID,
MAC: lxcmap.MAC(mac),
NodeMAC: lxcmap.MAC(nodeMAC),
}
return info, nil
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"GetBPFValue",
"(",
")",
"(",
"*",
"lxcmap",
".",
"EndpointInfo",
",",
"error",
")",
"{",
"mac",
",",
"err",
":=",
"e",
".",
"LXCMAC",
".",
"Uint64",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",... | // GetBPFValue returns the value which should represent this endpoint in the
// BPF endpoints map | [
"GetBPFValue",
"returns",
"the",
"value",
"which",
"should",
"represent",
"this",
"endpoint",
"in",
"the",
"BPF",
"endpoints",
"map"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/bpf.go#L886-L908 |
163,337 | cilium/cilium | pkg/status/status.go | NewCollector | func NewCollector(probes []Probe, config Config) *Collector {
c := &Collector{
config: config,
stop: make(chan struct{}, 0),
staleProbes: make(map[string]struct{}),
probeStartTime: make(map[string]time.Time),
}
if c.config.Interval == time.Duration(0) {
c.config.Interval = defaults.StatusCollectorInterval
}
if c.config.FailureThreshold == time.Duration(0) {
c.config.FailureThreshold = defaults.StatusCollectorFailureThreshold
}
if c.config.WarningThreshold == time.Duration(0) {
c.config.WarningThreshold = defaults.StatusCollectorWarningThreshold
}
for i := range probes {
c.spawnProbe(&probes[i])
}
return c
} | go | func NewCollector(probes []Probe, config Config) *Collector {
c := &Collector{
config: config,
stop: make(chan struct{}, 0),
staleProbes: make(map[string]struct{}),
probeStartTime: make(map[string]time.Time),
}
if c.config.Interval == time.Duration(0) {
c.config.Interval = defaults.StatusCollectorInterval
}
if c.config.FailureThreshold == time.Duration(0) {
c.config.FailureThreshold = defaults.StatusCollectorFailureThreshold
}
if c.config.WarningThreshold == time.Duration(0) {
c.config.WarningThreshold = defaults.StatusCollectorWarningThreshold
}
for i := range probes {
c.spawnProbe(&probes[i])
}
return c
} | [
"func",
"NewCollector",
"(",
"probes",
"[",
"]",
"Probe",
",",
"config",
"Config",
")",
"*",
"Collector",
"{",
"c",
":=",
"&",
"Collector",
"{",
"config",
":",
"config",
",",
"stop",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
",",
"0",
")",
",",... | // NewCollector creates a collector and starts the given probes.
//
// Each probe runs in a separate goroutine. | [
"NewCollector",
"creates",
"a",
"collector",
"and",
"starts",
"the",
"given",
"probes",
".",
"Each",
"probe",
"runs",
"in",
"a",
"separate",
"goroutine",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/status/status.go#L91-L116 |
163,338 | cilium/cilium | pkg/status/status.go | GetStaleProbes | func (c *Collector) GetStaleProbes() map[string]time.Time {
c.RLock()
defer c.RUnlock()
probes := make(map[string]time.Time)
for p := range c.staleProbes {
probes[p] = c.probeStartTime[p]
}
return probes
} | go | func (c *Collector) GetStaleProbes() map[string]time.Time {
c.RLock()
defer c.RUnlock()
probes := make(map[string]time.Time)
for p := range c.staleProbes {
probes[p] = c.probeStartTime[p]
}
return probes
} | [
"func",
"(",
"c",
"*",
"Collector",
")",
"GetStaleProbes",
"(",
")",
"map",
"[",
"string",
"]",
"time",
".",
"Time",
"{",
"c",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"RUnlock",
"(",
")",
"\n\n",
"probes",
":=",
"make",
"(",
"map",
"[",
... | // GetStaleProbes returns a map of stale probes which key is a probe name and
// value is a time when the last instance of the probe has been started.
//
// A probe is declared stale if it hasn't returned in FailureThreshold. | [
"GetStaleProbes",
"returns",
"a",
"map",
"of",
"stale",
"probes",
"which",
"key",
"is",
"a",
"probe",
"name",
"and",
"value",
"is",
"a",
"time",
"when",
"the",
"last",
"instance",
"of",
"the",
"probe",
"has",
"been",
"started",
".",
"A",
"probe",
"is",
... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/status/status.go#L128-L139 |
163,339 | cilium/cilium | pkg/status/status.go | spawnProbe | func (c *Collector) spawnProbe(p *Probe) {
go func() {
for {
c.runProbe(p)
interval := c.config.Interval
if p.Interval != nil {
interval = p.Interval(p.consecutiveFailures)
}
select {
case <-c.stop:
// collector is closed, stop looping
return
case <-time.After(interval):
// keep looping
}
}
}()
} | go | func (c *Collector) spawnProbe(p *Probe) {
go func() {
for {
c.runProbe(p)
interval := c.config.Interval
if p.Interval != nil {
interval = p.Interval(p.consecutiveFailures)
}
select {
case <-c.stop:
// collector is closed, stop looping
return
case <-time.After(interval):
// keep looping
}
}
}()
} | [
"func",
"(",
"c",
"*",
"Collector",
")",
"spawnProbe",
"(",
"p",
"*",
"Probe",
")",
"{",
"go",
"func",
"(",
")",
"{",
"for",
"{",
"c",
".",
"runProbe",
"(",
"p",
")",
"\n\n",
"interval",
":=",
"c",
".",
"config",
".",
"Interval",
"\n",
"if",
"p... | // spawnProbe starts a goroutine which invokes the probe at the particular interval. | [
"spawnProbe",
"starts",
"a",
"goroutine",
"which",
"invokes",
"the",
"probe",
"at",
"the",
"particular",
"interval",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/status/status.go#L142-L161 |
163,340 | cilium/cilium | pkg/status/status.go | runProbe | func (c *Collector) runProbe(p *Probe) {
var (
statusData interface{}
err error
warningThreshold = time.After(c.config.WarningThreshold)
hardTimeout = false
probeReturned = make(chan struct{}, 1)
ctx, cancel = context.WithTimeout(context.Background(), c.config.FailureThreshold)
ctxTimeout = make(chan struct{}, 1)
)
c.Lock()
c.probeStartTime[p.Name] = time.Now()
c.Unlock()
go func() {
statusData, err = p.Probe(ctx)
close(probeReturned)
}()
go func() {
// Once ctx.Done() has been closed, we notify the polling loop by
// sending to the ctxTimeout channel. We cannot just close the channel,
// because otherwise the loop will always enter the "<-ctxTimeout" case.
<-ctx.Done()
ctxTimeout <- struct{}{}
}()
// This is a loop so that, when we hit a FailureThreshold, we still do
// not return until the probe returns. This is to ensure the same probe
// does not run again while it is blocked.
for {
select {
case <-c.stop:
// Collector was closed. The probe will complete in the background
// and won't be restarted again.
cancel()
return
case <-warningThreshold:
// Just warn and continue waiting for probe
log.WithField(logfields.Probe, p.Name).
Warnf("No response from probe within %v seconds",
c.config.WarningThreshold.Seconds())
case <-probeReturned:
// The probe completed and we can return from runProbe
switch {
case hardTimeout:
// FailureThreshold was already reached. Keep the failure error
// message
case err != nil:
c.updateProbeStatus(p, nil, false, err)
default:
c.updateProbeStatus(p, statusData, false, nil)
}
cancel()
return
case <-ctxTimeout:
// We have timed out. Report a status and mark that we timed out so we
// do not emit status later.
staleErr := fmt.Errorf("No response from %s probe within %v seconds",
p.Name, c.config.FailureThreshold.Seconds())
c.updateProbeStatus(p, nil, true, staleErr)
hardTimeout = true
}
}
} | go | func (c *Collector) runProbe(p *Probe) {
var (
statusData interface{}
err error
warningThreshold = time.After(c.config.WarningThreshold)
hardTimeout = false
probeReturned = make(chan struct{}, 1)
ctx, cancel = context.WithTimeout(context.Background(), c.config.FailureThreshold)
ctxTimeout = make(chan struct{}, 1)
)
c.Lock()
c.probeStartTime[p.Name] = time.Now()
c.Unlock()
go func() {
statusData, err = p.Probe(ctx)
close(probeReturned)
}()
go func() {
// Once ctx.Done() has been closed, we notify the polling loop by
// sending to the ctxTimeout channel. We cannot just close the channel,
// because otherwise the loop will always enter the "<-ctxTimeout" case.
<-ctx.Done()
ctxTimeout <- struct{}{}
}()
// This is a loop so that, when we hit a FailureThreshold, we still do
// not return until the probe returns. This is to ensure the same probe
// does not run again while it is blocked.
for {
select {
case <-c.stop:
// Collector was closed. The probe will complete in the background
// and won't be restarted again.
cancel()
return
case <-warningThreshold:
// Just warn and continue waiting for probe
log.WithField(logfields.Probe, p.Name).
Warnf("No response from probe within %v seconds",
c.config.WarningThreshold.Seconds())
case <-probeReturned:
// The probe completed and we can return from runProbe
switch {
case hardTimeout:
// FailureThreshold was already reached. Keep the failure error
// message
case err != nil:
c.updateProbeStatus(p, nil, false, err)
default:
c.updateProbeStatus(p, statusData, false, nil)
}
cancel()
return
case <-ctxTimeout:
// We have timed out. Report a status and mark that we timed out so we
// do not emit status later.
staleErr := fmt.Errorf("No response from %s probe within %v seconds",
p.Name, c.config.FailureThreshold.Seconds())
c.updateProbeStatus(p, nil, true, staleErr)
hardTimeout = true
}
}
} | [
"func",
"(",
"c",
"*",
"Collector",
")",
"runProbe",
"(",
"p",
"*",
"Probe",
")",
"{",
"var",
"(",
"statusData",
"interface",
"{",
"}",
"\n",
"err",
"error",
"\n",
"warningThreshold",
"=",
"time",
".",
"After",
"(",
"c",
".",
"config",
".",
"WarningT... | // runProbe runs the given probe, and returns either after the probe has returned
// or after the collector has been closed. | [
"runProbe",
"runs",
"the",
"given",
"probe",
"and",
"returns",
"either",
"after",
"the",
"probe",
"has",
"returned",
"or",
"after",
"the",
"collector",
"has",
"been",
"closed",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/status/status.go#L165-L234 |
163,341 | cilium/cilium | api/v1/server/restapi/policy/delete_fqdn_cache.go | NewDeleteFqdnCache | func NewDeleteFqdnCache(ctx *middleware.Context, handler DeleteFqdnCacheHandler) *DeleteFqdnCache {
return &DeleteFqdnCache{Context: ctx, Handler: handler}
} | go | func NewDeleteFqdnCache(ctx *middleware.Context, handler DeleteFqdnCacheHandler) *DeleteFqdnCache {
return &DeleteFqdnCache{Context: ctx, Handler: handler}
} | [
"func",
"NewDeleteFqdnCache",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"DeleteFqdnCacheHandler",
")",
"*",
"DeleteFqdnCache",
"{",
"return",
"&",
"DeleteFqdnCache",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}... | // NewDeleteFqdnCache creates a new http.Handler for the delete fqdn cache operation | [
"NewDeleteFqdnCache",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"delete",
"fqdn",
"cache",
"operation"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/delete_fqdn_cache.go#L28-L30 |
163,342 | cilium/cilium | api/v1/client/policy/get_policy_resolve_parameters.go | WithTimeout | func (o *GetPolicyResolveParams) WithTimeout(timeout time.Duration) *GetPolicyResolveParams {
o.SetTimeout(timeout)
return o
} | go | func (o *GetPolicyResolveParams) WithTimeout(timeout time.Duration) *GetPolicyResolveParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"GetPolicyResolveParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"GetPolicyResolveParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the get policy resolve params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"get",
"policy",
"resolve",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/get_policy_resolve_parameters.go#L78-L81 |
163,343 | cilium/cilium | api/v1/client/policy/get_policy_resolve_parameters.go | WithContext | func (o *GetPolicyResolveParams) WithContext(ctx context.Context) *GetPolicyResolveParams {
o.SetContext(ctx)
return o
} | go | func (o *GetPolicyResolveParams) WithContext(ctx context.Context) *GetPolicyResolveParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"GetPolicyResolveParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"GetPolicyResolveParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the get policy resolve params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"get",
"policy",
"resolve",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/get_policy_resolve_parameters.go#L89-L92 |
163,344 | cilium/cilium | api/v1/client/policy/get_policy_resolve_parameters.go | WithHTTPClient | func (o *GetPolicyResolveParams) WithHTTPClient(client *http.Client) *GetPolicyResolveParams {
o.SetHTTPClient(client)
return o
} | go | func (o *GetPolicyResolveParams) WithHTTPClient(client *http.Client) *GetPolicyResolveParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"GetPolicyResolveParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"GetPolicyResolveParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the get policy resolve params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"get",
"policy",
"resolve",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/get_policy_resolve_parameters.go#L100-L103 |
163,345 | cilium/cilium | api/v1/client/policy/get_policy_resolve_parameters.go | WithTraceSelector | func (o *GetPolicyResolveParams) WithTraceSelector(traceSelector *models.TraceSelector) *GetPolicyResolveParams {
o.SetTraceSelector(traceSelector)
return o
} | go | func (o *GetPolicyResolveParams) WithTraceSelector(traceSelector *models.TraceSelector) *GetPolicyResolveParams {
o.SetTraceSelector(traceSelector)
return o
} | [
"func",
"(",
"o",
"*",
"GetPolicyResolveParams",
")",
"WithTraceSelector",
"(",
"traceSelector",
"*",
"models",
".",
"TraceSelector",
")",
"*",
"GetPolicyResolveParams",
"{",
"o",
".",
"SetTraceSelector",
"(",
"traceSelector",
")",
"\n",
"return",
"o",
"\n",
"}"... | // WithTraceSelector adds the traceSelector to the get policy resolve params | [
"WithTraceSelector",
"adds",
"the",
"traceSelector",
"to",
"the",
"get",
"policy",
"resolve",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/get_policy_resolve_parameters.go#L111-L114 |
163,346 | cilium/cilium | pkg/identity/cache/allocator.go | InitIdentityAllocator | func InitIdentityAllocator(owner IdentityAllocatorOwner) {
setupMutex.Lock()
defer setupMutex.Unlock()
if IdentityAllocator != nil {
log.Panic("InitIdentityAllocator() in succession without calling Close()")
}
identity.InitWellKnownIdentities()
log.Info("Initializing identity allocator")
minID := idpool.ID(identity.MinimalAllocationIdentity)
maxID := idpool.ID(identity.MaximumAllocationIdentity)
events := make(allocator.AllocatorEventChan, 1024)
// It is important to start listening for events before calling
// NewAllocator() as it will emit events while filling the
// initial cache
watcher.watch(owner, events)
a, err := allocator.NewAllocator(IdentitiesPath, globalIdentity{},
allocator.WithMax(maxID), allocator.WithMin(minID),
allocator.WithSuffix(owner.GetNodeSuffix()),
allocator.WithEvents(events),
allocator.WithMasterKeyProtection(),
allocator.WithPrefixMask(idpool.ID(option.Config.ClusterID<<identity.ClusterIDShift)))
if err != nil {
log.WithError(err).Fatal("Unable to initialize identity allocator")
}
IdentityAllocator = a
close(identityAllocatorInitialized)
localIdentities = newLocalIdentityCache(1, 0xFFFFFF, events)
} | go | func InitIdentityAllocator(owner IdentityAllocatorOwner) {
setupMutex.Lock()
defer setupMutex.Unlock()
if IdentityAllocator != nil {
log.Panic("InitIdentityAllocator() in succession without calling Close()")
}
identity.InitWellKnownIdentities()
log.Info("Initializing identity allocator")
minID := idpool.ID(identity.MinimalAllocationIdentity)
maxID := idpool.ID(identity.MaximumAllocationIdentity)
events := make(allocator.AllocatorEventChan, 1024)
// It is important to start listening for events before calling
// NewAllocator() as it will emit events while filling the
// initial cache
watcher.watch(owner, events)
a, err := allocator.NewAllocator(IdentitiesPath, globalIdentity{},
allocator.WithMax(maxID), allocator.WithMin(minID),
allocator.WithSuffix(owner.GetNodeSuffix()),
allocator.WithEvents(events),
allocator.WithMasterKeyProtection(),
allocator.WithPrefixMask(idpool.ID(option.Config.ClusterID<<identity.ClusterIDShift)))
if err != nil {
log.WithError(err).Fatal("Unable to initialize identity allocator")
}
IdentityAllocator = a
close(identityAllocatorInitialized)
localIdentities = newLocalIdentityCache(1, 0xFFFFFF, events)
} | [
"func",
"InitIdentityAllocator",
"(",
"owner",
"IdentityAllocatorOwner",
")",
"{",
"setupMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"setupMutex",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"IdentityAllocator",
"!=",
"nil",
"{",
"log",
".",
"Panic",
"(",
"\"",... | // InitIdentityAllocator creates the the identity allocator. Only the first
// invocation of this function will have an effect. | [
"InitIdentityAllocator",
"creates",
"the",
"the",
"identity",
"allocator",
".",
"Only",
"the",
"first",
"invocation",
"of",
"this",
"function",
"will",
"have",
"an",
"effect",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/cache/allocator.go#L90-L125 |
163,347 | cilium/cilium | pkg/identity/cache/allocator.go | WaitForInitialIdentities | func WaitForInitialIdentities(ctx context.Context) error {
select {
case <-identityAllocatorInitialized:
case <-ctx.Done():
return fmt.Errorf("initial identity sync was cancelled: %s", ctx.Err())
}
return IdentityAllocator.WaitForInitialSync(ctx)
} | go | func WaitForInitialIdentities(ctx context.Context) error {
select {
case <-identityAllocatorInitialized:
case <-ctx.Done():
return fmt.Errorf("initial identity sync was cancelled: %s", ctx.Err())
}
return IdentityAllocator.WaitForInitialSync(ctx)
} | [
"func",
"WaitForInitialIdentities",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"select",
"{",
"case",
"<-",
"identityAllocatorInitialized",
":",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\""... | // WaitForInitialIdentities waits for the initial set of security identities to
// have been received and populated into the allocator cache | [
"WaitForInitialIdentities",
"waits",
"for",
"the",
"initial",
"set",
"of",
"security",
"identities",
"to",
"have",
"been",
"received",
"and",
"populated",
"into",
"the",
"allocator",
"cache"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/cache/allocator.go#L151-L159 |
163,348 | cilium/cilium | pkg/identity/cache/allocator.go | AllocateIdentity | func AllocateIdentity(ctx context.Context, lbls labels.Labels) (*identity.Identity, bool, error) {
log.WithFields(logrus.Fields{
logfields.IdentityLabels: lbls.String(),
}).Debug("Resolving identity")
// If there is only one label with the "reserved" source and a well-known
// key, use the well-known identity for that key.
if reservedIdentity := LookupReservedIdentityByLabels(lbls); reservedIdentity != nil {
log.WithFields(logrus.Fields{
logfields.Identity: reservedIdentity.ID,
logfields.IdentityLabels: lbls.String(),
"isNew": false,
}).Debug("Resolved reserved identity")
return reservedIdentity, false, nil
}
if !identity.RequiresGlobalIdentity(lbls) && localIdentities != nil {
return localIdentities.lookupOrCreate(lbls)
}
// This will block until the kvstore can be accessed and all identities
// were succesfully synced
WaitForInitialIdentities(ctx)
if IdentityAllocator == nil {
return nil, false, fmt.Errorf("allocator not initialized")
}
id, isNew, err := IdentityAllocator.Allocate(ctx, globalIdentity{lbls.LabelArray()})
if err != nil {
return nil, false, err
}
log.WithFields(logrus.Fields{
logfields.Identity: id,
logfields.IdentityLabels: lbls.String(),
"isNew": isNew,
}).Debug("Resolved identity")
return identity.NewIdentity(identity.NumericIdentity(id), lbls), isNew, nil
} | go | func AllocateIdentity(ctx context.Context, lbls labels.Labels) (*identity.Identity, bool, error) {
log.WithFields(logrus.Fields{
logfields.IdentityLabels: lbls.String(),
}).Debug("Resolving identity")
// If there is only one label with the "reserved" source and a well-known
// key, use the well-known identity for that key.
if reservedIdentity := LookupReservedIdentityByLabels(lbls); reservedIdentity != nil {
log.WithFields(logrus.Fields{
logfields.Identity: reservedIdentity.ID,
logfields.IdentityLabels: lbls.String(),
"isNew": false,
}).Debug("Resolved reserved identity")
return reservedIdentity, false, nil
}
if !identity.RequiresGlobalIdentity(lbls) && localIdentities != nil {
return localIdentities.lookupOrCreate(lbls)
}
// This will block until the kvstore can be accessed and all identities
// were succesfully synced
WaitForInitialIdentities(ctx)
if IdentityAllocator == nil {
return nil, false, fmt.Errorf("allocator not initialized")
}
id, isNew, err := IdentityAllocator.Allocate(ctx, globalIdentity{lbls.LabelArray()})
if err != nil {
return nil, false, err
}
log.WithFields(logrus.Fields{
logfields.Identity: id,
logfields.IdentityLabels: lbls.String(),
"isNew": isNew,
}).Debug("Resolved identity")
return identity.NewIdentity(identity.NumericIdentity(id), lbls), isNew, nil
} | [
"func",
"AllocateIdentity",
"(",
"ctx",
"context",
".",
"Context",
",",
"lbls",
"labels",
".",
"Labels",
")",
"(",
"*",
"identity",
".",
"Identity",
",",
"bool",
",",
"error",
")",
"{",
"log",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"logf... | // AllocateIdentity allocates an identity described by the specified labels. If
// an identity for the specified set of labels already exist, the identity is
// re-used and reference counting is performed, otherwise a new identity is
// allocated via the kvstore. | [
"AllocateIdentity",
"allocates",
"an",
"identity",
"described",
"by",
"the",
"specified",
"labels",
".",
"If",
"an",
"identity",
"for",
"the",
"specified",
"set",
"of",
"labels",
"already",
"exist",
"the",
"identity",
"is",
"re",
"-",
"used",
"and",
"reference... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/cache/allocator.go#L177-L217 |
163,349 | cilium/cilium | pkg/identity/cache/allocator.go | ReleaseSlice | func ReleaseSlice(ctx context.Context, identities []*identity.Identity) error {
var err error
for _, id := range identities {
if id == nil {
continue
}
if _, err2 := Release(ctx, id); err2 != nil {
log.WithError(err2).WithFields(logrus.Fields{
logfields.Identity: id,
}).Error("Failed to release identity")
err = err2
}
}
return err
} | go | func ReleaseSlice(ctx context.Context, identities []*identity.Identity) error {
var err error
for _, id := range identities {
if id == nil {
continue
}
if _, err2 := Release(ctx, id); err2 != nil {
log.WithError(err2).WithFields(logrus.Fields{
logfields.Identity: id,
}).Error("Failed to release identity")
err = err2
}
}
return err
} | [
"func",
"ReleaseSlice",
"(",
"ctx",
"context",
".",
"Context",
",",
"identities",
"[",
"]",
"*",
"identity",
".",
"Identity",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"for",
"_",
",",
"id",
":=",
"range",
"identities",
"{",
"if",
"id",
"==",
"... | // ReleaseSlice attempts to release a set of identities. It is a helper
// function that may be useful for cleaning up multiple identities in paths
// where several identities may be allocated and another error means that they
// should all be released. | [
"ReleaseSlice",
"attempts",
"to",
"release",
"a",
"set",
"of",
"identities",
".",
"It",
"is",
"a",
"helper",
"function",
"that",
"may",
"be",
"useful",
"for",
"cleaning",
"up",
"multiple",
"identities",
"in",
"paths",
"where",
"several",
"identities",
"may",
... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/cache/allocator.go#L248-L262 |
163,350 | cilium/cilium | pkg/identity/cache/allocator.go | WatchRemoteIdentities | func WatchRemoteIdentities(backend kvstore.BackendOperations) *allocator.RemoteCache {
<-identityAllocatorInitialized
return IdentityAllocator.WatchRemoteKVStore(backend, IdentitiesPath)
} | go | func WatchRemoteIdentities(backend kvstore.BackendOperations) *allocator.RemoteCache {
<-identityAllocatorInitialized
return IdentityAllocator.WatchRemoteKVStore(backend, IdentitiesPath)
} | [
"func",
"WatchRemoteIdentities",
"(",
"backend",
"kvstore",
".",
"BackendOperations",
")",
"*",
"allocator",
".",
"RemoteCache",
"{",
"<-",
"identityAllocatorInitialized",
"\n",
"return",
"IdentityAllocator",
".",
"WatchRemoteKVStore",
"(",
"backend",
",",
"IdentitiesPa... | // WatchRemoteIdentities starts watching for identities in another kvstore and
// syncs all identities to the local identity cache. | [
"WatchRemoteIdentities",
"starts",
"watching",
"for",
"identities",
"in",
"another",
"kvstore",
"and",
"syncs",
"all",
"identities",
"to",
"the",
"local",
"identity",
"cache",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/cache/allocator.go#L266-L269 |
163,351 | cilium/cilium | pkg/maps/lbmap/lbmap.go | DeleteService | func DeleteService(key ServiceKey) error {
mutex.Lock()
defer mutex.Unlock()
err := deleteServiceLocked(key)
if err != nil {
return err
}
return nil
} | go | func DeleteService(key ServiceKey) error {
mutex.Lock()
defer mutex.Unlock()
err := deleteServiceLocked(key)
if err != nil {
return err
}
return nil
} | [
"func",
"DeleteService",
"(",
"key",
"ServiceKey",
")",
"error",
"{",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"err",
":=",
"deleteServiceLocked",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"... | // DeleteService deletes a legacy service from the lbmap. The given key has to
// be of the master service. | [
"DeleteService",
"deletes",
"a",
"legacy",
"service",
"from",
"the",
"lbmap",
".",
"The",
"given",
"key",
"has",
"to",
"be",
"of",
"the",
"master",
"service",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/lbmap.go#L70-L80 |
163,352 | cilium/cilium | pkg/maps/lbmap/lbmap.go | updateServiceWeights | func updateServiceWeights(key ServiceKey, value *RRSeqValue) error {
if _, err := key.RRMap().OpenOrCreate(); err != nil {
return err
}
return key.RRMap().Update(key.ToNetwork(), value)
} | go | func updateServiceWeights(key ServiceKey, value *RRSeqValue) error {
if _, err := key.RRMap().OpenOrCreate(); err != nil {
return err
}
return key.RRMap().Update(key.ToNetwork(), value)
} | [
"func",
"updateServiceWeights",
"(",
"key",
"ServiceKey",
",",
"value",
"*",
"RRSeqValue",
")",
"error",
"{",
"if",
"_",
",",
"err",
":=",
"key",
".",
"RRMap",
"(",
")",
".",
"OpenOrCreate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\... | // updateServiceWeights updates cilium_lb6_rr_seq or cilium_lb4_rr_seq bpf maps. | [
"updateServiceWeights",
"updates",
"cilium_lb6_rr_seq",
"or",
"cilium_lb4_rr_seq",
"bpf",
"maps",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/lbmap.go#L108-L114 |
163,353 | cilium/cilium | pkg/maps/lbmap/lbmap.go | lookupAndDeleteServiceWeights | func lookupAndDeleteServiceWeights(key ServiceKey) error {
_, err := key.RRMap().Lookup(key.ToNetwork())
if err != nil {
// Ignore if entry is not found.
return nil
}
return key.RRMap().Delete(key.ToNetwork())
} | go | func lookupAndDeleteServiceWeights(key ServiceKey) error {
_, err := key.RRMap().Lookup(key.ToNetwork())
if err != nil {
// Ignore if entry is not found.
return nil
}
return key.RRMap().Delete(key.ToNetwork())
} | [
"func",
"lookupAndDeleteServiceWeights",
"(",
"key",
"ServiceKey",
")",
"error",
"{",
"_",
",",
"err",
":=",
"key",
".",
"RRMap",
"(",
")",
".",
"Lookup",
"(",
"key",
".",
"ToNetwork",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Ignore if e... | // lookupAndDeleteServiceWeights deletes entry from cilium_lb6_rr_seq or cilium_lb4_rr_seq | [
"lookupAndDeleteServiceWeights",
"deletes",
"entry",
"from",
"cilium_lb6_rr_seq",
"or",
"cilium_lb4_rr_seq"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/lbmap.go#L117-L125 |
163,354 | cilium/cilium | pkg/maps/lbmap/lbmap.go | gcd | func gcd(x, y uint16) uint16 {
for y != 0 {
x, y = y, x%y
}
return x
} | go | func gcd(x, y uint16) uint16 {
for y != 0 {
x, y = y, x%y
}
return x
} | [
"func",
"gcd",
"(",
"x",
",",
"y",
"uint16",
")",
"uint16",
"{",
"for",
"y",
"!=",
"0",
"{",
"x",
",",
"y",
"=",
"y",
",",
"x",
"%",
"y",
"\n",
"}",
"\n",
"return",
"x",
"\n",
"}"
] | // gcd computes the gcd of two numbers. | [
"gcd",
"computes",
"the",
"gcd",
"of",
"two",
"numbers",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/lbmap.go#L164-L169 |
163,355 | cilium/cilium | pkg/maps/lbmap/lbmap.go | generateWrrSeq | func generateWrrSeq(weights []uint16) (*RRSeqValue, error) {
svcRRSeq := RRSeqValue{}
n := len(weights)
if n < 2 {
return nil, fmt.Errorf("needs at least 2 weights")
}
g := uint16(0)
for i := 0; i < n; i++ {
if weights[i] != 0 {
g = gcd(g, weights[i])
}
}
// This means all the weights are 0.
if g == 0 {
return nil, fmt.Errorf("all specified weights are 0")
}
sum := uint16(0)
for i := range weights {
// Normalize the weights.
weights[i] = weights[i] / g
sum += weights[i]
}
// Check if Generated seq fits in our array.
if int(sum) > len(svcRRSeq.Idx) {
return nil, fmt.Errorf("sum of normalized weights exceeds %d", len(svcRRSeq.Idx))
}
// Generate the Sequence.
i := uint16(0)
k := uint16(0)
for {
j := uint16(0)
for j < weights[k] {
svcRRSeq.Idx[i] = k
i++
j++
}
if i >= sum {
break
}
k++
}
svcRRSeq.Count = sum
return &svcRRSeq, nil
} | go | func generateWrrSeq(weights []uint16) (*RRSeqValue, error) {
svcRRSeq := RRSeqValue{}
n := len(weights)
if n < 2 {
return nil, fmt.Errorf("needs at least 2 weights")
}
g := uint16(0)
for i := 0; i < n; i++ {
if weights[i] != 0 {
g = gcd(g, weights[i])
}
}
// This means all the weights are 0.
if g == 0 {
return nil, fmt.Errorf("all specified weights are 0")
}
sum := uint16(0)
for i := range weights {
// Normalize the weights.
weights[i] = weights[i] / g
sum += weights[i]
}
// Check if Generated seq fits in our array.
if int(sum) > len(svcRRSeq.Idx) {
return nil, fmt.Errorf("sum of normalized weights exceeds %d", len(svcRRSeq.Idx))
}
// Generate the Sequence.
i := uint16(0)
k := uint16(0)
for {
j := uint16(0)
for j < weights[k] {
svcRRSeq.Idx[i] = k
i++
j++
}
if i >= sum {
break
}
k++
}
svcRRSeq.Count = sum
return &svcRRSeq, nil
} | [
"func",
"generateWrrSeq",
"(",
"weights",
"[",
"]",
"uint16",
")",
"(",
"*",
"RRSeqValue",
",",
"error",
")",
"{",
"svcRRSeq",
":=",
"RRSeqValue",
"{",
"}",
"\n\n",
"n",
":=",
"len",
"(",
"weights",
")",
"\n",
"if",
"n",
"<",
"2",
"{",
"return",
"n... | // generateWrrSeq generates a wrr sequence based on provided weights. | [
"generateWrrSeq",
"generates",
"a",
"wrr",
"sequence",
"based",
"on",
"provided",
"weights",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/lbmap.go#L172-L221 |
163,356 | cilium/cilium | pkg/maps/lbmap/lbmap.go | DumpBackendMapsToUserspace | func DumpBackendMapsToUserspace() (map[BackendAddrID]*loadbalancer.LBBackEnd, error) {
backendValueMap := map[loadbalancer.BackendID]BackendValue{}
lbBackends := map[BackendAddrID]*loadbalancer.LBBackEnd{}
parseBackendEntries := func(key bpf.MapKey, value bpf.MapValue) {
backendKey := key.(BackendKey)
backendValue := value.(BackendValue)
backendValueMap[backendKey.GetID()] = backendValue
}
if option.Config.EnableIPv4 {
err := Backend4Map.DumpWithCallback(parseBackendEntries)
if err != nil {
return nil, fmt.Errorf("Unable to dump lb4 backends map: %s", err)
}
}
if option.Config.EnableIPv6 {
err := Backend6Map.DumpWithCallback(parseBackendEntries)
if err != nil {
return nil, fmt.Errorf("Unable to dump lb6 backends map: %s", err)
}
}
for backendID, backendVal := range backendValueMap {
ip := backendVal.GetAddress()
port := backendVal.GetPort()
weight := uint16(0) // FIXME(brb): set weight when we support it
proto := loadbalancer.NONE
lbBackend := loadbalancer.NewLBBackEnd(backendID, proto, ip, port, weight)
lbBackends[backendVal.BackendAddrID()] = lbBackend
}
return lbBackends, nil
} | go | func DumpBackendMapsToUserspace() (map[BackendAddrID]*loadbalancer.LBBackEnd, error) {
backendValueMap := map[loadbalancer.BackendID]BackendValue{}
lbBackends := map[BackendAddrID]*loadbalancer.LBBackEnd{}
parseBackendEntries := func(key bpf.MapKey, value bpf.MapValue) {
backendKey := key.(BackendKey)
backendValue := value.(BackendValue)
backendValueMap[backendKey.GetID()] = backendValue
}
if option.Config.EnableIPv4 {
err := Backend4Map.DumpWithCallback(parseBackendEntries)
if err != nil {
return nil, fmt.Errorf("Unable to dump lb4 backends map: %s", err)
}
}
if option.Config.EnableIPv6 {
err := Backend6Map.DumpWithCallback(parseBackendEntries)
if err != nil {
return nil, fmt.Errorf("Unable to dump lb6 backends map: %s", err)
}
}
for backendID, backendVal := range backendValueMap {
ip := backendVal.GetAddress()
port := backendVal.GetPort()
weight := uint16(0) // FIXME(brb): set weight when we support it
proto := loadbalancer.NONE
lbBackend := loadbalancer.NewLBBackEnd(backendID, proto, ip, port, weight)
lbBackends[backendVal.BackendAddrID()] = lbBackend
}
return lbBackends, nil
} | [
"func",
"DumpBackendMapsToUserspace",
"(",
")",
"(",
"map",
"[",
"BackendAddrID",
"]",
"*",
"loadbalancer",
".",
"LBBackEnd",
",",
"error",
")",
"{",
"backendValueMap",
":=",
"map",
"[",
"loadbalancer",
".",
"BackendID",
"]",
"BackendValue",
"{",
"}",
"\n",
... | // DumpBackendMapsToUserspace dumps the backend entries from the BPF maps. | [
"DumpBackendMapsToUserspace",
"dumps",
"the",
"backend",
"entries",
"from",
"the",
"BPF",
"maps",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/lbmap.go#L719-L753 |
163,357 | cilium/cilium | pkg/maps/lbmap/lbmap.go | DumpRevNATMapsToUserspace | func DumpRevNATMapsToUserspace() (loadbalancer.RevNATMap, []error) {
newRevNATMap := loadbalancer.RevNATMap{}
errors := []error{}
parseRevNATEntries := func(key bpf.MapKey, value bpf.MapValue) {
revNatK := key.(RevNatKey)
revNatV := value.(RevNatValue)
scopedLog := log.WithFields(logrus.Fields{
logfields.BPFMapKey: revNatK,
logfields.BPFMapValue: revNatV,
})
scopedLog.Debug("parsing BPF revNAT mapping")
fe := revNatValue2L3n4AddrID(revNatK, revNatV)
newRevNATMap[loadbalancer.ServiceID(fe.ID)] = fe.L3n4Addr
}
mutex.RLock()
defer mutex.RUnlock()
if option.Config.EnableIPv4 {
if err := RevNat4Map.DumpWithCallback(parseRevNATEntries); err != nil {
err = fmt.Errorf("error dumping RevNat4Map: %s", err)
errors = append(errors, err)
}
}
if option.Config.EnableIPv6 {
if err := RevNat6Map.DumpWithCallback(parseRevNATEntries); err != nil {
err = fmt.Errorf("error dumping RevNat6Map: %s", err)
errors = append(errors, err)
}
}
return newRevNATMap, errors
} | go | func DumpRevNATMapsToUserspace() (loadbalancer.RevNATMap, []error) {
newRevNATMap := loadbalancer.RevNATMap{}
errors := []error{}
parseRevNATEntries := func(key bpf.MapKey, value bpf.MapValue) {
revNatK := key.(RevNatKey)
revNatV := value.(RevNatValue)
scopedLog := log.WithFields(logrus.Fields{
logfields.BPFMapKey: revNatK,
logfields.BPFMapValue: revNatV,
})
scopedLog.Debug("parsing BPF revNAT mapping")
fe := revNatValue2L3n4AddrID(revNatK, revNatV)
newRevNATMap[loadbalancer.ServiceID(fe.ID)] = fe.L3n4Addr
}
mutex.RLock()
defer mutex.RUnlock()
if option.Config.EnableIPv4 {
if err := RevNat4Map.DumpWithCallback(parseRevNATEntries); err != nil {
err = fmt.Errorf("error dumping RevNat4Map: %s", err)
errors = append(errors, err)
}
}
if option.Config.EnableIPv6 {
if err := RevNat6Map.DumpWithCallback(parseRevNATEntries); err != nil {
err = fmt.Errorf("error dumping RevNat6Map: %s", err)
errors = append(errors, err)
}
}
return newRevNATMap, errors
} | [
"func",
"DumpRevNATMapsToUserspace",
"(",
")",
"(",
"loadbalancer",
".",
"RevNATMap",
",",
"[",
"]",
"error",
")",
"{",
"newRevNATMap",
":=",
"loadbalancer",
".",
"RevNATMap",
"{",
"}",
"\n",
"errors",
":=",
"[",
"]",
"error",
"{",
"}",
"\n\n",
"parseRevNA... | // DumpRevNATMapsToUserspace dumps the contents of both the IPv6 and IPv4
// revNAT BPF maps, and stores the contents of said dumps in a RevNATMap.
// Returns the errors that occurred while dumping the maps. | [
"DumpRevNATMapsToUserspace",
"dumps",
"the",
"contents",
"of",
"both",
"the",
"IPv6",
"and",
"IPv4",
"revNAT",
"BPF",
"maps",
"and",
"stores",
"the",
"contents",
"of",
"said",
"dumps",
"in",
"a",
"RevNATMap",
".",
"Returns",
"the",
"errors",
"that",
"occurred"... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/lbmap.go#L758-L794 |
163,358 | cilium/cilium | pkg/maps/lbmap/lbmap.go | RestoreService | func RestoreService(svc loadbalancer.LBSVC, v2Exists bool) error {
return cache.restoreService(svc, v2Exists)
} | go | func RestoreService(svc loadbalancer.LBSVC, v2Exists bool) error {
return cache.restoreService(svc, v2Exists)
} | [
"func",
"RestoreService",
"(",
"svc",
"loadbalancer",
".",
"LBSVC",
",",
"v2Exists",
"bool",
")",
"error",
"{",
"return",
"cache",
".",
"restoreService",
"(",
"svc",
",",
"v2Exists",
")",
"\n",
"}"
] | // RestoreService restores a single service in the cache. This is required to
// guarantee consistent backend ordering, slave slot and backend by backend
// address ID lookups. | [
"RestoreService",
"restores",
"a",
"single",
"service",
"in",
"the",
"cache",
".",
"This",
"is",
"required",
"to",
"guarantee",
"consistent",
"backend",
"ordering",
"slave",
"slot",
"and",
"backend",
"by",
"backend",
"address",
"ID",
"lookups",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/lbmap.go#L799-L801 |
163,359 | cilium/cilium | pkg/maps/lbmap/lbmap.go | updateServiceWeightsV2 | func updateServiceWeightsV2(key ServiceKeyV2, value *RRSeqValue) error {
if _, err := key.RRMap().OpenOrCreate(); err != nil {
return err
}
return key.RRMap().Update(key.ToNetwork(), value)
} | go | func updateServiceWeightsV2(key ServiceKeyV2, value *RRSeqValue) error {
if _, err := key.RRMap().OpenOrCreate(); err != nil {
return err
}
return key.RRMap().Update(key.ToNetwork(), value)
} | [
"func",
"updateServiceWeightsV2",
"(",
"key",
"ServiceKeyV2",
",",
"value",
"*",
"RRSeqValue",
")",
"error",
"{",
"if",
"_",
",",
"err",
":=",
"key",
".",
"RRMap",
"(",
")",
".",
"OpenOrCreate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
... | // updateServiceWeightsV2 updates cilium_lb6_rr_seq_v2 or cilium_lb4_rr_seq_v2 bpf maps. | [
"updateServiceWeightsV2",
"updates",
"cilium_lb6_rr_seq_v2",
"or",
"cilium_lb4_rr_seq_v2",
"bpf",
"maps",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/lbmap.go#L840-L846 |
163,360 | cilium/cilium | pkg/maps/lbmap/lbmap.go | lookupAndDeleteServiceWeightsV2 | func lookupAndDeleteServiceWeightsV2(key ServiceKeyV2) error {
_, err := key.RRMap().Lookup(key.ToNetwork())
if err != nil {
// Ignore if entry is not found.
return nil
}
return key.RRMap().Delete(key.ToNetwork())
} | go | func lookupAndDeleteServiceWeightsV2(key ServiceKeyV2) error {
_, err := key.RRMap().Lookup(key.ToNetwork())
if err != nil {
// Ignore if entry is not found.
return nil
}
return key.RRMap().Delete(key.ToNetwork())
} | [
"func",
"lookupAndDeleteServiceWeightsV2",
"(",
"key",
"ServiceKeyV2",
")",
"error",
"{",
"_",
",",
"err",
":=",
"key",
".",
"RRMap",
"(",
")",
".",
"Lookup",
"(",
"key",
".",
"ToNetwork",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Ignore ... | // lookupAndDeleteServiceWeightsV2 deletes entry from cilium_lb6_rr_seq or cilium_lb4_rr_seq | [
"lookupAndDeleteServiceWeightsV2",
"deletes",
"entry",
"from",
"cilium_lb6_rr_seq",
"or",
"cilium_lb4_rr_seq"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/lbmap.go#L857-L865 |
163,361 | cilium/cilium | pkg/maps/lbmap/lbmap.go | DeleteServiceV2 | func DeleteServiceV2(svc loadbalancer.L3n4AddrID, releaseBackendID func(loadbalancer.BackendID)) error {
var (
backendKey BackendKey
svcKey ServiceKeyV2
)
mutex.Lock()
defer mutex.Unlock()
isIPv6 := svc.IsIPv6()
log.WithField(logfields.ServiceName, svc).Debug("Deleting service")
if isIPv6 {
svcKey = NewService6KeyV2(svc.IP, svc.Port, u8proto.All, 0)
} else {
svcKey = NewService4KeyV2(svc.IP, svc.Port, u8proto.All, 0)
}
backendsToRemove, backendsCount, err := cache.removeServiceV2(svcKey)
if err != nil {
return err
}
for slot := 0; slot <= backendsCount; slot++ {
svcKey.SetSlave(slot)
if err := svcKey.MapDelete(); err != nil {
return err
}
}
if isIPv6 {
backendKey = NewBackend6Key(0)
} else {
backendKey = NewBackend4Key(0)
}
for _, id := range backendsToRemove {
backendKey.SetID(id)
if err := deleteBackendLocked(backendKey); err != nil {
return fmt.Errorf("Unable to delete backend with ID %d: %s", id, err)
}
releaseBackendID(id)
log.WithField(logfields.BackendID, id).Debug("Deleted backend")
}
return nil
} | go | func DeleteServiceV2(svc loadbalancer.L3n4AddrID, releaseBackendID func(loadbalancer.BackendID)) error {
var (
backendKey BackendKey
svcKey ServiceKeyV2
)
mutex.Lock()
defer mutex.Unlock()
isIPv6 := svc.IsIPv6()
log.WithField(logfields.ServiceName, svc).Debug("Deleting service")
if isIPv6 {
svcKey = NewService6KeyV2(svc.IP, svc.Port, u8proto.All, 0)
} else {
svcKey = NewService4KeyV2(svc.IP, svc.Port, u8proto.All, 0)
}
backendsToRemove, backendsCount, err := cache.removeServiceV2(svcKey)
if err != nil {
return err
}
for slot := 0; slot <= backendsCount; slot++ {
svcKey.SetSlave(slot)
if err := svcKey.MapDelete(); err != nil {
return err
}
}
if isIPv6 {
backendKey = NewBackend6Key(0)
} else {
backendKey = NewBackend4Key(0)
}
for _, id := range backendsToRemove {
backendKey.SetID(id)
if err := deleteBackendLocked(backendKey); err != nil {
return fmt.Errorf("Unable to delete backend with ID %d: %s", id, err)
}
releaseBackendID(id)
log.WithField(logfields.BackendID, id).Debug("Deleted backend")
}
return nil
} | [
"func",
"DeleteServiceV2",
"(",
"svc",
"loadbalancer",
".",
"L3n4AddrID",
",",
"releaseBackendID",
"func",
"(",
"loadbalancer",
".",
"BackendID",
")",
")",
"error",
"{",
"var",
"(",
"backendKey",
"BackendKey",
"\n",
"svcKey",
"ServiceKeyV2",
"\n",
")",
"\n\n",
... | // DeleteServiceV2 deletes a service from the lbmap and deletes backends of it if
// they are not used by any other service.
//
//The given key has to be of the master service. | [
"DeleteServiceV2",
"deletes",
"a",
"service",
"from",
"the",
"lbmap",
"and",
"deletes",
"backends",
"of",
"it",
"if",
"they",
"are",
"not",
"used",
"by",
"any",
"other",
"service",
".",
"The",
"given",
"key",
"has",
"to",
"be",
"of",
"the",
"master",
"se... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/lbmap.go#L904-L951 |
163,362 | cilium/cilium | pkg/maps/lbmap/lbmap.go | DeleteServiceCache | func DeleteServiceCache(svc loadbalancer.L3n4AddrID) {
var svcKey ServiceKey
if !svc.IsIPv6() {
svcKey = NewService4Key(svc.IP, svc.Port, 0)
} else {
svcKey = NewService6Key(svc.IP, svc.Port, 0)
}
cache.delete(svcKey)
} | go | func DeleteServiceCache(svc loadbalancer.L3n4AddrID) {
var svcKey ServiceKey
if !svc.IsIPv6() {
svcKey = NewService4Key(svc.IP, svc.Port, 0)
} else {
svcKey = NewService6Key(svc.IP, svc.Port, 0)
}
cache.delete(svcKey)
} | [
"func",
"DeleteServiceCache",
"(",
"svc",
"loadbalancer",
".",
"L3n4AddrID",
")",
"{",
"var",
"svcKey",
"ServiceKey",
"\n\n",
"if",
"!",
"svc",
".",
"IsIPv6",
"(",
")",
"{",
"svcKey",
"=",
"NewService4Key",
"(",
"svc",
".",
"IP",
",",
"svc",
".",
"Port",... | // DeleteServiceCache deletes the service cache. | [
"DeleteServiceCache",
"deletes",
"the",
"service",
"cache",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/lbmap.go#L954-L964 |
163,363 | cilium/cilium | pkg/datapath/loader/cache.go | Init | func Init(dp datapath.Datapath, nodeCfg *datapath.LocalNodeConfiguration) {
once.Do(func() {
templateCache = NewObjectCache(dp, nodeCfg)
ignorePrefixes := ignoredELFPrefixes
if !option.Config.EnableIPv4 {
ignorePrefixes = append(ignorePrefixes, "LXC_IPV4")
}
if !option.Config.EnableIPv6 {
ignorePrefixes = append(ignorePrefixes, "LXC_IP_")
}
elf.IgnoreSymbolPrefixes(ignorePrefixes)
})
templateCache.Update(nodeCfg)
} | go | func Init(dp datapath.Datapath, nodeCfg *datapath.LocalNodeConfiguration) {
once.Do(func() {
templateCache = NewObjectCache(dp, nodeCfg)
ignorePrefixes := ignoredELFPrefixes
if !option.Config.EnableIPv4 {
ignorePrefixes = append(ignorePrefixes, "LXC_IPV4")
}
if !option.Config.EnableIPv6 {
ignorePrefixes = append(ignorePrefixes, "LXC_IP_")
}
elf.IgnoreSymbolPrefixes(ignorePrefixes)
})
templateCache.Update(nodeCfg)
} | [
"func",
"Init",
"(",
"dp",
"datapath",
".",
"Datapath",
",",
"nodeCfg",
"*",
"datapath",
".",
"LocalNodeConfiguration",
")",
"{",
"once",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"templateCache",
"=",
"NewObjectCache",
"(",
"dp",
",",
"nodeCfg",
")",
"\n",... | // Init initializes the datapath cache with base program hashes derived from
// the LocalNodeConfiguration. | [
"Init",
"initializes",
"the",
"datapath",
"cache",
"with",
"base",
"program",
"hashes",
"derived",
"from",
"the",
"LocalNodeConfiguration",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/cache.go#L67-L80 |
163,364 | cilium/cilium | pkg/datapath/loader/cache.go | RestoreTemplates | func RestoreTemplates(stateDir string) error {
// Simplest implementation: Just garbage-collect everything.
// In future we should make this smarter.
path := filepath.Join(stateDir, defaults.TemplatesDir)
err := os.RemoveAll(path)
if err == nil || os.IsNotExist(err) {
return nil
}
return &os.PathError{
Op: "failed to remove old BPF templates",
Path: path,
Err: err,
}
} | go | func RestoreTemplates(stateDir string) error {
// Simplest implementation: Just garbage-collect everything.
// In future we should make this smarter.
path := filepath.Join(stateDir, defaults.TemplatesDir)
err := os.RemoveAll(path)
if err == nil || os.IsNotExist(err) {
return nil
}
return &os.PathError{
Op: "failed to remove old BPF templates",
Path: path,
Err: err,
}
} | [
"func",
"RestoreTemplates",
"(",
"stateDir",
"string",
")",
"error",
"{",
"// Simplest implementation: Just garbage-collect everything.",
"// In future we should make this smarter.",
"path",
":=",
"filepath",
".",
"Join",
"(",
"stateDir",
",",
"defaults",
".",
"TemplatesDir",... | // RestoreTemplates populates the object cache from templates on the filesystem
// at the specified path. | [
"RestoreTemplates",
"populates",
"the",
"object",
"cache",
"from",
"templates",
"on",
"the",
"filesystem",
"at",
"the",
"specified",
"path",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/cache.go#L84-L97 |
163,365 | cilium/cilium | pkg/datapath/loader/cache.go | NewObjectCache | func NewObjectCache(dp datapath.Datapath, nodeCfg *datapath.LocalNodeConfiguration) *objectCache {
return newObjectCache(dp, nodeCfg, option.Config.StateDir)
} | go | func NewObjectCache(dp datapath.Datapath, nodeCfg *datapath.LocalNodeConfiguration) *objectCache {
return newObjectCache(dp, nodeCfg, option.Config.StateDir)
} | [
"func",
"NewObjectCache",
"(",
"dp",
"datapath",
".",
"Datapath",
",",
"nodeCfg",
"*",
"datapath",
".",
"LocalNodeConfiguration",
")",
"*",
"objectCache",
"{",
"return",
"newObjectCache",
"(",
"dp",
",",
"nodeCfg",
",",
"option",
".",
"Config",
".",
"StateDir"... | // NewObjectCache creates a new cache for datapath objects, basing the hash
// upon the configuration of the datapath and the specified node configuration. | [
"NewObjectCache",
"creates",
"a",
"new",
"cache",
"for",
"datapath",
"objects",
"basing",
"the",
"hash",
"upon",
"the",
"configuration",
"of",
"the",
"datapath",
"and",
"the",
"specified",
"node",
"configuration",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/cache.go#L141-L143 |
163,366 | cilium/cilium | pkg/datapath/loader/cache.go | Update | func (o *objectCache) Update(nodeCfg *datapath.LocalNodeConfiguration) {
newHash := hashDatapath(o.Datapath, nodeCfg, nil, nil)
o.Lock()
defer o.Unlock()
o.baseHash = newHash
} | go | func (o *objectCache) Update(nodeCfg *datapath.LocalNodeConfiguration) {
newHash := hashDatapath(o.Datapath, nodeCfg, nil, nil)
o.Lock()
defer o.Unlock()
o.baseHash = newHash
} | [
"func",
"(",
"o",
"*",
"objectCache",
")",
"Update",
"(",
"nodeCfg",
"*",
"datapath",
".",
"LocalNodeConfiguration",
")",
"{",
"newHash",
":=",
"hashDatapath",
"(",
"o",
".",
"Datapath",
",",
"nodeCfg",
",",
"nil",
",",
"nil",
")",
"\n\n",
"o",
".",
"L... | // Update may be called to update the base hash for configuration of datapath
// configuration that applies across the node. | [
"Update",
"may",
"be",
"called",
"to",
"update",
"the",
"base",
"hash",
"for",
"configuration",
"of",
"datapath",
"configuration",
"that",
"applies",
"across",
"the",
"node",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/cache.go#L147-L153 |
163,367 | cilium/cilium | pkg/datapath/loader/cache.go | serialize | func (o *objectCache) serialize(hash string) (fq *serializer.FunctionQueue, found bool) {
o.Lock()
defer o.Unlock()
fq, compiled := o.compileQueue[hash]
if !compiled {
fq = serializer.NewFunctionQueue(1)
o.compileQueue[hash] = fq
}
return fq, compiled
} | go | func (o *objectCache) serialize(hash string) (fq *serializer.FunctionQueue, found bool) {
o.Lock()
defer o.Unlock()
fq, compiled := o.compileQueue[hash]
if !compiled {
fq = serializer.NewFunctionQueue(1)
o.compileQueue[hash] = fq
}
return fq, compiled
} | [
"func",
"(",
"o",
"*",
"objectCache",
")",
"serialize",
"(",
"hash",
"string",
")",
"(",
"fq",
"*",
"serializer",
".",
"FunctionQueue",
",",
"found",
"bool",
")",
"{",
"o",
".",
"Lock",
"(",
")",
"\n",
"defer",
"o",
".",
"Unlock",
"(",
")",
"\n\n",... | // serialize finds the channel that serializes builds against the same hash.
// Returns the channel and whether or not the caller needs to compile the
// datapath for this hash. | [
"serialize",
"finds",
"the",
"channel",
"that",
"serializes",
"builds",
"against",
"the",
"same",
"hash",
".",
"Returns",
"the",
"channel",
"and",
"whether",
"or",
"not",
"the",
"caller",
"needs",
"to",
"compile",
"the",
"datapath",
"for",
"this",
"hash",
".... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/cache.go#L158-L168 |
163,368 | cilium/cilium | pkg/datapath/loader/cache.go | build | func (o *objectCache) build(ctx context.Context, cfg *templateCfg, hash string) error {
templatePath := filepath.Join(o.workingDirectory, defaults.TemplatesDir, hash)
headerPath := filepath.Join(templatePath, common.CHeaderFileName)
objectPath := filepath.Join(templatePath, endpointObj)
if err := os.MkdirAll(templatePath, defaults.StateDirRights); err != nil {
return &os.PathError{
Op: "failed to create template directory",
Path: templatePath,
Err: err,
}
}
f, err := os.Create(headerPath)
if err != nil {
return &os.PathError{
Op: "failed to open template header for writing",
Path: headerPath,
Err: err,
}
}
if err = o.Datapath.WriteEndpointConfig(f, cfg); err != nil {
return &os.PathError{
Op: "failed to write template header",
Path: headerPath,
Err: err,
}
}
cfg.stats.bpfCompilation.Start()
err = compileTemplate(ctx, templatePath)
cfg.stats.bpfCompilation.End(err == nil)
if err != nil {
return &os.PathError{
Op: "failed to compile template program",
Path: templatePath,
Err: err,
}
}
log.WithFields(logrus.Fields{
logfields.Path: objectPath,
logfields.BPFCompilationTime: cfg.stats.bpfCompilation.Total(),
}).Info("Compiled new BPF template")
o.insert(hash, objectPath)
return nil
} | go | func (o *objectCache) build(ctx context.Context, cfg *templateCfg, hash string) error {
templatePath := filepath.Join(o.workingDirectory, defaults.TemplatesDir, hash)
headerPath := filepath.Join(templatePath, common.CHeaderFileName)
objectPath := filepath.Join(templatePath, endpointObj)
if err := os.MkdirAll(templatePath, defaults.StateDirRights); err != nil {
return &os.PathError{
Op: "failed to create template directory",
Path: templatePath,
Err: err,
}
}
f, err := os.Create(headerPath)
if err != nil {
return &os.PathError{
Op: "failed to open template header for writing",
Path: headerPath,
Err: err,
}
}
if err = o.Datapath.WriteEndpointConfig(f, cfg); err != nil {
return &os.PathError{
Op: "failed to write template header",
Path: headerPath,
Err: err,
}
}
cfg.stats.bpfCompilation.Start()
err = compileTemplate(ctx, templatePath)
cfg.stats.bpfCompilation.End(err == nil)
if err != nil {
return &os.PathError{
Op: "failed to compile template program",
Path: templatePath,
Err: err,
}
}
log.WithFields(logrus.Fields{
logfields.Path: objectPath,
logfields.BPFCompilationTime: cfg.stats.bpfCompilation.Total(),
}).Info("Compiled new BPF template")
o.insert(hash, objectPath)
return nil
} | [
"func",
"(",
"o",
"*",
"objectCache",
")",
"build",
"(",
"ctx",
"context",
".",
"Context",
",",
"cfg",
"*",
"templateCfg",
",",
"hash",
"string",
")",
"error",
"{",
"templatePath",
":=",
"filepath",
".",
"Join",
"(",
"o",
".",
"workingDirectory",
",",
... | // build attempts to compile and cache a datapath template object file
// corresponding to the specified endpoint configuration. | [
"build",
"attempts",
"to",
"compile",
"and",
"cache",
"a",
"datapath",
"template",
"object",
"file",
"corresponding",
"to",
"the",
"specified",
"endpoint",
"configuration",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/cache.go#L205-L253 |
163,369 | cilium/cilium | pkg/datapath/loader/cache.go | fetchOrCompile | func (o *objectCache) fetchOrCompile(ctx context.Context, cfg datapath.EndpointConfiguration, stats *SpanStat) (path string, compiled bool, err error) {
var hash string
hash, err = o.baseHash.sumEndpoint(o, cfg, false)
if err != nil {
return "", false, err
}
// Capture the time spent waiting for the template to compile.
if stats != nil {
stats.bpfWaitForELF.Start()
defer func() {
// Wrap to ensure that "err" is compared upon return.
stats.bpfWaitForELF.End(err == nil)
}()
}
scopedLog := log.WithField(logfields.BPFHeaderfileHash, hash)
// Serializes attempts to compile this cfg.
fq, compiled := o.serialize(hash)
if !compiled {
fq.Enqueue(func() error {
defer fq.Stop()
templateCfg := wrap(cfg, stats)
err := o.build(ctx, templateCfg, hash)
if err != nil {
scopedLog.WithError(err).Error("BPF template object creation failed")
}
return err
}, serializer.NoRetry)
}
// Wait until the build completes.
if err = fq.Wait(ctx); err != nil {
scopedLog.WithError(err).Warning("Error while waiting for BPF template compilation")
return "", false, fmt.Errorf("BPF template compilation failed: %s", err)
}
// Fetch the result of the compilation.
path, ok := o.lookup(hash)
if !ok {
err := fmt.Errorf("Could not locate previously compiled BPF template")
scopedLog.WithError(err).Warning("BPF template compilation unsuccessful")
return "", false, err
}
return path, !compiled, nil
} | go | func (o *objectCache) fetchOrCompile(ctx context.Context, cfg datapath.EndpointConfiguration, stats *SpanStat) (path string, compiled bool, err error) {
var hash string
hash, err = o.baseHash.sumEndpoint(o, cfg, false)
if err != nil {
return "", false, err
}
// Capture the time spent waiting for the template to compile.
if stats != nil {
stats.bpfWaitForELF.Start()
defer func() {
// Wrap to ensure that "err" is compared upon return.
stats.bpfWaitForELF.End(err == nil)
}()
}
scopedLog := log.WithField(logfields.BPFHeaderfileHash, hash)
// Serializes attempts to compile this cfg.
fq, compiled := o.serialize(hash)
if !compiled {
fq.Enqueue(func() error {
defer fq.Stop()
templateCfg := wrap(cfg, stats)
err := o.build(ctx, templateCfg, hash)
if err != nil {
scopedLog.WithError(err).Error("BPF template object creation failed")
}
return err
}, serializer.NoRetry)
}
// Wait until the build completes.
if err = fq.Wait(ctx); err != nil {
scopedLog.WithError(err).Warning("Error while waiting for BPF template compilation")
return "", false, fmt.Errorf("BPF template compilation failed: %s", err)
}
// Fetch the result of the compilation.
path, ok := o.lookup(hash)
if !ok {
err := fmt.Errorf("Could not locate previously compiled BPF template")
scopedLog.WithError(err).Warning("BPF template compilation unsuccessful")
return "", false, err
}
return path, !compiled, nil
} | [
"func",
"(",
"o",
"*",
"objectCache",
")",
"fetchOrCompile",
"(",
"ctx",
"context",
".",
"Context",
",",
"cfg",
"datapath",
".",
"EndpointConfiguration",
",",
"stats",
"*",
"SpanStat",
")",
"(",
"path",
"string",
",",
"compiled",
"bool",
",",
"err",
"error... | // fetchOrCompile attempts to fetch the path to the datapath object
// corresponding to the provided endpoint configuration, or if this
// configuration is not yet compiled, compiles it. It will block if multiple
// threads attempt to concurrently fetchOrCompile a template binary for the
// same set of EndpointConfiguration.
//
// Returns the path to the compiled template datapath object and whether the
// object was compiled, or an error. | [
"fetchOrCompile",
"attempts",
"to",
"fetch",
"the",
"path",
"to",
"the",
"datapath",
"object",
"corresponding",
"to",
"the",
"provided",
"endpoint",
"configuration",
"or",
"if",
"this",
"configuration",
"is",
"not",
"yet",
"compiled",
"compiles",
"it",
".",
"It"... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/cache.go#L263-L310 |
163,370 | cilium/cilium | pkg/datapath/loader/cache.go | EndpointHash | func EndpointHash(cfg datapath.EndpointConfiguration) (string, error) {
return templateCache.baseHash.sumEndpoint(templateCache, cfg, true)
} | go | func EndpointHash(cfg datapath.EndpointConfiguration) (string, error) {
return templateCache.baseHash.sumEndpoint(templateCache, cfg, true)
} | [
"func",
"EndpointHash",
"(",
"cfg",
"datapath",
".",
"EndpointConfiguration",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"templateCache",
".",
"baseHash",
".",
"sumEndpoint",
"(",
"templateCache",
",",
"cfg",
",",
"true",
")",
"\n",
"}"
] | // EndpointHash hashes the specified endpoint configuration with the current
// datapath hash cache and returns the hash as string. | [
"EndpointHash",
"hashes",
"the",
"specified",
"endpoint",
"configuration",
"with",
"the",
"current",
"datapath",
"hash",
"cache",
"and",
"returns",
"the",
"hash",
"as",
"string",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/cache.go#L357-L359 |
163,371 | cilium/cilium | pkg/envoy/xds/cache.go | NewCache | func NewCache() *Cache {
return &Cache{
BaseObservableResourceSource: NewBaseObservableResourceSource(),
resources: make(map[cacheKey]cacheValue),
version: 1,
}
} | go | func NewCache() *Cache {
return &Cache{
BaseObservableResourceSource: NewBaseObservableResourceSource(),
resources: make(map[cacheKey]cacheValue),
version: 1,
}
} | [
"func",
"NewCache",
"(",
")",
"*",
"Cache",
"{",
"return",
"&",
"Cache",
"{",
"BaseObservableResourceSource",
":",
"NewBaseObservableResourceSource",
"(",
")",
",",
"resources",
":",
"make",
"(",
"map",
"[",
"cacheKey",
"]",
"cacheValue",
")",
",",
"version",
... | // NewCache creates a new, empty cache with 0 as its current version. | [
"NewCache",
"creates",
"a",
"new",
"empty",
"cache",
"with",
"0",
"as",
"its",
"current",
"version",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/xds/cache.go#L67-L73 |
163,372 | cilium/cilium | pkg/envoy/xds/cache.go | Lookup | func (c *Cache) Lookup(typeURL string, resourceName string) (proto.Message, error) {
res, err := c.GetResources(context.Background(), typeURL, 0, nil, []string{resourceName})
if err != nil || res == nil || len(res.Resources) == 0 {
return nil, err
}
return res.Resources[0], nil
} | go | func (c *Cache) Lookup(typeURL string, resourceName string) (proto.Message, error) {
res, err := c.GetResources(context.Background(), typeURL, 0, nil, []string{resourceName})
if err != nil || res == nil || len(res.Resources) == 0 {
return nil, err
}
return res.Resources[0], nil
} | [
"func",
"(",
"c",
"*",
"Cache",
")",
"Lookup",
"(",
"typeURL",
"string",
",",
"resourceName",
"string",
")",
"(",
"proto",
".",
"Message",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"c",
".",
"GetResources",
"(",
"context",
".",
"Background",
"... | // Lookup finds the resource corresponding to the specified typeURL and resourceName,
// if available, and returns it. Otherwise, returns nil. If an error occurs while
// fetching the resource, also returns the error. | [
"Lookup",
"finds",
"the",
"resource",
"corresponding",
"to",
"the",
"specified",
"typeURL",
"and",
"resourceName",
"if",
"available",
"and",
"returns",
"it",
".",
"Otherwise",
"returns",
"nil",
".",
"If",
"an",
"error",
"occurs",
"while",
"fetching",
"the",
"r... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/xds/cache.go#L310-L316 |
163,373 | cilium/cilium | pkg/kvstore/backend.go | StatusCheckInterval | func (e *ExtraOptions) StatusCheckInterval(allConnected bool) time.Duration {
interval := 30 * time.Second
// Reduce the interval while connectivity issues are being detected
if !allConnected {
interval = 5 * time.Second
}
if e != nil && e.ClusterSizeDependantInterval != nil {
interval = e.ClusterSizeDependantInterval(interval)
}
return interval
} | go | func (e *ExtraOptions) StatusCheckInterval(allConnected bool) time.Duration {
interval := 30 * time.Second
// Reduce the interval while connectivity issues are being detected
if !allConnected {
interval = 5 * time.Second
}
if e != nil && e.ClusterSizeDependantInterval != nil {
interval = e.ClusterSizeDependantInterval(interval)
}
return interval
} | [
"func",
"(",
"e",
"*",
"ExtraOptions",
")",
"StatusCheckInterval",
"(",
"allConnected",
"bool",
")",
"time",
".",
"Duration",
"{",
"interval",
":=",
"30",
"*",
"time",
".",
"Second",
"\n\n",
"// Reduce the interval while connectivity issues are being detected",
"if",
... | // StatusCheckInterval returns the interval of status checks depending on the
// cluster size and the current connectivity state
//
// nodes OK Failing
// 1 20s 3s
// 4 45s 7s
// 8 1m05s 11s
// 32 1m45s 18s
// 128 2m25s 24s
// 512 3m07s 32s
// 2048 3m46s 38s
// 8192 4m30s 45s | [
"StatusCheckInterval",
"returns",
"the",
"interval",
"of",
"status",
"checks",
"depending",
"on",
"the",
"cluster",
"size",
"and",
"the",
"current",
"connectivity",
"state",
"nodes",
"OK",
"Failing",
"1",
"20s",
"3s",
"4",
"45s",
"7s",
"8",
"1m05s",
"11s",
"... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/backend.go#L59-L71 |
163,374 | cilium/cilium | pkg/kvstore/backend.go | registerBackend | func registerBackend(name string, module backendModule) {
if _, ok := registeredBackends[name]; ok {
log.Panicf("backend with name '%s' already registered", name)
}
registeredBackends[name] = module
} | go | func registerBackend(name string, module backendModule) {
if _, ok := registeredBackends[name]; ok {
log.Panicf("backend with name '%s' already registered", name)
}
registeredBackends[name] = module
} | [
"func",
"registerBackend",
"(",
"name",
"string",
",",
"module",
"backendModule",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"registeredBackends",
"[",
"name",
"]",
";",
"ok",
"{",
"log",
".",
"Panicf",
"(",
"\"",
"\"",
",",
"name",
")",
"\n",
"}",
"\n\n"... | // registerBackend must be called by kvstore backends to register themselves | [
"registerBackend",
"must",
"be",
"called",
"by",
"kvstore",
"backends",
"to",
"register",
"themselves"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/backend.go#L108-L114 |
163,375 | cilium/cilium | pkg/kvstore/backend.go | getBackend | func getBackend(name string) backendModule {
if backend, ok := registeredBackends[name]; ok {
return backend.createInstance()
}
return nil
} | go | func getBackend(name string) backendModule {
if backend, ok := registeredBackends[name]; ok {
return backend.createInstance()
}
return nil
} | [
"func",
"getBackend",
"(",
"name",
"string",
")",
"backendModule",
"{",
"if",
"backend",
",",
"ok",
":=",
"registeredBackends",
"[",
"name",
"]",
";",
"ok",
"{",
"return",
"backend",
".",
"createInstance",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\... | // getBackend finds a registered backend by name | [
"getBackend",
"finds",
"a",
"registered",
"backend",
"by",
"name"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/backend.go#L117-L123 |
163,376 | cilium/cilium | pkg/option/config.go | getEnvName | func getEnvName(option string) string {
under := strings.Replace(option, "-", "_", -1)
upper := strings.ToUpper(under)
return ciliumEnvPrefix + upper
} | go | func getEnvName(option string) string {
under := strings.Replace(option, "-", "_", -1)
upper := strings.ToUpper(under)
return ciliumEnvPrefix + upper
} | [
"func",
"getEnvName",
"(",
"option",
"string",
")",
"string",
"{",
"under",
":=",
"strings",
".",
"Replace",
"(",
"option",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n",
"upper",
":=",
"strings",
".",
"ToUpper",
"(",
"under",
")",
"\n... | // getEnvName returns the environment variable to be used for the given option name. | [
"getEnvName",
"returns",
"the",
"environment",
"variable",
"to",
"be",
"used",
"for",
"the",
"given",
"option",
"name",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/config.go#L516-L520 |
163,377 | cilium/cilium | pkg/option/config.go | BindEnv | func BindEnv(optName string) {
registerOpt(optName)
viper.BindEnv(optName, getEnvName(optName))
} | go | func BindEnv(optName string) {
registerOpt(optName)
viper.BindEnv(optName, getEnvName(optName))
} | [
"func",
"BindEnv",
"(",
"optName",
"string",
")",
"{",
"registerOpt",
"(",
"optName",
")",
"\n",
"viper",
".",
"BindEnv",
"(",
"optName",
",",
"getEnvName",
"(",
"optName",
")",
")",
"\n",
"}"
] | // BindEnv binds the option name with an deterministic generated environment
// variable which s based on the given optName. If the same optName is bind
// more than 1 time, this function panics. | [
"BindEnv",
"binds",
"the",
"option",
"name",
"with",
"an",
"deterministic",
"generated",
"environment",
"variable",
"which",
"s",
"based",
"on",
"the",
"given",
"optName",
".",
"If",
"the",
"same",
"optName",
"is",
"bind",
"more",
"than",
"1",
"time",
"this"... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/config.go#L528-L531 |
163,378 | cilium/cilium | pkg/option/config.go | BindEnvWithLegacyEnvFallback | func BindEnvWithLegacyEnvFallback(optName, legacyEnvName string) {
registerOpt(optName)
envName := getEnvName(optName)
if os.Getenv(envName) == "" {
envName = legacyEnvName
}
viper.BindEnv(optName, envName)
} | go | func BindEnvWithLegacyEnvFallback(optName, legacyEnvName string) {
registerOpt(optName)
envName := getEnvName(optName)
if os.Getenv(envName) == "" {
envName = legacyEnvName
}
viper.BindEnv(optName, envName)
} | [
"func",
"BindEnvWithLegacyEnvFallback",
"(",
"optName",
",",
"legacyEnvName",
"string",
")",
"{",
"registerOpt",
"(",
"optName",
")",
"\n\n",
"envName",
":=",
"getEnvName",
"(",
"optName",
")",
"\n",
"if",
"os",
".",
"Getenv",
"(",
"envName",
")",
"==",
"\""... | // BindEnvWithLegacyEnvFallback binds the given option name with either the same
// environment variable as BindEnv, if it's set, or with the given legacyEnvName.
//
// The function is used to work around the viper.BindEnv limitation that only
// one environment variable can be bound for an option, and we need multiple
// environment variables due to backward compatibility reasons. | [
"BindEnvWithLegacyEnvFallback",
"binds",
"the",
"given",
"option",
"name",
"with",
"either",
"the",
"same",
"environment",
"variable",
"as",
"BindEnv",
"if",
"it",
"s",
"set",
"or",
"with",
"the",
"given",
"legacyEnvName",
".",
"The",
"function",
"is",
"used",
... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/config.go#L539-L548 |
163,379 | cilium/cilium | pkg/option/config.go | LogRegisteredOptions | func LogRegisteredOptions(entry *logrus.Entry) {
keys := make([]string, 0, len(RegisteredOptions))
for k := range RegisteredOptions {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
entry.Infof(" --%s='%s'", k, viper.GetString(k))
}
} | go | func LogRegisteredOptions(entry *logrus.Entry) {
keys := make([]string, 0, len(RegisteredOptions))
for k := range RegisteredOptions {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
entry.Infof(" --%s='%s'", k, viper.GetString(k))
}
} | [
"func",
"LogRegisteredOptions",
"(",
"entry",
"*",
"logrus",
".",
"Entry",
")",
"{",
"keys",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"RegisteredOptions",
")",
")",
"\n",
"for",
"k",
":=",
"range",
"RegisteredOptions",
"{",
"ke... | // LogRegisteredOptions logs all options that where bind to viper. | [
"LogRegisteredOptions",
"logs",
"all",
"options",
"that",
"where",
"bind",
"to",
"viper",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/config.go#L559-L568 |
163,380 | cilium/cilium | pkg/option/config.go | GetNodeConfigPath | func (c *DaemonConfig) GetNodeConfigPath() string {
return filepath.Join(c.GetGlobalsDir(), common.NodeConfigFile)
} | go | func (c *DaemonConfig) GetNodeConfigPath() string {
return filepath.Join(c.GetGlobalsDir(), common.NodeConfigFile)
} | [
"func",
"(",
"c",
"*",
"DaemonConfig",
")",
"GetNodeConfigPath",
"(",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"c",
".",
"GetGlobalsDir",
"(",
")",
",",
"common",
".",
"NodeConfigFile",
")",
"\n",
"}"
] | // GetNodeConfigPath returns the full path of the NodeConfigFile. | [
"GetNodeConfigPath",
"returns",
"the",
"full",
"path",
"of",
"the",
"NodeConfigFile",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/config.go#L924-L926 |
163,381 | cilium/cilium | pkg/option/config.go | WorkloadsEnabled | func (c *DaemonConfig) WorkloadsEnabled() bool {
for _, w := range c.Workloads {
if w == "none" {
return false
}
}
return len(c.Workloads) > 0
} | go | func (c *DaemonConfig) WorkloadsEnabled() bool {
for _, w := range c.Workloads {
if w == "none" {
return false
}
}
return len(c.Workloads) > 0
} | [
"func",
"(",
"c",
"*",
"DaemonConfig",
")",
"WorkloadsEnabled",
"(",
")",
"bool",
"{",
"for",
"_",
",",
"w",
":=",
"range",
"c",
".",
"Workloads",
"{",
"if",
"w",
"==",
"\"",
"\"",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"... | // WorkloadsEnabled returns true if any workload runtimes are enabled | [
"WorkloadsEnabled",
"returns",
"true",
"if",
"any",
"workload",
"runtimes",
"are",
"enabled"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/config.go#L934-L942 |
163,382 | cilium/cilium | pkg/option/config.go | AlwaysAllowLocalhost | func (c *DaemonConfig) AlwaysAllowLocalhost() bool {
switch c.AllowLocalhost {
case AllowLocalhostAlways:
return true
case AllowLocalhostAuto, AllowLocalhostPolicy:
return false
default:
return false
}
} | go | func (c *DaemonConfig) AlwaysAllowLocalhost() bool {
switch c.AllowLocalhost {
case AllowLocalhostAlways:
return true
case AllowLocalhostAuto, AllowLocalhostPolicy:
return false
default:
return false
}
} | [
"func",
"(",
"c",
"*",
"DaemonConfig",
")",
"AlwaysAllowLocalhost",
"(",
")",
"bool",
"{",
"switch",
"c",
".",
"AllowLocalhost",
"{",
"case",
"AllowLocalhostAlways",
":",
"return",
"true",
"\n",
"case",
"AllowLocalhostAuto",
",",
"AllowLocalhostPolicy",
":",
"re... | // AlwaysAllowLocalhost returns true if the daemon has the option set that
// localhost can always reach local endpoints | [
"AlwaysAllowLocalhost",
"returns",
"true",
"if",
"the",
"daemon",
"has",
"the",
"option",
"set",
"that",
"localhost",
"can",
"always",
"reach",
"local",
"endpoints"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/config.go#L946-L955 |
163,383 | cilium/cilium | pkg/option/config.go | Validate | func (c *DaemonConfig) Validate() error {
if err := c.validateIPv6ClusterAllocCIDR(); err != nil {
return fmt.Errorf("unable to parse CIDR value '%s' of option --%s: %s",
c.IPv6ClusterAllocCIDR, IPv6ClusterAllocCIDRName, err)
}
if c.MTU < 0 {
return fmt.Errorf("MTU '%d' cannot be negative", c.MTU)
}
switch c.Tunnel {
case TunnelVXLAN, TunnelGeneve, "":
case TunnelDisabled:
if c.UseSingleClusterRoute {
return fmt.Errorf("option --%s cannot be used in combination with --%s=%s",
SingleClusterRouteName, TunnelName, TunnelDisabled)
}
default:
return fmt.Errorf("invalid tunnel mode '%s', valid modes = {%s}", c.Tunnel, GetTunnelModes())
}
if c.ClusterID < ClusterIDMin || c.ClusterID > ClusterIDMax {
return fmt.Errorf("invalid cluster id %d: must be in range %d..%d",
c.ClusterID, ClusterIDMin, ClusterIDMax)
}
if c.ClusterID != 0 {
if c.ClusterName == defaults.ClusterName {
return fmt.Errorf("cannot use default cluster name (%s) with option %s",
defaults.ClusterName, ClusterIDName)
}
}
ctTableMin := 1 << 10 // 1Ki entries
ctTableMax := 1 << 24 // 16Mi entries (~1GiB of entries per map)
if c.CTMapEntriesGlobalTCP < ctTableMin || c.CTMapEntriesGlobalAny < ctTableMin {
return fmt.Errorf("Specified CT tables values %d/%d must exceed minimum %d",
c.CTMapEntriesGlobalTCP, c.CTMapEntriesGlobalAny, ctTableMin)
}
if c.CTMapEntriesGlobalTCP > ctTableMax || c.CTMapEntriesGlobalAny > ctTableMax {
return fmt.Errorf("Specified CT tables values %d/%d must not exceed maximum %d",
c.CTMapEntriesGlobalTCP, c.CTMapEntriesGlobalAny, ctTableMax)
}
return nil
} | go | func (c *DaemonConfig) Validate() error {
if err := c.validateIPv6ClusterAllocCIDR(); err != nil {
return fmt.Errorf("unable to parse CIDR value '%s' of option --%s: %s",
c.IPv6ClusterAllocCIDR, IPv6ClusterAllocCIDRName, err)
}
if c.MTU < 0 {
return fmt.Errorf("MTU '%d' cannot be negative", c.MTU)
}
switch c.Tunnel {
case TunnelVXLAN, TunnelGeneve, "":
case TunnelDisabled:
if c.UseSingleClusterRoute {
return fmt.Errorf("option --%s cannot be used in combination with --%s=%s",
SingleClusterRouteName, TunnelName, TunnelDisabled)
}
default:
return fmt.Errorf("invalid tunnel mode '%s', valid modes = {%s}", c.Tunnel, GetTunnelModes())
}
if c.ClusterID < ClusterIDMin || c.ClusterID > ClusterIDMax {
return fmt.Errorf("invalid cluster id %d: must be in range %d..%d",
c.ClusterID, ClusterIDMin, ClusterIDMax)
}
if c.ClusterID != 0 {
if c.ClusterName == defaults.ClusterName {
return fmt.Errorf("cannot use default cluster name (%s) with option %s",
defaults.ClusterName, ClusterIDName)
}
}
ctTableMin := 1 << 10 // 1Ki entries
ctTableMax := 1 << 24 // 16Mi entries (~1GiB of entries per map)
if c.CTMapEntriesGlobalTCP < ctTableMin || c.CTMapEntriesGlobalAny < ctTableMin {
return fmt.Errorf("Specified CT tables values %d/%d must exceed minimum %d",
c.CTMapEntriesGlobalTCP, c.CTMapEntriesGlobalAny, ctTableMin)
}
if c.CTMapEntriesGlobalTCP > ctTableMax || c.CTMapEntriesGlobalAny > ctTableMax {
return fmt.Errorf("Specified CT tables values %d/%d must not exceed maximum %d",
c.CTMapEntriesGlobalTCP, c.CTMapEntriesGlobalAny, ctTableMax)
}
return nil
} | [
"func",
"(",
"c",
"*",
"DaemonConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"c",
".",
"validateIPv6ClusterAllocCIDR",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"c",
".",
"IP... | // Validate validates the daemon configuration | [
"Validate",
"validates",
"the",
"daemon",
"configuration"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/config.go#L988-L1033 |
163,384 | cilium/cilium | pkg/option/config.go | ReadDirConfig | func ReadDirConfig(dirName string) (map[string]interface{}, error) {
m := map[string]interface{}{}
fi, err := ioutil.ReadDir(dirName)
if err != nil && !os.IsNotExist(err) {
return nil, fmt.Errorf("unable to read configuration directory: %s", err)
}
for _, f := range fi {
if f.Mode().IsDir() {
continue
}
fName := filepath.Join(dirName, f.Name())
// the file can still be a symlink to a directory
if f.Mode()&os.ModeSymlink == 0 {
absFileName, err := filepath.EvalSymlinks(fName)
if err != nil {
log.Warnf("Unable to read configuration file %q: %s", absFileName, err)
continue
}
fName = absFileName
}
f, err = os.Stat(fName)
if err != nil {
log.Warnf("Unable to read configuration file %q: %s", fName, err)
continue
}
if f.Mode().IsDir() {
continue
}
b, err := ioutil.ReadFile(fName)
if err != nil {
log.Warnf("Unable to read configuration file %q: %s", fName, err)
continue
}
m[f.Name()] = string(bytes.TrimSpace(b))
}
return m, nil
} | go | func ReadDirConfig(dirName string) (map[string]interface{}, error) {
m := map[string]interface{}{}
fi, err := ioutil.ReadDir(dirName)
if err != nil && !os.IsNotExist(err) {
return nil, fmt.Errorf("unable to read configuration directory: %s", err)
}
for _, f := range fi {
if f.Mode().IsDir() {
continue
}
fName := filepath.Join(dirName, f.Name())
// the file can still be a symlink to a directory
if f.Mode()&os.ModeSymlink == 0 {
absFileName, err := filepath.EvalSymlinks(fName)
if err != nil {
log.Warnf("Unable to read configuration file %q: %s", absFileName, err)
continue
}
fName = absFileName
}
f, err = os.Stat(fName)
if err != nil {
log.Warnf("Unable to read configuration file %q: %s", fName, err)
continue
}
if f.Mode().IsDir() {
continue
}
b, err := ioutil.ReadFile(fName)
if err != nil {
log.Warnf("Unable to read configuration file %q: %s", fName, err)
continue
}
m[f.Name()] = string(bytes.TrimSpace(b))
}
return m, nil
} | [
"func",
"ReadDirConfig",
"(",
"dirName",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"m",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"fi",
",",
"err",
":=",
"ioutil",
... | // ReadDirConfig reads the given directory and returns a map that maps the
// filename to the contents of that file. | [
"ReadDirConfig",
"reads",
"the",
"given",
"directory",
"and",
"returns",
"a",
"map",
"that",
"maps",
"the",
"filename",
"to",
"the",
"contents",
"of",
"that",
"file",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/config.go#L1037-L1076 |
163,385 | cilium/cilium | pkg/option/config.go | MergeConfig | func MergeConfig(m map[string]interface{}) error {
err := viper.MergeConfigMap(m)
if err != nil {
return fmt.Errorf("unable to read merge directory configuration: %s", err)
}
return nil
} | go | func MergeConfig(m map[string]interface{}) error {
err := viper.MergeConfigMap(m)
if err != nil {
return fmt.Errorf("unable to read merge directory configuration: %s", err)
}
return nil
} | [
"func",
"MergeConfig",
"(",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"err",
":=",
"viper",
".",
"MergeConfigMap",
"(",
"m",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
... | // MergeConfig merges the given configuration map with viper's configuration. | [
"MergeConfig",
"merges",
"the",
"given",
"configuration",
"map",
"with",
"viper",
"s",
"configuration",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/config.go#L1079-L1085 |
163,386 | cilium/cilium | pkg/option/config.go | ReplaceDeprecatedFields | func ReplaceDeprecatedFields(m map[string]interface{}) {
deprecatedFields := map[string]string{
"monitor-aggregation-level": MonitorAggregationName,
"ct-global-max-entries-tcp": CTMapEntriesGlobalTCPName,
"ct-global-max-entries-other": CTMapEntriesGlobalAnyName,
}
for deprecatedOption, newOption := range deprecatedFields {
if deprecatedValue, ok := m[deprecatedOption]; ok {
if _, ok := m[newOption]; !ok {
m[newOption] = deprecatedValue
}
}
}
} | go | func ReplaceDeprecatedFields(m map[string]interface{}) {
deprecatedFields := map[string]string{
"monitor-aggregation-level": MonitorAggregationName,
"ct-global-max-entries-tcp": CTMapEntriesGlobalTCPName,
"ct-global-max-entries-other": CTMapEntriesGlobalAnyName,
}
for deprecatedOption, newOption := range deprecatedFields {
if deprecatedValue, ok := m[deprecatedOption]; ok {
if _, ok := m[newOption]; !ok {
m[newOption] = deprecatedValue
}
}
}
} | [
"func",
"ReplaceDeprecatedFields",
"(",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"deprecatedFields",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"MonitorAggregationName",
",",
"\"",
"\"",
":",
"CTMapEntriesGlobalT... | // ReplaceDeprecatedFields replaces the deprecated options set with the new set
// of options that overwrite the deprecated ones.
// This function replaces the deprecated fields used by environment variables
// with a different name than the option they are setting. This also replaces
// the deprecated names used in the Kubernetes ConfigMap.
// Once we remove them from this function we also need to remove them from
// daemon_main.go and warn users about the old environment variable nor the
// option in the configuration map have any effect. | [
"ReplaceDeprecatedFields",
"replaces",
"the",
"deprecated",
"options",
"set",
"with",
"the",
"new",
"set",
"of",
"options",
"that",
"overwrite",
"the",
"deprecated",
"ones",
".",
"This",
"function",
"replaces",
"the",
"deprecated",
"fields",
"used",
"by",
"environ... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/config.go#L1095-L1108 |
163,387 | cilium/cilium | api/v1/models/datapath_mode.go | Validate | func (m DatapathMode) Validate(formats strfmt.Registry) error {
var res []error
// value enum
if err := m.validateDatapathModeEnum("", "body", m); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m DatapathMode) Validate(formats strfmt.Registry) error {
var res []error
// value enum
if err := m.validateDatapathModeEnum("", "body", m); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"DatapathMode",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"// value enum",
"if",
"err",
":=",
"m",
".",
"validateDatapathModeEnum",
"(",
"\"",
"\"",
",",
"\""... | // Validate validates this datapath mode | [
"Validate",
"validates",
"this",
"datapath",
"mode"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/datapath_mode.go#L51-L63 |
163,388 | cilium/cilium | api/v1/models/ipvlan_configuration.go | Validate | func (m *IpvlanConfiguration) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateOperationMode(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *IpvlanConfiguration) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateOperationMode(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"IpvlanConfiguration",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateOperationMode",
"(",
"formats",
")",
";",
"err",
... | // Validate validates this ipvlan configuration | [
"Validate",
"validates",
"this",
"ipvlan",
"configuration"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/ipvlan_configuration.go#L31-L42 |
163,389 | cilium/cilium | api/v1/models/b_p_f_map_entry.go | Validate | func (m *BPFMapEntry) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateDesiredAction(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *BPFMapEntry) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateDesiredAction(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"BPFMapEntry",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateDesiredAction",
"(",
"formats",
")",
";",
"err",
"!=",
... | // Validate validates this b p f map entry | [
"Validate",
"validates",
"this",
"b",
"p",
"f",
"map",
"entry"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/b_p_f_map_entry.go#L37-L48 |
163,390 | cilium/cilium | pkg/datapath/linux/config.go | WriteNetdevConfig | func (l *linuxDatapath) WriteNetdevConfig(w io.Writer, cfg datapath.DeviceConfiguration) error {
fw := bufio.NewWriter(w)
l.writeNetdevConfig(fw, cfg)
return fw.Flush()
} | go | func (l *linuxDatapath) WriteNetdevConfig(w io.Writer, cfg datapath.DeviceConfiguration) error {
fw := bufio.NewWriter(w)
l.writeNetdevConfig(fw, cfg)
return fw.Flush()
} | [
"func",
"(",
"l",
"*",
"linuxDatapath",
")",
"WriteNetdevConfig",
"(",
"w",
"io",
".",
"Writer",
",",
"cfg",
"datapath",
".",
"DeviceConfiguration",
")",
"error",
"{",
"fw",
":=",
"bufio",
".",
"NewWriter",
"(",
"w",
")",
"\n",
"l",
".",
"writeNetdevConf... | // WriteNetdevConfig writes the BPF configuration for the endpoint to a writer. | [
"WriteNetdevConfig",
"writes",
"the",
"BPF",
"configuration",
"for",
"the",
"endpoint",
"to",
"a",
"writer",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/linux/config.go#L199-L203 |
163,391 | cilium/cilium | pkg/datapath/linux/config.go | WriteEndpointConfig | func (l *linuxDatapath) WriteEndpointConfig(w io.Writer, e datapath.EndpointConfiguration) error {
fw := bufio.NewWriter(w)
writeIncludes(w)
l.writeStaticData(fw, e)
return l.writeTemplateConfig(fw, e)
} | go | func (l *linuxDatapath) WriteEndpointConfig(w io.Writer, e datapath.EndpointConfiguration) error {
fw := bufio.NewWriter(w)
writeIncludes(w)
l.writeStaticData(fw, e)
return l.writeTemplateConfig(fw, e)
} | [
"func",
"(",
"l",
"*",
"linuxDatapath",
")",
"WriteEndpointConfig",
"(",
"w",
"io",
".",
"Writer",
",",
"e",
"datapath",
".",
"EndpointConfiguration",
")",
"error",
"{",
"fw",
":=",
"bufio",
".",
"NewWriter",
"(",
"w",
")",
"\n\n",
"writeIncludes",
"(",
... | // WriteEndpointConfig writes the BPF configuration for the endpoint to a writer. | [
"WriteEndpointConfig",
"writes",
"the",
"BPF",
"configuration",
"for",
"the",
"endpoint",
"to",
"a",
"writer",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/linux/config.go#L225-L232 |
163,392 | cilium/cilium | pkg/datapath/linux/config.go | WriteTemplateConfig | func (l *linuxDatapath) WriteTemplateConfig(w io.Writer, e datapath.EndpointConfiguration) error {
fw := bufio.NewWriter(w)
return l.writeTemplateConfig(fw, e)
} | go | func (l *linuxDatapath) WriteTemplateConfig(w io.Writer, e datapath.EndpointConfiguration) error {
fw := bufio.NewWriter(w)
return l.writeTemplateConfig(fw, e)
} | [
"func",
"(",
"l",
"*",
"linuxDatapath",
")",
"WriteTemplateConfig",
"(",
"w",
"io",
".",
"Writer",
",",
"e",
"datapath",
".",
"EndpointConfiguration",
")",
"error",
"{",
"fw",
":=",
"bufio",
".",
"NewWriter",
"(",
"w",
")",
"\n",
"return",
"l",
".",
"w... | // WriteEndpointConfig writes the BPF configuration for the template to a writer. | [
"WriteEndpointConfig",
"writes",
"the",
"BPF",
"configuration",
"for",
"the",
"template",
"to",
"a",
"writer",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/linux/config.go#L262-L265 |
163,393 | cilium/cilium | pkg/datapath/ipcache/listener.go | updateStaleEntriesFunction | func updateStaleEntriesFunction(keysToRemove map[string]*ipcacheMap.Key) bpf.DumpCallback {
return func(key bpf.MapKey, value bpf.MapValue) {
k := key.(*ipcacheMap.Key)
keyToIP := k.String()
// Don't RLock as part of the same goroutine.
if i, exists := ipcache.IPIdentityCache.LookupByPrefixRLocked(keyToIP); !exists {
switch i.Source {
case ipcache.FromKVStore, ipcache.FromAgentLocal:
// Cannot delete from map during callback because DumpWithCallback
// RLocks the map.
keysToRemove[keyToIP] = k
}
}
}
} | go | func updateStaleEntriesFunction(keysToRemove map[string]*ipcacheMap.Key) bpf.DumpCallback {
return func(key bpf.MapKey, value bpf.MapValue) {
k := key.(*ipcacheMap.Key)
keyToIP := k.String()
// Don't RLock as part of the same goroutine.
if i, exists := ipcache.IPIdentityCache.LookupByPrefixRLocked(keyToIP); !exists {
switch i.Source {
case ipcache.FromKVStore, ipcache.FromAgentLocal:
// Cannot delete from map during callback because DumpWithCallback
// RLocks the map.
keysToRemove[keyToIP] = k
}
}
}
} | [
"func",
"updateStaleEntriesFunction",
"(",
"keysToRemove",
"map",
"[",
"string",
"]",
"*",
"ipcacheMap",
".",
"Key",
")",
"bpf",
".",
"DumpCallback",
"{",
"return",
"func",
"(",
"key",
"bpf",
".",
"MapKey",
",",
"value",
"bpf",
".",
"MapValue",
")",
"{",
... | // updateStaleEntriesFunction returns a DumpCallback that will update the
// specified "keysToRemove" map with entries that exist in the BPF map which
// do not exist in the in-memory ipcache.
//
// Must be called while holding ipcache.IPIdentityCache.Lock for reading. | [
"updateStaleEntriesFunction",
"returns",
"a",
"DumpCallback",
"that",
"will",
"update",
"the",
"specified",
"keysToRemove",
"map",
"with",
"entries",
"that",
"exist",
"in",
"the",
"BPF",
"map",
"which",
"do",
"not",
"exist",
"in",
"the",
"in",
"-",
"memory",
"... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/ipcache/listener.go#L136-L151 |
163,394 | cilium/cilium | pkg/datapath/ipcache/listener.go | handleMapShuffleFailure | func handleMapShuffleFailure(src, dst string) {
backupPath := bpf.MapPath(src)
realizedPath := bpf.MapPath(dst)
if err := os.Rename(backupPath, realizedPath); err != nil {
log.WithError(err).WithFields(logrus.Fields{
logfields.BPFMapPath: realizedPath,
}).Warningf("Unable to recover during error renaming map paths")
}
} | go | func handleMapShuffleFailure(src, dst string) {
backupPath := bpf.MapPath(src)
realizedPath := bpf.MapPath(dst)
if err := os.Rename(backupPath, realizedPath); err != nil {
log.WithError(err).WithFields(logrus.Fields{
logfields.BPFMapPath: realizedPath,
}).Warningf("Unable to recover during error renaming map paths")
}
} | [
"func",
"handleMapShuffleFailure",
"(",
"src",
",",
"dst",
"string",
")",
"{",
"backupPath",
":=",
"bpf",
".",
"MapPath",
"(",
"src",
")",
"\n",
"realizedPath",
":=",
"bpf",
".",
"MapPath",
"(",
"dst",
")",
"\n\n",
"if",
"err",
":=",
"os",
".",
"Rename... | // handleMapShuffleFailure attempts to move the map with name 'backup' back to
// 'realized', and logs a warning message if this can't be achieved. | [
"handleMapShuffleFailure",
"attempts",
"to",
"move",
"the",
"map",
"with",
"name",
"backup",
"back",
"to",
"realized",
"and",
"logs",
"a",
"warning",
"message",
"if",
"this",
"can",
"t",
"be",
"achieved",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/ipcache/listener.go#L155-L164 |
163,395 | cilium/cilium | pkg/datapath/ipcache/listener.go | shuffleMaps | func shuffleMaps(realized, backup, pending string) error {
realizedPath := bpf.MapPath(realized)
backupPath := bpf.MapPath(backup)
pendingPath := bpf.MapPath(pending)
if err := os.Rename(realizedPath, backupPath); err != nil && !os.IsNotExist(err) {
return fmt.Errorf("Unable to back up existing ipcache: %s", err)
}
if err := os.Rename(pendingPath, realizedPath); err != nil {
handleMapShuffleFailure(backup, realized)
return fmt.Errorf("Unable to shift ipcache into new location: %s", err)
}
return nil
} | go | func shuffleMaps(realized, backup, pending string) error {
realizedPath := bpf.MapPath(realized)
backupPath := bpf.MapPath(backup)
pendingPath := bpf.MapPath(pending)
if err := os.Rename(realizedPath, backupPath); err != nil && !os.IsNotExist(err) {
return fmt.Errorf("Unable to back up existing ipcache: %s", err)
}
if err := os.Rename(pendingPath, realizedPath); err != nil {
handleMapShuffleFailure(backup, realized)
return fmt.Errorf("Unable to shift ipcache into new location: %s", err)
}
return nil
} | [
"func",
"shuffleMaps",
"(",
"realized",
",",
"backup",
",",
"pending",
"string",
")",
"error",
"{",
"realizedPath",
":=",
"bpf",
".",
"MapPath",
"(",
"realized",
")",
"\n",
"backupPath",
":=",
"bpf",
".",
"MapPath",
"(",
"backup",
")",
"\n",
"pendingPath",... | // shuffleMaps attempts to move the map with name 'realized' to 'backup' and
// 'pending' to 'realized'. If an error occurs, attempts to return the maps
// back to their original paths. | [
"shuffleMaps",
"attempts",
"to",
"move",
"the",
"map",
"with",
"name",
"realized",
"to",
"backup",
"and",
"pending",
"to",
"realized",
".",
"If",
"an",
"error",
"occurs",
"attempts",
"to",
"return",
"the",
"maps",
"back",
"to",
"their",
"original",
"paths",
... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/ipcache/listener.go#L169-L184 |
163,396 | cilium/cilium | pkg/datapath/ipcache/listener.go | OnIPIdentityCacheGC | func (l *BPFListener) OnIPIdentityCacheGC() {
// This controller ensures that the in-memory IP-identity cache is in-sync
// with the BPF map on disk. These can get out of sync if the cilium-agent
// is offline for some time, as the maps persist on the BPF filesystem.
// In the case that there is some loss of event history in the key-value
// store (e.g., compaction in etcd), we cannot rely upon the key-value store
// fully to give us the history of all events. As such, periodically check
// for inconsistencies in the data-path with that in the agent to ensure
// consistent state.
controller.NewManager().UpdateController("ipcache-bpf-garbage-collection",
controller.ControllerParams{
DoFunc: l.garbageCollect,
RunInterval: 5 * time.Minute,
},
)
} | go | func (l *BPFListener) OnIPIdentityCacheGC() {
// This controller ensures that the in-memory IP-identity cache is in-sync
// with the BPF map on disk. These can get out of sync if the cilium-agent
// is offline for some time, as the maps persist on the BPF filesystem.
// In the case that there is some loss of event history in the key-value
// store (e.g., compaction in etcd), we cannot rely upon the key-value store
// fully to give us the history of all events. As such, periodically check
// for inconsistencies in the data-path with that in the agent to ensure
// consistent state.
controller.NewManager().UpdateController("ipcache-bpf-garbage-collection",
controller.ControllerParams{
DoFunc: l.garbageCollect,
RunInterval: 5 * time.Minute,
},
)
} | [
"func",
"(",
"l",
"*",
"BPFListener",
")",
"OnIPIdentityCacheGC",
"(",
")",
"{",
"// This controller ensures that the in-memory IP-identity cache is in-sync",
"// with the BPF map on disk. These can get out of sync if the cilium-agent",
"// is offline for some time, as the maps persist on th... | // OnIPIdentityCacheGC spawns a controller which synchronizes the BPF IPCache Map
// with the in-memory IP-Identity cache. | [
"OnIPIdentityCacheGC",
"spawns",
"a",
"controller",
"which",
"synchronizes",
"the",
"BPF",
"IPCache",
"Map",
"with",
"the",
"in",
"-",
"memory",
"IP",
"-",
"Identity",
"cache",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/ipcache/listener.go#L265-L280 |
163,397 | cilium/cilium | api/v1/client/policy/delete_policy_parameters.go | WithTimeout | func (o *DeletePolicyParams) WithTimeout(timeout time.Duration) *DeletePolicyParams {
o.SetTimeout(timeout)
return o
} | go | func (o *DeletePolicyParams) WithTimeout(timeout time.Duration) *DeletePolicyParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"DeletePolicyParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"DeletePolicyParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the delete policy params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"delete",
"policy",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/delete_policy_parameters.go#L75-L78 |
163,398 | cilium/cilium | api/v1/client/policy/delete_policy_parameters.go | WithContext | func (o *DeletePolicyParams) WithContext(ctx context.Context) *DeletePolicyParams {
o.SetContext(ctx)
return o
} | go | func (o *DeletePolicyParams) WithContext(ctx context.Context) *DeletePolicyParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"DeletePolicyParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"DeletePolicyParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the delete policy params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"delete",
"policy",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/delete_policy_parameters.go#L86-L89 |
163,399 | cilium/cilium | api/v1/client/policy/delete_policy_parameters.go | WithHTTPClient | func (o *DeletePolicyParams) WithHTTPClient(client *http.Client) *DeletePolicyParams {
o.SetHTTPClient(client)
return o
} | go | func (o *DeletePolicyParams) WithHTTPClient(client *http.Client) *DeletePolicyParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"DeletePolicyParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"DeletePolicyParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the delete policy params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"delete",
"policy",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/delete_policy_parameters.go#L97-L100 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.