id
int32 0
167k
| repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
sequencelengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
sequencelengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
163,100 | cilium/cilium | pkg/identity/identitymanager/manager.go | NewIdentityManager | func NewIdentityManager() *IdentityManager {
return &IdentityManager{
identities: make(map[identity.NumericIdentity]*identityMetadata),
observers: make(map[Observer]struct{}),
}
} | go | func NewIdentityManager() *IdentityManager {
return &IdentityManager{
identities: make(map[identity.NumericIdentity]*identityMetadata),
observers: make(map[Observer]struct{}),
}
} | [
"func",
"NewIdentityManager",
"(",
")",
"*",
"IdentityManager",
"{",
"return",
"&",
"IdentityManager",
"{",
"identities",
":",
"make",
"(",
"map",
"[",
"identity",
".",
"NumericIdentity",
"]",
"*",
"identityMetadata",
")",
",",
"observers",
":",
"make",
"(",
"map",
"[",
"Observer",
"]",
"struct",
"{",
"}",
")",
",",
"}",
"\n",
"}"
] | // NewIdentityManager returns an initialized IdentityManager. | [
"NewIdentityManager",
"returns",
"an",
"initialized",
"IdentityManager",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/identitymanager/manager.go#L45-L50 |
163,101 | cilium/cilium | pkg/identity/identitymanager/manager.go | Add | func (idm *IdentityManager) Add(identity *identity.Identity) {
idm.mutex.Lock()
defer idm.mutex.Unlock()
idm.add(identity)
} | go | func (idm *IdentityManager) Add(identity *identity.Identity) {
idm.mutex.Lock()
defer idm.mutex.Unlock()
idm.add(identity)
} | [
"func",
"(",
"idm",
"*",
"IdentityManager",
")",
"Add",
"(",
"identity",
"*",
"identity",
".",
"Identity",
")",
"{",
"idm",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"idm",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"idm",
".",
"add",
"(",
"identity",
")",
"\n",
"}"
] | // Add inserts the identity into the identity manager. If the identity is
// already in the identity manager, the reference count for the identity is
// incremented. | [
"Add",
"inserts",
"the",
"identity",
"into",
"the",
"identity",
"manager",
".",
"If",
"the",
"identity",
"is",
"already",
"in",
"the",
"identity",
"manager",
"the",
"reference",
"count",
"for",
"the",
"identity",
"is",
"incremented",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/identitymanager/manager.go#L65-L69 |
163,102 | cilium/cilium | pkg/identity/identitymanager/manager.go | RemoveOldAddNew | func (idm *IdentityManager) RemoveOldAddNew(old, new *identity.Identity) {
idm.mutex.Lock()
defer idm.mutex.Unlock()
idm.remove(old)
idm.add(new)
} | go | func (idm *IdentityManager) RemoveOldAddNew(old, new *identity.Identity) {
idm.mutex.Lock()
defer idm.mutex.Unlock()
idm.remove(old)
idm.add(new)
} | [
"func",
"(",
"idm",
"*",
"IdentityManager",
")",
"RemoveOldAddNew",
"(",
"old",
",",
"new",
"*",
"identity",
".",
"Identity",
")",
"{",
"idm",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"idm",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"idm",
".",
"remove",
"(",
"old",
")",
"\n",
"idm",
".",
"add",
"(",
"new",
")",
"\n",
"}"
] | // RemoveOldAddNew removes old from the identity manager and inserts new
// into the IdentityManager. | [
"RemoveOldAddNew",
"removes",
"old",
"from",
"the",
"identity",
"manager",
"and",
"inserts",
"new",
"into",
"the",
"IdentityManager",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/identitymanager/manager.go#L93-L99 |
163,103 | cilium/cilium | pkg/identity/identitymanager/manager.go | Remove | func (idm *IdentityManager) Remove(identity *identity.Identity) {
idm.mutex.Lock()
defer idm.mutex.Unlock()
idm.remove(identity)
} | go | func (idm *IdentityManager) Remove(identity *identity.Identity) {
idm.mutex.Lock()
defer idm.mutex.Unlock()
idm.remove(identity)
} | [
"func",
"(",
"idm",
"*",
"IdentityManager",
")",
"Remove",
"(",
"identity",
"*",
"identity",
".",
"Identity",
")",
"{",
"idm",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"idm",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"idm",
".",
"remove",
"(",
"identity",
")",
"\n",
"}"
] | // Remove deletes the identity from the identity manager. If the identity is
// already in the identity manager, the reference count for the identity is
// decremented. If the identity is not in the cache, this is a no-op. If the
// ref count becomes zero, the identity is removed from the cache. | [
"Remove",
"deletes",
"the",
"identity",
"from",
"the",
"identity",
"manager",
".",
"If",
"the",
"identity",
"is",
"already",
"in",
"the",
"identity",
"manager",
"the",
"reference",
"count",
"for",
"the",
"identity",
"is",
"decremented",
".",
"If",
"the",
"identity",
"is",
"not",
"in",
"the",
"cache",
"this",
"is",
"a",
"no",
"-",
"op",
".",
"If",
"the",
"ref",
"count",
"becomes",
"zero",
"the",
"identity",
"is",
"removed",
"from",
"the",
"cache",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/identitymanager/manager.go#L111-L115 |
163,104 | cilium/cilium | pkg/identity/identitymanager/manager.go | GetIdentityModels | func (idm *IdentityManager) GetIdentityModels() []*models.IdentityEndpoints {
idm.mutex.RLock()
defer idm.mutex.RUnlock()
identities := make([]*models.IdentityEndpoints, 0, len(idm.identities))
for _, v := range idm.identities {
identities = append(identities, &models.IdentityEndpoints{
Identity: v.identity.GetModel(),
RefCount: int64(v.refCount),
})
}
return identities
} | go | func (idm *IdentityManager) GetIdentityModels() []*models.IdentityEndpoints {
idm.mutex.RLock()
defer idm.mutex.RUnlock()
identities := make([]*models.IdentityEndpoints, 0, len(idm.identities))
for _, v := range idm.identities {
identities = append(identities, &models.IdentityEndpoints{
Identity: v.identity.GetModel(),
RefCount: int64(v.refCount),
})
}
return identities
} | [
"func",
"(",
"idm",
"*",
"IdentityManager",
")",
"GetIdentityModels",
"(",
")",
"[",
"]",
"*",
"models",
".",
"IdentityEndpoints",
"{",
"idm",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"idm",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n\n",
"identities",
":=",
"make",
"(",
"[",
"]",
"*",
"models",
".",
"IdentityEndpoints",
",",
"0",
",",
"len",
"(",
"idm",
".",
"identities",
")",
")",
"\n\n",
"for",
"_",
",",
"v",
":=",
"range",
"idm",
".",
"identities",
"{",
"identities",
"=",
"append",
"(",
"identities",
",",
"&",
"models",
".",
"IdentityEndpoints",
"{",
"Identity",
":",
"v",
".",
"identity",
".",
"GetModel",
"(",
")",
",",
"RefCount",
":",
"int64",
"(",
"v",
".",
"refCount",
")",
",",
"}",
")",
"\n",
"}",
"\n\n",
"return",
"identities",
"\n",
"}"
] | // GetIdentityModels returns the API representation of the IdentityManager. | [
"GetIdentityModels",
"returns",
"the",
"API",
"representation",
"of",
"the",
"IdentityManager",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/identitymanager/manager.go#L138-L152 |
163,105 | cilium/cilium | pkg/elf/elf.go | NewELF | func NewELF(ra io.ReaderAt, scopedLog *logrus.Entry) (*ELF, error) {
ef, err := elf.NewFile(ra)
if err != nil {
return nil, fmt.Errorf("unable to open ELF: %s", err)
}
// EM_NONE is generated by older Clang (eg 3.8.x), which we currently
// use in Travis. We should be able to drop that part pretty soon.
if ef.Machine != elf.EM_NONE && ef.Machine != elf.EM_BPF {
return nil, fmt.Errorf("unsupported ELF machine type %s", ef.Machine)
}
result := &ELF{
metadata: ef,
log: scopedLog,
}
if err := result.symbols.extractFrom(ef); err != nil {
return nil, fmt.Errorf("unable to read ELF symbols: %s", err)
}
return result, nil
} | go | func NewELF(ra io.ReaderAt, scopedLog *logrus.Entry) (*ELF, error) {
ef, err := elf.NewFile(ra)
if err != nil {
return nil, fmt.Errorf("unable to open ELF: %s", err)
}
// EM_NONE is generated by older Clang (eg 3.8.x), which we currently
// use in Travis. We should be able to drop that part pretty soon.
if ef.Machine != elf.EM_NONE && ef.Machine != elf.EM_BPF {
return nil, fmt.Errorf("unsupported ELF machine type %s", ef.Machine)
}
result := &ELF{
metadata: ef,
log: scopedLog,
}
if err := result.symbols.extractFrom(ef); err != nil {
return nil, fmt.Errorf("unable to read ELF symbols: %s", err)
}
return result, nil
} | [
"func",
"NewELF",
"(",
"ra",
"io",
".",
"ReaderAt",
",",
"scopedLog",
"*",
"logrus",
".",
"Entry",
")",
"(",
"*",
"ELF",
",",
"error",
")",
"{",
"ef",
",",
"err",
":=",
"elf",
".",
"NewFile",
"(",
"ra",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"// EM_NONE is generated by older Clang (eg 3.8.x), which we currently",
"// use in Travis. We should be able to drop that part pretty soon.",
"if",
"ef",
".",
"Machine",
"!=",
"elf",
".",
"EM_NONE",
"&&",
"ef",
".",
"Machine",
"!=",
"elf",
".",
"EM_BPF",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ef",
".",
"Machine",
")",
"\n",
"}",
"\n\n",
"result",
":=",
"&",
"ELF",
"{",
"metadata",
":",
"ef",
",",
"log",
":",
"scopedLog",
",",
"}",
"\n",
"if",
"err",
":=",
"result",
".",
"symbols",
".",
"extractFrom",
"(",
"ef",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"result",
",",
"nil",
"\n",
"}"
] | // NewELF returns a new object from the specified reader.
//
// The ELF binary is expected to start at position 0 in the specified reader. | [
"NewELF",
"returns",
"a",
"new",
"object",
"from",
"the",
"specified",
"reader",
".",
"The",
"ELF",
"binary",
"is",
"expected",
"to",
"start",
"at",
"position",
"0",
"in",
"the",
"specified",
"reader",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/elf/elf.go#L61-L82 |
163,106 | cilium/cilium | pkg/elf/elf.go | Open | func Open(path string) (*ELF, error) {
scopedLog := log.WithField(srcPath, path)
f, err := os.Open(path)
if err != nil {
return nil, &os.PathError{
Op: "failed to open ELF file",
Path: path,
Err: err,
}
}
result, err := NewELF(f, scopedLog)
if err != nil {
if err2 := f.Close(); err2 != nil {
scopedLog.WithError(err).Warning("Failed to close ELF")
}
return nil, &os.PathError{
Op: "failed to parse ELF file",
Path: path,
Err: err,
}
}
result.file = f
return result, nil
} | go | func Open(path string) (*ELF, error) {
scopedLog := log.WithField(srcPath, path)
f, err := os.Open(path)
if err != nil {
return nil, &os.PathError{
Op: "failed to open ELF file",
Path: path,
Err: err,
}
}
result, err := NewELF(f, scopedLog)
if err != nil {
if err2 := f.Close(); err2 != nil {
scopedLog.WithError(err).Warning("Failed to close ELF")
}
return nil, &os.PathError{
Op: "failed to parse ELF file",
Path: path,
Err: err,
}
}
result.file = f
return result, nil
} | [
"func",
"Open",
"(",
"path",
"string",
")",
"(",
"*",
"ELF",
",",
"error",
")",
"{",
"scopedLog",
":=",
"log",
".",
"WithField",
"(",
"srcPath",
",",
"path",
")",
"\n\n",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"&",
"os",
".",
"PathError",
"{",
"Op",
":",
"\"",
"\"",
",",
"Path",
":",
"path",
",",
"Err",
":",
"err",
",",
"}",
"\n",
"}",
"\n\n",
"result",
",",
"err",
":=",
"NewELF",
"(",
"f",
",",
"scopedLog",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"err2",
":=",
"f",
".",
"Close",
"(",
")",
";",
"err2",
"!=",
"nil",
"{",
"scopedLog",
".",
"WithError",
"(",
"err",
")",
".",
"Warning",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"nil",
",",
"&",
"os",
".",
"PathError",
"{",
"Op",
":",
"\"",
"\"",
",",
"Path",
":",
"path",
",",
"Err",
":",
"err",
",",
"}",
"\n",
"}",
"\n",
"result",
".",
"file",
"=",
"f",
"\n",
"return",
"result",
",",
"nil",
"\n",
"}"
] | // Open an ELF file from the specified path. | [
"Open",
"an",
"ELF",
"file",
"from",
"the",
"specified",
"path",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/elf/elf.go#L85-L110 |
163,107 | cilium/cilium | pkg/elf/elf.go | Close | func (elf *ELF) Close() (err error) {
if elf.file != nil {
err = elf.file.Close()
}
return err
} | go | func (elf *ELF) Close() (err error) {
if elf.file != nil {
err = elf.file.Close()
}
return err
} | [
"func",
"(",
"elf",
"*",
"ELF",
")",
"Close",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"elf",
".",
"file",
"!=",
"nil",
"{",
"err",
"=",
"elf",
".",
"file",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] | // Close closes the ELF. If the File was created using NewELF directly instead
// of Open, Close has no effect. | [
"Close",
"closes",
"the",
"ELF",
".",
"If",
"the",
"File",
"was",
"created",
"using",
"NewELF",
"directly",
"instead",
"of",
"Open",
"Close",
"has",
"no",
"effect",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/elf/elf.go#L114-L119 |
163,108 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/register.go | CreateCustomResourceDefinitions | func CreateCustomResourceDefinitions(clientset apiextensionsclient.Interface) error {
if err := createCNPCRD(clientset); err != nil {
return err
}
if err := createCEPCRD(clientset); err != nil {
return err
}
return nil
} | go | func CreateCustomResourceDefinitions(clientset apiextensionsclient.Interface) error {
if err := createCNPCRD(clientset); err != nil {
return err
}
if err := createCEPCRD(clientset); err != nil {
return err
}
return nil
} | [
"func",
"CreateCustomResourceDefinitions",
"(",
"clientset",
"apiextensionsclient",
".",
"Interface",
")",
"error",
"{",
"if",
"err",
":=",
"createCNPCRD",
"(",
"clientset",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"createCEPCRD",
"(",
"clientset",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // CreateCustomResourceDefinitions creates our CRD objects in the kubernetes
// cluster | [
"CreateCustomResourceDefinitions",
"creates",
"our",
"CRD",
"objects",
"in",
"the",
"kubernetes",
"cluster"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/register.go#L113-L123 |
163,109 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/register.go | createCNPCRD | func createCNPCRD(clientset apiextensionsclient.Interface) error {
var (
// CustomResourceDefinitionSingularName is the singular name of custom resource definition
CustomResourceDefinitionSingularName = "ciliumnetworkpolicy"
// CustomResourceDefinitionPluralName is the plural name of custom resource definition
CustomResourceDefinitionPluralName = "ciliumnetworkpolicies"
// CustomResourceDefinitionShortNames are the abbreviated names to refer to this CRD's instances
CustomResourceDefinitionShortNames = []string{"cnp", "ciliumnp"}
// CustomResourceDefinitionKind is the Kind name of custom resource definition
CustomResourceDefinitionKind = CNPKindDefinition
CRDName = CustomResourceDefinitionPluralName + "." + SchemeGroupVersion.Group
)
res := &apiextensionsv1beta1.CustomResourceDefinition{
ObjectMeta: metav1.ObjectMeta{
Name: CRDName,
Labels: map[string]string{
CustomResourceDefinitionSchemaVersionKey: CustomResourceDefinitionSchemaVersion,
},
},
Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{
Group: SchemeGroupVersion.Group,
Version: SchemeGroupVersion.Version,
Names: apiextensionsv1beta1.CustomResourceDefinitionNames{
Plural: CustomResourceDefinitionPluralName,
Singular: CustomResourceDefinitionSingularName,
ShortNames: CustomResourceDefinitionShortNames,
Kind: CustomResourceDefinitionKind,
},
Subresources: &apiextensionsv1beta1.CustomResourceSubresources{
Status: &apiextensionsv1beta1.CustomResourceSubresourceStatus{},
},
Scope: apiextensionsv1beta1.NamespaceScoped,
Validation: &cnpCRV,
},
}
return createUpdateCRD(clientset, "CiliumNetworkPolicy/v2", res)
} | go | func createCNPCRD(clientset apiextensionsclient.Interface) error {
var (
// CustomResourceDefinitionSingularName is the singular name of custom resource definition
CustomResourceDefinitionSingularName = "ciliumnetworkpolicy"
// CustomResourceDefinitionPluralName is the plural name of custom resource definition
CustomResourceDefinitionPluralName = "ciliumnetworkpolicies"
// CustomResourceDefinitionShortNames are the abbreviated names to refer to this CRD's instances
CustomResourceDefinitionShortNames = []string{"cnp", "ciliumnp"}
// CustomResourceDefinitionKind is the Kind name of custom resource definition
CustomResourceDefinitionKind = CNPKindDefinition
CRDName = CustomResourceDefinitionPluralName + "." + SchemeGroupVersion.Group
)
res := &apiextensionsv1beta1.CustomResourceDefinition{
ObjectMeta: metav1.ObjectMeta{
Name: CRDName,
Labels: map[string]string{
CustomResourceDefinitionSchemaVersionKey: CustomResourceDefinitionSchemaVersion,
},
},
Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{
Group: SchemeGroupVersion.Group,
Version: SchemeGroupVersion.Version,
Names: apiextensionsv1beta1.CustomResourceDefinitionNames{
Plural: CustomResourceDefinitionPluralName,
Singular: CustomResourceDefinitionSingularName,
ShortNames: CustomResourceDefinitionShortNames,
Kind: CustomResourceDefinitionKind,
},
Subresources: &apiextensionsv1beta1.CustomResourceSubresources{
Status: &apiextensionsv1beta1.CustomResourceSubresourceStatus{},
},
Scope: apiextensionsv1beta1.NamespaceScoped,
Validation: &cnpCRV,
},
}
return createUpdateCRD(clientset, "CiliumNetworkPolicy/v2", res)
} | [
"func",
"createCNPCRD",
"(",
"clientset",
"apiextensionsclient",
".",
"Interface",
")",
"error",
"{",
"var",
"(",
"// CustomResourceDefinitionSingularName is the singular name of custom resource definition",
"CustomResourceDefinitionSingularName",
"=",
"\"",
"\"",
"\n\n",
"// CustomResourceDefinitionPluralName is the plural name of custom resource definition",
"CustomResourceDefinitionPluralName",
"=",
"\"",
"\"",
"\n\n",
"// CustomResourceDefinitionShortNames are the abbreviated names to refer to this CRD's instances",
"CustomResourceDefinitionShortNames",
"=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"\n\n",
"// CustomResourceDefinitionKind is the Kind name of custom resource definition",
"CustomResourceDefinitionKind",
"=",
"CNPKindDefinition",
"\n\n",
"CRDName",
"=",
"CustomResourceDefinitionPluralName",
"+",
"\"",
"\"",
"+",
"SchemeGroupVersion",
".",
"Group",
"\n",
")",
"\n\n",
"res",
":=",
"&",
"apiextensionsv1beta1",
".",
"CustomResourceDefinition",
"{",
"ObjectMeta",
":",
"metav1",
".",
"ObjectMeta",
"{",
"Name",
":",
"CRDName",
",",
"Labels",
":",
"map",
"[",
"string",
"]",
"string",
"{",
"CustomResourceDefinitionSchemaVersionKey",
":",
"CustomResourceDefinitionSchemaVersion",
",",
"}",
",",
"}",
",",
"Spec",
":",
"apiextensionsv1beta1",
".",
"CustomResourceDefinitionSpec",
"{",
"Group",
":",
"SchemeGroupVersion",
".",
"Group",
",",
"Version",
":",
"SchemeGroupVersion",
".",
"Version",
",",
"Names",
":",
"apiextensionsv1beta1",
".",
"CustomResourceDefinitionNames",
"{",
"Plural",
":",
"CustomResourceDefinitionPluralName",
",",
"Singular",
":",
"CustomResourceDefinitionSingularName",
",",
"ShortNames",
":",
"CustomResourceDefinitionShortNames",
",",
"Kind",
":",
"CustomResourceDefinitionKind",
",",
"}",
",",
"Subresources",
":",
"&",
"apiextensionsv1beta1",
".",
"CustomResourceSubresources",
"{",
"Status",
":",
"&",
"apiextensionsv1beta1",
".",
"CustomResourceSubresourceStatus",
"{",
"}",
",",
"}",
",",
"Scope",
":",
"apiextensionsv1beta1",
".",
"NamespaceScoped",
",",
"Validation",
":",
"&",
"cnpCRV",
",",
"}",
",",
"}",
"\n\n",
"return",
"createUpdateCRD",
"(",
"clientset",
",",
"\"",
"\"",
",",
"res",
")",
"\n",
"}"
] | // createCNPCRD creates and updates the CiliumNetworkPolicies CRD. It should be called
// on agent startup but is idempotent and safe to call again. | [
"createCNPCRD",
"creates",
"and",
"updates",
"the",
"CiliumNetworkPolicies",
"CRD",
".",
"It",
"should",
"be",
"called",
"on",
"agent",
"startup",
"but",
"is",
"idempotent",
"and",
"safe",
"to",
"call",
"again",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/register.go#L127-L169 |
163,110 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/register.go | createCEPCRD | func createCEPCRD(clientset apiextensionsclient.Interface) error {
var (
// CustomResourceDefinitionSingularName is the singular name of custom resource definition
CustomResourceDefinitionSingularName = "ciliumendpoint"
// CustomResourceDefinitionPluralName is the plural name of custom resource definition
CustomResourceDefinitionPluralName = "ciliumendpoints"
// CustomResourceDefinitionShortNames are the abbreviated names to refer to this CRD's instances
CustomResourceDefinitionShortNames = []string{"cep", "ciliumep"}
// CustomResourceDefinitionKind is the Kind name of custom resource definition
CustomResourceDefinitionKind = "CiliumEndpoint"
CRDName = CustomResourceDefinitionPluralName + "." + SchemeGroupVersion.Group
)
res := &apiextensionsv1beta1.CustomResourceDefinition{
ObjectMeta: metav1.ObjectMeta{
Name: CRDName,
},
Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{
Group: SchemeGroupVersion.Group,
Version: SchemeGroupVersion.Version,
Names: apiextensionsv1beta1.CustomResourceDefinitionNames{
Plural: CustomResourceDefinitionPluralName,
Singular: CustomResourceDefinitionSingularName,
ShortNames: CustomResourceDefinitionShortNames,
Kind: CustomResourceDefinitionKind,
},
AdditionalPrinterColumns: []apiextensionsv1beta1.CustomResourceColumnDefinition{
{
Name: "Endpoint ID",
Type: "integer",
Description: "Cilium endpoint id",
JSONPath: ".status.id",
},
{
Name: "Identity ID",
Type: "integer",
Description: "Cilium identity id",
JSONPath: ".status.identity.id",
},
{
Name: "Ingress Enforcement",
Type: "boolean",
Description: "Ingress enforcement in the endpoint",
JSONPath: ".status.policy.ingress.enforcing",
},
{
Name: "Egress Enforcement",
Type: "boolean",
Description: "Egress enforcement in the endpoint",
JSONPath: ".status.policy.egress.enforcing",
},
{
Name: "Endpoint State",
Type: "string",
Description: "Endpoint current state",
JSONPath: ".status.state",
},
{
Name: "IPv4",
Type: "string",
Description: "Endpoint IPv4 address",
JSONPath: ".status.networking.addressing[0].ipv4",
},
{
Name: "IPv6",
Type: "string",
Description: "Endpoint IPv6 address",
JSONPath: ".status.networking.addressing[0].ipv6",
},
},
Subresources: &apiextensionsv1beta1.CustomResourceSubresources{
Status: &apiextensionsv1beta1.CustomResourceSubresourceStatus{},
},
Scope: apiextensionsv1beta1.NamespaceScoped,
Validation: &cepCRV,
},
}
return createUpdateCRD(clientset, "v2.CiliumEndpoint", res)
} | go | func createCEPCRD(clientset apiextensionsclient.Interface) error {
var (
// CustomResourceDefinitionSingularName is the singular name of custom resource definition
CustomResourceDefinitionSingularName = "ciliumendpoint"
// CustomResourceDefinitionPluralName is the plural name of custom resource definition
CustomResourceDefinitionPluralName = "ciliumendpoints"
// CustomResourceDefinitionShortNames are the abbreviated names to refer to this CRD's instances
CustomResourceDefinitionShortNames = []string{"cep", "ciliumep"}
// CustomResourceDefinitionKind is the Kind name of custom resource definition
CustomResourceDefinitionKind = "CiliumEndpoint"
CRDName = CustomResourceDefinitionPluralName + "." + SchemeGroupVersion.Group
)
res := &apiextensionsv1beta1.CustomResourceDefinition{
ObjectMeta: metav1.ObjectMeta{
Name: CRDName,
},
Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{
Group: SchemeGroupVersion.Group,
Version: SchemeGroupVersion.Version,
Names: apiextensionsv1beta1.CustomResourceDefinitionNames{
Plural: CustomResourceDefinitionPluralName,
Singular: CustomResourceDefinitionSingularName,
ShortNames: CustomResourceDefinitionShortNames,
Kind: CustomResourceDefinitionKind,
},
AdditionalPrinterColumns: []apiextensionsv1beta1.CustomResourceColumnDefinition{
{
Name: "Endpoint ID",
Type: "integer",
Description: "Cilium endpoint id",
JSONPath: ".status.id",
},
{
Name: "Identity ID",
Type: "integer",
Description: "Cilium identity id",
JSONPath: ".status.identity.id",
},
{
Name: "Ingress Enforcement",
Type: "boolean",
Description: "Ingress enforcement in the endpoint",
JSONPath: ".status.policy.ingress.enforcing",
},
{
Name: "Egress Enforcement",
Type: "boolean",
Description: "Egress enforcement in the endpoint",
JSONPath: ".status.policy.egress.enforcing",
},
{
Name: "Endpoint State",
Type: "string",
Description: "Endpoint current state",
JSONPath: ".status.state",
},
{
Name: "IPv4",
Type: "string",
Description: "Endpoint IPv4 address",
JSONPath: ".status.networking.addressing[0].ipv4",
},
{
Name: "IPv6",
Type: "string",
Description: "Endpoint IPv6 address",
JSONPath: ".status.networking.addressing[0].ipv6",
},
},
Subresources: &apiextensionsv1beta1.CustomResourceSubresources{
Status: &apiextensionsv1beta1.CustomResourceSubresourceStatus{},
},
Scope: apiextensionsv1beta1.NamespaceScoped,
Validation: &cepCRV,
},
}
return createUpdateCRD(clientset, "v2.CiliumEndpoint", res)
} | [
"func",
"createCEPCRD",
"(",
"clientset",
"apiextensionsclient",
".",
"Interface",
")",
"error",
"{",
"var",
"(",
"// CustomResourceDefinitionSingularName is the singular name of custom resource definition",
"CustomResourceDefinitionSingularName",
"=",
"\"",
"\"",
"\n\n",
"// CustomResourceDefinitionPluralName is the plural name of custom resource definition",
"CustomResourceDefinitionPluralName",
"=",
"\"",
"\"",
"\n\n",
"// CustomResourceDefinitionShortNames are the abbreviated names to refer to this CRD's instances",
"CustomResourceDefinitionShortNames",
"=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"\n\n",
"// CustomResourceDefinitionKind is the Kind name of custom resource definition",
"CustomResourceDefinitionKind",
"=",
"\"",
"\"",
"\n\n",
"CRDName",
"=",
"CustomResourceDefinitionPluralName",
"+",
"\"",
"\"",
"+",
"SchemeGroupVersion",
".",
"Group",
"\n",
")",
"\n\n",
"res",
":=",
"&",
"apiextensionsv1beta1",
".",
"CustomResourceDefinition",
"{",
"ObjectMeta",
":",
"metav1",
".",
"ObjectMeta",
"{",
"Name",
":",
"CRDName",
",",
"}",
",",
"Spec",
":",
"apiextensionsv1beta1",
".",
"CustomResourceDefinitionSpec",
"{",
"Group",
":",
"SchemeGroupVersion",
".",
"Group",
",",
"Version",
":",
"SchemeGroupVersion",
".",
"Version",
",",
"Names",
":",
"apiextensionsv1beta1",
".",
"CustomResourceDefinitionNames",
"{",
"Plural",
":",
"CustomResourceDefinitionPluralName",
",",
"Singular",
":",
"CustomResourceDefinitionSingularName",
",",
"ShortNames",
":",
"CustomResourceDefinitionShortNames",
",",
"Kind",
":",
"CustomResourceDefinitionKind",
",",
"}",
",",
"AdditionalPrinterColumns",
":",
"[",
"]",
"apiextensionsv1beta1",
".",
"CustomResourceColumnDefinition",
"{",
"{",
"Name",
":",
"\"",
"\"",
",",
"Type",
":",
"\"",
"\"",
",",
"Description",
":",
"\"",
"\"",
",",
"JSONPath",
":",
"\"",
"\"",
",",
"}",
",",
"{",
"Name",
":",
"\"",
"\"",
",",
"Type",
":",
"\"",
"\"",
",",
"Description",
":",
"\"",
"\"",
",",
"JSONPath",
":",
"\"",
"\"",
",",
"}",
",",
"{",
"Name",
":",
"\"",
"\"",
",",
"Type",
":",
"\"",
"\"",
",",
"Description",
":",
"\"",
"\"",
",",
"JSONPath",
":",
"\"",
"\"",
",",
"}",
",",
"{",
"Name",
":",
"\"",
"\"",
",",
"Type",
":",
"\"",
"\"",
",",
"Description",
":",
"\"",
"\"",
",",
"JSONPath",
":",
"\"",
"\"",
",",
"}",
",",
"{",
"Name",
":",
"\"",
"\"",
",",
"Type",
":",
"\"",
"\"",
",",
"Description",
":",
"\"",
"\"",
",",
"JSONPath",
":",
"\"",
"\"",
",",
"}",
",",
"{",
"Name",
":",
"\"",
"\"",
",",
"Type",
":",
"\"",
"\"",
",",
"Description",
":",
"\"",
"\"",
",",
"JSONPath",
":",
"\"",
"\"",
",",
"}",
",",
"{",
"Name",
":",
"\"",
"\"",
",",
"Type",
":",
"\"",
"\"",
",",
"Description",
":",
"\"",
"\"",
",",
"JSONPath",
":",
"\"",
"\"",
",",
"}",
",",
"}",
",",
"Subresources",
":",
"&",
"apiextensionsv1beta1",
".",
"CustomResourceSubresources",
"{",
"Status",
":",
"&",
"apiextensionsv1beta1",
".",
"CustomResourceSubresourceStatus",
"{",
"}",
",",
"}",
",",
"Scope",
":",
"apiextensionsv1beta1",
".",
"NamespaceScoped",
",",
"Validation",
":",
"&",
"cepCRV",
",",
"}",
",",
"}",
"\n\n",
"return",
"createUpdateCRD",
"(",
"clientset",
",",
"\"",
"\"",
",",
"res",
")",
"\n",
"}"
] | // createCEPCRD creates and updates the CiliumEndpoint CRD. It should be called
// on agent startup but is idempotent and safe to call again. | [
"createCEPCRD",
"creates",
"and",
"updates",
"the",
"CiliumEndpoint",
"CRD",
".",
"It",
"should",
"be",
"called",
"on",
"agent",
"startup",
"but",
"is",
"idempotent",
"and",
"safe",
"to",
"call",
"again",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/register.go#L173-L256 |
163,111 | cilium/cilium | pkg/endpoint/endpoint.go | UpdateController | func (e *Endpoint) UpdateController(name string, params controller.ControllerParams) *controller.Controller {
return e.controllers.UpdateController(name, params)
} | go | func (e *Endpoint) UpdateController(name string, params controller.ControllerParams) *controller.Controller {
return e.controllers.UpdateController(name, params)
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"UpdateController",
"(",
"name",
"string",
",",
"params",
"controller",
".",
"ControllerParams",
")",
"*",
"controller",
".",
"Controller",
"{",
"return",
"e",
".",
"controllers",
".",
"UpdateController",
"(",
"name",
",",
"params",
")",
"\n",
"}"
] | // UpdateController updates the controller with the specified name with the
// provided list of parameters in endpoint's list of controllers. | [
"UpdateController",
"updates",
"the",
"controller",
"with",
"the",
"specified",
"name",
"with",
"the",
"provided",
"list",
"of",
"parameters",
"in",
"endpoint",
"s",
"list",
"of",
"controllers",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L315-L317 |
163,112 | cilium/cilium | pkg/endpoint/endpoint.go | SetDesiredIngressPolicyEnabled | func (e *Endpoint) SetDesiredIngressPolicyEnabled(ingress bool) {
e.UnconditionalLock()
e.desiredPolicy.IngressPolicyEnabled = ingress
e.Unlock()
} | go | func (e *Endpoint) SetDesiredIngressPolicyEnabled(ingress bool) {
e.UnconditionalLock()
e.desiredPolicy.IngressPolicyEnabled = ingress
e.Unlock()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"SetDesiredIngressPolicyEnabled",
"(",
"ingress",
"bool",
")",
"{",
"e",
".",
"UnconditionalLock",
"(",
")",
"\n",
"e",
".",
"desiredPolicy",
".",
"IngressPolicyEnabled",
"=",
"ingress",
"\n",
"e",
".",
"Unlock",
"(",
")",
"\n\n",
"}"
] | // SetDesiredIngressPolicyEnabled sets Endpoint's ingress policy enforcement
// configuration to the specified value. The endpoint's mutex must not be held. | [
"SetDesiredIngressPolicyEnabled",
"sets",
"Endpoint",
"s",
"ingress",
"policy",
"enforcement",
"configuration",
"to",
"the",
"specified",
"value",
".",
"The",
"endpoint",
"s",
"mutex",
"must",
"not",
"be",
"held",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L363-L368 |
163,113 | cilium/cilium | pkg/endpoint/endpoint.go | SetDesiredEgressPolicyEnabled | func (e *Endpoint) SetDesiredEgressPolicyEnabled(egress bool) {
e.UnconditionalLock()
e.desiredPolicy.EgressPolicyEnabled = egress
e.Unlock()
} | go | func (e *Endpoint) SetDesiredEgressPolicyEnabled(egress bool) {
e.UnconditionalLock()
e.desiredPolicy.EgressPolicyEnabled = egress
e.Unlock()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"SetDesiredEgressPolicyEnabled",
"(",
"egress",
"bool",
")",
"{",
"e",
".",
"UnconditionalLock",
"(",
")",
"\n",
"e",
".",
"desiredPolicy",
".",
"EgressPolicyEnabled",
"=",
"egress",
"\n",
"e",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // SetDesiredEgressPolicyEnabled sets Endpoint's egress policy enforcement
// configuration to the specified value. The endpoint's mutex must not be held. | [
"SetDesiredEgressPolicyEnabled",
"sets",
"Endpoint",
"s",
"egress",
"policy",
"enforcement",
"configuration",
"to",
"the",
"specified",
"value",
".",
"The",
"endpoint",
"s",
"mutex",
"must",
"not",
"be",
"held",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L372-L376 |
163,114 | cilium/cilium | pkg/endpoint/endpoint.go | WaitForProxyCompletions | func (e *Endpoint) WaitForProxyCompletions(proxyWaitGroup *completion.WaitGroup) error {
if proxyWaitGroup == nil {
return nil
}
err := proxyWaitGroup.Context().Err()
if err != nil {
return fmt.Errorf("context cancelled before waiting for proxy updates: %s", err)
}
start := time.Now()
e.getLogger().Debug("Waiting for proxy updates to complete...")
err = proxyWaitGroup.Wait()
if err != nil {
return fmt.Errorf("proxy state changes failed: %s", err)
}
e.getLogger().Debug("Wait time for proxy updates: ", time.Since(start))
return nil
} | go | func (e *Endpoint) WaitForProxyCompletions(proxyWaitGroup *completion.WaitGroup) error {
if proxyWaitGroup == nil {
return nil
}
err := proxyWaitGroup.Context().Err()
if err != nil {
return fmt.Errorf("context cancelled before waiting for proxy updates: %s", err)
}
start := time.Now()
e.getLogger().Debug("Waiting for proxy updates to complete...")
err = proxyWaitGroup.Wait()
if err != nil {
return fmt.Errorf("proxy state changes failed: %s", err)
}
e.getLogger().Debug("Wait time for proxy updates: ", time.Since(start))
return nil
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"WaitForProxyCompletions",
"(",
"proxyWaitGroup",
"*",
"completion",
".",
"WaitGroup",
")",
"error",
"{",
"if",
"proxyWaitGroup",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"err",
":=",
"proxyWaitGroup",
".",
"Context",
"(",
")",
".",
"Err",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"start",
":=",
"time",
".",
"Now",
"(",
")",
"\n\n",
"e",
".",
"getLogger",
"(",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"err",
"=",
"proxyWaitGroup",
".",
"Wait",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"e",
".",
"getLogger",
"(",
")",
".",
"Debug",
"(",
"\"",
"\"",
",",
"time",
".",
"Since",
"(",
"start",
")",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // WaitForProxyCompletions blocks until all proxy changes have been completed.
// Called with BuildMutex held. | [
"WaitForProxyCompletions",
"blocks",
"until",
"all",
"proxy",
"changes",
"have",
"been",
"completed",
".",
"Called",
"with",
"BuildMutex",
"held",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L392-L412 |
163,115 | cilium/cilium | pkg/endpoint/endpoint.go | NewEndpointWithState | func NewEndpointWithState(ID uint16, state string) *Endpoint {
ep := &Endpoint{
ID: ID,
OpLabels: pkgLabels.NewOpLabels(),
Status: NewEndpointStatus(),
DNSHistory: fqdn.NewDNSCacheWithLimit(option.Config.ToFQDNsMinTTL, option.Config.ToFQDNsMaxIPsPerHost),
state: state,
hasBPFProgram: make(chan struct{}, 0),
controllers: controller.NewManager(),
EventQueue: eventqueue.NewEventQueueBuffered(fmt.Sprintf("endpoint-%d", ID), option.Config.EndpointQueueSize),
desiredPolicy: policy.NewEndpointPolicy(),
realizedPolicy: policy.NewEndpointPolicy(),
}
ep.SetDefaultOpts(option.Config.Opts)
ep.UpdateLogger(nil)
ep.EventQueue.Run()
return ep
} | go | func NewEndpointWithState(ID uint16, state string) *Endpoint {
ep := &Endpoint{
ID: ID,
OpLabels: pkgLabels.NewOpLabels(),
Status: NewEndpointStatus(),
DNSHistory: fqdn.NewDNSCacheWithLimit(option.Config.ToFQDNsMinTTL, option.Config.ToFQDNsMaxIPsPerHost),
state: state,
hasBPFProgram: make(chan struct{}, 0),
controllers: controller.NewManager(),
EventQueue: eventqueue.NewEventQueueBuffered(fmt.Sprintf("endpoint-%d", ID), option.Config.EndpointQueueSize),
desiredPolicy: policy.NewEndpointPolicy(),
realizedPolicy: policy.NewEndpointPolicy(),
}
ep.SetDefaultOpts(option.Config.Opts)
ep.UpdateLogger(nil)
ep.EventQueue.Run()
return ep
} | [
"func",
"NewEndpointWithState",
"(",
"ID",
"uint16",
",",
"state",
"string",
")",
"*",
"Endpoint",
"{",
"ep",
":=",
"&",
"Endpoint",
"{",
"ID",
":",
"ID",
",",
"OpLabels",
":",
"pkgLabels",
".",
"NewOpLabels",
"(",
")",
",",
"Status",
":",
"NewEndpointStatus",
"(",
")",
",",
"DNSHistory",
":",
"fqdn",
".",
"NewDNSCacheWithLimit",
"(",
"option",
".",
"Config",
".",
"ToFQDNsMinTTL",
",",
"option",
".",
"Config",
".",
"ToFQDNsMaxIPsPerHost",
")",
",",
"state",
":",
"state",
",",
"hasBPFProgram",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
",",
"0",
")",
",",
"controllers",
":",
"controller",
".",
"NewManager",
"(",
")",
",",
"EventQueue",
":",
"eventqueue",
".",
"NewEventQueueBuffered",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ID",
")",
",",
"option",
".",
"Config",
".",
"EndpointQueueSize",
")",
",",
"desiredPolicy",
":",
"policy",
".",
"NewEndpointPolicy",
"(",
")",
",",
"realizedPolicy",
":",
"policy",
".",
"NewEndpointPolicy",
"(",
")",
",",
"}",
"\n",
"ep",
".",
"SetDefaultOpts",
"(",
"option",
".",
"Config",
".",
"Opts",
")",
"\n",
"ep",
".",
"UpdateLogger",
"(",
"nil",
")",
"\n\n",
"ep",
".",
"EventQueue",
".",
"Run",
"(",
")",
"\n\n",
"return",
"ep",
"\n",
"}"
] | // NewEndpointWithState creates a new endpoint useful for testing purposes | [
"NewEndpointWithState",
"creates",
"a",
"new",
"endpoint",
"useful",
"for",
"testing",
"purposes"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L415-L434 |
163,116 | cilium/cilium | pkg/endpoint/endpoint.go | NewEndpointFromChangeModel | func NewEndpointFromChangeModel(base *models.EndpointChangeRequest) (*Endpoint, error) {
if base == nil {
return nil, nil
}
ep := &Endpoint{
ID: uint16(base.ID),
ContainerName: base.ContainerName,
ContainerID: base.ContainerID,
DockerNetworkID: base.DockerNetworkID,
DockerEndpointID: base.DockerEndpointID,
IfName: base.InterfaceName,
K8sPodName: base.K8sPodName,
K8sNamespace: base.K8sNamespace,
DatapathMapID: int(base.DatapathMapID),
IfIndex: int(base.InterfaceIndex),
OpLabels: pkgLabels.NewOpLabels(),
DNSHistory: fqdn.NewDNSCacheWithLimit(option.Config.ToFQDNsMinTTL, option.Config.ToFQDNsMaxIPsPerHost),
state: "",
Status: NewEndpointStatus(),
hasBPFProgram: make(chan struct{}, 0),
desiredPolicy: policy.NewEndpointPolicy(),
realizedPolicy: policy.NewEndpointPolicy(),
controllers: controller.NewManager(),
}
if base.Mac != "" {
m, err := mac.ParseMAC(base.Mac)
if err != nil {
return nil, err
}
ep.LXCMAC = m
}
if base.HostMac != "" {
m, err := mac.ParseMAC(base.HostMac)
if err != nil {
return nil, err
}
ep.NodeMAC = m
}
if base.Addressing != nil {
if ip := base.Addressing.IPV6; ip != "" {
ip6, err := addressing.NewCiliumIPv6(ip)
if err != nil {
return nil, err
}
ep.IPv6 = ip6
}
if ip := base.Addressing.IPV4; ip != "" {
ip4, err := addressing.NewCiliumIPv4(ip)
if err != nil {
return nil, err
}
ep.IPv4 = ip4
}
}
ep.SetDefaultOpts(option.Config.Opts)
ep.UpdateLogger(nil)
ep.SetStateLocked(string(base.State), "Endpoint creation")
return ep, nil
} | go | func NewEndpointFromChangeModel(base *models.EndpointChangeRequest) (*Endpoint, error) {
if base == nil {
return nil, nil
}
ep := &Endpoint{
ID: uint16(base.ID),
ContainerName: base.ContainerName,
ContainerID: base.ContainerID,
DockerNetworkID: base.DockerNetworkID,
DockerEndpointID: base.DockerEndpointID,
IfName: base.InterfaceName,
K8sPodName: base.K8sPodName,
K8sNamespace: base.K8sNamespace,
DatapathMapID: int(base.DatapathMapID),
IfIndex: int(base.InterfaceIndex),
OpLabels: pkgLabels.NewOpLabels(),
DNSHistory: fqdn.NewDNSCacheWithLimit(option.Config.ToFQDNsMinTTL, option.Config.ToFQDNsMaxIPsPerHost),
state: "",
Status: NewEndpointStatus(),
hasBPFProgram: make(chan struct{}, 0),
desiredPolicy: policy.NewEndpointPolicy(),
realizedPolicy: policy.NewEndpointPolicy(),
controllers: controller.NewManager(),
}
if base.Mac != "" {
m, err := mac.ParseMAC(base.Mac)
if err != nil {
return nil, err
}
ep.LXCMAC = m
}
if base.HostMac != "" {
m, err := mac.ParseMAC(base.HostMac)
if err != nil {
return nil, err
}
ep.NodeMAC = m
}
if base.Addressing != nil {
if ip := base.Addressing.IPV6; ip != "" {
ip6, err := addressing.NewCiliumIPv6(ip)
if err != nil {
return nil, err
}
ep.IPv6 = ip6
}
if ip := base.Addressing.IPV4; ip != "" {
ip4, err := addressing.NewCiliumIPv4(ip)
if err != nil {
return nil, err
}
ep.IPv4 = ip4
}
}
ep.SetDefaultOpts(option.Config.Opts)
ep.UpdateLogger(nil)
ep.SetStateLocked(string(base.State), "Endpoint creation")
return ep, nil
} | [
"func",
"NewEndpointFromChangeModel",
"(",
"base",
"*",
"models",
".",
"EndpointChangeRequest",
")",
"(",
"*",
"Endpoint",
",",
"error",
")",
"{",
"if",
"base",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"ep",
":=",
"&",
"Endpoint",
"{",
"ID",
":",
"uint16",
"(",
"base",
".",
"ID",
")",
",",
"ContainerName",
":",
"base",
".",
"ContainerName",
",",
"ContainerID",
":",
"base",
".",
"ContainerID",
",",
"DockerNetworkID",
":",
"base",
".",
"DockerNetworkID",
",",
"DockerEndpointID",
":",
"base",
".",
"DockerEndpointID",
",",
"IfName",
":",
"base",
".",
"InterfaceName",
",",
"K8sPodName",
":",
"base",
".",
"K8sPodName",
",",
"K8sNamespace",
":",
"base",
".",
"K8sNamespace",
",",
"DatapathMapID",
":",
"int",
"(",
"base",
".",
"DatapathMapID",
")",
",",
"IfIndex",
":",
"int",
"(",
"base",
".",
"InterfaceIndex",
")",
",",
"OpLabels",
":",
"pkgLabels",
".",
"NewOpLabels",
"(",
")",
",",
"DNSHistory",
":",
"fqdn",
".",
"NewDNSCacheWithLimit",
"(",
"option",
".",
"Config",
".",
"ToFQDNsMinTTL",
",",
"option",
".",
"Config",
".",
"ToFQDNsMaxIPsPerHost",
")",
",",
"state",
":",
"\"",
"\"",
",",
"Status",
":",
"NewEndpointStatus",
"(",
")",
",",
"hasBPFProgram",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
",",
"0",
")",
",",
"desiredPolicy",
":",
"policy",
".",
"NewEndpointPolicy",
"(",
")",
",",
"realizedPolicy",
":",
"policy",
".",
"NewEndpointPolicy",
"(",
")",
",",
"controllers",
":",
"controller",
".",
"NewManager",
"(",
")",
",",
"}",
"\n\n",
"if",
"base",
".",
"Mac",
"!=",
"\"",
"\"",
"{",
"m",
",",
"err",
":=",
"mac",
".",
"ParseMAC",
"(",
"base",
".",
"Mac",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"ep",
".",
"LXCMAC",
"=",
"m",
"\n",
"}",
"\n\n",
"if",
"base",
".",
"HostMac",
"!=",
"\"",
"\"",
"{",
"m",
",",
"err",
":=",
"mac",
".",
"ParseMAC",
"(",
"base",
".",
"HostMac",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"ep",
".",
"NodeMAC",
"=",
"m",
"\n",
"}",
"\n\n",
"if",
"base",
".",
"Addressing",
"!=",
"nil",
"{",
"if",
"ip",
":=",
"base",
".",
"Addressing",
".",
"IPV6",
";",
"ip",
"!=",
"\"",
"\"",
"{",
"ip6",
",",
"err",
":=",
"addressing",
".",
"NewCiliumIPv6",
"(",
"ip",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"ep",
".",
"IPv6",
"=",
"ip6",
"\n",
"}",
"\n\n",
"if",
"ip",
":=",
"base",
".",
"Addressing",
".",
"IPV4",
";",
"ip",
"!=",
"\"",
"\"",
"{",
"ip4",
",",
"err",
":=",
"addressing",
".",
"NewCiliumIPv4",
"(",
"ip",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"ep",
".",
"IPv4",
"=",
"ip4",
"\n",
"}",
"\n",
"}",
"\n\n",
"ep",
".",
"SetDefaultOpts",
"(",
"option",
".",
"Config",
".",
"Opts",
")",
"\n\n",
"ep",
".",
"UpdateLogger",
"(",
"nil",
")",
"\n",
"ep",
".",
"SetStateLocked",
"(",
"string",
"(",
"base",
".",
"State",
")",
",",
"\"",
"\"",
")",
"\n\n",
"return",
"ep",
",",
"nil",
"\n",
"}"
] | // NewEndpointFromChangeModel creates a new endpoint from a request | [
"NewEndpointFromChangeModel",
"creates",
"a",
"new",
"endpoint",
"from",
"a",
"request"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L437-L503 |
163,117 | cilium/cilium | pkg/endpoint/endpoint.go | GetModelRLocked | func (e *Endpoint) GetModelRLocked() *models.Endpoint {
if e == nil {
return nil
}
currentState := models.EndpointState(e.state)
if currentState == models.EndpointStateReady && e.Status.CurrentStatus() != OK {
currentState = models.EndpointStateNotReady
}
// This returns the most recent log entry for this endpoint. It is backwards
// compatible with the json from before we added `cilium endpoint log` but it
// only returns 1 entry.
statusLog := e.Status.GetModel()
if len(statusLog) > 0 {
statusLog = statusLog[:1]
}
lblMdl := model.NewModel(&e.OpLabels)
// Sort these slices since they come out in random orders. This allows
// reflect.DeepEqual to succeed.
sort.StringSlice(lblMdl.Realized.User).Sort()
sort.StringSlice(lblMdl.Disabled).Sort()
sort.StringSlice(lblMdl.SecurityRelevant).Sort()
sort.StringSlice(lblMdl.Derived).Sort()
controllerMdl := e.controllers.GetStatusModel()
sort.Slice(controllerMdl, func(i, j int) bool { return controllerMdl[i].Name < controllerMdl[j].Name })
spec := &models.EndpointConfigurationSpec{
LabelConfiguration: lblMdl.Realized,
}
if e.Options != nil {
spec.Options = *e.Options.GetMutableModel()
}
mdl := &models.Endpoint{
ID: int64(e.ID),
Spec: spec,
Status: &models.EndpointStatus{
// FIXME GH-3280 When we begin implementing revision numbers this will
// diverge from models.Endpoint.Spec to reflect the in-datapath config
Realized: spec,
Identity: e.SecurityIdentity.GetModel(),
Labels: lblMdl,
Networking: &models.EndpointNetworking{
Addressing: []*models.AddressPair{{
IPV4: e.IPv4.String(),
IPV6: e.IPv6.String(),
}},
InterfaceIndex: int64(e.IfIndex),
InterfaceName: e.IfName,
Mac: e.LXCMAC.String(),
HostMac: e.NodeMAC.String(),
},
ExternalIdentifiers: &models.EndpointIdentifiers{
ContainerID: e.ContainerID,
ContainerName: e.ContainerName,
DockerEndpointID: e.DockerEndpointID,
DockerNetworkID: e.DockerNetworkID,
PodName: e.GetK8sNamespaceAndPodNameLocked(),
},
// FIXME GH-3280 When we begin returning endpoint revisions this should
// change to return the configured and in-datapath policies.
Policy: e.GetPolicyModel(),
Log: statusLog,
Controllers: controllerMdl,
State: currentState, // TODO: Validate
Health: e.getHealthModel(),
},
}
return mdl
} | go | func (e *Endpoint) GetModelRLocked() *models.Endpoint {
if e == nil {
return nil
}
currentState := models.EndpointState(e.state)
if currentState == models.EndpointStateReady && e.Status.CurrentStatus() != OK {
currentState = models.EndpointStateNotReady
}
// This returns the most recent log entry for this endpoint. It is backwards
// compatible with the json from before we added `cilium endpoint log` but it
// only returns 1 entry.
statusLog := e.Status.GetModel()
if len(statusLog) > 0 {
statusLog = statusLog[:1]
}
lblMdl := model.NewModel(&e.OpLabels)
// Sort these slices since they come out in random orders. This allows
// reflect.DeepEqual to succeed.
sort.StringSlice(lblMdl.Realized.User).Sort()
sort.StringSlice(lblMdl.Disabled).Sort()
sort.StringSlice(lblMdl.SecurityRelevant).Sort()
sort.StringSlice(lblMdl.Derived).Sort()
controllerMdl := e.controllers.GetStatusModel()
sort.Slice(controllerMdl, func(i, j int) bool { return controllerMdl[i].Name < controllerMdl[j].Name })
spec := &models.EndpointConfigurationSpec{
LabelConfiguration: lblMdl.Realized,
}
if e.Options != nil {
spec.Options = *e.Options.GetMutableModel()
}
mdl := &models.Endpoint{
ID: int64(e.ID),
Spec: spec,
Status: &models.EndpointStatus{
// FIXME GH-3280 When we begin implementing revision numbers this will
// diverge from models.Endpoint.Spec to reflect the in-datapath config
Realized: spec,
Identity: e.SecurityIdentity.GetModel(),
Labels: lblMdl,
Networking: &models.EndpointNetworking{
Addressing: []*models.AddressPair{{
IPV4: e.IPv4.String(),
IPV6: e.IPv6.String(),
}},
InterfaceIndex: int64(e.IfIndex),
InterfaceName: e.IfName,
Mac: e.LXCMAC.String(),
HostMac: e.NodeMAC.String(),
},
ExternalIdentifiers: &models.EndpointIdentifiers{
ContainerID: e.ContainerID,
ContainerName: e.ContainerName,
DockerEndpointID: e.DockerEndpointID,
DockerNetworkID: e.DockerNetworkID,
PodName: e.GetK8sNamespaceAndPodNameLocked(),
},
// FIXME GH-3280 When we begin returning endpoint revisions this should
// change to return the configured and in-datapath policies.
Policy: e.GetPolicyModel(),
Log: statusLog,
Controllers: controllerMdl,
State: currentState, // TODO: Validate
Health: e.getHealthModel(),
},
}
return mdl
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"GetModelRLocked",
"(",
")",
"*",
"models",
".",
"Endpoint",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"currentState",
":=",
"models",
".",
"EndpointState",
"(",
"e",
".",
"state",
")",
"\n",
"if",
"currentState",
"==",
"models",
".",
"EndpointStateReady",
"&&",
"e",
".",
"Status",
".",
"CurrentStatus",
"(",
")",
"!=",
"OK",
"{",
"currentState",
"=",
"models",
".",
"EndpointStateNotReady",
"\n",
"}",
"\n\n",
"// This returns the most recent log entry for this endpoint. It is backwards",
"// compatible with the json from before we added `cilium endpoint log` but it",
"// only returns 1 entry.",
"statusLog",
":=",
"e",
".",
"Status",
".",
"GetModel",
"(",
")",
"\n",
"if",
"len",
"(",
"statusLog",
")",
">",
"0",
"{",
"statusLog",
"=",
"statusLog",
"[",
":",
"1",
"]",
"\n",
"}",
"\n\n",
"lblMdl",
":=",
"model",
".",
"NewModel",
"(",
"&",
"e",
".",
"OpLabels",
")",
"\n\n",
"// Sort these slices since they come out in random orders. This allows",
"// reflect.DeepEqual to succeed.",
"sort",
".",
"StringSlice",
"(",
"lblMdl",
".",
"Realized",
".",
"User",
")",
".",
"Sort",
"(",
")",
"\n",
"sort",
".",
"StringSlice",
"(",
"lblMdl",
".",
"Disabled",
")",
".",
"Sort",
"(",
")",
"\n",
"sort",
".",
"StringSlice",
"(",
"lblMdl",
".",
"SecurityRelevant",
")",
".",
"Sort",
"(",
")",
"\n",
"sort",
".",
"StringSlice",
"(",
"lblMdl",
".",
"Derived",
")",
".",
"Sort",
"(",
")",
"\n\n",
"controllerMdl",
":=",
"e",
".",
"controllers",
".",
"GetStatusModel",
"(",
")",
"\n",
"sort",
".",
"Slice",
"(",
"controllerMdl",
",",
"func",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"controllerMdl",
"[",
"i",
"]",
".",
"Name",
"<",
"controllerMdl",
"[",
"j",
"]",
".",
"Name",
"}",
")",
"\n\n",
"spec",
":=",
"&",
"models",
".",
"EndpointConfigurationSpec",
"{",
"LabelConfiguration",
":",
"lblMdl",
".",
"Realized",
",",
"}",
"\n\n",
"if",
"e",
".",
"Options",
"!=",
"nil",
"{",
"spec",
".",
"Options",
"=",
"*",
"e",
".",
"Options",
".",
"GetMutableModel",
"(",
")",
"\n",
"}",
"\n\n",
"mdl",
":=",
"&",
"models",
".",
"Endpoint",
"{",
"ID",
":",
"int64",
"(",
"e",
".",
"ID",
")",
",",
"Spec",
":",
"spec",
",",
"Status",
":",
"&",
"models",
".",
"EndpointStatus",
"{",
"// FIXME GH-3280 When we begin implementing revision numbers this will",
"// diverge from models.Endpoint.Spec to reflect the in-datapath config",
"Realized",
":",
"spec",
",",
"Identity",
":",
"e",
".",
"SecurityIdentity",
".",
"GetModel",
"(",
")",
",",
"Labels",
":",
"lblMdl",
",",
"Networking",
":",
"&",
"models",
".",
"EndpointNetworking",
"{",
"Addressing",
":",
"[",
"]",
"*",
"models",
".",
"AddressPair",
"{",
"{",
"IPV4",
":",
"e",
".",
"IPv4",
".",
"String",
"(",
")",
",",
"IPV6",
":",
"e",
".",
"IPv6",
".",
"String",
"(",
")",
",",
"}",
"}",
",",
"InterfaceIndex",
":",
"int64",
"(",
"e",
".",
"IfIndex",
")",
",",
"InterfaceName",
":",
"e",
".",
"IfName",
",",
"Mac",
":",
"e",
".",
"LXCMAC",
".",
"String",
"(",
")",
",",
"HostMac",
":",
"e",
".",
"NodeMAC",
".",
"String",
"(",
")",
",",
"}",
",",
"ExternalIdentifiers",
":",
"&",
"models",
".",
"EndpointIdentifiers",
"{",
"ContainerID",
":",
"e",
".",
"ContainerID",
",",
"ContainerName",
":",
"e",
".",
"ContainerName",
",",
"DockerEndpointID",
":",
"e",
".",
"DockerEndpointID",
",",
"DockerNetworkID",
":",
"e",
".",
"DockerNetworkID",
",",
"PodName",
":",
"e",
".",
"GetK8sNamespaceAndPodNameLocked",
"(",
")",
",",
"}",
",",
"// FIXME GH-3280 When we begin returning endpoint revisions this should",
"// change to return the configured and in-datapath policies.",
"Policy",
":",
"e",
".",
"GetPolicyModel",
"(",
")",
",",
"Log",
":",
"statusLog",
",",
"Controllers",
":",
"controllerMdl",
",",
"State",
":",
"currentState",
",",
"// TODO: Validate",
"Health",
":",
"e",
".",
"getHealthModel",
"(",
")",
",",
"}",
",",
"}",
"\n\n",
"return",
"mdl",
"\n",
"}"
] | // GetModelRLocked returns the API model of endpoint e.
// e.mutex must be RLocked. | [
"GetModelRLocked",
"returns",
"the",
"API",
"model",
"of",
"endpoint",
"e",
".",
"e",
".",
"mutex",
"must",
"be",
"RLocked",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L507-L582 |
163,118 | cilium/cilium | pkg/endpoint/endpoint.go | getHealthModel | func (e *Endpoint) getHealthModel() *models.EndpointHealth {
// Duplicated from GetModelRLocked.
currentState := models.EndpointState(e.state)
if currentState == models.EndpointStateReady && e.Status.CurrentStatus() != OK {
currentState = models.EndpointStateNotReady
}
h := models.EndpointHealth{
Bpf: models.EndpointHealthStatusDisabled,
Policy: models.EndpointHealthStatusDisabled,
Connected: false,
OverallHealth: models.EndpointHealthStatusDisabled,
}
switch currentState {
case models.EndpointStateRegenerating, models.EndpointStateWaitingToRegenerate, models.EndpointStateDisconnecting:
h = models.EndpointHealth{
Bpf: models.EndpointHealthStatusPending,
Policy: models.EndpointHealthStatusPending,
Connected: true,
OverallHealth: models.EndpointHealthStatusPending,
}
case models.EndpointStateCreating:
h = models.EndpointHealth{
Bpf: models.EndpointHealthStatusBootstrap,
Policy: models.EndpointHealthStatusDisabled,
Connected: true,
OverallHealth: models.EndpointHealthStatusDisabled,
}
case models.EndpointStateWaitingForIdentity:
h = models.EndpointHealth{
Bpf: models.EndpointHealthStatusDisabled,
Policy: models.EndpointHealthStatusBootstrap,
Connected: true,
OverallHealth: models.EndpointHealthStatusDisabled,
}
case models.EndpointStateNotReady:
h = models.EndpointHealth{
Bpf: models.EndpointHealthStatusWarning,
Policy: models.EndpointHealthStatusWarning,
Connected: true,
OverallHealth: models.EndpointHealthStatusWarning,
}
case models.EndpointStateDisconnected:
h = models.EndpointHealth{
Bpf: models.EndpointHealthStatusDisabled,
Policy: models.EndpointHealthStatusDisabled,
Connected: false,
OverallHealth: models.EndpointHealthStatusDisabled,
}
case models.EndpointStateReady:
h = models.EndpointHealth{
Bpf: models.EndpointHealthStatusOK,
Policy: models.EndpointHealthStatusOK,
Connected: true,
OverallHealth: models.EndpointHealthStatusOK,
}
}
return &h
} | go | func (e *Endpoint) getHealthModel() *models.EndpointHealth {
// Duplicated from GetModelRLocked.
currentState := models.EndpointState(e.state)
if currentState == models.EndpointStateReady && e.Status.CurrentStatus() != OK {
currentState = models.EndpointStateNotReady
}
h := models.EndpointHealth{
Bpf: models.EndpointHealthStatusDisabled,
Policy: models.EndpointHealthStatusDisabled,
Connected: false,
OverallHealth: models.EndpointHealthStatusDisabled,
}
switch currentState {
case models.EndpointStateRegenerating, models.EndpointStateWaitingToRegenerate, models.EndpointStateDisconnecting:
h = models.EndpointHealth{
Bpf: models.EndpointHealthStatusPending,
Policy: models.EndpointHealthStatusPending,
Connected: true,
OverallHealth: models.EndpointHealthStatusPending,
}
case models.EndpointStateCreating:
h = models.EndpointHealth{
Bpf: models.EndpointHealthStatusBootstrap,
Policy: models.EndpointHealthStatusDisabled,
Connected: true,
OverallHealth: models.EndpointHealthStatusDisabled,
}
case models.EndpointStateWaitingForIdentity:
h = models.EndpointHealth{
Bpf: models.EndpointHealthStatusDisabled,
Policy: models.EndpointHealthStatusBootstrap,
Connected: true,
OverallHealth: models.EndpointHealthStatusDisabled,
}
case models.EndpointStateNotReady:
h = models.EndpointHealth{
Bpf: models.EndpointHealthStatusWarning,
Policy: models.EndpointHealthStatusWarning,
Connected: true,
OverallHealth: models.EndpointHealthStatusWarning,
}
case models.EndpointStateDisconnected:
h = models.EndpointHealth{
Bpf: models.EndpointHealthStatusDisabled,
Policy: models.EndpointHealthStatusDisabled,
Connected: false,
OverallHealth: models.EndpointHealthStatusDisabled,
}
case models.EndpointStateReady:
h = models.EndpointHealth{
Bpf: models.EndpointHealthStatusOK,
Policy: models.EndpointHealthStatusOK,
Connected: true,
OverallHealth: models.EndpointHealthStatusOK,
}
}
return &h
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"getHealthModel",
"(",
")",
"*",
"models",
".",
"EndpointHealth",
"{",
"// Duplicated from GetModelRLocked.",
"currentState",
":=",
"models",
".",
"EndpointState",
"(",
"e",
".",
"state",
")",
"\n",
"if",
"currentState",
"==",
"models",
".",
"EndpointStateReady",
"&&",
"e",
".",
"Status",
".",
"CurrentStatus",
"(",
")",
"!=",
"OK",
"{",
"currentState",
"=",
"models",
".",
"EndpointStateNotReady",
"\n",
"}",
"\n\n",
"h",
":=",
"models",
".",
"EndpointHealth",
"{",
"Bpf",
":",
"models",
".",
"EndpointHealthStatusDisabled",
",",
"Policy",
":",
"models",
".",
"EndpointHealthStatusDisabled",
",",
"Connected",
":",
"false",
",",
"OverallHealth",
":",
"models",
".",
"EndpointHealthStatusDisabled",
",",
"}",
"\n",
"switch",
"currentState",
"{",
"case",
"models",
".",
"EndpointStateRegenerating",
",",
"models",
".",
"EndpointStateWaitingToRegenerate",
",",
"models",
".",
"EndpointStateDisconnecting",
":",
"h",
"=",
"models",
".",
"EndpointHealth",
"{",
"Bpf",
":",
"models",
".",
"EndpointHealthStatusPending",
",",
"Policy",
":",
"models",
".",
"EndpointHealthStatusPending",
",",
"Connected",
":",
"true",
",",
"OverallHealth",
":",
"models",
".",
"EndpointHealthStatusPending",
",",
"}",
"\n",
"case",
"models",
".",
"EndpointStateCreating",
":",
"h",
"=",
"models",
".",
"EndpointHealth",
"{",
"Bpf",
":",
"models",
".",
"EndpointHealthStatusBootstrap",
",",
"Policy",
":",
"models",
".",
"EndpointHealthStatusDisabled",
",",
"Connected",
":",
"true",
",",
"OverallHealth",
":",
"models",
".",
"EndpointHealthStatusDisabled",
",",
"}",
"\n",
"case",
"models",
".",
"EndpointStateWaitingForIdentity",
":",
"h",
"=",
"models",
".",
"EndpointHealth",
"{",
"Bpf",
":",
"models",
".",
"EndpointHealthStatusDisabled",
",",
"Policy",
":",
"models",
".",
"EndpointHealthStatusBootstrap",
",",
"Connected",
":",
"true",
",",
"OverallHealth",
":",
"models",
".",
"EndpointHealthStatusDisabled",
",",
"}",
"\n",
"case",
"models",
".",
"EndpointStateNotReady",
":",
"h",
"=",
"models",
".",
"EndpointHealth",
"{",
"Bpf",
":",
"models",
".",
"EndpointHealthStatusWarning",
",",
"Policy",
":",
"models",
".",
"EndpointHealthStatusWarning",
",",
"Connected",
":",
"true",
",",
"OverallHealth",
":",
"models",
".",
"EndpointHealthStatusWarning",
",",
"}",
"\n",
"case",
"models",
".",
"EndpointStateDisconnected",
":",
"h",
"=",
"models",
".",
"EndpointHealth",
"{",
"Bpf",
":",
"models",
".",
"EndpointHealthStatusDisabled",
",",
"Policy",
":",
"models",
".",
"EndpointHealthStatusDisabled",
",",
"Connected",
":",
"false",
",",
"OverallHealth",
":",
"models",
".",
"EndpointHealthStatusDisabled",
",",
"}",
"\n",
"case",
"models",
".",
"EndpointStateReady",
":",
"h",
"=",
"models",
".",
"EndpointHealth",
"{",
"Bpf",
":",
"models",
".",
"EndpointHealthStatusOK",
",",
"Policy",
":",
"models",
".",
"EndpointHealthStatusOK",
",",
"Connected",
":",
"true",
",",
"OverallHealth",
":",
"models",
".",
"EndpointHealthStatusOK",
",",
"}",
"\n",
"}",
"\n\n",
"return",
"&",
"h",
"\n",
"}"
] | // GetHealthModel returns the endpoint's health object.
//
// Must be called with e.Mutex locked. | [
"GetHealthModel",
"returns",
"the",
"endpoint",
"s",
"health",
"object",
".",
"Must",
"be",
"called",
"with",
"e",
".",
"Mutex",
"locked",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L587-L646 |
163,119 | cilium/cilium | pkg/endpoint/endpoint.go | GetHealthModel | func (e *Endpoint) GetHealthModel() *models.EndpointHealth {
// NOTE: Using rlock on mutex directly because getHealthModel handles removed endpoint properly
e.mutex.RLock()
defer e.mutex.RUnlock()
return e.getHealthModel()
} | go | func (e *Endpoint) GetHealthModel() *models.EndpointHealth {
// NOTE: Using rlock on mutex directly because getHealthModel handles removed endpoint properly
e.mutex.RLock()
defer e.mutex.RUnlock()
return e.getHealthModel()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"GetHealthModel",
"(",
")",
"*",
"models",
".",
"EndpointHealth",
"{",
"// NOTE: Using rlock on mutex directly because getHealthModel handles removed endpoint properly",
"e",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"e",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"e",
".",
"getHealthModel",
"(",
")",
"\n",
"}"
] | // GetHealthModel returns the endpoint's health object. | [
"GetHealthModel",
"returns",
"the",
"endpoint",
"s",
"health",
"object",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L649-L654 |
163,120 | cilium/cilium | pkg/endpoint/endpoint.go | GetModel | func (e *Endpoint) GetModel() *models.Endpoint {
if e == nil {
return nil
}
// NOTE: Using rlock on mutex directly because GetModelRLocked handles removed endpoint properly
e.mutex.RLock()
defer e.mutex.RUnlock()
return e.GetModelRLocked()
} | go | func (e *Endpoint) GetModel() *models.Endpoint {
if e == nil {
return nil
}
// NOTE: Using rlock on mutex directly because GetModelRLocked handles removed endpoint properly
e.mutex.RLock()
defer e.mutex.RUnlock()
return e.GetModelRLocked()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"GetModel",
"(",
")",
"*",
"models",
".",
"Endpoint",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"// NOTE: Using rlock on mutex directly because GetModelRLocked handles removed endpoint properly",
"e",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"e",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"e",
".",
"GetModelRLocked",
"(",
")",
"\n",
"}"
] | // GetModel returns the API model of endpoint e. | [
"GetModel",
"returns",
"the",
"API",
"model",
"of",
"endpoint",
"e",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L657-L666 |
163,121 | cilium/cilium | pkg/endpoint/endpoint.go | policyStatus | func (e *Endpoint) policyStatus() models.EndpointPolicyEnabled {
policyEnabled := models.EndpointPolicyEnabledNone
switch {
case e.realizedPolicy.IngressPolicyEnabled && e.realizedPolicy.EgressPolicyEnabled:
policyEnabled = models.EndpointPolicyEnabledBoth
case e.realizedPolicy.IngressPolicyEnabled:
policyEnabled = models.EndpointPolicyEnabledIngress
case e.realizedPolicy.EgressPolicyEnabled:
policyEnabled = models.EndpointPolicyEnabledEgress
}
return policyEnabled
} | go | func (e *Endpoint) policyStatus() models.EndpointPolicyEnabled {
policyEnabled := models.EndpointPolicyEnabledNone
switch {
case e.realizedPolicy.IngressPolicyEnabled && e.realizedPolicy.EgressPolicyEnabled:
policyEnabled = models.EndpointPolicyEnabledBoth
case e.realizedPolicy.IngressPolicyEnabled:
policyEnabled = models.EndpointPolicyEnabledIngress
case e.realizedPolicy.EgressPolicyEnabled:
policyEnabled = models.EndpointPolicyEnabledEgress
}
return policyEnabled
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"policyStatus",
"(",
")",
"models",
".",
"EndpointPolicyEnabled",
"{",
"policyEnabled",
":=",
"models",
".",
"EndpointPolicyEnabledNone",
"\n",
"switch",
"{",
"case",
"e",
".",
"realizedPolicy",
".",
"IngressPolicyEnabled",
"&&",
"e",
".",
"realizedPolicy",
".",
"EgressPolicyEnabled",
":",
"policyEnabled",
"=",
"models",
".",
"EndpointPolicyEnabledBoth",
"\n",
"case",
"e",
".",
"realizedPolicy",
".",
"IngressPolicyEnabled",
":",
"policyEnabled",
"=",
"models",
".",
"EndpointPolicyEnabledIngress",
"\n",
"case",
"e",
".",
"realizedPolicy",
".",
"EgressPolicyEnabled",
":",
"policyEnabled",
"=",
"models",
".",
"EndpointPolicyEnabledEgress",
"\n",
"}",
"\n",
"return",
"policyEnabled",
"\n",
"}"
] | // policyStatus returns the endpoint's policy status
//
// Must be called with e.Mutex locked. | [
"policyStatus",
"returns",
"the",
"endpoint",
"s",
"policy",
"status",
"Must",
"be",
"called",
"with",
"e",
".",
"Mutex",
"locked",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L791-L802 |
163,122 | cilium/cilium | pkg/endpoint/endpoint.go | GetLabels | func (e *Endpoint) GetLabels() []string {
if e.SecurityIdentity == nil {
return []string{}
}
return e.SecurityIdentity.Labels.GetModel()
} | go | func (e *Endpoint) GetLabels() []string {
if e.SecurityIdentity == nil {
return []string{}
}
return e.SecurityIdentity.Labels.GetModel()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"GetLabels",
"(",
")",
"[",
"]",
"string",
"{",
"if",
"e",
".",
"SecurityIdentity",
"==",
"nil",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
"\n",
"}",
"\n\n",
"return",
"e",
".",
"SecurityIdentity",
".",
"Labels",
".",
"GetModel",
"(",
")",
"\n",
"}"
] | // GetLabels returns the labels as slice | [
"GetLabels",
"returns",
"the",
"labels",
"as",
"slice"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L810-L816 |
163,123 | cilium/cilium | pkg/endpoint/endpoint.go | GetK8sPodLabels | func (e *Endpoint) GetK8sPodLabels() pkgLabels.Labels {
e.UnconditionalRLock()
defer e.RUnlock()
allLabels := e.OpLabels.AllLabels()
if allLabels == nil {
return nil
}
allLabelsFromK8s := allLabels.GetFromSource(pkgLabels.LabelSourceK8s)
k8sEPPodLabels := pkgLabels.Labels{}
for k, v := range allLabelsFromK8s {
if !strings.HasPrefix(v.Key, ciliumio.PodNamespaceMetaLabels) &&
!strings.HasPrefix(v.Key, ciliumio.PolicyLabelServiceAccount) &&
!strings.HasPrefix(v.Key, ciliumio.PodNamespaceLabel) {
k8sEPPodLabels[k] = v
}
}
return k8sEPPodLabels
} | go | func (e *Endpoint) GetK8sPodLabels() pkgLabels.Labels {
e.UnconditionalRLock()
defer e.RUnlock()
allLabels := e.OpLabels.AllLabels()
if allLabels == nil {
return nil
}
allLabelsFromK8s := allLabels.GetFromSource(pkgLabels.LabelSourceK8s)
k8sEPPodLabels := pkgLabels.Labels{}
for k, v := range allLabelsFromK8s {
if !strings.HasPrefix(v.Key, ciliumio.PodNamespaceMetaLabels) &&
!strings.HasPrefix(v.Key, ciliumio.PolicyLabelServiceAccount) &&
!strings.HasPrefix(v.Key, ciliumio.PodNamespaceLabel) {
k8sEPPodLabels[k] = v
}
}
return k8sEPPodLabels
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"GetK8sPodLabels",
"(",
")",
"pkgLabels",
".",
"Labels",
"{",
"e",
".",
"UnconditionalRLock",
"(",
")",
"\n",
"defer",
"e",
".",
"RUnlock",
"(",
")",
"\n",
"allLabels",
":=",
"e",
".",
"OpLabels",
".",
"AllLabels",
"(",
")",
"\n",
"if",
"allLabels",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"allLabelsFromK8s",
":=",
"allLabels",
".",
"GetFromSource",
"(",
"pkgLabels",
".",
"LabelSourceK8s",
")",
"\n\n",
"k8sEPPodLabels",
":=",
"pkgLabels",
".",
"Labels",
"{",
"}",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"allLabelsFromK8s",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"v",
".",
"Key",
",",
"ciliumio",
".",
"PodNamespaceMetaLabels",
")",
"&&",
"!",
"strings",
".",
"HasPrefix",
"(",
"v",
".",
"Key",
",",
"ciliumio",
".",
"PolicyLabelServiceAccount",
")",
"&&",
"!",
"strings",
".",
"HasPrefix",
"(",
"v",
".",
"Key",
",",
"ciliumio",
".",
"PodNamespaceLabel",
")",
"{",
"k8sEPPodLabels",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"k8sEPPodLabels",
"\n",
"}"
] | // GetK8sPodLabels returns all labels that exist in the endpoint and were
// derived from k8s pod. | [
"GetK8sPodLabels",
"returns",
"all",
"labels",
"that",
"exist",
"in",
"the",
"endpoint",
"and",
"were",
"derived",
"from",
"k8s",
"pod",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L831-L850 |
163,124 | cilium/cilium | pkg/endpoint/endpoint.go | GetLabelsSHA | func (e *Endpoint) GetLabelsSHA() string {
if e.SecurityIdentity == nil {
return ""
}
return e.SecurityIdentity.GetLabelsSHA256()
} | go | func (e *Endpoint) GetLabelsSHA() string {
if e.SecurityIdentity == nil {
return ""
}
return e.SecurityIdentity.GetLabelsSHA256()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"GetLabelsSHA",
"(",
")",
"string",
"{",
"if",
"e",
".",
"SecurityIdentity",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"e",
".",
"SecurityIdentity",
".",
"GetLabelsSHA256",
"(",
")",
"\n",
"}"
] | // GetLabelsSHA returns the SHA of labels | [
"GetLabelsSHA",
"returns",
"the",
"SHA",
"of",
"labels"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L853-L859 |
163,125 | cilium/cilium | pkg/endpoint/endpoint.go | GetOpLabels | func (e *Endpoint) GetOpLabels() []string {
e.UnconditionalRLock()
defer e.RUnlock()
return e.OpLabels.IdentityLabels().GetModel()
} | go | func (e *Endpoint) GetOpLabels() []string {
e.UnconditionalRLock()
defer e.RUnlock()
return e.OpLabels.IdentityLabels().GetModel()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"GetOpLabels",
"(",
")",
"[",
"]",
"string",
"{",
"e",
".",
"UnconditionalRLock",
"(",
")",
"\n",
"defer",
"e",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"e",
".",
"OpLabels",
".",
"IdentityLabels",
"(",
")",
".",
"GetModel",
"(",
")",
"\n",
"}"
] | // GetOpLabels returns the labels as slice | [
"GetOpLabels",
"returns",
"the",
"labels",
"as",
"slice"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L862-L866 |
163,126 | cilium/cilium | pkg/endpoint/endpoint.go | ConntrackName | func (e *Endpoint) ConntrackName() string {
if e.ConntrackLocalLocked() {
return fmt.Sprintf("%05d", int(e.ID))
}
return "global"
} | go | func (e *Endpoint) ConntrackName() string {
if e.ConntrackLocalLocked() {
return fmt.Sprintf("%05d", int(e.ID))
}
return "global"
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"ConntrackName",
"(",
")",
"string",
"{",
"if",
"e",
".",
"ConntrackLocalLocked",
"(",
")",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"int",
"(",
"e",
".",
"ID",
")",
")",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] | // ConntrackName returns the name suffix for the endpoint-specific bpf
// conntrack map, which is a 5-digit endpoint ID, or "global" when the
// global map should be used.
// Must be called with the endpoint locked. | [
"ConntrackName",
"returns",
"the",
"name",
"suffix",
"for",
"the",
"endpoint",
"-",
"specific",
"bpf",
"conntrack",
"map",
"which",
"is",
"a",
"5",
"-",
"digit",
"endpoint",
"ID",
"or",
"global",
"when",
"the",
"global",
"map",
"should",
"be",
"used",
".",
"Must",
"be",
"called",
"with",
"the",
"endpoint",
"locked",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L911-L916 |
163,127 | cilium/cilium | pkg/endpoint/endpoint.go | String | func (e *Endpoint) String() string {
e.UnconditionalRLock()
defer e.RUnlock()
b, err := json.MarshalIndent(e, "", " ")
if err != nil {
return err.Error()
}
return string(b)
} | go | func (e *Endpoint) String() string {
e.UnconditionalRLock()
defer e.RUnlock()
b, err := json.MarshalIndent(e, "", " ")
if err != nil {
return err.Error()
}
return string(b)
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"String",
"(",
")",
"string",
"{",
"e",
".",
"UnconditionalRLock",
"(",
")",
"\n",
"defer",
"e",
".",
"RUnlock",
"(",
")",
"\n",
"b",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"e",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
".",
"Error",
"(",
")",
"\n",
"}",
"\n",
"return",
"string",
"(",
"b",
")",
"\n",
"}"
] | // String returns endpoint on a JSON format. | [
"String",
"returns",
"endpoint",
"on",
"a",
"JSON",
"format",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L945-L953 |
163,128 | cilium/cilium | pkg/endpoint/endpoint.go | applyOptsLocked | func (e *Endpoint) applyOptsLocked(opts option.OptionMap) bool {
changed := e.Options.ApplyValidated(opts, optionChanged, e) > 0
_, exists := opts[option.Debug]
if exists && changed {
e.UpdateLogger(nil)
}
return changed
} | go | func (e *Endpoint) applyOptsLocked(opts option.OptionMap) bool {
changed := e.Options.ApplyValidated(opts, optionChanged, e) > 0
_, exists := opts[option.Debug]
if exists && changed {
e.UpdateLogger(nil)
}
return changed
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"applyOptsLocked",
"(",
"opts",
"option",
".",
"OptionMap",
")",
"bool",
"{",
"changed",
":=",
"e",
".",
"Options",
".",
"ApplyValidated",
"(",
"opts",
",",
"optionChanged",
",",
"e",
")",
">",
"0",
"\n",
"_",
",",
"exists",
":=",
"opts",
"[",
"option",
".",
"Debug",
"]",
"\n",
"if",
"exists",
"&&",
"changed",
"{",
"e",
".",
"UpdateLogger",
"(",
"nil",
")",
"\n",
"}",
"\n",
"return",
"changed",
"\n",
"}"
] | // applyOptsLocked applies the given options to the endpoint's options and
// returns true if there were any options changed. | [
"applyOptsLocked",
"applies",
"the",
"given",
"options",
"to",
"the",
"endpoint",
"s",
"options",
"and",
"returns",
"true",
"if",
"there",
"were",
"any",
"options",
"changed",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L962-L969 |
163,129 | cilium/cilium | pkg/endpoint/endpoint.go | SetDefaultOpts | func (e *Endpoint) SetDefaultOpts(opts *option.IntOptions) {
if e.Options == nil {
e.Options = option.NewIntOptions(&EndpointMutableOptionLibrary)
}
if e.Options.Library == nil {
e.Options.Library = &EndpointMutableOptionLibrary
}
if opts != nil {
epOptLib := option.GetEndpointMutableOptionLibrary()
for k := range epOptLib {
e.Options.SetValidated(k, opts.GetValue(k))
}
}
e.UpdateLogger(nil)
} | go | func (e *Endpoint) SetDefaultOpts(opts *option.IntOptions) {
if e.Options == nil {
e.Options = option.NewIntOptions(&EndpointMutableOptionLibrary)
}
if e.Options.Library == nil {
e.Options.Library = &EndpointMutableOptionLibrary
}
if opts != nil {
epOptLib := option.GetEndpointMutableOptionLibrary()
for k := range epOptLib {
e.Options.SetValidated(k, opts.GetValue(k))
}
}
e.UpdateLogger(nil)
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"SetDefaultOpts",
"(",
"opts",
"*",
"option",
".",
"IntOptions",
")",
"{",
"if",
"e",
".",
"Options",
"==",
"nil",
"{",
"e",
".",
"Options",
"=",
"option",
".",
"NewIntOptions",
"(",
"&",
"EndpointMutableOptionLibrary",
")",
"\n",
"}",
"\n",
"if",
"e",
".",
"Options",
".",
"Library",
"==",
"nil",
"{",
"e",
".",
"Options",
".",
"Library",
"=",
"&",
"EndpointMutableOptionLibrary",
"\n",
"}",
"\n\n",
"if",
"opts",
"!=",
"nil",
"{",
"epOptLib",
":=",
"option",
".",
"GetEndpointMutableOptionLibrary",
"(",
")",
"\n",
"for",
"k",
":=",
"range",
"epOptLib",
"{",
"e",
".",
"Options",
".",
"SetValidated",
"(",
"k",
",",
"opts",
".",
"GetValue",
"(",
"k",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"e",
".",
"UpdateLogger",
"(",
"nil",
")",
"\n",
"}"
] | // SetDefaultOpts initializes the endpoint Options and configures the specified
// options. | [
"SetDefaultOpts",
"initializes",
"the",
"endpoint",
"Options",
"and",
"configures",
"the",
"specified",
"options",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L978-L993 |
163,130 | cilium/cilium | pkg/endpoint/endpoint.go | ConntrackLocalLocked | func (e *Endpoint) ConntrackLocalLocked() bool {
if e.SecurityIdentity == nil || e.Options == nil ||
!e.Options.IsEnabled(option.ConntrackLocal) {
return false
}
return true
} | go | func (e *Endpoint) ConntrackLocalLocked() bool {
if e.SecurityIdentity == nil || e.Options == nil ||
!e.Options.IsEnabled(option.ConntrackLocal) {
return false
}
return true
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"ConntrackLocalLocked",
"(",
")",
"bool",
"{",
"if",
"e",
".",
"SecurityIdentity",
"==",
"nil",
"||",
"e",
".",
"Options",
"==",
"nil",
"||",
"!",
"e",
".",
"Options",
".",
"IsEnabled",
"(",
"option",
".",
"ConntrackLocal",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"return",
"true",
"\n",
"}"
] | // ConntrackLocalLocked is the same as ConntrackLocal, but assumes that the
// endpoint is already locked for reading. | [
"ConntrackLocalLocked",
"is",
"the",
"same",
"as",
"ConntrackLocal",
"but",
"assumes",
"that",
"the",
"endpoint",
"is",
"already",
"locked",
"for",
"reading",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1006-L1013 |
163,131 | cilium/cilium | pkg/endpoint/endpoint.go | base64 | func (e *Endpoint) base64() (string, error) {
var (
jsonBytes []byte
err error
)
transformEndpointForDowngrade(e)
jsonBytes, err = json.Marshal(e)
if err != nil {
return "", err
}
return base64.StdEncoding.EncodeToString(jsonBytes), nil
} | go | func (e *Endpoint) base64() (string, error) {
var (
jsonBytes []byte
err error
)
transformEndpointForDowngrade(e)
jsonBytes, err = json.Marshal(e)
if err != nil {
return "", err
}
return base64.StdEncoding.EncodeToString(jsonBytes), nil
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"base64",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"(",
"jsonBytes",
"[",
"]",
"byte",
"\n",
"err",
"error",
"\n",
")",
"\n\n",
"transformEndpointForDowngrade",
"(",
"e",
")",
"\n",
"jsonBytes",
",",
"err",
"=",
"json",
".",
"Marshal",
"(",
"e",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"base64",
".",
"StdEncoding",
".",
"EncodeToString",
"(",
"jsonBytes",
")",
",",
"nil",
"\n",
"}"
] | // base64 returns the endpoint in a base64 format. | [
"base64",
"returns",
"the",
"endpoint",
"in",
"a",
"base64",
"format",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1016-L1028 |
163,132 | cilium/cilium | pkg/endpoint/endpoint.go | parseBase64ToEndpoint | func parseBase64ToEndpoint(str string, ep *Endpoint) error {
jsonBytes, err := base64.StdEncoding.DecodeString(str)
if err != nil {
return err
}
return json.Unmarshal(jsonBytes, ep)
} | go | func parseBase64ToEndpoint(str string, ep *Endpoint) error {
jsonBytes, err := base64.StdEncoding.DecodeString(str)
if err != nil {
return err
}
return json.Unmarshal(jsonBytes, ep)
} | [
"func",
"parseBase64ToEndpoint",
"(",
"str",
"string",
",",
"ep",
"*",
"Endpoint",
")",
"error",
"{",
"jsonBytes",
",",
"err",
":=",
"base64",
".",
"StdEncoding",
".",
"DecodeString",
"(",
"str",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"json",
".",
"Unmarshal",
"(",
"jsonBytes",
",",
"ep",
")",
"\n",
"}"
] | // parseBase64ToEndpoint parses the endpoint stored in the given base64 string. | [
"parseBase64ToEndpoint",
"parses",
"the",
"endpoint",
"stored",
"in",
"the",
"given",
"base64",
"string",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1031-L1037 |
163,133 | cilium/cilium | pkg/endpoint/endpoint.go | FilterEPDir | func FilterEPDir(dirFiles []os.FileInfo) []string {
eptsID := []string{}
for _, file := range dirFiles {
if file.IsDir() {
_, err := strconv.ParseUint(file.Name(), 10, 16)
if err == nil || strings.HasSuffix(file.Name(), "_next") || strings.HasSuffix(file.Name(), "_next_fail") {
eptsID = append(eptsID, file.Name())
}
}
}
return eptsID
} | go | func FilterEPDir(dirFiles []os.FileInfo) []string {
eptsID := []string{}
for _, file := range dirFiles {
if file.IsDir() {
_, err := strconv.ParseUint(file.Name(), 10, 16)
if err == nil || strings.HasSuffix(file.Name(), "_next") || strings.HasSuffix(file.Name(), "_next_fail") {
eptsID = append(eptsID, file.Name())
}
}
}
return eptsID
} | [
"func",
"FilterEPDir",
"(",
"dirFiles",
"[",
"]",
"os",
".",
"FileInfo",
")",
"[",
"]",
"string",
"{",
"eptsID",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"file",
":=",
"range",
"dirFiles",
"{",
"if",
"file",
".",
"IsDir",
"(",
")",
"{",
"_",
",",
"err",
":=",
"strconv",
".",
"ParseUint",
"(",
"file",
".",
"Name",
"(",
")",
",",
"10",
",",
"16",
")",
"\n",
"if",
"err",
"==",
"nil",
"||",
"strings",
".",
"HasSuffix",
"(",
"file",
".",
"Name",
"(",
")",
",",
"\"",
"\"",
")",
"||",
"strings",
".",
"HasSuffix",
"(",
"file",
".",
"Name",
"(",
")",
",",
"\"",
"\"",
")",
"{",
"eptsID",
"=",
"append",
"(",
"eptsID",
",",
"file",
".",
"Name",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"eptsID",
"\n",
"}"
] | // FilterEPDir returns a list of directories' names that possible belong to an endpoint. | [
"FilterEPDir",
"returns",
"a",
"list",
"of",
"directories",
"names",
"that",
"possible",
"belong",
"to",
"an",
"endpoint",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1040-L1051 |
163,134 | cilium/cilium | pkg/endpoint/endpoint.go | LogStatusOKLocked | func (e *Endpoint) LogStatusOKLocked(typ StatusType, msg string) {
e.logStatusLocked(typ, OK, msg)
} | go | func (e *Endpoint) LogStatusOKLocked(typ StatusType, msg string) {
e.logStatusLocked(typ, OK, msg)
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"LogStatusOKLocked",
"(",
"typ",
"StatusType",
",",
"msg",
"string",
")",
"{",
"e",
".",
"logStatusLocked",
"(",
"typ",
",",
"OK",
",",
"msg",
")",
"\n",
"}"
] | // LogStatusOKLocked will log an OK message of the given status type with the
// given msg string.
// must be called with endpoint.Mutex held | [
"LogStatusOKLocked",
"will",
"log",
"an",
"OK",
"message",
"of",
"the",
"given",
"status",
"type",
"with",
"the",
"given",
"msg",
"string",
".",
"must",
"be",
"called",
"with",
"endpoint",
".",
"Mutex",
"held"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1114-L1116 |
163,135 | cilium/cilium | pkg/endpoint/endpoint.go | logStatusLocked | func (e *Endpoint) logStatusLocked(typ StatusType, code StatusCode, msg string) {
e.Status.indexMU.Lock()
defer e.Status.indexMU.Unlock()
sts := &statusLogMsg{
Status: Status{
Code: code,
Msg: msg,
Type: typ,
State: e.state,
},
Timestamp: time.Now().UTC(),
}
e.Status.addStatusLog(sts)
e.getLogger().WithFields(logrus.Fields{
"code": sts.Status.Code,
"type": sts.Status.Type,
logfields.EndpointState: sts.Status.State,
logfields.PolicyRevision: e.policyRevision,
}).Debug(msg)
} | go | func (e *Endpoint) logStatusLocked(typ StatusType, code StatusCode, msg string) {
e.Status.indexMU.Lock()
defer e.Status.indexMU.Unlock()
sts := &statusLogMsg{
Status: Status{
Code: code,
Msg: msg,
Type: typ,
State: e.state,
},
Timestamp: time.Now().UTC(),
}
e.Status.addStatusLog(sts)
e.getLogger().WithFields(logrus.Fields{
"code": sts.Status.Code,
"type": sts.Status.Type,
logfields.EndpointState: sts.Status.State,
logfields.PolicyRevision: e.policyRevision,
}).Debug(msg)
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"logStatusLocked",
"(",
"typ",
"StatusType",
",",
"code",
"StatusCode",
",",
"msg",
"string",
")",
"{",
"e",
".",
"Status",
".",
"indexMU",
".",
"Lock",
"(",
")",
"\n",
"defer",
"e",
".",
"Status",
".",
"indexMU",
".",
"Unlock",
"(",
")",
"\n",
"sts",
":=",
"&",
"statusLogMsg",
"{",
"Status",
":",
"Status",
"{",
"Code",
":",
"code",
",",
"Msg",
":",
"msg",
",",
"Type",
":",
"typ",
",",
"State",
":",
"e",
".",
"state",
",",
"}",
",",
"Timestamp",
":",
"time",
".",
"Now",
"(",
")",
".",
"UTC",
"(",
")",
",",
"}",
"\n",
"e",
".",
"Status",
".",
"addStatusLog",
"(",
"sts",
")",
"\n",
"e",
".",
"getLogger",
"(",
")",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"\"",
"\"",
":",
"sts",
".",
"Status",
".",
"Code",
",",
"\"",
"\"",
":",
"sts",
".",
"Status",
".",
"Type",
",",
"logfields",
".",
"EndpointState",
":",
"sts",
".",
"Status",
".",
"State",
",",
"logfields",
".",
"PolicyRevision",
":",
"e",
".",
"policyRevision",
",",
"}",
")",
".",
"Debug",
"(",
"msg",
")",
"\n",
"}"
] | // logStatusLocked logs a status message
// must be called with endpoint.Mutex held | [
"logStatusLocked",
"logs",
"a",
"status",
"message",
"must",
"be",
"called",
"with",
"endpoint",
".",
"Mutex",
"held"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1120-L1139 |
163,136 | cilium/cilium | pkg/endpoint/endpoint.go | HasLabels | func (e *Endpoint) HasLabels(l pkgLabels.Labels) bool {
e.UnconditionalRLock()
defer e.RUnlock()
return e.hasLabelsRLocked(l)
} | go | func (e *Endpoint) HasLabels(l pkgLabels.Labels) bool {
e.UnconditionalRLock()
defer e.RUnlock()
return e.hasLabelsRLocked(l)
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"HasLabels",
"(",
"l",
"pkgLabels",
".",
"Labels",
")",
"bool",
"{",
"e",
".",
"UnconditionalRLock",
"(",
")",
"\n",
"defer",
"e",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"e",
".",
"hasLabelsRLocked",
"(",
"l",
")",
"\n",
"}"
] | // HasLabels returns whether endpoint e contains all labels l. Will return 'false'
// if any label in l is not in the endpoint's labels. | [
"HasLabels",
"returns",
"whether",
"endpoint",
"e",
"contains",
"all",
"labels",
"l",
".",
"Will",
"return",
"false",
"if",
"any",
"label",
"in",
"l",
"is",
"not",
"in",
"the",
"endpoint",
"s",
"labels",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1244-L1249 |
163,137 | cilium/cilium | pkg/endpoint/endpoint.go | hasLabelsRLocked | func (e *Endpoint) hasLabelsRLocked(l pkgLabels.Labels) bool {
allEpLabels := e.OpLabels.AllLabels()
for _, v := range l {
found := false
for _, j := range allEpLabels {
if j.Equals(&v) {
found = true
break
}
}
if !found {
return false
}
}
return true
} | go | func (e *Endpoint) hasLabelsRLocked(l pkgLabels.Labels) bool {
allEpLabels := e.OpLabels.AllLabels()
for _, v := range l {
found := false
for _, j := range allEpLabels {
if j.Equals(&v) {
found = true
break
}
}
if !found {
return false
}
}
return true
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"hasLabelsRLocked",
"(",
"l",
"pkgLabels",
".",
"Labels",
")",
"bool",
"{",
"allEpLabels",
":=",
"e",
".",
"OpLabels",
".",
"AllLabels",
"(",
")",
"\n\n",
"for",
"_",
",",
"v",
":=",
"range",
"l",
"{",
"found",
":=",
"false",
"\n",
"for",
"_",
",",
"j",
":=",
"range",
"allEpLabels",
"{",
"if",
"j",
".",
"Equals",
"(",
"&",
"v",
")",
"{",
"found",
"=",
"true",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"!",
"found",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"true",
"\n",
"}"
] | // hasLabelsRLocked returns whether endpoint e contains all labels l. Will
// return 'false' if any label in l is not in the endpoint's labels.
// e.Mutex must be RLocked | [
"hasLabelsRLocked",
"returns",
"whether",
"endpoint",
"e",
"contains",
"all",
"labels",
"l",
".",
"Will",
"return",
"false",
"if",
"any",
"label",
"in",
"l",
"is",
"not",
"in",
"the",
"endpoint",
"s",
"labels",
".",
"e",
".",
"Mutex",
"must",
"be",
"RLocked"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1254-L1271 |
163,138 | cilium/cilium | pkg/endpoint/endpoint.go | RegenerateWait | func (e *Endpoint) RegenerateWait(owner Owner, reason string) error {
if !<-e.Regenerate(owner, &ExternalRegenerationMetadata{Reason: reason}) {
return fmt.Errorf("error while regenerating endpoint."+
" For more info run: 'cilium endpoint get %d'", e.ID)
}
return nil
} | go | func (e *Endpoint) RegenerateWait(owner Owner, reason string) error {
if !<-e.Regenerate(owner, &ExternalRegenerationMetadata{Reason: reason}) {
return fmt.Errorf("error while regenerating endpoint."+
" For more info run: 'cilium endpoint get %d'", e.ID)
}
return nil
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"RegenerateWait",
"(",
"owner",
"Owner",
",",
"reason",
"string",
")",
"error",
"{",
"if",
"!",
"<-",
"e",
".",
"Regenerate",
"(",
"owner",
",",
"&",
"ExternalRegenerationMetadata",
"{",
"Reason",
":",
"reason",
"}",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"e",
".",
"ID",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // RegenerateWait should only be called when endpoint's state has successfully
// been changed to "waiting-to-regenerate" | [
"RegenerateWait",
"should",
"only",
"be",
"called",
"when",
"endpoint",
"s",
"state",
"has",
"successfully",
"been",
"changed",
"to",
"waiting",
"-",
"to",
"-",
"regenerate"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1373-L1379 |
163,139 | cilium/cilium | pkg/endpoint/endpoint.go | SetContainerName | func (e *Endpoint) SetContainerName(name string) {
e.UnconditionalLock()
e.ContainerName = name
e.Unlock()
} | go | func (e *Endpoint) SetContainerName(name string) {
e.UnconditionalLock()
e.ContainerName = name
e.Unlock()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"SetContainerName",
"(",
"name",
"string",
")",
"{",
"e",
".",
"UnconditionalLock",
"(",
")",
"\n",
"e",
".",
"ContainerName",
"=",
"name",
"\n",
"e",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // SetContainerName modifies the endpoint's container name | [
"SetContainerName",
"modifies",
"the",
"endpoint",
"s",
"container",
"name"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1382-L1386 |
163,140 | cilium/cilium | pkg/endpoint/endpoint.go | GetK8sNamespace | func (e *Endpoint) GetK8sNamespace() string {
e.UnconditionalRLock()
ns := e.K8sNamespace
e.RUnlock()
return ns
} | go | func (e *Endpoint) GetK8sNamespace() string {
e.UnconditionalRLock()
ns := e.K8sNamespace
e.RUnlock()
return ns
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"GetK8sNamespace",
"(",
")",
"string",
"{",
"e",
".",
"UnconditionalRLock",
"(",
")",
"\n",
"ns",
":=",
"e",
".",
"K8sNamespace",
"\n",
"e",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"ns",
"\n",
"}"
] | // GetK8sNamespace returns the name of the pod if the endpoint represents a
// Kubernetes pod | [
"GetK8sNamespace",
"returns",
"the",
"name",
"of",
"the",
"pod",
"if",
"the",
"endpoint",
"represents",
"a",
"Kubernetes",
"pod"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1390-L1395 |
163,141 | cilium/cilium | pkg/endpoint/endpoint.go | SetK8sNamespace | func (e *Endpoint) SetK8sNamespace(name string) {
e.UnconditionalLock()
e.K8sNamespace = name
e.UpdateLogger(map[string]interface{}{
logfields.K8sPodName: e.GetK8sNamespaceAndPodNameLocked(),
})
e.Unlock()
} | go | func (e *Endpoint) SetK8sNamespace(name string) {
e.UnconditionalLock()
e.K8sNamespace = name
e.UpdateLogger(map[string]interface{}{
logfields.K8sPodName: e.GetK8sNamespaceAndPodNameLocked(),
})
e.Unlock()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"SetK8sNamespace",
"(",
"name",
"string",
")",
"{",
"e",
".",
"UnconditionalLock",
"(",
")",
"\n",
"e",
".",
"K8sNamespace",
"=",
"name",
"\n",
"e",
".",
"UpdateLogger",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"logfields",
".",
"K8sPodName",
":",
"e",
".",
"GetK8sNamespaceAndPodNameLocked",
"(",
")",
",",
"}",
")",
"\n",
"e",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // SetK8sNamespace modifies the endpoint's pod name | [
"SetK8sNamespace",
"modifies",
"the",
"endpoint",
"s",
"pod",
"name"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1398-L1405 |
163,142 | cilium/cilium | pkg/endpoint/endpoint.go | GetK8sPodName | func (e *Endpoint) GetK8sPodName() string {
e.UnconditionalRLock()
k8sPodName := e.K8sPodName
e.RUnlock()
return k8sPodName
} | go | func (e *Endpoint) GetK8sPodName() string {
e.UnconditionalRLock()
k8sPodName := e.K8sPodName
e.RUnlock()
return k8sPodName
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"GetK8sPodName",
"(",
")",
"string",
"{",
"e",
".",
"UnconditionalRLock",
"(",
")",
"\n",
"k8sPodName",
":=",
"e",
".",
"K8sPodName",
"\n",
"e",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"k8sPodName",
"\n",
"}"
] | // GetK8sPodName returns the name of the pod if the endpoint represents a
// Kubernetes pod | [
"GetK8sPodName",
"returns",
"the",
"name",
"of",
"the",
"pod",
"if",
"the",
"endpoint",
"represents",
"a",
"Kubernetes",
"pod"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1409-L1415 |
163,143 | cilium/cilium | pkg/endpoint/endpoint.go | HumanStringLocked | func (e *Endpoint) HumanStringLocked() string {
if pod := e.GetK8sNamespaceAndPodNameLocked(); pod != "" {
return pod
}
return e.StringID()
} | go | func (e *Endpoint) HumanStringLocked() string {
if pod := e.GetK8sNamespaceAndPodNameLocked(); pod != "" {
return pod
}
return e.StringID()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"HumanStringLocked",
"(",
")",
"string",
"{",
"if",
"pod",
":=",
"e",
".",
"GetK8sNamespaceAndPodNameLocked",
"(",
")",
";",
"pod",
"!=",
"\"",
"\"",
"{",
"return",
"pod",
"\n",
"}",
"\n\n",
"return",
"e",
".",
"StringID",
"(",
")",
"\n",
"}"
] | // HumanStringLocked returns the endpoint's most human readable identifier as string | [
"HumanStringLocked",
"returns",
"the",
"endpoint",
"s",
"most",
"human",
"readable",
"identifier",
"as",
"string"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1418-L1424 |
163,144 | cilium/cilium | pkg/endpoint/endpoint.go | SetK8sPodName | func (e *Endpoint) SetK8sPodName(name string) {
e.UnconditionalLock()
e.K8sPodName = name
e.UpdateLogger(map[string]interface{}{
logfields.K8sPodName: e.GetK8sNamespaceAndPodNameLocked(),
})
e.Unlock()
} | go | func (e *Endpoint) SetK8sPodName(name string) {
e.UnconditionalLock()
e.K8sPodName = name
e.UpdateLogger(map[string]interface{}{
logfields.K8sPodName: e.GetK8sNamespaceAndPodNameLocked(),
})
e.Unlock()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"SetK8sPodName",
"(",
"name",
"string",
")",
"{",
"e",
".",
"UnconditionalLock",
"(",
")",
"\n",
"e",
".",
"K8sPodName",
"=",
"name",
"\n",
"e",
".",
"UpdateLogger",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"logfields",
".",
"K8sPodName",
":",
"e",
".",
"GetK8sNamespaceAndPodNameLocked",
"(",
")",
",",
"}",
")",
"\n",
"e",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // SetK8sPodName modifies the endpoint's pod name | [
"SetK8sPodName",
"modifies",
"the",
"endpoint",
"s",
"pod",
"name"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1433-L1440 |
163,145 | cilium/cilium | pkg/endpoint/endpoint.go | SetContainerID | func (e *Endpoint) SetContainerID(id string) {
e.UnconditionalLock()
e.ContainerID = id
e.UpdateLogger(map[string]interface{}{
logfields.ContainerID: e.getShortContainerID(),
})
e.Unlock()
} | go | func (e *Endpoint) SetContainerID(id string) {
e.UnconditionalLock()
e.ContainerID = id
e.UpdateLogger(map[string]interface{}{
logfields.ContainerID: e.getShortContainerID(),
})
e.Unlock()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"SetContainerID",
"(",
"id",
"string",
")",
"{",
"e",
".",
"UnconditionalLock",
"(",
")",
"\n",
"e",
".",
"ContainerID",
"=",
"id",
"\n",
"e",
".",
"UpdateLogger",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"logfields",
".",
"ContainerID",
":",
"e",
".",
"getShortContainerID",
"(",
")",
",",
"}",
")",
"\n",
"e",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // SetContainerID modifies the endpoint's container ID | [
"SetContainerID",
"modifies",
"the",
"endpoint",
"s",
"container",
"ID"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1443-L1450 |
163,146 | cilium/cilium | pkg/endpoint/endpoint.go | GetContainerID | func (e *Endpoint) GetContainerID() string {
e.UnconditionalRLock()
cID := e.ContainerID
e.RUnlock()
return cID
} | go | func (e *Endpoint) GetContainerID() string {
e.UnconditionalRLock()
cID := e.ContainerID
e.RUnlock()
return cID
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"GetContainerID",
"(",
")",
"string",
"{",
"e",
".",
"UnconditionalRLock",
"(",
")",
"\n",
"cID",
":=",
"e",
".",
"ContainerID",
"\n",
"e",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"cID",
"\n",
"}"
] | // GetContainerID returns the endpoint's container ID | [
"GetContainerID",
"returns",
"the",
"endpoint",
"s",
"container",
"ID"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1453-L1458 |
163,147 | cilium/cilium | pkg/endpoint/endpoint.go | GetShortContainerID | func (e *Endpoint) GetShortContainerID() string {
e.UnconditionalRLock()
defer e.RUnlock()
return e.getShortContainerID()
} | go | func (e *Endpoint) GetShortContainerID() string {
e.UnconditionalRLock()
defer e.RUnlock()
return e.getShortContainerID()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"GetShortContainerID",
"(",
")",
"string",
"{",
"e",
".",
"UnconditionalRLock",
"(",
")",
"\n",
"defer",
"e",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"e",
".",
"getShortContainerID",
"(",
")",
"\n",
"}"
] | // GetShortContainerID returns the endpoint's shortened container ID | [
"GetShortContainerID",
"returns",
"the",
"endpoint",
"s",
"shortened",
"container",
"ID"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1461-L1466 |
163,148 | cilium/cilium | pkg/endpoint/endpoint.go | SetDockerEndpointID | func (e *Endpoint) SetDockerEndpointID(id string) {
e.UnconditionalLock()
e.DockerEndpointID = id
e.Unlock()
} | go | func (e *Endpoint) SetDockerEndpointID(id string) {
e.UnconditionalLock()
e.DockerEndpointID = id
e.Unlock()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"SetDockerEndpointID",
"(",
"id",
"string",
")",
"{",
"e",
".",
"UnconditionalLock",
"(",
")",
"\n",
"e",
".",
"DockerEndpointID",
"=",
"id",
"\n",
"e",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // SetDockerEndpointID modifies the endpoint's Docker Endpoint ID | [
"SetDockerEndpointID",
"modifies",
"the",
"endpoint",
"s",
"Docker",
"Endpoint",
"ID"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1483-L1487 |
163,149 | cilium/cilium | pkg/endpoint/endpoint.go | SetDockerNetworkID | func (e *Endpoint) SetDockerNetworkID(id string) {
e.UnconditionalLock()
e.DockerNetworkID = id
e.Unlock()
} | go | func (e *Endpoint) SetDockerNetworkID(id string) {
e.UnconditionalLock()
e.DockerNetworkID = id
e.Unlock()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"SetDockerNetworkID",
"(",
"id",
"string",
")",
"{",
"e",
".",
"UnconditionalLock",
"(",
")",
"\n",
"e",
".",
"DockerNetworkID",
"=",
"id",
"\n",
"e",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // SetDockerNetworkID modifies the endpoint's Docker Endpoint ID | [
"SetDockerNetworkID",
"modifies",
"the",
"endpoint",
"s",
"Docker",
"Endpoint",
"ID"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1490-L1494 |
163,150 | cilium/cilium | pkg/endpoint/endpoint.go | GetDockerNetworkID | func (e *Endpoint) GetDockerNetworkID() string {
e.UnconditionalRLock()
defer e.RUnlock()
return e.DockerNetworkID
} | go | func (e *Endpoint) GetDockerNetworkID() string {
e.UnconditionalRLock()
defer e.RUnlock()
return e.DockerNetworkID
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"GetDockerNetworkID",
"(",
")",
"string",
"{",
"e",
".",
"UnconditionalRLock",
"(",
")",
"\n",
"defer",
"e",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"e",
".",
"DockerNetworkID",
"\n",
"}"
] | // GetDockerNetworkID returns the endpoint's Docker Endpoint ID | [
"GetDockerNetworkID",
"returns",
"the",
"endpoint",
"s",
"Docker",
"Endpoint",
"ID"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1497-L1502 |
163,151 | cilium/cilium | pkg/endpoint/endpoint.go | SetDatapathMapIDAndPinMapLocked | func (e *Endpoint) SetDatapathMapIDAndPinMapLocked(id int) error {
e.DatapathMapID = id
return e.PinDatapathMap()
} | go | func (e *Endpoint) SetDatapathMapIDAndPinMapLocked(id int) error {
e.DatapathMapID = id
return e.PinDatapathMap()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"SetDatapathMapIDAndPinMapLocked",
"(",
"id",
"int",
")",
"error",
"{",
"e",
".",
"DatapathMapID",
"=",
"id",
"\n",
"return",
"e",
".",
"PinDatapathMap",
"(",
")",
"\n",
"}"
] | // SetDatapathMapIDAndPinMapLocked modifies the endpoint's datapath map ID | [
"SetDatapathMapIDAndPinMapLocked",
"modifies",
"the",
"endpoint",
"s",
"datapath",
"map",
"ID"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1505-L1508 |
163,152 | cilium/cilium | pkg/endpoint/endpoint.go | SetStateLocked | func (e *Endpoint) SetStateLocked(toState, reason string) bool {
// Validate the state transition.
fromState := e.state
switch fromState { // From state
case "": // Special case for capturing initial state transitions like
// nil --> StateWaitingForIdentity, StateRestoring
switch toState {
case StateWaitingForIdentity, StateRestoring:
goto OKState
}
case StateCreating:
switch toState {
case StateDisconnecting, StateWaitingForIdentity, StateRestoring:
goto OKState
}
case StateWaitingForIdentity:
switch toState {
case StateReady, StateDisconnecting:
goto OKState
}
case StateReady:
switch toState {
case StateWaitingForIdentity, StateDisconnecting, StateWaitingToRegenerate, StateRestoring:
goto OKState
}
case StateDisconnecting:
switch toState {
case StateDisconnected:
goto OKState
}
case StateDisconnected:
// No valid transitions, as disconnected is a terminal state for the endpoint.
case StateWaitingToRegenerate:
switch toState {
// Note that transitions to waiting-to-regenerate state
case StateWaitingForIdentity, StateDisconnecting, StateRestoring:
goto OKState
}
case StateRegenerating:
switch toState {
// Even while the endpoint is regenerating it is
// possible that further changes require a new
// build. In this case the endpoint is transitioned
// from the regenerating state to
// waiting-for-identity or waiting-to-regenerate state.
case StateWaitingForIdentity, StateDisconnecting, StateWaitingToRegenerate, StateRestoring:
goto OKState
}
case StateRestoring:
switch toState {
case StateDisconnecting, StateWaitingToRegenerate, StateRestoring:
goto OKState
}
}
if toState != fromState {
_, fileName, fileLine, _ := runtime.Caller(1)
e.getLogger().WithFields(logrus.Fields{
logfields.EndpointState + ".from": fromState,
logfields.EndpointState + ".to": toState,
"file": fileName,
"line": fileLine,
}).Info("Invalid state transition skipped")
}
e.logStatusLocked(Other, Warning, fmt.Sprintf("Skipped invalid state transition to %s due to: %s", toState, reason))
return false
OKState:
e.state = toState
e.logStatusLocked(Other, OK, reason)
if fromState != "" {
metrics.EndpointStateCount.
WithLabelValues(fromState).Dec()
}
// Since StateDisconnected is the final state, after which the
// endpoint is gone, we should not increment metrics for this state.
if toState != "" && toState != StateDisconnected {
metrics.EndpointStateCount.
WithLabelValues(toState).Inc()
}
return true
} | go | func (e *Endpoint) SetStateLocked(toState, reason string) bool {
// Validate the state transition.
fromState := e.state
switch fromState { // From state
case "": // Special case for capturing initial state transitions like
// nil --> StateWaitingForIdentity, StateRestoring
switch toState {
case StateWaitingForIdentity, StateRestoring:
goto OKState
}
case StateCreating:
switch toState {
case StateDisconnecting, StateWaitingForIdentity, StateRestoring:
goto OKState
}
case StateWaitingForIdentity:
switch toState {
case StateReady, StateDisconnecting:
goto OKState
}
case StateReady:
switch toState {
case StateWaitingForIdentity, StateDisconnecting, StateWaitingToRegenerate, StateRestoring:
goto OKState
}
case StateDisconnecting:
switch toState {
case StateDisconnected:
goto OKState
}
case StateDisconnected:
// No valid transitions, as disconnected is a terminal state for the endpoint.
case StateWaitingToRegenerate:
switch toState {
// Note that transitions to waiting-to-regenerate state
case StateWaitingForIdentity, StateDisconnecting, StateRestoring:
goto OKState
}
case StateRegenerating:
switch toState {
// Even while the endpoint is regenerating it is
// possible that further changes require a new
// build. In this case the endpoint is transitioned
// from the regenerating state to
// waiting-for-identity or waiting-to-regenerate state.
case StateWaitingForIdentity, StateDisconnecting, StateWaitingToRegenerate, StateRestoring:
goto OKState
}
case StateRestoring:
switch toState {
case StateDisconnecting, StateWaitingToRegenerate, StateRestoring:
goto OKState
}
}
if toState != fromState {
_, fileName, fileLine, _ := runtime.Caller(1)
e.getLogger().WithFields(logrus.Fields{
logfields.EndpointState + ".from": fromState,
logfields.EndpointState + ".to": toState,
"file": fileName,
"line": fileLine,
}).Info("Invalid state transition skipped")
}
e.logStatusLocked(Other, Warning, fmt.Sprintf("Skipped invalid state transition to %s due to: %s", toState, reason))
return false
OKState:
e.state = toState
e.logStatusLocked(Other, OK, reason)
if fromState != "" {
metrics.EndpointStateCount.
WithLabelValues(fromState).Dec()
}
// Since StateDisconnected is the final state, after which the
// endpoint is gone, we should not increment metrics for this state.
if toState != "" && toState != StateDisconnected {
metrics.EndpointStateCount.
WithLabelValues(toState).Inc()
}
return true
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"SetStateLocked",
"(",
"toState",
",",
"reason",
"string",
")",
"bool",
"{",
"// Validate the state transition.",
"fromState",
":=",
"e",
".",
"state",
"\n\n",
"switch",
"fromState",
"{",
"// From state",
"case",
"\"",
"\"",
":",
"// Special case for capturing initial state transitions like",
"// nil --> StateWaitingForIdentity, StateRestoring",
"switch",
"toState",
"{",
"case",
"StateWaitingForIdentity",
",",
"StateRestoring",
":",
"goto",
"OKState",
"\n",
"}",
"\n",
"case",
"StateCreating",
":",
"switch",
"toState",
"{",
"case",
"StateDisconnecting",
",",
"StateWaitingForIdentity",
",",
"StateRestoring",
":",
"goto",
"OKState",
"\n",
"}",
"\n",
"case",
"StateWaitingForIdentity",
":",
"switch",
"toState",
"{",
"case",
"StateReady",
",",
"StateDisconnecting",
":",
"goto",
"OKState",
"\n",
"}",
"\n",
"case",
"StateReady",
":",
"switch",
"toState",
"{",
"case",
"StateWaitingForIdentity",
",",
"StateDisconnecting",
",",
"StateWaitingToRegenerate",
",",
"StateRestoring",
":",
"goto",
"OKState",
"\n",
"}",
"\n",
"case",
"StateDisconnecting",
":",
"switch",
"toState",
"{",
"case",
"StateDisconnected",
":",
"goto",
"OKState",
"\n",
"}",
"\n",
"case",
"StateDisconnected",
":",
"// No valid transitions, as disconnected is a terminal state for the endpoint.",
"case",
"StateWaitingToRegenerate",
":",
"switch",
"toState",
"{",
"// Note that transitions to waiting-to-regenerate state",
"case",
"StateWaitingForIdentity",
",",
"StateDisconnecting",
",",
"StateRestoring",
":",
"goto",
"OKState",
"\n",
"}",
"\n",
"case",
"StateRegenerating",
":",
"switch",
"toState",
"{",
"// Even while the endpoint is regenerating it is",
"// possible that further changes require a new",
"// build. In this case the endpoint is transitioned",
"// from the regenerating state to",
"// waiting-for-identity or waiting-to-regenerate state.",
"case",
"StateWaitingForIdentity",
",",
"StateDisconnecting",
",",
"StateWaitingToRegenerate",
",",
"StateRestoring",
":",
"goto",
"OKState",
"\n",
"}",
"\n",
"case",
"StateRestoring",
":",
"switch",
"toState",
"{",
"case",
"StateDisconnecting",
",",
"StateWaitingToRegenerate",
",",
"StateRestoring",
":",
"goto",
"OKState",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"toState",
"!=",
"fromState",
"{",
"_",
",",
"fileName",
",",
"fileLine",
",",
"_",
":=",
"runtime",
".",
"Caller",
"(",
"1",
")",
"\n",
"e",
".",
"getLogger",
"(",
")",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"logfields",
".",
"EndpointState",
"+",
"\"",
"\"",
":",
"fromState",
",",
"logfields",
".",
"EndpointState",
"+",
"\"",
"\"",
":",
"toState",
",",
"\"",
"\"",
":",
"fileName",
",",
"\"",
"\"",
":",
"fileLine",
",",
"}",
")",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"e",
".",
"logStatusLocked",
"(",
"Other",
",",
"Warning",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"toState",
",",
"reason",
")",
")",
"\n",
"return",
"false",
"\n\n",
"OKState",
":",
"e",
".",
"state",
"=",
"toState",
"\n",
"e",
".",
"logStatusLocked",
"(",
"Other",
",",
"OK",
",",
"reason",
")",
"\n\n",
"if",
"fromState",
"!=",
"\"",
"\"",
"{",
"metrics",
".",
"EndpointStateCount",
".",
"WithLabelValues",
"(",
"fromState",
")",
".",
"Dec",
"(",
")",
"\n",
"}",
"\n\n",
"// Since StateDisconnected is the final state, after which the",
"// endpoint is gone, we should not increment metrics for this state.",
"if",
"toState",
"!=",
"\"",
"\"",
"&&",
"toState",
"!=",
"StateDisconnected",
"{",
"metrics",
".",
"EndpointStateCount",
".",
"WithLabelValues",
"(",
"toState",
")",
".",
"Inc",
"(",
")",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] | // SetStateLocked modifies the endpoint's state
// endpoint.Mutex must be held
// Returns true only if endpoints state was changed as requested | [
"SetStateLocked",
"modifies",
"the",
"endpoint",
"s",
"state",
"endpoint",
".",
"Mutex",
"must",
"be",
"held",
"Returns",
"true",
"only",
"if",
"endpoints",
"state",
"was",
"changed",
"as",
"requested"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1532-L1615 |
163,153 | cilium/cilium | pkg/endpoint/endpoint.go | BuilderSetStateLocked | func (e *Endpoint) BuilderSetStateLocked(toState, reason string) bool {
// Validate the state transition.
fromState := e.state
switch fromState { // From state
case StateCreating, StateWaitingForIdentity, StateReady, StateDisconnecting, StateDisconnected:
// No valid transitions for the builder
case StateWaitingToRegenerate:
switch toState {
// Builder transitions the endpoint from
// waiting-to-regenerate state to regenerating state
// right after acquiring the endpoint lock, and while
// endpoint's build mutex is held. All changes to
// cilium and endpoint configuration, policy as well
// as the existing set of security identities will be
// reconsidered after this point, i.e., even if some
// of them are changed regeneration need not be queued
// if the endpoint is already in waiting-to-regenerate
// state.
case StateRegenerating:
goto OKState
// Transition to ReadyState is not supported, but is
// attempted when a regeneration is competed, and another
// regeneration has been queued in the meanwhile. So this
// is expected and will not be logged as an error or warning.
case StateReady:
return false
}
case StateRegenerating:
switch toState {
// While still holding the build mutex, the builder
// tries to transition the endpoint to ready
// state. But since the endpoint mutex was released
// for the duration of the bpf generation, it is
// possible that another build request has been
// queued. In this case the endpoint has been
// transitioned to waiting-to-regenerate state
// already, and the transition to ready state is
// skipped (but not worth logging for, as this is
// normal, see above).
case StateReady:
goto OKState
}
}
e.logStatusLocked(Other, Warning, fmt.Sprintf("Skipped invalid state transition to %s due to: %s", toState, reason))
return false
OKState:
e.state = toState
e.logStatusLocked(Other, OK, reason)
if fromState != "" {
metrics.EndpointStateCount.
WithLabelValues(fromState).Dec()
}
// Since StateDisconnected is the final state, after which the
// endpoint is gone, we should not increment metrics for this state.
if toState != "" && toState != StateDisconnected {
metrics.EndpointStateCount.
WithLabelValues(toState).Inc()
}
return true
} | go | func (e *Endpoint) BuilderSetStateLocked(toState, reason string) bool {
// Validate the state transition.
fromState := e.state
switch fromState { // From state
case StateCreating, StateWaitingForIdentity, StateReady, StateDisconnecting, StateDisconnected:
// No valid transitions for the builder
case StateWaitingToRegenerate:
switch toState {
// Builder transitions the endpoint from
// waiting-to-regenerate state to regenerating state
// right after acquiring the endpoint lock, and while
// endpoint's build mutex is held. All changes to
// cilium and endpoint configuration, policy as well
// as the existing set of security identities will be
// reconsidered after this point, i.e., even if some
// of them are changed regeneration need not be queued
// if the endpoint is already in waiting-to-regenerate
// state.
case StateRegenerating:
goto OKState
// Transition to ReadyState is not supported, but is
// attempted when a regeneration is competed, and another
// regeneration has been queued in the meanwhile. So this
// is expected and will not be logged as an error or warning.
case StateReady:
return false
}
case StateRegenerating:
switch toState {
// While still holding the build mutex, the builder
// tries to transition the endpoint to ready
// state. But since the endpoint mutex was released
// for the duration of the bpf generation, it is
// possible that another build request has been
// queued. In this case the endpoint has been
// transitioned to waiting-to-regenerate state
// already, and the transition to ready state is
// skipped (but not worth logging for, as this is
// normal, see above).
case StateReady:
goto OKState
}
}
e.logStatusLocked(Other, Warning, fmt.Sprintf("Skipped invalid state transition to %s due to: %s", toState, reason))
return false
OKState:
e.state = toState
e.logStatusLocked(Other, OK, reason)
if fromState != "" {
metrics.EndpointStateCount.
WithLabelValues(fromState).Dec()
}
// Since StateDisconnected is the final state, after which the
// endpoint is gone, we should not increment metrics for this state.
if toState != "" && toState != StateDisconnected {
metrics.EndpointStateCount.
WithLabelValues(toState).Inc()
}
return true
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"BuilderSetStateLocked",
"(",
"toState",
",",
"reason",
"string",
")",
"bool",
"{",
"// Validate the state transition.",
"fromState",
":=",
"e",
".",
"state",
"\n",
"switch",
"fromState",
"{",
"// From state",
"case",
"StateCreating",
",",
"StateWaitingForIdentity",
",",
"StateReady",
",",
"StateDisconnecting",
",",
"StateDisconnected",
":",
"// No valid transitions for the builder",
"case",
"StateWaitingToRegenerate",
":",
"switch",
"toState",
"{",
"// Builder transitions the endpoint from",
"// waiting-to-regenerate state to regenerating state",
"// right after acquiring the endpoint lock, and while",
"// endpoint's build mutex is held. All changes to",
"// cilium and endpoint configuration, policy as well",
"// as the existing set of security identities will be",
"// reconsidered after this point, i.e., even if some",
"// of them are changed regeneration need not be queued",
"// if the endpoint is already in waiting-to-regenerate",
"// state.",
"case",
"StateRegenerating",
":",
"goto",
"OKState",
"\n",
"// Transition to ReadyState is not supported, but is",
"// attempted when a regeneration is competed, and another",
"// regeneration has been queued in the meanwhile. So this",
"// is expected and will not be logged as an error or warning.",
"case",
"StateReady",
":",
"return",
"false",
"\n",
"}",
"\n",
"case",
"StateRegenerating",
":",
"switch",
"toState",
"{",
"// While still holding the build mutex, the builder",
"// tries to transition the endpoint to ready",
"// state. But since the endpoint mutex was released",
"// for the duration of the bpf generation, it is",
"// possible that another build request has been",
"// queued. In this case the endpoint has been",
"// transitioned to waiting-to-regenerate state",
"// already, and the transition to ready state is",
"// skipped (but not worth logging for, as this is",
"// normal, see above).",
"case",
"StateReady",
":",
"goto",
"OKState",
"\n",
"}",
"\n",
"}",
"\n",
"e",
".",
"logStatusLocked",
"(",
"Other",
",",
"Warning",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"toState",
",",
"reason",
")",
")",
"\n",
"return",
"false",
"\n\n",
"OKState",
":",
"e",
".",
"state",
"=",
"toState",
"\n",
"e",
".",
"logStatusLocked",
"(",
"Other",
",",
"OK",
",",
"reason",
")",
"\n\n",
"if",
"fromState",
"!=",
"\"",
"\"",
"{",
"metrics",
".",
"EndpointStateCount",
".",
"WithLabelValues",
"(",
"fromState",
")",
".",
"Dec",
"(",
")",
"\n",
"}",
"\n\n",
"// Since StateDisconnected is the final state, after which the",
"// endpoint is gone, we should not increment metrics for this state.",
"if",
"toState",
"!=",
"\"",
"\"",
"&&",
"toState",
"!=",
"StateDisconnected",
"{",
"metrics",
".",
"EndpointStateCount",
".",
"WithLabelValues",
"(",
"toState",
")",
".",
"Inc",
"(",
")",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] | // BuilderSetStateLocked modifies the endpoint's state
// endpoint.Mutex must be held
// endpoint BuildMutex must be held! | [
"BuilderSetStateLocked",
"modifies",
"the",
"endpoint",
"s",
"state",
"endpoint",
".",
"Mutex",
"must",
"be",
"held",
"endpoint",
"BuildMutex",
"must",
"be",
"held!"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1620-L1682 |
163,154 | cilium/cilium | pkg/endpoint/endpoint.go | OnProxyPolicyUpdate | func (e *Endpoint) OnProxyPolicyUpdate(revision uint64) {
// NOTE: UnconditionalLock is used here because this callback has no way of reporting an error
e.UnconditionalLock()
if revision > e.proxyPolicyRevision {
e.proxyPolicyRevision = revision
}
e.Unlock()
} | go | func (e *Endpoint) OnProxyPolicyUpdate(revision uint64) {
// NOTE: UnconditionalLock is used here because this callback has no way of reporting an error
e.UnconditionalLock()
if revision > e.proxyPolicyRevision {
e.proxyPolicyRevision = revision
}
e.Unlock()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"OnProxyPolicyUpdate",
"(",
"revision",
"uint64",
")",
"{",
"// NOTE: UnconditionalLock is used here because this callback has no way of reporting an error",
"e",
".",
"UnconditionalLock",
"(",
")",
"\n",
"if",
"revision",
">",
"e",
".",
"proxyPolicyRevision",
"{",
"e",
".",
"proxyPolicyRevision",
"=",
"revision",
"\n",
"}",
"\n",
"e",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // OnProxyPolicyUpdate is a callback used to update the Endpoint's
// proxyPolicyRevision when the specified revision has been applied in the
// proxy. | [
"OnProxyPolicyUpdate",
"is",
"a",
"callback",
"used",
"to",
"update",
"the",
"Endpoint",
"s",
"proxyPolicyRevision",
"when",
"the",
"specified",
"revision",
"has",
"been",
"applied",
"in",
"the",
"proxy",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1687-L1694 |
163,155 | cilium/cilium | pkg/endpoint/endpoint.go | getProxyStatisticsLocked | func (e *Endpoint) getProxyStatisticsLocked(l7Protocol string, port uint16, ingress bool) *models.ProxyStatistics {
var location string
if ingress {
location = models.ProxyStatisticsLocationIngress
} else {
location = models.ProxyStatisticsLocationEgress
}
key := models.ProxyStatistics{
Location: location,
Port: int64(port),
Protocol: l7Protocol,
}
if e.proxyStatistics == nil {
e.proxyStatistics = make(map[models.ProxyStatistics]*models.ProxyStatistics)
}
proxyStats, ok := e.proxyStatistics[key]
if !ok {
keyCopy := key
proxyStats = &keyCopy
proxyStats.Statistics = &models.RequestResponseStatistics{
Requests: &models.MessageForwardingStatistics{},
Responses: &models.MessageForwardingStatistics{},
}
e.proxyStatistics[key] = proxyStats
}
return proxyStats
} | go | func (e *Endpoint) getProxyStatisticsLocked(l7Protocol string, port uint16, ingress bool) *models.ProxyStatistics {
var location string
if ingress {
location = models.ProxyStatisticsLocationIngress
} else {
location = models.ProxyStatisticsLocationEgress
}
key := models.ProxyStatistics{
Location: location,
Port: int64(port),
Protocol: l7Protocol,
}
if e.proxyStatistics == nil {
e.proxyStatistics = make(map[models.ProxyStatistics]*models.ProxyStatistics)
}
proxyStats, ok := e.proxyStatistics[key]
if !ok {
keyCopy := key
proxyStats = &keyCopy
proxyStats.Statistics = &models.RequestResponseStatistics{
Requests: &models.MessageForwardingStatistics{},
Responses: &models.MessageForwardingStatistics{},
}
e.proxyStatistics[key] = proxyStats
}
return proxyStats
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"getProxyStatisticsLocked",
"(",
"l7Protocol",
"string",
",",
"port",
"uint16",
",",
"ingress",
"bool",
")",
"*",
"models",
".",
"ProxyStatistics",
"{",
"var",
"location",
"string",
"\n",
"if",
"ingress",
"{",
"location",
"=",
"models",
".",
"ProxyStatisticsLocationIngress",
"\n",
"}",
"else",
"{",
"location",
"=",
"models",
".",
"ProxyStatisticsLocationEgress",
"\n",
"}",
"\n",
"key",
":=",
"models",
".",
"ProxyStatistics",
"{",
"Location",
":",
"location",
",",
"Port",
":",
"int64",
"(",
"port",
")",
",",
"Protocol",
":",
"l7Protocol",
",",
"}",
"\n\n",
"if",
"e",
".",
"proxyStatistics",
"==",
"nil",
"{",
"e",
".",
"proxyStatistics",
"=",
"make",
"(",
"map",
"[",
"models",
".",
"ProxyStatistics",
"]",
"*",
"models",
".",
"ProxyStatistics",
")",
"\n",
"}",
"\n\n",
"proxyStats",
",",
"ok",
":=",
"e",
".",
"proxyStatistics",
"[",
"key",
"]",
"\n",
"if",
"!",
"ok",
"{",
"keyCopy",
":=",
"key",
"\n",
"proxyStats",
"=",
"&",
"keyCopy",
"\n",
"proxyStats",
".",
"Statistics",
"=",
"&",
"models",
".",
"RequestResponseStatistics",
"{",
"Requests",
":",
"&",
"models",
".",
"MessageForwardingStatistics",
"{",
"}",
",",
"Responses",
":",
"&",
"models",
".",
"MessageForwardingStatistics",
"{",
"}",
",",
"}",
"\n",
"e",
".",
"proxyStatistics",
"[",
"key",
"]",
"=",
"proxyStats",
"\n",
"}",
"\n\n",
"return",
"proxyStats",
"\n",
"}"
] | // getProxyStatisticsLocked gets the ProxyStatistics for the flows with the
// given characteristics, or adds a new one and returns it.
// Must be called with e.proxyStatisticsMutex held. | [
"getProxyStatisticsLocked",
"gets",
"the",
"ProxyStatistics",
"for",
"the",
"flows",
"with",
"the",
"given",
"characteristics",
"or",
"adds",
"a",
"new",
"one",
"and",
"returns",
"it",
".",
"Must",
"be",
"called",
"with",
"e",
".",
"proxyStatisticsMutex",
"held",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1699-L1728 |
163,156 | cilium/cilium | pkg/endpoint/endpoint.go | UpdateProxyStatistics | func (e *Endpoint) UpdateProxyStatistics(l7Protocol string, port uint16, ingress, request bool, verdict accesslog.FlowVerdict) {
e.proxyStatisticsMutex.Lock()
defer e.proxyStatisticsMutex.Unlock()
proxyStats := e.getProxyStatisticsLocked(l7Protocol, port, ingress)
var stats *models.MessageForwardingStatistics
if request {
stats = proxyStats.Statistics.Requests
} else {
stats = proxyStats.Statistics.Responses
}
stats.Received++
metrics.ProxyReceived.Inc()
switch verdict {
case accesslog.VerdictForwarded:
stats.Forwarded++
metrics.ProxyForwarded.Inc()
case accesslog.VerdictDenied:
stats.Denied++
metrics.ProxyDenied.Inc()
case accesslog.VerdictError:
stats.Error++
metrics.ProxyParseErrors.Inc()
}
} | go | func (e *Endpoint) UpdateProxyStatistics(l7Protocol string, port uint16, ingress, request bool, verdict accesslog.FlowVerdict) {
e.proxyStatisticsMutex.Lock()
defer e.proxyStatisticsMutex.Unlock()
proxyStats := e.getProxyStatisticsLocked(l7Protocol, port, ingress)
var stats *models.MessageForwardingStatistics
if request {
stats = proxyStats.Statistics.Requests
} else {
stats = proxyStats.Statistics.Responses
}
stats.Received++
metrics.ProxyReceived.Inc()
switch verdict {
case accesslog.VerdictForwarded:
stats.Forwarded++
metrics.ProxyForwarded.Inc()
case accesslog.VerdictDenied:
stats.Denied++
metrics.ProxyDenied.Inc()
case accesslog.VerdictError:
stats.Error++
metrics.ProxyParseErrors.Inc()
}
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"UpdateProxyStatistics",
"(",
"l7Protocol",
"string",
",",
"port",
"uint16",
",",
"ingress",
",",
"request",
"bool",
",",
"verdict",
"accesslog",
".",
"FlowVerdict",
")",
"{",
"e",
".",
"proxyStatisticsMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"e",
".",
"proxyStatisticsMutex",
".",
"Unlock",
"(",
")",
"\n\n",
"proxyStats",
":=",
"e",
".",
"getProxyStatisticsLocked",
"(",
"l7Protocol",
",",
"port",
",",
"ingress",
")",
"\n\n",
"var",
"stats",
"*",
"models",
".",
"MessageForwardingStatistics",
"\n",
"if",
"request",
"{",
"stats",
"=",
"proxyStats",
".",
"Statistics",
".",
"Requests",
"\n",
"}",
"else",
"{",
"stats",
"=",
"proxyStats",
".",
"Statistics",
".",
"Responses",
"\n",
"}",
"\n\n",
"stats",
".",
"Received",
"++",
"\n",
"metrics",
".",
"ProxyReceived",
".",
"Inc",
"(",
")",
"\n\n",
"switch",
"verdict",
"{",
"case",
"accesslog",
".",
"VerdictForwarded",
":",
"stats",
".",
"Forwarded",
"++",
"\n",
"metrics",
".",
"ProxyForwarded",
".",
"Inc",
"(",
")",
"\n",
"case",
"accesslog",
".",
"VerdictDenied",
":",
"stats",
".",
"Denied",
"++",
"\n",
"metrics",
".",
"ProxyDenied",
".",
"Inc",
"(",
")",
"\n",
"case",
"accesslog",
".",
"VerdictError",
":",
"stats",
".",
"Error",
"++",
"\n",
"metrics",
".",
"ProxyParseErrors",
".",
"Inc",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // UpdateProxyStatistics updates the Endpoint's proxy statistics to account
// for a new observed flow with the given characteristics. | [
"UpdateProxyStatistics",
"updates",
"the",
"Endpoint",
"s",
"proxy",
"statistics",
"to",
"account",
"for",
"a",
"new",
"observed",
"flow",
"with",
"the",
"given",
"characteristics",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1732-L1759 |
163,157 | cilium/cilium | pkg/endpoint/endpoint.go | APICanModify | func APICanModify(e *Endpoint) error {
if e.IsInit() {
return nil
}
if e.OpLabels.OrchestrationIdentity.IsReserved() {
return fmt.Errorf("endpoint may not be associated reserved labels")
}
return nil
} | go | func APICanModify(e *Endpoint) error {
if e.IsInit() {
return nil
}
if e.OpLabels.OrchestrationIdentity.IsReserved() {
return fmt.Errorf("endpoint may not be associated reserved labels")
}
return nil
} | [
"func",
"APICanModify",
"(",
"e",
"*",
"Endpoint",
")",
"error",
"{",
"if",
"e",
".",
"IsInit",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"e",
".",
"OpLabels",
".",
"OrchestrationIdentity",
".",
"IsReserved",
"(",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // APICanModify determines whether API requests from a user are allowed to
// modify this endpoint. | [
"APICanModify",
"determines",
"whether",
"API",
"requests",
"from",
"a",
"user",
"are",
"allowed",
"to",
"modify",
"this",
"endpoint",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1763-L1771 |
163,158 | cilium/cilium | pkg/endpoint/endpoint.go | ModifyIdentityLabels | func (e *Endpoint) ModifyIdentityLabels(owner Owner, addLabels, delLabels pkgLabels.Labels) error {
if err := e.LockAlive(); err != nil {
return err
}
switch e.GetStateLocked() {
case StateDisconnected, StateDisconnecting:
e.Unlock()
return nil
}
changed, err := e.OpLabels.ModifyIdentityLabels(addLabels, delLabels)
if err != nil {
e.Unlock()
return err
}
var rev int
if changed {
// Mark with StateWaitingForIdentity, it will be set to
// StateWaitingToRegenerate after the identity resolution has been
// completed
e.SetStateLocked(StateWaitingForIdentity, "Triggering identity resolution due to updated identity labels")
e.identityRevision++
rev = e.identityRevision
}
e.Unlock()
if changed {
e.runLabelsResolver(context.Background(), owner, rev, false)
}
return nil
} | go | func (e *Endpoint) ModifyIdentityLabels(owner Owner, addLabels, delLabels pkgLabels.Labels) error {
if err := e.LockAlive(); err != nil {
return err
}
switch e.GetStateLocked() {
case StateDisconnected, StateDisconnecting:
e.Unlock()
return nil
}
changed, err := e.OpLabels.ModifyIdentityLabels(addLabels, delLabels)
if err != nil {
e.Unlock()
return err
}
var rev int
if changed {
// Mark with StateWaitingForIdentity, it will be set to
// StateWaitingToRegenerate after the identity resolution has been
// completed
e.SetStateLocked(StateWaitingForIdentity, "Triggering identity resolution due to updated identity labels")
e.identityRevision++
rev = e.identityRevision
}
e.Unlock()
if changed {
e.runLabelsResolver(context.Background(), owner, rev, false)
}
return nil
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"ModifyIdentityLabels",
"(",
"owner",
"Owner",
",",
"addLabels",
",",
"delLabels",
"pkgLabels",
".",
"Labels",
")",
"error",
"{",
"if",
"err",
":=",
"e",
".",
"LockAlive",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"switch",
"e",
".",
"GetStateLocked",
"(",
")",
"{",
"case",
"StateDisconnected",
",",
"StateDisconnecting",
":",
"e",
".",
"Unlock",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"changed",
",",
"err",
":=",
"e",
".",
"OpLabels",
".",
"ModifyIdentityLabels",
"(",
"addLabels",
",",
"delLabels",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"e",
".",
"Unlock",
"(",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"var",
"rev",
"int",
"\n",
"if",
"changed",
"{",
"// Mark with StateWaitingForIdentity, it will be set to",
"// StateWaitingToRegenerate after the identity resolution has been",
"// completed",
"e",
".",
"SetStateLocked",
"(",
"StateWaitingForIdentity",
",",
"\"",
"\"",
")",
"\n\n",
"e",
".",
"identityRevision",
"++",
"\n",
"rev",
"=",
"e",
".",
"identityRevision",
"\n",
"}",
"\n",
"e",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"changed",
"{",
"e",
".",
"runLabelsResolver",
"(",
"context",
".",
"Background",
"(",
")",
",",
"owner",
",",
"rev",
",",
"false",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // ModifyIdentityLabels changes the custom and orchestration identity labels of an endpoint.
// Labels can be added or deleted. If a label change is performed, the
// endpoint will receive a new identity and will be regenerated. Both of these
// operations will happen in the background. | [
"ModifyIdentityLabels",
"changes",
"the",
"custom",
"and",
"orchestration",
"identity",
"labels",
"of",
"an",
"endpoint",
".",
"Labels",
"can",
"be",
"added",
"or",
"deleted",
".",
"If",
"a",
"label",
"change",
"is",
"performed",
"the",
"endpoint",
"will",
"receive",
"a",
"new",
"identity",
"and",
"will",
"be",
"regenerated",
".",
"Both",
"of",
"these",
"operations",
"will",
"happen",
"in",
"the",
"background",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1789-L1822 |
163,159 | cilium/cilium | pkg/endpoint/endpoint.go | UpdateLabels | func (e *Endpoint) UpdateLabels(ctx context.Context, owner Owner, identityLabels, infoLabels pkgLabels.Labels, blocking bool) {
log.WithFields(logrus.Fields{
logfields.ContainerID: e.GetShortContainerID(),
logfields.EndpointID: e.StringID(),
logfields.IdentityLabels: identityLabels.String(),
logfields.InfoLabels: infoLabels.String(),
}).Debug("Refreshing labels of endpoint")
if err := e.LockAlive(); err != nil {
e.LogDisconnectedMutexAction(err, "when trying to refresh endpoint labels")
return
}
e.replaceInformationLabels(infoLabels)
// replace identity labels and update the identity if labels have changed
rev := e.replaceIdentityLabels(identityLabels)
e.Unlock()
if rev != 0 {
e.runLabelsResolver(ctx, owner, rev, blocking)
}
} | go | func (e *Endpoint) UpdateLabels(ctx context.Context, owner Owner, identityLabels, infoLabels pkgLabels.Labels, blocking bool) {
log.WithFields(logrus.Fields{
logfields.ContainerID: e.GetShortContainerID(),
logfields.EndpointID: e.StringID(),
logfields.IdentityLabels: identityLabels.String(),
logfields.InfoLabels: infoLabels.String(),
}).Debug("Refreshing labels of endpoint")
if err := e.LockAlive(); err != nil {
e.LogDisconnectedMutexAction(err, "when trying to refresh endpoint labels")
return
}
e.replaceInformationLabels(infoLabels)
// replace identity labels and update the identity if labels have changed
rev := e.replaceIdentityLabels(identityLabels)
e.Unlock()
if rev != 0 {
e.runLabelsResolver(ctx, owner, rev, blocking)
}
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"UpdateLabels",
"(",
"ctx",
"context",
".",
"Context",
",",
"owner",
"Owner",
",",
"identityLabels",
",",
"infoLabels",
"pkgLabels",
".",
"Labels",
",",
"blocking",
"bool",
")",
"{",
"log",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"logfields",
".",
"ContainerID",
":",
"e",
".",
"GetShortContainerID",
"(",
")",
",",
"logfields",
".",
"EndpointID",
":",
"e",
".",
"StringID",
"(",
")",
",",
"logfields",
".",
"IdentityLabels",
":",
"identityLabels",
".",
"String",
"(",
")",
",",
"logfields",
".",
"InfoLabels",
":",
"infoLabels",
".",
"String",
"(",
")",
",",
"}",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"err",
":=",
"e",
".",
"LockAlive",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"e",
".",
"LogDisconnectedMutexAction",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"e",
".",
"replaceInformationLabels",
"(",
"infoLabels",
")",
"\n",
"// replace identity labels and update the identity if labels have changed",
"rev",
":=",
"e",
".",
"replaceIdentityLabels",
"(",
"identityLabels",
")",
"\n",
"e",
".",
"Unlock",
"(",
")",
"\n",
"if",
"rev",
"!=",
"0",
"{",
"e",
".",
"runLabelsResolver",
"(",
"ctx",
",",
"owner",
",",
"rev",
",",
"blocking",
")",
"\n",
"}",
"\n",
"}"
] | // UpdateLabels is called to update the labels of an endpoint. Calls to this
// function do not necessarily mean that the labels actually changed. The
// container runtime layer will periodically synchronize labels.
//
// If a net label changed was performed, the endpoint will receive a new
// identity and will be regenerated. Both of these operations will happen in
// the background. | [
"UpdateLabels",
"is",
"called",
"to",
"update",
"the",
"labels",
"of",
"an",
"endpoint",
".",
"Calls",
"to",
"this",
"function",
"do",
"not",
"necessarily",
"mean",
"that",
"the",
"labels",
"actually",
"changed",
".",
"The",
"container",
"runtime",
"layer",
"will",
"periodically",
"synchronize",
"labels",
".",
"If",
"a",
"net",
"label",
"changed",
"was",
"performed",
"the",
"endpoint",
"will",
"receive",
"a",
"new",
"identity",
"and",
"will",
"be",
"regenerated",
".",
"Both",
"of",
"these",
"operations",
"will",
"happen",
"in",
"the",
"background",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1838-L1858 |
163,160 | cilium/cilium | pkg/endpoint/endpoint.go | runLabelsResolver | func (e *Endpoint) runLabelsResolver(ctx context.Context, owner Owner, myChangeRev int, blocking bool) {
if err := e.RLockAlive(); err != nil {
// If a labels update and an endpoint delete API request arrive
// in quick succession, this could occur; in that case, there's
// no point updating the controller.
e.getLogger().WithError(err).Info("Cannot run labels resolver")
return
}
newLabels := e.OpLabels.IdentityLabels()
e.RUnlock()
scopedLog := e.getLogger().WithField(logfields.IdentityLabels, newLabels)
// If we are certain we can resolve the identity without accessing the KV
// store, do it first synchronously right now. This can reduce the number
// of regenerations for the endpoint during its initialization.
if blocking || cache.IdentityAllocationIsLocal(newLabels) {
scopedLog.Info("Resolving identity labels (blocking)")
err := e.identityLabelsChanged(ctx, owner, myChangeRev)
switch err {
case ErrNotAlive:
scopedLog.Debug("not changing endpoint identity because endpoint is in process of being removed")
return
default:
if err != nil {
scopedLog.WithError(err).Warn("Error changing endpoint identity")
}
}
} else {
scopedLog.Info("Resolving identity labels (non-blocking)")
}
ctrlName := fmt.Sprintf("resolve-identity-%d", e.ID)
e.controllers.UpdateController(ctrlName,
controller.ControllerParams{
DoFunc: func(ctx context.Context) error {
err := e.identityLabelsChanged(ctx, owner, myChangeRev)
switch err {
case ErrNotAlive:
e.getLogger().Debug("not changing endpoint identity because endpoint is in process of being removed")
return controller.NewExitReason("Endpoint disappeared")
default:
return err
}
},
RunInterval: 5 * time.Minute,
},
)
} | go | func (e *Endpoint) runLabelsResolver(ctx context.Context, owner Owner, myChangeRev int, blocking bool) {
if err := e.RLockAlive(); err != nil {
// If a labels update and an endpoint delete API request arrive
// in quick succession, this could occur; in that case, there's
// no point updating the controller.
e.getLogger().WithError(err).Info("Cannot run labels resolver")
return
}
newLabels := e.OpLabels.IdentityLabels()
e.RUnlock()
scopedLog := e.getLogger().WithField(logfields.IdentityLabels, newLabels)
// If we are certain we can resolve the identity without accessing the KV
// store, do it first synchronously right now. This can reduce the number
// of regenerations for the endpoint during its initialization.
if blocking || cache.IdentityAllocationIsLocal(newLabels) {
scopedLog.Info("Resolving identity labels (blocking)")
err := e.identityLabelsChanged(ctx, owner, myChangeRev)
switch err {
case ErrNotAlive:
scopedLog.Debug("not changing endpoint identity because endpoint is in process of being removed")
return
default:
if err != nil {
scopedLog.WithError(err).Warn("Error changing endpoint identity")
}
}
} else {
scopedLog.Info("Resolving identity labels (non-blocking)")
}
ctrlName := fmt.Sprintf("resolve-identity-%d", e.ID)
e.controllers.UpdateController(ctrlName,
controller.ControllerParams{
DoFunc: func(ctx context.Context) error {
err := e.identityLabelsChanged(ctx, owner, myChangeRev)
switch err {
case ErrNotAlive:
e.getLogger().Debug("not changing endpoint identity because endpoint is in process of being removed")
return controller.NewExitReason("Endpoint disappeared")
default:
return err
}
},
RunInterval: 5 * time.Minute,
},
)
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"runLabelsResolver",
"(",
"ctx",
"context",
".",
"Context",
",",
"owner",
"Owner",
",",
"myChangeRev",
"int",
",",
"blocking",
"bool",
")",
"{",
"if",
"err",
":=",
"e",
".",
"RLockAlive",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"// If a labels update and an endpoint delete API request arrive",
"// in quick succession, this could occur; in that case, there's",
"// no point updating the controller.",
"e",
".",
"getLogger",
"(",
")",
".",
"WithError",
"(",
"err",
")",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"newLabels",
":=",
"e",
".",
"OpLabels",
".",
"IdentityLabels",
"(",
")",
"\n",
"e",
".",
"RUnlock",
"(",
")",
"\n",
"scopedLog",
":=",
"e",
".",
"getLogger",
"(",
")",
".",
"WithField",
"(",
"logfields",
".",
"IdentityLabels",
",",
"newLabels",
")",
"\n\n",
"// If we are certain we can resolve the identity without accessing the KV",
"// store, do it first synchronously right now. This can reduce the number",
"// of regenerations for the endpoint during its initialization.",
"if",
"blocking",
"||",
"cache",
".",
"IdentityAllocationIsLocal",
"(",
"newLabels",
")",
"{",
"scopedLog",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"err",
":=",
"e",
".",
"identityLabelsChanged",
"(",
"ctx",
",",
"owner",
",",
"myChangeRev",
")",
"\n",
"switch",
"err",
"{",
"case",
"ErrNotAlive",
":",
"scopedLog",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"default",
":",
"if",
"err",
"!=",
"nil",
"{",
"scopedLog",
".",
"WithError",
"(",
"err",
")",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"else",
"{",
"scopedLog",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"ctrlName",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"ID",
")",
"\n",
"e",
".",
"controllers",
".",
"UpdateController",
"(",
"ctrlName",
",",
"controller",
".",
"ControllerParams",
"{",
"DoFunc",
":",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"err",
":=",
"e",
".",
"identityLabelsChanged",
"(",
"ctx",
",",
"owner",
",",
"myChangeRev",
")",
"\n",
"switch",
"err",
"{",
"case",
"ErrNotAlive",
":",
"e",
".",
"getLogger",
"(",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"controller",
".",
"NewExitReason",
"(",
"\"",
"\"",
")",
"\n",
"default",
":",
"return",
"err",
"\n",
"}",
"\n",
"}",
",",
"RunInterval",
":",
"5",
"*",
"time",
".",
"Minute",
",",
"}",
",",
")",
"\n",
"}"
] | // Must be called with e.Mutex NOT held. | [
"Must",
"be",
"called",
"with",
"e",
".",
"Mutex",
"NOT",
"held",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L1877-L1925 |
163,161 | cilium/cilium | pkg/endpoint/endpoint.go | SetPolicyRevision | func (e *Endpoint) SetPolicyRevision(rev uint64) {
if err := e.LockAlive(); err != nil {
return
}
e.setPolicyRevision(rev)
e.Unlock()
} | go | func (e *Endpoint) SetPolicyRevision(rev uint64) {
if err := e.LockAlive(); err != nil {
return
}
e.setPolicyRevision(rev)
e.Unlock()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"SetPolicyRevision",
"(",
"rev",
"uint64",
")",
"{",
"if",
"err",
":=",
"e",
".",
"LockAlive",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"e",
".",
"setPolicyRevision",
"(",
"rev",
")",
"\n",
"e",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // SetPolicyRevision sets the endpoint's policy revision with the given
// revision. | [
"SetPolicyRevision",
"sets",
"the",
"endpoint",
"s",
"policy",
"revision",
"with",
"the",
"given",
"revision",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L2070-L2076 |
163,162 | cilium/cilium | pkg/endpoint/endpoint.go | setPolicyRevision | func (e *Endpoint) setPolicyRevision(rev uint64) {
if rev <= e.policyRevision {
return
}
now := time.Now()
e.policyRevision = rev
e.UpdateLogger(map[string]interface{}{
logfields.DatapathPolicyRevision: e.policyRevision,
})
for ps := range e.policyRevisionSignals {
select {
case <-ps.ctx.Done():
close(ps.ch)
ps.done(now)
delete(e.policyRevisionSignals, ps)
default:
if rev >= ps.wantedRev {
close(ps.ch)
ps.done(now)
delete(e.policyRevisionSignals, ps)
}
}
}
} | go | func (e *Endpoint) setPolicyRevision(rev uint64) {
if rev <= e.policyRevision {
return
}
now := time.Now()
e.policyRevision = rev
e.UpdateLogger(map[string]interface{}{
logfields.DatapathPolicyRevision: e.policyRevision,
})
for ps := range e.policyRevisionSignals {
select {
case <-ps.ctx.Done():
close(ps.ch)
ps.done(now)
delete(e.policyRevisionSignals, ps)
default:
if rev >= ps.wantedRev {
close(ps.ch)
ps.done(now)
delete(e.policyRevisionSignals, ps)
}
}
}
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"setPolicyRevision",
"(",
"rev",
"uint64",
")",
"{",
"if",
"rev",
"<=",
"e",
".",
"policyRevision",
"{",
"return",
"\n",
"}",
"\n\n",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"e",
".",
"policyRevision",
"=",
"rev",
"\n",
"e",
".",
"UpdateLogger",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"logfields",
".",
"DatapathPolicyRevision",
":",
"e",
".",
"policyRevision",
",",
"}",
")",
"\n",
"for",
"ps",
":=",
"range",
"e",
".",
"policyRevisionSignals",
"{",
"select",
"{",
"case",
"<-",
"ps",
".",
"ctx",
".",
"Done",
"(",
")",
":",
"close",
"(",
"ps",
".",
"ch",
")",
"\n",
"ps",
".",
"done",
"(",
"now",
")",
"\n",
"delete",
"(",
"e",
".",
"policyRevisionSignals",
",",
"ps",
")",
"\n",
"default",
":",
"if",
"rev",
">=",
"ps",
".",
"wantedRev",
"{",
"close",
"(",
"ps",
".",
"ch",
")",
"\n",
"ps",
".",
"done",
"(",
"now",
")",
"\n",
"delete",
"(",
"e",
".",
"policyRevisionSignals",
",",
"ps",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // setPolicyRevision sets the endpoint's policy revision with the given
// revision. | [
"setPolicyRevision",
"sets",
"the",
"endpoint",
"s",
"policy",
"revision",
"with",
"the",
"given",
"revision",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L2080-L2104 |
163,163 | cilium/cilium | pkg/endpoint/endpoint.go | cleanPolicySignals | func (e *Endpoint) cleanPolicySignals() {
now := time.Now()
for w := range e.policyRevisionSignals {
w.done(now)
close(w.ch)
}
e.policyRevisionSignals = map[*policySignal]bool{}
} | go | func (e *Endpoint) cleanPolicySignals() {
now := time.Now()
for w := range e.policyRevisionSignals {
w.done(now)
close(w.ch)
}
e.policyRevisionSignals = map[*policySignal]bool{}
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"cleanPolicySignals",
"(",
")",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"for",
"w",
":=",
"range",
"e",
".",
"policyRevisionSignals",
"{",
"w",
".",
"done",
"(",
"now",
")",
"\n",
"close",
"(",
"w",
".",
"ch",
")",
"\n",
"}",
"\n",
"e",
".",
"policyRevisionSignals",
"=",
"map",
"[",
"*",
"policySignal",
"]",
"bool",
"{",
"}",
"\n",
"}"
] | // cleanPolicySignals closes and removes all policy revision signals. | [
"cleanPolicySignals",
"closes",
"and",
"removes",
"all",
"policy",
"revision",
"signals",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L2107-L2114 |
163,164 | cilium/cilium | pkg/endpoint/endpoint.go | IPs | func (e *Endpoint) IPs() []net.IP {
ips := []net.IP{}
if e.IPv4.IsSet() {
ips = append(ips, e.IPv4.IP())
}
if e.IPv6.IsSet() {
ips = append(ips, e.IPv6.IP())
}
return ips
} | go | func (e *Endpoint) IPs() []net.IP {
ips := []net.IP{}
if e.IPv4.IsSet() {
ips = append(ips, e.IPv4.IP())
}
if e.IPv6.IsSet() {
ips = append(ips, e.IPv6.IP())
}
return ips
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"IPs",
"(",
")",
"[",
"]",
"net",
".",
"IP",
"{",
"ips",
":=",
"[",
"]",
"net",
".",
"IP",
"{",
"}",
"\n",
"if",
"e",
".",
"IPv4",
".",
"IsSet",
"(",
")",
"{",
"ips",
"=",
"append",
"(",
"ips",
",",
"e",
".",
"IPv4",
".",
"IP",
"(",
")",
")",
"\n",
"}",
"\n",
"if",
"e",
".",
"IPv6",
".",
"IsSet",
"(",
")",
"{",
"ips",
"=",
"append",
"(",
"ips",
",",
"e",
".",
"IPv6",
".",
"IP",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"ips",
"\n",
"}"
] | // IPs returns the slice of valid IPs for this endpoint. | [
"IPs",
"returns",
"the",
"slice",
"of",
"valid",
"IPs",
"for",
"this",
"endpoint",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L2163-L2172 |
163,165 | cilium/cilium | pkg/endpoint/endpoint.go | IsDisconnecting | func (e *Endpoint) IsDisconnecting() bool {
return e.state == StateDisconnected || e.state == StateDisconnecting
} | go | func (e *Endpoint) IsDisconnecting() bool {
return e.state == StateDisconnected || e.state == StateDisconnecting
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"IsDisconnecting",
"(",
")",
"bool",
"{",
"return",
"e",
".",
"state",
"==",
"StateDisconnected",
"||",
"e",
".",
"state",
"==",
"StateDisconnecting",
"\n",
"}"
] | // IsDisconnecting returns true if the endpoint is being disconnected or
// already disconnected
//
// This function must be called after re-aquiring the endpoint mutex to verify
// that the endpoint has not been removed in the meantime.
//
// endpoint.mutex must be held in read mode at least | [
"IsDisconnecting",
"returns",
"true",
"if",
"the",
"endpoint",
"is",
"being",
"disconnected",
"or",
"already",
"disconnected",
"This",
"function",
"must",
"be",
"called",
"after",
"re",
"-",
"aquiring",
"the",
"endpoint",
"mutex",
"to",
"verify",
"that",
"the",
"endpoint",
"has",
"not",
"been",
"removed",
"in",
"the",
"meantime",
".",
"endpoint",
".",
"mutex",
"must",
"be",
"held",
"in",
"read",
"mode",
"at",
"least"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L2187-L2189 |
163,166 | cilium/cilium | pkg/endpoint/endpoint.go | PinDatapathMap | func (e *Endpoint) PinDatapathMap() error {
if e.DatapathMapID == 0 {
return nil
}
mapFd, err := bpf.MapFdFromID(e.DatapathMapID)
if err != nil {
return err
}
defer unix.Close(mapFd)
err = bpf.ObjPin(mapFd, e.BPFIpvlanMapPath())
if err == nil {
e.isDatapathMapPinned = true
}
return err
} | go | func (e *Endpoint) PinDatapathMap() error {
if e.DatapathMapID == 0 {
return nil
}
mapFd, err := bpf.MapFdFromID(e.DatapathMapID)
if err != nil {
return err
}
defer unix.Close(mapFd)
err = bpf.ObjPin(mapFd, e.BPFIpvlanMapPath())
if err == nil {
e.isDatapathMapPinned = true
}
return err
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"PinDatapathMap",
"(",
")",
"error",
"{",
"if",
"e",
".",
"DatapathMapID",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"mapFd",
",",
"err",
":=",
"bpf",
".",
"MapFdFromID",
"(",
"e",
".",
"DatapathMapID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"unix",
".",
"Close",
"(",
"mapFd",
")",
"\n\n",
"err",
"=",
"bpf",
".",
"ObjPin",
"(",
"mapFd",
",",
"e",
".",
"BPFIpvlanMapPath",
"(",
")",
")",
"\n\n",
"if",
"err",
"==",
"nil",
"{",
"e",
".",
"isDatapathMapPinned",
"=",
"true",
"\n",
"}",
"\n\n",
"return",
"err",
"\n",
"}"
] | // PinDatapathMap retrieves a file descriptor from the map ID from the API call
// and pins the corresponding map into the BPF file system. | [
"PinDatapathMap",
"retrieves",
"a",
"file",
"descriptor",
"from",
"the",
"map",
"ID",
"from",
"the",
"API",
"call",
"and",
"pins",
"the",
"corresponding",
"map",
"into",
"the",
"BPF",
"file",
"system",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L2193-L2211 |
163,167 | cilium/cilium | pkg/endpoint/endpoint.go | SyncEndpointHeaderFile | func (e *Endpoint) SyncEndpointHeaderFile(owner Owner) error {
if err := e.LockAlive(); err != nil {
// endpoint was removed in the meanwhile, return
return nil
}
defer e.Unlock()
if e.dnsHistoryTrigger == nil {
t, err := trigger.NewTrigger(trigger.Parameters{
Name: "sync_endpoint_header_file",
PrometheusMetrics: false,
MinInterval: 5 * time.Second,
TriggerFunc: func(reasons []string) { e.syncEndpointHeaderFile(owner, reasons) },
})
if err != nil {
return fmt.Errorf(
"Sync Endpoint header file trigger for endpoint cannot be activated: %s",
err)
}
e.dnsHistoryTrigger = t
}
e.dnsHistoryTrigger.Trigger()
return nil
} | go | func (e *Endpoint) SyncEndpointHeaderFile(owner Owner) error {
if err := e.LockAlive(); err != nil {
// endpoint was removed in the meanwhile, return
return nil
}
defer e.Unlock()
if e.dnsHistoryTrigger == nil {
t, err := trigger.NewTrigger(trigger.Parameters{
Name: "sync_endpoint_header_file",
PrometheusMetrics: false,
MinInterval: 5 * time.Second,
TriggerFunc: func(reasons []string) { e.syncEndpointHeaderFile(owner, reasons) },
})
if err != nil {
return fmt.Errorf(
"Sync Endpoint header file trigger for endpoint cannot be activated: %s",
err)
}
e.dnsHistoryTrigger = t
}
e.dnsHistoryTrigger.Trigger()
return nil
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"SyncEndpointHeaderFile",
"(",
"owner",
"Owner",
")",
"error",
"{",
"if",
"err",
":=",
"e",
".",
"LockAlive",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"// endpoint was removed in the meanwhile, return",
"return",
"nil",
"\n",
"}",
"\n",
"defer",
"e",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"e",
".",
"dnsHistoryTrigger",
"==",
"nil",
"{",
"t",
",",
"err",
":=",
"trigger",
".",
"NewTrigger",
"(",
"trigger",
".",
"Parameters",
"{",
"Name",
":",
"\"",
"\"",
",",
"PrometheusMetrics",
":",
"false",
",",
"MinInterval",
":",
"5",
"*",
"time",
".",
"Second",
",",
"TriggerFunc",
":",
"func",
"(",
"reasons",
"[",
"]",
"string",
")",
"{",
"e",
".",
"syncEndpointHeaderFile",
"(",
"owner",
",",
"reasons",
")",
"}",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"e",
".",
"dnsHistoryTrigger",
"=",
"t",
"\n",
"}",
"\n",
"e",
".",
"dnsHistoryTrigger",
".",
"Trigger",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // SyncEndpointHeaderFile it bumps the current DNS History information for the
// endpoint in the lxc_config.h file. | [
"SyncEndpointHeaderFile",
"it",
"bumps",
"the",
"current",
"DNS",
"History",
"information",
"for",
"the",
"endpoint",
"in",
"the",
"lxc_config",
".",
"h",
"file",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/endpoint.go#L2232-L2255 |
163,168 | cilium/cilium | pkg/envoy/sort.go | PortNetworkPolicyRuleLess | func PortNetworkPolicyRuleLess(r1, r2 *cilium.PortNetworkPolicyRule) bool {
// TODO: Support Kafka.
http1, http2 := r1.GetHttpRules(), r2.GetHttpRules()
switch {
case http1 == nil && http2 != nil:
return true
case http1 != nil && http2 == nil:
return false
}
if http1 != nil && http2 != nil {
httpRules1, httpRules2 := http1.HttpRules, http2.HttpRules
switch {
case len(httpRules1) < len(httpRules2):
return true
case len(httpRules1) > len(httpRules2):
return false
}
// Assuming that the slices are sorted.
for idx := range httpRules1 {
httpRule1, httpRule2 := httpRules1[idx], httpRules2[idx]
switch {
case HTTPNetworkPolicyRuleLess(httpRule1, httpRule2):
return true
case HTTPNetworkPolicyRuleLess(httpRule2, httpRule1):
return false
}
}
}
remotePolicies1, remotePolicies2 := r1.RemotePolicies, r2.RemotePolicies
switch {
case len(remotePolicies1) < len(remotePolicies2):
return true
case len(remotePolicies1) > len(remotePolicies2):
return false
}
// Assuming that the slices are sorted.
for idx := range remotePolicies1 {
p1, p2 := remotePolicies1[idx], remotePolicies2[idx]
switch {
case p1 < p2:
return true
case p1 > p2:
return false
}
}
// Elements are equal.
return false
} | go | func PortNetworkPolicyRuleLess(r1, r2 *cilium.PortNetworkPolicyRule) bool {
// TODO: Support Kafka.
http1, http2 := r1.GetHttpRules(), r2.GetHttpRules()
switch {
case http1 == nil && http2 != nil:
return true
case http1 != nil && http2 == nil:
return false
}
if http1 != nil && http2 != nil {
httpRules1, httpRules2 := http1.HttpRules, http2.HttpRules
switch {
case len(httpRules1) < len(httpRules2):
return true
case len(httpRules1) > len(httpRules2):
return false
}
// Assuming that the slices are sorted.
for idx := range httpRules1 {
httpRule1, httpRule2 := httpRules1[idx], httpRules2[idx]
switch {
case HTTPNetworkPolicyRuleLess(httpRule1, httpRule2):
return true
case HTTPNetworkPolicyRuleLess(httpRule2, httpRule1):
return false
}
}
}
remotePolicies1, remotePolicies2 := r1.RemotePolicies, r2.RemotePolicies
switch {
case len(remotePolicies1) < len(remotePolicies2):
return true
case len(remotePolicies1) > len(remotePolicies2):
return false
}
// Assuming that the slices are sorted.
for idx := range remotePolicies1 {
p1, p2 := remotePolicies1[idx], remotePolicies2[idx]
switch {
case p1 < p2:
return true
case p1 > p2:
return false
}
}
// Elements are equal.
return false
} | [
"func",
"PortNetworkPolicyRuleLess",
"(",
"r1",
",",
"r2",
"*",
"cilium",
".",
"PortNetworkPolicyRule",
")",
"bool",
"{",
"// TODO: Support Kafka.",
"http1",
",",
"http2",
":=",
"r1",
".",
"GetHttpRules",
"(",
")",
",",
"r2",
".",
"GetHttpRules",
"(",
")",
"\n",
"switch",
"{",
"case",
"http1",
"==",
"nil",
"&&",
"http2",
"!=",
"nil",
":",
"return",
"true",
"\n",
"case",
"http1",
"!=",
"nil",
"&&",
"http2",
"==",
"nil",
":",
"return",
"false",
"\n",
"}",
"\n\n",
"if",
"http1",
"!=",
"nil",
"&&",
"http2",
"!=",
"nil",
"{",
"httpRules1",
",",
"httpRules2",
":=",
"http1",
".",
"HttpRules",
",",
"http2",
".",
"HttpRules",
"\n",
"switch",
"{",
"case",
"len",
"(",
"httpRules1",
")",
"<",
"len",
"(",
"httpRules2",
")",
":",
"return",
"true",
"\n",
"case",
"len",
"(",
"httpRules1",
")",
">",
"len",
"(",
"httpRules2",
")",
":",
"return",
"false",
"\n",
"}",
"\n",
"// Assuming that the slices are sorted.",
"for",
"idx",
":=",
"range",
"httpRules1",
"{",
"httpRule1",
",",
"httpRule2",
":=",
"httpRules1",
"[",
"idx",
"]",
",",
"httpRules2",
"[",
"idx",
"]",
"\n",
"switch",
"{",
"case",
"HTTPNetworkPolicyRuleLess",
"(",
"httpRule1",
",",
"httpRule2",
")",
":",
"return",
"true",
"\n",
"case",
"HTTPNetworkPolicyRuleLess",
"(",
"httpRule2",
",",
"httpRule1",
")",
":",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"remotePolicies1",
",",
"remotePolicies2",
":=",
"r1",
".",
"RemotePolicies",
",",
"r2",
".",
"RemotePolicies",
"\n",
"switch",
"{",
"case",
"len",
"(",
"remotePolicies1",
")",
"<",
"len",
"(",
"remotePolicies2",
")",
":",
"return",
"true",
"\n",
"case",
"len",
"(",
"remotePolicies1",
")",
">",
"len",
"(",
"remotePolicies2",
")",
":",
"return",
"false",
"\n",
"}",
"\n",
"// Assuming that the slices are sorted.",
"for",
"idx",
":=",
"range",
"remotePolicies1",
"{",
"p1",
",",
"p2",
":=",
"remotePolicies1",
"[",
"idx",
"]",
",",
"remotePolicies2",
"[",
"idx",
"]",
"\n",
"switch",
"{",
"case",
"p1",
"<",
"p2",
":",
"return",
"true",
"\n",
"case",
"p1",
">",
"p2",
":",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Elements are equal.",
"return",
"false",
"\n",
"}"
] | // PortNetworkPolicyRuleLess reports whether the r1 rule should sort before
// the r2 rule.
// L3-L4-only rules are less than L7 rules. | [
"PortNetworkPolicyRuleLess",
"reports",
"whether",
"the",
"r1",
"rule",
"should",
"sort",
"before",
"the",
"r2",
"rule",
".",
"L3",
"-",
"L4",
"-",
"only",
"rules",
"are",
"less",
"than",
"L7",
"rules",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/sort.go#L87-L138 |
163,169 | cilium/cilium | pkg/envoy/sort.go | HTTPNetworkPolicyRuleLess | func HTTPNetworkPolicyRuleLess(r1, r2 *cilium.HttpNetworkPolicyRule) bool {
headers1, headers2 := r1.Headers, r2.Headers
switch {
case len(headers1) < len(headers2):
return true
case len(headers1) > len(headers2):
return false
}
// Assuming that the slices are sorted.
for idx := range headers1 {
header1, header2 := headers1[idx], headers2[idx]
switch {
case HeaderMatcherLess(header1, header2):
return true
case HeaderMatcherLess(header2, header1):
return false
}
}
// Elements are equal.
return false
} | go | func HTTPNetworkPolicyRuleLess(r1, r2 *cilium.HttpNetworkPolicyRule) bool {
headers1, headers2 := r1.Headers, r2.Headers
switch {
case len(headers1) < len(headers2):
return true
case len(headers1) > len(headers2):
return false
}
// Assuming that the slices are sorted.
for idx := range headers1 {
header1, header2 := headers1[idx], headers2[idx]
switch {
case HeaderMatcherLess(header1, header2):
return true
case HeaderMatcherLess(header2, header1):
return false
}
}
// Elements are equal.
return false
} | [
"func",
"HTTPNetworkPolicyRuleLess",
"(",
"r1",
",",
"r2",
"*",
"cilium",
".",
"HttpNetworkPolicyRule",
")",
"bool",
"{",
"headers1",
",",
"headers2",
":=",
"r1",
".",
"Headers",
",",
"r2",
".",
"Headers",
"\n",
"switch",
"{",
"case",
"len",
"(",
"headers1",
")",
"<",
"len",
"(",
"headers2",
")",
":",
"return",
"true",
"\n",
"case",
"len",
"(",
"headers1",
")",
">",
"len",
"(",
"headers2",
")",
":",
"return",
"false",
"\n",
"}",
"\n",
"// Assuming that the slices are sorted.",
"for",
"idx",
":=",
"range",
"headers1",
"{",
"header1",
",",
"header2",
":=",
"headers1",
"[",
"idx",
"]",
",",
"headers2",
"[",
"idx",
"]",
"\n",
"switch",
"{",
"case",
"HeaderMatcherLess",
"(",
"header1",
",",
"header2",
")",
":",
"return",
"true",
"\n",
"case",
"HeaderMatcherLess",
"(",
"header2",
",",
"header1",
")",
":",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Elements are equal.",
"return",
"false",
"\n",
"}"
] | // HTTPNetworkPolicyRuleLess reports whether the r1 rule should sort before the
// r2 rule. | [
"HTTPNetworkPolicyRuleLess",
"reports",
"whether",
"the",
"r1",
"rule",
"should",
"sort",
"before",
"the",
"r2",
"rule",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/sort.go#L163-L184 |
163,170 | cilium/cilium | pkg/envoy/sort.go | HeaderMatcherLess | func HeaderMatcherLess(m1, m2 *envoy_api_v2_route.HeaderMatcher) bool {
switch {
case m1.Name < m2.Name:
return true
case m1.Name > m2.Name:
return false
}
// Compare the header_match_specifier oneof field, by comparing each
// possible field in the oneof individually:
// - exactMatch
// - regexMatch
// - rangeMatch
// - presentMatch
// - prefixMatch
// - suffixMatch
// Use the getters to access the fields and return zero values when they
// are not set.
s1 := m1.GetExactMatch()
s2 := m2.GetExactMatch()
switch {
case s1 < s2:
return true
case s1 > s2:
return false
}
s1 = m1.GetRegexMatch()
s2 = m2.GetRegexMatch()
switch {
case s1 < s2:
return true
case s1 > s2:
return false
}
rm1 := m1.GetRangeMatch()
rm2 := m2.GetRangeMatch()
switch {
case rm1 == nil && rm2 != nil:
return true
case rm1 != nil && rm2 == nil:
return false
case rm1 != nil && rm2 != nil:
switch {
case rm1.Start < rm2.Start:
return true
case rm1.Start > rm2.Start:
return false
}
switch {
case rm1.End < rm2.End:
return true
case rm1.End > rm2.End:
return false
}
}
switch {
case !m1.GetPresentMatch() && m2.GetPresentMatch():
return true
case m1.GetPresentMatch() && !m2.GetPresentMatch():
return false
}
s1 = m1.GetPrefixMatch()
s2 = m2.GetPrefixMatch()
switch {
case s1 < s2:
return true
case s1 > s2:
return false
}
s1 = m1.GetSuffixMatch()
s2 = m2.GetSuffixMatch()
switch {
case s1 < s2:
return true
case s1 > s2:
return false
}
switch {
case !m1.InvertMatch && m2.InvertMatch:
return true
case m1.InvertMatch && !m2.InvertMatch:
return false
}
// Elements are equal.
return false
} | go | func HeaderMatcherLess(m1, m2 *envoy_api_v2_route.HeaderMatcher) bool {
switch {
case m1.Name < m2.Name:
return true
case m1.Name > m2.Name:
return false
}
// Compare the header_match_specifier oneof field, by comparing each
// possible field in the oneof individually:
// - exactMatch
// - regexMatch
// - rangeMatch
// - presentMatch
// - prefixMatch
// - suffixMatch
// Use the getters to access the fields and return zero values when they
// are not set.
s1 := m1.GetExactMatch()
s2 := m2.GetExactMatch()
switch {
case s1 < s2:
return true
case s1 > s2:
return false
}
s1 = m1.GetRegexMatch()
s2 = m2.GetRegexMatch()
switch {
case s1 < s2:
return true
case s1 > s2:
return false
}
rm1 := m1.GetRangeMatch()
rm2 := m2.GetRangeMatch()
switch {
case rm1 == nil && rm2 != nil:
return true
case rm1 != nil && rm2 == nil:
return false
case rm1 != nil && rm2 != nil:
switch {
case rm1.Start < rm2.Start:
return true
case rm1.Start > rm2.Start:
return false
}
switch {
case rm1.End < rm2.End:
return true
case rm1.End > rm2.End:
return false
}
}
switch {
case !m1.GetPresentMatch() && m2.GetPresentMatch():
return true
case m1.GetPresentMatch() && !m2.GetPresentMatch():
return false
}
s1 = m1.GetPrefixMatch()
s2 = m2.GetPrefixMatch()
switch {
case s1 < s2:
return true
case s1 > s2:
return false
}
s1 = m1.GetSuffixMatch()
s2 = m2.GetSuffixMatch()
switch {
case s1 < s2:
return true
case s1 > s2:
return false
}
switch {
case !m1.InvertMatch && m2.InvertMatch:
return true
case m1.InvertMatch && !m2.InvertMatch:
return false
}
// Elements are equal.
return false
} | [
"func",
"HeaderMatcherLess",
"(",
"m1",
",",
"m2",
"*",
"envoy_api_v2_route",
".",
"HeaderMatcher",
")",
"bool",
"{",
"switch",
"{",
"case",
"m1",
".",
"Name",
"<",
"m2",
".",
"Name",
":",
"return",
"true",
"\n",
"case",
"m1",
".",
"Name",
">",
"m2",
".",
"Name",
":",
"return",
"false",
"\n",
"}",
"\n\n",
"// Compare the header_match_specifier oneof field, by comparing each",
"// possible field in the oneof individually:",
"// - exactMatch",
"// - regexMatch",
"// - rangeMatch",
"// - presentMatch",
"// - prefixMatch",
"// - suffixMatch",
"// Use the getters to access the fields and return zero values when they",
"// are not set.",
"s1",
":=",
"m1",
".",
"GetExactMatch",
"(",
")",
"\n",
"s2",
":=",
"m2",
".",
"GetExactMatch",
"(",
")",
"\n",
"switch",
"{",
"case",
"s1",
"<",
"s2",
":",
"return",
"true",
"\n",
"case",
"s1",
">",
"s2",
":",
"return",
"false",
"\n",
"}",
"\n\n",
"s1",
"=",
"m1",
".",
"GetRegexMatch",
"(",
")",
"\n",
"s2",
"=",
"m2",
".",
"GetRegexMatch",
"(",
")",
"\n",
"switch",
"{",
"case",
"s1",
"<",
"s2",
":",
"return",
"true",
"\n",
"case",
"s1",
">",
"s2",
":",
"return",
"false",
"\n",
"}",
"\n\n",
"rm1",
":=",
"m1",
".",
"GetRangeMatch",
"(",
")",
"\n",
"rm2",
":=",
"m2",
".",
"GetRangeMatch",
"(",
")",
"\n",
"switch",
"{",
"case",
"rm1",
"==",
"nil",
"&&",
"rm2",
"!=",
"nil",
":",
"return",
"true",
"\n",
"case",
"rm1",
"!=",
"nil",
"&&",
"rm2",
"==",
"nil",
":",
"return",
"false",
"\n",
"case",
"rm1",
"!=",
"nil",
"&&",
"rm2",
"!=",
"nil",
":",
"switch",
"{",
"case",
"rm1",
".",
"Start",
"<",
"rm2",
".",
"Start",
":",
"return",
"true",
"\n",
"case",
"rm1",
".",
"Start",
">",
"rm2",
".",
"Start",
":",
"return",
"false",
"\n",
"}",
"\n",
"switch",
"{",
"case",
"rm1",
".",
"End",
"<",
"rm2",
".",
"End",
":",
"return",
"true",
"\n",
"case",
"rm1",
".",
"End",
">",
"rm2",
".",
"End",
":",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n\n",
"switch",
"{",
"case",
"!",
"m1",
".",
"GetPresentMatch",
"(",
")",
"&&",
"m2",
".",
"GetPresentMatch",
"(",
")",
":",
"return",
"true",
"\n",
"case",
"m1",
".",
"GetPresentMatch",
"(",
")",
"&&",
"!",
"m2",
".",
"GetPresentMatch",
"(",
")",
":",
"return",
"false",
"\n",
"}",
"\n\n",
"s1",
"=",
"m1",
".",
"GetPrefixMatch",
"(",
")",
"\n",
"s2",
"=",
"m2",
".",
"GetPrefixMatch",
"(",
")",
"\n",
"switch",
"{",
"case",
"s1",
"<",
"s2",
":",
"return",
"true",
"\n",
"case",
"s1",
">",
"s2",
":",
"return",
"false",
"\n",
"}",
"\n\n",
"s1",
"=",
"m1",
".",
"GetSuffixMatch",
"(",
")",
"\n",
"s2",
"=",
"m2",
".",
"GetSuffixMatch",
"(",
")",
"\n",
"switch",
"{",
"case",
"s1",
"<",
"s2",
":",
"return",
"true",
"\n",
"case",
"s1",
">",
"s2",
":",
"return",
"false",
"\n",
"}",
"\n\n",
"switch",
"{",
"case",
"!",
"m1",
".",
"InvertMatch",
"&&",
"m2",
".",
"InvertMatch",
":",
"return",
"true",
"\n",
"case",
"m1",
".",
"InvertMatch",
"&&",
"!",
"m2",
".",
"InvertMatch",
":",
"return",
"false",
"\n",
"}",
"\n\n",
"// Elements are equal.",
"return",
"false",
"\n",
"}"
] | // HeaderMatcherLess reports whether the m1 matcher should sort before the m2
// matcher. | [
"HeaderMatcherLess",
"reports",
"whether",
"the",
"m1",
"matcher",
"should",
"sort",
"before",
"the",
"m2",
"matcher",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/sort.go#L209-L302 |
163,171 | cilium/cilium | pkg/maps/metricsmap/metricsmap.go | String | func (k *Key) String() string {
return fmt.Sprintf("reason:%d dir:%d", k.Reason, k.Dir)
} | go | func (k *Key) String() string {
return fmt.Sprintf("reason:%d dir:%d", k.Reason, k.Dir)
} | [
"func",
"(",
"k",
"*",
"Key",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"k",
".",
"Reason",
",",
"k",
".",
"Dir",
")",
"\n",
"}"
] | // String converts the key into a human readable string format | [
"String",
"converts",
"the",
"key",
"into",
"a",
"human",
"readable",
"string",
"format"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/metricsmap/metricsmap.go#L81-L83 |
163,172 | cilium/cilium | pkg/maps/metricsmap/metricsmap.go | Direction | func (k *Key) Direction() string {
switch k.Dir {
case dirIngress:
return direction[k.Dir]
case dirEgress:
return direction[k.Dir]
}
return direction[dirUnknown]
} | go | func (k *Key) Direction() string {
switch k.Dir {
case dirIngress:
return direction[k.Dir]
case dirEgress:
return direction[k.Dir]
}
return direction[dirUnknown]
} | [
"func",
"(",
"k",
"*",
"Key",
")",
"Direction",
"(",
")",
"string",
"{",
"switch",
"k",
".",
"Dir",
"{",
"case",
"dirIngress",
":",
"return",
"direction",
"[",
"k",
".",
"Dir",
"]",
"\n",
"case",
"dirEgress",
":",
"return",
"direction",
"[",
"k",
".",
"Dir",
"]",
"\n",
"}",
"\n",
"return",
"direction",
"[",
"dirUnknown",
"]",
"\n",
"}"
] | // Direction gets the direction in human readable string format | [
"Direction",
"gets",
"the",
"direction",
"in",
"human",
"readable",
"string",
"format"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/metricsmap/metricsmap.go#L86-L94 |
163,173 | cilium/cilium | pkg/maps/metricsmap/metricsmap.go | String | func (v *Value) String() string {
return fmt.Sprintf("count:%d bytes:%d", v.Count, v.Bytes)
} | go | func (v *Value) String() string {
return fmt.Sprintf("count:%d bytes:%d", v.Count, v.Bytes)
} | [
"func",
"(",
"v",
"*",
"Value",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"v",
".",
"Count",
",",
"v",
".",
"Bytes",
")",
"\n",
"}"
] | // String converts the value into a human readable string format | [
"String",
"converts",
"the",
"value",
"into",
"a",
"human",
"readable",
"string",
"format"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/metricsmap/metricsmap.go#L105-L107 |
163,174 | cilium/cilium | pkg/maps/metricsmap/metricsmap.go | updatePrometheusMetrics | func updatePrometheusMetrics(key *Key, val *Value) {
updateMetric(func() (prometheus.Counter, error) {
if key.IsDrop() {
return metrics.DropCount.GetMetricWithLabelValues(key.DropForwardReason(), key.Direction())
}
return metrics.ForwardCount.GetMetricWithLabelValues(key.Direction())
}, val.CountFloat())
updateMetric(func() (prometheus.Counter, error) {
if key.IsDrop() {
return metrics.DropBytes.GetMetricWithLabelValues(key.DropForwardReason(), key.Direction())
}
return metrics.ForwardBytes.GetMetricWithLabelValues(key.Direction())
}, val.bytesFloat())
} | go | func updatePrometheusMetrics(key *Key, val *Value) {
updateMetric(func() (prometheus.Counter, error) {
if key.IsDrop() {
return metrics.DropCount.GetMetricWithLabelValues(key.DropForwardReason(), key.Direction())
}
return metrics.ForwardCount.GetMetricWithLabelValues(key.Direction())
}, val.CountFloat())
updateMetric(func() (prometheus.Counter, error) {
if key.IsDrop() {
return metrics.DropBytes.GetMetricWithLabelValues(key.DropForwardReason(), key.Direction())
}
return metrics.ForwardBytes.GetMetricWithLabelValues(key.Direction())
}, val.bytesFloat())
} | [
"func",
"updatePrometheusMetrics",
"(",
"key",
"*",
"Key",
",",
"val",
"*",
"Value",
")",
"{",
"updateMetric",
"(",
"func",
"(",
")",
"(",
"prometheus",
".",
"Counter",
",",
"error",
")",
"{",
"if",
"key",
".",
"IsDrop",
"(",
")",
"{",
"return",
"metrics",
".",
"DropCount",
".",
"GetMetricWithLabelValues",
"(",
"key",
".",
"DropForwardReason",
"(",
")",
",",
"key",
".",
"Direction",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"metrics",
".",
"ForwardCount",
".",
"GetMetricWithLabelValues",
"(",
"key",
".",
"Direction",
"(",
")",
")",
"\n",
"}",
",",
"val",
".",
"CountFloat",
"(",
")",
")",
"\n\n",
"updateMetric",
"(",
"func",
"(",
")",
"(",
"prometheus",
".",
"Counter",
",",
"error",
")",
"{",
"if",
"key",
".",
"IsDrop",
"(",
")",
"{",
"return",
"metrics",
".",
"DropBytes",
".",
"GetMetricWithLabelValues",
"(",
"key",
".",
"DropForwardReason",
"(",
")",
",",
"key",
".",
"Direction",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"metrics",
".",
"ForwardBytes",
".",
"GetMetricWithLabelValues",
"(",
"key",
".",
"Direction",
"(",
")",
")",
"\n",
"}",
",",
"val",
".",
"bytesFloat",
"(",
")",
")",
"\n",
"}"
] | // updatePrometheusMetrics checks the metricsmap key value pair
// and determines which prometheus metrics along with respective labels
// need to be updated. | [
"updatePrometheusMetrics",
"checks",
"the",
"metricsmap",
"key",
"value",
"pair",
"and",
"determines",
"which",
"prometheus",
"metrics",
"along",
"with",
"respective",
"labels",
"need",
"to",
"be",
"updated",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/metricsmap/metricsmap.go#L159-L173 |
163,175 | cilium/cilium | pkg/policy/api/fqdn.go | sanitize | func (s *FQDNSelector) sanitize() error {
if len(s.MatchName) > 0 && !allowedMatchNameChars.MatchString(s.MatchName) {
return fmt.Errorf("Invalid characters in MatchName: \"%s\". Only 0-9, a-z, A-Z and . and - characters are allowed", s.MatchName)
}
if len(s.MatchPattern) > 0 && !allowedPatternChars.MatchString(s.MatchPattern) {
return fmt.Errorf("Invalid characters in MatchPattern: \"%s\". Only 0-9, a-z, A-Z and ., - and * characters are allowed", s.MatchPattern)
}
_, err := matchpattern.Validate(s.MatchPattern)
return err
} | go | func (s *FQDNSelector) sanitize() error {
if len(s.MatchName) > 0 && !allowedMatchNameChars.MatchString(s.MatchName) {
return fmt.Errorf("Invalid characters in MatchName: \"%s\". Only 0-9, a-z, A-Z and . and - characters are allowed", s.MatchName)
}
if len(s.MatchPattern) > 0 && !allowedPatternChars.MatchString(s.MatchPattern) {
return fmt.Errorf("Invalid characters in MatchPattern: \"%s\". Only 0-9, a-z, A-Z and ., - and * characters are allowed", s.MatchPattern)
}
_, err := matchpattern.Validate(s.MatchPattern)
return err
} | [
"func",
"(",
"s",
"*",
"FQDNSelector",
")",
"sanitize",
"(",
")",
"error",
"{",
"if",
"len",
"(",
"s",
".",
"MatchName",
")",
">",
"0",
"&&",
"!",
"allowedMatchNameChars",
".",
"MatchString",
"(",
"s",
".",
"MatchName",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"s",
".",
"MatchName",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"s",
".",
"MatchPattern",
")",
">",
"0",
"&&",
"!",
"allowedPatternChars",
".",
"MatchString",
"(",
"s",
".",
"MatchPattern",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"s",
".",
"MatchPattern",
")",
"\n",
"}",
"\n",
"_",
",",
"err",
":=",
"matchpattern",
".",
"Validate",
"(",
"s",
".",
"MatchPattern",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // sanitize for FQDNSelector is a little wonky. While we do more processing
// when using MatchName the basic requirement is that is a valid regexp. We
// test that it can compile here. | [
"sanitize",
"for",
"FQDNSelector",
"is",
"a",
"little",
"wonky",
".",
"While",
"we",
"do",
"more",
"processing",
"when",
"using",
"MatchName",
"the",
"basic",
"requirement",
"is",
"that",
"is",
"a",
"valid",
"regexp",
".",
"We",
"test",
"that",
"it",
"can",
"compile",
"here",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/fqdn.go#L60-L70 |
163,176 | cilium/cilium | pkg/policy/api/fqdn.go | Sanitize | func (r *PortRuleDNS) Sanitize() error {
if len(r.MatchName) > 0 && !allowedMatchNameChars.MatchString(r.MatchName) {
return fmt.Errorf("Invalid characters in MatchName: \"%s\". Only 0-9, a-z, A-Z and . and - characters are allowed", r.MatchName)
}
if len(r.MatchPattern) > 0 && !allowedPatternChars.MatchString(r.MatchPattern) {
return fmt.Errorf("Invalid characters in MatchPattern: \"%s\". Only 0-9, a-z, A-Z and ., - and * characters are allowed", r.MatchPattern)
}
_, err := matchpattern.Validate(r.MatchPattern)
return err
} | go | func (r *PortRuleDNS) Sanitize() error {
if len(r.MatchName) > 0 && !allowedMatchNameChars.MatchString(r.MatchName) {
return fmt.Errorf("Invalid characters in MatchName: \"%s\". Only 0-9, a-z, A-Z and . and - characters are allowed", r.MatchName)
}
if len(r.MatchPattern) > 0 && !allowedPatternChars.MatchString(r.MatchPattern) {
return fmt.Errorf("Invalid characters in MatchPattern: \"%s\". Only 0-9, a-z, A-Z and ., - and * characters are allowed", r.MatchPattern)
}
_, err := matchpattern.Validate(r.MatchPattern)
return err
} | [
"func",
"(",
"r",
"*",
"PortRuleDNS",
")",
"Sanitize",
"(",
")",
"error",
"{",
"if",
"len",
"(",
"r",
".",
"MatchName",
")",
">",
"0",
"&&",
"!",
"allowedMatchNameChars",
".",
"MatchString",
"(",
"r",
".",
"MatchName",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"r",
".",
"MatchName",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"r",
".",
"MatchPattern",
")",
">",
"0",
"&&",
"!",
"allowedPatternChars",
".",
"MatchString",
"(",
"r",
".",
"MatchPattern",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"r",
".",
"MatchPattern",
")",
"\n",
"}",
"\n",
"_",
",",
"err",
":=",
"matchpattern",
".",
"Validate",
"(",
"r",
".",
"MatchPattern",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Sanitize checks that the matchName in the portRule can be compiled as a
// regex. It does not check that a DNS name is a valid DNS name. | [
"Sanitize",
"checks",
"that",
"the",
"matchName",
"in",
"the",
"portRule",
"can",
"be",
"compiled",
"as",
"a",
"regex",
".",
"It",
"does",
"not",
"check",
"that",
"a",
"DNS",
"name",
"is",
"a",
"valid",
"DNS",
"name",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/fqdn.go#L77-L87 |
163,177 | cilium/cilium | pkg/policy/api/fqdn.go | GetAsEndpointSelectors | func (s FQDNSelectorSlice) GetAsEndpointSelectors() EndpointSelectorSlice {
for _, rule := range s {
return rule.GetAsEndpointSelectors()
}
return nil
} | go | func (s FQDNSelectorSlice) GetAsEndpointSelectors() EndpointSelectorSlice {
for _, rule := range s {
return rule.GetAsEndpointSelectors()
}
return nil
} | [
"func",
"(",
"s",
"FQDNSelectorSlice",
")",
"GetAsEndpointSelectors",
"(",
")",
"EndpointSelectorSlice",
"{",
"for",
"_",
",",
"rule",
":=",
"range",
"s",
"{",
"return",
"rule",
".",
"GetAsEndpointSelectors",
"(",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // GetAsEndpointSelectors will return a single EntityNone if any
// toFQDNs rules exist, and a nil slice otherwise. | [
"GetAsEndpointSelectors",
"will",
"return",
"a",
"single",
"EntityNone",
"if",
"any",
"toFQDNs",
"rules",
"exist",
"and",
"a",
"nil",
"slice",
"otherwise",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/fqdn.go#L104-L109 |
163,178 | cilium/cilium | pkg/policy/api/egress.go | GetDestinationEndpointSelectors | func (e *EgressRule) GetDestinationEndpointSelectors() EndpointSelectorSlice {
if e.aggregatedSelectors == nil {
e.SetAggregatedSelectors()
}
return e.aggregatedSelectors
} | go | func (e *EgressRule) GetDestinationEndpointSelectors() EndpointSelectorSlice {
if e.aggregatedSelectors == nil {
e.SetAggregatedSelectors()
}
return e.aggregatedSelectors
} | [
"func",
"(",
"e",
"*",
"EgressRule",
")",
"GetDestinationEndpointSelectors",
"(",
")",
"EndpointSelectorSlice",
"{",
"if",
"e",
".",
"aggregatedSelectors",
"==",
"nil",
"{",
"e",
".",
"SetAggregatedSelectors",
"(",
")",
"\n",
"}",
"\n",
"return",
"e",
".",
"aggregatedSelectors",
"\n",
"}"
] | // GetDestinationEndpointSelectors returns a slice of endpoints selectors
// covering all L3 destination selectors of the egress rule | [
"GetDestinationEndpointSelectors",
"returns",
"a",
"slice",
"of",
"endpoints",
"selectors",
"covering",
"all",
"L3",
"destination",
"selectors",
"of",
"the",
"egress",
"rule"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/egress.go#L172-L177 |
163,179 | cilium/cilium | pkg/policy/api/egress.go | IsLabelBased | func (e *EgressRule) IsLabelBased() bool {
return len(e.ToRequires)+len(e.ToCIDR)+len(e.ToCIDRSet)+len(e.ToServices)+len(e.ToFQDNs) == 0
} | go | func (e *EgressRule) IsLabelBased() bool {
return len(e.ToRequires)+len(e.ToCIDR)+len(e.ToCIDRSet)+len(e.ToServices)+len(e.ToFQDNs) == 0
} | [
"func",
"(",
"e",
"*",
"EgressRule",
")",
"IsLabelBased",
"(",
")",
"bool",
"{",
"return",
"len",
"(",
"e",
".",
"ToRequires",
")",
"+",
"len",
"(",
"e",
".",
"ToCIDR",
")",
"+",
"len",
"(",
"e",
".",
"ToCIDRSet",
")",
"+",
"len",
"(",
"e",
".",
"ToServices",
")",
"+",
"len",
"(",
"e",
".",
"ToFQDNs",
")",
"==",
"0",
"\n",
"}"
] | // IsLabelBased returns true whether the L3 destination endpoints are selected
// based on labels, i.e. either by setting ToEndpoints or ToEntities, or not
// setting any To field. | [
"IsLabelBased",
"returns",
"true",
"whether",
"the",
"L3",
"destination",
"endpoints",
"are",
"selected",
"based",
"on",
"labels",
"i",
".",
"e",
".",
"either",
"by",
"setting",
"ToEndpoints",
"or",
"ToEntities",
"or",
"not",
"setting",
"any",
"To",
"field",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/egress.go#L182-L184 |
163,180 | cilium/cilium | pkg/policy/api/egress.go | CreateDerivative | func (e *EgressRule) CreateDerivative() (*EgressRule, error) {
newRule := e.DeepCopy()
if !e.RequiresDerivative() {
return newRule, nil
}
newRule.ToCIDRSet = CIDRRuleSlice{}
for _, group := range e.ToGroups {
cidrSet, err := group.GetCidrSet()
if err != nil {
return &EgressRule{}, err
}
if len(cidrSet) == 0 {
return &EgressRule{}, nil
}
newRule.ToCIDRSet = append(e.ToCIDRSet, cidrSet...)
}
newRule.ToGroups = nil
e.SetAggregatedSelectors()
return newRule, nil
} | go | func (e *EgressRule) CreateDerivative() (*EgressRule, error) {
newRule := e.DeepCopy()
if !e.RequiresDerivative() {
return newRule, nil
}
newRule.ToCIDRSet = CIDRRuleSlice{}
for _, group := range e.ToGroups {
cidrSet, err := group.GetCidrSet()
if err != nil {
return &EgressRule{}, err
}
if len(cidrSet) == 0 {
return &EgressRule{}, nil
}
newRule.ToCIDRSet = append(e.ToCIDRSet, cidrSet...)
}
newRule.ToGroups = nil
e.SetAggregatedSelectors()
return newRule, nil
} | [
"func",
"(",
"e",
"*",
"EgressRule",
")",
"CreateDerivative",
"(",
")",
"(",
"*",
"EgressRule",
",",
"error",
")",
"{",
"newRule",
":=",
"e",
".",
"DeepCopy",
"(",
")",
"\n",
"if",
"!",
"e",
".",
"RequiresDerivative",
"(",
")",
"{",
"return",
"newRule",
",",
"nil",
"\n",
"}",
"\n",
"newRule",
".",
"ToCIDRSet",
"=",
"CIDRRuleSlice",
"{",
"}",
"\n",
"for",
"_",
",",
"group",
":=",
"range",
"e",
".",
"ToGroups",
"{",
"cidrSet",
",",
"err",
":=",
"group",
".",
"GetCidrSet",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"&",
"EgressRule",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"cidrSet",
")",
"==",
"0",
"{",
"return",
"&",
"EgressRule",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n",
"newRule",
".",
"ToCIDRSet",
"=",
"append",
"(",
"e",
".",
"ToCIDRSet",
",",
"cidrSet",
"...",
")",
"\n",
"}",
"\n",
"newRule",
".",
"ToGroups",
"=",
"nil",
"\n",
"e",
".",
"SetAggregatedSelectors",
"(",
")",
"\n",
"return",
"newRule",
",",
"nil",
"\n",
"}"
] | // CreateDerivative will return a new rule based on the data gathered by the
// rules that creates a new derivative policy.
// In the case of ToGroups will call outside using the groups callback and this
// function can take a bit of time. | [
"CreateDerivative",
"will",
"return",
"a",
"new",
"rule",
"based",
"on",
"the",
"data",
"gathered",
"by",
"the",
"rules",
"that",
"creates",
"a",
"new",
"derivative",
"policy",
".",
"In",
"the",
"case",
"of",
"ToGroups",
"will",
"call",
"outside",
"using",
"the",
"groups",
"callback",
"and",
"this",
"function",
"can",
"take",
"a",
"bit",
"of",
"time",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/egress.go#L196-L215 |
163,181 | cilium/cilium | pkg/maps/ipcache/ipcache.go | NewKey | func NewKey(ip net.IP, mask net.IPMask) Key {
result := Key{}
ones, _ := mask.Size()
if ip4 := ip.To4(); ip4 != nil {
if mask == nil {
ones = net.IPv4len * 8
}
result.Prefixlen = getPrefixLen(ones)
result.Family = bpf.EndpointKeyIPv4
copy(result.IP[:], ip4)
} else {
if mask == nil {
ones = net.IPv6len * 8
}
result.Prefixlen = getPrefixLen(ones)
result.Family = bpf.EndpointKeyIPv6
copy(result.IP[:], ip)
}
return result
} | go | func NewKey(ip net.IP, mask net.IPMask) Key {
result := Key{}
ones, _ := mask.Size()
if ip4 := ip.To4(); ip4 != nil {
if mask == nil {
ones = net.IPv4len * 8
}
result.Prefixlen = getPrefixLen(ones)
result.Family = bpf.EndpointKeyIPv4
copy(result.IP[:], ip4)
} else {
if mask == nil {
ones = net.IPv6len * 8
}
result.Prefixlen = getPrefixLen(ones)
result.Family = bpf.EndpointKeyIPv6
copy(result.IP[:], ip)
}
return result
} | [
"func",
"NewKey",
"(",
"ip",
"net",
".",
"IP",
",",
"mask",
"net",
".",
"IPMask",
")",
"Key",
"{",
"result",
":=",
"Key",
"{",
"}",
"\n\n",
"ones",
",",
"_",
":=",
"mask",
".",
"Size",
"(",
")",
"\n",
"if",
"ip4",
":=",
"ip",
".",
"To4",
"(",
")",
";",
"ip4",
"!=",
"nil",
"{",
"if",
"mask",
"==",
"nil",
"{",
"ones",
"=",
"net",
".",
"IPv4len",
"*",
"8",
"\n",
"}",
"\n",
"result",
".",
"Prefixlen",
"=",
"getPrefixLen",
"(",
"ones",
")",
"\n",
"result",
".",
"Family",
"=",
"bpf",
".",
"EndpointKeyIPv4",
"\n",
"copy",
"(",
"result",
".",
"IP",
"[",
":",
"]",
",",
"ip4",
")",
"\n",
"}",
"else",
"{",
"if",
"mask",
"==",
"nil",
"{",
"ones",
"=",
"net",
".",
"IPv6len",
"*",
"8",
"\n",
"}",
"\n",
"result",
".",
"Prefixlen",
"=",
"getPrefixLen",
"(",
"ones",
")",
"\n",
"result",
".",
"Family",
"=",
"bpf",
".",
"EndpointKeyIPv6",
"\n",
"copy",
"(",
"result",
".",
"IP",
"[",
":",
"]",
",",
"ip",
")",
"\n",
"}",
"\n\n",
"return",
"result",
"\n",
"}"
] | // NewKey returns an Key based on the provided IP address and mask. The address
// family is automatically detected | [
"NewKey",
"returns",
"an",
"Key",
"based",
"on",
"the",
"provided",
"IP",
"address",
"and",
"mask",
".",
"The",
"address",
"family",
"is",
"automatically",
"detected"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/ipcache/ipcache.go#L103-L124 |
163,182 | cilium/cilium | pkg/maps/ipcache/ipcache.go | Delete | func (m *Map) Delete(k bpf.MapKey) error {
_, err := m.delete(k, true)
return err
} | go | func (m *Map) Delete(k bpf.MapKey) error {
_, err := m.delete(k, true)
return err
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"Delete",
"(",
"k",
"bpf",
".",
"MapKey",
")",
"error",
"{",
"_",
",",
"err",
":=",
"m",
".",
"delete",
"(",
"k",
",",
"true",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Delete removes a key from the ipcache BPF map | [
"Delete",
"removes",
"a",
"key",
"from",
"the",
"ipcache",
"BPF",
"map"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/ipcache/ipcache.go#L199-L202 |
163,183 | cilium/cilium | pkg/maps/ipcache/ipcache.go | GetMaxPrefixLengths | func (m *Map) GetMaxPrefixLengths(ipv6 bool) (count int) {
if IPCache.MapType == bpf.BPF_MAP_TYPE_LPM_TRIE {
if ipv6 {
return net.IPv6len*8 + 1
} else {
return net.IPv4len*8 + 1
}
}
if ipv6 {
return maxPrefixLengths6
}
return maxPrefixLengths4
} | go | func (m *Map) GetMaxPrefixLengths(ipv6 bool) (count int) {
if IPCache.MapType == bpf.BPF_MAP_TYPE_LPM_TRIE {
if ipv6 {
return net.IPv6len*8 + 1
} else {
return net.IPv4len*8 + 1
}
}
if ipv6 {
return maxPrefixLengths6
}
return maxPrefixLengths4
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"GetMaxPrefixLengths",
"(",
"ipv6",
"bool",
")",
"(",
"count",
"int",
")",
"{",
"if",
"IPCache",
".",
"MapType",
"==",
"bpf",
".",
"BPF_MAP_TYPE_LPM_TRIE",
"{",
"if",
"ipv6",
"{",
"return",
"net",
".",
"IPv6len",
"*",
"8",
"+",
"1",
"\n",
"}",
"else",
"{",
"return",
"net",
".",
"IPv4len",
"*",
"8",
"+",
"1",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"ipv6",
"{",
"return",
"maxPrefixLengths6",
"\n",
"}",
"\n",
"return",
"maxPrefixLengths4",
"\n",
"}"
] | // GetMaxPrefixLengths determines how many unique prefix lengths are supported
// simultaneously based on the underlying BPF map type in use. | [
"GetMaxPrefixLengths",
"determines",
"how",
"many",
"unique",
"prefix",
"lengths",
"are",
"supported",
"simultaneously",
"based",
"on",
"the",
"underlying",
"BPF",
"map",
"type",
"in",
"use",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/ipcache/ipcache.go#L206-L218 |
163,184 | cilium/cilium | api/v1/server/restapi/policy/get_identity_endpoints.go | NewGetIdentityEndpoints | func NewGetIdentityEndpoints(ctx *middleware.Context, handler GetIdentityEndpointsHandler) *GetIdentityEndpoints {
return &GetIdentityEndpoints{Context: ctx, Handler: handler}
} | go | func NewGetIdentityEndpoints(ctx *middleware.Context, handler GetIdentityEndpointsHandler) *GetIdentityEndpoints {
return &GetIdentityEndpoints{Context: ctx, Handler: handler}
} | [
"func",
"NewGetIdentityEndpoints",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"GetIdentityEndpointsHandler",
")",
"*",
"GetIdentityEndpoints",
"{",
"return",
"&",
"GetIdentityEndpoints",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewGetIdentityEndpoints creates a new http.Handler for the get identity endpoints operation | [
"NewGetIdentityEndpoints",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"get",
"identity",
"endpoints",
"operation"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/get_identity_endpoints.go#L28-L30 |
163,185 | cilium/cilium | api/v1/models/endpoint_configuration_spec.go | Validate | func (m *EndpointConfigurationSpec) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateLabelConfiguration(formats); err != nil {
res = append(res, err)
}
if err := m.validateOptions(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *EndpointConfigurationSpec) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateLabelConfiguration(formats); err != nil {
res = append(res, err)
}
if err := m.validateOptions(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"EndpointConfigurationSpec",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateLabelConfiguration",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateOptions",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this endpoint configuration spec | [
"Validate",
"validates",
"this",
"endpoint",
"configuration",
"spec"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/endpoint_configuration_spec.go#L27-L42 |
163,186 | cilium/cilium | pkg/kvstore/kvstore.go | GetPrefix | func GetPrefix(ctx context.Context, prefix string) (k string, v []byte, err error) {
k, v, err = Client().GetPrefix(ctx, prefix)
Trace("GetPrefix", err, logrus.Fields{fieldPrefix: prefix, fieldKey: k, fieldValue: string(v)})
return
} | go | func GetPrefix(ctx context.Context, prefix string) (k string, v []byte, err error) {
k, v, err = Client().GetPrefix(ctx, prefix)
Trace("GetPrefix", err, logrus.Fields{fieldPrefix: prefix, fieldKey: k, fieldValue: string(v)})
return
} | [
"func",
"GetPrefix",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"(",
"k",
"string",
",",
"v",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"k",
",",
"v",
",",
"err",
"=",
"Client",
"(",
")",
".",
"GetPrefix",
"(",
"ctx",
",",
"prefix",
")",
"\n",
"Trace",
"(",
"\"",
"\"",
",",
"err",
",",
"logrus",
".",
"Fields",
"{",
"fieldPrefix",
":",
"prefix",
",",
"fieldKey",
":",
"k",
",",
"fieldValue",
":",
"string",
"(",
"v",
")",
"}",
")",
"\n",
"return",
"\n",
"}"
] | // GetPrefix returns the first key which matches the prefix and its value. | [
"GetPrefix",
"returns",
"the",
"first",
"key",
"which",
"matches",
"the",
"prefix",
"and",
"its",
"value",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/kvstore.go#L48-L52 |
163,187 | cilium/cilium | pkg/kvstore/kvstore.go | ListPrefix | func ListPrefix(prefix string) (KeyValuePairs, error) {
v, err := Client().ListPrefix(prefix)
Trace("ListPrefix", err, logrus.Fields{fieldPrefix: prefix, fieldNumEntries: len(v)})
return v, err
} | go | func ListPrefix(prefix string) (KeyValuePairs, error) {
v, err := Client().ListPrefix(prefix)
Trace("ListPrefix", err, logrus.Fields{fieldPrefix: prefix, fieldNumEntries: len(v)})
return v, err
} | [
"func",
"ListPrefix",
"(",
"prefix",
"string",
")",
"(",
"KeyValuePairs",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"Client",
"(",
")",
".",
"ListPrefix",
"(",
"prefix",
")",
"\n",
"Trace",
"(",
"\"",
"\"",
",",
"err",
",",
"logrus",
".",
"Fields",
"{",
"fieldPrefix",
":",
"prefix",
",",
"fieldNumEntries",
":",
"len",
"(",
"v",
")",
"}",
")",
"\n",
"return",
"v",
",",
"err",
"\n",
"}"
] | // ListPrefix returns the list of keys matching the prefix | [
"ListPrefix",
"returns",
"the",
"list",
"of",
"keys",
"matching",
"the",
"prefix"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/kvstore.go#L55-L59 |
163,188 | cilium/cilium | pkg/kvstore/kvstore.go | Update | func Update(ctx context.Context, key string, value []byte, lease bool) error {
err := Client().Update(ctx, key, value, lease)
Trace("Update", err, logrus.Fields{fieldKey: key, fieldValue: string(value), fieldAttachLease: lease})
return err
} | go | func Update(ctx context.Context, key string, value []byte, lease bool) error {
err := Client().Update(ctx, key, value, lease)
Trace("Update", err, logrus.Fields{fieldKey: key, fieldValue: string(value), fieldAttachLease: lease})
return err
} | [
"func",
"Update",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"string",
",",
"value",
"[",
"]",
"byte",
",",
"lease",
"bool",
")",
"error",
"{",
"err",
":=",
"Client",
"(",
")",
".",
"Update",
"(",
"ctx",
",",
"key",
",",
"value",
",",
"lease",
")",
"\n",
"Trace",
"(",
"\"",
"\"",
",",
"err",
",",
"logrus",
".",
"Fields",
"{",
"fieldKey",
":",
"key",
",",
"fieldValue",
":",
"string",
"(",
"value",
")",
",",
"fieldAttachLease",
":",
"lease",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Update creates or updates a key value pair | [
"Update",
"creates",
"or",
"updates",
"a",
"key",
"value",
"pair"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/kvstore.go#L73-L77 |
163,189 | cilium/cilium | pkg/kvstore/kvstore.go | Set | func Set(key string, value []byte) error {
err := Client().Set(key, value)
Trace("Set", err, logrus.Fields{fieldKey: key, fieldValue: string(value)})
return err
} | go | func Set(key string, value []byte) error {
err := Client().Set(key, value)
Trace("Set", err, logrus.Fields{fieldKey: key, fieldValue: string(value)})
return err
} | [
"func",
"Set",
"(",
"key",
"string",
",",
"value",
"[",
"]",
"byte",
")",
"error",
"{",
"err",
":=",
"Client",
"(",
")",
".",
"Set",
"(",
"key",
",",
"value",
")",
"\n",
"Trace",
"(",
"\"",
"\"",
",",
"err",
",",
"logrus",
".",
"Fields",
"{",
"fieldKey",
":",
"key",
",",
"fieldValue",
":",
"string",
"(",
"value",
")",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Set sets the value of a key | [
"Set",
"sets",
"the",
"value",
"of",
"a",
"key"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/kvstore.go#L99-L103 |
163,190 | cilium/cilium | pkg/kvstore/kvstore.go | DeletePrefix | func DeletePrefix(prefix string) error {
err := Client().DeletePrefix(prefix)
Trace("DeletePrefix", err, logrus.Fields{fieldPrefix: prefix})
return err
} | go | func DeletePrefix(prefix string) error {
err := Client().DeletePrefix(prefix)
Trace("DeletePrefix", err, logrus.Fields{fieldPrefix: prefix})
return err
} | [
"func",
"DeletePrefix",
"(",
"prefix",
"string",
")",
"error",
"{",
"err",
":=",
"Client",
"(",
")",
".",
"DeletePrefix",
"(",
"prefix",
")",
"\n",
"Trace",
"(",
"\"",
"\"",
",",
"err",
",",
"logrus",
".",
"Fields",
"{",
"fieldPrefix",
":",
"prefix",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // DeletePrefix deletes all keys matching a prefix | [
"DeletePrefix",
"deletes",
"all",
"keys",
"matching",
"a",
"prefix"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/kvstore.go#L113-L117 |
163,191 | cilium/cilium | api/v1/server/restapi/service/delete_service_id.go | NewDeleteServiceID | func NewDeleteServiceID(ctx *middleware.Context, handler DeleteServiceIDHandler) *DeleteServiceID {
return &DeleteServiceID{Context: ctx, Handler: handler}
} | go | func NewDeleteServiceID(ctx *middleware.Context, handler DeleteServiceIDHandler) *DeleteServiceID {
return &DeleteServiceID{Context: ctx, Handler: handler}
} | [
"func",
"NewDeleteServiceID",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"DeleteServiceIDHandler",
")",
"*",
"DeleteServiceID",
"{",
"return",
"&",
"DeleteServiceID",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewDeleteServiceID creates a new http.Handler for the delete service ID operation | [
"NewDeleteServiceID",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"delete",
"service",
"ID",
"operation"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/service/delete_service_id.go#L28-L30 |
163,192 | cilium/cilium | pkg/maps/cidrmap/cidrmap.go | checkPrefixlen | func (cm *CIDRMap) checkPrefixlen(key *cidrKey, operation string) error {
if cm.Prefixlen != 0 &&
((cm.PrefixIsDynamic && cm.Prefixlen < key.Prefixlen) ||
(!cm.PrefixIsDynamic && cm.Prefixlen != key.Prefixlen)) {
return fmt.Errorf("Unable to %s element with dynamic prefix length cm.Prefixlen=%d key.Prefixlen=%d",
operation, cm.Prefixlen, key.Prefixlen)
}
return nil
} | go | func (cm *CIDRMap) checkPrefixlen(key *cidrKey, operation string) error {
if cm.Prefixlen != 0 &&
((cm.PrefixIsDynamic && cm.Prefixlen < key.Prefixlen) ||
(!cm.PrefixIsDynamic && cm.Prefixlen != key.Prefixlen)) {
return fmt.Errorf("Unable to %s element with dynamic prefix length cm.Prefixlen=%d key.Prefixlen=%d",
operation, cm.Prefixlen, key.Prefixlen)
}
return nil
} | [
"func",
"(",
"cm",
"*",
"CIDRMap",
")",
"checkPrefixlen",
"(",
"key",
"*",
"cidrKey",
",",
"operation",
"string",
")",
"error",
"{",
"if",
"cm",
".",
"Prefixlen",
"!=",
"0",
"&&",
"(",
"(",
"cm",
".",
"PrefixIsDynamic",
"&&",
"cm",
".",
"Prefixlen",
"<",
"key",
".",
"Prefixlen",
")",
"||",
"(",
"!",
"cm",
".",
"PrefixIsDynamic",
"&&",
"cm",
".",
"Prefixlen",
"!=",
"key",
".",
"Prefixlen",
")",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"operation",
",",
"cm",
".",
"Prefixlen",
",",
"key",
".",
"Prefixlen",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // checkPrefixlen checks whether it's valid to manipulate elements in the map
// with the specified key. If it's unsupported, it returns an error. | [
"checkPrefixlen",
"checks",
"whether",
"it",
"s",
"valid",
"to",
"manipulate",
"elements",
"in",
"the",
"map",
"with",
"the",
"specified",
"key",
".",
"If",
"it",
"s",
"unsupported",
"it",
"returns",
"an",
"error",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/cidrmap/cidrmap.go#L75-L83 |
163,193 | cilium/cilium | pkg/maps/cidrmap/cidrmap.go | InsertCIDR | func (cm *CIDRMap) InsertCIDR(cidr net.IPNet) error {
key := cm.cidrKeyInit(cidr)
entry := [LPM_MAP_VALUE_SIZE]byte{}
if err := cm.checkPrefixlen(&key, "update"); err != nil {
return err
}
log.WithField(logfields.Path, cm.path).Debugf("Inserting CIDR entry %s", cidr.String())
return bpf.UpdateElement(cm.Fd, unsafe.Pointer(&key), unsafe.Pointer(&entry), 0)
} | go | func (cm *CIDRMap) InsertCIDR(cidr net.IPNet) error {
key := cm.cidrKeyInit(cidr)
entry := [LPM_MAP_VALUE_SIZE]byte{}
if err := cm.checkPrefixlen(&key, "update"); err != nil {
return err
}
log.WithField(logfields.Path, cm.path).Debugf("Inserting CIDR entry %s", cidr.String())
return bpf.UpdateElement(cm.Fd, unsafe.Pointer(&key), unsafe.Pointer(&entry), 0)
} | [
"func",
"(",
"cm",
"*",
"CIDRMap",
")",
"InsertCIDR",
"(",
"cidr",
"net",
".",
"IPNet",
")",
"error",
"{",
"key",
":=",
"cm",
".",
"cidrKeyInit",
"(",
"cidr",
")",
"\n",
"entry",
":=",
"[",
"LPM_MAP_VALUE_SIZE",
"]",
"byte",
"{",
"}",
"\n",
"if",
"err",
":=",
"cm",
".",
"checkPrefixlen",
"(",
"&",
"key",
",",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"log",
".",
"WithField",
"(",
"logfields",
".",
"Path",
",",
"cm",
".",
"path",
")",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"cidr",
".",
"String",
"(",
")",
")",
"\n",
"return",
"bpf",
".",
"UpdateElement",
"(",
"cm",
".",
"Fd",
",",
"unsafe",
".",
"Pointer",
"(",
"&",
"key",
")",
",",
"unsafe",
".",
"Pointer",
"(",
"&",
"entry",
")",
",",
"0",
")",
"\n",
"}"
] | // InsertCIDR inserts an entry to 'cm' with key 'cidr'. Value is currently not
// used. | [
"InsertCIDR",
"inserts",
"an",
"entry",
"to",
"cm",
"with",
"key",
"cidr",
".",
"Value",
"is",
"currently",
"not",
"used",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/cidrmap/cidrmap.go#L87-L95 |
163,194 | cilium/cilium | pkg/maps/cidrmap/cidrmap.go | DeleteCIDR | func (cm *CIDRMap) DeleteCIDR(cidr net.IPNet) error {
key := cm.cidrKeyInit(cidr)
if err := cm.checkPrefixlen(&key, "delete"); err != nil {
return err
}
log.WithField(logfields.Path, cm.path).Debugf("Removing CIDR entry %s", cidr.String())
return bpf.DeleteElement(cm.Fd, unsafe.Pointer(&key))
} | go | func (cm *CIDRMap) DeleteCIDR(cidr net.IPNet) error {
key := cm.cidrKeyInit(cidr)
if err := cm.checkPrefixlen(&key, "delete"); err != nil {
return err
}
log.WithField(logfields.Path, cm.path).Debugf("Removing CIDR entry %s", cidr.String())
return bpf.DeleteElement(cm.Fd, unsafe.Pointer(&key))
} | [
"func",
"(",
"cm",
"*",
"CIDRMap",
")",
"DeleteCIDR",
"(",
"cidr",
"net",
".",
"IPNet",
")",
"error",
"{",
"key",
":=",
"cm",
".",
"cidrKeyInit",
"(",
"cidr",
")",
"\n",
"if",
"err",
":=",
"cm",
".",
"checkPrefixlen",
"(",
"&",
"key",
",",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"log",
".",
"WithField",
"(",
"logfields",
".",
"Path",
",",
"cm",
".",
"path",
")",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"cidr",
".",
"String",
"(",
")",
")",
"\n",
"return",
"bpf",
".",
"DeleteElement",
"(",
"cm",
".",
"Fd",
",",
"unsafe",
".",
"Pointer",
"(",
"&",
"key",
")",
")",
"\n",
"}"
] | // DeleteCIDR deletes an entry from 'cm' with key 'cidr'. | [
"DeleteCIDR",
"deletes",
"an",
"entry",
"from",
"cm",
"with",
"key",
"cidr",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/cidrmap/cidrmap.go#L98-L105 |
163,195 | cilium/cilium | pkg/maps/cidrmap/cidrmap.go | CIDRExists | func (cm *CIDRMap) CIDRExists(cidr net.IPNet) bool {
key := cm.cidrKeyInit(cidr)
var entry [LPM_MAP_VALUE_SIZE]byte
return bpf.LookupElement(cm.Fd, unsafe.Pointer(&key), unsafe.Pointer(&entry)) == nil
} | go | func (cm *CIDRMap) CIDRExists(cidr net.IPNet) bool {
key := cm.cidrKeyInit(cidr)
var entry [LPM_MAP_VALUE_SIZE]byte
return bpf.LookupElement(cm.Fd, unsafe.Pointer(&key), unsafe.Pointer(&entry)) == nil
} | [
"func",
"(",
"cm",
"*",
"CIDRMap",
")",
"CIDRExists",
"(",
"cidr",
"net",
".",
"IPNet",
")",
"bool",
"{",
"key",
":=",
"cm",
".",
"cidrKeyInit",
"(",
"cidr",
")",
"\n",
"var",
"entry",
"[",
"LPM_MAP_VALUE_SIZE",
"]",
"byte",
"\n",
"return",
"bpf",
".",
"LookupElement",
"(",
"cm",
".",
"Fd",
",",
"unsafe",
".",
"Pointer",
"(",
"&",
"key",
")",
",",
"unsafe",
".",
"Pointer",
"(",
"&",
"entry",
")",
")",
"==",
"nil",
"\n",
"}"
] | // CIDRExists returns true if 'cidr' exists in map 'cm' | [
"CIDRExists",
"returns",
"true",
"if",
"cidr",
"exists",
"in",
"map",
"cm"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/cidrmap/cidrmap.go#L108-L112 |
163,196 | cilium/cilium | pkg/maps/cidrmap/cidrmap.go | CIDRNext | func (cm *CIDRMap) CIDRNext(cidr *net.IPNet) *net.IPNet {
var key, keyNext cidrKey
if cidr != nil {
key = cm.cidrKeyInit(*cidr)
}
err := bpf.GetNextKey(cm.Fd, unsafe.Pointer(&key), unsafe.Pointer(&keyNext))
if err != nil {
return nil
}
out := cm.keyCidrInit(keyNext)
return &out
} | go | func (cm *CIDRMap) CIDRNext(cidr *net.IPNet) *net.IPNet {
var key, keyNext cidrKey
if cidr != nil {
key = cm.cidrKeyInit(*cidr)
}
err := bpf.GetNextKey(cm.Fd, unsafe.Pointer(&key), unsafe.Pointer(&keyNext))
if err != nil {
return nil
}
out := cm.keyCidrInit(keyNext)
return &out
} | [
"func",
"(",
"cm",
"*",
"CIDRMap",
")",
"CIDRNext",
"(",
"cidr",
"*",
"net",
".",
"IPNet",
")",
"*",
"net",
".",
"IPNet",
"{",
"var",
"key",
",",
"keyNext",
"cidrKey",
"\n",
"if",
"cidr",
"!=",
"nil",
"{",
"key",
"=",
"cm",
".",
"cidrKeyInit",
"(",
"*",
"cidr",
")",
"\n",
"}",
"\n",
"err",
":=",
"bpf",
".",
"GetNextKey",
"(",
"cm",
".",
"Fd",
",",
"unsafe",
".",
"Pointer",
"(",
"&",
"key",
")",
",",
"unsafe",
".",
"Pointer",
"(",
"&",
"keyNext",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"cm",
".",
"keyCidrInit",
"(",
"keyNext",
")",
"\n",
"return",
"&",
"out",
"\n",
"}"
] | // CIDRNext returns next CIDR entry in map 'cm' | [
"CIDRNext",
"returns",
"next",
"CIDR",
"entry",
"in",
"map",
"cm"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/cidrmap/cidrmap.go#L115-L126 |
163,197 | cilium/cilium | pkg/maps/cidrmap/cidrmap.go | CIDRDump | func (cm *CIDRMap) CIDRDump(to []string) []string {
var key, keyNext *net.IPNet
for {
keyNext = cm.CIDRNext(key)
if keyNext == nil {
return to
}
key = keyNext
to = append(to, key.String())
}
} | go | func (cm *CIDRMap) CIDRDump(to []string) []string {
var key, keyNext *net.IPNet
for {
keyNext = cm.CIDRNext(key)
if keyNext == nil {
return to
}
key = keyNext
to = append(to, key.String())
}
} | [
"func",
"(",
"cm",
"*",
"CIDRMap",
")",
"CIDRDump",
"(",
"to",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"var",
"key",
",",
"keyNext",
"*",
"net",
".",
"IPNet",
"\n",
"for",
"{",
"keyNext",
"=",
"cm",
".",
"CIDRNext",
"(",
"key",
")",
"\n",
"if",
"keyNext",
"==",
"nil",
"{",
"return",
"to",
"\n",
"}",
"\n",
"key",
"=",
"keyNext",
"\n",
"to",
"=",
"append",
"(",
"to",
",",
"key",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n",
"}"
] | // CIDRDump walks map 'cm' and dumps all CIDR entries | [
"CIDRDump",
"walks",
"map",
"cm",
"and",
"dumps",
"all",
"CIDR",
"entries"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/cidrmap/cidrmap.go#L129-L139 |
163,198 | cilium/cilium | pkg/maps/cidrmap/cidrmap.go | Close | func (cm *CIDRMap) Close() error {
if cm == nil {
return nil
}
return bpf.ObjClose(cm.Fd)
} | go | func (cm *CIDRMap) Close() error {
if cm == nil {
return nil
}
return bpf.ObjClose(cm.Fd)
} | [
"func",
"(",
"cm",
"*",
"CIDRMap",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"cm",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"bpf",
".",
"ObjClose",
"(",
"cm",
".",
"Fd",
")",
"\n",
"}"
] | // Close closes the FD of the given CIDRMap | [
"Close",
"closes",
"the",
"FD",
"of",
"the",
"given",
"CIDRMap"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/cidrmap/cidrmap.go#L150-L155 |
163,199 | cilium/cilium | pkg/maps/cidrmap/cidrmap.go | OpenMap | func OpenMap(path string, prefixlen int, prefixdyn bool) (*CIDRMap, bool, error) {
return OpenMapElems(path, prefixlen, prefixdyn, MaxEntries)
} | go | func OpenMap(path string, prefixlen int, prefixdyn bool) (*CIDRMap, bool, error) {
return OpenMapElems(path, prefixlen, prefixdyn, MaxEntries)
} | [
"func",
"OpenMap",
"(",
"path",
"string",
",",
"prefixlen",
"int",
",",
"prefixdyn",
"bool",
")",
"(",
"*",
"CIDRMap",
",",
"bool",
",",
"error",
")",
"{",
"return",
"OpenMapElems",
"(",
"path",
",",
"prefixlen",
",",
"prefixdyn",
",",
"MaxEntries",
")",
"\n",
"}"
] | // OpenMap opens a new CIDRMap. 'bool' returns 'true' if the map was
// created, and 'false' if the map already existed. prefixdyn denotes
// whether element's prefixlen can vary and we thus need to use a LPM
// trie instead of hash table. | [
"OpenMap",
"opens",
"a",
"new",
"CIDRMap",
".",
"bool",
"returns",
"true",
"if",
"the",
"map",
"was",
"created",
"and",
"false",
"if",
"the",
"map",
"already",
"existed",
".",
"prefixdyn",
"denotes",
"whether",
"element",
"s",
"prefixlen",
"can",
"vary",
"and",
"we",
"thus",
"need",
"to",
"use",
"a",
"LPM",
"trie",
"instead",
"of",
"hash",
"table",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/cidrmap/cidrmap.go#L161-L163 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.