id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
163,400
cilium/cilium
api/v1/client/policy/delete_policy_parameters.go
WithLabels
func (o *DeletePolicyParams) WithLabels(labels models.Labels) *DeletePolicyParams { o.SetLabels(labels) return o }
go
func (o *DeletePolicyParams) WithLabels(labels models.Labels) *DeletePolicyParams { o.SetLabels(labels) return o }
[ "func", "(", "o", "*", "DeletePolicyParams", ")", "WithLabels", "(", "labels", "models", ".", "Labels", ")", "*", "DeletePolicyParams", "{", "o", ".", "SetLabels", "(", "labels", ")", "\n", "return", "o", "\n", "}" ]
// WithLabels adds the labels to the delete policy params
[ "WithLabels", "adds", "the", "labels", "to", "the", "delete", "policy", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/delete_policy_parameters.go#L108-L111
163,401
cilium/cilium
api/v1/server/restapi/endpoint/patch_endpoint_id_config.go
NewPatchEndpointIDConfig
func NewPatchEndpointIDConfig(ctx *middleware.Context, handler PatchEndpointIDConfigHandler) *PatchEndpointIDConfig { return &PatchEndpointIDConfig{Context: ctx, Handler: handler} }
go
func NewPatchEndpointIDConfig(ctx *middleware.Context, handler PatchEndpointIDConfigHandler) *PatchEndpointIDConfig { return &PatchEndpointIDConfig{Context: ctx, Handler: handler} }
[ "func", "NewPatchEndpointIDConfig", "(", "ctx", "*", "middleware", ".", "Context", ",", "handler", "PatchEndpointIDConfigHandler", ")", "*", "PatchEndpointIDConfig", "{", "return", "&", "PatchEndpointIDConfig", "{", "Context", ":", "ctx", ",", "Handler", ":", "handl...
// NewPatchEndpointIDConfig creates a new http.Handler for the patch endpoint ID config operation
[ "NewPatchEndpointIDConfig", "creates", "a", "new", "http", ".", "Handler", "for", "the", "patch", "endpoint", "ID", "config", "operation" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/endpoint/patch_endpoint_id_config.go#L28-L30
163,402
cilium/cilium
pkg/metrics/metrics.go
RegisterList
func RegisterList(list []prometheus.Collector) error { registered := []prometheus.Collector{} for _, c := range list { if err := Register(c); err != nil { for _, c := range registered { Unregister(c) } return err } registered = append(registered, c) } return nil }
go
func RegisterList(list []prometheus.Collector) error { registered := []prometheus.Collector{} for _, c := range list { if err := Register(c); err != nil { for _, c := range registered { Unregister(c) } return err } registered = append(registered, c) } return nil }
[ "func", "RegisterList", "(", "list", "[", "]", "prometheus", ".", "Collector", ")", "error", "{", "registered", ":=", "[", "]", "prometheus", ".", "Collector", "{", "}", "\n\n", "for", "_", ",", "c", ":=", "range", "list", "{", "if", "err", ":=", "Re...
// RegisterList registers a list of collectors. If registration of one // collector fails, no collector is registered.
[ "RegisterList", "registers", "a", "list", "of", "collectors", ".", "If", "registration", "of", "one", "collector", "fails", "no", "collector", "is", "registered", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/metrics/metrics.go#L641-L656
163,403
cilium/cilium
pkg/metrics/metrics.go
GetCounterValue
func GetCounterValue(m prometheus.Counter) float64 { var pm dto.Metric err := m.Write(&pm) if err == nil { return *pm.Counter.Value } return 0 }
go
func GetCounterValue(m prometheus.Counter) float64 { var pm dto.Metric err := m.Write(&pm) if err == nil { return *pm.Counter.Value } return 0 }
[ "func", "GetCounterValue", "(", "m", "prometheus", ".", "Counter", ")", "float64", "{", "var", "pm", "dto", ".", "Metric", "\n", "err", ":=", "m", ".", "Write", "(", "&", "pm", ")", "\n", "if", "err", "==", "nil", "{", "return", "*", "pm", ".", "...
// GetCounterValue returns the current value // stored for the counter
[ "GetCounterValue", "returns", "the", "current", "value", "stored", "for", "the", "counter" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/metrics/metrics.go#L680-L687
163,404
cilium/cilium
pkg/metrics/metrics.go
DumpMetrics
func DumpMetrics() ([]*models.Metric, error) { result := []*models.Metric{} currentMetrics, err := registry.Gather() if err != nil { return result, err } for _, val := range currentMetrics { metricName := val.GetName() metricType := val.GetType() for _, metricLabel := range val.Metric { labels := map[string]string{} for _, label := range metricLabel.GetLabel() { labels[label.GetName()] = label.GetValue() } var value float64 switch metricType { case dto.MetricType_COUNTER: value = metricLabel.Counter.GetValue() case dto.MetricType_GAUGE: value = metricLabel.GetGauge().GetValue() case dto.MetricType_UNTYPED: value = metricLabel.GetUntyped().GetValue() case dto.MetricType_SUMMARY: value = metricLabel.GetSummary().GetSampleSum() case dto.MetricType_HISTOGRAM: value = metricLabel.GetHistogram().GetSampleSum() default: continue } metric := &models.Metric{ Name: metricName, Labels: labels, Value: value, } result = append(result, metric) } } return result, nil }
go
func DumpMetrics() ([]*models.Metric, error) { result := []*models.Metric{} currentMetrics, err := registry.Gather() if err != nil { return result, err } for _, val := range currentMetrics { metricName := val.GetName() metricType := val.GetType() for _, metricLabel := range val.Metric { labels := map[string]string{} for _, label := range metricLabel.GetLabel() { labels[label.GetName()] = label.GetValue() } var value float64 switch metricType { case dto.MetricType_COUNTER: value = metricLabel.Counter.GetValue() case dto.MetricType_GAUGE: value = metricLabel.GetGauge().GetValue() case dto.MetricType_UNTYPED: value = metricLabel.GetUntyped().GetValue() case dto.MetricType_SUMMARY: value = metricLabel.GetSummary().GetSampleSum() case dto.MetricType_HISTOGRAM: value = metricLabel.GetHistogram().GetSampleSum() default: continue } metric := &models.Metric{ Name: metricName, Labels: labels, Value: value, } result = append(result, metric) } } return result, nil }
[ "func", "DumpMetrics", "(", ")", "(", "[", "]", "*", "models", ".", "Metric", ",", "error", ")", "{", "result", ":=", "[", "]", "*", "models", ".", "Metric", "{", "}", "\n", "currentMetrics", ",", "err", ":=", "registry", ".", "Gather", "(", ")", ...
// DumpMetrics gets the current Cilium metrics and dumps all into a // models.Metrics structure.If metrics cannot be retrieved, returns an error
[ "DumpMetrics", "gets", "the", "current", "Cilium", "metrics", "and", "dumps", "all", "into", "a", "models", ".", "Metrics", "structure", ".", "If", "metrics", "cannot", "be", "retrieved", "returns", "an", "error" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/metrics/metrics.go#L691-L734
163,405
cilium/cilium
pkg/policy/cidr.go
getPrefixesFromCIDR
func getPrefixesFromCIDR(cidrs api.CIDRSlice) []*net.IPNet { result, _ := ip.ParseCIDRs(cidrs.StringSlice()) return result }
go
func getPrefixesFromCIDR(cidrs api.CIDRSlice) []*net.IPNet { result, _ := ip.ParseCIDRs(cidrs.StringSlice()) return result }
[ "func", "getPrefixesFromCIDR", "(", "cidrs", "api", ".", "CIDRSlice", ")", "[", "]", "*", "net", ".", "IPNet", "{", "result", ",", "_", ":=", "ip", ".", "ParseCIDRs", "(", "cidrs", ".", "StringSlice", "(", ")", ")", "\n", "return", "result", "\n", "}...
// getPrefixesFromCIDR fetches all CIDRs referred to by the specified slice // and returns them as regular golang CIDR objects.
[ "getPrefixesFromCIDR", "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/policy/cidr.go#L26-L29
163,406
cilium/cilium
pkg/policy/cidr.go
GetPrefixesFromCIDRSet
func GetPrefixesFromCIDRSet(rules api.CIDRRuleSlice) []*net.IPNet { cidrs := api.ComputeResultantCIDRSet(rules) return getPrefixesFromCIDR(cidrs) }
go
func GetPrefixesFromCIDRSet(rules api.CIDRRuleSlice) []*net.IPNet { cidrs := api.ComputeResultantCIDRSet(rules) return getPrefixesFromCIDR(cidrs) }
[ "func", "GetPrefixesFromCIDRSet", "(", "rules", "api", ".", "CIDRRuleSlice", ")", "[", "]", "*", "net", ".", "IPNet", "{", "cidrs", ":=", "api", ".", "ComputeResultantCIDRSet", "(", "rules", ")", "\n", "return", "getPrefixesFromCIDR", "(", "cidrs", ")", "\n"...
// GetPrefixesFromCIDRSet fetches all CIDRs referred to by the specified slice // and returns them as regular golang CIDR objects. // // Assumes that validation already occurred on 'rules'.
[ "GetPrefixesFromCIDRSet", "fetches", "all", "CIDRs", "referred", "to", "by", "the", "specified", "slice", "and", "returns", "them", "as", "regular", "golang", "CIDR", "objects", ".", "Assumes", "that", "validation", "already", "occurred", "on", "rules", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/cidr.go#L35-L38
163,407
cilium/cilium
pkg/policy/cidr.go
GetCIDRPrefixes
func GetCIDRPrefixes(rules api.Rules) []*net.IPNet { if len(rules) == 0 { return nil } res := make([]*net.IPNet, 0, 32) for _, r := range rules { for _, ir := range r.Ingress { if len(ir.FromCIDR) > 0 { res = append(res, getPrefixesFromCIDR(ir.FromCIDR)...) } if len(ir.FromCIDRSet) > 0 { res = append(res, GetPrefixesFromCIDRSet(ir.FromCIDRSet)...) } } for _, er := range r.Egress { if len(er.ToCIDR) > 0 { res = append(res, getPrefixesFromCIDR(er.ToCIDR)...) } if len(er.ToCIDRSet) > 0 { res = append(res, GetPrefixesFromCIDRSet(er.ToCIDRSet)...) } } } return res }
go
func GetCIDRPrefixes(rules api.Rules) []*net.IPNet { if len(rules) == 0 { return nil } res := make([]*net.IPNet, 0, 32) for _, r := range rules { for _, ir := range r.Ingress { if len(ir.FromCIDR) > 0 { res = append(res, getPrefixesFromCIDR(ir.FromCIDR)...) } if len(ir.FromCIDRSet) > 0 { res = append(res, GetPrefixesFromCIDRSet(ir.FromCIDRSet)...) } } for _, er := range r.Egress { if len(er.ToCIDR) > 0 { res = append(res, getPrefixesFromCIDR(er.ToCIDR)...) } if len(er.ToCIDRSet) > 0 { res = append(res, GetPrefixesFromCIDRSet(er.ToCIDRSet)...) } } } return res }
[ "func", "GetCIDRPrefixes", "(", "rules", "api", ".", "Rules", ")", "[", "]", "*", "net", ".", "IPNet", "{", "if", "len", "(", "rules", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "res", ":=", "make", "(", "[", "]", "*", "net", ".", ...
// GetCIDRPrefixes runs through the specified 'rules' to find every reference // to a CIDR in the rules, and returns a slice containing all of these CIDRs. // Multiple rules referring to the same CIDR will result in multiple copies of // the CIDR in the returned slice. // // Assumes that validation already occurred on 'rules'.
[ "GetCIDRPrefixes", "runs", "through", "the", "specified", "rules", "to", "find", "every", "reference", "to", "a", "CIDR", "in", "the", "rules", "and", "returns", "a", "slice", "containing", "all", "of", "these", "CIDRs", ".", "Multiple", "rules", "referring", ...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/cidr.go#L46-L70
163,408
cilium/cilium
monitor/listener/listener.go
IsDisconnected
func IsDisconnected(err error) bool { if err == nil { return false } op, ok := err.(*net.OpError) if !ok { return false } syscerr, ok := op.Err.(*os.SyscallError) if !ok { return false } errn := syscerr.Err.(syscall.Errno) return errn == syscall.EPIPE }
go
func IsDisconnected(err error) bool { if err == nil { return false } op, ok := err.(*net.OpError) if !ok { return false } syscerr, ok := op.Err.(*os.SyscallError) if !ok { return false } errn := syscerr.Err.(syscall.Errno) return errn == syscall.EPIPE }
[ "func", "IsDisconnected", "(", "err", "error", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "op", ",", "ok", ":=", "err", ".", "(", "*", "net", ".", "OpError", ")", "\n", "if", "!", "ok", "{", "return", ...
// IsDisconnected is a convenience function that wraps the absurdly long set of // checks for a disconnect.
[ "IsDisconnected", "is", "a", "convenience", "function", "that", "wraps", "the", "absurdly", "long", "set", "of", "checks", "for", "a", "disconnect", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/monitor/listener/listener.go#L58-L75
163,409
cilium/cilium
pkg/buildqueue/buildqueue.go
finish
func (b *buildGroup) finish(q *BuildQueue, buildStatus *buildStatus) { q.mutex.Lock() b.running-- buildStatus.currentBuild = nil q.mutex.Unlock() q.waitingBuilders.Broadcast() }
go
func (b *buildGroup) finish(q *BuildQueue, buildStatus *buildStatus) { q.mutex.Lock() b.running-- buildStatus.currentBuild = nil q.mutex.Unlock() q.waitingBuilders.Broadcast() }
[ "func", "(", "b", "*", "buildGroup", ")", "finish", "(", "q", "*", "BuildQueue", ",", "buildStatus", "*", "buildStatus", ")", "{", "q", ".", "mutex", ".", "Lock", "(", ")", "\n", "b", ".", "running", "--", "\n", "buildStatus", ".", "currentBuild", "=...
// finish signals that a build of this buildGroup has completed
[ "finish", "signals", "that", "a", "build", "of", "this", "buildGroup", "has", "completed" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/buildqueue/buildqueue.go#L78-L85
163,410
cilium/cilium
pkg/buildqueue/buildqueue.go
NewBuildQueue
func NewBuildQueue(name string) *BuildQueue { q := &BuildQueue{ name: name, buildStatus: buildStatusMap{}, workerBuildQueue: make(chan Builder, buildQueueSize), stopWorker: make(chan struct{}, 0), regularBuilds: buildGroup{ condition: func(q *BuildQueue) bool { return q.exclusiveBuilds.waiting == 0 && q.exclusiveBuilds.running == 0 }, }, exclusiveBuilds: buildGroup{ condition: func(q *BuildQueue) bool { return q.exclusiveBuilds.running == 0 && q.regularBuilds.running == 0 }, }, } q.waitingBuilders = sync.NewCond(&q.mutex) nWorkers := numWorkerThreads() for w := 0; w < nWorkers; w++ { go q.runWorker() } return q }
go
func NewBuildQueue(name string) *BuildQueue { q := &BuildQueue{ name: name, buildStatus: buildStatusMap{}, workerBuildQueue: make(chan Builder, buildQueueSize), stopWorker: make(chan struct{}, 0), regularBuilds: buildGroup{ condition: func(q *BuildQueue) bool { return q.exclusiveBuilds.waiting == 0 && q.exclusiveBuilds.running == 0 }, }, exclusiveBuilds: buildGroup{ condition: func(q *BuildQueue) bool { return q.exclusiveBuilds.running == 0 && q.regularBuilds.running == 0 }, }, } q.waitingBuilders = sync.NewCond(&q.mutex) nWorkers := numWorkerThreads() for w := 0; w < nWorkers; w++ { go q.runWorker() } return q }
[ "func", "NewBuildQueue", "(", "name", "string", ")", "*", "BuildQueue", "{", "q", ":=", "&", "BuildQueue", "{", "name", ":", "name", ",", "buildStatus", ":", "buildStatusMap", "{", "}", ",", "workerBuildQueue", ":", "make", "(", "chan", "Builder", ",", "...
// NewBuildQueue returns a new build queue
[ "NewBuildQueue", "returns", "a", "new", "build", "queue" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/buildqueue/buildqueue.go#L120-L146
163,411
cilium/cilium
pkg/buildqueue/buildqueue.go
Stop
func (q *BuildQueue) Stop() { close(q.stopWorker) waitForCleanup := sync.WaitGroup{} q.mutex.Lock() for _, status := range q.buildStatus { waitForCleanup.Add(1) go func(b Builder) { q.Drain(b) waitForCleanup.Done() }(status.builder) } q.mutex.Unlock() waitForCleanup.Wait() }
go
func (q *BuildQueue) Stop() { close(q.stopWorker) waitForCleanup := sync.WaitGroup{} q.mutex.Lock() for _, status := range q.buildStatus { waitForCleanup.Add(1) go func(b Builder) { q.Drain(b) waitForCleanup.Done() }(status.builder) } q.mutex.Unlock() waitForCleanup.Wait() }
[ "func", "(", "q", "*", "BuildQueue", ")", "Stop", "(", ")", "{", "close", "(", "q", ".", "stopWorker", ")", "\n\n", "waitForCleanup", ":=", "sync", ".", "WaitGroup", "{", "}", "\n\n", "q", ".", "mutex", ".", "Lock", "(", ")", "\n", "for", "_", ",...
// Stop stops the build queue and terminates all workers
[ "Stop", "stops", "the", "build", "queue", "and", "terminates", "all", "workers" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/buildqueue/buildqueue.go#L149-L165
163,412
cilium/cilium
pkg/buildqueue/buildqueue.go
createAndAddNotificationChannel
func (b *build) createAndAddNotificationChannel() BuildNotification { notify := newBuildNotification() b.notificationChannels = append(b.notificationChannels, notify) return notify }
go
func (b *build) createAndAddNotificationChannel() BuildNotification { notify := newBuildNotification() b.notificationChannels = append(b.notificationChannels, notify) return notify }
[ "func", "(", "b", "*", "build", ")", "createAndAddNotificationChannel", "(", ")", "BuildNotification", "{", "notify", ":=", "newBuildNotification", "(", ")", "\n", "b", ".", "notificationChannels", "=", "append", "(", "b", ".", "notificationChannels", ",", "noti...
// createAndAddNotificationChannel creates and adds a build notification // channel. This function may only be called while the build is not yet in // progress.
[ "createAndAddNotificationChannel", "creates", "and", "adds", "a", "build", "notification", "channel", ".", "This", "function", "may", "only", "be", "called", "while", "the", "build", "is", "not", "yet", "in", "progress", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/buildqueue/buildqueue.go#L229-L233
163,413
cilium/cilium
pkg/buildqueue/buildqueue.go
reportStatus
func (b *build) reportStatus(q *BuildQueue, success bool) { for _, notify := range b.notificationChannels { notify <- success close(notify) } }
go
func (b *build) reportStatus(q *BuildQueue, success bool) { for _, notify := range b.notificationChannels { notify <- success close(notify) } }
[ "func", "(", "b", "*", "build", ")", "reportStatus", "(", "q", "*", "BuildQueue", ",", "success", "bool", ")", "{", "for", "_", ",", "notify", ":=", "range", "b", ".", "notificationChannels", "{", "notify", "<-", "success", "\n", "close", "(", "notify"...
// reportStatus reports the status of a build to all notification channels. // This function may only be called if the build is the currentBuild. It may // never be called while the build is still assigned to nextBuild.
[ "reportStatus", "reports", "the", "status", "of", "a", "build", "to", "all", "notification", "channels", ".", "This", "function", "may", "only", "be", "called", "if", "the", "build", "is", "the", "currentBuild", ".", "It", "may", "never", "be", "called", "...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/buildqueue/buildqueue.go#L238-L243
163,414
cilium/cilium
pkg/buildqueue/buildqueue.go
cancelScheduled
func (b *build) cancelScheduled(q *BuildQueue) int { numBuilds := b.numFolded() metrics.BuildQueueEntries.With(map[string]string{ metrics.LabelBuildQueueName: q.name, metrics.LabelBuildState: metrics.BuildStateWaiting, }).Sub(float64(numBuilds)) b.reportStatus(q, false) return numBuilds }
go
func (b *build) cancelScheduled(q *BuildQueue) int { numBuilds := b.numFolded() metrics.BuildQueueEntries.With(map[string]string{ metrics.LabelBuildQueueName: q.name, metrics.LabelBuildState: metrics.BuildStateWaiting, }).Sub(float64(numBuilds)) b.reportStatus(q, false) return numBuilds }
[ "func", "(", "b", "*", "build", ")", "cancelScheduled", "(", "q", "*", "BuildQueue", ")", "int", "{", "numBuilds", ":=", "b", ".", "numFolded", "(", ")", "\n\n", "metrics", ".", "BuildQueueEntries", ".", "With", "(", "map", "[", "string", "]", "string"...
// cancel cancels a scheduled and not yet running build. q.mutex must be held.
[ "cancel", "cancels", "a", "scheduled", "and", "not", "yet", "running", "build", ".", "q", ".", "mutex", "must", "be", "held", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/buildqueue/buildqueue.go#L246-L257
163,415
cilium/cilium
pkg/buildqueue/buildqueue.go
Remove
func (q *BuildQueue) Remove(b Buildable) { uuid := b.GetUUID() q.mutex.Lock() if status, ok := q.buildStatus[uuid]; ok { // Only remove the builder UUID from the buildStatus if no // build is currently running. If a build is running, the // buildStatus continue to be in place until the build has // completed. if status.currentBuild == nil { delete(q.buildStatus, uuid) } if status.nextBuild != nil { num := status.nextBuild.cancelScheduled(q) defer status.builder.BuildsDequeued(num, true) } } q.mutex.Unlock() }
go
func (q *BuildQueue) Remove(b Buildable) { uuid := b.GetUUID() q.mutex.Lock() if status, ok := q.buildStatus[uuid]; ok { // Only remove the builder UUID from the buildStatus if no // build is currently running. If a build is running, the // buildStatus continue to be in place until the build has // completed. if status.currentBuild == nil { delete(q.buildStatus, uuid) } if status.nextBuild != nil { num := status.nextBuild.cancelScheduled(q) defer status.builder.BuildsDequeued(num, true) } } q.mutex.Unlock() }
[ "func", "(", "q", "*", "BuildQueue", ")", "Remove", "(", "b", "Buildable", ")", "{", "uuid", ":=", "b", ".", "GetUUID", "(", ")", "\n", "q", ".", "mutex", ".", "Lock", "(", ")", "\n", "if", "status", ",", "ok", ":=", "q", ".", "buildStatus", "[...
// Remove removes the builder from the queue.
[ "Remove", "removes", "the", "builder", "from", "the", "queue", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/buildqueue/buildqueue.go#L373-L391
163,416
cilium/cilium
pkg/buildqueue/buildqueue.go
Drain
func (q *BuildQueue) Drain(b Buildable) bool { uuid := b.GetUUID() waited := false q.mutex.Lock() status, ok := q.buildStatus[uuid] if ok { if status.nextBuild != nil { num := status.nextBuild.cancelScheduled(q) status.nextBuild = nil defer status.builder.BuildsDequeued(num, true) } for status.currentBuild != nil { waited = true q.waitingBuilders.Wait() } delete(q.buildStatus, uuid) } q.mutex.Unlock() return waited }
go
func (q *BuildQueue) Drain(b Buildable) bool { uuid := b.GetUUID() waited := false q.mutex.Lock() status, ok := q.buildStatus[uuid] if ok { if status.nextBuild != nil { num := status.nextBuild.cancelScheduled(q) status.nextBuild = nil defer status.builder.BuildsDequeued(num, true) } for status.currentBuild != nil { waited = true q.waitingBuilders.Wait() } delete(q.buildStatus, uuid) } q.mutex.Unlock() return waited }
[ "func", "(", "q", "*", "BuildQueue", ")", "Drain", "(", "b", "Buildable", ")", "bool", "{", "uuid", ":=", "b", ".", "GetUUID", "(", ")", "\n", "waited", ":=", "false", "\n\n", "q", ".", "mutex", ".", "Lock", "(", ")", "\n", "status", ",", "ok", ...
// Drain will drain the queue from any running or scheduled builds of a // Buildable. If a build is running, the function will block for the build to // complete. It is the responsibility of the caller that the Buildable does not // get re-scheduled during the draining. Returns true if waiting was required.
[ "Drain", "will", "drain", "the", "queue", "from", "any", "running", "or", "scheduled", "builds", "of", "a", "Buildable", ".", "If", "a", "build", "is", "running", "the", "function", "will", "block", "for", "the", "build", "to", "complete", ".", "It", "is...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/buildqueue/buildqueue.go#L397-L420
163,417
cilium/cilium
pkg/buildqueue/buildqueue.go
checkBuildGuarantees
func (q *BuildQueue) checkBuildGuarantees() error { q.mutex.Lock() defer q.mutex.Unlock() buildCount := map[string]int{} for _, status := range q.buildStatus { if build := status.currentBuild; build != nil { buildCount[build.uuid]++ } } switch { case q.exclusiveBuilds.running > 1: return fmt.Errorf("More than one exclusive build is running") case q.exclusiveBuilds.running > 0 && q.regularBuilds.running > 0: return fmt.Errorf("Exclusive build is running in parallel with regular build") default: for uuid, count := range buildCount { if count > 1 { return fmt.Errorf("UUID %s is being built in parallel", uuid) } } } return nil }
go
func (q *BuildQueue) checkBuildGuarantees() error { q.mutex.Lock() defer q.mutex.Unlock() buildCount := map[string]int{} for _, status := range q.buildStatus { if build := status.currentBuild; build != nil { buildCount[build.uuid]++ } } switch { case q.exclusiveBuilds.running > 1: return fmt.Errorf("More than one exclusive build is running") case q.exclusiveBuilds.running > 0 && q.regularBuilds.running > 0: return fmt.Errorf("Exclusive build is running in parallel with regular build") default: for uuid, count := range buildCount { if count > 1 { return fmt.Errorf("UUID %s is being built in parallel", uuid) } } } return nil }
[ "func", "(", "q", "*", "BuildQueue", ")", "checkBuildGuarantees", "(", ")", "error", "{", "q", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "q", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "buildCount", ":=", "map", "[", "string", "]", "i...
// checkBuildGuarantees reports errors when build conditions are currently not // being respected. This function is used for unit testing.
[ "checkBuildGuarantees", "reports", "errors", "when", "build", "conditions", "are", "currently", "not", "being", "respected", ".", "This", "function", "is", "used", "for", "unit", "testing", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/buildqueue/buildqueue.go#L569-L595
163,418
cilium/cilium
api/v1/health/server/restapi/connectivity/get_status.go
NewGetStatus
func NewGetStatus(ctx *middleware.Context, handler GetStatusHandler) *GetStatus { return &GetStatus{Context: ctx, Handler: handler} }
go
func NewGetStatus(ctx *middleware.Context, handler GetStatusHandler) *GetStatus { return &GetStatus{Context: ctx, Handler: handler} }
[ "func", "NewGetStatus", "(", "ctx", "*", "middleware", ".", "Context", ",", "handler", "GetStatusHandler", ")", "*", "GetStatus", "{", "return", "&", "GetStatus", "{", "Context", ":", "ctx", ",", "Handler", ":", "handler", "}", "\n", "}" ]
// NewGetStatus creates a new http.Handler for the get status operation
[ "NewGetStatus", "creates", "a", "new", "http", ".", "Handler", "for", "the", "get", "status", "operation" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/server/restapi/connectivity/get_status.go#L28-L30
163,419
cilium/cilium
pkg/maps/policymap/callmap.go
RemoveGlobalMapping
func RemoveGlobalMapping(id uint32) error { gpm, err := OpenCallMap() if err == nil { k := plumbingKey{ key: id, } err = gpm.Map.Delete(&k) gpm.Close() } return err }
go
func RemoveGlobalMapping(id uint32) error { gpm, err := OpenCallMap() if err == nil { k := plumbingKey{ key: id, } err = gpm.Map.Delete(&k) gpm.Close() } return err }
[ "func", "RemoveGlobalMapping", "(", "id", "uint32", ")", "error", "{", "gpm", ",", "err", ":=", "OpenCallMap", "(", ")", "\n", "if", "err", "==", "nil", "{", "k", ":=", "plumbingKey", "{", "key", ":", "id", ",", "}", "\n", "err", "=", "gpm", ".", ...
// RemoveGlobalMapping removes the mapping from the specified endpoint ID to // the BPF policy program for that endpoint.
[ "RemoveGlobalMapping", "removes", "the", "mapping", "from", "the", "specified", "endpoint", "ID", "to", "the", "BPF", "policy", "program", "for", "that", "endpoint", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/policymap/callmap.go#L53-L64
163,420
cilium/cilium
pkg/maps/policymap/callmap.go
OpenCallMap
func OpenCallMap() (*PolicyPlumbingMap, error) { m, err := bpf.OpenMap(CallMapName) if err != nil { return nil, err } return &PolicyPlumbingMap{Map: m}, nil }
go
func OpenCallMap() (*PolicyPlumbingMap, error) { m, err := bpf.OpenMap(CallMapName) if err != nil { return nil, err } return &PolicyPlumbingMap{Map: m}, nil }
[ "func", "OpenCallMap", "(", ")", "(", "*", "PolicyPlumbingMap", ",", "error", ")", "{", "m", ",", "err", ":=", "bpf", ".", "OpenMap", "(", "CallMapName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "retur...
// OpenCallMap opens the map that maps endpoint IDs to program file // descriptors, which allows tail calling into the policy datapath code from // other BPF programs.
[ "OpenCallMap", "opens", "the", "map", "that", "maps", "endpoint", "IDs", "to", "program", "file", "descriptors", "which", "allows", "tail", "calling", "into", "the", "policy", "datapath", "code", "from", "other", "BPF", "programs", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/policymap/callmap.go#L69-L75
163,421
cilium/cilium
api/v1/server/restapi/daemon/get_config_responses.go
WithPayload
func (o *GetConfigOK) WithPayload(payload *models.DaemonConfiguration) *GetConfigOK { o.Payload = payload return o }
go
func (o *GetConfigOK) WithPayload(payload *models.DaemonConfiguration) *GetConfigOK { o.Payload = payload return o }
[ "func", "(", "o", "*", "GetConfigOK", ")", "WithPayload", "(", "payload", "*", "models", ".", "DaemonConfiguration", ")", "*", "GetConfigOK", "{", "o", ".", "Payload", "=", "payload", "\n", "return", "o", "\n", "}" ]
// WithPayload adds the payload to the get config o k response
[ "WithPayload", "adds", "the", "payload", "to", "the", "get", "config", "o", "k", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/daemon/get_config_responses.go#L38-L41
163,422
cilium/cilium
pkg/maps/tunnel/tunnel.go
NewTunnelMap
func NewTunnelMap(name string) *Map { return &Map{Map: bpf.NewMap(MapName, bpf.MapTypeHash, int(unsafe.Sizeof(TunnelEndpoint{})), int(unsafe.Sizeof(TunnelEndpoint{})), MaxEntries, 0, 0, func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) { k, v := TunnelEndpoint{}, TunnelEndpoint{} if err := bpf.ConvertKeyValue(key, value, &k, &v); err != nil { return nil, nil, err } return &k, &v, nil }).WithCache(), } }
go
func NewTunnelMap(name string) *Map { return &Map{Map: bpf.NewMap(MapName, bpf.MapTypeHash, int(unsafe.Sizeof(TunnelEndpoint{})), int(unsafe.Sizeof(TunnelEndpoint{})), MaxEntries, 0, 0, func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) { k, v := TunnelEndpoint{}, TunnelEndpoint{} if err := bpf.ConvertKeyValue(key, value, &k, &v); err != nil { return nil, nil, err } return &k, &v, nil }).WithCache(), } }
[ "func", "NewTunnelMap", "(", "name", "string", ")", "*", "Map", "{", "return", "&", "Map", "{", "Map", ":", "bpf", ".", "NewMap", "(", "MapName", ",", "bpf", ".", "MapTypeHash", ",", "int", "(", "unsafe", ".", "Sizeof", "(", "TunnelEndpoint", "{", "}...
// NewTunnelMap returns a new tunnel map with the specified name.
[ "NewTunnelMap", "returns", "a", "new", "tunnel", "map", "with", "the", "specified", "name", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/tunnel/tunnel.go#L44-L61
163,423
cilium/cilium
pkg/maps/tunnel/tunnel.go
GetTunnelEndpoint
func (m *Map) GetTunnelEndpoint(prefix net.IP) (net.IP, error) { val, err := TunnelMap.Lookup(newTunnelEndpoint(prefix)) if err != nil { return net.IP{}, err } return val.(*TunnelEndpoint).ToIP(), nil }
go
func (m *Map) GetTunnelEndpoint(prefix net.IP) (net.IP, error) { val, err := TunnelMap.Lookup(newTunnelEndpoint(prefix)) if err != nil { return net.IP{}, err } return val.(*TunnelEndpoint).ToIP(), nil }
[ "func", "(", "m", "*", "Map", ")", "GetTunnelEndpoint", "(", "prefix", "net", ".", "IP", ")", "(", "net", ".", "IP", ",", "error", ")", "{", "val", ",", "err", ":=", "TunnelMap", ".", "Lookup", "(", "newTunnelEndpoint", "(", "prefix", ")", ")", "\n...
// GetTunnelEndpoint removes a prefix => tunnel-endpoint mapping
[ "GetTunnelEndpoint", "removes", "a", "prefix", "=", ">", "tunnel", "-", "endpoint", "mapping" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/tunnel/tunnel.go#L93-L100
163,424
cilium/cilium
pkg/maps/tunnel/tunnel.go
DeleteTunnelEndpoint
func (m *Map) DeleteTunnelEndpoint(prefix net.IP) error { log.WithField(fieldPrefix, prefix).Debug("Deleting tunnel map entry") return TunnelMap.Delete(newTunnelEndpoint(prefix)) }
go
func (m *Map) DeleteTunnelEndpoint(prefix net.IP) error { log.WithField(fieldPrefix, prefix).Debug("Deleting tunnel map entry") return TunnelMap.Delete(newTunnelEndpoint(prefix)) }
[ "func", "(", "m", "*", "Map", ")", "DeleteTunnelEndpoint", "(", "prefix", "net", ".", "IP", ")", "error", "{", "log", ".", "WithField", "(", "fieldPrefix", ",", "prefix", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "TunnelMap", ".", "Del...
// DeleteTunnelEndpoint removes a prefix => tunnel-endpoint mapping
[ "DeleteTunnelEndpoint", "removes", "a", "prefix", "=", ">", "tunnel", "-", "endpoint", "mapping" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/tunnel/tunnel.go#L103-L106
163,425
cilium/cilium
api/v1/models/b_p_f_map.go
Validate
func (m *BPFMap) Validate(formats strfmt.Registry) error { var res []error if err := m.validateCache(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m *BPFMap) Validate(formats strfmt.Registry) error { var res []error if err := m.validateCache(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "*", "BPFMap", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateCache", "(", "formats", ")", ";", "err", "!=", "nil", "{"...
// Validate validates this b p f map
[ "Validate", "validates", "this", "b", "p", "f", "map" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/b_p_f_map.go#L29-L40
163,426
cilium/cilium
daemon/state.go
validateEndpoint
func (d *Daemon) validateEndpoint(ep *endpoint.Endpoint) (valid bool, err error) { // On each restart, the health endpoint is supposed to be recreated. // Hence we need to clean health endpoint state unconditionally. if ep.HasLabels(labels.LabelHealth) { // Ignore health endpoint and don't report // it as not restored. But we need to clean up the old // state files, so do this now. healthStateDir := ep.StateDirectoryPath() scopedLog := log.WithFields(logrus.Fields{ logfields.EndpointID: ep.ID, logfields.Path: healthStateDir, }) scopedLog.Debug("Removing old health endpoint state directory") if err := os.RemoveAll(healthStateDir); err != nil { scopedLog.Warning("Cannot clean up old health state directory") } return false, nil } if ep.K8sPodName != "" && ep.K8sNamespace != "" && k8s.IsEnabled() { _, err := k8s.Client().CoreV1().Pods(ep.K8sNamespace).Get(ep.K8sPodName, meta_v1.GetOptions{}) if err != nil && k8serrors.IsNotFound(err) { return false, fmt.Errorf("kubernetes pod not found") } } if ep.HasIpvlanDataPath() { // FIXME: We cannot check whether ipvlan slave netdev exists, // because it requires entering container netns which is not // always accessible (e.g. in k8s case "/proc" has to be bind // mounted). Instead, we check whether the tail call map exists. if _, err := os.Stat(ep.BPFIpvlanMapPath()); err != nil { return false, fmt.Errorf("tail call map for IPvlan unavailable: %s", err) } } else if _, err := netlink.LinkByName(ep.IfName); err != nil { return false, fmt.Errorf("interface %s could not be found", ep.IfName) } if option.Config.WorkloadsEnabled() && !workloads.IsRunning(ep) { return false, fmt.Errorf("no workload could be associated with endpoint") } if err := d.allocateIPsLocked(ep); err != nil { return false, fmt.Errorf("Failed to re-allocate IP of endpoint: %s", err) } return true, nil }
go
func (d *Daemon) validateEndpoint(ep *endpoint.Endpoint) (valid bool, err error) { // On each restart, the health endpoint is supposed to be recreated. // Hence we need to clean health endpoint state unconditionally. if ep.HasLabels(labels.LabelHealth) { // Ignore health endpoint and don't report // it as not restored. But we need to clean up the old // state files, so do this now. healthStateDir := ep.StateDirectoryPath() scopedLog := log.WithFields(logrus.Fields{ logfields.EndpointID: ep.ID, logfields.Path: healthStateDir, }) scopedLog.Debug("Removing old health endpoint state directory") if err := os.RemoveAll(healthStateDir); err != nil { scopedLog.Warning("Cannot clean up old health state directory") } return false, nil } if ep.K8sPodName != "" && ep.K8sNamespace != "" && k8s.IsEnabled() { _, err := k8s.Client().CoreV1().Pods(ep.K8sNamespace).Get(ep.K8sPodName, meta_v1.GetOptions{}) if err != nil && k8serrors.IsNotFound(err) { return false, fmt.Errorf("kubernetes pod not found") } } if ep.HasIpvlanDataPath() { // FIXME: We cannot check whether ipvlan slave netdev exists, // because it requires entering container netns which is not // always accessible (e.g. in k8s case "/proc" has to be bind // mounted). Instead, we check whether the tail call map exists. if _, err := os.Stat(ep.BPFIpvlanMapPath()); err != nil { return false, fmt.Errorf("tail call map for IPvlan unavailable: %s", err) } } else if _, err := netlink.LinkByName(ep.IfName); err != nil { return false, fmt.Errorf("interface %s could not be found", ep.IfName) } if option.Config.WorkloadsEnabled() && !workloads.IsRunning(ep) { return false, fmt.Errorf("no workload could be associated with endpoint") } if err := d.allocateIPsLocked(ep); err != nil { return false, fmt.Errorf("Failed to re-allocate IP of endpoint: %s", err) } return true, nil }
[ "func", "(", "d", "*", "Daemon", ")", "validateEndpoint", "(", "ep", "*", "endpoint", ".", "Endpoint", ")", "(", "valid", "bool", ",", "err", "error", ")", "{", "// On each restart, the health endpoint is supposed to be recreated.", "// Hence we need to clean health end...
// validateEndpoint attempts to determine that the endpoint is valid, ie it // still exists in k8s, its datapath devices are present, and Cilium is // responsible for its workload, etc. // // Returns true to indicate that the endpoint is valid to restore, and an // optional error.
[ "validateEndpoint", "attempts", "to", "determine", "that", "the", "endpoint", "is", "valid", "ie", "it", "still", "exists", "in", "k8s", "its", "datapath", "devices", "are", "present", "and", "Cilium", "is", "responsible", "for", "its", "workload", "etc", ".",...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/state.go#L57-L104
163,427
cilium/cilium
proxylib/proxylib/connection.go
advanceInput
func advanceInput(input [][]byte, bytes int) [][]byte { for bytes > 0 && len(input) > 0 { rem := len(input[0]) // this much data left in the first slice if bytes < rem { input[0] = input[0][bytes:] // skip 'bytes' bytes bytes = 0 } else { // go to the beginning of the next unit bytes -= rem input = input[1:] // may result in an empty slice } } return input }
go
func advanceInput(input [][]byte, bytes int) [][]byte { for bytes > 0 && len(input) > 0 { rem := len(input[0]) // this much data left in the first slice if bytes < rem { input[0] = input[0][bytes:] // skip 'bytes' bytes bytes = 0 } else { // go to the beginning of the next unit bytes -= rem input = input[1:] // may result in an empty slice } } return input }
[ "func", "advanceInput", "(", "input", "[", "]", "[", "]", "byte", ",", "bytes", "int", ")", "[", "]", "[", "]", "byte", "{", "for", "bytes", ">", "0", "&&", "len", "(", "input", ")", ">", "0", "{", "rem", ":=", "len", "(", "input", "[", "0", ...
// Skip bytes in input, or exhaust the input.
[ "Skip", "bytes", "in", "input", "or", "exhaust", "the", "input", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/proxylib/proxylib/connection.go#L103-L115
163,428
cilium/cilium
proxylib/proxylib/connection.go
getInjectBuf
func (connection *Connection) getInjectBuf(reply bool) InjectBuf { if reply { return connection.ReplyBuf } return connection.OrigBuf }
go
func (connection *Connection) getInjectBuf(reply bool) InjectBuf { if reply { return connection.ReplyBuf } return connection.OrigBuf }
[ "func", "(", "connection", "*", "Connection", ")", "getInjectBuf", "(", "reply", "bool", ")", "InjectBuf", "{", "if", "reply", "{", "return", "connection", ".", "ReplyBuf", "\n", "}", "\n", "return", "connection", ".", "OrigBuf", "\n", "}" ]
// getInjectBuf return the pointer to the inject buffer slice header for the indicated direction
[ "getInjectBuf", "return", "the", "pointer", "to", "the", "inject", "buffer", "slice", "header", "for", "the", "indicated", "direction" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/proxylib/proxylib/connection.go#L181-L186
163,429
cilium/cilium
proxylib/proxylib/connection.go
Inject
func (connection *Connection) Inject(reply bool, data []byte) int { buf := connection.getInjectBuf(reply) // append data to C-provided buffer offset := len(*buf) n := copy((*buf)[offset:cap(*buf)], data) *buf = (*buf)[:offset+n] // update the buffer length log.Debugf("proxylib: Injected %d bytes: %s (given: %s)", n, string((*buf)[offset:offset+n]), string(data)) // return the number of bytes injected. This may be less than the length of `data` is // the buffer becomes full. // Parser may opt dropping the connection via parser error in this case! return n }
go
func (connection *Connection) Inject(reply bool, data []byte) int { buf := connection.getInjectBuf(reply) // append data to C-provided buffer offset := len(*buf) n := copy((*buf)[offset:cap(*buf)], data) *buf = (*buf)[:offset+n] // update the buffer length log.Debugf("proxylib: Injected %d bytes: %s (given: %s)", n, string((*buf)[offset:offset+n]), string(data)) // return the number of bytes injected. This may be less than the length of `data` is // the buffer becomes full. // Parser may opt dropping the connection via parser error in this case! return n }
[ "func", "(", "connection", "*", "Connection", ")", "Inject", "(", "reply", "bool", ",", "data", "[", "]", "byte", ")", "int", "{", "buf", ":=", "connection", ".", "getInjectBuf", "(", "reply", ")", "\n", "// append data to C-provided buffer", "offset", ":=",...
// inject buffers data to be injected into the connection at the point of INJECT
[ "inject", "buffers", "data", "to", "be", "injected", "into", "the", "connection", "at", "the", "point", "of", "INJECT" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/proxylib/proxylib/connection.go#L189-L202
163,430
cilium/cilium
proxylib/proxylib/connection.go
IsInjectBufFull
func (connection *Connection) IsInjectBufFull(reply bool) bool { buf := connection.getInjectBuf(reply) return len(*buf) == cap(*buf) }
go
func (connection *Connection) IsInjectBufFull(reply bool) bool { buf := connection.getInjectBuf(reply) return len(*buf) == cap(*buf) }
[ "func", "(", "connection", "*", "Connection", ")", "IsInjectBufFull", "(", "reply", "bool", ")", "bool", "{", "buf", ":=", "connection", ".", "getInjectBuf", "(", "reply", ")", "\n", "return", "len", "(", "*", "buf", ")", "==", "cap", "(", "*", "buf", ...
// isInjectBufFull return true if the inject buffer for the indicated direction is full
[ "isInjectBufFull", "return", "true", "if", "the", "inject", "buffer", "for", "the", "indicated", "direction", "is", "full" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/proxylib/proxylib/connection.go#L205-L208
163,431
cilium/cilium
api/v1/models/endpoint_policy.go
Validate
func (m *EndpointPolicy) Validate(formats strfmt.Registry) error { var res []error if err := m.validateCidrPolicy(formats); err != nil { res = append(res, err) } if err := m.validateL4(formats); err != nil { res = append(res, err) } if err := m.validatePolicyEnabled(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m *EndpointPolicy) Validate(formats strfmt.Registry) error { var res []error if err := m.validateCidrPolicy(formats); err != nil { res = append(res, err) } if err := m.validateL4(formats); err != nil { res = append(res, err) } if err := m.validatePolicyEnabled(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "*", "EndpointPolicy", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateCidrPolicy", "(", "formats", ")", ";", "err", "!=", ...
// Validate validates this endpoint policy
[ "Validate", "validates", "this", "endpoint", "policy" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/endpoint_policy.go#L47-L66
163,432
cilium/cilium
pkg/node/manager/manager.go
NewManager
func NewManager(name string, datapath datapath.NodeHandler) (*Manager, error) { m := &Manager{ name: name, nodes: map[node.Identity]*nodeEntry{}, datapath: datapath, closeChan: make(chan struct{}), } m.metricEventsReceived = prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: metrics.Namespace, Subsystem: "nodes", Name: name + "_events_received_total", Help: "Number of node events received", }, []string{"eventType", "source"}) m.metricNumNodes = prometheus.NewGauge(prometheus.GaugeOpts{ Namespace: metrics.Namespace, Subsystem: "nodes", Name: name + "_num", Help: "Number of nodes managed", }) m.metricDatapathValidations = prometheus.NewCounter(prometheus.CounterOpts{ Namespace: metrics.Namespace, Subsystem: "nodes", Name: name + "_datapath_validations_total", Help: "Number of validation calls to implement the datapath implemention of a node", }) err := metrics.RegisterList([]prometheus.Collector{m.metricDatapathValidations, m.metricEventsReceived, m.metricNumNodes}) if err != nil { return nil, err } go m.backgroundSync() return m, nil }
go
func NewManager(name string, datapath datapath.NodeHandler) (*Manager, error) { m := &Manager{ name: name, nodes: map[node.Identity]*nodeEntry{}, datapath: datapath, closeChan: make(chan struct{}), } m.metricEventsReceived = prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: metrics.Namespace, Subsystem: "nodes", Name: name + "_events_received_total", Help: "Number of node events received", }, []string{"eventType", "source"}) m.metricNumNodes = prometheus.NewGauge(prometheus.GaugeOpts{ Namespace: metrics.Namespace, Subsystem: "nodes", Name: name + "_num", Help: "Number of nodes managed", }) m.metricDatapathValidations = prometheus.NewCounter(prometheus.CounterOpts{ Namespace: metrics.Namespace, Subsystem: "nodes", Name: name + "_datapath_validations_total", Help: "Number of validation calls to implement the datapath implemention of a node", }) err := metrics.RegisterList([]prometheus.Collector{m.metricDatapathValidations, m.metricEventsReceived, m.metricNumNodes}) if err != nil { return nil, err } go m.backgroundSync() return m, nil }
[ "func", "NewManager", "(", "name", "string", ",", "datapath", "datapath", ".", "NodeHandler", ")", "(", "*", "Manager", ",", "error", ")", "{", "m", ":=", "&", "Manager", "{", "name", ":", "name", ",", "nodes", ":", "map", "[", "node", ".", "Identity...
// NewManager returns a new node manager
[ "NewManager", "returns", "a", "new", "node", "manager" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/manager/manager.go#L94-L131
163,433
cilium/cilium
pkg/node/manager/manager.go
Close
func (m *Manager) Close() { m.mutex.Lock() defer m.mutex.Unlock() close(m.closeChan) metrics.Unregister(m.metricNumNodes) metrics.Unregister(m.metricEventsReceived) metrics.Unregister(m.metricDatapathValidations) // delete all nodes to clean up the datapath for each node for _, n := range m.nodes { n.mutex.Lock() m.datapath.NodeDelete(n.node) n.mutex.Unlock() } }
go
func (m *Manager) Close() { m.mutex.Lock() defer m.mutex.Unlock() close(m.closeChan) metrics.Unregister(m.metricNumNodes) metrics.Unregister(m.metricEventsReceived) metrics.Unregister(m.metricDatapathValidations) // delete all nodes to clean up the datapath for each node for _, n := range m.nodes { n.mutex.Lock() m.datapath.NodeDelete(n.node) n.mutex.Unlock() } }
[ "func", "(", "m", "*", "Manager", ")", "Close", "(", ")", "{", "m", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "close", "(", "m", ".", "closeChan", ")", "\n\n", "metrics", ".", "Unreg...
// Close shuts down a node manager
[ "Close", "shuts", "down", "a", "node", "manager" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/manager/manager.go#L134-L150
163,434
cilium/cilium
pkg/node/manager/manager.go
overwriteAllowed
func overwriteAllowed(oldSource, newSource node.Source) bool { switch newSource { // the local node always takes precedence case node.FromLocalNode: return true // agent local updates can overwrite everything except for the local // node case node.FromAgentLocal: return oldSource != node.FromLocalNode // kvstore updates can overwrite everything except agent local updates and local node case node.FromKVStore: return oldSource != node.FromAgentLocal && oldSource != node.FromLocalNode // kubernetes updates can only overwrite kubernetes nodes case node.FromKubernetes: return oldSource != node.FromAgentLocal && oldSource != node.FromLocalNode && oldSource != node.FromKVStore default: return false } }
go
func overwriteAllowed(oldSource, newSource node.Source) bool { switch newSource { // the local node always takes precedence case node.FromLocalNode: return true // agent local updates can overwrite everything except for the local // node case node.FromAgentLocal: return oldSource != node.FromLocalNode // kvstore updates can overwrite everything except agent local updates and local node case node.FromKVStore: return oldSource != node.FromAgentLocal && oldSource != node.FromLocalNode // kubernetes updates can only overwrite kubernetes nodes case node.FromKubernetes: return oldSource != node.FromAgentLocal && oldSource != node.FromLocalNode && oldSource != node.FromKVStore default: return false } }
[ "func", "overwriteAllowed", "(", "oldSource", ",", "newSource", "node", ".", "Source", ")", "bool", "{", "switch", "newSource", "{", "// the local node always takes precedence", "case", "node", ".", "FromLocalNode", ":", "return", "true", "\n\n", "// agent local updat...
// overwriteAllowed returns true if an update from newSource can overwrite a node owned by oldSource.
[ "overwriteAllowed", "returns", "true", "if", "an", "update", "from", "newSource", "can", "overwrite", "a", "node", "owned", "by", "oldSource", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/manager/manager.go#L231-L253
163,435
cilium/cilium
pkg/node/manager/manager.go
NodeSoftUpdated
func (m *Manager) NodeSoftUpdated(n node.Node) { log.Debugf("Received soft node update event from %s: %#v", n.Source, n) m.nodeUpdated(n, false) }
go
func (m *Manager) NodeSoftUpdated(n node.Node) { log.Debugf("Received soft node update event from %s: %#v", n.Source, n) m.nodeUpdated(n, false) }
[ "func", "(", "m", "*", "Manager", ")", "NodeSoftUpdated", "(", "n", "node", ".", "Node", ")", "{", "log", ".", "Debugf", "(", "\"", "\"", ",", "n", ".", "Source", ",", "n", ")", "\n", "m", ".", "nodeUpdated", "(", "n", ",", "false", ")", "\n", ...
// NodeSoftUpdated is called after the information of a node has be upated but // unlike a NodeUpdated does not require the datapath to be updated.
[ "NodeSoftUpdated", "is", "called", "after", "the", "information", "of", "a", "node", "has", "be", "upated", "but", "unlike", "a", "NodeUpdated", "does", "not", "require", "the", "datapath", "to", "be", "updated", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/manager/manager.go#L257-L260
163,436
cilium/cilium
pkg/node/manager/manager.go
GetNodes
func (m *Manager) GetNodes() map[node.Identity]node.Node { m.mutex.RLock() defer m.mutex.RUnlock() nodes := make(map[node.Identity]node.Node) for nodeIdentity, entry := range m.nodes { entry.mutex.Lock() nodes[nodeIdentity] = entry.node entry.mutex.Unlock() } return nodes }
go
func (m *Manager) GetNodes() map[node.Identity]node.Node { m.mutex.RLock() defer m.mutex.RUnlock() nodes := make(map[node.Identity]node.Node) for nodeIdentity, entry := range m.nodes { entry.mutex.Lock() nodes[nodeIdentity] = entry.node entry.mutex.Unlock() } return nodes }
[ "func", "(", "m", "*", "Manager", ")", "GetNodes", "(", ")", "map", "[", "node", ".", "Identity", "]", "node", ".", "Node", "{", "m", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "m", ".", "mutex", ".", "RUnlock", "(", ")", "\n\n", "nod...
// GetNodes returns a copy of all of the nodes as a map from Identity to Node.
[ "GetNodes", "returns", "a", "copy", "of", "all", "of", "the", "nodes", "as", "a", "map", "from", "Identity", "to", "Node", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/manager/manager.go#L342-L354
163,437
cilium/cilium
pkg/node/manager/manager.go
DeleteAllNodes
func (m *Manager) DeleteAllNodes() { m.mutex.Lock() for _, entry := range m.nodes { entry.mutex.Lock() m.datapath.NodeDelete(entry.node) entry.mutex.Unlock() } m.nodes = map[node.Identity]*nodeEntry{} m.mutex.Unlock() }
go
func (m *Manager) DeleteAllNodes() { m.mutex.Lock() for _, entry := range m.nodes { entry.mutex.Lock() m.datapath.NodeDelete(entry.node) entry.mutex.Unlock() } m.nodes = map[node.Identity]*nodeEntry{} m.mutex.Unlock() }
[ "func", "(", "m", "*", "Manager", ")", "DeleteAllNodes", "(", ")", "{", "m", ".", "mutex", ".", "Lock", "(", ")", "\n", "for", "_", ",", "entry", ":=", "range", "m", ".", "nodes", "{", "entry", ".", "mutex", ".", "Lock", "(", ")", "\n", "m", ...
// DeleteAllNodes deletes all nodes from the node maanger.
[ "DeleteAllNodes", "deletes", "all", "nodes", "from", "the", "node", "maanger", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/manager/manager.go#L357-L366
163,438
cilium/cilium
pkg/k8s/rule_translate.go
Translate
func (k RuleTranslator) Translate(r *api.Rule, result *policy.TranslationResult) error { for egressIndex := range r.Egress { err := k.TranslateEgress(&r.Egress[egressIndex], result) if err != nil { return err } } return nil }
go
func (k RuleTranslator) Translate(r *api.Rule, result *policy.TranslationResult) error { for egressIndex := range r.Egress { err := k.TranslateEgress(&r.Egress[egressIndex], result) if err != nil { return err } } return nil }
[ "func", "(", "k", "RuleTranslator", ")", "Translate", "(", "r", "*", "api", ".", "Rule", ",", "result", "*", "policy", ".", "TranslationResult", ")", "error", "{", "for", "egressIndex", ":=", "range", "r", ".", "Egress", "{", "err", ":=", "k", ".", "...
// Translate calls TranslateEgress on all r.Egress rules
[ "Translate", "calls", "TranslateEgress", "on", "all", "r", ".", "Egress", "rules" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/rule_translate.go#L42-L50
163,439
cilium/cilium
pkg/k8s/rule_translate.go
generateToCidrFromEndpoint
func generateToCidrFromEndpoint( egress *api.EgressRule, endpoint Endpoints, impl ipcache.Implementation) error { // Non-nil implementation here implies that this translation is // occurring after policy import. This means that the CIDRs were not // known at that time, so the IPCache hasn't been informed about them. // In this case, it's the job of this Translator to notify the IPCache. if impl != nil { prefixes, err := endpoint.CIDRPrefixes() if err != nil { return err } if err := ipcache.AllocateCIDRs(impl, prefixes); err != nil { return err } } // This will generate one-address CIDRs consisting of endpoint backend ip mask := net.CIDRMask(128, 128) for ip := range endpoint.Backends { epIP := net.ParseIP(ip) if epIP == nil { return fmt.Errorf("Unable to parse ip: %s", ip) } found := false for _, c := range egress.ToCIDRSet { _, cidr, err := net.ParseCIDR(string(c.Cidr)) if err != nil { return err } if cidr.Contains(epIP) { found = true break } } if !found { cidr := net.IPNet{IP: epIP.Mask(mask), Mask: mask} egress.ToCIDRSet = append(egress.ToCIDRSet, api.CIDRRule{ Cidr: api.CIDR(cidr.String()), Generated: true, }) } } return nil }
go
func generateToCidrFromEndpoint( egress *api.EgressRule, endpoint Endpoints, impl ipcache.Implementation) error { // Non-nil implementation here implies that this translation is // occurring after policy import. This means that the CIDRs were not // known at that time, so the IPCache hasn't been informed about them. // In this case, it's the job of this Translator to notify the IPCache. if impl != nil { prefixes, err := endpoint.CIDRPrefixes() if err != nil { return err } if err := ipcache.AllocateCIDRs(impl, prefixes); err != nil { return err } } // This will generate one-address CIDRs consisting of endpoint backend ip mask := net.CIDRMask(128, 128) for ip := range endpoint.Backends { epIP := net.ParseIP(ip) if epIP == nil { return fmt.Errorf("Unable to parse ip: %s", ip) } found := false for _, c := range egress.ToCIDRSet { _, cidr, err := net.ParseCIDR(string(c.Cidr)) if err != nil { return err } if cidr.Contains(epIP) { found = true break } } if !found { cidr := net.IPNet{IP: epIP.Mask(mask), Mask: mask} egress.ToCIDRSet = append(egress.ToCIDRSet, api.CIDRRule{ Cidr: api.CIDR(cidr.String()), Generated: true, }) } } return nil }
[ "func", "generateToCidrFromEndpoint", "(", "egress", "*", "api", ".", "EgressRule", ",", "endpoint", "Endpoints", ",", "impl", "ipcache", ".", "Implementation", ")", "error", "{", "// Non-nil implementation here implies that this translation is", "// occurring after policy im...
// generateToCidrFromEndpoint takes an egress rule and populates it with // ToCIDR rules based on provided endpoint object
[ "generateToCidrFromEndpoint", "takes", "an", "egress", "rule", "and", "populates", "it", "with", "ToCIDR", "rules", "based", "on", "provided", "endpoint", "object" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/rule_translate.go#L116-L163
163,440
cilium/cilium
pkg/k8s/rule_translate.go
PreprocessRules
func PreprocessRules(r api.Rules, cache *ServiceCache) error { // Headless services are translated prior to policy import, so the // policy will contain all of the CIDRs and can handle ipcache // interactions when the policy is imported. Ignore the IPCache // interaction here and just set the implementation to nil. ipcache := ipcache.Implementation(nil) cache.mutex.Lock() defer cache.mutex.Unlock() for _, rule := range r { for ns, ep := range cache.endpoints { svc, ok := cache.services[ns] if ok && svc.IsExternal() { t := NewK8sTranslator(ns, *ep, false, svc.Labels, ipcache) err := t.Translate(rule, &policy.TranslationResult{}) if err != nil { return err } } } } return nil }
go
func PreprocessRules(r api.Rules, cache *ServiceCache) error { // Headless services are translated prior to policy import, so the // policy will contain all of the CIDRs and can handle ipcache // interactions when the policy is imported. Ignore the IPCache // interaction here and just set the implementation to nil. ipcache := ipcache.Implementation(nil) cache.mutex.Lock() defer cache.mutex.Unlock() for _, rule := range r { for ns, ep := range cache.endpoints { svc, ok := cache.services[ns] if ok && svc.IsExternal() { t := NewK8sTranslator(ns, *ep, false, svc.Labels, ipcache) err := t.Translate(rule, &policy.TranslationResult{}) if err != nil { return err } } } } return nil }
[ "func", "PreprocessRules", "(", "r", "api", ".", "Rules", ",", "cache", "*", "ServiceCache", ")", "error", "{", "// Headless services are translated prior to policy import, so the", "// policy will contain all of the CIDRs and can handle ipcache", "// interactions when the policy is ...
// PreprocessRules translates rules that apply to headless services
[ "PreprocessRules", "translates", "rules", "that", "apply", "to", "headless", "services" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/rule_translate.go#L212-L236
163,441
cilium/cilium
pkg/k8s/rule_translate.go
NewK8sTranslator
func NewK8sTranslator( serviceInfo ServiceID, endpoint Endpoints, revert bool, labels map[string]string, ipcache ipcache.Implementation) RuleTranslator { return RuleTranslator{serviceInfo, endpoint, labels, revert, ipcache} }
go
func NewK8sTranslator( serviceInfo ServiceID, endpoint Endpoints, revert bool, labels map[string]string, ipcache ipcache.Implementation) RuleTranslator { return RuleTranslator{serviceInfo, endpoint, labels, revert, ipcache} }
[ "func", "NewK8sTranslator", "(", "serviceInfo", "ServiceID", ",", "endpoint", "Endpoints", ",", "revert", "bool", ",", "labels", "map", "[", "string", "]", "string", ",", "ipcache", "ipcache", ".", "Implementation", ")", "RuleTranslator", "{", "return", "RuleTra...
// NewK8sTranslator returns RuleTranslator
[ "NewK8sTranslator", "returns", "RuleTranslator" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/rule_translate.go#L239-L247
163,442
cilium/cilium
pkg/safetime/safetime.go
TimeSinceSafe
func TimeSinceSafe(t time.Time, logger *log.Entry) (time.Duration, bool) { n := time.Now() d := n.Sub(t) if d < 0 { logger = logger.WithFields(log.Fields{ logfields.StartTime: t, logfields.EndTime: n, logfields.Duration: d, }) _, file, line, ok := runtime.Caller(1) if ok { logger = logger.WithFields(log.Fields{ logfields.Path: file, logfields.Line: line, }) } logger.Warn("BUG: negative duration") return time.Duration(0), false } return d, true }
go
func TimeSinceSafe(t time.Time, logger *log.Entry) (time.Duration, bool) { n := time.Now() d := n.Sub(t) if d < 0 { logger = logger.WithFields(log.Fields{ logfields.StartTime: t, logfields.EndTime: n, logfields.Duration: d, }) _, file, line, ok := runtime.Caller(1) if ok { logger = logger.WithFields(log.Fields{ logfields.Path: file, logfields.Line: line, }) } logger.Warn("BUG: negative duration") return time.Duration(0), false } return d, true }
[ "func", "TimeSinceSafe", "(", "t", "time", ".", "Time", ",", "logger", "*", "log", ".", "Entry", ")", "(", "time", ".", "Duration", ",", "bool", ")", "{", "n", ":=", "time", ".", "Now", "(", ")", "\n", "d", ":=", "n", ".", "Sub", "(", "t", ")...
// TimeSinceSafe returns the duration since t. If the duration is negative, // returns false to indicate the fact. // // Used to workaround a malfunctioning monotonic clock.
[ "TimeSinceSafe", "returns", "the", "duration", "since", "t", ".", "If", "the", "duration", "is", "negative", "returns", "false", "to", "indicate", "the", "fact", ".", "Used", "to", "workaround", "a", "malfunctioning", "monotonic", "clock", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/safetime/safetime.go#L30-L53
163,443
cilium/cilium
api/v1/models/request_response_statistics.go
Validate
func (m *RequestResponseStatistics) Validate(formats strfmt.Registry) error { var res []error if err := m.validateRequests(formats); err != nil { res = append(res, err) } if err := m.validateResponses(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m *RequestResponseStatistics) Validate(formats strfmt.Registry) error { var res []error if err := m.validateRequests(formats); err != nil { res = append(res, err) } if err := m.validateResponses(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "*", "RequestResponseStatistics", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateRequests", "(", "formats", ")", ";", "err", ...
// Validate validates this request response statistics
[ "Validate", "validates", "this", "request", "response", "statistics" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/request_response_statistics.go#L28-L43
163,444
cilium/cilium
api/v1/models/port.go
Validate
func (m *Port) Validate(formats strfmt.Registry) error { var res []error if err := m.validateProtocol(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m *Port) Validate(formats strfmt.Registry) error { var res []error if err := m.validateProtocol(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "*", "Port", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateProtocol", "(", "formats", ")", ";", "err", "!=", "nil", "{...
// Validate validates this port
[ "Validate", "validates", "this", "port" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/port.go#L31-L42
163,445
cilium/cilium
api/v1/models/controller_statuses.go
Validate
func (m ControllerStatuses) Validate(formats strfmt.Registry) error { var res []error for i := 0; i < len(m); i++ { if swag.IsZero(m[i]) { // not required continue } if m[i] != nil { if err := m[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName(strconv.Itoa(i)) } return err } } } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m ControllerStatuses) Validate(formats strfmt.Registry) error { var res []error for i := 0; i < len(m); i++ { if swag.IsZero(m[i]) { // not required continue } if m[i] != nil { if err := m[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName(strconv.Itoa(i)) } return err } } } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "ControllerStatuses", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "m", ")", ";", "i", "++", "{", "if",...
// Validate validates this controller statuses
[ "Validate", "validates", "this", "controller", "statuses" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/controller_statuses.go#L22-L45
163,446
cilium/cilium
daemon/daemon_main.go
RestoreExecPermissions
func RestoreExecPermissions(searchDir string, patterns ...string) error { fileList := []string{} err := filepath.Walk(searchDir, func(path string, f os.FileInfo, err error) error { for _, pattern := range patterns { if regexp.MustCompile(pattern).MatchString(f.Name()) { fileList = append(fileList, path) break } } return nil }) for _, fileToChange := range fileList { // Changing files permissions to -rwx:r--:---, we are only // adding executable permission to the owner and keeping the // same permissions stored by go-bindata. if err := os.Chmod(fileToChange, os.FileMode(0740)); err != nil { return err } } return err }
go
func RestoreExecPermissions(searchDir string, patterns ...string) error { fileList := []string{} err := filepath.Walk(searchDir, func(path string, f os.FileInfo, err error) error { for _, pattern := range patterns { if regexp.MustCompile(pattern).MatchString(f.Name()) { fileList = append(fileList, path) break } } return nil }) for _, fileToChange := range fileList { // Changing files permissions to -rwx:r--:---, we are only // adding executable permission to the owner and keeping the // same permissions stored by go-bindata. if err := os.Chmod(fileToChange, os.FileMode(0740)); err != nil { return err } } return err }
[ "func", "RestoreExecPermissions", "(", "searchDir", "string", ",", "patterns", "...", "string", ")", "error", "{", "fileList", ":=", "[", "]", "string", "{", "}", "\n", "err", ":=", "filepath", ".", "Walk", "(", "searchDir", ",", "func", "(", "path", "st...
// RestoreExecPermissions restores file permissions to 0740 of all files inside // `searchDir` with the given regex `patterns`.
[ "RestoreExecPermissions", "restores", "file", "permissions", "to", "0740", "of", "all", "files", "inside", "searchDir", "with", "the", "given", "regex", "patterns", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/daemon_main.go#L736-L756
163,447
cilium/cilium
daemon/daemon_main.go
waitForHostDeviceWhenReady
func waitForHostDeviceWhenReady(ifaceName string) error { for i := 0; ; i++ { if i%10 == 0 { log.WithField(logfields.Interface, ifaceName). Info("Waiting for the underlying interface to be initialized with containers") } _, err := netlink.LinkByName(ifaceName) if err == nil { log.WithField(logfields.Interface, ifaceName). Info("Underlying interface initialized with containers!") break } select { case <-cleanUPSig: return errors.New("clean up signal triggered") default: time.Sleep(time.Second) } } return nil }
go
func waitForHostDeviceWhenReady(ifaceName string) error { for i := 0; ; i++ { if i%10 == 0 { log.WithField(logfields.Interface, ifaceName). Info("Waiting for the underlying interface to be initialized with containers") } _, err := netlink.LinkByName(ifaceName) if err == nil { log.WithField(logfields.Interface, ifaceName). Info("Underlying interface initialized with containers!") break } select { case <-cleanUPSig: return errors.New("clean up signal triggered") default: time.Sleep(time.Second) } } return nil }
[ "func", "waitForHostDeviceWhenReady", "(", "ifaceName", "string", ")", "error", "{", "for", "i", ":=", "0", ";", ";", "i", "++", "{", "if", "i", "%", "10", "==", "0", "{", "log", ".", "WithField", "(", "logfields", ".", "Interface", ",", "ifaceName", ...
// waitForHostDeviceWhenReady waits the given ifaceName to be up and ready. If // ifaceName is not found, then it will wait forever until the device is // created.
[ "waitForHostDeviceWhenReady", "waits", "the", "given", "ifaceName", "to", "be", "up", "and", "ready", ".", "If", "ifaceName", "is", "not", "found", "then", "it", "will", "wait", "forever", "until", "the", "device", "is", "created", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/daemon_main.go#L1106-L1126
163,448
cilium/cilium
proxylib/cassandra/cassandraparser.go
CassandraRuleParser
func CassandraRuleParser(rule *cilium.PortNetworkPolicyRule) []L7NetworkPolicyRule { var rules []L7NetworkPolicyRule l7Rules := rule.GetL7Rules() if l7Rules == nil { return rules } for _, l7Rule := range l7Rules.GetL7Rules() { var cr CassandraRule for k, v := range l7Rule.Rule { switch k { case "query_action": cr.queryActionExact = v case "query_table": if v != "" { cr.tableRegexCompiled = regexp.MustCompile(v) } default: ParseError(fmt.Sprintf("Unsupported key: %s", k), rule) } } if len(cr.queryActionExact) > 0 { // ensure this is a valid query action res := queryActionMap[cr.queryActionExact] if res == invalidAction { ParseError(fmt.Sprintf("Unable to parse L7 cassandra rule with invalid query_action: '%s'", cr.queryActionExact), rule) } else if res == actionNoTable && cr.tableRegexCompiled != nil { ParseError(fmt.Sprintf("query_action '%s' is not compatible with a query_table match", cr.queryActionExact), rule) } } log.Debugf("Parsed CassandraRule pair: %v", cr) rules = append(rules, &cr) } return rules }
go
func CassandraRuleParser(rule *cilium.PortNetworkPolicyRule) []L7NetworkPolicyRule { var rules []L7NetworkPolicyRule l7Rules := rule.GetL7Rules() if l7Rules == nil { return rules } for _, l7Rule := range l7Rules.GetL7Rules() { var cr CassandraRule for k, v := range l7Rule.Rule { switch k { case "query_action": cr.queryActionExact = v case "query_table": if v != "" { cr.tableRegexCompiled = regexp.MustCompile(v) } default: ParseError(fmt.Sprintf("Unsupported key: %s", k), rule) } } if len(cr.queryActionExact) > 0 { // ensure this is a valid query action res := queryActionMap[cr.queryActionExact] if res == invalidAction { ParseError(fmt.Sprintf("Unable to parse L7 cassandra rule with invalid query_action: '%s'", cr.queryActionExact), rule) } else if res == actionNoTable && cr.tableRegexCompiled != nil { ParseError(fmt.Sprintf("query_action '%s' is not compatible with a query_table match", cr.queryActionExact), rule) } } log.Debugf("Parsed CassandraRule pair: %v", cr) rules = append(rules, &cr) } return rules }
[ "func", "CassandraRuleParser", "(", "rule", "*", "cilium", ".", "PortNetworkPolicyRule", ")", "[", "]", "L7NetworkPolicyRule", "{", "var", "rules", "[", "]", "L7NetworkPolicyRule", "\n", "l7Rules", ":=", "rule", ".", "GetL7Rules", "(", ")", "\n", "if", "l7Rule...
// CassandraRuleParser parses protobuf L7 rules to enforcement objects // May panic
[ "CassandraRuleParser", "parses", "protobuf", "L7", "rules", "to", "enforcement", "objects", "May", "panic" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/proxylib/cassandra/cassandraparser.go#L108-L143
163,449
cilium/cilium
proxylib/cassandra/cassandraparser.go
cassandraParseReply
func cassandraParseReply(p *CassandraParser, data []byte) { direction := data[0] & 0x80 // top bit if direction != 0x80 { log.Errorf("Direction bit is 'request', but we are trying to parse a reply") return } compressionFlag := data[1] & 0x01 if compressionFlag == 1 { log.Errorf("Compression flag set, unable to parse reply beyond the header") return } streamID := binary.BigEndian.Uint16(data[2:4]) log.Debugf("Reply with opcode %d and stream-id %d", data[4], streamID) // if this is an opcode == RESULT message of type 'prepared', associate the prepared // statement id with the full query string that was included in the // associated PREPARE request. The stream-id in this reply allows us to // find the associated prepare query string. if data[4] == 0x08 { resultKind := binary.BigEndian.Uint32(data[9:13]) log.Debugf("resultKind = %d", resultKind) if resultKind == 0x0004 { idLen := binary.BigEndian.Uint16(data[13:15]) preparedID := string(data[15 : 15+idLen]) log.Debugf("Result with prepared-id = '%s' for stream-id %d", preparedID, streamID) path := p.preparedQueryPathByStreamID[streamID] if len(path) > 0 { // found cached query path to associate with this preparedID p.preparedQueryPathByPreparedID[preparedID] = path log.Debugf("Associating query path '%s' with prepared-id %s as part of stream-id %d", path, preparedID, streamID) } else { log.Warnf("Unable to find prepared query path associated with stream-id %d", streamID) } } } }
go
func cassandraParseReply(p *CassandraParser, data []byte) { direction := data[0] & 0x80 // top bit if direction != 0x80 { log.Errorf("Direction bit is 'request', but we are trying to parse a reply") return } compressionFlag := data[1] & 0x01 if compressionFlag == 1 { log.Errorf("Compression flag set, unable to parse reply beyond the header") return } streamID := binary.BigEndian.Uint16(data[2:4]) log.Debugf("Reply with opcode %d and stream-id %d", data[4], streamID) // if this is an opcode == RESULT message of type 'prepared', associate the prepared // statement id with the full query string that was included in the // associated PREPARE request. The stream-id in this reply allows us to // find the associated prepare query string. if data[4] == 0x08 { resultKind := binary.BigEndian.Uint32(data[9:13]) log.Debugf("resultKind = %d", resultKind) if resultKind == 0x0004 { idLen := binary.BigEndian.Uint16(data[13:15]) preparedID := string(data[15 : 15+idLen]) log.Debugf("Result with prepared-id = '%s' for stream-id %d", preparedID, streamID) path := p.preparedQueryPathByStreamID[streamID] if len(path) > 0 { // found cached query path to associate with this preparedID p.preparedQueryPathByPreparedID[preparedID] = path log.Debugf("Associating query path '%s' with prepared-id %s as part of stream-id %d", path, preparedID, streamID) } else { log.Warnf("Unable to find prepared query path associated with stream-id %d", streamID) } } } }
[ "func", "cassandraParseReply", "(", "p", "*", "CassandraParser", ",", "data", "[", "]", "byte", ")", "{", "direction", ":=", "data", "[", "0", "]", "&", "0x80", "// top bit", "\n", "if", "direction", "!=", "0x80", "{", "log", ".", "Errorf", "(", "\"", ...
// reply parsing is very basic, just focusing on parsing RESULT messages that // contain prepared query IDs so that we can later enforce policy on "execute" requests.
[ "reply", "parsing", "is", "very", "basic", "just", "focusing", "on", "parsing", "RESULT", "messages", "that", "contain", "prepared", "query", "IDs", "so", "that", "we", "can", "later", "enforce", "policy", "on", "execute", "requests", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/proxylib/cassandra/cassandraparser.go#L676-L713
163,450
cilium/cilium
pkg/policy/distillery/distillery.go
lookupOrCreate
func (cache *policyCache) lookupOrCreate(identity *identityPkg.Identity, create bool) (SelectorPolicy, bool) { cache.Lock() defer cache.Unlock() cip, ok := cache.policies[identity.ID] if create && !ok { cip = newCachedSelectorPolicy(identity) cache.policies[identity.ID] = cip } computed := false if cip != nil { computed = cip.getPolicy().Revision > 0 } return cip, computed }
go
func (cache *policyCache) lookupOrCreate(identity *identityPkg.Identity, create bool) (SelectorPolicy, bool) { cache.Lock() defer cache.Unlock() cip, ok := cache.policies[identity.ID] if create && !ok { cip = newCachedSelectorPolicy(identity) cache.policies[identity.ID] = cip } computed := false if cip != nil { computed = cip.getPolicy().Revision > 0 } return cip, computed }
[ "func", "(", "cache", "*", "policyCache", ")", "lookupOrCreate", "(", "identity", "*", "identityPkg", ".", "Identity", ",", "create", "bool", ")", "(", "SelectorPolicy", ",", "bool", ")", "{", "cache", ".", "Lock", "(", ")", "\n", "defer", "cache", ".", ...
// lookupOrCreate adds the specified Identity to the policy cache, with a reference // from the specified Endpoint, then returns the threadsafe copy of the policy // and whether policy has been computed for this identity.
[ "lookupOrCreate", "adds", "the", "specified", "Identity", "to", "the", "policy", "cache", "with", "a", "reference", "from", "the", "specified", "Endpoint", "then", "returns", "the", "threadsafe", "copy", "of", "the", "policy", "and", "whether", "policy", "has", ...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/distillery/distillery.go#L61-L75
163,451
cilium/cilium
pkg/policy/distillery/distillery.go
insert
func (cache *policyCache) insert(identity *identityPkg.Identity) (SelectorPolicy, bool) { return cache.lookupOrCreate(identity, true) }
go
func (cache *policyCache) insert(identity *identityPkg.Identity) (SelectorPolicy, bool) { return cache.lookupOrCreate(identity, true) }
[ "func", "(", "cache", "*", "policyCache", ")", "insert", "(", "identity", "*", "identityPkg", ".", "Identity", ")", "(", "SelectorPolicy", ",", "bool", ")", "{", "return", "cache", ".", "lookupOrCreate", "(", "identity", ",", "true", ")", "\n", "}" ]
// insert adds the specified Identity to the policy cache, with a reference // from the specified Endpoint, then returns the threadsafe copy of the policy // and whether policy has been computed for this identity.
[ "insert", "adds", "the", "specified", "Identity", "to", "the", "policy", "cache", "with", "a", "reference", "from", "the", "specified", "Endpoint", "then", "returns", "the", "threadsafe", "copy", "of", "the", "policy", "and", "whether", "policy", "has", "been"...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/distillery/distillery.go#L80-L82
163,452
cilium/cilium
pkg/policy/distillery/distillery.go
delete
func (cache *policyCache) delete(identity *identityPkg.Identity) bool { cache.Lock() defer cache.Unlock() _, ok := cache.policies[identity.ID] if ok { delete(cache.policies, identity.ID) } return ok }
go
func (cache *policyCache) delete(identity *identityPkg.Identity) bool { cache.Lock() defer cache.Unlock() _, ok := cache.policies[identity.ID] if ok { delete(cache.policies, identity.ID) } return ok }
[ "func", "(", "cache", "*", "policyCache", ")", "delete", "(", "identity", "*", "identityPkg", ".", "Identity", ")", "bool", "{", "cache", ".", "Lock", "(", ")", "\n", "defer", "cache", ".", "Unlock", "(", ")", "\n", "_", ",", "ok", ":=", "cache", "...
// delete forgets about any cached SelectorPolicy that this endpoint uses. // // Returns true if the SelectorPolicy was removed from the cache.
[ "delete", "forgets", "about", "any", "cached", "SelectorPolicy", "that", "this", "endpoint", "uses", ".", "Returns", "true", "if", "the", "SelectorPolicy", "was", "removed", "from", "the", "cache", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/distillery/distillery.go#L87-L95
163,453
cilium/cilium
pkg/policy/distillery/distillery.go
updateSelectorPolicy
func (cache *policyCache) updateSelectorPolicy(repo PolicyRepository, identity *identityPkg.Identity) (bool, error) { revision := repo.GetRevision() cache.Lock() cip, ok := cache.policies[identity.ID] cache.Unlock() if !ok { return false, fmt.Errorf("SelectorPolicy not found in cache for ID %d", identity.ID) } // Don't resolve policy if it was already done for this Identity. currentRevision := cip.getPolicy().Revision if revision <= currentRevision { return false, nil } // Resolve the policies, which could fail identityPolicy, err := repo.ResolvePolicyLocked(identity) if err != nil { return false, err } // We don't cover the ResolvePolicyLocked() call above with the cache // Mutex because it's potentially expensive, and endpoints with // different identities should be able to concurrently compute policy. // // However, as long as UpdatePolicy() is triggered from endpoint // regeneration, it's possible for two endpoints with the *same* // identity to race to the revision check above, both find that the // policy is out-of-date, and resolve the policy then race down to // here. Set the pointer to the latest revision in both cases. // // Note that because repo.Mutex is held, the two racing threads will be // guaranteed to compute policy for the same revision of the policy. // We could save some CPU by, for example, forcing resolution of policy // for the same identity to block on a channel/lock, but this is // skipped for now as there are upcoming changes to the cache update // logic which would render such mechanisms obsolete. changed := revision > currentRevision if changed { cip.setPolicy(identityPolicy) } return changed, nil }
go
func (cache *policyCache) updateSelectorPolicy(repo PolicyRepository, identity *identityPkg.Identity) (bool, error) { revision := repo.GetRevision() cache.Lock() cip, ok := cache.policies[identity.ID] cache.Unlock() if !ok { return false, fmt.Errorf("SelectorPolicy not found in cache for ID %d", identity.ID) } // Don't resolve policy if it was already done for this Identity. currentRevision := cip.getPolicy().Revision if revision <= currentRevision { return false, nil } // Resolve the policies, which could fail identityPolicy, err := repo.ResolvePolicyLocked(identity) if err != nil { return false, err } // We don't cover the ResolvePolicyLocked() call above with the cache // Mutex because it's potentially expensive, and endpoints with // different identities should be able to concurrently compute policy. // // However, as long as UpdatePolicy() is triggered from endpoint // regeneration, it's possible for two endpoints with the *same* // identity to race to the revision check above, both find that the // policy is out-of-date, and resolve the policy then race down to // here. Set the pointer to the latest revision in both cases. // // Note that because repo.Mutex is held, the two racing threads will be // guaranteed to compute policy for the same revision of the policy. // We could save some CPU by, for example, forcing resolution of policy // for the same identity to block on a channel/lock, but this is // skipped for now as there are upcoming changes to the cache update // logic which would render such mechanisms obsolete. changed := revision > currentRevision if changed { cip.setPolicy(identityPolicy) } return changed, nil }
[ "func", "(", "cache", "*", "policyCache", ")", "updateSelectorPolicy", "(", "repo", "PolicyRepository", ",", "identity", "*", "identityPkg", ".", "Identity", ")", "(", "bool", ",", "error", ")", "{", "revision", ":=", "repo", ".", "GetRevision", "(", ")", ...
// updateSelectorPolicy resolves the policy for the security identity of the // specified endpoint and stores it internally. It will skip policy resolution // if the cached policy is already at the revision specified in the repo. // // Returns whether the cache was updated, or an error. // // Must be called with repo.Mutex held for reading.
[ "updateSelectorPolicy", "resolves", "the", "policy", "for", "the", "security", "identity", "of", "the", "specified", "endpoint", "and", "stores", "it", "internally", ".", "It", "will", "skip", "policy", "resolution", "if", "the", "cached", "policy", "is", "alrea...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/distillery/distillery.go#L104-L147
163,454
cilium/cilium
pkg/policy/distillery/distillery.go
Lookup
func Lookup(identity *identityPkg.Identity) SelectorPolicy { cip, _ := globalPolicyCache.lookupOrCreate(identity, false) return cip }
go
func Lookup(identity *identityPkg.Identity) SelectorPolicy { cip, _ := globalPolicyCache.lookupOrCreate(identity, false) return cip }
[ "func", "Lookup", "(", "identity", "*", "identityPkg", ".", "Identity", ")", "SelectorPolicy", "{", "cip", ",", "_", ":=", "globalPolicyCache", ".", "lookupOrCreate", "(", "identity", ",", "false", ")", "\n", "return", "cip", "\n", "}" ]
// Lookup attempts to locate the SelectorPolicy corresponding to the specified // identity. If policy is not cached for the identity, it returns nil.
[ "Lookup", "attempts", "to", "locate", "the", "SelectorPolicy", "corresponding", "to", "the", "specified", "identity", ".", "If", "policy", "is", "not", "cached", "for", "the", "identity", "it", "returns", "nil", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/distillery/distillery.go#L163-L166
163,455
cilium/cilium
pkg/policy/distillery/distillery.go
UpdatePolicy
func UpdatePolicy(repo PolicyRepository, identity *identityPkg.Identity) error { _, err := globalPolicyCache.updateSelectorPolicy(repo, identity) return err }
go
func UpdatePolicy(repo PolicyRepository, identity *identityPkg.Identity) error { _, err := globalPolicyCache.updateSelectorPolicy(repo, identity) return err }
[ "func", "UpdatePolicy", "(", "repo", "PolicyRepository", ",", "identity", "*", "identityPkg", ".", "Identity", ")", "error", "{", "_", ",", "err", ":=", "globalPolicyCache", ".", "updateSelectorPolicy", "(", "repo", ",", "identity", ")", "\n", "return", "err",...
// UpdatePolicy resolves the policy for the security identity of the specified // endpoint and caches it for future use. // // The caller must provide threadsafety for iteration over the provided policy // repository.
[ "UpdatePolicy", "resolves", "the", "policy", "for", "the", "security", "identity", "of", "the", "specified", "endpoint", "and", "caches", "it", "for", "future", "use", ".", "The", "caller", "must", "provide", "threadsafety", "for", "iteration", "over", "the", ...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/distillery/distillery.go#L180-L183
163,456
cilium/cilium
pkg/checker/checker.go
Check
func (checker *diffChecker) Check(params []interface{}, names []string) (result bool, error string) { if len(params) != 2 || len(names) != 2 { return false, "params and names must be of length 2" } if reflect.DeepEqual(params[0], params[1]) { return true, "" } return false, comparator.CompareWithNames(params[0], params[1], names[0], names[1]) }
go
func (checker *diffChecker) Check(params []interface{}, names []string) (result bool, error string) { if len(params) != 2 || len(names) != 2 { return false, "params and names must be of length 2" } if reflect.DeepEqual(params[0], params[1]) { return true, "" } return false, comparator.CompareWithNames(params[0], params[1], names[0], names[1]) }
[ "func", "(", "checker", "*", "diffChecker", ")", "Check", "(", "params", "[", "]", "interface", "{", "}", ",", "names", "[", "]", "string", ")", "(", "result", "bool", ",", "error", "string", ")", "{", "if", "len", "(", "params", ")", "!=", "2", ...
// Check performs a diff between two objects provided as parameters, and // returns either true if the objects are identical, or false otherwise. If // it returns false, it also returns the unified diff between the expected // and obtained output.
[ "Check", "performs", "a", "diff", "between", "two", "objects", "provided", "as", "parameters", "and", "returns", "either", "true", "if", "the", "objects", "are", "identical", "or", "false", "otherwise", ".", "If", "it", "returns", "false", "it", "also", "ret...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/checker/checker.go#L43-L53
163,457
cilium/cilium
pkg/k8s/cnp.go
getUpdatedCNPFromStore
func (c *CNPStatusUpdateContext) getUpdatedCNPFromStore(cnp *types.SlimCNP) (*types.SlimCNP, error) { serverRuleStore, exists, err := c.CiliumV2Store.Get(cnp) if err != nil { return nil, fmt.Errorf("unable to find v2.CiliumNetworkPolicy in local cache: %s", err) } if !exists { return nil, errors.New("v2.CiliumNetworkPolicy does not exist in local cache") } serverRule, ok := serverRuleStore.(*types.SlimCNP) if !ok { return nil, errors.New("Received object of unknown type from API server, expecting v2.CiliumNetworkPolicy") } return serverRule, nil }
go
func (c *CNPStatusUpdateContext) getUpdatedCNPFromStore(cnp *types.SlimCNP) (*types.SlimCNP, error) { serverRuleStore, exists, err := c.CiliumV2Store.Get(cnp) if err != nil { return nil, fmt.Errorf("unable to find v2.CiliumNetworkPolicy in local cache: %s", err) } if !exists { return nil, errors.New("v2.CiliumNetworkPolicy does not exist in local cache") } serverRule, ok := serverRuleStore.(*types.SlimCNP) if !ok { return nil, errors.New("Received object of unknown type from API server, expecting v2.CiliumNetworkPolicy") } return serverRule, nil }
[ "func", "(", "c", "*", "CNPStatusUpdateContext", ")", "getUpdatedCNPFromStore", "(", "cnp", "*", "types", ".", "SlimCNP", ")", "(", "*", "types", ".", "SlimCNP", ",", "error", ")", "{", "serverRuleStore", ",", "exists", ",", "err", ":=", "c", ".", "Ciliu...
// getUpdatedCNPFromStore gets the most recent version of cnp from the store // ciliumV2Store, which is updated by the Kubernetes watcher. This reduces // the possibility of Cilium trying to update cnp in Kubernetes which has // been updated between the time the watcher in this Cilium instance has // received cnp, and when this function is called. This still may occur, though // and users of the returned CiliumNetworkPolicy may not be able to update // the cnp because it may become out-of-date. Returns an error if the CNP cannot // be retrieved from the store, or the object retrieved from the store is not of // the expected type.
[ "getUpdatedCNPFromStore", "gets", "the", "most", "recent", "version", "of", "cnp", "from", "the", "store", "ciliumV2Store", "which", "is", "updated", "by", "the", "Kubernetes", "watcher", ".", "This", "reduces", "the", "possibility", "of", "Cilium", "trying", "t...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/cnp.go#L94-L109
163,458
cilium/cilium
pkg/k8s/cnp.go
UpdateStatus
func (c *CNPStatusUpdateContext) UpdateStatus(ctx context.Context, cnp *types.SlimCNP, rev uint64, policyImportErr error) error { var ( err error serverRule *types.SlimCNP // The following is an example distribution with jitter applied: // // nodes 4 16 128 512 1024 2048 // 1: 2.6s 5.5s 8.1s 9s 9.9s 12.9s // 2: 1.9s 4.2s 6.3s 11.9s 17.6s 26.2s // 3: 4s 10.4s 15.7s 26.7s 20.7s 23.3s // 4: 18s 12.1s 19.7s 40s 1m6.3s 1m46.3s // 5: 16.2s 28.9s 1m58.2s 46.2s 2m0s 2m0s // 6: 54.7s 7.9s 53.3s 2m0s 2m0s 45.8s // 7: 1m55.5s 22.8s 2m0s 2m0s 2m0s 2m0s // 8: 1m45.8s 1m36.7s 2m0s 2m0s 2m0s 2m0s cnpBackoff = backoff.Exponential{ Min: time.Second, NodeManager: c.NodeManager, Jitter: true, } scopedLog = log.WithFields(logrus.Fields{ logfields.CiliumNetworkPolicyName: cnp.ObjectMeta.Name, logfields.K8sAPIVersion: cnp.TypeMeta.APIVersion, logfields.K8sNamespace: cnp.ObjectMeta.Namespace, }) ) ctxEndpointWait, cancel := context.WithTimeout(ctx, 30*time.Second) defer cancel() waitForEPsErr := c.WaitForEndpointsAtPolicyRev(ctxEndpointWait, rev) numAttempts := 0 retryLoop: for { numAttempts++ select { case <-ctx.Done(): // The owning controller wants us to stop, no error is // returned. This is graceful err = fmt.Errorf("status update cancelled via context: %s", ctx.Err()) break retryLoop default: } // Failure to prepare are returned as error immediately to // expose them via the controller status as these errors are // most likely not temporary. // In case of a CNP parse error will update the status in the CNP. serverRule, err = c.prepareUpdate(cnp, scopedLog) if IsErrParse(err) { statusErr := c.updateStatus(serverRule, rev, err, waitForEPsErr) if statusErr != nil { scopedLog.WithError(statusErr).Debug("CNP status for invalid rule cannot be updated") } } if err != nil { return err } err = c.updateStatus(serverRule, rev, policyImportErr, waitForEPsErr) scopedLog.WithError(err).WithField("status", serverRule.Status).Debug("CNP status update result from apiserver") switch { case waitForEPsErr != nil: // Waiting for endpoints has failed previously. We made // an attempt to make this error condition visible via // the status field. Regardless of whether this has // succeeded or not, return an error to have the // surrounding controller retry the wait for endpoint // state. err = waitForEPsErr break retryLoop case err == nil: // The status update was successful break retryLoop } cnpBackoff.Wait(ctx) // error of Wait() can be ignored, if the context is cancelled, // the next iteration of the loop will break out } outcome := metrics.LabelValueOutcomeSuccess if err != nil { outcome = metrics.LabelValueOutcomeFail } if c.UpdateDuration != nil { latency := c.UpdateDuration.End(err == nil).Total() metrics.KubernetesCNPStatusCompletion.WithLabelValues(fmt.Sprintf("%d", numAttempts), outcome).Observe(latency.Seconds()) } return err }
go
func (c *CNPStatusUpdateContext) UpdateStatus(ctx context.Context, cnp *types.SlimCNP, rev uint64, policyImportErr error) error { var ( err error serverRule *types.SlimCNP // The following is an example distribution with jitter applied: // // nodes 4 16 128 512 1024 2048 // 1: 2.6s 5.5s 8.1s 9s 9.9s 12.9s // 2: 1.9s 4.2s 6.3s 11.9s 17.6s 26.2s // 3: 4s 10.4s 15.7s 26.7s 20.7s 23.3s // 4: 18s 12.1s 19.7s 40s 1m6.3s 1m46.3s // 5: 16.2s 28.9s 1m58.2s 46.2s 2m0s 2m0s // 6: 54.7s 7.9s 53.3s 2m0s 2m0s 45.8s // 7: 1m55.5s 22.8s 2m0s 2m0s 2m0s 2m0s // 8: 1m45.8s 1m36.7s 2m0s 2m0s 2m0s 2m0s cnpBackoff = backoff.Exponential{ Min: time.Second, NodeManager: c.NodeManager, Jitter: true, } scopedLog = log.WithFields(logrus.Fields{ logfields.CiliumNetworkPolicyName: cnp.ObjectMeta.Name, logfields.K8sAPIVersion: cnp.TypeMeta.APIVersion, logfields.K8sNamespace: cnp.ObjectMeta.Namespace, }) ) ctxEndpointWait, cancel := context.WithTimeout(ctx, 30*time.Second) defer cancel() waitForEPsErr := c.WaitForEndpointsAtPolicyRev(ctxEndpointWait, rev) numAttempts := 0 retryLoop: for { numAttempts++ select { case <-ctx.Done(): // The owning controller wants us to stop, no error is // returned. This is graceful err = fmt.Errorf("status update cancelled via context: %s", ctx.Err()) break retryLoop default: } // Failure to prepare are returned as error immediately to // expose them via the controller status as these errors are // most likely not temporary. // In case of a CNP parse error will update the status in the CNP. serverRule, err = c.prepareUpdate(cnp, scopedLog) if IsErrParse(err) { statusErr := c.updateStatus(serverRule, rev, err, waitForEPsErr) if statusErr != nil { scopedLog.WithError(statusErr).Debug("CNP status for invalid rule cannot be updated") } } if err != nil { return err } err = c.updateStatus(serverRule, rev, policyImportErr, waitForEPsErr) scopedLog.WithError(err).WithField("status", serverRule.Status).Debug("CNP status update result from apiserver") switch { case waitForEPsErr != nil: // Waiting for endpoints has failed previously. We made // an attempt to make this error condition visible via // the status field. Regardless of whether this has // succeeded or not, return an error to have the // surrounding controller retry the wait for endpoint // state. err = waitForEPsErr break retryLoop case err == nil: // The status update was successful break retryLoop } cnpBackoff.Wait(ctx) // error of Wait() can be ignored, if the context is cancelled, // the next iteration of the loop will break out } outcome := metrics.LabelValueOutcomeSuccess if err != nil { outcome = metrics.LabelValueOutcomeFail } if c.UpdateDuration != nil { latency := c.UpdateDuration.End(err == nil).Total() metrics.KubernetesCNPStatusCompletion.WithLabelValues(fmt.Sprintf("%d", numAttempts), outcome).Observe(latency.Seconds()) } return err }
[ "func", "(", "c", "*", "CNPStatusUpdateContext", ")", "UpdateStatus", "(", "ctx", "context", ".", "Context", ",", "cnp", "*", "types", ".", "SlimCNP", ",", "rev", "uint64", ",", "policyImportErr", "error", ")", "error", "{", "var", "(", "err", "error", "...
// UpdateStatus updates the status section of a CiliumNetworkPolicy. It will // retry as long as required to update the status unless a non-temporary error // occurs in which case it expects a surrounding controller to restart or give // up.
[ "UpdateStatus", "updates", "the", "status", "section", "of", "a", "CiliumNetworkPolicy", ".", "It", "will", "retry", "as", "long", "as", "required", "to", "update", "the", "status", "unless", "a", "non", "-", "temporary", "error", "occurs", "in", "which", "c...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/cnp.go#L172-L269
163,459
cilium/cilium
pkg/clustermesh/services.go
delete
func (c *globalServiceCache) delete(globalService *globalService, clusterName, serviceName string) { scopedLog := log.WithFields(logrus.Fields{ logfields.ServiceName: serviceName, logfields.ClusterName: clusterName, }) if _, ok := globalService.clusterServices[clusterName]; !ok { scopedLog.Debug("Ignoring delete request for unknown cluster") return } scopedLog.Debugf("Deleted service definition of remote cluster") delete(globalService.clusterServices, clusterName) // After the last cluster service is removed, remove the // global service if len(globalService.clusterServices) == 0 { scopedLog.Debugf("Deleted global service %s", serviceName) delete(c.byName, serviceName) } }
go
func (c *globalServiceCache) delete(globalService *globalService, clusterName, serviceName string) { scopedLog := log.WithFields(logrus.Fields{ logfields.ServiceName: serviceName, logfields.ClusterName: clusterName, }) if _, ok := globalService.clusterServices[clusterName]; !ok { scopedLog.Debug("Ignoring delete request for unknown cluster") return } scopedLog.Debugf("Deleted service definition of remote cluster") delete(globalService.clusterServices, clusterName) // After the last cluster service is removed, remove the // global service if len(globalService.clusterServices) == 0 { scopedLog.Debugf("Deleted global service %s", serviceName) delete(c.byName, serviceName) } }
[ "func", "(", "c", "*", "globalServiceCache", ")", "delete", "(", "globalService", "*", "globalService", ",", "clusterName", ",", "serviceName", "string", ")", "{", "scopedLog", ":=", "log", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", "...
// must be called with c.mutex held
[ "must", "be", "called", "with", "c", ".", "mutex", "held" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/clustermesh/services.go#L78-L98
163,460
cilium/cilium
pkg/clustermesh/services.go
OnUpdate
func (r *remoteServiceObserver) OnUpdate(key store.Key) { if svc, ok := key.(*service.ClusterService); ok { scopedLog := log.WithFields(logrus.Fields{logfields.ServiceName: svc.String()}) scopedLog.Debugf("Update event of remote service %#v", svc) mesh := r.remoteCluster.mesh mesh.globalServices.onUpdate(svc) if merger := mesh.conf.ServiceMerger; merger != nil { merger.MergeExternalServiceUpdate(svc) } else { scopedLog.Debugf("Ignoring remote service update. Missing merger function") } } else { log.Warningf("Received unexpected remote service update object %+v", key) } }
go
func (r *remoteServiceObserver) OnUpdate(key store.Key) { if svc, ok := key.(*service.ClusterService); ok { scopedLog := log.WithFields(logrus.Fields{logfields.ServiceName: svc.String()}) scopedLog.Debugf("Update event of remote service %#v", svc) mesh := r.remoteCluster.mesh mesh.globalServices.onUpdate(svc) if merger := mesh.conf.ServiceMerger; merger != nil { merger.MergeExternalServiceUpdate(svc) } else { scopedLog.Debugf("Ignoring remote service update. Missing merger function") } } else { log.Warningf("Received unexpected remote service update object %+v", key) } }
[ "func", "(", "r", "*", "remoteServiceObserver", ")", "OnUpdate", "(", "key", "store", ".", "Key", ")", "{", "if", "svc", ",", "ok", ":=", "key", ".", "(", "*", "service", ".", "ClusterService", ")", ";", "ok", "{", "scopedLog", ":=", "log", ".", "W...
// OnUpdate is called when a service in a remote cluster is updated
[ "OnUpdate", "is", "called", "when", "a", "service", "in", "a", "remote", "cluster", "is", "updated" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/clustermesh/services.go#L129-L145
163,461
cilium/cilium
pkg/clustermesh/services.go
OnDelete
func (r *remoteServiceObserver) OnDelete(key store.NamedKey) { if svc, ok := key.(*service.ClusterService); ok { scopedLog := log.WithFields(logrus.Fields{logfields.ServiceName: svc.String()}) scopedLog.Debugf("Update event of remote service %#v", svc) mesh := r.remoteCluster.mesh mesh.globalServices.onDelete(svc) if merger := mesh.conf.ServiceMerger; merger != nil { merger.MergeExternalServiceDelete(svc) } else { scopedLog.Debugf("Ignoring remote service update. Missing merger function") } } else { log.Warningf("Received unexpected remote service delete object %+v", key) } }
go
func (r *remoteServiceObserver) OnDelete(key store.NamedKey) { if svc, ok := key.(*service.ClusterService); ok { scopedLog := log.WithFields(logrus.Fields{logfields.ServiceName: svc.String()}) scopedLog.Debugf("Update event of remote service %#v", svc) mesh := r.remoteCluster.mesh mesh.globalServices.onDelete(svc) if merger := mesh.conf.ServiceMerger; merger != nil { merger.MergeExternalServiceDelete(svc) } else { scopedLog.Debugf("Ignoring remote service update. Missing merger function") } } else { log.Warningf("Received unexpected remote service delete object %+v", key) } }
[ "func", "(", "r", "*", "remoteServiceObserver", ")", "OnDelete", "(", "key", "store", ".", "NamedKey", ")", "{", "if", "svc", ",", "ok", ":=", "key", ".", "(", "*", "service", ".", "ClusterService", ")", ";", "ok", "{", "scopedLog", ":=", "log", ".",...
// OnDelete is called when a service in a remote cluster is deleted
[ "OnDelete", "is", "called", "when", "a", "service", "in", "a", "remote", "cluster", "is", "deleted" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/clustermesh/services.go#L148-L164
163,462
cilium/cilium
pkg/debug/subsystem.go
RegisterStatusFunc
func RegisterStatusFunc(name string, fn StatusFunc) error { return globalStatusFunctions.register(name, fn) }
go
func RegisterStatusFunc(name string, fn StatusFunc) error { return globalStatusFunctions.register(name, fn) }
[ "func", "RegisterStatusFunc", "(", "name", "string", ",", "fn", "StatusFunc", ")", "error", "{", "return", "globalStatusFunctions", ".", "register", "(", "name", ",", "fn", ")", "\n", "}" ]
// RegisterStatusFunc registers a subsystem and associates a status function to // call for debug status collection
[ "RegisterStatusFunc", "registers", "a", "subsystem", "and", "associates", "a", "status", "function", "to", "call", "for", "debug", "status", "collection" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/debug/subsystem.go#L92-L94
163,463
cilium/cilium
api/v1/client/policy/get_identity_endpoints_parameters.go
WithTimeout
func (o *GetIdentityEndpointsParams) WithTimeout(timeout time.Duration) *GetIdentityEndpointsParams { o.SetTimeout(timeout) return o }
go
func (o *GetIdentityEndpointsParams) WithTimeout(timeout time.Duration) *GetIdentityEndpointsParams { o.SetTimeout(timeout) return o }
[ "func", "(", "o", "*", "GetIdentityEndpointsParams", ")", "WithTimeout", "(", "timeout", "time", ".", "Duration", ")", "*", "GetIdentityEndpointsParams", "{", "o", ".", "SetTimeout", "(", "timeout", ")", "\n", "return", "o", "\n", "}" ]
// WithTimeout adds the timeout to the get identity endpoints params
[ "WithTimeout", "adds", "the", "timeout", "to", "the", "get", "identity", "endpoints", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/get_identity_endpoints_parameters.go#L69-L72
163,464
cilium/cilium
api/v1/client/policy/get_identity_endpoints_parameters.go
WithContext
func (o *GetIdentityEndpointsParams) WithContext(ctx context.Context) *GetIdentityEndpointsParams { o.SetContext(ctx) return o }
go
func (o *GetIdentityEndpointsParams) WithContext(ctx context.Context) *GetIdentityEndpointsParams { o.SetContext(ctx) return o }
[ "func", "(", "o", "*", "GetIdentityEndpointsParams", ")", "WithContext", "(", "ctx", "context", ".", "Context", ")", "*", "GetIdentityEndpointsParams", "{", "o", ".", "SetContext", "(", "ctx", ")", "\n", "return", "o", "\n", "}" ]
// WithContext adds the context to the get identity endpoints params
[ "WithContext", "adds", "the", "context", "to", "the", "get", "identity", "endpoints", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/get_identity_endpoints_parameters.go#L80-L83
163,465
cilium/cilium
api/v1/client/policy/get_identity_endpoints_parameters.go
WithHTTPClient
func (o *GetIdentityEndpointsParams) WithHTTPClient(client *http.Client) *GetIdentityEndpointsParams { o.SetHTTPClient(client) return o }
go
func (o *GetIdentityEndpointsParams) WithHTTPClient(client *http.Client) *GetIdentityEndpointsParams { o.SetHTTPClient(client) return o }
[ "func", "(", "o", "*", "GetIdentityEndpointsParams", ")", "WithHTTPClient", "(", "client", "*", "http", ".", "Client", ")", "*", "GetIdentityEndpointsParams", "{", "o", ".", "SetHTTPClient", "(", "client", ")", "\n", "return", "o", "\n", "}" ]
// WithHTTPClient adds the HTTPClient to the get identity endpoints params
[ "WithHTTPClient", "adds", "the", "HTTPClient", "to", "the", "get", "identity", "endpoints", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/get_identity_endpoints_parameters.go#L91-L94
163,466
cilium/cilium
api/v1/models/service.go
Validate
func (m *Service) Validate(formats strfmt.Registry) error { var res []error if err := m.validateSpec(formats); err != nil { res = append(res, err) } if err := m.validateStatus(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m *Service) Validate(formats strfmt.Registry) error { var res []error if err := m.validateSpec(formats); err != nil { res = append(res, err) } if err := m.validateStatus(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "*", "Service", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateSpec", "(", "formats", ")", ";", "err", "!=", "nil", "{"...
// Validate validates this service
[ "Validate", "validates", "this", "service" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/service.go#L27-L42
163,467
cilium/cilium
api/v1/models/dns_lookup.go
Validate
func (m *DNSLookup) Validate(formats strfmt.Registry) error { var res []error if err := m.validateExpirationTime(formats); err != nil { res = append(res, err) } if err := m.validateLookupTime(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m *DNSLookup) Validate(formats strfmt.Registry) error { var res []error if err := m.validateExpirationTime(formats); err != nil { res = append(res, err) } if err := m.validateLookupTime(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "*", "DNSLookup", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateExpirationTime", "(", "formats", ")", ";", "err", "!=", ...
// Validate validates this DNS lookup
[ "Validate", "validates", "this", "DNS", "lookup" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/dns_lookup.go#L42-L57
163,468
cilium/cilium
api/v1/models/endpoint_status_change.go
Validate
func (m *EndpointStatusChange) Validate(formats strfmt.Registry) error { var res []error if err := m.validateCode(formats); err != nil { res = append(res, err) } if err := m.validateState(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m *EndpointStatusChange) Validate(formats strfmt.Registry) error { var res []error if err := m.validateCode(formats); err != nil { res = append(res, err) } if err := m.validateState(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "*", "EndpointStatusChange", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateCode", "(", "formats", ")", ";", "err", "!=", ...
// Validate validates this endpoint status change
[ "Validate", "validates", "this", "endpoint", "status", "change" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/endpoint_status_change.go#L37-L52
163,469
cilium/cilium
api/v1/server/restapi/daemon/get_map_name_responses.go
WithPayload
func (o *GetMapNameOK) WithPayload(payload *models.BPFMap) *GetMapNameOK { o.Payload = payload return o }
go
func (o *GetMapNameOK) WithPayload(payload *models.BPFMap) *GetMapNameOK { o.Payload = payload return o }
[ "func", "(", "o", "*", "GetMapNameOK", ")", "WithPayload", "(", "payload", "*", "models", ".", "BPFMap", ")", "*", "GetMapNameOK", "{", "o", ".", "Payload", "=", "payload", "\n", "return", "o", "\n", "}" ]
// WithPayload adds the payload to the get map name o k response
[ "WithPayload", "adds", "the", "payload", "to", "the", "get", "map", "name", "o", "k", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/daemon/get_map_name_responses.go#L38-L41
163,470
cilium/cilium
cilium-health/launch/endpoint.go
PingEndpoint
func (c *Client) PingEndpoint() error { _, err := c.Restapi.GetHello(nil) return err }
go
func (c *Client) PingEndpoint() error { _, err := c.Restapi.GetHello(nil) return err }
[ "func", "(", "c", "*", "Client", ")", "PingEndpoint", "(", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "Restapi", ".", "GetHello", "(", "nil", ")", "\n", "return", "err", "\n", "}" ]
// PingEndpoint attempts to make an API ping request to the local cilium-health // endpoint, and returns whether this was successful.
[ "PingEndpoint", "attempts", "to", "make", "an", "API", "ping", "request", "to", "the", "local", "cilium", "-", "health", "endpoint", "and", "returns", "whether", "this", "was", "successful", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/cilium-health/launch/endpoint.go#L118-L121
163,471
cilium/cilium
cilium-health/launch/endpoint.go
CleanupEndpoint
func CleanupEndpoint() { // In the case of ipvlan, the ipvlan slave device is removed by removal // of the endpoint netns in "cleanup" of spawn_netns.sh if option.Config.DatapathMode == option.DatapathModeVeth { scopedLog := log.WithField(logfields.Veth, vethName) if link, err := netlink.LinkByName(vethName); err == nil { err = netlink.LinkDel(link) if err != nil { scopedLog.WithError(err).Warning("Couldn't delete cilium-health device") } } else { scopedLog.WithError(err).Debug("Didn't find existing device") } } }
go
func CleanupEndpoint() { // In the case of ipvlan, the ipvlan slave device is removed by removal // of the endpoint netns in "cleanup" of spawn_netns.sh if option.Config.DatapathMode == option.DatapathModeVeth { scopedLog := log.WithField(logfields.Veth, vethName) if link, err := netlink.LinkByName(vethName); err == nil { err = netlink.LinkDel(link) if err != nil { scopedLog.WithError(err).Warning("Couldn't delete cilium-health device") } } else { scopedLog.WithError(err).Debug("Didn't find existing device") } } }
[ "func", "CleanupEndpoint", "(", ")", "{", "// In the case of ipvlan, the ipvlan slave device is removed by removal", "// of the endpoint netns in \"cleanup\" of spawn_netns.sh", "if", "option", ".", "Config", ".", "DatapathMode", "==", "option", ".", "DatapathModeVeth", "{", "sco...
// CleanupEndpoint cleans up remaining resources associated with the health // endpoint. // // This is expected to be called after the process is killed and the endpoint // is removed from the endpointmanager.
[ "CleanupEndpoint", "cleans", "up", "remaining", "resources", "associated", "with", "the", "health", "endpoint", ".", "This", "is", "expected", "to", "be", "called", "after", "the", "process", "is", "killed", "and", "the", "endpoint", "is", "removed", "from", "...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/cilium-health/launch/endpoint.go#L144-L158
163,472
cilium/cilium
pkg/tuple/ipv4.go
Dump
func (k TupleKey4) Dump(buffer *bytes.Buffer, reverse bool) bool { var addrDest string if k.NextHeader == 0 { return false } // Addresses swapped, see issue #5848 if reverse { addrDest = k.SourceAddr.IP().String() } else { addrDest = k.DestAddr.IP().String() } if k.Flags&TUPLE_F_IN != 0 { buffer.WriteString(fmt.Sprintf("%s IN %s %d:%d ", k.NextHeader.String(), addrDest, k.SourcePort, k.DestPort), ) } else { buffer.WriteString(fmt.Sprintf("%s OUT %s %d:%d ", k.NextHeader.String(), addrDest, k.DestPort, k.SourcePort), ) } if k.Flags&TUPLE_F_RELATED != 0 { buffer.WriteString("related ") } if k.Flags&TUPLE_F_SERVICE != 0 { buffer.WriteString("service ") } return true }
go
func (k TupleKey4) Dump(buffer *bytes.Buffer, reverse bool) bool { var addrDest string if k.NextHeader == 0 { return false } // Addresses swapped, see issue #5848 if reverse { addrDest = k.SourceAddr.IP().String() } else { addrDest = k.DestAddr.IP().String() } if k.Flags&TUPLE_F_IN != 0 { buffer.WriteString(fmt.Sprintf("%s IN %s %d:%d ", k.NextHeader.String(), addrDest, k.SourcePort, k.DestPort), ) } else { buffer.WriteString(fmt.Sprintf("%s OUT %s %d:%d ", k.NextHeader.String(), addrDest, k.DestPort, k.SourcePort), ) } if k.Flags&TUPLE_F_RELATED != 0 { buffer.WriteString("related ") } if k.Flags&TUPLE_F_SERVICE != 0 { buffer.WriteString("service ") } return true }
[ "func", "(", "k", "TupleKey4", ")", "Dump", "(", "buffer", "*", "bytes", ".", "Buffer", ",", "reverse", "bool", ")", "bool", "{", "var", "addrDest", "string", "\n\n", "if", "k", ".", "NextHeader", "==", "0", "{", "return", "false", "\n", "}", "\n\n",...
// Dump writes the contents of key to buffer and returns true if the value for // next header in the key is nonzero.
[ "Dump", "writes", "the", "contents", "of", "key", "to", "buffer", "and", "returns", "true", "if", "the", "value", "for", "next", "header", "in", "the", "key", "is", "nonzero", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/tuple/ipv4.go#L74-L109
163,473
cilium/cilium
pkg/tuple/ipv4.go
ToNetwork
func (k *TupleKey4Global) ToNetwork() TupleKey { return &TupleKey4Global{ TupleKey4: *k.TupleKey4.ToNetwork().(*TupleKey4), } }
go
func (k *TupleKey4Global) ToNetwork() TupleKey { return &TupleKey4Global{ TupleKey4: *k.TupleKey4.ToNetwork().(*TupleKey4), } }
[ "func", "(", "k", "*", "TupleKey4Global", ")", "ToNetwork", "(", ")", "TupleKey", "{", "return", "&", "TupleKey4Global", "{", "TupleKey4", ":", "*", "k", ".", "TupleKey4", ".", "ToNetwork", "(", ")", ".", "(", "*", "TupleKey4", ")", ",", "}", "\n", "...
// ToNetwork converts ports to network byte order. // // This is necessary to prevent callers from implicitly converting // the TupleKey4Global type here into a local key type in the nested // TupleKey4 field.
[ "ToNetwork", "converts", "ports", "to", "network", "byte", "order", ".", "This", "is", "necessary", "to", "prevent", "callers", "from", "implicitly", "converting", "the", "TupleKey4Global", "type", "here", "into", "a", "local", "key", "type", "in", "the", "nes...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/tuple/ipv4.go#L132-L136
163,474
cilium/cilium
pkg/tuple/ipv4.go
ToHost
func (k *TupleKey4Global) ToHost() TupleKey { return &TupleKey4Global{ TupleKey4: *k.TupleKey4.ToHost().(*TupleKey4), } }
go
func (k *TupleKey4Global) ToHost() TupleKey { return &TupleKey4Global{ TupleKey4: *k.TupleKey4.ToHost().(*TupleKey4), } }
[ "func", "(", "k", "*", "TupleKey4Global", ")", "ToHost", "(", ")", "TupleKey", "{", "return", "&", "TupleKey4Global", "{", "TupleKey4", ":", "*", "k", ".", "TupleKey4", ".", "ToHost", "(", ")", ".", "(", "*", "TupleKey4", ")", ",", "}", "\n", "}" ]
// ToHost converts ports to host byte order. // // This is necessary to prevent callers from implicitly converting // the TupleKey4Global type here into a local key type in the nested // TupleKey4 field.
[ "ToHost", "converts", "ports", "to", "host", "byte", "order", ".", "This", "is", "necessary", "to", "prevent", "callers", "from", "implicitly", "converting", "the", "TupleKey4Global", "type", "here", "into", "a", "local", "key", "type", "in", "the", "nested", ...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/tuple/ipv4.go#L143-L147
163,475
cilium/cilium
api/v1/server/restapi/daemon/get_map.go
NewGetMap
func NewGetMap(ctx *middleware.Context, handler GetMapHandler) *GetMap { return &GetMap{Context: ctx, Handler: handler} }
go
func NewGetMap(ctx *middleware.Context, handler GetMapHandler) *GetMap { return &GetMap{Context: ctx, Handler: handler} }
[ "func", "NewGetMap", "(", "ctx", "*", "middleware", ".", "Context", ",", "handler", "GetMapHandler", ")", "*", "GetMap", "{", "return", "&", "GetMap", "{", "Context", ":", "ctx", ",", "Handler", ":", "handler", "}", "\n", "}" ]
// NewGetMap creates a new http.Handler for the get map operation
[ "NewGetMap", "creates", "a", "new", "http", ".", "Handler", "for", "the", "get", "map", "operation" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/daemon/get_map.go#L28-L30
163,476
cilium/cilium
api/v1/health/client/restapi/get_healthz_parameters.go
WithTimeout
func (o *GetHealthzParams) WithTimeout(timeout time.Duration) *GetHealthzParams { o.SetTimeout(timeout) return o }
go
func (o *GetHealthzParams) WithTimeout(timeout time.Duration) *GetHealthzParams { o.SetTimeout(timeout) return o }
[ "func", "(", "o", "*", "GetHealthzParams", ")", "WithTimeout", "(", "timeout", "time", ".", "Duration", ")", "*", "GetHealthzParams", "{", "o", ".", "SetTimeout", "(", "timeout", ")", "\n", "return", "o", "\n", "}" ]
// WithTimeout adds the timeout to the get healthz params
[ "WithTimeout", "adds", "the", "timeout", "to", "the", "get", "healthz", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/client/restapi/get_healthz_parameters.go#L69-L72
163,477
cilium/cilium
api/v1/health/client/restapi/get_healthz_parameters.go
WithContext
func (o *GetHealthzParams) WithContext(ctx context.Context) *GetHealthzParams { o.SetContext(ctx) return o }
go
func (o *GetHealthzParams) WithContext(ctx context.Context) *GetHealthzParams { o.SetContext(ctx) return o }
[ "func", "(", "o", "*", "GetHealthzParams", ")", "WithContext", "(", "ctx", "context", ".", "Context", ")", "*", "GetHealthzParams", "{", "o", ".", "SetContext", "(", "ctx", ")", "\n", "return", "o", "\n", "}" ]
// WithContext adds the context to the get healthz params
[ "WithContext", "adds", "the", "context", "to", "the", "get", "healthz", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/client/restapi/get_healthz_parameters.go#L80-L83
163,478
cilium/cilium
api/v1/health/client/restapi/get_healthz_parameters.go
WithHTTPClient
func (o *GetHealthzParams) WithHTTPClient(client *http.Client) *GetHealthzParams { o.SetHTTPClient(client) return o }
go
func (o *GetHealthzParams) WithHTTPClient(client *http.Client) *GetHealthzParams { o.SetHTTPClient(client) return o }
[ "func", "(", "o", "*", "GetHealthzParams", ")", "WithHTTPClient", "(", "client", "*", "http", ".", "Client", ")", "*", "GetHealthzParams", "{", "o", ".", "SetHTTPClient", "(", "client", ")", "\n", "return", "o", "\n", "}" ]
// WithHTTPClient adds the HTTPClient to the get healthz params
[ "WithHTTPClient", "adds", "the", "HTTPClient", "to", "the", "get", "healthz", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/client/restapi/get_healthz_parameters.go#L91-L94
163,479
cilium/cilium
pkg/k8s/ingress.go
ParseIngressID
func ParseIngressID(svc *types.Ingress) ServiceID { id := ServiceID{ Namespace: svc.ObjectMeta.Namespace, } if svc.Spec.Backend != nil { id.Name = svc.Spec.Backend.ServiceName } return id }
go
func ParseIngressID(svc *types.Ingress) ServiceID { id := ServiceID{ Namespace: svc.ObjectMeta.Namespace, } if svc.Spec.Backend != nil { id.Name = svc.Spec.Backend.ServiceName } return id }
[ "func", "ParseIngressID", "(", "svc", "*", "types", ".", "Ingress", ")", "ServiceID", "{", "id", ":=", "ServiceID", "{", "Namespace", ":", "svc", ".", "ObjectMeta", ".", "Namespace", ",", "}", "\n\n", "if", "svc", ".", "Spec", ".", "Backend", "!=", "ni...
// ParseIngressID parses the service ID from the ingress resource
[ "ParseIngressID", "parses", "the", "service", "ID", "from", "the", "ingress", "resource" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/ingress.go#L32-L42
163,480
cilium/cilium
pkg/k8s/ingress.go
ParseIngress
func ParseIngress(ingress *types.Ingress, host net.IP) (ServiceID, *Service, error) { svcID := ParseIngressID(ingress) if !supportV1beta1(ingress) { return svcID, nil, fmt.Errorf("only Single Service Ingress is supported for now, ignoring Ingress") } ingressPort := ingress.Spec.Backend.ServicePort.IntValue() if ingressPort == 0 { return svcID, nil, fmt.Errorf("invalid port number") } svc := NewService(host, false, nil, nil) portName := loadbalancer.FEPortName(ingress.Spec.Backend.ServiceName + "/" + ingress.Spec.Backend.ServicePort.String()) svc.Ports[portName] = loadbalancer.NewFEPort(loadbalancer.TCP, uint16(ingressPort)) return svcID, svc, nil }
go
func ParseIngress(ingress *types.Ingress, host net.IP) (ServiceID, *Service, error) { svcID := ParseIngressID(ingress) if !supportV1beta1(ingress) { return svcID, nil, fmt.Errorf("only Single Service Ingress is supported for now, ignoring Ingress") } ingressPort := ingress.Spec.Backend.ServicePort.IntValue() if ingressPort == 0 { return svcID, nil, fmt.Errorf("invalid port number") } svc := NewService(host, false, nil, nil) portName := loadbalancer.FEPortName(ingress.Spec.Backend.ServiceName + "/" + ingress.Spec.Backend.ServicePort.String()) svc.Ports[portName] = loadbalancer.NewFEPort(loadbalancer.TCP, uint16(ingressPort)) return svcID, svc, nil }
[ "func", "ParseIngress", "(", "ingress", "*", "types", ".", "Ingress", ",", "host", "net", ".", "IP", ")", "(", "ServiceID", ",", "*", "Service", ",", "error", ")", "{", "svcID", ":=", "ParseIngressID", "(", "ingress", ")", "\n\n", "if", "!", "supportV1...
// ParseIngress parses an ingress resources and returns the Service definition
[ "ParseIngress", "parses", "an", "ingress", "resources", "and", "returns", "the", "Service", "definition" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/ingress.go#L45-L62
163,481
cilium/cilium
api/v1/server/restapi/endpoint/get_endpoint_id_labels.go
NewGetEndpointIDLabels
func NewGetEndpointIDLabels(ctx *middleware.Context, handler GetEndpointIDLabelsHandler) *GetEndpointIDLabels { return &GetEndpointIDLabels{Context: ctx, Handler: handler} }
go
func NewGetEndpointIDLabels(ctx *middleware.Context, handler GetEndpointIDLabelsHandler) *GetEndpointIDLabels { return &GetEndpointIDLabels{Context: ctx, Handler: handler} }
[ "func", "NewGetEndpointIDLabels", "(", "ctx", "*", "middleware", ".", "Context", ",", "handler", "GetEndpointIDLabelsHandler", ")", "*", "GetEndpointIDLabels", "{", "return", "&", "GetEndpointIDLabels", "{", "Context", ":", "ctx", ",", "Handler", ":", "handler", "...
// NewGetEndpointIDLabels creates a new http.Handler for the get endpoint ID labels operation
[ "NewGetEndpointIDLabels", "creates", "a", "new", "http", ".", "Handler", "for", "the", "get", "endpoint", "ID", "labels", "operation" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/endpoint/get_endpoint_id_labels.go#L28-L30
163,482
cilium/cilium
api/v1/models/proxy_statistics.go
Validate
func (m *ProxyStatistics) Validate(formats strfmt.Registry) error { var res []error if err := m.validateLocation(formats); err != nil { res = append(res, err) } if err := m.validateStatistics(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m *ProxyStatistics) Validate(formats strfmt.Registry) error { var res []error if err := m.validateLocation(formats); err != nil { res = append(res, err) } if err := m.validateStatistics(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "*", "ProxyStatistics", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateLocation", "(", "formats", ")", ";", "err", "!=", ...
// Validate validates this proxy statistics
[ "Validate", "validates", "this", "proxy", "statistics" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/proxy_statistics.go#L41-L56
163,483
cilium/cilium
api/v1/server/restapi/policy/get_identity.go
NewGetIdentity
func NewGetIdentity(ctx *middleware.Context, handler GetIdentityHandler) *GetIdentity { return &GetIdentity{Context: ctx, Handler: handler} }
go
func NewGetIdentity(ctx *middleware.Context, handler GetIdentityHandler) *GetIdentity { return &GetIdentity{Context: ctx, Handler: handler} }
[ "func", "NewGetIdentity", "(", "ctx", "*", "middleware", ".", "Context", ",", "handler", "GetIdentityHandler", ")", "*", "GetIdentity", "{", "return", "&", "GetIdentity", "{", "Context", ":", "ctx", ",", "Handler", ":", "handler", "}", "\n", "}" ]
// NewGetIdentity creates a new http.Handler for the get identity operation
[ "NewGetIdentity", "creates", "a", "new", "http", ".", "Handler", "for", "the", "get", "identity", "operation" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/get_identity.go#L28-L30
163,484
cilium/cilium
api/v1/server/configure_cilium.go
setupGlobalMiddleware
func setupGlobalMiddleware(handler http.Handler) http.Handler { eventsHelper := &metrics.APIEventTSHelper{ Next: handler, TSGauge: metrics.EventTSAPI, Histogram: metrics.APIInteractions, } return &api.APIPanicHandler{ Next: eventsHelper, } }
go
func setupGlobalMiddleware(handler http.Handler) http.Handler { eventsHelper := &metrics.APIEventTSHelper{ Next: handler, TSGauge: metrics.EventTSAPI, Histogram: metrics.APIInteractions, } return &api.APIPanicHandler{ Next: eventsHelper, } }
[ "func", "setupGlobalMiddleware", "(", "handler", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "eventsHelper", ":=", "&", "metrics", ".", "APIEventTSHelper", "{", "Next", ":", "handler", ",", "TSGauge", ":", "metrics", ".", "EventTSAPI", ",", "Hi...
// The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document. // So this is a good place to plug in a panic handling middleware, logging and metrics
[ "The", "middleware", "configuration", "happens", "before", "anything", "this", "middleware", "also", "applies", "to", "serving", "the", "swagger", ".", "json", "document", ".", "So", "this", "is", "a", "good", "place", "to", "plug", "in", "a", "panic", "hand...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/configure_cilium.go#L62-L72
163,485
cilium/cilium
pkg/monitor/datapath_trace.go
DumpInfo
func (n *TraceNotify) DumpInfo(data []byte) { fmt.Printf("%s flow %#x identity %d->%d state %s ifindex %s: %s\n", n.traceSummary(), n.Hash, n.SrcLabel, n.DstLabel, connState(n.Reason), ifname(int(n.Ifindex)), GetConnectionSummary(data[TraceNotifyLen:])) }
go
func (n *TraceNotify) DumpInfo(data []byte) { fmt.Printf("%s flow %#x identity %d->%d state %s ifindex %s: %s\n", n.traceSummary(), n.Hash, n.SrcLabel, n.DstLabel, connState(n.Reason), ifname(int(n.Ifindex)), GetConnectionSummary(data[TraceNotifyLen:])) }
[ "func", "(", "n", "*", "TraceNotify", ")", "DumpInfo", "(", "data", "[", "]", "byte", ")", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "n", ".", "traceSummary", "(", ")", ",", "n", ".", "Hash", ",", "n", ".", "SrcLabel", ",", "n", ...
// DumpInfo prints a summary of the trace messages.
[ "DumpInfo", "prints", "a", "summary", "of", "the", "trace", "messages", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/datapath_trace.go#L128-L132
163,486
cilium/cilium
pkg/monitor/datapath_trace.go
DumpVerbose
func (n *TraceNotify) DumpVerbose(dissect bool, data []byte, prefix string) { fmt.Printf("%s MARK %#x FROM %d %s: %d bytes (%d captured), state %s", prefix, n.Hash, n.Source, obsPoint(n.ObsPoint), n.OrigLen, n.CapLen, connState(n.Reason)) if n.Ifindex != 0 { fmt.Printf(", interface %s", ifname(int(n.Ifindex))) } if n.SrcLabel != 0 || n.DstLabel != 0 { fmt.Printf(", identity %d->%d", n.SrcLabel, n.DstLabel) } if n.DstID != 0 { fmt.Printf(", to endpoint %d\n", n.DstID) } else { fmt.Printf("\n") } if n.CapLen > 0 && len(data) > TraceNotifyLen { Dissect(dissect, data[TraceNotifyLen:]) } }
go
func (n *TraceNotify) DumpVerbose(dissect bool, data []byte, prefix string) { fmt.Printf("%s MARK %#x FROM %d %s: %d bytes (%d captured), state %s", prefix, n.Hash, n.Source, obsPoint(n.ObsPoint), n.OrigLen, n.CapLen, connState(n.Reason)) if n.Ifindex != 0 { fmt.Printf(", interface %s", ifname(int(n.Ifindex))) } if n.SrcLabel != 0 || n.DstLabel != 0 { fmt.Printf(", identity %d->%d", n.SrcLabel, n.DstLabel) } if n.DstID != 0 { fmt.Printf(", to endpoint %d\n", n.DstID) } else { fmt.Printf("\n") } if n.CapLen > 0 && len(data) > TraceNotifyLen { Dissect(dissect, data[TraceNotifyLen:]) } }
[ "func", "(", "n", "*", "TraceNotify", ")", "DumpVerbose", "(", "dissect", "bool", ",", "data", "[", "]", "byte", ",", "prefix", "string", ")", "{", "fmt", ".", "Printf", "(", "\"", "\"", ",", "prefix", ",", "n", ".", "Hash", ",", "n", ".", "Sourc...
// DumpVerbose prints the trace notification in human readable form
[ "DumpVerbose", "prints", "the", "trace", "notification", "in", "human", "readable", "form" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/datapath_trace.go#L135-L156
163,487
cilium/cilium
pkg/monitor/datapath_trace.go
TraceNotifyToVerbose
func TraceNotifyToVerbose(n *TraceNotify) TraceNotifyVerbose { return TraceNotifyVerbose{ Type: "trace", Mark: fmt.Sprintf("%#x", n.Hash), Ifindex: ifname(int(n.Ifindex)), State: connState(n.Reason), ObservationPoint: obsPoint(n.ObsPoint), TraceSummary: n.traceSummary(), Source: n.Source, Bytes: n.OrigLen, SrcLabel: n.SrcLabel, DstLabel: n.DstLabel, DstID: n.DstID, } }
go
func TraceNotifyToVerbose(n *TraceNotify) TraceNotifyVerbose { return TraceNotifyVerbose{ Type: "trace", Mark: fmt.Sprintf("%#x", n.Hash), Ifindex: ifname(int(n.Ifindex)), State: connState(n.Reason), ObservationPoint: obsPoint(n.ObsPoint), TraceSummary: n.traceSummary(), Source: n.Source, Bytes: n.OrigLen, SrcLabel: n.SrcLabel, DstLabel: n.DstLabel, DstID: n.DstID, } }
[ "func", "TraceNotifyToVerbose", "(", "n", "*", "TraceNotify", ")", "TraceNotifyVerbose", "{", "return", "TraceNotifyVerbose", "{", "Type", ":", "\"", "\"", ",", "Mark", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "n", ".", "Hash", ")", ",", "Ifinde...
// TraceNotifyToVerbose creates verbose notification from base TraceNotify
[ "TraceNotifyToVerbose", "creates", "verbose", "notification", "from", "base", "TraceNotify" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/datapath_trace.go#L197-L211
163,488
cilium/cilium
api/v1/server/restapi/endpoint/patch_endpoint_id_labels.go
NewPatchEndpointIDLabels
func NewPatchEndpointIDLabels(ctx *middleware.Context, handler PatchEndpointIDLabelsHandler) *PatchEndpointIDLabels { return &PatchEndpointIDLabels{Context: ctx, Handler: handler} }
go
func NewPatchEndpointIDLabels(ctx *middleware.Context, handler PatchEndpointIDLabelsHandler) *PatchEndpointIDLabels { return &PatchEndpointIDLabels{Context: ctx, Handler: handler} }
[ "func", "NewPatchEndpointIDLabels", "(", "ctx", "*", "middleware", ".", "Context", ",", "handler", "PatchEndpointIDLabelsHandler", ")", "*", "PatchEndpointIDLabels", "{", "return", "&", "PatchEndpointIDLabels", "{", "Context", ":", "ctx", ",", "Handler", ":", "handl...
// NewPatchEndpointIDLabels creates a new http.Handler for the patch endpoint ID labels operation
[ "NewPatchEndpointIDLabels", "creates", "a", "new", "http", ".", "Handler", "for", "the", "patch", "endpoint", "ID", "labels", "operation" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/endpoint/patch_endpoint_id_labels.go#L28-L30
163,489
cilium/cilium
pkg/datapath/prefilter/prefilter.go
WriteConfig
func (p *PreFilter) WriteConfig(fw io.Writer) { p.mutex.RLock() defer p.mutex.RUnlock() fmt.Fprintf(fw, "#define CIDR4_HMAP_ELEMS %d\n", maxHKeys) fmt.Fprintf(fw, "#define CIDR4_LMAP_ELEMS %d\n", maxLKeys) fmt.Fprintf(fw, "#define CIDR4_HMAP_NAME %s\n", path.Base(p.maps[prefixesV4Fix].String())) fmt.Fprintf(fw, "#define CIDR4_LMAP_NAME %s\n", path.Base(p.maps[prefixesV4Dyn].String())) fmt.Fprintf(fw, "#define CIDR6_HMAP_NAME %s\n", path.Base(p.maps[prefixesV6Fix].String())) fmt.Fprintf(fw, "#define CIDR6_LMAP_NAME %s\n", path.Base(p.maps[prefixesV6Dyn].String())) if p.config.fix4Enabled { fmt.Fprintf(fw, "#define CIDR4_FILTER\n") if p.config.dyn4Enabled { fmt.Fprintf(fw, "#define CIDR4_LPM_PREFILTER\n") } } if p.config.fix6Enabled { fmt.Fprintf(fw, "#define CIDR6_FILTER\n") if p.config.dyn6Enabled { fmt.Fprintf(fw, "#define CIDR6_LPM_PREFILTER\n") } } }
go
func (p *PreFilter) WriteConfig(fw io.Writer) { p.mutex.RLock() defer p.mutex.RUnlock() fmt.Fprintf(fw, "#define CIDR4_HMAP_ELEMS %d\n", maxHKeys) fmt.Fprintf(fw, "#define CIDR4_LMAP_ELEMS %d\n", maxLKeys) fmt.Fprintf(fw, "#define CIDR4_HMAP_NAME %s\n", path.Base(p.maps[prefixesV4Fix].String())) fmt.Fprintf(fw, "#define CIDR4_LMAP_NAME %s\n", path.Base(p.maps[prefixesV4Dyn].String())) fmt.Fprintf(fw, "#define CIDR6_HMAP_NAME %s\n", path.Base(p.maps[prefixesV6Fix].String())) fmt.Fprintf(fw, "#define CIDR6_LMAP_NAME %s\n", path.Base(p.maps[prefixesV6Dyn].String())) if p.config.fix4Enabled { fmt.Fprintf(fw, "#define CIDR4_FILTER\n") if p.config.dyn4Enabled { fmt.Fprintf(fw, "#define CIDR4_LPM_PREFILTER\n") } } if p.config.fix6Enabled { fmt.Fprintf(fw, "#define CIDR6_FILTER\n") if p.config.dyn6Enabled { fmt.Fprintf(fw, "#define CIDR6_LPM_PREFILTER\n") } } }
[ "func", "(", "p", "*", "PreFilter", ")", "WriteConfig", "(", "fw", "io", ".", "Writer", ")", "{", "p", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "p", ".", "mutex", ".", "RUnlock", "(", ")", "\n\n", "fmt", ".", "Fprintf", "(", "fw", "...
// WriteConfig dumps the configuration for the corresponding header file
[ "WriteConfig", "dumps", "the", "configuration", "for", "the", "corresponding", "header", "file" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/prefilter/prefilter.go#L65-L89
163,490
cilium/cilium
pkg/datapath/prefilter/prefilter.go
Dump
func (p *PreFilter) Dump(to []string) ([]string, int64) { p.mutex.RLock() defer p.mutex.RUnlock() for i := prefixesV4Dyn; i < mapCount; i++ { to = p.dumpOneMap(i, to) } return to, p.revision }
go
func (p *PreFilter) Dump(to []string) ([]string, int64) { p.mutex.RLock() defer p.mutex.RUnlock() for i := prefixesV4Dyn; i < mapCount; i++ { to = p.dumpOneMap(i, to) } return to, p.revision }
[ "func", "(", "p", "*", "PreFilter", ")", "Dump", "(", "to", "[", "]", "string", ")", "(", "[", "]", "string", ",", "int64", ")", "{", "p", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "p", ".", "mutex", ".", "RUnlock", "(", ")", "\n",...
// Dump dumps revision and CIDRs as string slice of all participating maps
[ "Dump", "dumps", "revision", "and", "CIDRs", "as", "string", "slice", "of", "all", "participating", "maps" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/prefilter/prefilter.go#L99-L106
163,491
cilium/cilium
pkg/datapath/prefilter/prefilter.go
ProbePreFilter
func ProbePreFilter(device, mode string) error { cmd := exec.Command("ip", "-force", "link", "set", "dev", device, mode, "off") if err := cmd.Start(); err != nil { return fmt.Errorf("Cannot run ip command: %v", err) } if err := cmd.Wait(); err != nil { if exiterr, ok := err.(*exec.ExitError); ok { if status, ok := exiterr.Sys().(syscall.WaitStatus); ok { switch status.ExitStatus() { case 2: return fmt.Errorf("Mode %s not supported on device %s", mode, device) default: return fmt.Errorf("Prefilter not supported on OS") } } } else { return fmt.Errorf("Cannot wait for ip command: %v", err) } } return nil }
go
func ProbePreFilter(device, mode string) error { cmd := exec.Command("ip", "-force", "link", "set", "dev", device, mode, "off") if err := cmd.Start(); err != nil { return fmt.Errorf("Cannot run ip command: %v", err) } if err := cmd.Wait(); err != nil { if exiterr, ok := err.(*exec.ExitError); ok { if status, ok := exiterr.Sys().(syscall.WaitStatus); ok { switch status.ExitStatus() { case 2: return fmt.Errorf("Mode %s not supported on device %s", mode, device) default: return fmt.Errorf("Prefilter not supported on OS") } } } else { return fmt.Errorf("Cannot wait for ip command: %v", err) } } return nil }
[ "func", "ProbePreFilter", "(", "device", ",", "mode", "string", ")", "error", "{", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "device", ",", "mode", ",", "\"", ...
// ProbePreFilter checks whether XDP mode is supported on given device
[ "ProbePreFilter", "checks", "whether", "XDP", "mode", "is", "supported", "on", "given", "device" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/prefilter/prefilter.go#L258-L278
163,492
cilium/cilium
pkg/datapath/prefilter/prefilter.go
NewPreFilter
func NewPreFilter() (*PreFilter, error) { // dyn{4,6} officially disabled for now due to missing // dump (get_next_key) from kernel side. c := preFilterConfig{ dyn4Enabled: false, dyn6Enabled: false, fix4Enabled: true, fix6Enabled: true, } p := &PreFilter{ revision: 1, config: c, } // Only needed here given we access pinned maps. p.mutex.Lock() defer p.mutex.Unlock() return p.init() }
go
func NewPreFilter() (*PreFilter, error) { // dyn{4,6} officially disabled for now due to missing // dump (get_next_key) from kernel side. c := preFilterConfig{ dyn4Enabled: false, dyn6Enabled: false, fix4Enabled: true, fix6Enabled: true, } p := &PreFilter{ revision: 1, config: c, } // Only needed here given we access pinned maps. p.mutex.Lock() defer p.mutex.Unlock() return p.init() }
[ "func", "NewPreFilter", "(", ")", "(", "*", "PreFilter", ",", "error", ")", "{", "// dyn{4,6} officially disabled for now due to missing", "// dump (get_next_key) from kernel side.", "c", ":=", "preFilterConfig", "{", "dyn4Enabled", ":", "false", ",", "dyn6Enabled", ":", ...
// NewPreFilter returns prefilter handle
[ "NewPreFilter", "returns", "prefilter", "handle" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/prefilter/prefilter.go#L281-L298
163,493
cilium/cilium
pkg/monitor/datapath_debug.go
Dump
func (n *DebugMsg) Dump(prefix string) { fmt.Printf("%s MARK %#x FROM %d DEBUG: %s\n", prefix, n.Hash, n.Source, n.subTypeString()) }
go
func (n *DebugMsg) Dump(prefix string) { fmt.Printf("%s MARK %#x FROM %d DEBUG: %s\n", prefix, n.Hash, n.Source, n.subTypeString()) }
[ "func", "(", "n", "*", "DebugMsg", ")", "Dump", "(", "prefix", "string", ")", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "prefix", ",", "n", ".", "Hash", ",", "n", ".", "Source", ",", "n", ".", "subTypeString", "(", ")", ")", "\n",...
// Dump prints the debug message in a human readable format.
[ "Dump", "prints", "the", "debug", "message", "in", "a", "human", "readable", "format", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/datapath_debug.go#L236-L238
163,494
cilium/cilium
pkg/monitor/datapath_debug.go
DumpInfo
func (n *DebugCapture) DumpInfo(data []byte) { prefix := n.infoPrefix() if len(prefix) > 0 { fmt.Printf("%s: %s\n", prefix, GetConnectionSummary(data[DebugCaptureLen:])) } }
go
func (n *DebugCapture) DumpInfo(data []byte) { prefix := n.infoPrefix() if len(prefix) > 0 { fmt.Printf("%s: %s\n", prefix, GetConnectionSummary(data[DebugCaptureLen:])) } }
[ "func", "(", "n", "*", "DebugCapture", ")", "DumpInfo", "(", "data", "[", "]", "byte", ")", "{", "prefix", ":=", "n", ".", "infoPrefix", "(", ")", "\n\n", "if", "len", "(", "prefix", ")", ">", "0", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "...
// DumpInfo prints a summary of the capture messages.
[ "DumpInfo", "prints", "a", "summary", "of", "the", "capture", "messages", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/datapath_debug.go#L398-L404
163,495
cilium/cilium
pkg/monitor/datapath_debug.go
DumpVerbose
func (n *DebugCapture) DumpVerbose(dissect bool, data []byte, prefix string) { fmt.Printf("%s MARK %#x FROM %d DEBUG: %d bytes, ", prefix, n.Hash, n.Source, n.Len) fmt.Println(n.subTypeString()) if n.Len > 0 && len(data) > DebugCaptureLen { Dissect(dissect, data[DebugCaptureLen:]) } }
go
func (n *DebugCapture) DumpVerbose(dissect bool, data []byte, prefix string) { fmt.Printf("%s MARK %#x FROM %d DEBUG: %d bytes, ", prefix, n.Hash, n.Source, n.Len) fmt.Println(n.subTypeString()) if n.Len > 0 && len(data) > DebugCaptureLen { Dissect(dissect, data[DebugCaptureLen:]) } }
[ "func", "(", "n", "*", "DebugCapture", ")", "DumpVerbose", "(", "dissect", "bool", ",", "data", "[", "]", "byte", ",", "prefix", "string", ")", "{", "fmt", ".", "Printf", "(", "\"", "\"", ",", "prefix", ",", "n", ".", "Hash", ",", "n", ".", "Sour...
// DumpVerbose prints the captured packet in human readable format
[ "DumpVerbose", "prints", "the", "captured", "packet", "in", "human", "readable", "format" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/datapath_debug.go#L428-L435
163,496
cilium/cilium
pkg/monitor/datapath_debug.go
DebugCaptureToVerbose
func DebugCaptureToVerbose(n *DebugCapture) DebugCaptureVerbose { return DebugCaptureVerbose{ Type: "capture", Mark: fmt.Sprintf("%#x", n.Hash), Source: n.Source, Bytes: n.Len, Message: n.subTypeString(), Prefix: n.infoPrefix(), } }
go
func DebugCaptureToVerbose(n *DebugCapture) DebugCaptureVerbose { return DebugCaptureVerbose{ Type: "capture", Mark: fmt.Sprintf("%#x", n.Hash), Source: n.Source, Bytes: n.Len, Message: n.subTypeString(), Prefix: n.infoPrefix(), } }
[ "func", "DebugCaptureToVerbose", "(", "n", "*", "DebugCapture", ")", "DebugCaptureVerbose", "{", "return", "DebugCaptureVerbose", "{", "Type", ":", "\"", "\"", ",", "Mark", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "n", ".", "Hash", ")", ",", "So...
// DebugCaptureToVerbose creates verbose notification from base TraceNotify
[ "DebugCaptureToVerbose", "creates", "verbose", "notification", "from", "base", "TraceNotify" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/datapath_debug.go#L495-L504
163,497
cilium/cilium
daemon/ipam.go
DumpIPAM
func (d *Daemon) DumpIPAM() *models.IPAMStatus { allocv4, allocv6 := d.ipam.Dump() status := &models.IPAMStatus{} v4 := []string{} for ip := range allocv4 { v4 = append(v4, ip) } v6 := []string{} for ip, owner := range allocv6 { v6 = append(v6, ip) // merge allocv6 into allocv4 allocv4[ip] = owner } if option.Config.EnableIPv4 { status.IPV4 = v4 } if option.Config.EnableIPv6 { status.IPV6 = v4 } status.Allocations = allocv4 return status }
go
func (d *Daemon) DumpIPAM() *models.IPAMStatus { allocv4, allocv6 := d.ipam.Dump() status := &models.IPAMStatus{} v4 := []string{} for ip := range allocv4 { v4 = append(v4, ip) } v6 := []string{} for ip, owner := range allocv6 { v6 = append(v6, ip) // merge allocv6 into allocv4 allocv4[ip] = owner } if option.Config.EnableIPv4 { status.IPV4 = v4 } if option.Config.EnableIPv6 { status.IPV6 = v4 } status.Allocations = allocv4 return status }
[ "func", "(", "d", "*", "Daemon", ")", "DumpIPAM", "(", ")", "*", "models", ".", "IPAMStatus", "{", "allocv4", ",", "allocv6", ":=", "d", ".", "ipam", ".", "Dump", "(", ")", "\n", "status", ":=", "&", "models", ".", "IPAMStatus", "{", "}", "\n\n", ...
// DumpIPAM dumps in the form of a map, the list of // reserved IPv4 and IPv6 addresses.
[ "DumpIPAM", "dumps", "in", "the", "form", "of", "a", "map", "the", "list", "of", "reserved", "IPv4", "and", "IPv6", "addresses", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/ipam.go#L104-L131
163,498
cilium/cilium
pkg/proxy/logger/epinfo.go
getEndpointInfo
func getEndpointInfo(source EndpointInfoSource) *accesslog.EndpointInfo { source.UnconditionalRLock() defer source.RUnlock() return &accesslog.EndpointInfo{ ID: source.GetID(), IPv4: source.GetIPv4Address(), IPv6: source.GetIPv6Address(), Labels: source.GetLabels(), LabelsSHA256: source.GetLabelsSHA(), Identity: uint64(source.GetIdentity()), } }
go
func getEndpointInfo(source EndpointInfoSource) *accesslog.EndpointInfo { source.UnconditionalRLock() defer source.RUnlock() return &accesslog.EndpointInfo{ ID: source.GetID(), IPv4: source.GetIPv4Address(), IPv6: source.GetIPv6Address(), Labels: source.GetLabels(), LabelsSHA256: source.GetLabelsSHA(), Identity: uint64(source.GetIdentity()), } }
[ "func", "getEndpointInfo", "(", "source", "EndpointInfoSource", ")", "*", "accesslog", ".", "EndpointInfo", "{", "source", ".", "UnconditionalRLock", "(", ")", "\n", "defer", "source", ".", "RUnlock", "(", ")", "\n", "return", "&", "accesslog", ".", "EndpointI...
// getEndpointInfo returns a consistent snapshot of the given source. // The source's read lock must not be held.
[ "getEndpointInfo", "returns", "a", "consistent", "snapshot", "of", "the", "given", "source", ".", "The", "source", "s", "read", "lock", "must", "not", "be", "held", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/logger/epinfo.go#L41-L52
163,499
cilium/cilium
pkg/policy/mapstate.go
DetermineAllowLocalhost
func (keys MapState) DetermineAllowLocalhost(l4Policy *L4Policy) { if option.Config.AlwaysAllowLocalhost() || (l4Policy != nil && l4Policy.HasRedirect()) { keys[localHostKey] = MapStateEntry{} } }
go
func (keys MapState) DetermineAllowLocalhost(l4Policy *L4Policy) { if option.Config.AlwaysAllowLocalhost() || (l4Policy != nil && l4Policy.HasRedirect()) { keys[localHostKey] = MapStateEntry{} } }
[ "func", "(", "keys", "MapState", ")", "DetermineAllowLocalhost", "(", "l4Policy", "*", "L4Policy", ")", "{", "if", "option", ".", "Config", ".", "AlwaysAllowLocalhost", "(", ")", "||", "(", "l4Policy", "!=", "nil", "&&", "l4Policy", ".", "HasRedirect", "(", ...
// DetermineAllowLocalhost determines whether communication should be allowed to // the localhost. It inserts the Key corresponding to the localhost in // the desiredPolicyKeys if the endpoint is allowed to communicate with the // localhost.
[ "DetermineAllowLocalhost", "determines", "whether", "communication", "should", "be", "allowed", "to", "the", "localhost", ".", "It", "inserts", "the", "Key", "corresponding", "to", "the", "localhost", "in", "the", "desiredPolicyKeys", "if", "the", "endpoint", "is", ...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/mapstate.go#L80-L85