id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
162,600 | cilium/cilium | pkg/ip/cidr.go | ParseCIDRs | func ParseCIDRs(cidrs []string) (valid []*net.IPNet, invalid []string) {
valid = make([]*net.IPNet, 0, len(cidrs))
invalid = make([]string, 0, len(cidrs))
for _, cidr := range cidrs {
_, prefix, err := net.ParseCIDR(cidr)
if err != nil {
// Likely the CIDR is specified in host format.
ip := net.ParseIP(cidr)
if ip == nil {
invalid = append(invalid, cidr)
continue
} else {
bits := net.IPv6len * 8
if ip.To4() != nil {
ip = ip.To4()
bits = net.IPv4len * 8
}
prefix = &net.IPNet{
IP: ip,
Mask: net.CIDRMask(bits, bits),
}
}
}
if prefix != nil {
valid = append(valid, prefix)
}
}
return valid, invalid
} | go | func ParseCIDRs(cidrs []string) (valid []*net.IPNet, invalid []string) {
valid = make([]*net.IPNet, 0, len(cidrs))
invalid = make([]string, 0, len(cidrs))
for _, cidr := range cidrs {
_, prefix, err := net.ParseCIDR(cidr)
if err != nil {
// Likely the CIDR is specified in host format.
ip := net.ParseIP(cidr)
if ip == nil {
invalid = append(invalid, cidr)
continue
} else {
bits := net.IPv6len * 8
if ip.To4() != nil {
ip = ip.To4()
bits = net.IPv4len * 8
}
prefix = &net.IPNet{
IP: ip,
Mask: net.CIDRMask(bits, bits),
}
}
}
if prefix != nil {
valid = append(valid, prefix)
}
}
return valid, invalid
} | [
"func",
"ParseCIDRs",
"(",
"cidrs",
"[",
"]",
"string",
")",
"(",
"valid",
"[",
"]",
"*",
"net",
".",
"IPNet",
",",
"invalid",
"[",
"]",
"string",
")",
"{",
"valid",
"=",
"make",
"(",
"[",
"]",
"*",
"net",
".",
"IPNet",
",",
"0",
",",
"len",
... | // ParseCIDRs fetches all CIDRs referred to by the specified slice and returns
// them as regular golang CIDR objects. | [
"ParseCIDRs",
"fetches",
"all",
"CIDRs",
"referred",
"to",
"by",
"the",
"specified",
"slice",
"and",
"returns",
"them",
"as",
"regular",
"golang",
"CIDR",
"objects",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/ip/cidr.go#L23-L51 |
162,601 | cilium/cilium | pkg/kvstore/lock.go | Unlock | func (l *Lock) Unlock() error {
if l == nil {
return nil
}
// Unlock kvstore mutex first
err := l.kvLock.Unlock()
// unlock local lock even if kvstore cannot be unlocked
kvstoreLocks.unlock(l.path, l.id)
Trace("Unlocked", nil, logrus.Fields{fieldKey: l.path})
return err
} | go | func (l *Lock) Unlock() error {
if l == nil {
return nil
}
// Unlock kvstore mutex first
err := l.kvLock.Unlock()
// unlock local lock even if kvstore cannot be unlocked
kvstoreLocks.unlock(l.path, l.id)
Trace("Unlocked", nil, logrus.Fields{fieldKey: l.path})
return err
} | [
"func",
"(",
"l",
"*",
"Lock",
")",
"Unlock",
"(",
")",
"error",
"{",
"if",
"l",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Unlock kvstore mutex first",
"err",
":=",
"l",
".",
"kvLock",
".",
"Unlock",
"(",
")",
"\n\n",
"// unlock local l... | // Unlock unlocks a lock | [
"Unlock",
"unlocks",
"a",
"lock"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/lock.go#L131-L144 |
162,602 | cilium/cilium | api/v1/models/endpoint_policy_status.go | Validate | func (m *EndpointPolicyStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateProxyStatistics(formats); err != nil {
res = append(res, err)
}
if err := m.validateRealized(formats); err != nil {
res = append(res, err)
}
if err := m.validateSpec(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *EndpointPolicyStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateProxyStatistics(formats); err != nil {
res = append(res, err)
}
if err := m.validateRealized(formats); err != nil {
res = append(res, err)
}
if err := m.validateSpec(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"EndpointPolicyStatus",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateProxyStatistics",
"(",
"formats",
")",
";",
"err"... | // Validate validates this endpoint policy status | [
"Validate",
"validates",
"this",
"endpoint",
"policy",
"status"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/endpoint_policy_status.go#L35-L54 |
162,603 | cilium/cilium | pkg/maps/nat/nat.go | NatDumpCreated | func NatDumpCreated(dumpStart, entryCreated uint64) string {
tsecCreated := entryCreated / 1000000000
tsecStart := dumpStart / 1000000000
return fmt.Sprintf("%dsec", tsecStart-tsecCreated)
} | go | func NatDumpCreated(dumpStart, entryCreated uint64) string {
tsecCreated := entryCreated / 1000000000
tsecStart := dumpStart / 1000000000
return fmt.Sprintf("%dsec", tsecStart-tsecCreated)
} | [
"func",
"NatDumpCreated",
"(",
"dumpStart",
",",
"entryCreated",
"uint64",
")",
"string",
"{",
"tsecCreated",
":=",
"entryCreated",
"/",
"1000000000",
"\n",
"tsecStart",
":=",
"dumpStart",
"/",
"1000000000",
"\n\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
... | // NatDumpCreated returns time in seconds when NAT entry was created. | [
"NatDumpCreated",
"returns",
"time",
"in",
"seconds",
"when",
"NAT",
"entry",
"was",
"created",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/nat/nat.go#L74-L79 |
162,604 | cilium/cilium | pkg/maps/nat/nat.go | DumpEntries | func (m *Map) DumpEntries() (string, error) {
var buffer bytes.Buffer
nsecStart, _ := bpf.GetMtime()
cb := func(k bpf.MapKey, v bpf.MapValue) {
key := k.(tuple.TupleKey)
if !key.ToHost().Dump(&buffer, false) {
return
}
val := v.(NatEntry)
buffer.WriteString(val.ToHost().Dump(key, nsecStart))
}
err := m.DumpWithCallback(cb)
return buffer.String(), err
} | go | func (m *Map) DumpEntries() (string, error) {
var buffer bytes.Buffer
nsecStart, _ := bpf.GetMtime()
cb := func(k bpf.MapKey, v bpf.MapValue) {
key := k.(tuple.TupleKey)
if !key.ToHost().Dump(&buffer, false) {
return
}
val := v.(NatEntry)
buffer.WriteString(val.ToHost().Dump(key, nsecStart))
}
err := m.DumpWithCallback(cb)
return buffer.String(), err
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"DumpEntries",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"buffer",
"bytes",
".",
"Buffer",
"\n\n",
"nsecStart",
",",
"_",
":=",
"bpf",
".",
"GetMtime",
"(",
")",
"\n",
"cb",
":=",
"func",
"(",
"k",... | // DumpEntries iterates through Map m and writes the values of the
// nat entries in m to a string. | [
"DumpEntries",
"iterates",
"through",
"Map",
"m",
"and",
"writes",
"the",
"values",
"of",
"the",
"nat",
"entries",
"in",
"m",
"to",
"a",
"string",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/nat/nat.go#L129-L143 |
162,605 | cilium/cilium | pkg/maps/nat/nat.go | Flush | func (m *Map) Flush() int {
if m.v4 {
return int(doFlush4(m).deleted)
}
return int(doFlush6(m).deleted)
} | go | func (m *Map) Flush() int {
if m.v4 {
return int(doFlush4(m).deleted)
}
return int(doFlush6(m).deleted)
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"Flush",
"(",
")",
"int",
"{",
"if",
"m",
".",
"v4",
"{",
"return",
"int",
"(",
"doFlush4",
"(",
"m",
")",
".",
"deleted",
")",
"\n",
"}",
"\n",
"return",
"int",
"(",
"doFlush6",
"(",
"m",
")",
".",
"deleted... | // Flush deletes all NAT mappings from the given table. | [
"Flush",
"deletes",
"all",
"NAT",
"mappings",
"from",
"the",
"given",
"table",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/nat/nat.go#L192-L197 |
162,606 | cilium/cilium | pkg/maps/nat/nat.go | DeleteMapping | func (m *Map) DeleteMapping(key tuple.TupleKey) error {
if key.GetFlags()&tuple.TUPLE_F_IN != 0 {
return nil
}
if m.v4 {
return deleteMapping4(m, key.(*tuple.TupleKey4Global))
}
return deleteMapping6(m, key.(*tuple.TupleKey6Global))
} | go | func (m *Map) DeleteMapping(key tuple.TupleKey) error {
if key.GetFlags()&tuple.TUPLE_F_IN != 0 {
return nil
}
if m.v4 {
return deleteMapping4(m, key.(*tuple.TupleKey4Global))
}
return deleteMapping6(m, key.(*tuple.TupleKey6Global))
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"DeleteMapping",
"(",
"key",
"tuple",
".",
"TupleKey",
")",
"error",
"{",
"if",
"key",
".",
"GetFlags",
"(",
")",
"&",
"tuple",
".",
"TUPLE_F_IN",
"!=",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"m",
"."... | // DeleteMapping removes a NAT mapping from the global NAT table. | [
"DeleteMapping",
"removes",
"a",
"NAT",
"mapping",
"from",
"the",
"global",
"NAT",
"table",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/nat/nat.go#L244-L252 |
162,607 | cilium/cilium | daemon/k8s_watcher.go | blockWaitGroupToSyncResources | func (d *Daemon) blockWaitGroupToSyncResources(stop <-chan struct{}, informer cache.Controller, resourceName string) {
ch := make(chan struct{})
d.k8sResourceSyncedMu.Lock()
d.k8sResourceSynced[resourceName] = ch
d.k8sResourceSyncedMu.Unlock()
go func() {
scopedLog := log.WithField("kubernetesResource", resourceName)
scopedLog.Debug("waiting for cache to synchronize")
if ok := cache.WaitForCacheSync(stop, informer.HasSynced); !ok {
select {
case <-stop:
scopedLog.Debug("canceled cache synchronization")
// do not fatal if the channel was stopped
default:
// Fatally exit it resource fails to sync
scopedLog.Fatalf("failed to wait for cache to sync")
}
} else {
scopedLog.Debug("cache synced")
}
close(ch)
}()
} | go | func (d *Daemon) blockWaitGroupToSyncResources(stop <-chan struct{}, informer cache.Controller, resourceName string) {
ch := make(chan struct{})
d.k8sResourceSyncedMu.Lock()
d.k8sResourceSynced[resourceName] = ch
d.k8sResourceSyncedMu.Unlock()
go func() {
scopedLog := log.WithField("kubernetesResource", resourceName)
scopedLog.Debug("waiting for cache to synchronize")
if ok := cache.WaitForCacheSync(stop, informer.HasSynced); !ok {
select {
case <-stop:
scopedLog.Debug("canceled cache synchronization")
// do not fatal if the channel was stopped
default:
// Fatally exit it resource fails to sync
scopedLog.Fatalf("failed to wait for cache to sync")
}
} else {
scopedLog.Debug("cache synced")
}
close(ch)
}()
} | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"blockWaitGroupToSyncResources",
"(",
"stop",
"<-",
"chan",
"struct",
"{",
"}",
",",
"informer",
"cache",
".",
"Controller",
",",
"resourceName",
"string",
")",
"{",
"ch",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}... | // blockWaitGroupToSyncResources ensures that anything which waits on waitGroup
// waits until all objects of the specified resource stored in Kubernetes are
// received by the informer and processed by controller.
// Fatally exits if syncing these initial objects fails.
// If the given stop channel is closed, it does not fatal. | [
"blockWaitGroupToSyncResources",
"ensures",
"that",
"anything",
"which",
"waits",
"on",
"waitGroup",
"waits",
"until",
"all",
"objects",
"of",
"the",
"specified",
"resource",
"stored",
"in",
"Kubernetes",
"are",
"received",
"by",
"the",
"informer",
"and",
"processed... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/k8s_watcher.go#L257-L279 |
162,608 | cilium/cilium | daemon/k8s_watcher.go | waitForCacheSync | func (d *Daemon) waitForCacheSync(resourceNames ...string) {
for _, resourceName := range resourceNames {
d.k8sResourceSyncedMu.RLock()
c, ok := d.k8sResourceSynced[resourceName]
d.k8sResourceSyncedMu.RUnlock()
if !ok {
continue
}
<-c
}
} | go | func (d *Daemon) waitForCacheSync(resourceNames ...string) {
for _, resourceName := range resourceNames {
d.k8sResourceSyncedMu.RLock()
c, ok := d.k8sResourceSynced[resourceName]
d.k8sResourceSyncedMu.RUnlock()
if !ok {
continue
}
<-c
}
} | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"waitForCacheSync",
"(",
"resourceNames",
"...",
"string",
")",
"{",
"for",
"_",
",",
"resourceName",
":=",
"range",
"resourceNames",
"{",
"d",
".",
"k8sResourceSyncedMu",
".",
"RLock",
"(",
")",
"\n",
"c",
",",
"ok"... | // waitForCacheSync waits for k8s caches to be synchronized for the given
// resource. Returns once all resourcesNames are synchronized with cilium-agent. | [
"waitForCacheSync",
"waits",
"for",
"k8s",
"caches",
"to",
"be",
"synchronized",
"for",
"the",
"given",
"resource",
".",
"Returns",
"once",
"all",
"resourcesNames",
"are",
"synchronized",
"with",
"cilium",
"-",
"agent",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/k8s_watcher.go#L283-L293 |
162,609 | cilium/cilium | daemon/k8s_watcher.go | initK8sSubsystem | func (d *Daemon) initK8sSubsystem() <-chan struct{} {
if err := d.EnableK8sWatcher(option.Config.K8sWatcherQueueSize); err != nil {
log.WithError(err).Fatal("Unable to establish connection to Kubernetes apiserver")
}
cachesSynced := make(chan struct{})
go func() {
log.Info("Waiting until all pre-existing resources related to policy have been received")
// Wait only for certain caches, but not all!
// We don't wait for nodes synchronization nor ingresses.
d.waitForCacheSync(
// To perform the service translation and have the BPF LB datapath
// with the right service -> backend (k8s endpoints) translation.
k8sAPIGroupServiceV1Core,
// To perform the service translation and have the BPF LB datapath
// with the right service -> backend (k8s endpoints) translation.
k8sAPIGroupEndpointV1Core,
// We need all network policies in place before restoring to make sure
// we are enforcing the correct policies for each endpoint before
// restarting.
k8sAPIGroupCiliumV2,
// We need all network policies in place before restoring to make sure
// we are enforcing the correct policies for each endpoint before
// restarting.
k8sAPIGroupNetworkingV1Core,
// Namespaces can contain labels which are essential for endpoints
// being restored to have the right identity.
k8sAPIGroupNamespaceV1Core,
// Pods can contain labels which are essential for endpoints
// being restored to have the right identity.
k8sAPIGroupPodV1Core,
)
close(cachesSynced)
}()
go func() {
select {
case <-cachesSynced:
log.Info("All pre-existing resources related to policy have been received; continuing")
case <-time.After(cacheSyncTimeout):
log.Fatalf("Timed out waiting for pre-existing resources related to policy to be received; exiting")
}
}()
return cachesSynced
} | go | func (d *Daemon) initK8sSubsystem() <-chan struct{} {
if err := d.EnableK8sWatcher(option.Config.K8sWatcherQueueSize); err != nil {
log.WithError(err).Fatal("Unable to establish connection to Kubernetes apiserver")
}
cachesSynced := make(chan struct{})
go func() {
log.Info("Waiting until all pre-existing resources related to policy have been received")
// Wait only for certain caches, but not all!
// We don't wait for nodes synchronization nor ingresses.
d.waitForCacheSync(
// To perform the service translation and have the BPF LB datapath
// with the right service -> backend (k8s endpoints) translation.
k8sAPIGroupServiceV1Core,
// To perform the service translation and have the BPF LB datapath
// with the right service -> backend (k8s endpoints) translation.
k8sAPIGroupEndpointV1Core,
// We need all network policies in place before restoring to make sure
// we are enforcing the correct policies for each endpoint before
// restarting.
k8sAPIGroupCiliumV2,
// We need all network policies in place before restoring to make sure
// we are enforcing the correct policies for each endpoint before
// restarting.
k8sAPIGroupNetworkingV1Core,
// Namespaces can contain labels which are essential for endpoints
// being restored to have the right identity.
k8sAPIGroupNamespaceV1Core,
// Pods can contain labels which are essential for endpoints
// being restored to have the right identity.
k8sAPIGroupPodV1Core,
)
close(cachesSynced)
}()
go func() {
select {
case <-cachesSynced:
log.Info("All pre-existing resources related to policy have been received; continuing")
case <-time.After(cacheSyncTimeout):
log.Fatalf("Timed out waiting for pre-existing resources related to policy to be received; exiting")
}
}()
return cachesSynced
} | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"initK8sSubsystem",
"(",
")",
"<-",
"chan",
"struct",
"{",
"}",
"{",
"if",
"err",
":=",
"d",
".",
"EnableK8sWatcher",
"(",
"option",
".",
"Config",
".",
"K8sWatcherQueueSize",
")",
";",
"err",
"!=",
"nil",
"{",
"... | // initK8sSubsystem returns a channel for which it will be closed when all
// caches essential for daemon are synchronized. | [
"initK8sSubsystem",
"returns",
"a",
"channel",
"for",
"which",
"it",
"will",
"be",
"closed",
"when",
"all",
"caches",
"essential",
"for",
"daemon",
"are",
"synchronized",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/k8s_watcher.go#L297-L343 |
162,610 | cilium/cilium | daemon/k8s_watcher.go | updateK8sEventMetric | func updateK8sEventMetric(scope string, action string, status bool) {
result := "success"
if status == false {
result = "failed"
}
metrics.KubernetesEventProcessed.WithLabelValues(scope, action, result).Inc()
} | go | func updateK8sEventMetric(scope string, action string, status bool) {
result := "success"
if status == false {
result = "failed"
}
metrics.KubernetesEventProcessed.WithLabelValues(scope, action, result).Inc()
} | [
"func",
"updateK8sEventMetric",
"(",
"scope",
"string",
",",
"action",
"string",
",",
"status",
"bool",
")",
"{",
"result",
":=",
"\"",
"\"",
"\n",
"if",
"status",
"==",
"false",
"{",
"result",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"metrics",
".",
"Kuber... | // updateK8sEventMetric incrment the given metric per event type and the result
// status of the function | [
"updateK8sEventMetric",
"incrment",
"the",
"given",
"metric",
"per",
"event",
"type",
"and",
"the",
"result",
"status",
"of",
"the",
"function"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/k8s_watcher.go#L1900-L1907 |
162,611 | cilium/cilium | pkg/maps/policymap/policymap.go | Less | func (p PolicyEntriesDump) Less(i, j int) bool {
if p[i].Key.TrafficDirection < p[j].Key.TrafficDirection {
return true
}
return p[i].Key.TrafficDirection <= p[j].Key.TrafficDirection &&
p[i].Key.Identity < p[j].Key.Identity
} | go | func (p PolicyEntriesDump) Less(i, j int) bool {
if p[i].Key.TrafficDirection < p[j].Key.TrafficDirection {
return true
}
return p[i].Key.TrafficDirection <= p[j].Key.TrafficDirection &&
p[i].Key.Identity < p[j].Key.Identity
} | [
"func",
"(",
"p",
"PolicyEntriesDump",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"if",
"p",
"[",
"i",
"]",
".",
"Key",
".",
"TrafficDirection",
"<",
"p",
"[",
"j",
"]",
".",
"Key",
".",
"TrafficDirection",
"{",
"return",
"true",
"... | // Less returns true if the element in index `i` has the value of
// TrafficDirection lower than `j`'s TrafficDirection or if the element in index
// `i` has the value of TrafficDirection lower and equal than `j`'s
// TrafficDirection and the identity of element `i` is lower than the Identity
// of element j. | [
"Less",
"returns",
"true",
"if",
"the",
"element",
"in",
"index",
"i",
"has",
"the",
"value",
"of",
"TrafficDirection",
"lower",
"than",
"j",
"s",
"TrafficDirection",
"or",
"if",
"the",
"element",
"in",
"index",
"i",
"has",
"the",
"value",
"of",
"TrafficDi... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/policymap/policymap.go#L106-L112 |
162,612 | cilium/cilium | pkg/maps/policymap/policymap.go | ToHost | func (key *PolicyKey) ToHost() PolicyKey {
if key == nil {
return PolicyKey{}
}
n := *key
n.DestPort = byteorder.NetworkToHost(n.DestPort).(uint16)
return n
} | go | func (key *PolicyKey) ToHost() PolicyKey {
if key == nil {
return PolicyKey{}
}
n := *key
n.DestPort = byteorder.NetworkToHost(n.DestPort).(uint16)
return n
} | [
"func",
"(",
"key",
"*",
"PolicyKey",
")",
"ToHost",
"(",
")",
"PolicyKey",
"{",
"if",
"key",
"==",
"nil",
"{",
"return",
"PolicyKey",
"{",
"}",
"\n",
"}",
"\n\n",
"n",
":=",
"*",
"key",
"\n",
"n",
".",
"DestPort",
"=",
"byteorder",
".",
"NetworkTo... | // ToHost returns a copy of key with fields converted from network byte-order
// to host-byte-order if necessary. | [
"ToHost",
"returns",
"a",
"copy",
"of",
"key",
"with",
"fields",
"converted",
"from",
"network",
"byte",
"-",
"order",
"to",
"host",
"-",
"byte",
"-",
"order",
"if",
"necessary",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/policymap/policymap.go#L128-L136 |
162,613 | cilium/cilium | pkg/maps/policymap/policymap.go | ToNetwork | func (key *PolicyKey) ToNetwork() PolicyKey {
if key == nil {
return PolicyKey{}
}
n := *key
n.DestPort = byteorder.HostToNetwork(n.DestPort).(uint16)
return n
} | go | func (key *PolicyKey) ToNetwork() PolicyKey {
if key == nil {
return PolicyKey{}
}
n := *key
n.DestPort = byteorder.HostToNetwork(n.DestPort).(uint16)
return n
} | [
"func",
"(",
"key",
"*",
"PolicyKey",
")",
"ToNetwork",
"(",
")",
"PolicyKey",
"{",
"if",
"key",
"==",
"nil",
"{",
"return",
"PolicyKey",
"{",
"}",
"\n",
"}",
"\n\n",
"n",
":=",
"*",
"key",
"\n",
"n",
".",
"DestPort",
"=",
"byteorder",
".",
"HostTo... | // ToNetwork returns a copy of key with fields converted from host byte-order
// to network-byte-order if necessary. | [
"ToNetwork",
"returns",
"a",
"copy",
"of",
"key",
"with",
"fields",
"converted",
"from",
"host",
"byte",
"-",
"order",
"to",
"network",
"-",
"byte",
"-",
"order",
"if",
"necessary",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/policymap/policymap.go#L140-L148 |
162,614 | cilium/cilium | pkg/maps/policymap/policymap.go | newKey | func newKey(id uint32, dport uint16, proto u8proto.U8proto, trafficDirection trafficdirection.TrafficDirection) PolicyKey {
return PolicyKey{
Identity: id,
DestPort: byteorder.HostToNetwork(dport).(uint16),
Nexthdr: uint8(proto),
TrafficDirection: trafficDirection.Uint8(),
}
} | go | func newKey(id uint32, dport uint16, proto u8proto.U8proto, trafficDirection trafficdirection.TrafficDirection) PolicyKey {
return PolicyKey{
Identity: id,
DestPort: byteorder.HostToNetwork(dport).(uint16),
Nexthdr: uint8(proto),
TrafficDirection: trafficDirection.Uint8(),
}
} | [
"func",
"newKey",
"(",
"id",
"uint32",
",",
"dport",
"uint16",
",",
"proto",
"u8proto",
".",
"U8proto",
",",
"trafficDirection",
"trafficdirection",
".",
"TrafficDirection",
")",
"PolicyKey",
"{",
"return",
"PolicyKey",
"{",
"Identity",
":",
"id",
",",
"DestPo... | // newKey returns a PolicyKey representing the specified parameters in network
// byte-order. | [
"newKey",
"returns",
"a",
"PolicyKey",
"representing",
"the",
"specified",
"parameters",
"in",
"network",
"byte",
"-",
"order",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/policymap/policymap.go#L152-L159 |
162,615 | cilium/cilium | pkg/maps/policymap/policymap.go | newEntry | func newEntry(proxyPort uint16) PolicyEntry {
return PolicyEntry{
ProxyPort: byteorder.HostToNetwork(proxyPort).(uint16),
}
} | go | func newEntry(proxyPort uint16) PolicyEntry {
return PolicyEntry{
ProxyPort: byteorder.HostToNetwork(proxyPort).(uint16),
}
} | [
"func",
"newEntry",
"(",
"proxyPort",
"uint16",
")",
"PolicyEntry",
"{",
"return",
"PolicyEntry",
"{",
"ProxyPort",
":",
"byteorder",
".",
"HostToNetwork",
"(",
"proxyPort",
")",
".",
"(",
"uint16",
")",
",",
"}",
"\n",
"}"
] | // newEntry returns a PolicyEntry representing the specified parameters in
// network byte-order. | [
"newEntry",
"returns",
"a",
"PolicyEntry",
"representing",
"the",
"specified",
"parameters",
"in",
"network",
"byte",
"-",
"order",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/policymap/policymap.go#L163-L167 |
162,616 | cilium/cilium | pkg/maps/policymap/policymap.go | AllowKey | func (pm *PolicyMap) AllowKey(k PolicyKey, proxyPort uint16) error {
return pm.Allow(k.Identity, k.DestPort, u8proto.U8proto(k.Nexthdr), trafficdirection.TrafficDirection(k.TrafficDirection), proxyPort)
} | go | func (pm *PolicyMap) AllowKey(k PolicyKey, proxyPort uint16) error {
return pm.Allow(k.Identity, k.DestPort, u8proto.U8proto(k.Nexthdr), trafficdirection.TrafficDirection(k.TrafficDirection), proxyPort)
} | [
"func",
"(",
"pm",
"*",
"PolicyMap",
")",
"AllowKey",
"(",
"k",
"PolicyKey",
",",
"proxyPort",
"uint16",
")",
"error",
"{",
"return",
"pm",
".",
"Allow",
"(",
"k",
".",
"Identity",
",",
"k",
".",
"DestPort",
",",
"u8proto",
".",
"U8proto",
"(",
"k",
... | // AllowKey pushes an entry into the PolicyMap for the given PolicyKey k.
// Returns an error if the update of the PolicyMap fails. | [
"AllowKey",
"pushes",
"an",
"entry",
"into",
"the",
"PolicyMap",
"for",
"the",
"given",
"PolicyKey",
"k",
".",
"Returns",
"an",
"error",
"if",
"the",
"update",
"of",
"the",
"PolicyMap",
"fails",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/policymap/policymap.go#L171-L173 |
162,617 | cilium/cilium | pkg/maps/policymap/policymap.go | Allow | func (pm *PolicyMap) Allow(id uint32, dport uint16, proto u8proto.U8proto, trafficDirection trafficdirection.TrafficDirection, proxyPort uint16) error {
key := newKey(id, dport, proto, trafficDirection)
entry := newEntry(proxyPort)
return pm.Update(&key, &entry)
} | go | func (pm *PolicyMap) Allow(id uint32, dport uint16, proto u8proto.U8proto, trafficDirection trafficdirection.TrafficDirection, proxyPort uint16) error {
key := newKey(id, dport, proto, trafficDirection)
entry := newEntry(proxyPort)
return pm.Update(&key, &entry)
} | [
"func",
"(",
"pm",
"*",
"PolicyMap",
")",
"Allow",
"(",
"id",
"uint32",
",",
"dport",
"uint16",
",",
"proto",
"u8proto",
".",
"U8proto",
",",
"trafficDirection",
"trafficdirection",
".",
"TrafficDirection",
",",
"proxyPort",
"uint16",
")",
"error",
"{",
"key... | // Allow pushes an entry into the PolicyMap to allow traffic in the given
// `trafficDirection` for identity `id` with destination port `dport` over
// protocol `proto`. It is assumed that `dport` and `proxyPort` are in host byte-order. | [
"Allow",
"pushes",
"an",
"entry",
"into",
"the",
"PolicyMap",
"to",
"allow",
"traffic",
"in",
"the",
"given",
"trafficDirection",
"for",
"identity",
"id",
"with",
"destination",
"port",
"dport",
"over",
"protocol",
"proto",
".",
"It",
"is",
"assumed",
"that",
... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/policymap/policymap.go#L178-L182 |
162,618 | cilium/cilium | pkg/maps/policymap/policymap.go | Exists | func (pm *PolicyMap) Exists(id uint32, dport uint16, proto u8proto.U8proto, trafficDirection trafficdirection.TrafficDirection) bool {
key := newKey(id, dport, proto, trafficDirection)
_, err := pm.Lookup(&key)
return err == nil
} | go | func (pm *PolicyMap) Exists(id uint32, dport uint16, proto u8proto.U8proto, trafficDirection trafficdirection.TrafficDirection) bool {
key := newKey(id, dport, proto, trafficDirection)
_, err := pm.Lookup(&key)
return err == nil
} | [
"func",
"(",
"pm",
"*",
"PolicyMap",
")",
"Exists",
"(",
"id",
"uint32",
",",
"dport",
"uint16",
",",
"proto",
"u8proto",
".",
"U8proto",
",",
"trafficDirection",
"trafficdirection",
".",
"TrafficDirection",
")",
"bool",
"{",
"key",
":=",
"newKey",
"(",
"i... | // Exists determines whether PolicyMap currently contains an entry that
// allows traffic in `trafficDirection` for identity `id` with destination port
// `dport`over protocol `proto`. It is assumed that `dport` is in host byte-order. | [
"Exists",
"determines",
"whether",
"PolicyMap",
"currently",
"contains",
"an",
"entry",
"that",
"allows",
"traffic",
"in",
"trafficDirection",
"for",
"identity",
"id",
"with",
"destination",
"port",
"dport",
"over",
"protocol",
"proto",
".",
"It",
"is",
"assumed",... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/policymap/policymap.go#L187-L191 |
162,619 | cilium/cilium | pkg/maps/policymap/policymap.go | DeleteKey | func (pm *PolicyMap) DeleteKey(key PolicyKey) error {
k := key.ToNetwork()
return pm.Map.Delete(&k)
} | go | func (pm *PolicyMap) DeleteKey(key PolicyKey) error {
k := key.ToNetwork()
return pm.Map.Delete(&k)
} | [
"func",
"(",
"pm",
"*",
"PolicyMap",
")",
"DeleteKey",
"(",
"key",
"PolicyKey",
")",
"error",
"{",
"k",
":=",
"key",
".",
"ToNetwork",
"(",
")",
"\n",
"return",
"pm",
".",
"Map",
".",
"Delete",
"(",
"&",
"k",
")",
"\n",
"}"
] | // DeleteKey deletes the key-value pair from the given PolicyMap with PolicyKey
// k. Returns an error if deletion from the PolicyMap fails. | [
"DeleteKey",
"deletes",
"the",
"key",
"-",
"value",
"pair",
"from",
"the",
"given",
"PolicyMap",
"with",
"PolicyKey",
"k",
".",
"Returns",
"an",
"error",
"if",
"deletion",
"from",
"the",
"PolicyMap",
"fails",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/policymap/policymap.go#L195-L198 |
162,620 | cilium/cilium | pkg/maps/policymap/policymap.go | Delete | func (pm *PolicyMap) Delete(id uint32, dport uint16, proto u8proto.U8proto, trafficDirection trafficdirection.TrafficDirection) error {
k := newKey(id, dport, proto, trafficDirection)
return pm.Map.Delete(&k)
} | go | func (pm *PolicyMap) Delete(id uint32, dport uint16, proto u8proto.U8proto, trafficDirection trafficdirection.TrafficDirection) error {
k := newKey(id, dport, proto, trafficDirection)
return pm.Map.Delete(&k)
} | [
"func",
"(",
"pm",
"*",
"PolicyMap",
")",
"Delete",
"(",
"id",
"uint32",
",",
"dport",
"uint16",
",",
"proto",
"u8proto",
".",
"U8proto",
",",
"trafficDirection",
"trafficdirection",
".",
"TrafficDirection",
")",
"error",
"{",
"k",
":=",
"newKey",
"(",
"id... | // Delete removes an entry from the PolicyMap for identity `id`
// sending traffic in direction `trafficDirection` with destination port `dport`
// over protocol `proto`. It is assumed that `dport` is in host byte-order.
// Returns an error if the deletion did not succeed. | [
"Delete",
"removes",
"an",
"entry",
"from",
"the",
"PolicyMap",
"for",
"identity",
"id",
"sending",
"traffic",
"in",
"direction",
"trafficDirection",
"with",
"destination",
"port",
"dport",
"over",
"protocol",
"proto",
".",
"It",
"is",
"assumed",
"that",
"dport"... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/policymap/policymap.go#L204-L207 |
162,621 | cilium/cilium | pkg/maps/policymap/policymap.go | String | func (pm *PolicyMap) String() string {
path, err := pm.Path()
if err != nil {
return err.Error()
}
return path
} | go | func (pm *PolicyMap) String() string {
path, err := pm.Path()
if err != nil {
return err.Error()
}
return path
} | [
"func",
"(",
"pm",
"*",
"PolicyMap",
")",
"String",
"(",
")",
"string",
"{",
"path",
",",
"err",
":=",
"pm",
".",
"Path",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
".",
"Error",
"(",
")",
"\n",
"}",
"\n",
"return",
"path",... | // String returns a human-readable string representing the policy map. | [
"String",
"returns",
"a",
"human",
"-",
"readable",
"string",
"representing",
"the",
"policy",
"map",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/policymap/policymap.go#L216-L222 |
162,622 | cilium/cilium | pkg/maps/policymap/policymap.go | Open | func Open(path string) (*PolicyMap, error) {
m := newMap(path)
if err := m.Open(); err != nil {
return nil, err
}
return m, nil
} | go | func Open(path string) (*PolicyMap, error) {
m := newMap(path)
if err := m.Open(); err != nil {
return nil, err
}
return m, nil
} | [
"func",
"Open",
"(",
"path",
"string",
")",
"(",
"*",
"PolicyMap",
",",
"error",
")",
"{",
"m",
":=",
"newMap",
"(",
"path",
")",
"\n",
"if",
"err",
":=",
"m",
".",
"Open",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
... | // Open opens the policymap at the specified path. | [
"Open",
"opens",
"the",
"policymap",
"at",
"the",
"specified",
"path",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/policymap/policymap.go#L286-L292 |
162,623 | cilium/cilium | pkg/health/server/prober.go | copyResultRLocked | func (p *prober) copyResultRLocked(ip string) *models.PathStatus {
status := p.results[ipString(ip)]
if status == nil {
return nil
}
result := &models.PathStatus{
IP: ip,
}
paths := map[**models.ConnectivityStatus]*models.ConnectivityStatus{
&result.Icmp: status.Icmp,
&result.HTTP: status.HTTP,
}
for res, value := range paths {
if value != nil {
*res = &*value
}
}
return result
} | go | func (p *prober) copyResultRLocked(ip string) *models.PathStatus {
status := p.results[ipString(ip)]
if status == nil {
return nil
}
result := &models.PathStatus{
IP: ip,
}
paths := map[**models.ConnectivityStatus]*models.ConnectivityStatus{
&result.Icmp: status.Icmp,
&result.HTTP: status.HTTP,
}
for res, value := range paths {
if value != nil {
*res = &*value
}
}
return result
} | [
"func",
"(",
"p",
"*",
"prober",
")",
"copyResultRLocked",
"(",
"ip",
"string",
")",
"*",
"models",
".",
"PathStatus",
"{",
"status",
":=",
"p",
".",
"results",
"[",
"ipString",
"(",
"ip",
")",
"]",
"\n",
"if",
"status",
"==",
"nil",
"{",
"return",
... | // copyResultRLocked makes a copy of the path status for the specified IP. | [
"copyResultRLocked",
"makes",
"a",
"copy",
"of",
"the",
"path",
"status",
"for",
"the",
"specified",
"IP",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/health/server/prober.go#L63-L82 |
162,624 | cilium/cilium | pkg/health/server/prober.go | getResults | func (p *prober) getResults() *healthReport {
p.RLock()
defer p.RUnlock()
// De-duplicate IPs in 'p.nodes' by building a map based on node.Name.
resultMap := map[string]*models.NodeStatus{}
for _, node := range p.nodes {
if resultMap[node.Name] != nil {
continue
}
primaryIP := node.PrimaryIP()
healthIP := node.HealthIP()
status := &models.NodeStatus{
Name: node.Name,
Host: &models.HostStatus{
PrimaryAddress: p.copyResultRLocked(primaryIP),
},
}
if healthIP != "" {
status.Endpoint = p.copyResultRLocked(healthIP)
}
secondaryResults := []*models.PathStatus{}
for _, addr := range node.SecondaryAddresses {
if addr.Enabled {
secondaryStatus := p.copyResultRLocked(addr.IP)
secondaryResults = append(secondaryResults, secondaryStatus)
}
}
status.Host.SecondaryAddresses = secondaryResults
resultMap[node.Name] = status
}
result := &healthReport{startTime: p.start}
for _, res := range resultMap {
result.nodes = append(result.nodes, res)
}
return result
} | go | func (p *prober) getResults() *healthReport {
p.RLock()
defer p.RUnlock()
// De-duplicate IPs in 'p.nodes' by building a map based on node.Name.
resultMap := map[string]*models.NodeStatus{}
for _, node := range p.nodes {
if resultMap[node.Name] != nil {
continue
}
primaryIP := node.PrimaryIP()
healthIP := node.HealthIP()
status := &models.NodeStatus{
Name: node.Name,
Host: &models.HostStatus{
PrimaryAddress: p.copyResultRLocked(primaryIP),
},
}
if healthIP != "" {
status.Endpoint = p.copyResultRLocked(healthIP)
}
secondaryResults := []*models.PathStatus{}
for _, addr := range node.SecondaryAddresses {
if addr.Enabled {
secondaryStatus := p.copyResultRLocked(addr.IP)
secondaryResults = append(secondaryResults, secondaryStatus)
}
}
status.Host.SecondaryAddresses = secondaryResults
resultMap[node.Name] = status
}
result := &healthReport{startTime: p.start}
for _, res := range resultMap {
result.nodes = append(result.nodes, res)
}
return result
} | [
"func",
"(",
"p",
"*",
"prober",
")",
"getResults",
"(",
")",
"*",
"healthReport",
"{",
"p",
".",
"RLock",
"(",
")",
"\n",
"defer",
"p",
".",
"RUnlock",
"(",
")",
"\n\n",
"// De-duplicate IPs in 'p.nodes' by building a map based on node.Name.",
"resultMap",
":="... | // getResults gathers a copy of all of the results for nodes currently in the
// cluster. | [
"getResults",
"gathers",
"a",
"copy",
"of",
"all",
"of",
"the",
"results",
"for",
"nodes",
"currently",
"in",
"the",
"cluster",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/health/server/prober.go#L86-L123 |
162,625 | cilium/cilium | pkg/health/server/prober.go | resolveIP | func resolveIP(n *healthNode, addr *ciliumModels.NodeAddressingElement, proto string, primary bool) (string, *net.IPAddr) {
node := n.NodeElement
network := "ip6:icmp"
if isIPv4(addr.IP) {
network = "ip4:icmp"
}
scopedLog := log.WithFields(logrus.Fields{
logfields.NodeName: node.Name,
logfields.IPAddr: addr.IP,
"primary": primary,
})
if skipAddress(addr) {
scopedLog.Debug("Skipping probe for address")
return "", nil
}
ra, err := net.ResolveIPAddr(network, addr.IP)
if err != nil {
scopedLog.Debug("Unable to resolve address")
return "", nil
}
scopedLog.WithField("protocol", proto).Debug("Probing for connectivity to node")
return node.Name, ra
} | go | func resolveIP(n *healthNode, addr *ciliumModels.NodeAddressingElement, proto string, primary bool) (string, *net.IPAddr) {
node := n.NodeElement
network := "ip6:icmp"
if isIPv4(addr.IP) {
network = "ip4:icmp"
}
scopedLog := log.WithFields(logrus.Fields{
logfields.NodeName: node.Name,
logfields.IPAddr: addr.IP,
"primary": primary,
})
if skipAddress(addr) {
scopedLog.Debug("Skipping probe for address")
return "", nil
}
ra, err := net.ResolveIPAddr(network, addr.IP)
if err != nil {
scopedLog.Debug("Unable to resolve address")
return "", nil
}
scopedLog.WithField("protocol", proto).Debug("Probing for connectivity to node")
return node.Name, ra
} | [
"func",
"resolveIP",
"(",
"n",
"*",
"healthNode",
",",
"addr",
"*",
"ciliumModels",
".",
"NodeAddressingElement",
",",
"proto",
"string",
",",
"primary",
"bool",
")",
"(",
"string",
",",
"*",
"net",
".",
"IPAddr",
")",
"{",
"node",
":=",
"n",
".",
"Nod... | // resolveIP attempts to sanitize 'node' and 'ip', and if successful, returns
// the name of the node and the IP address specified in the addressing element.
// If validation fails or this IP should not be pinged, 'ip' is returned as nil. | [
"resolveIP",
"attempts",
"to",
"sanitize",
"node",
"and",
"ip",
"and",
"if",
"successful",
"returns",
"the",
"name",
"of",
"the",
"node",
"and",
"the",
"IP",
"address",
"specified",
"in",
"the",
"addressing",
"element",
".",
"If",
"validation",
"fails",
"or"... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/health/server/prober.go#L137-L162 |
162,626 | cilium/cilium | pkg/health/server/prober.go | markIPsLocked | func (p *prober) markIPsLocked() {
for ip, node := range p.nodes {
node.deletionMark = true
p.nodes[ip] = node
}
} | go | func (p *prober) markIPsLocked() {
for ip, node := range p.nodes {
node.deletionMark = true
p.nodes[ip] = node
}
} | [
"func",
"(",
"p",
"*",
"prober",
")",
"markIPsLocked",
"(",
")",
"{",
"for",
"ip",
",",
"node",
":=",
"range",
"p",
".",
"nodes",
"{",
"node",
".",
"deletionMark",
"=",
"true",
"\n",
"p",
".",
"nodes",
"[",
"ip",
"]",
"=",
"node",
"\n",
"}",
"\... | // markIPsLocked marks all nodes in the prober for deletion. | [
"markIPsLocked",
"marks",
"all",
"nodes",
"in",
"the",
"prober",
"for",
"deletion",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/health/server/prober.go#L165-L170 |
162,627 | cilium/cilium | pkg/health/server/prober.go | sweepIPsLocked | func (p *prober) sweepIPsLocked() {
for ip, node := range p.nodes {
if node.deletionMark {
// Remove deleted nodes from:
// * Results (accessed from ICMP pinger or TCP prober)
// * ICMP pinger
// * TCP prober
for elem := range node.Addresses() {
delete(p.results, ipString(elem.IP))
p.RemoveIP(elem.IP) // ICMP pinger
}
delete(p.nodes, ip) // TCP prober
}
}
} | go | func (p *prober) sweepIPsLocked() {
for ip, node := range p.nodes {
if node.deletionMark {
// Remove deleted nodes from:
// * Results (accessed from ICMP pinger or TCP prober)
// * ICMP pinger
// * TCP prober
for elem := range node.Addresses() {
delete(p.results, ipString(elem.IP))
p.RemoveIP(elem.IP) // ICMP pinger
}
delete(p.nodes, ip) // TCP prober
}
}
} | [
"func",
"(",
"p",
"*",
"prober",
")",
"sweepIPsLocked",
"(",
")",
"{",
"for",
"ip",
",",
"node",
":=",
"range",
"p",
".",
"nodes",
"{",
"if",
"node",
".",
"deletionMark",
"{",
"// Remove deleted nodes from:",
"// * Results (accessed from ICMP pinger or TCP prober)... | // sweepIPsLocked iterates through nodes in the prober and removes nodes which
// are marked for deletion. | [
"sweepIPsLocked",
"iterates",
"through",
"nodes",
"in",
"the",
"prober",
"and",
"removes",
"nodes",
"which",
"are",
"marked",
"for",
"deletion",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/health/server/prober.go#L174-L188 |
162,628 | cilium/cilium | pkg/health/server/prober.go | setNodes | func (p *prober) setNodes(nodes nodeMap) {
p.Lock()
defer p.Unlock()
// Mark all nodes for deletion, insert nodes that should not be deleted
// then at the end of the function, sweep all nodes that remain as
// "to be deleted".
p.markIPsLocked()
for _, n := range nodes {
for elem, primary := range n.Addresses() {
_, addr := resolveIP(&n, elem, "icmp", primary)
ip := ipString(elem.IP)
result := &models.ConnectivityStatus{}
if addr == nil {
result.Status = "Failed to resolve IP"
} else {
result.Status = "Connection timed out"
p.AddIPAddr(addr)
p.nodes[ip] = n
}
if p.results[ip] == nil {
p.results[ip] = &models.PathStatus{
IP: elem.IP,
}
}
p.results[ip].Icmp = result
}
}
p.sweepIPsLocked()
} | go | func (p *prober) setNodes(nodes nodeMap) {
p.Lock()
defer p.Unlock()
// Mark all nodes for deletion, insert nodes that should not be deleted
// then at the end of the function, sweep all nodes that remain as
// "to be deleted".
p.markIPsLocked()
for _, n := range nodes {
for elem, primary := range n.Addresses() {
_, addr := resolveIP(&n, elem, "icmp", primary)
ip := ipString(elem.IP)
result := &models.ConnectivityStatus{}
if addr == nil {
result.Status = "Failed to resolve IP"
} else {
result.Status = "Connection timed out"
p.AddIPAddr(addr)
p.nodes[ip] = n
}
if p.results[ip] == nil {
p.results[ip] = &models.PathStatus{
IP: elem.IP,
}
}
p.results[ip].Icmp = result
}
}
p.sweepIPsLocked()
} | [
"func",
"(",
"p",
"*",
"prober",
")",
"setNodes",
"(",
"nodes",
"nodeMap",
")",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n\n",
"// Mark all nodes for deletion, insert nodes that should not be deleted",
"// then at the end of ... | // setNodes sets the list of nodes for the prober, and updates the pinger to
// start sending pings to all of the nodes.
// setNodes will steal references to nodes referenced from 'nodes', so the
// caller should not modify them after a call to setNodes. | [
"setNodes",
"sets",
"the",
"list",
"of",
"nodes",
"for",
"the",
"prober",
"and",
"updates",
"the",
"pinger",
"to",
"start",
"sending",
"pings",
"to",
"all",
"of",
"the",
"nodes",
".",
"setNodes",
"will",
"steal",
"references",
"to",
"nodes",
"referenced",
... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/health/server/prober.go#L194-L227 |
162,629 | cilium/cilium | pkg/health/server/prober.go | Run | func (p *prober) Run() error {
err := p.Pinger.Run()
p.runHTTPProbe()
return err
} | go | func (p *prober) Run() error {
err := p.Pinger.Run()
p.runHTTPProbe()
return err
} | [
"func",
"(",
"p",
"*",
"prober",
")",
"Run",
"(",
")",
"error",
"{",
"err",
":=",
"p",
".",
"Pinger",
".",
"Run",
"(",
")",
"\n",
"p",
".",
"runHTTPProbe",
"(",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Run sends a single probes out to all of the other cilium nodes to gather
// connectivity status for the cluster. | [
"Run",
"sends",
"a",
"single",
"probes",
"out",
"to",
"all",
"of",
"the",
"other",
"cilium",
"nodes",
"to",
"gather",
"connectivity",
"status",
"for",
"the",
"cluster",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/health/server/prober.go#L332-L336 |
162,630 | cilium/cilium | api/v1/client/ipam/post_ip_a_m_ip_parameters.go | WithTimeout | func (o *PostIPAMIPParams) WithTimeout(timeout time.Duration) *PostIPAMIPParams {
o.SetTimeout(timeout)
return o
} | go | func (o *PostIPAMIPParams) WithTimeout(timeout time.Duration) *PostIPAMIPParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"PostIPAMIPParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"PostIPAMIPParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the post IP a m IP params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"post",
"IP",
"a",
"m",
"IP",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/ipam/post_ip_a_m_ip_parameters.go#L78-L81 |
162,631 | cilium/cilium | api/v1/client/ipam/post_ip_a_m_ip_parameters.go | WithContext | func (o *PostIPAMIPParams) WithContext(ctx context.Context) *PostIPAMIPParams {
o.SetContext(ctx)
return o
} | go | func (o *PostIPAMIPParams) WithContext(ctx context.Context) *PostIPAMIPParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"PostIPAMIPParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"PostIPAMIPParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the post IP a m IP params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"post",
"IP",
"a",
"m",
"IP",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/ipam/post_ip_a_m_ip_parameters.go#L89-L92 |
162,632 | cilium/cilium | api/v1/client/ipam/post_ip_a_m_ip_parameters.go | WithHTTPClient | func (o *PostIPAMIPParams) WithHTTPClient(client *http.Client) *PostIPAMIPParams {
o.SetHTTPClient(client)
return o
} | go | func (o *PostIPAMIPParams) WithHTTPClient(client *http.Client) *PostIPAMIPParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"PostIPAMIPParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"PostIPAMIPParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the post IP a m IP params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"post",
"IP",
"a",
"m",
"IP",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/ipam/post_ip_a_m_ip_parameters.go#L100-L103 |
162,633 | cilium/cilium | api/v1/client/ipam/post_ip_a_m_ip_parameters.go | WithIP | func (o *PostIPAMIPParams) WithIP(ip string) *PostIPAMIPParams {
o.SetIP(ip)
return o
} | go | func (o *PostIPAMIPParams) WithIP(ip string) *PostIPAMIPParams {
o.SetIP(ip)
return o
} | [
"func",
"(",
"o",
"*",
"PostIPAMIPParams",
")",
"WithIP",
"(",
"ip",
"string",
")",
"*",
"PostIPAMIPParams",
"{",
"o",
".",
"SetIP",
"(",
"ip",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithIP adds the ip to the post IP a m IP params | [
"WithIP",
"adds",
"the",
"ip",
"to",
"the",
"post",
"IP",
"a",
"m",
"IP",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/ipam/post_ip_a_m_ip_parameters.go#L111-L114 |
162,634 | cilium/cilium | api/v1/client/ipam/post_ip_a_m_ip_parameters.go | WithOwner | func (o *PostIPAMIPParams) WithOwner(owner *string) *PostIPAMIPParams {
o.SetOwner(owner)
return o
} | go | func (o *PostIPAMIPParams) WithOwner(owner *string) *PostIPAMIPParams {
o.SetOwner(owner)
return o
} | [
"func",
"(",
"o",
"*",
"PostIPAMIPParams",
")",
"WithOwner",
"(",
"owner",
"*",
"string",
")",
"*",
"PostIPAMIPParams",
"{",
"o",
".",
"SetOwner",
"(",
"owner",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithOwner adds the owner to the post IP a m IP params | [
"WithOwner",
"adds",
"the",
"owner",
"to",
"the",
"post",
"IP",
"a",
"m",
"IP",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/ipam/post_ip_a_m_ip_parameters.go#L122-L125 |
162,635 | cilium/cilium | api/v1/client/daemon/get_debuginfo_parameters.go | WithTimeout | func (o *GetDebuginfoParams) WithTimeout(timeout time.Duration) *GetDebuginfoParams {
o.SetTimeout(timeout)
return o
} | go | func (o *GetDebuginfoParams) WithTimeout(timeout time.Duration) *GetDebuginfoParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"GetDebuginfoParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"GetDebuginfoParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the get debuginfo params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"get",
"debuginfo",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/daemon/get_debuginfo_parameters.go#L69-L72 |
162,636 | cilium/cilium | api/v1/client/daemon/get_debuginfo_parameters.go | WithContext | func (o *GetDebuginfoParams) WithContext(ctx context.Context) *GetDebuginfoParams {
o.SetContext(ctx)
return o
} | go | func (o *GetDebuginfoParams) WithContext(ctx context.Context) *GetDebuginfoParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"GetDebuginfoParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"GetDebuginfoParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the get debuginfo params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"get",
"debuginfo",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/daemon/get_debuginfo_parameters.go#L80-L83 |
162,637 | cilium/cilium | api/v1/client/daemon/get_debuginfo_parameters.go | WithHTTPClient | func (o *GetDebuginfoParams) WithHTTPClient(client *http.Client) *GetDebuginfoParams {
o.SetHTTPClient(client)
return o
} | go | func (o *GetDebuginfoParams) WithHTTPClient(client *http.Client) *GetDebuginfoParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"GetDebuginfoParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"GetDebuginfoParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the get debuginfo params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"get",
"debuginfo",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/daemon/get_debuginfo_parameters.go#L91-L94 |
162,638 | cilium/cilium | pkg/labels/filter.go | String | func (p LabelPrefix) String() string {
s := fmt.Sprintf("%s:%s", p.Source, p.Prefix)
if p.Ignore {
s = "!" + s
}
return s
} | go | func (p LabelPrefix) String() string {
s := fmt.Sprintf("%s:%s", p.Source, p.Prefix)
if p.Ignore {
s = "!" + s
}
return s
} | [
"func",
"(",
"p",
"LabelPrefix",
")",
"String",
"(",
")",
"string",
"{",
"s",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"p",
".",
"Source",
",",
"p",
".",
"Prefix",
")",
"\n",
"if",
"p",
".",
"Ignore",
"{",
"s",
"=",
"\"",
"\"",
"+",... | // String returns a human readable representation of the LabelPrefix | [
"String",
"returns",
"a",
"human",
"readable",
"representation",
"of",
"the",
"LabelPrefix"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/filter.go#L53-L60 |
162,639 | cilium/cilium | pkg/labels/filter.go | matches | func (p LabelPrefix) matches(l Label) (bool, int) {
if p.Source != "" && p.Source != l.Source {
return false, 0
}
// If no regular expression is available, fall back to prefix matching
if p.expr == nil {
return strings.HasPrefix(l.Key, p.Prefix), len(p.Prefix)
}
res := p.expr.FindStringIndex(l.Key)
// No match if regexp was not found
if res == nil {
return false, 0
}
// Otherwise match if match was found at start of key
return res[0] == 0, res[1]
} | go | func (p LabelPrefix) matches(l Label) (bool, int) {
if p.Source != "" && p.Source != l.Source {
return false, 0
}
// If no regular expression is available, fall back to prefix matching
if p.expr == nil {
return strings.HasPrefix(l.Key, p.Prefix), len(p.Prefix)
}
res := p.expr.FindStringIndex(l.Key)
// No match if regexp was not found
if res == nil {
return false, 0
}
// Otherwise match if match was found at start of key
return res[0] == 0, res[1]
} | [
"func",
"(",
"p",
"LabelPrefix",
")",
"matches",
"(",
"l",
"Label",
")",
"(",
"bool",
",",
"int",
")",
"{",
"if",
"p",
".",
"Source",
"!=",
"\"",
"\"",
"&&",
"p",
".",
"Source",
"!=",
"l",
".",
"Source",
"{",
"return",
"false",
",",
"0",
"\n",
... | // matches returns true and the length of the matched section if the label is
// matched by the LabelPrefix. The Ignore flag has no effect at this point. | [
"matches",
"returns",
"true",
"and",
"the",
"length",
"of",
"the",
"matched",
"section",
"if",
"the",
"label",
"is",
"matched",
"by",
"the",
"LabelPrefix",
".",
"The",
"Ignore",
"flag",
"has",
"no",
"effect",
"at",
"this",
"point",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/filter.go#L64-L83 |
162,640 | cilium/cilium | pkg/labels/filter.go | parseLabelPrefix | func parseLabelPrefix(label string) (*LabelPrefix, error) {
labelPrefix := LabelPrefix{}
i := strings.IndexByte(label, ':')
if i >= 0 {
labelPrefix.Source = label[:i]
labelPrefix.Prefix = label[i+1:]
} else {
labelPrefix.Prefix = label
}
if labelPrefix.Prefix[0] == '!' {
labelPrefix.Ignore = true
labelPrefix.Prefix = labelPrefix.Prefix[1:]
}
r, err := regexp.Compile(labelPrefix.Prefix)
if err != nil {
return nil, fmt.Errorf("Unable to compile regexp: %s", err)
}
labelPrefix.expr = r
return &labelPrefix, nil
} | go | func parseLabelPrefix(label string) (*LabelPrefix, error) {
labelPrefix := LabelPrefix{}
i := strings.IndexByte(label, ':')
if i >= 0 {
labelPrefix.Source = label[:i]
labelPrefix.Prefix = label[i+1:]
} else {
labelPrefix.Prefix = label
}
if labelPrefix.Prefix[0] == '!' {
labelPrefix.Ignore = true
labelPrefix.Prefix = labelPrefix.Prefix[1:]
}
r, err := regexp.Compile(labelPrefix.Prefix)
if err != nil {
return nil, fmt.Errorf("Unable to compile regexp: %s", err)
}
labelPrefix.expr = r
return &labelPrefix, nil
} | [
"func",
"parseLabelPrefix",
"(",
"label",
"string",
")",
"(",
"*",
"LabelPrefix",
",",
"error",
")",
"{",
"labelPrefix",
":=",
"LabelPrefix",
"{",
"}",
"\n",
"i",
":=",
"strings",
".",
"IndexByte",
"(",
"label",
",",
"':'",
")",
"\n",
"if",
"i",
">=",
... | // parseLabelPrefix returns a LabelPrefix created from the string label parameter. | [
"parseLabelPrefix",
"returns",
"a",
"LabelPrefix",
"created",
"from",
"the",
"string",
"label",
"parameter",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/filter.go#L86-L108 |
162,641 | cilium/cilium | pkg/labels/filter.go | ParseLabelPrefixCfg | func ParseLabelPrefixCfg(prefixes []string, file string) error {
cfg, err := readLabelPrefixCfgFrom(file)
if err != nil {
return fmt.Errorf("Unable to read label prefix file: %s", err)
}
for _, label := range prefixes {
p, err := parseLabelPrefix(label)
if err != nil {
return err
}
if !p.Ignore {
cfg.whitelist = true
}
cfg.LabelPrefixes = append(cfg.LabelPrefixes, p)
}
validLabelPrefixes = cfg
log.Info("Valid label prefix configuration:")
for _, l := range validLabelPrefixes.LabelPrefixes {
log.Infof(" - %s", l)
}
return nil
} | go | func ParseLabelPrefixCfg(prefixes []string, file string) error {
cfg, err := readLabelPrefixCfgFrom(file)
if err != nil {
return fmt.Errorf("Unable to read label prefix file: %s", err)
}
for _, label := range prefixes {
p, err := parseLabelPrefix(label)
if err != nil {
return err
}
if !p.Ignore {
cfg.whitelist = true
}
cfg.LabelPrefixes = append(cfg.LabelPrefixes, p)
}
validLabelPrefixes = cfg
log.Info("Valid label prefix configuration:")
for _, l := range validLabelPrefixes.LabelPrefixes {
log.Infof(" - %s", l)
}
return nil
} | [
"func",
"ParseLabelPrefixCfg",
"(",
"prefixes",
"[",
"]",
"string",
",",
"file",
"string",
")",
"error",
"{",
"cfg",
",",
"err",
":=",
"readLabelPrefixCfgFrom",
"(",
"file",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
... | // ParseLabelPrefixCfg parses valid label prefixes from a file and from a slice
// of valid prefixes. Both are optional. If both are provided, both list are
// appended together. | [
"ParseLabelPrefixCfg",
"parses",
"valid",
"label",
"prefixes",
"from",
"a",
"file",
"and",
"from",
"a",
"slice",
"of",
"valid",
"prefixes",
".",
"Both",
"are",
"optional",
".",
"If",
"both",
"are",
"provided",
"both",
"list",
"are",
"appended",
"together",
"... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/filter.go#L113-L140 |
162,642 | cilium/cilium | pkg/labels/filter.go | defaultLabelPrefixCfg | func defaultLabelPrefixCfg() *labelPrefixCfg {
cfg := &labelPrefixCfg{
Version: LPCfgFileVersion,
LabelPrefixes: []*LabelPrefix{},
}
expressions := []string{
k8sConst.PodNamespaceLabel, // include io.kubernetes.pod.namspace
k8sConst.PodNamespaceMetaLabels, // include all namespace labels
"!io.kubernetes", // ignore all other io.kubernetes labels
"!.*kubernetes.io", // ignore all other kubernetes.io labels (annotation.*.k8s.io)
"!pod-template-generation", // ignore pod-template-generation
"!pod-template-hash", // ignore pod-template-hash
"!controller-revision-hash", // ignore controller-revision-hash
"!annotation." + k8sConst.CiliumK8sAnnotationPrefix, // ignore all cilium annotations
"!annotation." + k8sConst.CiliumIdentityAnnotationDeprecated, // ignore all cilium annotations
"!annotation.sidecar.istio.io", // ignore all istio sidecar annotation labels
"!annotation.etcd.version", // ignore all etcd.version annotations
"!etcd_node", // ignore etcd_node label
}
for _, e := range expressions {
p, err := parseLabelPrefix(e)
if err != nil {
msg := fmt.Sprintf("BUG: Unable to parse default label prefix '%s': %s", e, err)
panic(msg)
}
cfg.LabelPrefixes = append(cfg.LabelPrefixes, p)
}
return cfg
} | go | func defaultLabelPrefixCfg() *labelPrefixCfg {
cfg := &labelPrefixCfg{
Version: LPCfgFileVersion,
LabelPrefixes: []*LabelPrefix{},
}
expressions := []string{
k8sConst.PodNamespaceLabel, // include io.kubernetes.pod.namspace
k8sConst.PodNamespaceMetaLabels, // include all namespace labels
"!io.kubernetes", // ignore all other io.kubernetes labels
"!.*kubernetes.io", // ignore all other kubernetes.io labels (annotation.*.k8s.io)
"!pod-template-generation", // ignore pod-template-generation
"!pod-template-hash", // ignore pod-template-hash
"!controller-revision-hash", // ignore controller-revision-hash
"!annotation." + k8sConst.CiliumK8sAnnotationPrefix, // ignore all cilium annotations
"!annotation." + k8sConst.CiliumIdentityAnnotationDeprecated, // ignore all cilium annotations
"!annotation.sidecar.istio.io", // ignore all istio sidecar annotation labels
"!annotation.etcd.version", // ignore all etcd.version annotations
"!etcd_node", // ignore etcd_node label
}
for _, e := range expressions {
p, err := parseLabelPrefix(e)
if err != nil {
msg := fmt.Sprintf("BUG: Unable to parse default label prefix '%s': %s", e, err)
panic(msg)
}
cfg.LabelPrefixes = append(cfg.LabelPrefixes, p)
}
return cfg
} | [
"func",
"defaultLabelPrefixCfg",
"(",
")",
"*",
"labelPrefixCfg",
"{",
"cfg",
":=",
"&",
"labelPrefixCfg",
"{",
"Version",
":",
"LPCfgFileVersion",
",",
"LabelPrefixes",
":",
"[",
"]",
"*",
"LabelPrefix",
"{",
"}",
",",
"}",
"\n\n",
"expressions",
":=",
"[",... | // defaultLabelPrefixCfg returns a default LabelPrefixCfg using the latest
// LPCfgFileVersion | [
"defaultLabelPrefixCfg",
"returns",
"a",
"default",
"LabelPrefixCfg",
"using",
"the",
"latest",
"LPCfgFileVersion"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/filter.go#L155-L186 |
162,643 | cilium/cilium | pkg/labels/filter.go | readLabelPrefixCfgFrom | func readLabelPrefixCfgFrom(fileName string) (*labelPrefixCfg, error) {
// if not file is specified, the default is empty
if fileName == "" {
return defaultLabelPrefixCfg(), nil
}
f, err := os.Open(fileName)
if err != nil {
return nil, err
}
defer f.Close()
lpc := labelPrefixCfg{}
err = json.NewDecoder(f).Decode(&lpc)
if err != nil {
return nil, err
}
if lpc.Version != LPCfgFileVersion {
return nil, fmt.Errorf("unsupported version %d", lpc.Version)
}
for _, lp := range lpc.LabelPrefixes {
if lp.Prefix == "" {
return nil, fmt.Errorf("invalid label prefix file: prefix was empty")
}
if lp.Source == "" {
return nil, fmt.Errorf("invalid label prefix file: source was empty")
}
if !lp.Ignore {
lpc.whitelist = true
}
}
return &lpc, nil
} | go | func readLabelPrefixCfgFrom(fileName string) (*labelPrefixCfg, error) {
// if not file is specified, the default is empty
if fileName == "" {
return defaultLabelPrefixCfg(), nil
}
f, err := os.Open(fileName)
if err != nil {
return nil, err
}
defer f.Close()
lpc := labelPrefixCfg{}
err = json.NewDecoder(f).Decode(&lpc)
if err != nil {
return nil, err
}
if lpc.Version != LPCfgFileVersion {
return nil, fmt.Errorf("unsupported version %d", lpc.Version)
}
for _, lp := range lpc.LabelPrefixes {
if lp.Prefix == "" {
return nil, fmt.Errorf("invalid label prefix file: prefix was empty")
}
if lp.Source == "" {
return nil, fmt.Errorf("invalid label prefix file: source was empty")
}
if !lp.Ignore {
lpc.whitelist = true
}
}
return &lpc, nil
} | [
"func",
"readLabelPrefixCfgFrom",
"(",
"fileName",
"string",
")",
"(",
"*",
"labelPrefixCfg",
",",
"error",
")",
"{",
"// if not file is specified, the default is empty",
"if",
"fileName",
"==",
"\"",
"\"",
"{",
"return",
"defaultLabelPrefixCfg",
"(",
")",
",",
"nil... | // readLabelPrefixCfgFrom reads a label prefix configuration file from fileName. If the
// version is not supported by us it returns an error. | [
"readLabelPrefixCfgFrom",
"reads",
"a",
"label",
"prefix",
"configuration",
"file",
"from",
"fileName",
".",
"If",
"the",
"version",
"is",
"not",
"supported",
"by",
"us",
"it",
"returns",
"an",
"error",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/filter.go#L190-L221 |
162,644 | cilium/cilium | pkg/bpf/bpf.go | GetPreAllocateMapFlags | func GetPreAllocateMapFlags(t MapType) uint32 {
switch {
case !t.allowsPreallocation():
return BPF_F_NO_PREALLOC
case t.requiresPreallocation():
return 0
}
return atomic.LoadUint32(&preAllocateMapSetting)
} | go | func GetPreAllocateMapFlags(t MapType) uint32 {
switch {
case !t.allowsPreallocation():
return BPF_F_NO_PREALLOC
case t.requiresPreallocation():
return 0
}
return atomic.LoadUint32(&preAllocateMapSetting)
} | [
"func",
"GetPreAllocateMapFlags",
"(",
"t",
"MapType",
")",
"uint32",
"{",
"switch",
"{",
"case",
"!",
"t",
".",
"allowsPreallocation",
"(",
")",
":",
"return",
"BPF_F_NO_PREALLOC",
"\n",
"case",
"t",
".",
"requiresPreallocation",
"(",
")",
":",
"return",
"0... | // GetPreAllocateMapFlags returns the map flags for map which use conditional
// pre-allocation. | [
"GetPreAllocateMapFlags",
"returns",
"the",
"map",
"flags",
"for",
"map",
"which",
"use",
"conditional",
"pre",
"-",
"allocation",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/bpf.go#L115-L123 |
162,645 | cilium/cilium | api/v1/server/restapi/daemon/get_config.go | NewGetConfig | func NewGetConfig(ctx *middleware.Context, handler GetConfigHandler) *GetConfig {
return &GetConfig{Context: ctx, Handler: handler}
} | go | func NewGetConfig(ctx *middleware.Context, handler GetConfigHandler) *GetConfig {
return &GetConfig{Context: ctx, Handler: handler}
} | [
"func",
"NewGetConfig",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"GetConfigHandler",
")",
"*",
"GetConfig",
"{",
"return",
"&",
"GetConfig",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewGetConfig creates a new http.Handler for the get config operation | [
"NewGetConfig",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"get",
"config",
"operation"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/daemon/get_config.go#L28-L30 |
162,646 | cilium/cilium | pkg/policy/l4.go | HasL3DependentL7Rules | func (l4 *L4Filter) HasL3DependentL7Rules() bool {
switch len(l4.L7RulesPerEp) {
case 0:
// No L7 rules.
return false
case 1:
// If L3 is wildcarded, this filter corresponds to L4-only rule(s).
_, ok := l4.L7RulesPerEp[api.WildcardEndpointSelector]
return !ok
default:
return true
}
} | go | func (l4 *L4Filter) HasL3DependentL7Rules() bool {
switch len(l4.L7RulesPerEp) {
case 0:
// No L7 rules.
return false
case 1:
// If L3 is wildcarded, this filter corresponds to L4-only rule(s).
_, ok := l4.L7RulesPerEp[api.WildcardEndpointSelector]
return !ok
default:
return true
}
} | [
"func",
"(",
"l4",
"*",
"L4Filter",
")",
"HasL3DependentL7Rules",
"(",
")",
"bool",
"{",
"switch",
"len",
"(",
"l4",
".",
"L7RulesPerEp",
")",
"{",
"case",
"0",
":",
"// No L7 rules.",
"return",
"false",
"\n",
"case",
"1",
":",
"// If L3 is wildcarded, this ... | // HasL3DependentL7Rules returns true if this L4Filter is created from rules
// that require an L3 match as well as specific L7 rules. | [
"HasL3DependentL7Rules",
"returns",
"true",
"if",
"this",
"L4Filter",
"is",
"created",
"from",
"rules",
"that",
"require",
"an",
"L3",
"match",
"as",
"well",
"as",
"specific",
"L7",
"rules",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/l4.go#L127-L139 |
162,647 | cilium/cilium | pkg/policy/l4.go | ToKeys | func (l4 *L4Filter) ToKeys(direction trafficdirection.TrafficDirection, identityCache cache.IdentityCache, deniedIdentities cache.IdentityCache) []Key {
keysToAdd := []Key{}
port := uint16(l4.Port)
proto := uint8(l4.U8Proto)
// The BPF datapath only supports a value of '0' for identity (wildcarding
// at L3) if there is a corresponding port (i.e., a non-zero port).
// Wildcarding at L3 and L4 at the same time is not understood by the
// datapath at this time. So, if we have L3-only policy (e.g., port == 0),
// we need to explicitly allow each identity at port 0.
if l4.AllowsAllAtL3() && l4.Port != 0 {
keyToAdd := Key{
Identity: 0,
// NOTE: Port is in host byte-order!
DestPort: port,
Nexthdr: proto,
TrafficDirection: direction.Uint8(),
}
keysToAdd = append(keysToAdd, keyToAdd)
if !l4.HasL3DependentL7Rules() {
return keysToAdd
} // else we need to calculate all L3-dependent L4 peers below.
}
for _, sel := range l4.Endpoints {
identities := getSecurityIdentities(identityCache, &sel)
for _, id := range identities {
if _, identityIsDenied := deniedIdentities[id]; !identityIsDenied {
srcID := id.Uint32()
keyToAdd := Key{
Identity: srcID,
// NOTE: Port is in host byte-order!
DestPort: port,
Nexthdr: proto,
TrafficDirection: direction.Uint8(),
}
keysToAdd = append(keysToAdd, keyToAdd)
}
}
}
return keysToAdd
} | go | func (l4 *L4Filter) ToKeys(direction trafficdirection.TrafficDirection, identityCache cache.IdentityCache, deniedIdentities cache.IdentityCache) []Key {
keysToAdd := []Key{}
port := uint16(l4.Port)
proto := uint8(l4.U8Proto)
// The BPF datapath only supports a value of '0' for identity (wildcarding
// at L3) if there is a corresponding port (i.e., a non-zero port).
// Wildcarding at L3 and L4 at the same time is not understood by the
// datapath at this time. So, if we have L3-only policy (e.g., port == 0),
// we need to explicitly allow each identity at port 0.
if l4.AllowsAllAtL3() && l4.Port != 0 {
keyToAdd := Key{
Identity: 0,
// NOTE: Port is in host byte-order!
DestPort: port,
Nexthdr: proto,
TrafficDirection: direction.Uint8(),
}
keysToAdd = append(keysToAdd, keyToAdd)
if !l4.HasL3DependentL7Rules() {
return keysToAdd
} // else we need to calculate all L3-dependent L4 peers below.
}
for _, sel := range l4.Endpoints {
identities := getSecurityIdentities(identityCache, &sel)
for _, id := range identities {
if _, identityIsDenied := deniedIdentities[id]; !identityIsDenied {
srcID := id.Uint32()
keyToAdd := Key{
Identity: srcID,
// NOTE: Port is in host byte-order!
DestPort: port,
Nexthdr: proto,
TrafficDirection: direction.Uint8(),
}
keysToAdd = append(keysToAdd, keyToAdd)
}
}
}
return keysToAdd
} | [
"func",
"(",
"l4",
"*",
"L4Filter",
")",
"ToKeys",
"(",
"direction",
"trafficdirection",
".",
"TrafficDirection",
",",
"identityCache",
"cache",
".",
"IdentityCache",
",",
"deniedIdentities",
"cache",
".",
"IdentityCache",
")",
"[",
"]",
"Key",
"{",
"keysToAdd",... | // ToKeys converts filter into a list of Keys. | [
"ToKeys",
"converts",
"filter",
"into",
"a",
"list",
"of",
"Keys",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/l4.go#L142-L184 |
162,648 | cilium/cilium | pkg/policy/l4.go | MarshalIndent | func (l4 *L4Filter) MarshalIndent() string {
b, err := json.MarshalIndent(l4, "", " ")
if err != nil {
b = []byte("\"L4Filter error: " + err.Error() + "\"")
}
return string(b)
} | go | func (l4 *L4Filter) MarshalIndent() string {
b, err := json.MarshalIndent(l4, "", " ")
if err != nil {
b = []byte("\"L4Filter error: " + err.Error() + "\"")
}
return string(b)
} | [
"func",
"(",
"l4",
"*",
"L4Filter",
")",
"MarshalIndent",
"(",
")",
"string",
"{",
"b",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"l4",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"b",
"=",
"[",
"]",
... | // MarshalIndent returns the `L4Filter` in indented JSON string. | [
"MarshalIndent",
"returns",
"the",
"L4Filter",
"in",
"indented",
"JSON",
"string",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/l4.go#L322-L328 |
162,649 | cilium/cilium | pkg/policy/l4.go | String | func (l4 L4Filter) String() string {
b, err := json.Marshal(l4)
if err != nil {
return err.Error()
}
return string(b)
} | go | func (l4 L4Filter) String() string {
b, err := json.Marshal(l4)
if err != nil {
return err.Error()
}
return string(b)
} | [
"func",
"(",
"l4",
"L4Filter",
")",
"String",
"(",
")",
"string",
"{",
"b",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"l4",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
".",
"Error",
"(",
")",
"\n",
"}",
"\n",
"return",
"stri... | // String returns the `L4Filter` in a human-readable string. | [
"String",
"returns",
"the",
"L4Filter",
"in",
"a",
"human",
"-",
"readable",
"string",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/l4.go#L331-L337 |
162,650 | cilium/cilium | pkg/policy/l4.go | HasRedirect | func (l4 L4PolicyMap) HasRedirect() bool {
for _, f := range l4 {
if f.IsRedirect() {
return true
}
}
return false
} | go | func (l4 L4PolicyMap) HasRedirect() bool {
for _, f := range l4 {
if f.IsRedirect() {
return true
}
}
return false
} | [
"func",
"(",
"l4",
"L4PolicyMap",
")",
"HasRedirect",
"(",
")",
"bool",
"{",
"for",
"_",
",",
"f",
":=",
"range",
"l4",
"{",
"if",
"f",
".",
"IsRedirect",
"(",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"... | // HasRedirect returns true if at least one L4 filter contains a port
// redirection | [
"HasRedirect",
"returns",
"true",
"if",
"at",
"least",
"one",
"L4",
"filter",
"contains",
"a",
"port",
"redirection"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/l4.go#L361-L369 |
162,651 | cilium/cilium | pkg/policy/l4.go | IngressCoversContext | func (l4 *L4PolicyMap) IngressCoversContext(ctx *SearchContext) api.Decision {
return l4.containsAllL3L4(ctx.From, ctx.DPorts)
} | go | func (l4 *L4PolicyMap) IngressCoversContext(ctx *SearchContext) api.Decision {
return l4.containsAllL3L4(ctx.From, ctx.DPorts)
} | [
"func",
"(",
"l4",
"*",
"L4PolicyMap",
")",
"IngressCoversContext",
"(",
"ctx",
"*",
"SearchContext",
")",
"api",
".",
"Decision",
"{",
"return",
"l4",
".",
"containsAllL3L4",
"(",
"ctx",
".",
"From",
",",
"ctx",
".",
"DPorts",
")",
"\n",
"}"
] | // IngressCoversContext checks if the receiver's ingress L4Policy contains
// all `dPorts` and `labels`. | [
"IngressCoversContext",
"checks",
"if",
"the",
"receiver",
"s",
"ingress",
"L4Policy",
"contains",
"all",
"dPorts",
"and",
"labels",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/l4.go#L438-L440 |
162,652 | cilium/cilium | pkg/policy/l4.go | EgressCoversContext | func (l4 *L4PolicyMap) EgressCoversContext(ctx *SearchContext) api.Decision {
return l4.containsAllL3L4(ctx.To, ctx.DPorts)
} | go | func (l4 *L4PolicyMap) EgressCoversContext(ctx *SearchContext) api.Decision {
return l4.containsAllL3L4(ctx.To, ctx.DPorts)
} | [
"func",
"(",
"l4",
"*",
"L4PolicyMap",
")",
"EgressCoversContext",
"(",
"ctx",
"*",
"SearchContext",
")",
"api",
".",
"Decision",
"{",
"return",
"l4",
".",
"containsAllL3L4",
"(",
"ctx",
".",
"To",
",",
"ctx",
".",
"DPorts",
")",
"\n",
"}"
] | // EgressCoversContext checks if the receiver's egress L4Policy contains
// all `dPorts` and `labels`. | [
"EgressCoversContext",
"checks",
"if",
"the",
"receiver",
"s",
"egress",
"L4Policy",
"contains",
"all",
"dPorts",
"and",
"labels",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/l4.go#L444-L446 |
162,653 | cilium/cilium | pkg/policy/l4.go | HasRedirect | func (l4 *L4Policy) HasRedirect() bool {
return l4 != nil && (l4.Ingress.HasRedirect() || l4.Egress.HasRedirect())
} | go | func (l4 *L4Policy) HasRedirect() bool {
return l4 != nil && (l4.Ingress.HasRedirect() || l4.Egress.HasRedirect())
} | [
"func",
"(",
"l4",
"*",
"L4Policy",
")",
"HasRedirect",
"(",
")",
"bool",
"{",
"return",
"l4",
"!=",
"nil",
"&&",
"(",
"l4",
".",
"Ingress",
".",
"HasRedirect",
"(",
")",
"||",
"l4",
".",
"Egress",
".",
"HasRedirect",
"(",
")",
")",
"\n",
"}"
] | // HasRedirect returns true if the L4 policy contains at least one port redirection | [
"HasRedirect",
"returns",
"true",
"if",
"the",
"L4",
"policy",
"contains",
"at",
"least",
"one",
"port",
"redirection"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/l4.go#L449-L451 |
162,654 | cilium/cilium | pkg/policy/l4.go | RequiresConntrack | func (l4 *L4Policy) RequiresConntrack() bool {
return l4 != nil && (len(l4.Ingress) > 0 || len(l4.Egress) > 0)
} | go | func (l4 *L4Policy) RequiresConntrack() bool {
return l4 != nil && (len(l4.Ingress) > 0 || len(l4.Egress) > 0)
} | [
"func",
"(",
"l4",
"*",
"L4Policy",
")",
"RequiresConntrack",
"(",
")",
"bool",
"{",
"return",
"l4",
"!=",
"nil",
"&&",
"(",
"len",
"(",
"l4",
".",
"Ingress",
")",
">",
"0",
"||",
"len",
"(",
"l4",
".",
"Egress",
")",
">",
"0",
")",
"\n",
"}"
] | // RequiresConntrack returns true if if the L4 configuration requires
// connection tracking to be enabled. | [
"RequiresConntrack",
"returns",
"true",
"if",
"if",
"the",
"L4",
"configuration",
"requires",
"connection",
"tracking",
"to",
"be",
"enabled",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/l4.go#L455-L457 |
162,655 | cilium/cilium | api/v1/client/service/put_service_id_parameters.go | WithTimeout | func (o *PutServiceIDParams) WithTimeout(timeout time.Duration) *PutServiceIDParams {
o.SetTimeout(timeout)
return o
} | go | func (o *PutServiceIDParams) WithTimeout(timeout time.Duration) *PutServiceIDParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"PutServiceIDParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"PutServiceIDParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the put service ID params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"put",
"service",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/service/put_service_id_parameters.go#L84-L87 |
162,656 | cilium/cilium | api/v1/client/service/put_service_id_parameters.go | WithContext | func (o *PutServiceIDParams) WithContext(ctx context.Context) *PutServiceIDParams {
o.SetContext(ctx)
return o
} | go | func (o *PutServiceIDParams) WithContext(ctx context.Context) *PutServiceIDParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"PutServiceIDParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"PutServiceIDParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the put service ID params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"put",
"service",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/service/put_service_id_parameters.go#L95-L98 |
162,657 | cilium/cilium | api/v1/client/service/put_service_id_parameters.go | WithHTTPClient | func (o *PutServiceIDParams) WithHTTPClient(client *http.Client) *PutServiceIDParams {
o.SetHTTPClient(client)
return o
} | go | func (o *PutServiceIDParams) WithHTTPClient(client *http.Client) *PutServiceIDParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"PutServiceIDParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"PutServiceIDParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the put service ID params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"put",
"service",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/service/put_service_id_parameters.go#L106-L109 |
162,658 | cilium/cilium | api/v1/client/service/put_service_id_parameters.go | WithConfig | func (o *PutServiceIDParams) WithConfig(config *models.ServiceSpec) *PutServiceIDParams {
o.SetConfig(config)
return o
} | go | func (o *PutServiceIDParams) WithConfig(config *models.ServiceSpec) *PutServiceIDParams {
o.SetConfig(config)
return o
} | [
"func",
"(",
"o",
"*",
"PutServiceIDParams",
")",
"WithConfig",
"(",
"config",
"*",
"models",
".",
"ServiceSpec",
")",
"*",
"PutServiceIDParams",
"{",
"o",
".",
"SetConfig",
"(",
"config",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithConfig adds the config to the put service ID params | [
"WithConfig",
"adds",
"the",
"config",
"to",
"the",
"put",
"service",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/service/put_service_id_parameters.go#L117-L120 |
162,659 | cilium/cilium | api/v1/client/service/put_service_id_parameters.go | WithID | func (o *PutServiceIDParams) WithID(id int64) *PutServiceIDParams {
o.SetID(id)
return o
} | go | func (o *PutServiceIDParams) WithID(id int64) *PutServiceIDParams {
o.SetID(id)
return o
} | [
"func",
"(",
"o",
"*",
"PutServiceIDParams",
")",
"WithID",
"(",
"id",
"int64",
")",
"*",
"PutServiceIDParams",
"{",
"o",
".",
"SetID",
"(",
"id",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithID adds the id to the put service ID params | [
"WithID",
"adds",
"the",
"id",
"to",
"the",
"put",
"service",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/service/put_service_id_parameters.go#L128-L131 |
162,660 | cilium/cilium | pkg/fqdn/regexpmap/regexp_map.go | NewRegexpList | func NewRegexpList(initialValues ...string) (result *RegexpList) {
sort.Slice(initialValues, func(i, j int) bool {
return len(initialValues[i]) < len(initialValues[j])
})
tmp := RegexpList(initialValues)
return &tmp
} | go | func NewRegexpList(initialValues ...string) (result *RegexpList) {
sort.Slice(initialValues, func(i, j int) bool {
return len(initialValues[i]) < len(initialValues[j])
})
tmp := RegexpList(initialValues)
return &tmp
} | [
"func",
"NewRegexpList",
"(",
"initialValues",
"...",
"string",
")",
"(",
"result",
"*",
"RegexpList",
")",
"{",
"sort",
".",
"Slice",
"(",
"initialValues",
",",
"func",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"len",
"(",
"initialValues",
... | // NewRegexpList returns a new RegexpList, if any initialValues is in place
// will add into the utility. | [
"NewRegexpList",
"returns",
"a",
"new",
"RegexpList",
"if",
"any",
"initialValues",
"is",
"in",
"place",
"will",
"add",
"into",
"the",
"utility",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/regexpmap/regexp_map.go#L28-L35 |
162,661 | cilium/cilium | pkg/fqdn/regexpmap/regexp_map.go | Add | func (r *RegexpList) Add(val string) {
for _, item := range *r {
if item == val {
return
}
}
tmpData := append(*r, val)
sort.Slice(tmpData, func(i, j int) bool {
return len(tmpData[i]) < len(tmpData[j])
})
*r = tmpData
} | go | func (r *RegexpList) Add(val string) {
for _, item := range *r {
if item == val {
return
}
}
tmpData := append(*r, val)
sort.Slice(tmpData, func(i, j int) bool {
return len(tmpData[i]) < len(tmpData[j])
})
*r = tmpData
} | [
"func",
"(",
"r",
"*",
"RegexpList",
")",
"Add",
"(",
"val",
"string",
")",
"{",
"for",
"_",
",",
"item",
":=",
"range",
"*",
"r",
"{",
"if",
"item",
"==",
"val",
"{",
"return",
"\n",
"}",
"\n",
"}",
"\n\n",
"tmpData",
":=",
"append",
"(",
"*",... | // Add function adds a new item in the list and sort the data based on the
// length | [
"Add",
"function",
"adds",
"a",
"new",
"item",
"in",
"the",
"list",
"and",
"sort",
"the",
"data",
"based",
"on",
"the",
"length"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/regexpmap/regexp_map.go#L39-L53 |
162,662 | cilium/cilium | pkg/fqdn/regexpmap/regexp_map.go | Remove | func (r *RegexpList) Remove(val string) {
tmpData := []string{}
for _, item := range *r {
if item == val {
continue
}
tmpData = append(tmpData, item)
}
*r = tmpData
return
} | go | func (r *RegexpList) Remove(val string) {
tmpData := []string{}
for _, item := range *r {
if item == val {
continue
}
tmpData = append(tmpData, item)
}
*r = tmpData
return
} | [
"func",
"(",
"r",
"*",
"RegexpList",
")",
"Remove",
"(",
"val",
"string",
")",
"{",
"tmpData",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"item",
":=",
"range",
"*",
"r",
"{",
"if",
"item",
"==",
"val",
"{",
"continue",
"\n",
"}... | // Remove removes the item from the internal array and keep the data sorted | [
"Remove",
"removes",
"the",
"item",
"from",
"the",
"internal",
"array",
"and",
"keep",
"the",
"data",
"sorted"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/regexpmap/regexp_map.go#L56-L66 |
162,663 | cilium/cilium | pkg/fqdn/regexpmap/regexp_map.go | Increment | func (r refCount) Increment(key string) int {
r[key]++
return r[key]
} | go | func (r refCount) Increment(key string) int {
r[key]++
return r[key]
} | [
"func",
"(",
"r",
"refCount",
")",
"Increment",
"(",
"key",
"string",
")",
"int",
"{",
"r",
"[",
"key",
"]",
"++",
"\n",
"return",
"r",
"[",
"key",
"]",
"\n",
"}"
] | // Increment adds one to the given key | [
"Increment",
"adds",
"one",
"to",
"the",
"given",
"key"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/regexpmap/regexp_map.go#L82-L85 |
162,664 | cilium/cilium | pkg/fqdn/regexpmap/regexp_map.go | Decrement | func (r refCount) Decrement(key string) int {
val := r[key]
if val <= 1 {
delete(r, key)
return 0
}
r[key]--
return r[key]
} | go | func (r refCount) Decrement(key string) int {
val := r[key]
if val <= 1 {
delete(r, key)
return 0
}
r[key]--
return r[key]
} | [
"func",
"(",
"r",
"refCount",
")",
"Decrement",
"(",
"key",
"string",
")",
"int",
"{",
"val",
":=",
"r",
"[",
"key",
"]",
"\n",
"if",
"val",
"<=",
"1",
"{",
"delete",
"(",
"r",
",",
"key",
")",
"\n",
"return",
"0",
"\n",
"}",
"\n",
"r",
"[",
... | // Decrement remove one to the given key. If the value is 0, the key will be
// deleted. | [
"Decrement",
"remove",
"one",
"to",
"the",
"given",
"key",
".",
"If",
"the",
"value",
"is",
"0",
"the",
"key",
"will",
"be",
"deleted",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/regexpmap/regexp_map.go#L89-L97 |
162,665 | cilium/cilium | pkg/fqdn/regexpmap/regexp_map.go | Keys | func (r refCount) Keys() []string {
result := make([]string, len(r))
position := 0
for key := range r {
result[position] = key
position++
}
return result
} | go | func (r refCount) Keys() []string {
result := make([]string, len(r))
position := 0
for key := range r {
result[position] = key
position++
}
return result
} | [
"func",
"(",
"r",
"refCount",
")",
"Keys",
"(",
")",
"[",
"]",
"string",
"{",
"result",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"r",
")",
")",
"\n",
"position",
":=",
"0",
"\n",
"for",
"key",
":=",
"range",
"r",
"{",
"result",
... | // Keys return the list of keys that are in place. | [
"Keys",
"return",
"the",
"list",
"of",
"keys",
"that",
"are",
"in",
"place",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/regexpmap/regexp_map.go#L100-L108 |
162,666 | cilium/cilium | pkg/fqdn/regexpmap/regexp_map.go | NewRegexpMap | func NewRegexpMap() *RegexpMap {
return &RegexpMap{
lookupValues: make(map[string]*RegexpList),
rules: make(map[string]*regexp.Regexp),
rulesRelation: make(map[string]refCount),
}
} | go | func NewRegexpMap() *RegexpMap {
return &RegexpMap{
lookupValues: make(map[string]*RegexpList),
rules: make(map[string]*regexp.Regexp),
rulesRelation: make(map[string]refCount),
}
} | [
"func",
"NewRegexpMap",
"(",
")",
"*",
"RegexpMap",
"{",
"return",
"&",
"RegexpMap",
"{",
"lookupValues",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"RegexpList",
")",
",",
"rules",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"regexp",
"... | // NewRegexpMap returns an initialized RegexpMap | [
"NewRegexpMap",
"returns",
"an",
"initialized",
"RegexpMap"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/regexpmap/regexp_map.go#L140-L146 |
162,667 | cilium/cilium | pkg/fqdn/regexpmap/regexp_map.go | Add | func (m *RegexpMap) Add(reStr string, lookupValue string) error {
_, exists := m.rules[reStr]
if !exists {
rule, err := regexp.Compile(reStr)
if err != nil {
return err
}
m.rules[reStr] = rule
}
val, exists := m.lookupValues[lookupValue]
if !exists {
val = NewRegexpList()
m.lookupValues[lookupValue] = val
}
val.Add(reStr)
lookupCount, exists := m.rulesRelation[reStr]
if !exists {
lookupCount = refCount{}
m.rulesRelation[reStr] = lookupCount
}
lookupCount.Increment(lookupValue)
return nil
} | go | func (m *RegexpMap) Add(reStr string, lookupValue string) error {
_, exists := m.rules[reStr]
if !exists {
rule, err := regexp.Compile(reStr)
if err != nil {
return err
}
m.rules[reStr] = rule
}
val, exists := m.lookupValues[lookupValue]
if !exists {
val = NewRegexpList()
m.lookupValues[lookupValue] = val
}
val.Add(reStr)
lookupCount, exists := m.rulesRelation[reStr]
if !exists {
lookupCount = refCount{}
m.rulesRelation[reStr] = lookupCount
}
lookupCount.Increment(lookupValue)
return nil
} | [
"func",
"(",
"m",
"*",
"RegexpMap",
")",
"Add",
"(",
"reStr",
"string",
",",
"lookupValue",
"string",
")",
"error",
"{",
"_",
",",
"exists",
":=",
"m",
".",
"rules",
"[",
"reStr",
"]",
"\n",
"if",
"!",
"exists",
"{",
"rule",
",",
"err",
":=",
"re... | // Add associates a Regular expression to a lookupValue that will be used in
// the lookup functions. It will return an error and data will be not saved if
// the regexp does not compile correctly | [
"Add",
"associates",
"a",
"Regular",
"expression",
"to",
"a",
"lookupValue",
"that",
"will",
"be",
"used",
"in",
"the",
"lookup",
"functions",
".",
"It",
"will",
"return",
"an",
"error",
"and",
"data",
"will",
"be",
"not",
"saved",
"if",
"the",
"regexp",
... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/regexpmap/regexp_map.go#L151-L174 |
162,668 | cilium/cilium | pkg/fqdn/regexpmap/regexp_map.go | LookupValues | func (m *RegexpMap) LookupValues(lookupKey string) (lookupValues []string) {
for reStr, rule := range m.rules {
if !rule.MatchString(lookupKey) {
continue
}
val, exists := m.rulesRelation[reStr]
if exists {
lookupValues = append(lookupValues, val.Keys()...)
}
}
return keepUniqueStrings(lookupValues)
} | go | func (m *RegexpMap) LookupValues(lookupKey string) (lookupValues []string) {
for reStr, rule := range m.rules {
if !rule.MatchString(lookupKey) {
continue
}
val, exists := m.rulesRelation[reStr]
if exists {
lookupValues = append(lookupValues, val.Keys()...)
}
}
return keepUniqueStrings(lookupValues)
} | [
"func",
"(",
"m",
"*",
"RegexpMap",
")",
"LookupValues",
"(",
"lookupKey",
"string",
")",
"(",
"lookupValues",
"[",
"]",
"string",
")",
"{",
"for",
"reStr",
",",
"rule",
":=",
"range",
"m",
".",
"rules",
"{",
"if",
"!",
"rule",
".",
"MatchString",
"(... | // LookupValues returns all lookupValues, inserted via Add, where the reStr
// matches lookupKey | [
"LookupValues",
"returns",
"all",
"lookupValues",
"inserted",
"via",
"Add",
"where",
"the",
"reStr",
"matches",
"lookupKey"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/regexpmap/regexp_map.go#L178-L190 |
162,669 | cilium/cilium | pkg/fqdn/regexpmap/regexp_map.go | LookupContainsValue | func (m *RegexpMap) LookupContainsValue(lookupKey, expectedValue string) (found bool) {
val, exists := m.lookupValues[expectedValue]
if !exists {
return false
}
for _, item := range val.Get() {
rule := m.rules[item]
if rule != nil && rule.MatchString(lookupKey) {
return true
}
}
return false
} | go | func (m *RegexpMap) LookupContainsValue(lookupKey, expectedValue string) (found bool) {
val, exists := m.lookupValues[expectedValue]
if !exists {
return false
}
for _, item := range val.Get() {
rule := m.rules[item]
if rule != nil && rule.MatchString(lookupKey) {
return true
}
}
return false
} | [
"func",
"(",
"m",
"*",
"RegexpMap",
")",
"LookupContainsValue",
"(",
"lookupKey",
",",
"expectedValue",
"string",
")",
"(",
"found",
"bool",
")",
"{",
"val",
",",
"exists",
":=",
"m",
".",
"lookupValues",
"[",
"expectedValue",
"]",
"\n",
"if",
"!",
"exis... | // LookupContainsValue returns true if any reStr in lookups, inserted via Add,
// matches lookupKey AND has a lookupValue, inserted via the same Add, that
// matches expectedValue. | [
"LookupContainsValue",
"returns",
"true",
"if",
"any",
"reStr",
"in",
"lookups",
"inserted",
"via",
"Add",
"matches",
"lookupKey",
"AND",
"has",
"a",
"lookupValue",
"inserted",
"via",
"the",
"same",
"Add",
"that",
"matches",
"expectedValue",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/regexpmap/regexp_map.go#L195-L208 |
162,670 | cilium/cilium | pkg/fqdn/regexpmap/regexp_map.go | GetPrecompiledRegexp | func (m *RegexpMap) GetPrecompiledRegexp(reStr string) (re *regexp.Regexp) {
return m.rules[reStr]
} | go | func (m *RegexpMap) GetPrecompiledRegexp(reStr string) (re *regexp.Regexp) {
return m.rules[reStr]
} | [
"func",
"(",
"m",
"*",
"RegexpMap",
")",
"GetPrecompiledRegexp",
"(",
"reStr",
"string",
")",
"(",
"re",
"*",
"regexp",
".",
"Regexp",
")",
"{",
"return",
"m",
".",
"rules",
"[",
"reStr",
"]",
"\n",
"}"
] | // GetPrecompiledRegexp returns the regexp matching reStr if it is in the map.
// This is a utility function to avoid recompiling regexps repeatedly, and the
// RegexpMap keeps the refcount for us. | [
"GetPrecompiledRegexp",
"returns",
"the",
"regexp",
"matching",
"reStr",
"if",
"it",
"is",
"in",
"the",
"map",
".",
"This",
"is",
"a",
"utility",
"function",
"to",
"avoid",
"recompiling",
"regexps",
"repeatedly",
"and",
"the",
"RegexpMap",
"keeps",
"the",
"ref... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/regexpmap/regexp_map.go#L241-L243 |
162,671 | cilium/cilium | pkg/fqdn/regexpmap/regexp_map.go | keepUniqueStrings | func keepUniqueStrings(s []string) []string {
sort.Strings(s)
out := s[:0] // len==0 but cap==cap(ips)
for readIdx, str := range s {
if len(out) == 0 ||
out[len(out)-1] != s[readIdx] {
out = append(out, str)
}
}
return out
} | go | func keepUniqueStrings(s []string) []string {
sort.Strings(s)
out := s[:0] // len==0 but cap==cap(ips)
for readIdx, str := range s {
if len(out) == 0 ||
out[len(out)-1] != s[readIdx] {
out = append(out, str)
}
}
return out
} | [
"func",
"keepUniqueStrings",
"(",
"s",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"sort",
".",
"Strings",
"(",
"s",
")",
"\n\n",
"out",
":=",
"s",
"[",
":",
"0",
"]",
"// len==0 but cap==cap(ips)",
"\n",
"for",
"readIdx",
",",
"str",
":=",
"ra... | // keepUniqueStrings deduplicates strings in s. The output is sorted. | [
"keepUniqueStrings",
"deduplicates",
"strings",
"in",
"s",
".",
"The",
"output",
"is",
"sorted",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/regexpmap/regexp_map.go#L246-L258 |
162,672 | cilium/cilium | common/utils.go | FindEPConfigCHeader | func FindEPConfigCHeader(basePath string, epFiles []os.FileInfo) string {
for _, epFile := range epFiles {
if epFile.Name() == CHeaderFileName {
return filepath.Join(basePath, epFile.Name())
}
}
return ""
} | go | func FindEPConfigCHeader(basePath string, epFiles []os.FileInfo) string {
for _, epFile := range epFiles {
if epFile.Name() == CHeaderFileName {
return filepath.Join(basePath, epFile.Name())
}
}
return ""
} | [
"func",
"FindEPConfigCHeader",
"(",
"basePath",
"string",
",",
"epFiles",
"[",
"]",
"os",
".",
"FileInfo",
")",
"string",
"{",
"for",
"_",
",",
"epFile",
":=",
"range",
"epFiles",
"{",
"if",
"epFile",
".",
"Name",
"(",
")",
"==",
"CHeaderFileName",
"{",
... | // FindEPConfigCHeader returns the full path of the file that is the CHeaderFileName from
// the slice of files | [
"FindEPConfigCHeader",
"returns",
"the",
"full",
"path",
"of",
"the",
"file",
"that",
"is",
"the",
"CHeaderFileName",
"from",
"the",
"slice",
"of",
"files"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/common/utils.go#L53-L60 |
162,673 | cilium/cilium | common/utils.go | GetCiliumVersionString | func GetCiliumVersionString(epCHeaderFilePath string) (string, error) {
f, err := os.Open(epCHeaderFilePath)
if err != nil {
return "", err
}
br := bufio.NewReader(f)
defer f.Close()
for {
s, err := br.ReadString('\n')
if err == io.EOF {
return "", nil
}
if err != nil {
return "", err
}
if strings.Contains(s, CiliumCHeaderPrefix) {
return s, nil
}
}
} | go | func GetCiliumVersionString(epCHeaderFilePath string) (string, error) {
f, err := os.Open(epCHeaderFilePath)
if err != nil {
return "", err
}
br := bufio.NewReader(f)
defer f.Close()
for {
s, err := br.ReadString('\n')
if err == io.EOF {
return "", nil
}
if err != nil {
return "", err
}
if strings.Contains(s, CiliumCHeaderPrefix) {
return s, nil
}
}
} | [
"func",
"GetCiliumVersionString",
"(",
"epCHeaderFilePath",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"epCHeaderFilePath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"... | // GetCiliumVersionString returns the first line containing CiliumCHeaderPrefix. | [
"GetCiliumVersionString",
"returns",
"the",
"first",
"line",
"containing",
"CiliumCHeaderPrefix",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/common/utils.go#L63-L82 |
162,674 | cilium/cilium | common/utils.go | RequireRootPrivilege | func RequireRootPrivilege(cmd string) {
if os.Getuid() != 0 {
fmt.Fprintf(os.Stderr, "Please run %q command(s) with root privileges.\n", cmd)
os.Exit(1)
}
} | go | func RequireRootPrivilege(cmd string) {
if os.Getuid() != 0 {
fmt.Fprintf(os.Stderr, "Please run %q command(s) with root privileges.\n", cmd)
os.Exit(1)
}
} | [
"func",
"RequireRootPrivilege",
"(",
"cmd",
"string",
")",
"{",
"if",
"os",
".",
"Getuid",
"(",
")",
"!=",
"0",
"{",
"fmt",
".",
"Fprintf",
"(",
"os",
".",
"Stderr",
",",
"\"",
"\\n",
"\"",
",",
"cmd",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")... | // RequireRootPrivilege checks if the user running cmd is root. If not, it exits the program | [
"RequireRootPrivilege",
"checks",
"if",
"the",
"user",
"running",
"cmd",
"is",
"root",
".",
"If",
"not",
"it",
"exits",
"the",
"program"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/common/utils.go#L85-L90 |
162,675 | cilium/cilium | common/utils.go | MoveNewFilesTo | func MoveNewFilesTo(oldDir, newDir string) error {
oldFiles, err := ioutil.ReadDir(oldDir)
if err != nil {
return err
}
newFiles, err := ioutil.ReadDir(newDir)
if err != nil {
return err
}
for _, oldFile := range oldFiles {
exists := false
for _, newFile := range newFiles {
if oldFile.Name() == newFile.Name() {
exists = true
break
}
}
if !exists {
os.Rename(filepath.Join(oldDir, oldFile.Name()), filepath.Join(newDir, oldFile.Name()))
}
}
return nil
} | go | func MoveNewFilesTo(oldDir, newDir string) error {
oldFiles, err := ioutil.ReadDir(oldDir)
if err != nil {
return err
}
newFiles, err := ioutil.ReadDir(newDir)
if err != nil {
return err
}
for _, oldFile := range oldFiles {
exists := false
for _, newFile := range newFiles {
if oldFile.Name() == newFile.Name() {
exists = true
break
}
}
if !exists {
os.Rename(filepath.Join(oldDir, oldFile.Name()), filepath.Join(newDir, oldFile.Name()))
}
}
return nil
} | [
"func",
"MoveNewFilesTo",
"(",
"oldDir",
",",
"newDir",
"string",
")",
"error",
"{",
"oldFiles",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"oldDir",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"newFiles",
",",
"... | // MoveNewFilesTo copies all files, that do not exist in newDir, from oldDir. | [
"MoveNewFilesTo",
"copies",
"all",
"files",
"that",
"do",
"not",
"exist",
"in",
"newDir",
"from",
"oldDir",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/common/utils.go#L93-L116 |
162,676 | cilium/cilium | api/v1/client/endpoint/put_endpoint_id_parameters.go | WithTimeout | func (o *PutEndpointIDParams) WithTimeout(timeout time.Duration) *PutEndpointIDParams {
o.SetTimeout(timeout)
return o
} | go | func (o *PutEndpointIDParams) WithTimeout(timeout time.Duration) *PutEndpointIDParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"PutEndpointIDParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"PutEndpointIDParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the put endpoint ID params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"put",
"endpoint",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/put_endpoint_id_parameters.go#L92-L95 |
162,677 | cilium/cilium | api/v1/client/endpoint/put_endpoint_id_parameters.go | WithContext | func (o *PutEndpointIDParams) WithContext(ctx context.Context) *PutEndpointIDParams {
o.SetContext(ctx)
return o
} | go | func (o *PutEndpointIDParams) WithContext(ctx context.Context) *PutEndpointIDParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"PutEndpointIDParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"PutEndpointIDParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the put endpoint ID params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"put",
"endpoint",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/put_endpoint_id_parameters.go#L103-L106 |
162,678 | cilium/cilium | api/v1/client/endpoint/put_endpoint_id_parameters.go | WithHTTPClient | func (o *PutEndpointIDParams) WithHTTPClient(client *http.Client) *PutEndpointIDParams {
o.SetHTTPClient(client)
return o
} | go | func (o *PutEndpointIDParams) WithHTTPClient(client *http.Client) *PutEndpointIDParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"PutEndpointIDParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"PutEndpointIDParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the put endpoint ID params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"put",
"endpoint",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/put_endpoint_id_parameters.go#L114-L117 |
162,679 | cilium/cilium | api/v1/client/endpoint/put_endpoint_id_parameters.go | WithEndpoint | func (o *PutEndpointIDParams) WithEndpoint(endpoint *models.EndpointChangeRequest) *PutEndpointIDParams {
o.SetEndpoint(endpoint)
return o
} | go | func (o *PutEndpointIDParams) WithEndpoint(endpoint *models.EndpointChangeRequest) *PutEndpointIDParams {
o.SetEndpoint(endpoint)
return o
} | [
"func",
"(",
"o",
"*",
"PutEndpointIDParams",
")",
"WithEndpoint",
"(",
"endpoint",
"*",
"models",
".",
"EndpointChangeRequest",
")",
"*",
"PutEndpointIDParams",
"{",
"o",
".",
"SetEndpoint",
"(",
"endpoint",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithEndpoint adds the endpoint to the put endpoint ID params | [
"WithEndpoint",
"adds",
"the",
"endpoint",
"to",
"the",
"put",
"endpoint",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/put_endpoint_id_parameters.go#L125-L128 |
162,680 | cilium/cilium | api/v1/client/endpoint/put_endpoint_id_parameters.go | WithID | func (o *PutEndpointIDParams) WithID(id string) *PutEndpointIDParams {
o.SetID(id)
return o
} | go | func (o *PutEndpointIDParams) WithID(id string) *PutEndpointIDParams {
o.SetID(id)
return o
} | [
"func",
"(",
"o",
"*",
"PutEndpointIDParams",
")",
"WithID",
"(",
"id",
"string",
")",
"*",
"PutEndpointIDParams",
"{",
"o",
".",
"SetID",
"(",
"id",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithID adds the id to the put endpoint ID params | [
"WithID",
"adds",
"the",
"id",
"to",
"the",
"put",
"endpoint",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/put_endpoint_id_parameters.go#L136-L139 |
162,681 | cilium/cilium | api/v1/server/restapi/prefilter/get_prefilter.go | NewGetPrefilter | func NewGetPrefilter(ctx *middleware.Context, handler GetPrefilterHandler) *GetPrefilter {
return &GetPrefilter{Context: ctx, Handler: handler}
} | go | func NewGetPrefilter(ctx *middleware.Context, handler GetPrefilterHandler) *GetPrefilter {
return &GetPrefilter{Context: ctx, Handler: handler}
} | [
"func",
"NewGetPrefilter",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"GetPrefilterHandler",
")",
"*",
"GetPrefilter",
"{",
"return",
"&",
"GetPrefilter",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewGetPrefilter creates a new http.Handler for the get prefilter operation | [
"NewGetPrefilter",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"get",
"prefilter",
"operation"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/prefilter/get_prefilter.go#L28-L30 |
162,682 | cilium/cilium | api/v1/server/restapi/policy/get_policy_resolve.go | NewGetPolicyResolve | func NewGetPolicyResolve(ctx *middleware.Context, handler GetPolicyResolveHandler) *GetPolicyResolve {
return &GetPolicyResolve{Context: ctx, Handler: handler}
} | go | func NewGetPolicyResolve(ctx *middleware.Context, handler GetPolicyResolveHandler) *GetPolicyResolve {
return &GetPolicyResolve{Context: ctx, Handler: handler}
} | [
"func",
"NewGetPolicyResolve",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"GetPolicyResolveHandler",
")",
"*",
"GetPolicyResolve",
"{",
"return",
"&",
"GetPolicyResolve",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
... | // NewGetPolicyResolve creates a new http.Handler for the get policy resolve operation | [
"NewGetPolicyResolve",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"get",
"policy",
"resolve",
"operation"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/get_policy_resolve.go#L28-L30 |
162,683 | cilium/cilium | pkg/monitor/api/drop.go | DropReason | func DropReason(reason uint8) string {
if err, ok := errors[reason]; ok {
return err
}
return fmt.Sprintf("%d", reason)
} | go | func DropReason(reason uint8) string {
if err, ok := errors[reason]; ok {
return err
}
return fmt.Sprintf("%d", reason)
} | [
"func",
"DropReason",
"(",
"reason",
"uint8",
")",
"string",
"{",
"if",
"err",
",",
"ok",
":=",
"errors",
"[",
"reason",
"]",
";",
"ok",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"reason",
")",
... | // DropReason prints the drop reason in a human readable string | [
"DropReason",
"prints",
"the",
"drop",
"reason",
"in",
"a",
"human",
"readable",
"string"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/api/drop.go#L66-L71 |
162,684 | cilium/cilium | api/v1/health/models/path_status.go | Validate | func (m *PathStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateHTTP(formats); err != nil {
res = append(res, err)
}
if err := m.validateIcmp(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *PathStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateHTTP(formats); err != nil {
res = append(res, err)
}
if err := m.validateIcmp(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"PathStatus",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateHTTP",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
... | // Validate validates this path status | [
"Validate",
"validates",
"this",
"path",
"status"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/models/path_status.go#L32-L47 |
162,685 | cilium/cilium | pkg/envoy/resources.go | handleIPDelete | func (cache *NPHDSCache) handleIPDelete(npHost *envoyAPI.NetworkPolicyHosts, peerIdentity, peerIP string) {
targetIndex := -1
scopedLog := log.WithFields(logrus.Fields{
logfields.IPAddr: peerIP,
logfields.Identity: peerIdentity,
logfields.Modification: ipcache.Delete,
})
for i, endpointIP := range npHost.HostAddresses {
if endpointIP == peerIP {
targetIndex = i
break
}
}
if targetIndex < 0 {
scopedLog.Warning("Can't find IP in NPHDS cache")
return
}
// If removing this host would result in empty list, delete it.
// Otherwise, update to a list that doesn't contain the target IP
if len(npHost.HostAddresses) <= 1 {
cache.Delete(NetworkPolicyHostsTypeURL, peerIdentity, false)
} else {
// If the resource is to be updated, create a copy of it before
// removing the IP address from its HostAddresses list.
hostAddresses := make([]string, 0, len(npHost.HostAddresses)-1)
if len(npHost.HostAddresses) == targetIndex {
hostAddresses = append(hostAddresses, npHost.HostAddresses[0:targetIndex]...)
} else {
hostAddresses = append(hostAddresses, npHost.HostAddresses[0:targetIndex]...)
hostAddresses = append(hostAddresses, npHost.HostAddresses[targetIndex+1:]...)
}
newNpHost := envoyAPI.NetworkPolicyHosts{
Policy: uint64(npHost.Policy),
HostAddresses: hostAddresses,
}
if err := newNpHost.Validate(); err != nil {
scopedLog.WithError(err).Warning("Could not validate NPHDS resource update on delete")
return
}
cache.Upsert(NetworkPolicyHostsTypeURL, peerIdentity, &newNpHost, false)
}
} | go | func (cache *NPHDSCache) handleIPDelete(npHost *envoyAPI.NetworkPolicyHosts, peerIdentity, peerIP string) {
targetIndex := -1
scopedLog := log.WithFields(logrus.Fields{
logfields.IPAddr: peerIP,
logfields.Identity: peerIdentity,
logfields.Modification: ipcache.Delete,
})
for i, endpointIP := range npHost.HostAddresses {
if endpointIP == peerIP {
targetIndex = i
break
}
}
if targetIndex < 0 {
scopedLog.Warning("Can't find IP in NPHDS cache")
return
}
// If removing this host would result in empty list, delete it.
// Otherwise, update to a list that doesn't contain the target IP
if len(npHost.HostAddresses) <= 1 {
cache.Delete(NetworkPolicyHostsTypeURL, peerIdentity, false)
} else {
// If the resource is to be updated, create a copy of it before
// removing the IP address from its HostAddresses list.
hostAddresses := make([]string, 0, len(npHost.HostAddresses)-1)
if len(npHost.HostAddresses) == targetIndex {
hostAddresses = append(hostAddresses, npHost.HostAddresses[0:targetIndex]...)
} else {
hostAddresses = append(hostAddresses, npHost.HostAddresses[0:targetIndex]...)
hostAddresses = append(hostAddresses, npHost.HostAddresses[targetIndex+1:]...)
}
newNpHost := envoyAPI.NetworkPolicyHosts{
Policy: uint64(npHost.Policy),
HostAddresses: hostAddresses,
}
if err := newNpHost.Validate(); err != nil {
scopedLog.WithError(err).Warning("Could not validate NPHDS resource update on delete")
return
}
cache.Upsert(NetworkPolicyHostsTypeURL, peerIdentity, &newNpHost, false)
}
} | [
"func",
"(",
"cache",
"*",
"NPHDSCache",
")",
"handleIPDelete",
"(",
"npHost",
"*",
"envoyAPI",
".",
"NetworkPolicyHosts",
",",
"peerIdentity",
",",
"peerIP",
"string",
")",
"{",
"targetIndex",
":=",
"-",
"1",
"\n\n",
"scopedLog",
":=",
"log",
".",
"WithFiel... | // handleIPUpsert deletes elements from the NPHDS cache with the specified peer IP->ID mapping. | [
"handleIPUpsert",
"deletes",
"elements",
"from",
"the",
"NPHDS",
"cache",
"with",
"the",
"specified",
"peer",
"IP",
"-",
">",
"ID",
"mapping",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/resources.go#L130-L174 |
162,686 | cilium/cilium | pkg/metrics/middleware.go | ServeHTTP | func (m *APIEventTSHelper) ServeHTTP(r http.ResponseWriter, req *http.Request) {
m.TSGauge.SetToCurrentTime()
duration := spanstat.Start()
rw := &responderWrapper{ResponseWriter: r}
m.Next.ServeHTTP(rw, req)
if req != nil && req.URL != nil && req.URL.Path != "" {
path := getShortPath(req.URL.Path)
took := float64(duration.End(true).Total().Seconds())
m.Histogram.WithLabelValues(path, req.Method, strconv.Itoa(rw.code)).Observe(took)
}
} | go | func (m *APIEventTSHelper) ServeHTTP(r http.ResponseWriter, req *http.Request) {
m.TSGauge.SetToCurrentTime()
duration := spanstat.Start()
rw := &responderWrapper{ResponseWriter: r}
m.Next.ServeHTTP(rw, req)
if req != nil && req.URL != nil && req.URL.Path != "" {
path := getShortPath(req.URL.Path)
took := float64(duration.End(true).Total().Seconds())
m.Histogram.WithLabelValues(path, req.Method, strconv.Itoa(rw.code)).Observe(took)
}
} | [
"func",
"(",
"m",
"*",
"APIEventTSHelper",
")",
"ServeHTTP",
"(",
"r",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"m",
".",
"TSGauge",
".",
"SetToCurrentTime",
"(",
")",
"\n",
"duration",
":=",
"spanstat",
".",
"S... | // ServeHTTP implements the http.Handler interface. It records the timestamp
// this API call began at, then chains to the next handler. | [
"ServeHTTP",
"implements",
"the",
"http",
".",
"Handler",
"interface",
".",
"It",
"records",
"the",
"timestamp",
"this",
"API",
"call",
"began",
"at",
"then",
"chains",
"to",
"the",
"next",
"handler",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/metrics/middleware.go#L65-L75 |
162,687 | cilium/cilium | pkg/sockops/sockops.go | bpftoolMapAttach | func bpftoolMapAttach(progID string, mapID string) error {
prog := "bpftool"
args := []string{"prog", "attach", "id", progID, "msg_verdict", "id", mapID}
log.WithFields(logrus.Fields{
"bpftool": prog,
"args": args,
}).Debug("Map Attach BPF Object:")
out, err := exec.Command(prog, args...).CombinedOutput()
if err != nil {
return fmt.Errorf("Failed to attach prog(%s) to map(%s): %s: %s", progID, mapID, err, out)
}
return nil
} | go | func bpftoolMapAttach(progID string, mapID string) error {
prog := "bpftool"
args := []string{"prog", "attach", "id", progID, "msg_verdict", "id", mapID}
log.WithFields(logrus.Fields{
"bpftool": prog,
"args": args,
}).Debug("Map Attach BPF Object:")
out, err := exec.Command(prog, args...).CombinedOutput()
if err != nil {
return fmt.Errorf("Failed to attach prog(%s) to map(%s): %s: %s", progID, mapID, err, out)
}
return nil
} | [
"func",
"bpftoolMapAttach",
"(",
"progID",
"string",
",",
"mapID",
"string",
")",
"error",
"{",
"prog",
":=",
"\"",
"\"",
"\n\n",
"args",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"progID",
",",
"\"",
"\"",
... | // BPF programs and sockmaps working on cgroups | [
"BPF",
"programs",
"and",
"sockmaps",
"working",
"on",
"cgroups"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/sockops/sockops.go#L61-L74 |
162,688 | cilium/cilium | pkg/sockops/sockops.go | bpfLoadAttachProg | func bpfLoadAttachProg(object string, load string, mapName string) (int, int, error) {
sockopsObj := filepath.Join(option.Config.StateDir, object)
mapID := 0
err := bpftoolLoad(sockopsObj, load)
if err != nil {
return 0, 0, err
}
err = bpftoolAttach(load)
if err != nil {
return 0, 0, err
}
if mapName != "" {
mapID, err = bpftoolGetMapID(load, mapName)
if err != nil {
return 0, mapID, err
}
err = bpftoolPinMapID(mapName, mapID)
if err != nil {
return 0, mapID, err
}
}
return 0, mapID, nil
} | go | func bpfLoadAttachProg(object string, load string, mapName string) (int, int, error) {
sockopsObj := filepath.Join(option.Config.StateDir, object)
mapID := 0
err := bpftoolLoad(sockopsObj, load)
if err != nil {
return 0, 0, err
}
err = bpftoolAttach(load)
if err != nil {
return 0, 0, err
}
if mapName != "" {
mapID, err = bpftoolGetMapID(load, mapName)
if err != nil {
return 0, mapID, err
}
err = bpftoolPinMapID(mapName, mapID)
if err != nil {
return 0, mapID, err
}
}
return 0, mapID, nil
} | [
"func",
"bpfLoadAttachProg",
"(",
"object",
"string",
",",
"load",
"string",
",",
"mapName",
"string",
")",
"(",
"int",
",",
"int",
",",
"error",
")",
"{",
"sockopsObj",
":=",
"filepath",
".",
"Join",
"(",
"option",
".",
"Config",
".",
"StateDir",
",",
... | // First user of sockops root is sockops load programs so we ensure the sockops
// root path no longer changes. | [
"First",
"user",
"of",
"sockops",
"root",
"is",
"sockops",
"load",
"programs",
"so",
"we",
"ensure",
"the",
"sockops",
"root",
"path",
"no",
"longer",
"changes",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/sockops/sockops.go#L333-L358 |
162,689 | cilium/cilium | pkg/sockops/sockops.go | SockmapEnable | func SockmapEnable() error {
err := bpfCompileProg(cSockops, oSockops)
if err != nil {
log.Error(err)
return err
}
progID, mapID, err := bpfLoadAttachProg(oSockops, eSockops, sockMap)
if err != nil {
log.Error(err)
return err
}
log.Infof("Sockmap Enabled: bpf_sockops prog_id %d and map_id %d loaded", progID, mapID)
return nil
} | go | func SockmapEnable() error {
err := bpfCompileProg(cSockops, oSockops)
if err != nil {
log.Error(err)
return err
}
progID, mapID, err := bpfLoadAttachProg(oSockops, eSockops, sockMap)
if err != nil {
log.Error(err)
return err
}
log.Infof("Sockmap Enabled: bpf_sockops prog_id %d and map_id %d loaded", progID, mapID)
return nil
} | [
"func",
"SockmapEnable",
"(",
")",
"error",
"{",
"err",
":=",
"bpfCompileProg",
"(",
"cSockops",
",",
"oSockops",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Error",
"(",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"progID",
",",
... | // SockmapEnable will compile sockops programs and attach the sockops programs
// to the cgroup. After this all TCP connect events will be filtered by a BPF
// sockops program. | [
"SockmapEnable",
"will",
"compile",
"sockops",
"programs",
"and",
"attach",
"the",
"sockops",
"programs",
"to",
"the",
"cgroup",
".",
"After",
"this",
"all",
"TCP",
"connect",
"events",
"will",
"be",
"filtered",
"by",
"a",
"BPF",
"sockops",
"program",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/sockops/sockops.go#L363-L376 |
162,690 | cilium/cilium | pkg/sockops/sockops.go | SockmapDisable | func SockmapDisable() {
mapName := filepath.Join(mapPrefix, sockMap)
bpftoolDetach(eSockops)
bpftoolUnload(eSockops)
bpftoolUnload(mapName)
} | go | func SockmapDisable() {
mapName := filepath.Join(mapPrefix, sockMap)
bpftoolDetach(eSockops)
bpftoolUnload(eSockops)
bpftoolUnload(mapName)
} | [
"func",
"SockmapDisable",
"(",
")",
"{",
"mapName",
":=",
"filepath",
".",
"Join",
"(",
"mapPrefix",
",",
"sockMap",
")",
"\n",
"bpftoolDetach",
"(",
"eSockops",
")",
"\n",
"bpftoolUnload",
"(",
"eSockops",
")",
"\n",
"bpftoolUnload",
"(",
"mapName",
")",
... | // SockmapDisable will detach any sockmap programs from cgroups then "unload"
// all the programs and maps associated with it. Here "unload" just means
// deleting the file associated with the map. | [
"SockmapDisable",
"will",
"detach",
"any",
"sockmap",
"programs",
"from",
"cgroups",
"then",
"unload",
"all",
"the",
"programs",
"and",
"maps",
"associated",
"with",
"it",
".",
"Here",
"unload",
"just",
"means",
"deleting",
"the",
"file",
"associated",
"with",
... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/sockops/sockops.go#L381-L386 |
162,691 | cilium/cilium | api/v1/client/endpoint/get_endpoint_id_healthz_parameters.go | WithTimeout | func (o *GetEndpointIDHealthzParams) WithTimeout(timeout time.Duration) *GetEndpointIDHealthzParams {
o.SetTimeout(timeout)
return o
} | go | func (o *GetEndpointIDHealthzParams) WithTimeout(timeout time.Duration) *GetEndpointIDHealthzParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointIDHealthzParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"GetEndpointIDHealthzParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the get endpoint ID healthz params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"get",
"endpoint",
"ID",
"healthz",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_id_healthz_parameters.go#L88-L91 |
162,692 | cilium/cilium | api/v1/client/endpoint/get_endpoint_id_healthz_parameters.go | WithContext | func (o *GetEndpointIDHealthzParams) WithContext(ctx context.Context) *GetEndpointIDHealthzParams {
o.SetContext(ctx)
return o
} | go | func (o *GetEndpointIDHealthzParams) WithContext(ctx context.Context) *GetEndpointIDHealthzParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointIDHealthzParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"GetEndpointIDHealthzParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the get endpoint ID healthz params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"get",
"endpoint",
"ID",
"healthz",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_id_healthz_parameters.go#L99-L102 |
162,693 | cilium/cilium | api/v1/client/endpoint/get_endpoint_id_healthz_parameters.go | WithHTTPClient | func (o *GetEndpointIDHealthzParams) WithHTTPClient(client *http.Client) *GetEndpointIDHealthzParams {
o.SetHTTPClient(client)
return o
} | go | func (o *GetEndpointIDHealthzParams) WithHTTPClient(client *http.Client) *GetEndpointIDHealthzParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointIDHealthzParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"GetEndpointIDHealthzParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the get endpoint ID healthz params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"get",
"endpoint",
"ID",
"healthz",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_id_healthz_parameters.go#L110-L113 |
162,694 | cilium/cilium | api/v1/client/endpoint/get_endpoint_id_healthz_parameters.go | WithID | func (o *GetEndpointIDHealthzParams) WithID(id string) *GetEndpointIDHealthzParams {
o.SetID(id)
return o
} | go | func (o *GetEndpointIDHealthzParams) WithID(id string) *GetEndpointIDHealthzParams {
o.SetID(id)
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointIDHealthzParams",
")",
"WithID",
"(",
"id",
"string",
")",
"*",
"GetEndpointIDHealthzParams",
"{",
"o",
".",
"SetID",
"(",
"id",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithID adds the id to the get endpoint ID healthz params | [
"WithID",
"adds",
"the",
"id",
"to",
"the",
"get",
"endpoint",
"ID",
"healthz",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_id_healthz_parameters.go#L121-L124 |
162,695 | cilium/cilium | daemon/daemon.go | UpdateProxyRedirect | func (d *Daemon) UpdateProxyRedirect(e *endpoint.Endpoint, l4 *policy.L4Filter, proxyWaitGroup *completion.WaitGroup) (uint16, error, revert.FinalizeFunc, revert.RevertFunc) {
if d.l7Proxy == nil {
return 0, fmt.Errorf("can't redirect, proxy disabled"), nil, nil
}
port, err, finalizeFunc, revertFunc := d.l7Proxy.CreateOrUpdateRedirect(l4, e.ProxyID(l4), e, proxyWaitGroup)
if err != nil {
return 0, err, nil, nil
}
return port, nil, finalizeFunc, revertFunc
} | go | func (d *Daemon) UpdateProxyRedirect(e *endpoint.Endpoint, l4 *policy.L4Filter, proxyWaitGroup *completion.WaitGroup) (uint16, error, revert.FinalizeFunc, revert.RevertFunc) {
if d.l7Proxy == nil {
return 0, fmt.Errorf("can't redirect, proxy disabled"), nil, nil
}
port, err, finalizeFunc, revertFunc := d.l7Proxy.CreateOrUpdateRedirect(l4, e.ProxyID(l4), e, proxyWaitGroup)
if err != nil {
return 0, err, nil, nil
}
return port, nil, finalizeFunc, revertFunc
} | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"UpdateProxyRedirect",
"(",
"e",
"*",
"endpoint",
".",
"Endpoint",
",",
"l4",
"*",
"policy",
".",
"L4Filter",
",",
"proxyWaitGroup",
"*",
"completion",
".",
"WaitGroup",
")",
"(",
"uint16",
",",
"error",
",",
"revert... | // UpdateProxyRedirect updates the redirect rules in the proxy for a particular
// endpoint using the provided L4 filter. Returns the allocated proxy port | [
"UpdateProxyRedirect",
"updates",
"the",
"redirect",
"rules",
"in",
"the",
"proxy",
"for",
"a",
"particular",
"endpoint",
"using",
"the",
"provided",
"L4",
"filter",
".",
"Returns",
"the",
"allocated",
"proxy",
"port"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/daemon.go#L198-L209 |
162,696 | cilium/cilium | daemon/daemon.go | RemoveProxyRedirect | func (d *Daemon) RemoveProxyRedirect(e *endpoint.Endpoint, id string, proxyWaitGroup *completion.WaitGroup) (error, revert.FinalizeFunc, revert.RevertFunc) {
if d.l7Proxy == nil {
return nil, nil, nil
}
log.WithFields(logrus.Fields{
logfields.EndpointID: e.ID,
logfields.L4PolicyID: id,
}).Debug("Removing redirect to endpoint")
return d.l7Proxy.RemoveRedirect(id, proxyWaitGroup)
} | go | func (d *Daemon) RemoveProxyRedirect(e *endpoint.Endpoint, id string, proxyWaitGroup *completion.WaitGroup) (error, revert.FinalizeFunc, revert.RevertFunc) {
if d.l7Proxy == nil {
return nil, nil, nil
}
log.WithFields(logrus.Fields{
logfields.EndpointID: e.ID,
logfields.L4PolicyID: id,
}).Debug("Removing redirect to endpoint")
return d.l7Proxy.RemoveRedirect(id, proxyWaitGroup)
} | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"RemoveProxyRedirect",
"(",
"e",
"*",
"endpoint",
".",
"Endpoint",
",",
"id",
"string",
",",
"proxyWaitGroup",
"*",
"completion",
".",
"WaitGroup",
")",
"(",
"error",
",",
"revert",
".",
"FinalizeFunc",
",",
"revert",
... | // RemoveProxyRedirect removes a previously installed proxy redirect for an
// endpoint | [
"RemoveProxyRedirect",
"removes",
"a",
"previously",
"installed",
"proxy",
"redirect",
"for",
"an",
"endpoint"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/daemon.go#L213-L223 |
162,697 | cilium/cilium | daemon/daemon.go | UpdateNetworkPolicy | func (d *Daemon) UpdateNetworkPolicy(e *endpoint.Endpoint, policy *policy.L4Policy,
labelsMap, deniedIngressIdentities, deniedEgressIdentities cache.IdentityCache, proxyWaitGroup *completion.WaitGroup) (error, revert.RevertFunc) {
if d.l7Proxy == nil {
return fmt.Errorf("can't update network policy, proxy disabled"), nil
}
err, revertFunc := d.l7Proxy.UpdateNetworkPolicy(e, policy, e.GetIngressPolicyEnabledLocked(), e.GetEgressPolicyEnabledLocked(),
labelsMap, deniedIngressIdentities, deniedEgressIdentities, proxyWaitGroup)
return err, revert.RevertFunc(revertFunc)
} | go | func (d *Daemon) UpdateNetworkPolicy(e *endpoint.Endpoint, policy *policy.L4Policy,
labelsMap, deniedIngressIdentities, deniedEgressIdentities cache.IdentityCache, proxyWaitGroup *completion.WaitGroup) (error, revert.RevertFunc) {
if d.l7Proxy == nil {
return fmt.Errorf("can't update network policy, proxy disabled"), nil
}
err, revertFunc := d.l7Proxy.UpdateNetworkPolicy(e, policy, e.GetIngressPolicyEnabledLocked(), e.GetEgressPolicyEnabledLocked(),
labelsMap, deniedIngressIdentities, deniedEgressIdentities, proxyWaitGroup)
return err, revert.RevertFunc(revertFunc)
} | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"UpdateNetworkPolicy",
"(",
"e",
"*",
"endpoint",
".",
"Endpoint",
",",
"policy",
"*",
"policy",
".",
"L4Policy",
",",
"labelsMap",
",",
"deniedIngressIdentities",
",",
"deniedEgressIdentities",
"cache",
".",
"IdentityCache"... | // UpdateNetworkPolicy adds or updates a network policy in the set
// published to L7 proxies. | [
"UpdateNetworkPolicy",
"adds",
"or",
"updates",
"a",
"network",
"policy",
"in",
"the",
"set",
"published",
"to",
"L7",
"proxies",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/daemon.go#L227-L235 |
162,698 | cilium/cilium | daemon/daemon.go | RemoveNetworkPolicy | func (d *Daemon) RemoveNetworkPolicy(e *endpoint.Endpoint) {
if d.l7Proxy == nil {
return
}
d.l7Proxy.RemoveNetworkPolicy(e)
} | go | func (d *Daemon) RemoveNetworkPolicy(e *endpoint.Endpoint) {
if d.l7Proxy == nil {
return
}
d.l7Proxy.RemoveNetworkPolicy(e)
} | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"RemoveNetworkPolicy",
"(",
"e",
"*",
"endpoint",
".",
"Endpoint",
")",
"{",
"if",
"d",
".",
"l7Proxy",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"d",
".",
"l7Proxy",
".",
"RemoveNetworkPolicy",
"(",
"e",
")",... | // RemoveNetworkPolicy removes a network policy from the set published to
// L7 proxies. | [
"RemoveNetworkPolicy",
"removes",
"a",
"network",
"policy",
"from",
"the",
"set",
"published",
"to",
"L7",
"proxies",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/daemon.go#L239-L244 |
162,699 | cilium/cilium | daemon/daemon.go | QueueEndpointBuild | func (d *Daemon) QueueEndpointBuild(ctx context.Context, epID uint64) (func(), error) {
d.uniqueIDMU.Lock()
// Skip new build requests if the endpoint is already in the queue
// waiting. In this case the queued build will pick up any changes
// made so far, so there is no need to queue another build now.
if _, queued := d.uniqueID[epID]; queued {
d.uniqueIDMU.Unlock()
return nil, nil
}
// Store a cancel function to the 'uniqueID' map so that we can
// cancel the wait when the endpoint is being deleted.
uniqueIDCtx, cancel := context.WithCancel(ctx)
d.uniqueID[epID] = cancel
d.uniqueIDMU.Unlock()
// Acquire build permit. This may block.
err := d.buildEndpointSem.Acquire(uniqueIDCtx, 1)
// Not queueing any more, so remove the cancel func from 'uniqueID' map.
// The caller may still cancel the build by calling the cancel func after we
// return it. After this point another build may be queued for this
// endpoint.
d.uniqueIDMU.Lock()
delete(d.uniqueID, epID)
d.uniqueIDMU.Unlock()
if err != nil {
return nil, err // Acquire failed
}
// Acquire succeeded, but the context was canceled after?
if uniqueIDCtx.Err() != nil {
d.buildEndpointSem.Release(1)
return nil, uniqueIDCtx.Err()
}
// At this point the build permit has been acquired. It must
// be released by the caller by calling the returned function
// when the heavy lifting of the build is done.
// Using sync.Once to make the returned function idempotent.
var once sync.Once
doneFunc := func() {
once.Do(func() {
d.buildEndpointSem.Release(1)
})
}
return doneFunc, nil
} | go | func (d *Daemon) QueueEndpointBuild(ctx context.Context, epID uint64) (func(), error) {
d.uniqueIDMU.Lock()
// Skip new build requests if the endpoint is already in the queue
// waiting. In this case the queued build will pick up any changes
// made so far, so there is no need to queue another build now.
if _, queued := d.uniqueID[epID]; queued {
d.uniqueIDMU.Unlock()
return nil, nil
}
// Store a cancel function to the 'uniqueID' map so that we can
// cancel the wait when the endpoint is being deleted.
uniqueIDCtx, cancel := context.WithCancel(ctx)
d.uniqueID[epID] = cancel
d.uniqueIDMU.Unlock()
// Acquire build permit. This may block.
err := d.buildEndpointSem.Acquire(uniqueIDCtx, 1)
// Not queueing any more, so remove the cancel func from 'uniqueID' map.
// The caller may still cancel the build by calling the cancel func after we
// return it. After this point another build may be queued for this
// endpoint.
d.uniqueIDMU.Lock()
delete(d.uniqueID, epID)
d.uniqueIDMU.Unlock()
if err != nil {
return nil, err // Acquire failed
}
// Acquire succeeded, but the context was canceled after?
if uniqueIDCtx.Err() != nil {
d.buildEndpointSem.Release(1)
return nil, uniqueIDCtx.Err()
}
// At this point the build permit has been acquired. It must
// be released by the caller by calling the returned function
// when the heavy lifting of the build is done.
// Using sync.Once to make the returned function idempotent.
var once sync.Once
doneFunc := func() {
once.Do(func() {
d.buildEndpointSem.Release(1)
})
}
return doneFunc, nil
} | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"QueueEndpointBuild",
"(",
"ctx",
"context",
".",
"Context",
",",
"epID",
"uint64",
")",
"(",
"func",
"(",
")",
",",
"error",
")",
"{",
"d",
".",
"uniqueIDMU",
".",
"Lock",
"(",
")",
"\n",
"// Skip new build reques... | // QueueEndpointBuild waits for a "build permit" for the endpoint
// identified by 'epID'. This function blocks until the endpoint can
// start building. The returned function must then be called to
// release the "build permit" when the most resource intensive parts
// of the build are done. The returned function is idempotent, so it
// may be called more than once. Returns a nil function if the caller should NOT
// start building the endpoint. This may happen due to a build being
// queued for the endpoint already, or due to the wait for the build
// permit being canceled. The latter case happens when the endpoint is
// being deleted. Returns an error if the build permit could not be acquired. | [
"QueueEndpointBuild",
"waits",
"for",
"a",
"build",
"permit",
"for",
"the",
"endpoint",
"identified",
"by",
"epID",
".",
"This",
"function",
"blocks",
"until",
"the",
"endpoint",
"can",
"start",
"building",
".",
"The",
"returned",
"function",
"must",
"then",
"... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/daemon.go#L256-L303 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.