id
int32 0
167k
| repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
sequencelengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
sequencelengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
163,000 | cilium/cilium | pkg/maps/ctmap/ctmap.go | LocalMaps | func LocalMaps(e CtEndpoint, ipv4, ipv6 bool) []*Map {
return maps(e, ipv4, ipv6)
} | go | func LocalMaps(e CtEndpoint, ipv4, ipv6 bool) []*Map {
return maps(e, ipv4, ipv6)
} | [
"func",
"LocalMaps",
"(",
"e",
"CtEndpoint",
",",
"ipv4",
",",
"ipv6",
"bool",
")",
"[",
"]",
"*",
"Map",
"{",
"return",
"maps",
"(",
"e",
",",
"ipv4",
",",
"ipv6",
")",
"\n",
"}"
] | // LocalMaps returns a slice of CT maps for the endpoint, which are local to
// the endpoint and not shared with other endpoints. If ipv4 or ipv6 are false,
// the maps for that protocol will not be returned.
//
// The returned maps are not yet opened. | [
"LocalMaps",
"returns",
"a",
"slice",
"of",
"CT",
"maps",
"for",
"the",
"endpoint",
"which",
"are",
"local",
"to",
"the",
"endpoint",
"and",
"not",
"shared",
"with",
"other",
"endpoints",
".",
"If",
"ipv4",
"or",
"ipv6",
"are",
"false",
"the",
"maps",
"for",
"that",
"protocol",
"will",
"not",
"be",
"returned",
".",
"The",
"returned",
"maps",
"are",
"not",
"yet",
"opened",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/ctmap/ctmap.go#L460-L462 |
163,001 | cilium/cilium | pkg/maps/ctmap/ctmap.go | WriteBPFMacros | func WriteBPFMacros(fw io.Writer, e CtEndpoint) {
var mapEntriesTCP, mapEntriesAny int
for _, m := range maps(e, true, true) {
fmt.Fprintf(fw, "#define %s %s\n", m.define, m.Name())
if m.mapType.isTCP() {
mapEntriesTCP = mapInfo[m.mapType].maxEntries
} else {
mapEntriesAny = mapInfo[m.mapType].maxEntries
}
}
fmt.Fprintf(fw, "#define CT_MAP_SIZE_TCP %d\n", mapEntriesTCP)
fmt.Fprintf(fw, "#define CT_MAP_SIZE_ANY %d\n", mapEntriesAny)
} | go | func WriteBPFMacros(fw io.Writer, e CtEndpoint) {
var mapEntriesTCP, mapEntriesAny int
for _, m := range maps(e, true, true) {
fmt.Fprintf(fw, "#define %s %s\n", m.define, m.Name())
if m.mapType.isTCP() {
mapEntriesTCP = mapInfo[m.mapType].maxEntries
} else {
mapEntriesAny = mapInfo[m.mapType].maxEntries
}
}
fmt.Fprintf(fw, "#define CT_MAP_SIZE_TCP %d\n", mapEntriesTCP)
fmt.Fprintf(fw, "#define CT_MAP_SIZE_ANY %d\n", mapEntriesAny)
} | [
"func",
"WriteBPFMacros",
"(",
"fw",
"io",
".",
"Writer",
",",
"e",
"CtEndpoint",
")",
"{",
"var",
"mapEntriesTCP",
",",
"mapEntriesAny",
"int",
"\n",
"for",
"_",
",",
"m",
":=",
"range",
"maps",
"(",
"e",
",",
"true",
",",
"true",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"fw",
",",
"\"",
"\\n",
"\"",
",",
"m",
".",
"define",
",",
"m",
".",
"Name",
"(",
")",
")",
"\n",
"if",
"m",
".",
"mapType",
".",
"isTCP",
"(",
")",
"{",
"mapEntriesTCP",
"=",
"mapInfo",
"[",
"m",
".",
"mapType",
"]",
".",
"maxEntries",
"\n",
"}",
"else",
"{",
"mapEntriesAny",
"=",
"mapInfo",
"[",
"m",
".",
"mapType",
"]",
".",
"maxEntries",
"\n",
"}",
"\n",
"}",
"\n",
"fmt",
".",
"Fprintf",
"(",
"fw",
",",
"\"",
"\\n",
"\"",
",",
"mapEntriesTCP",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"fw",
",",
"\"",
"\\n",
"\"",
",",
"mapEntriesAny",
")",
"\n",
"}"
] | // WriteBPFMacros writes the map names for conntrack maps into the specified
// writer, defining usage of the global map or local maps depending on whether
// the specified CtEndpoint is nil. | [
"WriteBPFMacros",
"writes",
"the",
"map",
"names",
"for",
"conntrack",
"maps",
"into",
"the",
"specified",
"writer",
"defining",
"usage",
"of",
"the",
"global",
"map",
"or",
"local",
"maps",
"depending",
"on",
"whether",
"the",
"specified",
"CtEndpoint",
"is",
"nil",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/ctmap/ctmap.go#L486-L498 |
163,002 | cilium/cilium | api/v1/server/restapi/prefilter/patch_prefilter_responses.go | WithPayload | func (o *PatchPrefilterOK) WithPayload(payload *models.Prefilter) *PatchPrefilterOK {
o.Payload = payload
return o
} | go | func (o *PatchPrefilterOK) WithPayload(payload *models.Prefilter) *PatchPrefilterOK {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"PatchPrefilterOK",
")",
"WithPayload",
"(",
"payload",
"*",
"models",
".",
"Prefilter",
")",
"*",
"PatchPrefilterOK",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the patch prefilter o k response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"patch",
"prefilter",
"o",
"k",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/prefilter/patch_prefilter_responses.go#L38-L41 |
163,003 | cilium/cilium | api/v1/server/restapi/prefilter/patch_prefilter_responses.go | WithPayload | func (o *PatchPrefilterInvalidCIDR) WithPayload(payload models.Error) *PatchPrefilterInvalidCIDR {
o.Payload = payload
return o
} | go | func (o *PatchPrefilterInvalidCIDR) WithPayload(payload models.Error) *PatchPrefilterInvalidCIDR {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"PatchPrefilterInvalidCIDR",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"Error",
")",
"*",
"PatchPrefilterInvalidCIDR",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the patch prefilter invalid c Id r response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"patch",
"prefilter",
"invalid",
"c",
"Id",
"r",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/prefilter/patch_prefilter_responses.go#L82-L85 |
163,004 | cilium/cilium | api/v1/server/restapi/prefilter/patch_prefilter_responses.go | WithPayload | func (o *PatchPrefilterFailure) WithPayload(payload models.Error) *PatchPrefilterFailure {
o.Payload = payload
return o
} | go | func (o *PatchPrefilterFailure) WithPayload(payload models.Error) *PatchPrefilterFailure {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"PatchPrefilterFailure",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"Error",
")",
"*",
"PatchPrefilterFailure",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the patch prefilter failure response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"patch",
"prefilter",
"failure",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/prefilter/patch_prefilter_responses.go#L124-L127 |
163,005 | cilium/cilium | api/v1/server/restapi/endpoint/get_endpoint_id_log.go | NewGetEndpointIDLog | func NewGetEndpointIDLog(ctx *middleware.Context, handler GetEndpointIDLogHandler) *GetEndpointIDLog {
return &GetEndpointIDLog{Context: ctx, Handler: handler}
} | go | func NewGetEndpointIDLog(ctx *middleware.Context, handler GetEndpointIDLogHandler) *GetEndpointIDLog {
return &GetEndpointIDLog{Context: ctx, Handler: handler}
} | [
"func",
"NewGetEndpointIDLog",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"GetEndpointIDLogHandler",
")",
"*",
"GetEndpointIDLog",
"{",
"return",
"&",
"GetEndpointIDLog",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewGetEndpointIDLog creates a new http.Handler for the get endpoint ID log operation | [
"NewGetEndpointIDLog",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"get",
"endpoint",
"ID",
"log",
"operation"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/endpoint/get_endpoint_id_log.go#L28-L30 |
163,006 | cilium/cilium | pkg/kvstore/trace.go | Trace | func Trace(format string, err error, fields logrus.Fields, a ...interface{}) {
if traceEnabled {
log.WithError(err).WithFields(fields).Debugf(format)
}
} | go | func Trace(format string, err error, fields logrus.Fields, a ...interface{}) {
if traceEnabled {
log.WithError(err).WithFields(fields).Debugf(format)
}
} | [
"func",
"Trace",
"(",
"format",
"string",
",",
"err",
"error",
",",
"fields",
"logrus",
".",
"Fields",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"traceEnabled",
"{",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"WithFields",
"(",
"fields",
")",
".",
"Debugf",
"(",
"format",
")",
"\n",
"}",
"\n",
"}"
] | // Trace is used to trace kvstore debug messages | [
"Trace",
"is",
"used",
"to",
"trace",
"kvstore",
"debug",
"messages"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/trace.go#L39-L43 |
163,007 | cilium/cilium | pkg/node/node_address.go | InitDefaultPrefix | func InitDefaultPrefix(device string) {
if option.Config.EnableIPv4 {
ip, err := firstGlobalV4Addr(device, GetInternalIPv4())
if err != nil {
return
}
if ipv4ExternalAddress == nil {
ipv4ExternalAddress = ip
}
if ipv4AllocRange == nil {
// If the IPv6AllocRange is not nil then the IPv4 allocation should be
// derived from the IPv6AllocRange.
// vvvv vvvv
// FD00:0000:0000:0000:0000:0000:0000:0000
if ipv6AllocRange != nil {
ip = net.IPv4(ipv6AllocRange.IP[8],
ipv6AllocRange.IP[9],
ipv6AllocRange.IP[10],
ipv6AllocRange.IP[11])
}
v4range := fmt.Sprintf(defaults.DefaultIPv4Prefix+"/%d",
ip.To4()[3], defaults.DefaultIPv4PrefixLen)
_, ip4net, err := net.ParseCIDR(v4range)
if err != nil {
log.WithError(err).WithField(logfields.V4Prefix, v4range).Panic("BUG: Invalid default IPv4 prefix")
}
ipv4AllocRange = cidr.NewCIDR(ip4net)
log.WithField(logfields.V4Prefix, ipv4AllocRange).Info("Using autogenerated IPv4 allocation range")
}
}
if option.Config.EnableIPv6 {
if ipv6Address == nil {
// Find a IPv6 node address first
ipv6Address, _ = firstGlobalV6Addr(device, GetIPv6Router())
if ipv6Address == nil {
ipv6Address = makeIPv6HostIP()
}
}
if ipv6AllocRange == nil && ipv4AllocRange != nil {
// The IPv6 allocation should be derived from the IPv4 allocation.
ip := ipv4AllocRange.IP
v6range := fmt.Sprintf("%s%02x%02x:%02x%02x:0:0/%d",
option.Config.IPv6ClusterAllocCIDRBase, ip[0], ip[1], ip[2], ip[3],
defaults.IPv6NodePrefixLen)
_, ip6net, err := net.ParseCIDR(v6range)
if err != nil {
log.WithError(err).WithField(logfields.V6Prefix, v6range).Panic("BUG: Invalid default IPv6 prefix")
}
ipv6AllocRange = cidr.NewCIDR(ip6net)
log.WithField(logfields.V6Prefix, ipv6AllocRange).Info("Using autogenerated IPv6 allocation range")
}
}
} | go | func InitDefaultPrefix(device string) {
if option.Config.EnableIPv4 {
ip, err := firstGlobalV4Addr(device, GetInternalIPv4())
if err != nil {
return
}
if ipv4ExternalAddress == nil {
ipv4ExternalAddress = ip
}
if ipv4AllocRange == nil {
// If the IPv6AllocRange is not nil then the IPv4 allocation should be
// derived from the IPv6AllocRange.
// vvvv vvvv
// FD00:0000:0000:0000:0000:0000:0000:0000
if ipv6AllocRange != nil {
ip = net.IPv4(ipv6AllocRange.IP[8],
ipv6AllocRange.IP[9],
ipv6AllocRange.IP[10],
ipv6AllocRange.IP[11])
}
v4range := fmt.Sprintf(defaults.DefaultIPv4Prefix+"/%d",
ip.To4()[3], defaults.DefaultIPv4PrefixLen)
_, ip4net, err := net.ParseCIDR(v4range)
if err != nil {
log.WithError(err).WithField(logfields.V4Prefix, v4range).Panic("BUG: Invalid default IPv4 prefix")
}
ipv4AllocRange = cidr.NewCIDR(ip4net)
log.WithField(logfields.V4Prefix, ipv4AllocRange).Info("Using autogenerated IPv4 allocation range")
}
}
if option.Config.EnableIPv6 {
if ipv6Address == nil {
// Find a IPv6 node address first
ipv6Address, _ = firstGlobalV6Addr(device, GetIPv6Router())
if ipv6Address == nil {
ipv6Address = makeIPv6HostIP()
}
}
if ipv6AllocRange == nil && ipv4AllocRange != nil {
// The IPv6 allocation should be derived from the IPv4 allocation.
ip := ipv4AllocRange.IP
v6range := fmt.Sprintf("%s%02x%02x:%02x%02x:0:0/%d",
option.Config.IPv6ClusterAllocCIDRBase, ip[0], ip[1], ip[2], ip[3],
defaults.IPv6NodePrefixLen)
_, ip6net, err := net.ParseCIDR(v6range)
if err != nil {
log.WithError(err).WithField(logfields.V6Prefix, v6range).Panic("BUG: Invalid default IPv6 prefix")
}
ipv6AllocRange = cidr.NewCIDR(ip6net)
log.WithField(logfields.V6Prefix, ipv6AllocRange).Info("Using autogenerated IPv6 allocation range")
}
}
} | [
"func",
"InitDefaultPrefix",
"(",
"device",
"string",
")",
"{",
"if",
"option",
".",
"Config",
".",
"EnableIPv4",
"{",
"ip",
",",
"err",
":=",
"firstGlobalV4Addr",
"(",
"device",
",",
"GetInternalIPv4",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"if",
"ipv4ExternalAddress",
"==",
"nil",
"{",
"ipv4ExternalAddress",
"=",
"ip",
"\n",
"}",
"\n\n",
"if",
"ipv4AllocRange",
"==",
"nil",
"{",
"// If the IPv6AllocRange is not nil then the IPv4 allocation should be",
"// derived from the IPv6AllocRange.",
"// vvvv vvvv",
"// FD00:0000:0000:0000:0000:0000:0000:0000",
"if",
"ipv6AllocRange",
"!=",
"nil",
"{",
"ip",
"=",
"net",
".",
"IPv4",
"(",
"ipv6AllocRange",
".",
"IP",
"[",
"8",
"]",
",",
"ipv6AllocRange",
".",
"IP",
"[",
"9",
"]",
",",
"ipv6AllocRange",
".",
"IP",
"[",
"10",
"]",
",",
"ipv6AllocRange",
".",
"IP",
"[",
"11",
"]",
")",
"\n",
"}",
"\n",
"v4range",
":=",
"fmt",
".",
"Sprintf",
"(",
"defaults",
".",
"DefaultIPv4Prefix",
"+",
"\"",
"\"",
",",
"ip",
".",
"To4",
"(",
")",
"[",
"3",
"]",
",",
"defaults",
".",
"DefaultIPv4PrefixLen",
")",
"\n",
"_",
",",
"ip4net",
",",
"err",
":=",
"net",
".",
"ParseCIDR",
"(",
"v4range",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"WithField",
"(",
"logfields",
".",
"V4Prefix",
",",
"v4range",
")",
".",
"Panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"ipv4AllocRange",
"=",
"cidr",
".",
"NewCIDR",
"(",
"ip4net",
")",
"\n",
"log",
".",
"WithField",
"(",
"logfields",
".",
"V4Prefix",
",",
"ipv4AllocRange",
")",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"option",
".",
"Config",
".",
"EnableIPv6",
"{",
"if",
"ipv6Address",
"==",
"nil",
"{",
"// Find a IPv6 node address first",
"ipv6Address",
",",
"_",
"=",
"firstGlobalV6Addr",
"(",
"device",
",",
"GetIPv6Router",
"(",
")",
")",
"\n",
"if",
"ipv6Address",
"==",
"nil",
"{",
"ipv6Address",
"=",
"makeIPv6HostIP",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"ipv6AllocRange",
"==",
"nil",
"&&",
"ipv4AllocRange",
"!=",
"nil",
"{",
"// The IPv6 allocation should be derived from the IPv4 allocation.",
"ip",
":=",
"ipv4AllocRange",
".",
"IP",
"\n",
"v6range",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"option",
".",
"Config",
".",
"IPv6ClusterAllocCIDRBase",
",",
"ip",
"[",
"0",
"]",
",",
"ip",
"[",
"1",
"]",
",",
"ip",
"[",
"2",
"]",
",",
"ip",
"[",
"3",
"]",
",",
"defaults",
".",
"IPv6NodePrefixLen",
")",
"\n\n",
"_",
",",
"ip6net",
",",
"err",
":=",
"net",
".",
"ParseCIDR",
"(",
"v6range",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"WithField",
"(",
"logfields",
".",
"V6Prefix",
",",
"v6range",
")",
".",
"Panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"ipv6AllocRange",
"=",
"cidr",
".",
"NewCIDR",
"(",
"ip6net",
")",
"\n",
"log",
".",
"WithField",
"(",
"logfields",
".",
"V6Prefix",
",",
"ipv6AllocRange",
")",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // InitDefaultPrefix initializes the node address and allocation prefixes with
// default values derived from the system. device can be set to the primary
// network device of the system in which case the first address with global
// scope will be regarded as the system's node address. | [
"InitDefaultPrefix",
"initializes",
"the",
"node",
"address",
"and",
"allocation",
"prefixes",
"with",
"default",
"values",
"derived",
"from",
"the",
"system",
".",
"device",
"can",
"be",
"set",
"to",
"the",
"primary",
"network",
"device",
"of",
"the",
"system",
"in",
"which",
"case",
"the",
"first",
"address",
"with",
"global",
"scope",
"will",
"be",
"regarded",
"as",
"the",
"system",
"s",
"node",
"address",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/node_address.go#L67-L126 |
163,008 | cilium/cilium | pkg/node/node_address.go | GetIPv4ClusterRange | func GetIPv4ClusterRange() *net.IPNet {
if ipv4AllocRange == nil {
return nil
}
mask := net.CIDRMask(ipv4ClusterCidrMaskSize, 32)
return &net.IPNet{
IP: ipv4AllocRange.IPNet.IP.Mask(mask),
Mask: mask,
}
} | go | func GetIPv4ClusterRange() *net.IPNet {
if ipv4AllocRange == nil {
return nil
}
mask := net.CIDRMask(ipv4ClusterCidrMaskSize, 32)
return &net.IPNet{
IP: ipv4AllocRange.IPNet.IP.Mask(mask),
Mask: mask,
}
} | [
"func",
"GetIPv4ClusterRange",
"(",
")",
"*",
"net",
".",
"IPNet",
"{",
"if",
"ipv4AllocRange",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"mask",
":=",
"net",
".",
"CIDRMask",
"(",
"ipv4ClusterCidrMaskSize",
",",
"32",
")",
"\n",
"return",
"&",
"net",
".",
"IPNet",
"{",
"IP",
":",
"ipv4AllocRange",
".",
"IPNet",
".",
"IP",
".",
"Mask",
"(",
"mask",
")",
",",
"Mask",
":",
"mask",
",",
"}",
"\n",
"}"
] | // GetIPv4ClusterRange returns the IPv4 prefix of the cluster | [
"GetIPv4ClusterRange",
"returns",
"the",
"IPv4",
"prefix",
"of",
"the",
"cluster"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/node_address.go#L129-L139 |
163,009 | cilium/cilium | pkg/node/node_address.go | GetIPv6AllocRange | func GetIPv6AllocRange() *cidr.CIDR {
if ipv6AllocRange == nil {
return nil
}
mask := net.CIDRMask(defaults.IPv6NodeAllocPrefixLen, 128)
return cidr.NewCIDR(&net.IPNet{
IP: ipv6AllocRange.IPNet.IP.Mask(mask),
Mask: mask,
})
} | go | func GetIPv6AllocRange() *cidr.CIDR {
if ipv6AllocRange == nil {
return nil
}
mask := net.CIDRMask(defaults.IPv6NodeAllocPrefixLen, 128)
return cidr.NewCIDR(&net.IPNet{
IP: ipv6AllocRange.IPNet.IP.Mask(mask),
Mask: mask,
})
} | [
"func",
"GetIPv6AllocRange",
"(",
")",
"*",
"cidr",
".",
"CIDR",
"{",
"if",
"ipv6AllocRange",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"mask",
":=",
"net",
".",
"CIDRMask",
"(",
"defaults",
".",
"IPv6NodeAllocPrefixLen",
",",
"128",
")",
"\n",
"return",
"cidr",
".",
"NewCIDR",
"(",
"&",
"net",
".",
"IPNet",
"{",
"IP",
":",
"ipv6AllocRange",
".",
"IPNet",
".",
"IP",
".",
"Mask",
"(",
"mask",
")",
",",
"Mask",
":",
"mask",
",",
"}",
")",
"\n",
"}"
] | // GetIPv6AllocRange returns the IPv6 allocation prefix of this node | [
"GetIPv6AllocRange",
"returns",
"the",
"IPv6",
"allocation",
"prefix",
"of",
"this",
"node"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/node_address.go#L157-L167 |
163,010 | cilium/cilium | pkg/node/node_address.go | SetIPv6NodeRange | func SetIPv6NodeRange(net *net.IPNet) error {
if ones, _ := net.Mask.Size(); ones != defaults.IPv6NodePrefixLen {
return fmt.Errorf("prefix length must be /%d", defaults.IPv6NodePrefixLen)
}
copy := *net
ipv6AllocRange = cidr.NewCIDR(©)
return nil
} | go | func SetIPv6NodeRange(net *net.IPNet) error {
if ones, _ := net.Mask.Size(); ones != defaults.IPv6NodePrefixLen {
return fmt.Errorf("prefix length must be /%d", defaults.IPv6NodePrefixLen)
}
copy := *net
ipv6AllocRange = cidr.NewCIDR(©)
return nil
} | [
"func",
"SetIPv6NodeRange",
"(",
"net",
"*",
"net",
".",
"IPNet",
")",
"error",
"{",
"if",
"ones",
",",
"_",
":=",
"net",
".",
"Mask",
".",
"Size",
"(",
")",
";",
"ones",
"!=",
"defaults",
".",
"IPv6NodePrefixLen",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"defaults",
".",
"IPv6NodePrefixLen",
")",
"\n",
"}",
"\n\n",
"copy",
":=",
"*",
"net",
"\n",
"ipv6AllocRange",
"=",
"cidr",
".",
"NewCIDR",
"(",
"&",
"copy",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // SetIPv6NodeRange sets the IPv6 address pool to be used on this node | [
"SetIPv6NodeRange",
"sets",
"the",
"IPv6",
"address",
"pool",
"to",
"be",
"used",
"on",
"this",
"node"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/node_address.go#L214-L223 |
163,011 | cilium/cilium | pkg/node/node_address.go | AutoComplete | func AutoComplete() error {
if option.Config.EnableHostIPRestore {
// Read the previous cilium host IPs from node_config.h for backward
// compatibility
ipv4GW, ipv6Router := getCiliumHostIPs()
if ipv4GW != nil && option.Config.EnableIPv4 {
log.Infof("Restored IPv4 internal node IP: %s", ipv4GW.String())
SetInternalIPv4(ipv4GW)
}
if ipv6Router != nil && option.Config.EnableIPv6 {
log.Infof("Restored IPv6 router IP: %s", ipv6Router.String())
SetIPv6Router(ipv6Router)
}
}
if option.Config.Device == "undefined" {
InitDefaultPrefix("")
}
if option.Config.EnableIPv6 && ipv6AllocRange == nil {
return fmt.Errorf("IPv6 allocation CIDR is not configured. Please specificy --ipv6-range")
}
if option.Config.EnableIPv4 && ipv4AllocRange == nil {
return fmt.Errorf("IPv4 allocation CIDR is not configured. Please specificy --ipv4-range")
}
return nil
} | go | func AutoComplete() error {
if option.Config.EnableHostIPRestore {
// Read the previous cilium host IPs from node_config.h for backward
// compatibility
ipv4GW, ipv6Router := getCiliumHostIPs()
if ipv4GW != nil && option.Config.EnableIPv4 {
log.Infof("Restored IPv4 internal node IP: %s", ipv4GW.String())
SetInternalIPv4(ipv4GW)
}
if ipv6Router != nil && option.Config.EnableIPv6 {
log.Infof("Restored IPv6 router IP: %s", ipv6Router.String())
SetIPv6Router(ipv6Router)
}
}
if option.Config.Device == "undefined" {
InitDefaultPrefix("")
}
if option.Config.EnableIPv6 && ipv6AllocRange == nil {
return fmt.Errorf("IPv6 allocation CIDR is not configured. Please specificy --ipv6-range")
}
if option.Config.EnableIPv4 && ipv4AllocRange == nil {
return fmt.Errorf("IPv4 allocation CIDR is not configured. Please specificy --ipv4-range")
}
return nil
} | [
"func",
"AutoComplete",
"(",
")",
"error",
"{",
"if",
"option",
".",
"Config",
".",
"EnableHostIPRestore",
"{",
"// Read the previous cilium host IPs from node_config.h for backward",
"// compatibility",
"ipv4GW",
",",
"ipv6Router",
":=",
"getCiliumHostIPs",
"(",
")",
"\n\n",
"if",
"ipv4GW",
"!=",
"nil",
"&&",
"option",
".",
"Config",
".",
"EnableIPv4",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"ipv4GW",
".",
"String",
"(",
")",
")",
"\n",
"SetInternalIPv4",
"(",
"ipv4GW",
")",
"\n",
"}",
"\n\n",
"if",
"ipv6Router",
"!=",
"nil",
"&&",
"option",
".",
"Config",
".",
"EnableIPv6",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"ipv6Router",
".",
"String",
"(",
")",
")",
"\n",
"SetIPv6Router",
"(",
"ipv6Router",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"option",
".",
"Config",
".",
"Device",
"==",
"\"",
"\"",
"{",
"InitDefaultPrefix",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"option",
".",
"Config",
".",
"EnableIPv6",
"&&",
"ipv6AllocRange",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"option",
".",
"Config",
".",
"EnableIPv4",
"&&",
"ipv4AllocRange",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // AutoComplete completes the parts of addressing that can be auto derived | [
"AutoComplete",
"completes",
"the",
"parts",
"of",
"addressing",
"that",
"can",
"be",
"auto",
"derived"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/node_address.go#L226-L256 |
163,012 | cilium/cilium | pkg/node/node_address.go | ValidatePostInit | func ValidatePostInit() error {
if option.Config.EnableIPv4 || option.Config.Tunnel != option.TunnelDisabled {
if ipv4ExternalAddress == nil {
return fmt.Errorf("External IPv4 node address could not be derived, please configure via --ipv4-node")
}
}
if option.Config.EnableIPv4 {
if ipv4InternalAddress == nil {
return fmt.Errorf("BUG: Internal IPv4 node address was not configured")
}
if !ipv4AllocRange.Contains(ipv4InternalAddress) {
return fmt.Errorf("BUG: Internal IPv4 (%s) must be part of cluster prefix (%s)",
ipv4InternalAddress, ipv4AllocRange)
}
ones, _ := ipv4AllocRange.Mask.Size()
if ipv4ClusterCidrMaskSize > ones {
return fmt.Errorf("IPv4 per node allocation prefix (%s) must be inside cluster prefix (%s)",
ipv4AllocRange, GetIPv4ClusterRange())
}
}
return nil
} | go | func ValidatePostInit() error {
if option.Config.EnableIPv4 || option.Config.Tunnel != option.TunnelDisabled {
if ipv4ExternalAddress == nil {
return fmt.Errorf("External IPv4 node address could not be derived, please configure via --ipv4-node")
}
}
if option.Config.EnableIPv4 {
if ipv4InternalAddress == nil {
return fmt.Errorf("BUG: Internal IPv4 node address was not configured")
}
if !ipv4AllocRange.Contains(ipv4InternalAddress) {
return fmt.Errorf("BUG: Internal IPv4 (%s) must be part of cluster prefix (%s)",
ipv4InternalAddress, ipv4AllocRange)
}
ones, _ := ipv4AllocRange.Mask.Size()
if ipv4ClusterCidrMaskSize > ones {
return fmt.Errorf("IPv4 per node allocation prefix (%s) must be inside cluster prefix (%s)",
ipv4AllocRange, GetIPv4ClusterRange())
}
}
return nil
} | [
"func",
"ValidatePostInit",
"(",
")",
"error",
"{",
"if",
"option",
".",
"Config",
".",
"EnableIPv4",
"||",
"option",
".",
"Config",
".",
"Tunnel",
"!=",
"option",
".",
"TunnelDisabled",
"{",
"if",
"ipv4ExternalAddress",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"option",
".",
"Config",
".",
"EnableIPv4",
"{",
"if",
"ipv4InternalAddress",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"ipv4AllocRange",
".",
"Contains",
"(",
"ipv4InternalAddress",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ipv4InternalAddress",
",",
"ipv4AllocRange",
")",
"\n",
"}",
"\n\n",
"ones",
",",
"_",
":=",
"ipv4AllocRange",
".",
"Mask",
".",
"Size",
"(",
")",
"\n",
"if",
"ipv4ClusterCidrMaskSize",
">",
"ones",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ipv4AllocRange",
",",
"GetIPv4ClusterRange",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // ValidatePostInit validates the entire addressing setup and completes it as
// required | [
"ValidatePostInit",
"validates",
"the",
"entire",
"addressing",
"setup",
"and",
"completes",
"it",
"as",
"required"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/node_address.go#L260-L285 |
163,013 | cilium/cilium | pkg/node/node_address.go | IsHostIPv4 | func IsHostIPv4(ip net.IP) bool {
return ip.Equal(GetInternalIPv4()) || ip.Equal(GetExternalIPv4())
} | go | func IsHostIPv4(ip net.IP) bool {
return ip.Equal(GetInternalIPv4()) || ip.Equal(GetExternalIPv4())
} | [
"func",
"IsHostIPv4",
"(",
"ip",
"net",
".",
"IP",
")",
"bool",
"{",
"return",
"ip",
".",
"Equal",
"(",
"GetInternalIPv4",
"(",
")",
")",
"||",
"ip",
".",
"Equal",
"(",
"GetExternalIPv4",
"(",
")",
")",
"\n",
"}"
] | // IsHostIPv4 returns true if the IP specified is a host IP | [
"IsHostIPv4",
"returns",
"true",
"if",
"the",
"IP",
"specified",
"is",
"a",
"host",
"IP"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/node_address.go#L308-L310 |
163,014 | cilium/cilium | pkg/node/node_address.go | IsHostIPv6 | func IsHostIPv6(ip net.IP) bool {
return ip.Equal(GetIPv6()) || ip.Equal(GetIPv6Router())
} | go | func IsHostIPv6(ip net.IP) bool {
return ip.Equal(GetIPv6()) || ip.Equal(GetIPv6Router())
} | [
"func",
"IsHostIPv6",
"(",
"ip",
"net",
".",
"IP",
")",
"bool",
"{",
"return",
"ip",
".",
"Equal",
"(",
"GetIPv6",
"(",
")",
")",
"||",
"ip",
".",
"Equal",
"(",
"GetIPv6Router",
"(",
")",
")",
"\n",
"}"
] | // IsHostIPv6 returns true if the IP specified is a host IP | [
"IsHostIPv6",
"returns",
"true",
"if",
"the",
"IP",
"specified",
"is",
"a",
"host",
"IP"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/node_address.go#L313-L315 |
163,015 | cilium/cilium | pkg/node/node_address.go | GetNodeAddressing | func GetNodeAddressing() *models.NodeAddressing {
a := &models.NodeAddressing{}
if option.Config.EnableIPv6 {
a.IPV6 = &models.NodeAddressingElement{
Enabled: option.Config.EnableIPv6,
IP: GetIPv6Router().String(),
AllocRange: GetIPv6AllocRange().String(),
}
}
if option.Config.EnableIPv4 {
a.IPV4 = &models.NodeAddressingElement{
Enabled: option.Config.EnableIPv4,
IP: GetInternalIPv4().String(),
AllocRange: GetIPv4AllocRange().String(),
}
}
return a
} | go | func GetNodeAddressing() *models.NodeAddressing {
a := &models.NodeAddressing{}
if option.Config.EnableIPv6 {
a.IPV6 = &models.NodeAddressingElement{
Enabled: option.Config.EnableIPv6,
IP: GetIPv6Router().String(),
AllocRange: GetIPv6AllocRange().String(),
}
}
if option.Config.EnableIPv4 {
a.IPV4 = &models.NodeAddressingElement{
Enabled: option.Config.EnableIPv4,
IP: GetInternalIPv4().String(),
AllocRange: GetIPv4AllocRange().String(),
}
}
return a
} | [
"func",
"GetNodeAddressing",
"(",
")",
"*",
"models",
".",
"NodeAddressing",
"{",
"a",
":=",
"&",
"models",
".",
"NodeAddressing",
"{",
"}",
"\n\n",
"if",
"option",
".",
"Config",
".",
"EnableIPv6",
"{",
"a",
".",
"IPV6",
"=",
"&",
"models",
".",
"NodeAddressingElement",
"{",
"Enabled",
":",
"option",
".",
"Config",
".",
"EnableIPv6",
",",
"IP",
":",
"GetIPv6Router",
"(",
")",
".",
"String",
"(",
")",
",",
"AllocRange",
":",
"GetIPv6AllocRange",
"(",
")",
".",
"String",
"(",
")",
",",
"}",
"\n",
"}",
"\n\n",
"if",
"option",
".",
"Config",
".",
"EnableIPv4",
"{",
"a",
".",
"IPV4",
"=",
"&",
"models",
".",
"NodeAddressingElement",
"{",
"Enabled",
":",
"option",
".",
"Config",
".",
"EnableIPv4",
",",
"IP",
":",
"GetInternalIPv4",
"(",
")",
".",
"String",
"(",
")",
",",
"AllocRange",
":",
"GetIPv4AllocRange",
"(",
")",
".",
"String",
"(",
")",
",",
"}",
"\n",
"}",
"\n\n",
"return",
"a",
"\n",
"}"
] | // GetNodeAddressing returns the NodeAddressing model for the local IPs. | [
"GetNodeAddressing",
"returns",
"the",
"NodeAddressing",
"model",
"for",
"the",
"local",
"IPs",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/node_address.go#L318-L338 |
163,016 | cilium/cilium | pkg/node/node_address.go | getCiliumHostIPs | func getCiliumHostIPs() (ipv4GW, ipv6Router net.IP) {
nodeConfig := option.Config.GetNodeConfigPath()
ipv4GW, ipv6Router = getCiliumHostIPsFromFile(nodeConfig)
if ipv4GW != nil {
return ipv4GW, ipv6Router
}
return getCiliumHostIPsFromNetDev(option.Config.HostDevice)
} | go | func getCiliumHostIPs() (ipv4GW, ipv6Router net.IP) {
nodeConfig := option.Config.GetNodeConfigPath()
ipv4GW, ipv6Router = getCiliumHostIPsFromFile(nodeConfig)
if ipv4GW != nil {
return ipv4GW, ipv6Router
}
return getCiliumHostIPsFromNetDev(option.Config.HostDevice)
} | [
"func",
"getCiliumHostIPs",
"(",
")",
"(",
"ipv4GW",
",",
"ipv6Router",
"net",
".",
"IP",
")",
"{",
"nodeConfig",
":=",
"option",
".",
"Config",
".",
"GetNodeConfigPath",
"(",
")",
"\n",
"ipv4GW",
",",
"ipv6Router",
"=",
"getCiliumHostIPsFromFile",
"(",
"nodeConfig",
")",
"\n",
"if",
"ipv4GW",
"!=",
"nil",
"{",
"return",
"ipv4GW",
",",
"ipv6Router",
"\n",
"}",
"\n",
"return",
"getCiliumHostIPsFromNetDev",
"(",
"option",
".",
"Config",
".",
"HostDevice",
")",
"\n",
"}"
] | // getCiliumHostIPs returns the Cilium IPv4 gateway and router IPv6 address from
// the node_config.h file if is present; or by deriving it from
// defaults.HostDevice interface, on which only the IPv4 is possible to derive. | [
"getCiliumHostIPs",
"returns",
"the",
"Cilium",
"IPv4",
"gateway",
"and",
"router",
"IPv6",
"address",
"from",
"the",
"node_config",
".",
"h",
"file",
"if",
"is",
"present",
";",
"or",
"by",
"deriving",
"it",
"from",
"defaults",
".",
"HostDevice",
"interface",
"on",
"which",
"only",
"the",
"IPv4",
"is",
"possible",
"to",
"derive",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/node_address.go#L386-L393 |
163,017 | cilium/cilium | pkg/service/id.go | AcquireID | func AcquireID(l3n4Addr loadbalancer.L3n4Addr, baseID uint32) (*loadbalancer.L3n4AddrID, error) {
log.WithField(logfields.L3n4Addr, logfields.Repr(l3n4Addr)).Debug("Resolving service")
if enableGlobalServiceIDs {
return acquireGlobalID(l3n4Addr, baseID)
}
return serviceIDAlloc.acquireLocalID(l3n4Addr, baseID)
} | go | func AcquireID(l3n4Addr loadbalancer.L3n4Addr, baseID uint32) (*loadbalancer.L3n4AddrID, error) {
log.WithField(logfields.L3n4Addr, logfields.Repr(l3n4Addr)).Debug("Resolving service")
if enableGlobalServiceIDs {
return acquireGlobalID(l3n4Addr, baseID)
}
return serviceIDAlloc.acquireLocalID(l3n4Addr, baseID)
} | [
"func",
"AcquireID",
"(",
"l3n4Addr",
"loadbalancer",
".",
"L3n4Addr",
",",
"baseID",
"uint32",
")",
"(",
"*",
"loadbalancer",
".",
"L3n4AddrID",
",",
"error",
")",
"{",
"log",
".",
"WithField",
"(",
"logfields",
".",
"L3n4Addr",
",",
"logfields",
".",
"Repr",
"(",
"l3n4Addr",
")",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"enableGlobalServiceIDs",
"{",
"return",
"acquireGlobalID",
"(",
"l3n4Addr",
",",
"baseID",
")",
"\n",
"}",
"\n\n",
"return",
"serviceIDAlloc",
".",
"acquireLocalID",
"(",
"l3n4Addr",
",",
"baseID",
")",
"\n",
"}"
] | // AcquireID acquires a service ID | [
"AcquireID",
"acquires",
"a",
"service",
"ID"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/service/id.go#L25-L33 |
163,018 | cilium/cilium | pkg/service/id.go | GetID | func GetID(id uint32) (*loadbalancer.L3n4AddrID, error) {
if enableGlobalServiceIDs {
return getGlobalID(id)
}
return serviceIDAlloc.getLocalID(id)
} | go | func GetID(id uint32) (*loadbalancer.L3n4AddrID, error) {
if enableGlobalServiceIDs {
return getGlobalID(id)
}
return serviceIDAlloc.getLocalID(id)
} | [
"func",
"GetID",
"(",
"id",
"uint32",
")",
"(",
"*",
"loadbalancer",
".",
"L3n4AddrID",
",",
"error",
")",
"{",
"if",
"enableGlobalServiceIDs",
"{",
"return",
"getGlobalID",
"(",
"id",
")",
"\n",
"}",
"\n\n",
"return",
"serviceIDAlloc",
".",
"getLocalID",
"(",
"id",
")",
"\n",
"}"
] | // GetID returns the L3n4AddrID that belongs to the given id. | [
"GetID",
"returns",
"the",
"L3n4AddrID",
"that",
"belongs",
"to",
"the",
"given",
"id",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/service/id.go#L50-L56 |
163,019 | cilium/cilium | pkg/service/id.go | DeleteID | func DeleteID(id uint32) error {
log.WithField(logfields.L3n4AddrID, id).Debug("deleting L3n4Addr by ID")
if enableGlobalServiceIDs {
return deleteGlobalID(id)
}
return serviceIDAlloc.deleteLocalID(id)
} | go | func DeleteID(id uint32) error {
log.WithField(logfields.L3n4AddrID, id).Debug("deleting L3n4Addr by ID")
if enableGlobalServiceIDs {
return deleteGlobalID(id)
}
return serviceIDAlloc.deleteLocalID(id)
} | [
"func",
"DeleteID",
"(",
"id",
"uint32",
")",
"error",
"{",
"log",
".",
"WithField",
"(",
"logfields",
".",
"L3n4AddrID",
",",
"id",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"enableGlobalServiceIDs",
"{",
"return",
"deleteGlobalID",
"(",
"id",
")",
"\n",
"}",
"\n\n",
"return",
"serviceIDAlloc",
".",
"deleteLocalID",
"(",
"id",
")",
"\n",
"}"
] | // DeleteID deletes the L3n4AddrID belonging to the given id from the kvstore. | [
"DeleteID",
"deletes",
"the",
"L3n4AddrID",
"belonging",
"to",
"the",
"given",
"id",
"from",
"the",
"kvstore",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/service/id.go#L59-L67 |
163,020 | cilium/cilium | pkg/service/id.go | LookupBackendID | func LookupBackendID(l3n4Addr loadbalancer.L3n4Addr) (loadbalancer.BackendID, error) {
id, err := backendIDAlloc.lookupLocalID(l3n4Addr)
return loadbalancer.BackendID(id), err
} | go | func LookupBackendID(l3n4Addr loadbalancer.L3n4Addr) (loadbalancer.BackendID, error) {
id, err := backendIDAlloc.lookupLocalID(l3n4Addr)
return loadbalancer.BackendID(id), err
} | [
"func",
"LookupBackendID",
"(",
"l3n4Addr",
"loadbalancer",
".",
"L3n4Addr",
")",
"(",
"loadbalancer",
".",
"BackendID",
",",
"error",
")",
"{",
"id",
",",
"err",
":=",
"backendIDAlloc",
".",
"lookupLocalID",
"(",
"l3n4Addr",
")",
"\n",
"return",
"loadbalancer",
".",
"BackendID",
"(",
"id",
")",
",",
"err",
"\n",
"}"
] | // LookupBackendID looks up already allocated backend ID for the given backend
// addr. If such cannot be found, returns an error. | [
"LookupBackendID",
"looks",
"up",
"already",
"allocated",
"backend",
"ID",
"for",
"the",
"given",
"backend",
"addr",
".",
"If",
"such",
"cannot",
"be",
"found",
"returns",
"an",
"error",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/service/id.go#L118-L121 |
163,021 | cilium/cilium | pkg/k8s/metrics/metrics.go | Reset | func (e *eventTimestamper) Reset() {
e.lock.Lock()
e.timestamp = time.Now()
e.lock.Unlock()
} | go | func (e *eventTimestamper) Reset() {
e.lock.Lock()
e.timestamp = time.Now()
e.lock.Unlock()
} | [
"func",
"(",
"e",
"*",
"eventTimestamper",
")",
"Reset",
"(",
")",
"{",
"e",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"e",
".",
"timestamp",
"=",
"time",
".",
"Now",
"(",
")",
"\n",
"e",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // Reset sets the timestamp to the current time | [
"Reset",
"sets",
"the",
"timestamp",
"to",
"the",
"current",
"time"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/metrics/metrics.go#L35-L39 |
163,022 | cilium/cilium | plugins/cilium-docker/driver/driver.go | NewDriver | func NewDriver(url string) (Driver, error) {
if url == "" {
url = client.DefaultSockPath()
}
scopedLog := log.WithField("url", url)
c, err := client.NewClient(url)
if err != nil {
scopedLog.WithError(err).Fatal("Error while starting cilium-client")
}
d := &driver{client: c}
for tries := 0; tries < 24; tries++ {
if res, err := c.ConfigGet(); err != nil {
if tries == 23 {
scopedLog.WithError(err).Fatal("Unable to connect to cilium daemon")
} else {
scopedLog.Info("Waiting for cilium daemon to start up...")
}
time.Sleep(time.Duration(tries) * time.Second)
} else {
if res.Status.Addressing == nil || (res.Status.Addressing.IPV4 == nil && res.Status.Addressing.IPV6 == nil) {
scopedLog.Fatal("Invalid addressing information from daemon")
}
d.conf = *res.Status
break
}
}
if err := connector.SufficientAddressing(d.conf.Addressing); err != nil {
scopedLog.WithError(err).Fatal("Insufficient addressing")
}
d.updateRoutes(nil)
log.Infof("Cilium Docker plugin ready")
return d, nil
} | go | func NewDriver(url string) (Driver, error) {
if url == "" {
url = client.DefaultSockPath()
}
scopedLog := log.WithField("url", url)
c, err := client.NewClient(url)
if err != nil {
scopedLog.WithError(err).Fatal("Error while starting cilium-client")
}
d := &driver{client: c}
for tries := 0; tries < 24; tries++ {
if res, err := c.ConfigGet(); err != nil {
if tries == 23 {
scopedLog.WithError(err).Fatal("Unable to connect to cilium daemon")
} else {
scopedLog.Info("Waiting for cilium daemon to start up...")
}
time.Sleep(time.Duration(tries) * time.Second)
} else {
if res.Status.Addressing == nil || (res.Status.Addressing.IPV4 == nil && res.Status.Addressing.IPV6 == nil) {
scopedLog.Fatal("Invalid addressing information from daemon")
}
d.conf = *res.Status
break
}
}
if err := connector.SufficientAddressing(d.conf.Addressing); err != nil {
scopedLog.WithError(err).Fatal("Insufficient addressing")
}
d.updateRoutes(nil)
log.Infof("Cilium Docker plugin ready")
return d, nil
} | [
"func",
"NewDriver",
"(",
"url",
"string",
")",
"(",
"Driver",
",",
"error",
")",
"{",
"if",
"url",
"==",
"\"",
"\"",
"{",
"url",
"=",
"client",
".",
"DefaultSockPath",
"(",
")",
"\n",
"}",
"\n\n",
"scopedLog",
":=",
"log",
".",
"WithField",
"(",
"\"",
"\"",
",",
"url",
")",
"\n",
"c",
",",
"err",
":=",
"client",
".",
"NewClient",
"(",
"url",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"scopedLog",
".",
"WithError",
"(",
"err",
")",
".",
"Fatal",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"d",
":=",
"&",
"driver",
"{",
"client",
":",
"c",
"}",
"\n\n",
"for",
"tries",
":=",
"0",
";",
"tries",
"<",
"24",
";",
"tries",
"++",
"{",
"if",
"res",
",",
"err",
":=",
"c",
".",
"ConfigGet",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"tries",
"==",
"23",
"{",
"scopedLog",
".",
"WithError",
"(",
"err",
")",
".",
"Fatal",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"scopedLog",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"time",
".",
"Sleep",
"(",
"time",
".",
"Duration",
"(",
"tries",
")",
"*",
"time",
".",
"Second",
")",
"\n",
"}",
"else",
"{",
"if",
"res",
".",
"Status",
".",
"Addressing",
"==",
"nil",
"||",
"(",
"res",
".",
"Status",
".",
"Addressing",
".",
"IPV4",
"==",
"nil",
"&&",
"res",
".",
"Status",
".",
"Addressing",
".",
"IPV6",
"==",
"nil",
")",
"{",
"scopedLog",
".",
"Fatal",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"d",
".",
"conf",
"=",
"*",
"res",
".",
"Status",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"connector",
".",
"SufficientAddressing",
"(",
"d",
".",
"conf",
".",
"Addressing",
")",
";",
"err",
"!=",
"nil",
"{",
"scopedLog",
".",
"WithError",
"(",
"err",
")",
".",
"Fatal",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"d",
".",
"updateRoutes",
"(",
"nil",
")",
"\n\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n\n",
"return",
"d",
",",
"nil",
"\n",
"}"
] | // NewDriver creates and returns a new Driver for the given API URL.
// If url is nil then use SockPath provided by CILIUM_SOCK
// or the cilium default SockPath | [
"NewDriver",
"creates",
"and",
"returns",
"a",
"new",
"Driver",
"for",
"the",
"given",
"API",
"URL",
".",
"If",
"url",
"is",
"nil",
"then",
"use",
"SockPath",
"provided",
"by",
"CILIUM_SOCK",
"or",
"the",
"cilium",
"default",
"SockPath"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/plugins/cilium-docker/driver/driver.go#L85-L126 |
163,023 | cilium/cilium | plugins/cilium-docker/driver/driver.go | Listen | func (driver *driver) Listen(socket string) error {
router := mux.NewRouter()
router.NotFoundHandler = http.HandlerFunc(notFound)
handleMethod := func(method string, h http.HandlerFunc) {
router.Methods("POST").Path(fmt.Sprintf("/%s", method)).HandlerFunc(h)
}
handleMethod("Plugin.Activate", driver.handshake)
handleMethod("NetworkDriver.GetCapabilities", driver.capabilities)
handleMethod("NetworkDriver.CreateNetwork", driver.createNetwork)
handleMethod("NetworkDriver.DeleteNetwork", driver.deleteNetwork)
handleMethod("NetworkDriver.CreateEndpoint", driver.createEndpoint)
handleMethod("NetworkDriver.DeleteEndpoint", driver.deleteEndpoint)
handleMethod("NetworkDriver.EndpointOperInfo", driver.infoEndpoint)
handleMethod("NetworkDriver.Join", driver.joinEndpoint)
handleMethod("NetworkDriver.Leave", driver.leaveEndpoint)
handleMethod("IpamDriver.GetCapabilities", driver.ipamCapabilities)
handleMethod("IpamDriver.GetDefaultAddressSpaces", driver.getDefaultAddressSpaces)
handleMethod("IpamDriver.RequestPool", driver.requestPool)
handleMethod("IpamDriver.ReleasePool", driver.releasePool)
handleMethod("IpamDriver.RequestAddress", driver.requestAddress)
handleMethod("IpamDriver.ReleaseAddress", driver.releaseAddress)
listener, err := net.Listen("unix", socket)
if err != nil {
return err
}
return http.Serve(listener, router)
} | go | func (driver *driver) Listen(socket string) error {
router := mux.NewRouter()
router.NotFoundHandler = http.HandlerFunc(notFound)
handleMethod := func(method string, h http.HandlerFunc) {
router.Methods("POST").Path(fmt.Sprintf("/%s", method)).HandlerFunc(h)
}
handleMethod("Plugin.Activate", driver.handshake)
handleMethod("NetworkDriver.GetCapabilities", driver.capabilities)
handleMethod("NetworkDriver.CreateNetwork", driver.createNetwork)
handleMethod("NetworkDriver.DeleteNetwork", driver.deleteNetwork)
handleMethod("NetworkDriver.CreateEndpoint", driver.createEndpoint)
handleMethod("NetworkDriver.DeleteEndpoint", driver.deleteEndpoint)
handleMethod("NetworkDriver.EndpointOperInfo", driver.infoEndpoint)
handleMethod("NetworkDriver.Join", driver.joinEndpoint)
handleMethod("NetworkDriver.Leave", driver.leaveEndpoint)
handleMethod("IpamDriver.GetCapabilities", driver.ipamCapabilities)
handleMethod("IpamDriver.GetDefaultAddressSpaces", driver.getDefaultAddressSpaces)
handleMethod("IpamDriver.RequestPool", driver.requestPool)
handleMethod("IpamDriver.ReleasePool", driver.releasePool)
handleMethod("IpamDriver.RequestAddress", driver.requestAddress)
handleMethod("IpamDriver.ReleaseAddress", driver.releaseAddress)
listener, err := net.Listen("unix", socket)
if err != nil {
return err
}
return http.Serve(listener, router)
} | [
"func",
"(",
"driver",
"*",
"driver",
")",
"Listen",
"(",
"socket",
"string",
")",
"error",
"{",
"router",
":=",
"mux",
".",
"NewRouter",
"(",
")",
"\n",
"router",
".",
"NotFoundHandler",
"=",
"http",
".",
"HandlerFunc",
"(",
"notFound",
")",
"\n\n",
"handleMethod",
":=",
"func",
"(",
"method",
"string",
",",
"h",
"http",
".",
"HandlerFunc",
")",
"{",
"router",
".",
"Methods",
"(",
"\"",
"\"",
")",
".",
"Path",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"method",
")",
")",
".",
"HandlerFunc",
"(",
"h",
")",
"\n",
"}",
"\n\n",
"handleMethod",
"(",
"\"",
"\"",
",",
"driver",
".",
"handshake",
")",
"\n",
"handleMethod",
"(",
"\"",
"\"",
",",
"driver",
".",
"capabilities",
")",
"\n",
"handleMethod",
"(",
"\"",
"\"",
",",
"driver",
".",
"createNetwork",
")",
"\n",
"handleMethod",
"(",
"\"",
"\"",
",",
"driver",
".",
"deleteNetwork",
")",
"\n",
"handleMethod",
"(",
"\"",
"\"",
",",
"driver",
".",
"createEndpoint",
")",
"\n",
"handleMethod",
"(",
"\"",
"\"",
",",
"driver",
".",
"deleteEndpoint",
")",
"\n",
"handleMethod",
"(",
"\"",
"\"",
",",
"driver",
".",
"infoEndpoint",
")",
"\n",
"handleMethod",
"(",
"\"",
"\"",
",",
"driver",
".",
"joinEndpoint",
")",
"\n",
"handleMethod",
"(",
"\"",
"\"",
",",
"driver",
".",
"leaveEndpoint",
")",
"\n",
"handleMethod",
"(",
"\"",
"\"",
",",
"driver",
".",
"ipamCapabilities",
")",
"\n",
"handleMethod",
"(",
"\"",
"\"",
",",
"driver",
".",
"getDefaultAddressSpaces",
")",
"\n",
"handleMethod",
"(",
"\"",
"\"",
",",
"driver",
".",
"requestPool",
")",
"\n",
"handleMethod",
"(",
"\"",
"\"",
",",
"driver",
".",
"releasePool",
")",
"\n",
"handleMethod",
"(",
"\"",
"\"",
",",
"driver",
".",
"requestAddress",
")",
"\n",
"handleMethod",
"(",
"\"",
"\"",
",",
"driver",
".",
"releaseAddress",
")",
"\n\n",
"listener",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"socket",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"http",
".",
"Serve",
"(",
"listener",
",",
"router",
")",
"\n",
"}"
] | // Listen listens for docker requests on a particular set of endpoints on the given
// socket path. | [
"Listen",
"listens",
"for",
"docker",
"requests",
"on",
"a",
"particular",
"set",
"of",
"endpoints",
"on",
"the",
"given",
"socket",
"path",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/plugins/cilium-docker/driver/driver.go#L165-L194 |
163,024 | cilium/cilium | pkg/policy/distillery/policy.go | getPolicy | func (cip *cachedSelectorPolicy) getPolicy() *policy.SelectorPolicy {
return (*policy.SelectorPolicy)(atomic.LoadPointer(&cip.policy))
} | go | func (cip *cachedSelectorPolicy) getPolicy() *policy.SelectorPolicy {
return (*policy.SelectorPolicy)(atomic.LoadPointer(&cip.policy))
} | [
"func",
"(",
"cip",
"*",
"cachedSelectorPolicy",
")",
"getPolicy",
"(",
")",
"*",
"policy",
".",
"SelectorPolicy",
"{",
"return",
"(",
"*",
"policy",
".",
"SelectorPolicy",
")",
"(",
"atomic",
".",
"LoadPointer",
"(",
"&",
"cip",
".",
"policy",
")",
")",
"\n",
"}"
] | // getPolicy returns a reference to the SelectorPolicy that is cached, and
// the revision for that policy.
//
// Users should treat the result as immutable state that MUST NOT be modified. | [
"getPolicy",
"returns",
"a",
"reference",
"to",
"the",
"SelectorPolicy",
"that",
"is",
"cached",
"and",
"the",
"revision",
"for",
"that",
"policy",
".",
"Users",
"should",
"treat",
"the",
"result",
"as",
"immutable",
"state",
"that",
"MUST",
"NOT",
"be",
"modified",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/distillery/policy.go#L46-L48 |
163,025 | cilium/cilium | pkg/policy/distillery/policy.go | setPolicy | func (cip *cachedSelectorPolicy) setPolicy(policy *policy.SelectorPolicy) {
// A lock must be held to ensure consistency between these fields.
atomic.StorePointer(&cip.policy, unsafe.Pointer(policy))
} | go | func (cip *cachedSelectorPolicy) setPolicy(policy *policy.SelectorPolicy) {
// A lock must be held to ensure consistency between these fields.
atomic.StorePointer(&cip.policy, unsafe.Pointer(policy))
} | [
"func",
"(",
"cip",
"*",
"cachedSelectorPolicy",
")",
"setPolicy",
"(",
"policy",
"*",
"policy",
".",
"SelectorPolicy",
")",
"{",
"// A lock must be held to ensure consistency between these fields.",
"atomic",
".",
"StorePointer",
"(",
"&",
"cip",
".",
"policy",
",",
"unsafe",
".",
"Pointer",
"(",
"policy",
")",
")",
"\n",
"}"
] | // setPolicy updates the reference to the SelectorPolicy that is cached. | [
"setPolicy",
"updates",
"the",
"reference",
"to",
"the",
"SelectorPolicy",
"that",
"is",
"cached",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/distillery/policy.go#L51-L54 |
163,026 | cilium/cilium | pkg/policy/distillery/policy.go | Consume | func (cip *cachedSelectorPolicy) Consume(owner policy.PolicyOwner, cache cache.IdentityCache) *policy.EndpointPolicy {
// TODO: This currently computes the EndpointPolicy from SelectorPolicy
// on-demand, however in future the cip is intended to cache the
// EndpointPolicy for this Identity and emit datapath deltas instead.
// Changing this requires shifting IdentityCache management
// responsibilities from the caller into this package.
return cip.getPolicy().DistillPolicy(owner, cache)
} | go | func (cip *cachedSelectorPolicy) Consume(owner policy.PolicyOwner, cache cache.IdentityCache) *policy.EndpointPolicy {
// TODO: This currently computes the EndpointPolicy from SelectorPolicy
// on-demand, however in future the cip is intended to cache the
// EndpointPolicy for this Identity and emit datapath deltas instead.
// Changing this requires shifting IdentityCache management
// responsibilities from the caller into this package.
return cip.getPolicy().DistillPolicy(owner, cache)
} | [
"func",
"(",
"cip",
"*",
"cachedSelectorPolicy",
")",
"Consume",
"(",
"owner",
"policy",
".",
"PolicyOwner",
",",
"cache",
"cache",
".",
"IdentityCache",
")",
"*",
"policy",
".",
"EndpointPolicy",
"{",
"// TODO: This currently computes the EndpointPolicy from SelectorPolicy",
"// on-demand, however in future the cip is intended to cache the",
"// EndpointPolicy for this Identity and emit datapath deltas instead.",
"// Changing this requires shifting IdentityCache management",
"// responsibilities from the caller into this package.",
"return",
"cip",
".",
"getPolicy",
"(",
")",
".",
"DistillPolicy",
"(",
"owner",
",",
"cache",
")",
"\n",
"}"
] | // Consume returns the EndpointPolicy that defines connectivity policy to
// Identities in the specified cache.
//
// This denotes that a particular endpoint is 'consuming' the policy from the
// selector policy cache. | [
"Consume",
"returns",
"the",
"EndpointPolicy",
"that",
"defines",
"connectivity",
"policy",
"to",
"Identities",
"in",
"the",
"specified",
"cache",
".",
"This",
"denotes",
"that",
"a",
"particular",
"endpoint",
"is",
"consuming",
"the",
"policy",
"from",
"the",
"selector",
"policy",
"cache",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/distillery/policy.go#L61-L68 |
163,027 | cilium/cilium | api/v1/health/server/restapi/get_healthz_responses.go | WithPayload | func (o *GetHealthzFailed) WithPayload(payload models.Error) *GetHealthzFailed {
o.Payload = payload
return o
} | go | func (o *GetHealthzFailed) WithPayload(payload models.Error) *GetHealthzFailed {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetHealthzFailed",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"Error",
")",
"*",
"GetHealthzFailed",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get healthz failed response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"healthz",
"failed",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/server/restapi/get_healthz_responses.go#L82-L85 |
163,028 | cilium/cilium | api/v1/server/restapi/endpoint/get_endpoint_id_healthz_responses.go | WithPayload | func (o *GetEndpointIDHealthzOK) WithPayload(payload *models.EndpointHealth) *GetEndpointIDHealthzOK {
o.Payload = payload
return o
} | go | func (o *GetEndpointIDHealthzOK) WithPayload(payload *models.EndpointHealth) *GetEndpointIDHealthzOK {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointIDHealthzOK",
")",
"WithPayload",
"(",
"payload",
"*",
"models",
".",
"EndpointHealth",
")",
"*",
"GetEndpointIDHealthzOK",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get endpoint Id healthz o k response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"endpoint",
"Id",
"healthz",
"o",
"k",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/endpoint/get_endpoint_id_healthz_responses.go#L38-L41 |
163,029 | cilium/cilium | pkg/launcher/launcher.go | Run | func (launcher *Launcher) Run() error {
targetName := launcher.GetTarget()
cmdStr := fmt.Sprintf("%s %s", targetName, launcher.GetArgs())
cmd := exec.Command(targetName, launcher.GetArgs()...)
cmd.Stderr = os.Stderr
stdout, _ := cmd.StdoutPipe()
if err := cmd.Start(); err != nil {
log.WithError(err).WithField("cmd", cmdStr).Error("cmd.Start()")
return fmt.Errorf("unable to launch process %s: %s", cmdStr, err)
}
launcher.setProcess(cmd.Process)
launcher.setStdout(stdout)
// Wait for the process to exit in the background to release all
// resources
go func() {
err := cmd.Wait()
log.WithFields(logrus.Fields{
"exitCode": err,
"cmd": cmdStr,
}).Debug("Process exited")
}()
return nil
} | go | func (launcher *Launcher) Run() error {
targetName := launcher.GetTarget()
cmdStr := fmt.Sprintf("%s %s", targetName, launcher.GetArgs())
cmd := exec.Command(targetName, launcher.GetArgs()...)
cmd.Stderr = os.Stderr
stdout, _ := cmd.StdoutPipe()
if err := cmd.Start(); err != nil {
log.WithError(err).WithField("cmd", cmdStr).Error("cmd.Start()")
return fmt.Errorf("unable to launch process %s: %s", cmdStr, err)
}
launcher.setProcess(cmd.Process)
launcher.setStdout(stdout)
// Wait for the process to exit in the background to release all
// resources
go func() {
err := cmd.Wait()
log.WithFields(logrus.Fields{
"exitCode": err,
"cmd": cmdStr,
}).Debug("Process exited")
}()
return nil
} | [
"func",
"(",
"launcher",
"*",
"Launcher",
")",
"Run",
"(",
")",
"error",
"{",
"targetName",
":=",
"launcher",
".",
"GetTarget",
"(",
")",
"\n",
"cmdStr",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"targetName",
",",
"launcher",
".",
"GetArgs",
"(",
")",
")",
"\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"targetName",
",",
"launcher",
".",
"GetArgs",
"(",
")",
"...",
")",
"\n",
"cmd",
".",
"Stderr",
"=",
"os",
".",
"Stderr",
"\n",
"stdout",
",",
"_",
":=",
"cmd",
".",
"StdoutPipe",
"(",
")",
"\n",
"if",
"err",
":=",
"cmd",
".",
"Start",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"WithField",
"(",
"\"",
"\"",
",",
"cmdStr",
")",
".",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"cmdStr",
",",
"err",
")",
"\n",
"}",
"\n\n",
"launcher",
".",
"setProcess",
"(",
"cmd",
".",
"Process",
")",
"\n",
"launcher",
".",
"setStdout",
"(",
"stdout",
")",
"\n\n",
"// Wait for the process to exit in the background to release all",
"// resources",
"go",
"func",
"(",
")",
"{",
"err",
":=",
"cmd",
".",
"Wait",
"(",
")",
"\n",
"log",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"\"",
"\"",
":",
"err",
",",
"\"",
"\"",
":",
"cmdStr",
",",
"}",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"}",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Run starts the daemon. | [
"Run",
"starts",
"the",
"daemon",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/launcher/launcher.go#L42-L67 |
163,030 | cilium/cilium | pkg/launcher/launcher.go | Restart | func (launcher *Launcher) Restart(args []string) {
launcher.Mutex.Lock()
defer launcher.Mutex.Unlock()
launcher.args = args
if launcher.process == nil {
return
}
if err := launcher.process.Kill(); err != nil {
log.WithError(err).WithField("pid", launcher.process.Pid).Error("process.Kill()")
}
launcher.process = nil
} | go | func (launcher *Launcher) Restart(args []string) {
launcher.Mutex.Lock()
defer launcher.Mutex.Unlock()
launcher.args = args
if launcher.process == nil {
return
}
if err := launcher.process.Kill(); err != nil {
log.WithError(err).WithField("pid", launcher.process.Pid).Error("process.Kill()")
}
launcher.process = nil
} | [
"func",
"(",
"launcher",
"*",
"Launcher",
")",
"Restart",
"(",
"args",
"[",
"]",
"string",
")",
"{",
"launcher",
".",
"Mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"launcher",
".",
"Mutex",
".",
"Unlock",
"(",
")",
"\n",
"launcher",
".",
"args",
"=",
"args",
"\n\n",
"if",
"launcher",
".",
"process",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"if",
"err",
":=",
"launcher",
".",
"process",
".",
"Kill",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"WithField",
"(",
"\"",
"\"",
",",
"launcher",
".",
"process",
".",
"Pid",
")",
".",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"launcher",
".",
"process",
"=",
"nil",
"\n",
"}"
] | // Restart stops the launcher which will trigger a rerun. | [
"Restart",
"stops",
"the",
"launcher",
"which",
"will",
"trigger",
"a",
"rerun",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/launcher/launcher.go#L70-L82 |
163,031 | cilium/cilium | pkg/launcher/launcher.go | SetTarget | func (launcher *Launcher) SetTarget(target string) {
launcher.Mutex.Lock()
launcher.target = target
launcher.Mutex.Unlock()
} | go | func (launcher *Launcher) SetTarget(target string) {
launcher.Mutex.Lock()
launcher.target = target
launcher.Mutex.Unlock()
} | [
"func",
"(",
"launcher",
"*",
"Launcher",
")",
"SetTarget",
"(",
"target",
"string",
")",
"{",
"launcher",
".",
"Mutex",
".",
"Lock",
"(",
")",
"\n",
"launcher",
".",
"target",
"=",
"target",
"\n",
"launcher",
".",
"Mutex",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // SetTarget sets the Launcher target. | [
"SetTarget",
"sets",
"the",
"Launcher",
"target",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/launcher/launcher.go#L85-L89 |
163,032 | cilium/cilium | pkg/launcher/launcher.go | GetTarget | func (launcher *Launcher) GetTarget() string {
launcher.Mutex.RLock()
arg := launcher.target
launcher.Mutex.RUnlock()
return arg
} | go | func (launcher *Launcher) GetTarget() string {
launcher.Mutex.RLock()
arg := launcher.target
launcher.Mutex.RUnlock()
return arg
} | [
"func",
"(",
"launcher",
"*",
"Launcher",
")",
"GetTarget",
"(",
")",
"string",
"{",
"launcher",
".",
"Mutex",
".",
"RLock",
"(",
")",
"\n",
"arg",
":=",
"launcher",
".",
"target",
"\n",
"launcher",
".",
"Mutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"arg",
"\n",
"}"
] | // GetTarget returns the Launcher target. | [
"GetTarget",
"returns",
"the",
"Launcher",
"target",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/launcher/launcher.go#L92-L97 |
163,033 | cilium/cilium | pkg/launcher/launcher.go | SetArgs | func (launcher *Launcher) SetArgs(args []string) {
launcher.Mutex.Lock()
launcher.args = args
launcher.Mutex.Unlock()
} | go | func (launcher *Launcher) SetArgs(args []string) {
launcher.Mutex.Lock()
launcher.args = args
launcher.Mutex.Unlock()
} | [
"func",
"(",
"launcher",
"*",
"Launcher",
")",
"SetArgs",
"(",
"args",
"[",
"]",
"string",
")",
"{",
"launcher",
".",
"Mutex",
".",
"Lock",
"(",
")",
"\n",
"launcher",
".",
"args",
"=",
"args",
"\n",
"launcher",
".",
"Mutex",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // SetArgs sets the Launcher arg. | [
"SetArgs",
"sets",
"the",
"Launcher",
"arg",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/launcher/launcher.go#L100-L104 |
163,034 | cilium/cilium | pkg/launcher/launcher.go | GetArgs | func (launcher *Launcher) GetArgs() []string {
launcher.Mutex.RLock()
args := launcher.args
launcher.Mutex.RUnlock()
return args
} | go | func (launcher *Launcher) GetArgs() []string {
launcher.Mutex.RLock()
args := launcher.args
launcher.Mutex.RUnlock()
return args
} | [
"func",
"(",
"launcher",
"*",
"Launcher",
")",
"GetArgs",
"(",
")",
"[",
"]",
"string",
"{",
"launcher",
".",
"Mutex",
".",
"RLock",
"(",
")",
"\n",
"args",
":=",
"launcher",
".",
"args",
"\n",
"launcher",
".",
"Mutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"args",
"\n",
"}"
] | // GetArgs returns the Launcher arg. | [
"GetArgs",
"returns",
"the",
"Launcher",
"arg",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/launcher/launcher.go#L107-L112 |
163,035 | cilium/cilium | pkg/launcher/launcher.go | setProcess | func (launcher *Launcher) setProcess(proc *os.Process) {
launcher.Mutex.Lock()
launcher.process = proc
launcher.Mutex.Unlock()
} | go | func (launcher *Launcher) setProcess(proc *os.Process) {
launcher.Mutex.Lock()
launcher.process = proc
launcher.Mutex.Unlock()
} | [
"func",
"(",
"launcher",
"*",
"Launcher",
")",
"setProcess",
"(",
"proc",
"*",
"os",
".",
"Process",
")",
"{",
"launcher",
".",
"Mutex",
".",
"Lock",
"(",
")",
"\n",
"launcher",
".",
"process",
"=",
"proc",
"\n",
"launcher",
".",
"Mutex",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // setProcess sets the internal process with the given process. | [
"setProcess",
"sets",
"the",
"internal",
"process",
"with",
"the",
"given",
"process",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/launcher/launcher.go#L115-L119 |
163,036 | cilium/cilium | pkg/launcher/launcher.go | GetProcess | func (launcher *Launcher) GetProcess() *os.Process {
launcher.Mutex.RLock()
proc := launcher.process
launcher.Mutex.RUnlock()
return proc
} | go | func (launcher *Launcher) GetProcess() *os.Process {
launcher.Mutex.RLock()
proc := launcher.process
launcher.Mutex.RUnlock()
return proc
} | [
"func",
"(",
"launcher",
"*",
"Launcher",
")",
"GetProcess",
"(",
")",
"*",
"os",
".",
"Process",
"{",
"launcher",
".",
"Mutex",
".",
"RLock",
"(",
")",
"\n",
"proc",
":=",
"launcher",
".",
"process",
"\n",
"launcher",
".",
"Mutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"proc",
"\n",
"}"
] | // GetProcess returns the internal process. | [
"GetProcess",
"returns",
"the",
"internal",
"process",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/launcher/launcher.go#L122-L127 |
163,037 | cilium/cilium | pkg/launcher/launcher.go | setStdout | func (launcher *Launcher) setStdout(stdout io.ReadCloser) {
launcher.Mutex.Lock()
launcher.stdout = stdout
launcher.Mutex.Unlock()
} | go | func (launcher *Launcher) setStdout(stdout io.ReadCloser) {
launcher.Mutex.Lock()
launcher.stdout = stdout
launcher.Mutex.Unlock()
} | [
"func",
"(",
"launcher",
"*",
"Launcher",
")",
"setStdout",
"(",
"stdout",
"io",
".",
"ReadCloser",
")",
"{",
"launcher",
".",
"Mutex",
".",
"Lock",
"(",
")",
"\n",
"launcher",
".",
"stdout",
"=",
"stdout",
"\n",
"launcher",
".",
"Mutex",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // setStdout sets the stdout pipe. | [
"setStdout",
"sets",
"the",
"stdout",
"pipe",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/launcher/launcher.go#L130-L134 |
163,038 | cilium/cilium | pkg/launcher/launcher.go | GetStdout | func (launcher *Launcher) GetStdout() io.ReadCloser {
launcher.Mutex.RLock()
stdout := launcher.stdout
launcher.Mutex.RUnlock()
return stdout
} | go | func (launcher *Launcher) GetStdout() io.ReadCloser {
launcher.Mutex.RLock()
stdout := launcher.stdout
launcher.Mutex.RUnlock()
return stdout
} | [
"func",
"(",
"launcher",
"*",
"Launcher",
")",
"GetStdout",
"(",
")",
"io",
".",
"ReadCloser",
"{",
"launcher",
".",
"Mutex",
".",
"RLock",
"(",
")",
"\n",
"stdout",
":=",
"launcher",
".",
"stdout",
"\n",
"launcher",
".",
"Mutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"stdout",
"\n",
"}"
] | // GetStdout gets the stdout pipe. | [
"GetStdout",
"gets",
"the",
"stdout",
"pipe",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/launcher/launcher.go#L137-L142 |
163,039 | cilium/cilium | pkg/k8s/network_policy.go | GetPolicyLabelsv1 | func GetPolicyLabelsv1(np *networkingv1.NetworkPolicy) labels.LabelArray {
if np == nil {
log.Warningf("unable to extract policy labels because provided NetworkPolicy is nil")
return nil
}
policyName := np.Annotations[annotation.Name]
policyUID := np.UID
if policyName == "" {
policyName = np.Name
}
ns := k8sUtils.ExtractNamespace(&np.ObjectMeta)
return k8sCiliumUtils.GetPolicyLabels(ns, policyName, policyUID, resourceTypeNetworkPolicy)
} | go | func GetPolicyLabelsv1(np *networkingv1.NetworkPolicy) labels.LabelArray {
if np == nil {
log.Warningf("unable to extract policy labels because provided NetworkPolicy is nil")
return nil
}
policyName := np.Annotations[annotation.Name]
policyUID := np.UID
if policyName == "" {
policyName = np.Name
}
ns := k8sUtils.ExtractNamespace(&np.ObjectMeta)
return k8sCiliumUtils.GetPolicyLabels(ns, policyName, policyUID, resourceTypeNetworkPolicy)
} | [
"func",
"GetPolicyLabelsv1",
"(",
"np",
"*",
"networkingv1",
".",
"NetworkPolicy",
")",
"labels",
".",
"LabelArray",
"{",
"if",
"np",
"==",
"nil",
"{",
"log",
".",
"Warningf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"policyName",
":=",
"np",
".",
"Annotations",
"[",
"annotation",
".",
"Name",
"]",
"\n",
"policyUID",
":=",
"np",
".",
"UID",
"\n\n",
"if",
"policyName",
"==",
"\"",
"\"",
"{",
"policyName",
"=",
"np",
".",
"Name",
"\n",
"}",
"\n\n",
"ns",
":=",
"k8sUtils",
".",
"ExtractNamespace",
"(",
"&",
"np",
".",
"ObjectMeta",
")",
"\n\n",
"return",
"k8sCiliumUtils",
".",
"GetPolicyLabels",
"(",
"ns",
",",
"policyName",
",",
"policyUID",
",",
"resourceTypeNetworkPolicy",
")",
"\n",
"}"
] | // GetPolicyLabelsv1 extracts the name of np. It uses the name from the Cilium
// annotation if present. If the policy's annotations do not contain
// the Cilium annotation, the policy's name field is used instead. | [
"GetPolicyLabelsv1",
"extracts",
"the",
"name",
"of",
"np",
".",
"It",
"uses",
"the",
"name",
"from",
"the",
"Cilium",
"annotation",
"if",
"present",
".",
"If",
"the",
"policy",
"s",
"annotations",
"do",
"not",
"contain",
"the",
"Cilium",
"annotation",
"the",
"policy",
"s",
"name",
"field",
"is",
"used",
"instead",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/network_policy.go#L47-L63 |
163,040 | cilium/cilium | pkg/k8s/network_policy.go | parsePorts | func parsePorts(ports []networkingv1.NetworkPolicyPort) []api.PortRule {
portRules := []api.PortRule{}
for _, port := range ports {
if port.Protocol == nil && port.Port == nil {
continue
}
protocol := api.ProtoTCP
if port.Protocol != nil {
protocol, _ = api.ParseL4Proto(string(*port.Protocol))
}
portStr := ""
if port.Port != nil {
portStr = port.Port.String()
}
portRule := api.PortRule{
Ports: []api.PortProtocol{
{Port: portStr, Protocol: protocol},
},
}
portRules = append(portRules, portRule)
}
return portRules
} | go | func parsePorts(ports []networkingv1.NetworkPolicyPort) []api.PortRule {
portRules := []api.PortRule{}
for _, port := range ports {
if port.Protocol == nil && port.Port == nil {
continue
}
protocol := api.ProtoTCP
if port.Protocol != nil {
protocol, _ = api.ParseL4Proto(string(*port.Protocol))
}
portStr := ""
if port.Port != nil {
portStr = port.Port.String()
}
portRule := api.PortRule{
Ports: []api.PortProtocol{
{Port: portStr, Protocol: protocol},
},
}
portRules = append(portRules, portRule)
}
return portRules
} | [
"func",
"parsePorts",
"(",
"ports",
"[",
"]",
"networkingv1",
".",
"NetworkPolicyPort",
")",
"[",
"]",
"api",
".",
"PortRule",
"{",
"portRules",
":=",
"[",
"]",
"api",
".",
"PortRule",
"{",
"}",
"\n",
"for",
"_",
",",
"port",
":=",
"range",
"ports",
"{",
"if",
"port",
".",
"Protocol",
"==",
"nil",
"&&",
"port",
".",
"Port",
"==",
"nil",
"{",
"continue",
"\n",
"}",
"\n\n",
"protocol",
":=",
"api",
".",
"ProtoTCP",
"\n",
"if",
"port",
".",
"Protocol",
"!=",
"nil",
"{",
"protocol",
",",
"_",
"=",
"api",
".",
"ParseL4Proto",
"(",
"string",
"(",
"*",
"port",
".",
"Protocol",
")",
")",
"\n",
"}",
"\n\n",
"portStr",
":=",
"\"",
"\"",
"\n",
"if",
"port",
".",
"Port",
"!=",
"nil",
"{",
"portStr",
"=",
"port",
".",
"Port",
".",
"String",
"(",
")",
"\n",
"}",
"\n\n",
"portRule",
":=",
"api",
".",
"PortRule",
"{",
"Ports",
":",
"[",
"]",
"api",
".",
"PortProtocol",
"{",
"{",
"Port",
":",
"portStr",
",",
"Protocol",
":",
"protocol",
"}",
",",
"}",
",",
"}",
"\n\n",
"portRules",
"=",
"append",
"(",
"portRules",
",",
"portRule",
")",
"\n",
"}",
"\n\n",
"return",
"portRules",
"\n",
"}"
] | // parsePorts converts list of K8s NetworkPolicyPorts to Cilium PortRules. | [
"parsePorts",
"converts",
"list",
"of",
"K8s",
"NetworkPolicyPorts",
"to",
"Cilium",
"PortRules",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/network_policy.go#L267-L294 |
163,041 | cilium/cilium | cilium/cmd/monitor.go | openMonitorSock | func openMonitorSock() (conn net.Conn, version listener.Version, err error) {
errors := make([]string, 0)
// try the 1.2 socket
conn, err = net.Dial("unix", defaults.MonitorSockPath1_2)
if err == nil {
return conn, listener.Version1_2, nil
}
errors = append(errors, defaults.MonitorSockPath1_2+": "+err.Error())
// try the 1.1 socket
conn, err = net.Dial("unix", defaults.MonitorSockPath1_0)
if err == nil {
return conn, listener.Version1_0, nil
}
errors = append(errors, defaults.MonitorSockPath1_0+": "+err.Error())
return nil, listener.VersionUnsupported, fmt.Errorf("Cannot find or open a supported node-monitor socket. %s", strings.Join(errors, ","))
} | go | func openMonitorSock() (conn net.Conn, version listener.Version, err error) {
errors := make([]string, 0)
// try the 1.2 socket
conn, err = net.Dial("unix", defaults.MonitorSockPath1_2)
if err == nil {
return conn, listener.Version1_2, nil
}
errors = append(errors, defaults.MonitorSockPath1_2+": "+err.Error())
// try the 1.1 socket
conn, err = net.Dial("unix", defaults.MonitorSockPath1_0)
if err == nil {
return conn, listener.Version1_0, nil
}
errors = append(errors, defaults.MonitorSockPath1_0+": "+err.Error())
return nil, listener.VersionUnsupported, fmt.Errorf("Cannot find or open a supported node-monitor socket. %s", strings.Join(errors, ","))
} | [
"func",
"openMonitorSock",
"(",
")",
"(",
"conn",
"net",
".",
"Conn",
",",
"version",
"listener",
".",
"Version",
",",
"err",
"error",
")",
"{",
"errors",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n\n",
"// try the 1.2 socket",
"conn",
",",
"err",
"=",
"net",
".",
"Dial",
"(",
"\"",
"\"",
",",
"defaults",
".",
"MonitorSockPath1_2",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"conn",
",",
"listener",
".",
"Version1_2",
",",
"nil",
"\n",
"}",
"\n",
"errors",
"=",
"append",
"(",
"errors",
",",
"defaults",
".",
"MonitorSockPath1_2",
"+",
"\"",
"\"",
"+",
"err",
".",
"Error",
"(",
")",
")",
"\n\n",
"// try the 1.1 socket",
"conn",
",",
"err",
"=",
"net",
".",
"Dial",
"(",
"\"",
"\"",
",",
"defaults",
".",
"MonitorSockPath1_0",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"conn",
",",
"listener",
".",
"Version1_0",
",",
"nil",
"\n",
"}",
"\n",
"errors",
"=",
"append",
"(",
"errors",
",",
"defaults",
".",
"MonitorSockPath1_0",
"+",
"\"",
"\"",
"+",
"err",
".",
"Error",
"(",
")",
")",
"\n\n",
"return",
"nil",
",",
"listener",
".",
"VersionUnsupported",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"errors",
",",
"\"",
"\"",
")",
")",
"\n",
"}"
] | // openMonitorSock attempts to open a version specific monitor socket It
// returns a connection, with a version, or an error. | [
"openMonitorSock",
"attempts",
"to",
"open",
"a",
"version",
"specific",
"monitor",
"socket",
"It",
"returns",
"a",
"connection",
"with",
"a",
"version",
"or",
"an",
"error",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/cilium/cmd/monitor.go#L91-L109 |
163,042 | cilium/cilium | cilium/cmd/monitor.go | consumeMonitorEvents | func consumeMonitorEvents(conn net.Conn, version listener.Version) error {
defer conn.Close()
getParsedPayload, err := getMonitorParser(conn, version)
if err != nil {
return err
}
for {
pl, err := getParsedPayload()
if err != nil {
return err
}
if !printer.FormatEvent(pl) {
// earlier code used an else to handle this case, along with pl.Type ==
// payload.RecordLost above. It should be safe to call lostEvent to match
// the earlier behaviour, despite it not being wholly correct.
log.WithError(err).WithField("type", pl.Type).Warn("Unknown payload type")
format.LostEvent(pl.Lost, pl.CPU)
}
}
} | go | func consumeMonitorEvents(conn net.Conn, version listener.Version) error {
defer conn.Close()
getParsedPayload, err := getMonitorParser(conn, version)
if err != nil {
return err
}
for {
pl, err := getParsedPayload()
if err != nil {
return err
}
if !printer.FormatEvent(pl) {
// earlier code used an else to handle this case, along with pl.Type ==
// payload.RecordLost above. It should be safe to call lostEvent to match
// the earlier behaviour, despite it not being wholly correct.
log.WithError(err).WithField("type", pl.Type).Warn("Unknown payload type")
format.LostEvent(pl.Lost, pl.CPU)
}
}
} | [
"func",
"consumeMonitorEvents",
"(",
"conn",
"net",
".",
"Conn",
",",
"version",
"listener",
".",
"Version",
")",
"error",
"{",
"defer",
"conn",
".",
"Close",
"(",
")",
"\n\n",
"getParsedPayload",
",",
"err",
":=",
"getMonitorParser",
"(",
"conn",
",",
"version",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"for",
"{",
"pl",
",",
"err",
":=",
"getParsedPayload",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"!",
"printer",
".",
"FormatEvent",
"(",
"pl",
")",
"{",
"// earlier code used an else to handle this case, along with pl.Type ==",
"// payload.RecordLost above. It should be safe to call lostEvent to match",
"// the earlier behaviour, despite it not being wholly correct.",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"WithField",
"(",
"\"",
"\"",
",",
"pl",
".",
"Type",
")",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"format",
".",
"LostEvent",
"(",
"pl",
".",
"Lost",
",",
"pl",
".",
"CPU",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // consumeMonitorEvents handles and prints events on a monitor connection. It
// calls getMonitorParsed to construct a monitor-version appropraite parser.
// It closes conn on return, and returns on error, including io.EOF | [
"consumeMonitorEvents",
"handles",
"and",
"prints",
"events",
"on",
"a",
"monitor",
"connection",
".",
"It",
"calls",
"getMonitorParsed",
"to",
"construct",
"a",
"monitor",
"-",
"version",
"appropraite",
"parser",
".",
"It",
"closes",
"conn",
"on",
"return",
"and",
"returns",
"on",
"error",
"including",
"io",
".",
"EOF"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/cilium/cmd/monitor.go#L114-L135 |
163,043 | cilium/cilium | cilium/cmd/monitor.go | getMonitorParser | func getMonitorParser(conn net.Conn, version listener.Version) (parser eventParserFunc, err error) {
switch version {
case listener.Version1_0:
var (
meta payload.Meta
pl payload.Payload
)
// This implements the older API. Always encode a Meta and Payload object,
// both with full gob type information
return func() (*payload.Payload, error) {
if err := payload.ReadMetaPayload(conn, &meta, &pl); err != nil {
return nil, err
}
return &pl, nil
}, nil
case listener.Version1_2:
var (
pl payload.Payload
dec = gob.NewDecoder(conn)
)
// This implemenents the newer 1.2 API. Each listener maintains its own gob
// session, and type information is only ever sent once.
return func() (*payload.Payload, error) {
if err := pl.DecodeBinary(dec); err != nil {
return nil, err
}
return &pl, nil
}, nil
default:
return nil, fmt.Errorf("unsupported version %s", version)
}
} | go | func getMonitorParser(conn net.Conn, version listener.Version) (parser eventParserFunc, err error) {
switch version {
case listener.Version1_0:
var (
meta payload.Meta
pl payload.Payload
)
// This implements the older API. Always encode a Meta and Payload object,
// both with full gob type information
return func() (*payload.Payload, error) {
if err := payload.ReadMetaPayload(conn, &meta, &pl); err != nil {
return nil, err
}
return &pl, nil
}, nil
case listener.Version1_2:
var (
pl payload.Payload
dec = gob.NewDecoder(conn)
)
// This implemenents the newer 1.2 API. Each listener maintains its own gob
// session, and type information is only ever sent once.
return func() (*payload.Payload, error) {
if err := pl.DecodeBinary(dec); err != nil {
return nil, err
}
return &pl, nil
}, nil
default:
return nil, fmt.Errorf("unsupported version %s", version)
}
} | [
"func",
"getMonitorParser",
"(",
"conn",
"net",
".",
"Conn",
",",
"version",
"listener",
".",
"Version",
")",
"(",
"parser",
"eventParserFunc",
",",
"err",
"error",
")",
"{",
"switch",
"version",
"{",
"case",
"listener",
".",
"Version1_0",
":",
"var",
"(",
"meta",
"payload",
".",
"Meta",
"\n",
"pl",
"payload",
".",
"Payload",
"\n",
")",
"\n",
"// This implements the older API. Always encode a Meta and Payload object,",
"// both with full gob type information",
"return",
"func",
"(",
")",
"(",
"*",
"payload",
".",
"Payload",
",",
"error",
")",
"{",
"if",
"err",
":=",
"payload",
".",
"ReadMetaPayload",
"(",
"conn",
",",
"&",
"meta",
",",
"&",
"pl",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"pl",
",",
"nil",
"\n",
"}",
",",
"nil",
"\n\n",
"case",
"listener",
".",
"Version1_2",
":",
"var",
"(",
"pl",
"payload",
".",
"Payload",
"\n",
"dec",
"=",
"gob",
".",
"NewDecoder",
"(",
"conn",
")",
"\n",
")",
"\n",
"// This implemenents the newer 1.2 API. Each listener maintains its own gob",
"// session, and type information is only ever sent once.",
"return",
"func",
"(",
")",
"(",
"*",
"payload",
".",
"Payload",
",",
"error",
")",
"{",
"if",
"err",
":=",
"pl",
".",
"DecodeBinary",
"(",
"dec",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"pl",
",",
"nil",
"\n",
"}",
",",
"nil",
"\n\n",
"default",
":",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"version",
")",
"\n",
"}",
"\n",
"}"
] | // getMonitorParser constructs and returns an eventParserFunc. It is
// appropriate for the monitor API version passed in. | [
"getMonitorParser",
"constructs",
"and",
"returns",
"an",
"eventParserFunc",
".",
"It",
"is",
"appropriate",
"for",
"the",
"monitor",
"API",
"version",
"passed",
"in",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/cilium/cmd/monitor.go#L143-L176 |
163,044 | cilium/cilium | api/v1/models/ip_a_m_status.go | Validate | func (m *IPAMStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAllocations(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *IPAMStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAllocations(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"IPAMStatus",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateAllocations",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this IP a m status | [
"Validate",
"validates",
"this",
"IP",
"a",
"m",
"status"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/ip_a_m_status.go#L31-L42 |
163,045 | cilium/cilium | pkg/counter/integer.go | DeepCopy | func (i IntCounter) DeepCopy() IntCounter {
result := make(IntCounter, len(i))
for k, v := range i {
result[k] = v
}
return result
} | go | func (i IntCounter) DeepCopy() IntCounter {
result := make(IntCounter, len(i))
for k, v := range i {
result[k] = v
}
return result
} | [
"func",
"(",
"i",
"IntCounter",
")",
"DeepCopy",
"(",
")",
"IntCounter",
"{",
"result",
":=",
"make",
"(",
"IntCounter",
",",
"len",
"(",
"i",
")",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"i",
"{",
"result",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"return",
"result",
"\n",
"}"
] | // DeepCopy makes a new copy of the received IntCounter. | [
"DeepCopy",
"makes",
"a",
"new",
"copy",
"of",
"the",
"received",
"IntCounter",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/counter/integer.go#L29-L35 |
163,046 | cilium/cilium | pkg/counter/integer.go | Add | func (i IntCounter) Add(key int) (changed bool) {
value, exists := i[key]
if !exists {
changed = true
}
i[key] = value + 1
return changed
} | go | func (i IntCounter) Add(key int) (changed bool) {
value, exists := i[key]
if !exists {
changed = true
}
i[key] = value + 1
return changed
} | [
"func",
"(",
"i",
"IntCounter",
")",
"Add",
"(",
"key",
"int",
")",
"(",
"changed",
"bool",
")",
"{",
"value",
",",
"exists",
":=",
"i",
"[",
"key",
"]",
"\n",
"if",
"!",
"exists",
"{",
"changed",
"=",
"true",
"\n",
"}",
"\n",
"i",
"[",
"key",
"]",
"=",
"value",
"+",
"1",
"\n",
"return",
"changed",
"\n",
"}"
] | // Add increments the reference count for the specified integer key. | [
"Add",
"increments",
"the",
"reference",
"count",
"for",
"the",
"specified",
"integer",
"key",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/counter/integer.go#L38-L45 |
163,047 | cilium/cilium | pkg/counter/integer.go | Delete | func (i IntCounter) Delete(key int) bool {
value, _ := i[key]
if value <= 1 {
delete(i, key)
return true
}
i[key] = value - 1
return false
} | go | func (i IntCounter) Delete(key int) bool {
value, _ := i[key]
if value <= 1 {
delete(i, key)
return true
}
i[key] = value - 1
return false
} | [
"func",
"(",
"i",
"IntCounter",
")",
"Delete",
"(",
"key",
"int",
")",
"bool",
"{",
"value",
",",
"_",
":=",
"i",
"[",
"key",
"]",
"\n",
"if",
"value",
"<=",
"1",
"{",
"delete",
"(",
"i",
",",
"key",
")",
"\n",
"return",
"true",
"\n",
"}",
"\n",
"i",
"[",
"key",
"]",
"=",
"value",
"-",
"1",
"\n",
"return",
"false",
"\n",
"}"
] | // Delete decrements the reference count for the specified integer key. | [
"Delete",
"decrements",
"the",
"reference",
"count",
"for",
"the",
"specified",
"integer",
"key",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/counter/integer.go#L48-L56 |
163,048 | cilium/cilium | pkg/counter/integer.go | ToBPFData | func (i IntCounter) ToBPFData() []int {
result := make([]int, 0, len(i))
for key := range i {
result = append(result, key)
}
sort.Sort(sort.Reverse(sort.IntSlice(result)))
return result
} | go | func (i IntCounter) ToBPFData() []int {
result := make([]int, 0, len(i))
for key := range i {
result = append(result, key)
}
sort.Sort(sort.Reverse(sort.IntSlice(result)))
return result
} | [
"func",
"(",
"i",
"IntCounter",
")",
"ToBPFData",
"(",
")",
"[",
"]",
"int",
"{",
"result",
":=",
"make",
"(",
"[",
"]",
"int",
",",
"0",
",",
"len",
"(",
"i",
")",
")",
"\n\n",
"for",
"key",
":=",
"range",
"i",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"key",
")",
"\n",
"}",
"\n",
"sort",
".",
"Sort",
"(",
"sort",
".",
"Reverse",
"(",
"sort",
".",
"IntSlice",
"(",
"result",
")",
")",
")",
"\n",
"return",
"result",
"\n",
"}"
] | // ToBPFData returns the keys as a slice, sorted from high to low. | [
"ToBPFData",
"returns",
"the",
"keys",
"as",
"a",
"slice",
"sorted",
"from",
"high",
"to",
"low",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/counter/integer.go#L59-L67 |
163,049 | cilium/cilium | api/v1/server/restapi/prefilter/patch_prefilter.go | NewPatchPrefilter | func NewPatchPrefilter(ctx *middleware.Context, handler PatchPrefilterHandler) *PatchPrefilter {
return &PatchPrefilter{Context: ctx, Handler: handler}
} | go | func NewPatchPrefilter(ctx *middleware.Context, handler PatchPrefilterHandler) *PatchPrefilter {
return &PatchPrefilter{Context: ctx, Handler: handler}
} | [
"func",
"NewPatchPrefilter",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"PatchPrefilterHandler",
")",
"*",
"PatchPrefilter",
"{",
"return",
"&",
"PatchPrefilter",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewPatchPrefilter creates a new http.Handler for the patch prefilter operation | [
"NewPatchPrefilter",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"patch",
"prefilter",
"operation"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/prefilter/patch_prefilter.go#L28-L30 |
163,050 | cilium/cilium | api/v1/models/label_configuration_status.go | Validate | func (m *LabelConfigurationStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateDerived(formats); err != nil {
res = append(res, err)
}
if err := m.validateDisabled(formats); err != nil {
res = append(res, err)
}
if err := m.validateRealized(formats); err != nil {
res = append(res, err)
}
if err := m.validateSecurityRelevant(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *LabelConfigurationStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateDerived(formats); err != nil {
res = append(res, err)
}
if err := m.validateDisabled(formats); err != nil {
res = append(res, err)
}
if err := m.validateRealized(formats); err != nil {
res = append(res, err)
}
if err := m.validateSecurityRelevant(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"LabelConfigurationStatus",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateDerived",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateDisabled",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateRealized",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateSecurityRelevant",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this label configuration status | [
"Validate",
"validates",
"this",
"label",
"configuration",
"status"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/label_configuration_status.go#L33-L56 |
163,051 | cilium/cilium | pkg/bpf/map_linux.go | NewMap | func NewMap(name string, mapType MapType, keySize int, valueSize int, maxEntries int, flags uint32, innerID uint32, dumpParser DumpParser) *Map {
m := &Map{
MapInfo: MapInfo{
MapType: mapType,
KeySize: uint32(keySize),
ValueSize: uint32(valueSize),
MaxEntries: uint32(maxEntries),
Flags: flags,
InnerID: innerID,
OwnerProgType: ProgTypeUnspec,
},
name: path.Base(name),
dumpParser: dumpParser,
}
return m
} | go | func NewMap(name string, mapType MapType, keySize int, valueSize int, maxEntries int, flags uint32, innerID uint32, dumpParser DumpParser) *Map {
m := &Map{
MapInfo: MapInfo{
MapType: mapType,
KeySize: uint32(keySize),
ValueSize: uint32(valueSize),
MaxEntries: uint32(maxEntries),
Flags: flags,
InnerID: innerID,
OwnerProgType: ProgTypeUnspec,
},
name: path.Base(name),
dumpParser: dumpParser,
}
return m
} | [
"func",
"NewMap",
"(",
"name",
"string",
",",
"mapType",
"MapType",
",",
"keySize",
"int",
",",
"valueSize",
"int",
",",
"maxEntries",
"int",
",",
"flags",
"uint32",
",",
"innerID",
"uint32",
",",
"dumpParser",
"DumpParser",
")",
"*",
"Map",
"{",
"m",
":=",
"&",
"Map",
"{",
"MapInfo",
":",
"MapInfo",
"{",
"MapType",
":",
"mapType",
",",
"KeySize",
":",
"uint32",
"(",
"keySize",
")",
",",
"ValueSize",
":",
"uint32",
"(",
"valueSize",
")",
",",
"MaxEntries",
":",
"uint32",
"(",
"maxEntries",
")",
",",
"Flags",
":",
"flags",
",",
"InnerID",
":",
"innerID",
",",
"OwnerProgType",
":",
"ProgTypeUnspec",
",",
"}",
",",
"name",
":",
"path",
".",
"Base",
"(",
"name",
")",
",",
"dumpParser",
":",
"dumpParser",
",",
"}",
"\n",
"return",
"m",
"\n",
"}"
] | // NewMap creates a new Map instance - object representing a BPF map | [
"NewMap",
"creates",
"a",
"new",
"Map",
"instance",
"-",
"object",
"representing",
"a",
"BPF",
"map"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/map_linux.go#L120-L135 |
163,052 | cilium/cilium | pkg/bpf/map_linux.go | scheduleErrorResolver | func (m *Map) scheduleErrorResolver() {
m.outstandingErrors++
if time.Since(m.errorResolverLastScheduled) <= errorResolverSchedulerMinInterval {
return
}
m.errorResolverLastScheduled = time.Now()
go func() {
time.Sleep(errorResolverSchedulerDelay)
mapControllers.UpdateController(m.controllerName(),
controller.ControllerParams{
DoFunc: m.resolveErrors,
RunInterval: errorResolverSchedulerMinInterval,
},
)
}()
} | go | func (m *Map) scheduleErrorResolver() {
m.outstandingErrors++
if time.Since(m.errorResolverLastScheduled) <= errorResolverSchedulerMinInterval {
return
}
m.errorResolverLastScheduled = time.Now()
go func() {
time.Sleep(errorResolverSchedulerDelay)
mapControllers.UpdateController(m.controllerName(),
controller.ControllerParams{
DoFunc: m.resolveErrors,
RunInterval: errorResolverSchedulerMinInterval,
},
)
}()
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"scheduleErrorResolver",
"(",
")",
"{",
"m",
".",
"outstandingErrors",
"++",
"\n\n",
"if",
"time",
".",
"Since",
"(",
"m",
".",
"errorResolverLastScheduled",
")",
"<=",
"errorResolverSchedulerMinInterval",
"{",
"return",
"\n",
"}",
"\n\n",
"m",
".",
"errorResolverLastScheduled",
"=",
"time",
".",
"Now",
"(",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"time",
".",
"Sleep",
"(",
"errorResolverSchedulerDelay",
")",
"\n",
"mapControllers",
".",
"UpdateController",
"(",
"m",
".",
"controllerName",
"(",
")",
",",
"controller",
".",
"ControllerParams",
"{",
"DoFunc",
":",
"m",
".",
"resolveErrors",
",",
"RunInterval",
":",
"errorResolverSchedulerMinInterval",
",",
"}",
",",
")",
"\n",
"}",
"(",
")",
"\n\n",
"}"
] | // scheduleErrorResolver schedules a periodic resolver controller that scans
// all BPF map caches for unresolved errors and attempts to resolve them. On
// error of resolution, the controller is-rescheduled in an expedited manner
// with an exponential back-off.
//
// m.lock must be held for writing | [
"scheduleErrorResolver",
"schedules",
"a",
"periodic",
"resolver",
"controller",
"that",
"scans",
"all",
"BPF",
"map",
"caches",
"for",
"unresolved",
"errors",
"and",
"attempts",
"to",
"resolve",
"them",
".",
"On",
"error",
"of",
"resolution",
"the",
"controller",
"is",
"-",
"rescheduled",
"in",
"an",
"expedited",
"manner",
"with",
"an",
"exponential",
"back",
"-",
"off",
".",
"m",
".",
"lock",
"must",
"be",
"held",
"for",
"writing"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/map_linux.go#L158-L177 |
163,053 | cilium/cilium | pkg/bpf/map_linux.go | Path | func (m *Map) Path() (string, error) {
if err := m.setPathIfUnset(); err != nil {
return "", err
}
return m.path, nil
} | go | func (m *Map) Path() (string, error) {
if err := m.setPathIfUnset(); err != nil {
return "", err
}
return m.path, nil
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"Path",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"err",
":=",
"m",
".",
"setPathIfUnset",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"m",
".",
"path",
",",
"nil",
"\n",
"}"
] | // Path returns the path to this map on the filesystem. | [
"Path",
"returns",
"the",
"path",
"to",
"this",
"map",
"on",
"the",
"filesystem",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/map_linux.go#L198-L204 |
163,054 | cilium/cilium | pkg/bpf/map_linux.go | DeepEquals | func (m *Map) DeepEquals(other *Map) bool {
return m.MapInfo == other.MapInfo &&
m.name == other.name &&
m.path == other.path &&
m.NonPersistent == other.NonPersistent
} | go | func (m *Map) DeepEquals(other *Map) bool {
return m.MapInfo == other.MapInfo &&
m.name == other.name &&
m.path == other.path &&
m.NonPersistent == other.NonPersistent
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"DeepEquals",
"(",
"other",
"*",
"Map",
")",
"bool",
"{",
"return",
"m",
".",
"MapInfo",
"==",
"other",
".",
"MapInfo",
"&&",
"m",
".",
"name",
"==",
"other",
".",
"name",
"&&",
"m",
".",
"path",
"==",
"other",
".",
"path",
"&&",
"m",
".",
"NonPersistent",
"==",
"other",
".",
"NonPersistent",
"\n",
"}"
] | // DeepEquals compares the current map against another map to see that the
// attributes of the two maps are the same. | [
"DeepEquals",
"compares",
"the",
"current",
"map",
"against",
"another",
"map",
"to",
"see",
"that",
"the",
"attributes",
"of",
"the",
"two",
"maps",
"are",
"the",
"same",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/map_linux.go#L232-L237 |
163,055 | cilium/cilium | pkg/bpf/map_linux.go | EndParallelMode | func (m *Map) EndParallelMode() {
m.lock.Lock()
defer m.lock.Unlock()
if m.inParallelMode {
m.inParallelMode = false
m.scopedLogger().Debug("End of parallel mode")
}
} | go | func (m *Map) EndParallelMode() {
m.lock.Lock()
defer m.lock.Unlock()
if m.inParallelMode {
m.inParallelMode = false
m.scopedLogger().Debug("End of parallel mode")
}
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"EndParallelMode",
"(",
")",
"{",
"m",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"m",
".",
"inParallelMode",
"{",
"m",
".",
"inParallelMode",
"=",
"false",
"\n",
"m",
".",
"scopedLogger",
"(",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] | // EndParallelMode ends the parallel mode of a map | [
"EndParallelMode",
"ends",
"the",
"parallel",
"mode",
"of",
"a",
"map"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/map_linux.go#L332-L340 |
163,056 | cilium/cilium | pkg/bpf/map_linux.go | DumpWithCallback | func (m *Map) DumpWithCallback(cb DumpCallback) error {
m.lock.RLock()
defer m.lock.RUnlock()
key := make([]byte, m.KeySize)
nextKey := make([]byte, m.KeySize)
value := make([]byte, m.ValueSize)
if err := m.Open(); err != nil {
return err
}
for {
err := GetNextKey(
m.fd,
unsafe.Pointer(&key[0]),
unsafe.Pointer(&nextKey[0]),
)
if err != nil {
break
}
err = LookupElement(
m.fd,
unsafe.Pointer(&nextKey[0]),
unsafe.Pointer(&value[0]),
)
if err != nil {
return err
}
k, v, err := m.dumpParser(nextKey, value)
if err != nil {
return err
}
if cb != nil {
cb(k, v)
}
copy(key, nextKey)
}
return nil
} | go | func (m *Map) DumpWithCallback(cb DumpCallback) error {
m.lock.RLock()
defer m.lock.RUnlock()
key := make([]byte, m.KeySize)
nextKey := make([]byte, m.KeySize)
value := make([]byte, m.ValueSize)
if err := m.Open(); err != nil {
return err
}
for {
err := GetNextKey(
m.fd,
unsafe.Pointer(&key[0]),
unsafe.Pointer(&nextKey[0]),
)
if err != nil {
break
}
err = LookupElement(
m.fd,
unsafe.Pointer(&nextKey[0]),
unsafe.Pointer(&value[0]),
)
if err != nil {
return err
}
k, v, err := m.dumpParser(nextKey, value)
if err != nil {
return err
}
if cb != nil {
cb(k, v)
}
copy(key, nextKey)
}
return nil
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"DumpWithCallback",
"(",
"cb",
"DumpCallback",
")",
"error",
"{",
"m",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"key",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"m",
".",
"KeySize",
")",
"\n",
"nextKey",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"m",
".",
"KeySize",
")",
"\n",
"value",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"m",
".",
"ValueSize",
")",
"\n\n",
"if",
"err",
":=",
"m",
".",
"Open",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"for",
"{",
"err",
":=",
"GetNextKey",
"(",
"m",
".",
"fd",
",",
"unsafe",
".",
"Pointer",
"(",
"&",
"key",
"[",
"0",
"]",
")",
",",
"unsafe",
".",
"Pointer",
"(",
"&",
"nextKey",
"[",
"0",
"]",
")",
",",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"break",
"\n",
"}",
"\n\n",
"err",
"=",
"LookupElement",
"(",
"m",
".",
"fd",
",",
"unsafe",
".",
"Pointer",
"(",
"&",
"nextKey",
"[",
"0",
"]",
")",
",",
"unsafe",
".",
"Pointer",
"(",
"&",
"value",
"[",
"0",
"]",
")",
",",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"k",
",",
"v",
",",
"err",
":=",
"m",
".",
"dumpParser",
"(",
"nextKey",
",",
"value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"cb",
"!=",
"nil",
"{",
"cb",
"(",
"k",
",",
"v",
")",
"\n",
"}",
"\n\n",
"copy",
"(",
"key",
",",
"nextKey",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // DumpWithCallback iterates over the Map and calls the given callback
// function on each iteration. That callback function is receiving the
// actual key and value. | [
"DumpWithCallback",
"iterates",
"over",
"the",
"Map",
"and",
"calls",
"the",
"given",
"callback",
"function",
"on",
"each",
"iteration",
".",
"That",
"callback",
"function",
"is",
"receiving",
"the",
"actual",
"key",
"and",
"value",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/map_linux.go#L488-L533 |
163,057 | cilium/cilium | pkg/bpf/map_linux.go | DumpWithCallbackIfExists | func (m *Map) DumpWithCallbackIfExists(cb DumpCallback) error {
found, err := m.exist()
if err != nil {
return err
}
if found {
return m.DumpWithCallback(cb)
}
return nil
} | go | func (m *Map) DumpWithCallbackIfExists(cb DumpCallback) error {
found, err := m.exist()
if err != nil {
return err
}
if found {
return m.DumpWithCallback(cb)
}
return nil
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"DumpWithCallbackIfExists",
"(",
"cb",
"DumpCallback",
")",
"error",
"{",
"found",
",",
"err",
":=",
"m",
".",
"exist",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"found",
"{",
"return",
"m",
".",
"DumpWithCallback",
"(",
"cb",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // DumpWithCallbackIfExists is similar to DumpWithCallback, but returns earlier
// if the given map does not exist. | [
"DumpWithCallbackIfExists",
"is",
"similar",
"to",
"DumpWithCallback",
"but",
"returns",
"earlier",
"if",
"the",
"given",
"map",
"does",
"not",
"exist",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/map_linux.go#L537-L548 |
163,058 | cilium/cilium | pkg/bpf/map_linux.go | deleteCacheEntry | func (m *Map) deleteCacheEntry(key MapKey, err error) {
if m.cache == nil {
return
}
k := key.String()
if err == nil {
delete(m.cache, k)
} else {
entry, ok := m.cache[k]
if !ok {
m.cache[k] = &cacheEntry{
Key: key,
}
entry = m.cache[k]
}
entry.DesiredAction = Delete
entry.LastError = err
m.scheduleErrorResolver()
}
} | go | func (m *Map) deleteCacheEntry(key MapKey, err error) {
if m.cache == nil {
return
}
k := key.String()
if err == nil {
delete(m.cache, k)
} else {
entry, ok := m.cache[k]
if !ok {
m.cache[k] = &cacheEntry{
Key: key,
}
entry = m.cache[k]
}
entry.DesiredAction = Delete
entry.LastError = err
m.scheduleErrorResolver()
}
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"deleteCacheEntry",
"(",
"key",
"MapKey",
",",
"err",
"error",
")",
"{",
"if",
"m",
".",
"cache",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"k",
":=",
"key",
".",
"String",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"delete",
"(",
"m",
".",
"cache",
",",
"k",
")",
"\n",
"}",
"else",
"{",
"entry",
",",
"ok",
":=",
"m",
".",
"cache",
"[",
"k",
"]",
"\n",
"if",
"!",
"ok",
"{",
"m",
".",
"cache",
"[",
"k",
"]",
"=",
"&",
"cacheEntry",
"{",
"Key",
":",
"key",
",",
"}",
"\n",
"entry",
"=",
"m",
".",
"cache",
"[",
"k",
"]",
"\n",
"}",
"\n\n",
"entry",
".",
"DesiredAction",
"=",
"Delete",
"\n",
"entry",
".",
"LastError",
"=",
"err",
"\n",
"m",
".",
"scheduleErrorResolver",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // deleteCacheEntry evaluates the specified error, if nil the map key is
// removed from the cache to indicate successful deletion. If non-nil, the map
// key entry in the cache is updated to indicate deletion failure with the
// specified error.
//
// Caller must hold m.lock for writing | [
"deleteCacheEntry",
"evaluates",
"the",
"specified",
"error",
"if",
"nil",
"the",
"map",
"key",
"is",
"removed",
"from",
"the",
"cache",
"to",
"indicate",
"successful",
"deletion",
".",
"If",
"non",
"-",
"nil",
"the",
"map",
"key",
"entry",
"in",
"the",
"cache",
"is",
"updated",
"to",
"indicate",
"deletion",
"failure",
"with",
"the",
"specified",
"error",
".",
"Caller",
"must",
"hold",
"m",
".",
"lock",
"for",
"writing"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/map_linux.go#L721-L742 |
163,059 | cilium/cilium | pkg/bpf/map_linux.go | scopedLogger | func (m *Map) scopedLogger() *logrus.Entry {
return log.WithFields(logrus.Fields{logfields.Path: m.path, "name": m.name})
} | go | func (m *Map) scopedLogger() *logrus.Entry {
return log.WithFields(logrus.Fields{logfields.Path: m.path, "name": m.name})
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"scopedLogger",
"(",
")",
"*",
"logrus",
".",
"Entry",
"{",
"return",
"log",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"logfields",
".",
"Path",
":",
"m",
".",
"path",
",",
"\"",
"\"",
":",
"m",
".",
"name",
"}",
")",
"\n",
"}"
] | // scopedLogger returns a logger scoped for the map. m.lock must be held. | [
"scopedLogger",
"returns",
"a",
"logger",
"scoped",
"for",
"the",
"map",
".",
"m",
".",
"lock",
"must",
"be",
"held",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/map_linux.go#L774-L776 |
163,060 | cilium/cilium | pkg/bpf/map_linux.go | DeleteAll | func (m *Map) DeleteAll() error {
m.lock.Lock()
defer m.lock.Unlock()
scopedLog := m.scopedLogger()
scopedLog.Debug("deleting all entries in map")
key := make([]byte, m.KeySize)
nextKey := make([]byte, m.KeySize)
if m.cache != nil {
// Mark all entries for deletion, upon successful deletion,
// entries will be removed or the LastError will be updated
for _, entry := range m.cache {
entry.DesiredAction = Delete
entry.LastError = fmt.Errorf("deletion pending")
}
}
if err := m.Open(); err != nil {
return err
}
for {
err := GetNextKey(
m.fd,
unsafe.Pointer(&key[0]),
unsafe.Pointer(&nextKey[0]),
)
if err != nil {
break
}
err = DeleteElement(m.fd, unsafe.Pointer(&nextKey[0]))
k, _, err2 := m.dumpParser(nextKey, []byte{})
if err2 == nil {
m.deleteCacheEntry(k, err)
} else {
log.WithError(err2).Warningf("Unable to correlate iteration key %v with cache entry. Inconsistent cache.", nextKey)
}
if err != nil {
return err
}
copy(key, nextKey)
}
return nil
} | go | func (m *Map) DeleteAll() error {
m.lock.Lock()
defer m.lock.Unlock()
scopedLog := m.scopedLogger()
scopedLog.Debug("deleting all entries in map")
key := make([]byte, m.KeySize)
nextKey := make([]byte, m.KeySize)
if m.cache != nil {
// Mark all entries for deletion, upon successful deletion,
// entries will be removed or the LastError will be updated
for _, entry := range m.cache {
entry.DesiredAction = Delete
entry.LastError = fmt.Errorf("deletion pending")
}
}
if err := m.Open(); err != nil {
return err
}
for {
err := GetNextKey(
m.fd,
unsafe.Pointer(&key[0]),
unsafe.Pointer(&nextKey[0]),
)
if err != nil {
break
}
err = DeleteElement(m.fd, unsafe.Pointer(&nextKey[0]))
k, _, err2 := m.dumpParser(nextKey, []byte{})
if err2 == nil {
m.deleteCacheEntry(k, err)
} else {
log.WithError(err2).Warningf("Unable to correlate iteration key %v with cache entry. Inconsistent cache.", nextKey)
}
if err != nil {
return err
}
copy(key, nextKey)
}
return nil
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"DeleteAll",
"(",
")",
"error",
"{",
"m",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"scopedLog",
":=",
"m",
".",
"scopedLogger",
"(",
")",
"\n",
"scopedLog",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"key",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"m",
".",
"KeySize",
")",
"\n",
"nextKey",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"m",
".",
"KeySize",
")",
"\n\n",
"if",
"m",
".",
"cache",
"!=",
"nil",
"{",
"// Mark all entries for deletion, upon successful deletion,",
"// entries will be removed or the LastError will be updated",
"for",
"_",
",",
"entry",
":=",
"range",
"m",
".",
"cache",
"{",
"entry",
".",
"DesiredAction",
"=",
"Delete",
"\n",
"entry",
".",
"LastError",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"Open",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"for",
"{",
"err",
":=",
"GetNextKey",
"(",
"m",
".",
"fd",
",",
"unsafe",
".",
"Pointer",
"(",
"&",
"key",
"[",
"0",
"]",
")",
",",
"unsafe",
".",
"Pointer",
"(",
"&",
"nextKey",
"[",
"0",
"]",
")",
",",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"break",
"\n",
"}",
"\n\n",
"err",
"=",
"DeleteElement",
"(",
"m",
".",
"fd",
",",
"unsafe",
".",
"Pointer",
"(",
"&",
"nextKey",
"[",
"0",
"]",
")",
")",
"\n\n",
"k",
",",
"_",
",",
"err2",
":=",
"m",
".",
"dumpParser",
"(",
"nextKey",
",",
"[",
"]",
"byte",
"{",
"}",
")",
"\n",
"if",
"err2",
"==",
"nil",
"{",
"m",
".",
"deleteCacheEntry",
"(",
"k",
",",
"err",
")",
"\n",
"}",
"else",
"{",
"log",
".",
"WithError",
"(",
"err2",
")",
".",
"Warningf",
"(",
"\"",
"\"",
",",
"nextKey",
")",
"\n",
"}",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"copy",
"(",
"key",
",",
"nextKey",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // DeleteAll deletes all entries of a map by traversing the map and deleting individual
// entries. Note that if entries are added while the taversal is in progress,
// such entries may survive the deletion process. | [
"DeleteAll",
"deletes",
"all",
"entries",
"of",
"a",
"map",
"by",
"traversing",
"the",
"map",
"and",
"deleting",
"individual",
"entries",
".",
"Note",
"that",
"if",
"entries",
"are",
"added",
"while",
"the",
"taversal",
"is",
"in",
"progress",
"such",
"entries",
"may",
"survive",
"the",
"deletion",
"process",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/map_linux.go#L781-L832 |
163,061 | cilium/cilium | pkg/bpf/map_linux.go | GetNextKey | func (m *Map) GetNextKey(key MapKey, nextKey MapKey) error {
if err := m.Open(); err != nil {
return err
}
err := GetNextKey(m.fd, key.GetKeyPtr(), nextKey.GetKeyPtr())
metricMapOps.WithLabelValues(m.commonName(), metricOpGetNextKey, metrics.Error2Outcome(err)).Inc()
return err
} | go | func (m *Map) GetNextKey(key MapKey, nextKey MapKey) error {
if err := m.Open(); err != nil {
return err
}
err := GetNextKey(m.fd, key.GetKeyPtr(), nextKey.GetKeyPtr())
metricMapOps.WithLabelValues(m.commonName(), metricOpGetNextKey, metrics.Error2Outcome(err)).Inc()
return err
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"GetNextKey",
"(",
"key",
"MapKey",
",",
"nextKey",
"MapKey",
")",
"error",
"{",
"if",
"err",
":=",
"m",
".",
"Open",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"err",
":=",
"GetNextKey",
"(",
"m",
".",
"fd",
",",
"key",
".",
"GetKeyPtr",
"(",
")",
",",
"nextKey",
".",
"GetKeyPtr",
"(",
")",
")",
"\n",
"metricMapOps",
".",
"WithLabelValues",
"(",
"m",
".",
"commonName",
"(",
")",
",",
"metricOpGetNextKey",
",",
"metrics",
".",
"Error2Outcome",
"(",
"err",
")",
")",
".",
"Inc",
"(",
")",
"\n",
"return",
"err",
"\n",
"}"
] | //GetNextKey returns the next key in the Map after key. | [
"GetNextKey",
"returns",
"the",
"next",
"key",
"in",
"the",
"Map",
"after",
"key",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/map_linux.go#L835-L843 |
163,062 | cilium/cilium | pkg/bpf/map_linux.go | ConvertKeyValue | func ConvertKeyValue(bKey []byte, bValue []byte, key interface{}, value interface{}) error {
keyBuf := bytes.NewBuffer(bKey)
valueBuf := bytes.NewBuffer(bValue)
if len(bKey) > 0 {
if err := binary.Read(keyBuf, byteorder.Native, key); err != nil {
return fmt.Errorf("Unable to convert key: %s", err)
}
}
if len(bValue) > 0 {
if err := binary.Read(valueBuf, byteorder.Native, value); err != nil {
return fmt.Errorf("Unable to convert value: %s", err)
}
}
return nil
} | go | func ConvertKeyValue(bKey []byte, bValue []byte, key interface{}, value interface{}) error {
keyBuf := bytes.NewBuffer(bKey)
valueBuf := bytes.NewBuffer(bValue)
if len(bKey) > 0 {
if err := binary.Read(keyBuf, byteorder.Native, key); err != nil {
return fmt.Errorf("Unable to convert key: %s", err)
}
}
if len(bValue) > 0 {
if err := binary.Read(valueBuf, byteorder.Native, value); err != nil {
return fmt.Errorf("Unable to convert value: %s", err)
}
}
return nil
} | [
"func",
"ConvertKeyValue",
"(",
"bKey",
"[",
"]",
"byte",
",",
"bValue",
"[",
"]",
"byte",
",",
"key",
"interface",
"{",
"}",
",",
"value",
"interface",
"{",
"}",
")",
"error",
"{",
"keyBuf",
":=",
"bytes",
".",
"NewBuffer",
"(",
"bKey",
")",
"\n",
"valueBuf",
":=",
"bytes",
".",
"NewBuffer",
"(",
"bValue",
")",
"\n\n",
"if",
"len",
"(",
"bKey",
")",
">",
"0",
"{",
"if",
"err",
":=",
"binary",
".",
"Read",
"(",
"keyBuf",
",",
"byteorder",
".",
"Native",
",",
"key",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"bValue",
")",
">",
"0",
"{",
"if",
"err",
":=",
"binary",
".",
"Read",
"(",
"valueBuf",
",",
"byteorder",
".",
"Native",
",",
"value",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // ConvertKeyValue converts key and value from bytes to given Golang struct pointers. | [
"ConvertKeyValue",
"converts",
"key",
"and",
"value",
"from",
"bytes",
"to",
"given",
"Golang",
"struct",
"pointers",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/map_linux.go#L846-L863 |
163,063 | cilium/cilium | pkg/bpf/map_linux.go | GetModel | func (m *Map) GetModel() *models.BPFMap {
m.lock.RLock()
defer m.lock.RUnlock()
mapModel := &models.BPFMap{
Path: m.path,
}
if m.cache != nil {
mapModel.Cache = make([]*models.BPFMapEntry, len(m.cache))
i := 0
for k, entry := range m.cache {
model := &models.BPFMapEntry{
Key: k,
DesiredAction: entry.DesiredAction.String(),
}
if entry.LastError != nil {
model.LastError = entry.LastError.Error()
}
if entry.Value != nil {
model.Value = entry.Value.String()
}
mapModel.Cache[i] = model
i++
}
}
return mapModel
} | go | func (m *Map) GetModel() *models.BPFMap {
m.lock.RLock()
defer m.lock.RUnlock()
mapModel := &models.BPFMap{
Path: m.path,
}
if m.cache != nil {
mapModel.Cache = make([]*models.BPFMapEntry, len(m.cache))
i := 0
for k, entry := range m.cache {
model := &models.BPFMapEntry{
Key: k,
DesiredAction: entry.DesiredAction.String(),
}
if entry.LastError != nil {
model.LastError = entry.LastError.Error()
}
if entry.Value != nil {
model.Value = entry.Value.String()
}
mapModel.Cache[i] = model
i++
}
}
return mapModel
} | [
"func",
"(",
"m",
"*",
"Map",
")",
"GetModel",
"(",
")",
"*",
"models",
".",
"BPFMap",
"{",
"m",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"mapModel",
":=",
"&",
"models",
".",
"BPFMap",
"{",
"Path",
":",
"m",
".",
"path",
",",
"}",
"\n\n",
"if",
"m",
".",
"cache",
"!=",
"nil",
"{",
"mapModel",
".",
"Cache",
"=",
"make",
"(",
"[",
"]",
"*",
"models",
".",
"BPFMapEntry",
",",
"len",
"(",
"m",
".",
"cache",
")",
")",
"\n",
"i",
":=",
"0",
"\n",
"for",
"k",
",",
"entry",
":=",
"range",
"m",
".",
"cache",
"{",
"model",
":=",
"&",
"models",
".",
"BPFMapEntry",
"{",
"Key",
":",
"k",
",",
"DesiredAction",
":",
"entry",
".",
"DesiredAction",
".",
"String",
"(",
")",
",",
"}",
"\n\n",
"if",
"entry",
".",
"LastError",
"!=",
"nil",
"{",
"model",
".",
"LastError",
"=",
"entry",
".",
"LastError",
".",
"Error",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"entry",
".",
"Value",
"!=",
"nil",
"{",
"model",
".",
"Value",
"=",
"entry",
".",
"Value",
".",
"String",
"(",
")",
"\n",
"}",
"\n",
"mapModel",
".",
"Cache",
"[",
"i",
"]",
"=",
"model",
"\n",
"i",
"++",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"mapModel",
"\n",
"}"
] | // GetModel returns a BPF map in the representation served via the API | [
"GetModel",
"returns",
"a",
"BPF",
"map",
"in",
"the",
"representation",
"served",
"via",
"the",
"API"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/map_linux.go#L866-L896 |
163,064 | cilium/cilium | monitor/monitor.go | agentPipeReader | func (m *Monitor) agentPipeReader(ctx context.Context, agentPipe io.Reader) {
log.Info("Beginning to read cilium agent events")
defer log.Info("Stopped reading cilium agent events")
for !isCtxDone(ctx) {
meta, p := payload.Meta{}, payload.Payload{}
err := payload.ReadMetaPayload(agentPipe, &meta, &p)
switch {
// this captures the case where we are shutting down and main closes the
// pipe socket
case isCtxDone(ctx):
return
case err == io.EOF || err == io.ErrUnexpectedEOF:
log.Fatal("Agent pipe unexpectedly closed, shutting down")
case err != nil:
log.WithError(err).Fatal("Unable to read cilium agent events from pipe")
}
m.send(&p)
}
} | go | func (m *Monitor) agentPipeReader(ctx context.Context, agentPipe io.Reader) {
log.Info("Beginning to read cilium agent events")
defer log.Info("Stopped reading cilium agent events")
for !isCtxDone(ctx) {
meta, p := payload.Meta{}, payload.Payload{}
err := payload.ReadMetaPayload(agentPipe, &meta, &p)
switch {
// this captures the case where we are shutting down and main closes the
// pipe socket
case isCtxDone(ctx):
return
case err == io.EOF || err == io.ErrUnexpectedEOF:
log.Fatal("Agent pipe unexpectedly closed, shutting down")
case err != nil:
log.WithError(err).Fatal("Unable to read cilium agent events from pipe")
}
m.send(&p)
}
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"agentPipeReader",
"(",
"ctx",
"context",
".",
"Context",
",",
"agentPipe",
"io",
".",
"Reader",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"defer",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"for",
"!",
"isCtxDone",
"(",
"ctx",
")",
"{",
"meta",
",",
"p",
":=",
"payload",
".",
"Meta",
"{",
"}",
",",
"payload",
".",
"Payload",
"{",
"}",
"\n",
"err",
":=",
"payload",
".",
"ReadMetaPayload",
"(",
"agentPipe",
",",
"&",
"meta",
",",
"&",
"p",
")",
"\n",
"switch",
"{",
"// this captures the case where we are shutting down and main closes the",
"// pipe socket",
"case",
"isCtxDone",
"(",
"ctx",
")",
":",
"return",
"\n\n",
"case",
"err",
"==",
"io",
".",
"EOF",
"||",
"err",
"==",
"io",
".",
"ErrUnexpectedEOF",
":",
"log",
".",
"Fatal",
"(",
"\"",
"\"",
")",
"\n\n",
"case",
"err",
"!=",
"nil",
":",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"Fatal",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"m",
".",
"send",
"(",
"&",
"p",
")",
"\n",
"}",
"\n",
"}"
] | // agentPipeReader reads agent events from the agentPipe and distributes to all listeners | [
"agentPipeReader",
"reads",
"agent",
"events",
"from",
"the",
"agentPipe",
"and",
"distributes",
"to",
"all",
"listeners"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/monitor/monitor.go#L78-L100 |
163,065 | cilium/cilium | monitor/monitor.go | NewMonitor | func NewMonitor(ctx context.Context, nPages int, agentPipe io.Reader, server1_0, server1_2 net.Listener) (m *Monitor, err error) {
m = &Monitor{
ctx: ctx,
listeners: make(map[listener.MonitorListener]struct{}),
nPages: nPages,
perfReaderCancel: func() {}, // no-op to avoid doing null checks everywhere
}
// start new MonitorListener handler
go m.connectionHandler1_0(ctx, server1_0)
go m.connectionHandler1_2(ctx, server1_2)
// start agent event pipe reader
go m.agentPipeReader(ctx, agentPipe)
return m, nil
} | go | func NewMonitor(ctx context.Context, nPages int, agentPipe io.Reader, server1_0, server1_2 net.Listener) (m *Monitor, err error) {
m = &Monitor{
ctx: ctx,
listeners: make(map[listener.MonitorListener]struct{}),
nPages: nPages,
perfReaderCancel: func() {}, // no-op to avoid doing null checks everywhere
}
// start new MonitorListener handler
go m.connectionHandler1_0(ctx, server1_0)
go m.connectionHandler1_2(ctx, server1_2)
// start agent event pipe reader
go m.agentPipeReader(ctx, agentPipe)
return m, nil
} | [
"func",
"NewMonitor",
"(",
"ctx",
"context",
".",
"Context",
",",
"nPages",
"int",
",",
"agentPipe",
"io",
".",
"Reader",
",",
"server1_0",
",",
"server1_2",
"net",
".",
"Listener",
")",
"(",
"m",
"*",
"Monitor",
",",
"err",
"error",
")",
"{",
"m",
"=",
"&",
"Monitor",
"{",
"ctx",
":",
"ctx",
",",
"listeners",
":",
"make",
"(",
"map",
"[",
"listener",
".",
"MonitorListener",
"]",
"struct",
"{",
"}",
")",
",",
"nPages",
":",
"nPages",
",",
"perfReaderCancel",
":",
"func",
"(",
")",
"{",
"}",
",",
"// no-op to avoid doing null checks everywhere",
"}",
"\n\n",
"// start new MonitorListener handler",
"go",
"m",
".",
"connectionHandler1_0",
"(",
"ctx",
",",
"server1_0",
")",
"\n",
"go",
"m",
".",
"connectionHandler1_2",
"(",
"ctx",
",",
"server1_2",
")",
"\n\n",
"// start agent event pipe reader",
"go",
"m",
".",
"agentPipeReader",
"(",
"ctx",
",",
"agentPipe",
")",
"\n\n",
"return",
"m",
",",
"nil",
"\n",
"}"
] | // NewMonitor creates a Monitor, and starts client connection handling and agent event
// handling.
// Note that the perf buffer reader is started only when listeners are
// connected. | [
"NewMonitor",
"creates",
"a",
"Monitor",
"and",
"starts",
"client",
"connection",
"handling",
"and",
"agent",
"event",
"handling",
".",
"Note",
"that",
"the",
"perf",
"buffer",
"reader",
"is",
"started",
"only",
"when",
"listeners",
"are",
"connected",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/monitor/monitor.go#L106-L122 |
163,066 | cilium/cilium | monitor/monitor.go | removeListener | func (m *Monitor) removeListener(ml listener.MonitorListener) {
m.Lock()
defer m.Unlock()
delete(m.listeners, ml)
log.WithFields(logrus.Fields{
"count.listener": len(m.listeners),
"version": ml.Version(),
}).Debug("Removed listener")
// If this was the final listener, shutdown the perf reader and unmap our
// ring buffer readers. This tells the kernel to not emit this data.
// Note: it is critical to hold the lock and check the number of listeners.
// This guards against an older generation listener calling the
// current generation perfReaderCancel
if len(m.listeners) == 0 {
m.perfReaderCancel()
}
} | go | func (m *Monitor) removeListener(ml listener.MonitorListener) {
m.Lock()
defer m.Unlock()
delete(m.listeners, ml)
log.WithFields(logrus.Fields{
"count.listener": len(m.listeners),
"version": ml.Version(),
}).Debug("Removed listener")
// If this was the final listener, shutdown the perf reader and unmap our
// ring buffer readers. This tells the kernel to not emit this data.
// Note: it is critical to hold the lock and check the number of listeners.
// This guards against an older generation listener calling the
// current generation perfReaderCancel
if len(m.listeners) == 0 {
m.perfReaderCancel()
}
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"removeListener",
"(",
"ml",
"listener",
".",
"MonitorListener",
")",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"delete",
"(",
"m",
".",
"listeners",
",",
"ml",
")",
"\n",
"log",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"\"",
"\"",
":",
"len",
"(",
"m",
".",
"listeners",
")",
",",
"\"",
"\"",
":",
"ml",
".",
"Version",
"(",
")",
",",
"}",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"// If this was the final listener, shutdown the perf reader and unmap our",
"// ring buffer readers. This tells the kernel to not emit this data.",
"// Note: it is critical to hold the lock and check the number of listeners.",
"// This guards against an older generation listener calling the",
"// current generation perfReaderCancel",
"if",
"len",
"(",
"m",
".",
"listeners",
")",
"==",
"0",
"{",
"m",
".",
"perfReaderCancel",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // removeListener deletes the MonitorListener from the list, closes its queue, and
// stops perfReader if this is the last MonitorListener | [
"removeListener",
"deletes",
"the",
"MonitorListener",
"from",
"the",
"list",
"closes",
"its",
"queue",
"and",
"stops",
"perfReader",
"if",
"this",
"is",
"the",
"last",
"MonitorListener"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/monitor/monitor.go#L163-L181 |
163,067 | cilium/cilium | monitor/monitor.go | perfEventReader | func (m *Monitor) perfEventReader(stopCtx context.Context, nPages int) {
scopedLog := log.WithField(logfields.StartTime, time.Now())
scopedLog.Info("Beginning to read perf buffer")
defer scopedLog.Info("Stopped reading perf buffer")
// configure BPF perf buffer reader
c := bpf.DefaultPerfEventConfig()
c.NumPages = nPages
monitorEvents, err := bpf.NewPerCpuEvents(c)
if err != nil {
scopedLog.WithError(err).Fatal("Cannot initialise BPF perf ring buffer sockets")
}
defer monitorEvents.CloseAll()
// update the class's monitorEvents This is only accessed by .DumpStats()
// also grab the callbacks we need to avoid locking again. These methods never change.
m.Lock()
m.monitorEvents = monitorEvents
receiveEvent := m.receiveEvent
lostEvent := m.lostEvent
errorEvent := m.errorEvent
m.Unlock()
last := time.Now()
for !isCtxDone(stopCtx) {
todo, err := monitorEvents.Poll(pollTimeout)
switch {
case isCtxDone(stopCtx):
return
case err == syscall.EBADF:
return
case err != nil:
scopedLog.WithError(err).Error("Error in Poll")
continue
}
if todo > 0 {
if err := monitorEvents.ReadAll(receiveEvent, lostEvent, errorEvent); err != nil {
scopedLog.WithError(err).Warn("Error received while reading from perf buffer")
}
}
if time.Since(last) > 5*time.Second {
last = time.Now()
m.dumpStat()
}
}
} | go | func (m *Monitor) perfEventReader(stopCtx context.Context, nPages int) {
scopedLog := log.WithField(logfields.StartTime, time.Now())
scopedLog.Info("Beginning to read perf buffer")
defer scopedLog.Info("Stopped reading perf buffer")
// configure BPF perf buffer reader
c := bpf.DefaultPerfEventConfig()
c.NumPages = nPages
monitorEvents, err := bpf.NewPerCpuEvents(c)
if err != nil {
scopedLog.WithError(err).Fatal("Cannot initialise BPF perf ring buffer sockets")
}
defer monitorEvents.CloseAll()
// update the class's monitorEvents This is only accessed by .DumpStats()
// also grab the callbacks we need to avoid locking again. These methods never change.
m.Lock()
m.monitorEvents = monitorEvents
receiveEvent := m.receiveEvent
lostEvent := m.lostEvent
errorEvent := m.errorEvent
m.Unlock()
last := time.Now()
for !isCtxDone(stopCtx) {
todo, err := monitorEvents.Poll(pollTimeout)
switch {
case isCtxDone(stopCtx):
return
case err == syscall.EBADF:
return
case err != nil:
scopedLog.WithError(err).Error("Error in Poll")
continue
}
if todo > 0 {
if err := monitorEvents.ReadAll(receiveEvent, lostEvent, errorEvent); err != nil {
scopedLog.WithError(err).Warn("Error received while reading from perf buffer")
}
}
if time.Since(last) > 5*time.Second {
last = time.Now()
m.dumpStat()
}
}
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"perfEventReader",
"(",
"stopCtx",
"context",
".",
"Context",
",",
"nPages",
"int",
")",
"{",
"scopedLog",
":=",
"log",
".",
"WithField",
"(",
"logfields",
".",
"StartTime",
",",
"time",
".",
"Now",
"(",
")",
")",
"\n",
"scopedLog",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"defer",
"scopedLog",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"// configure BPF perf buffer reader",
"c",
":=",
"bpf",
".",
"DefaultPerfEventConfig",
"(",
")",
"\n",
"c",
".",
"NumPages",
"=",
"nPages",
"\n\n",
"monitorEvents",
",",
"err",
":=",
"bpf",
".",
"NewPerCpuEvents",
"(",
"c",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"scopedLog",
".",
"WithError",
"(",
"err",
")",
".",
"Fatal",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"defer",
"monitorEvents",
".",
"CloseAll",
"(",
")",
"\n\n",
"// update the class's monitorEvents This is only accessed by .DumpStats()",
"// also grab the callbacks we need to avoid locking again. These methods never change.",
"m",
".",
"Lock",
"(",
")",
"\n",
"m",
".",
"monitorEvents",
"=",
"monitorEvents",
"\n",
"receiveEvent",
":=",
"m",
".",
"receiveEvent",
"\n",
"lostEvent",
":=",
"m",
".",
"lostEvent",
"\n",
"errorEvent",
":=",
"m",
".",
"errorEvent",
"\n",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"last",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"for",
"!",
"isCtxDone",
"(",
"stopCtx",
")",
"{",
"todo",
",",
"err",
":=",
"monitorEvents",
".",
"Poll",
"(",
"pollTimeout",
")",
"\n",
"switch",
"{",
"case",
"isCtxDone",
"(",
"stopCtx",
")",
":",
"return",
"\n\n",
"case",
"err",
"==",
"syscall",
".",
"EBADF",
":",
"return",
"\n\n",
"case",
"err",
"!=",
"nil",
":",
"scopedLog",
".",
"WithError",
"(",
"err",
")",
".",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"if",
"todo",
">",
"0",
"{",
"if",
"err",
":=",
"monitorEvents",
".",
"ReadAll",
"(",
"receiveEvent",
",",
"lostEvent",
",",
"errorEvent",
")",
";",
"err",
"!=",
"nil",
"{",
"scopedLog",
".",
"WithError",
"(",
"err",
")",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"time",
".",
"Since",
"(",
"last",
")",
">",
"5",
"*",
"time",
".",
"Second",
"{",
"last",
"=",
"time",
".",
"Now",
"(",
")",
"\n",
"m",
".",
"dumpStat",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // perfEventReader is a goroutine that reads events from the perf buffer. It
// will exit when stopCtx is done. Note, however, that it will block in the
// Poll call but assumes enough events are generated that these blocks are
// short. | [
"perfEventReader",
"is",
"a",
"goroutine",
"that",
"reads",
"events",
"from",
"the",
"perf",
"buffer",
".",
"It",
"will",
"exit",
"when",
"stopCtx",
"is",
"done",
".",
"Note",
"however",
"that",
"it",
"will",
"block",
"in",
"the",
"Poll",
"call",
"but",
"assumes",
"enough",
"events",
"are",
"generated",
"that",
"these",
"blocks",
"are",
"short",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/monitor/monitor.go#L187-L237 |
163,068 | cilium/cilium | monitor/monitor.go | dumpStat | func (m *Monitor) dumpStat() {
m.Lock()
defer m.Unlock()
c := int64(m.monitorEvents.Cpus)
n := int64(m.monitorEvents.Npages)
p := int64(m.monitorEvents.Pagesize)
l, _, u := m.monitorEvents.Stats()
ms := models.MonitorStatus{Cpus: c, Npages: n, Pagesize: p, Lost: int64(l), Unknown: int64(u)}
mp, err := json.Marshal(ms)
if err != nil {
log.WithError(err).Error("Error marshalling JSON")
return
}
fmt.Println(string(mp))
} | go | func (m *Monitor) dumpStat() {
m.Lock()
defer m.Unlock()
c := int64(m.monitorEvents.Cpus)
n := int64(m.monitorEvents.Npages)
p := int64(m.monitorEvents.Pagesize)
l, _, u := m.monitorEvents.Stats()
ms := models.MonitorStatus{Cpus: c, Npages: n, Pagesize: p, Lost: int64(l), Unknown: int64(u)}
mp, err := json.Marshal(ms)
if err != nil {
log.WithError(err).Error("Error marshalling JSON")
return
}
fmt.Println(string(mp))
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"dumpStat",
"(",
")",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"c",
":=",
"int64",
"(",
"m",
".",
"monitorEvents",
".",
"Cpus",
")",
"\n",
"n",
":=",
"int64",
"(",
"m",
".",
"monitorEvents",
".",
"Npages",
")",
"\n",
"p",
":=",
"int64",
"(",
"m",
".",
"monitorEvents",
".",
"Pagesize",
")",
"\n",
"l",
",",
"_",
",",
"u",
":=",
"m",
".",
"monitorEvents",
".",
"Stats",
"(",
")",
"\n",
"ms",
":=",
"models",
".",
"MonitorStatus",
"{",
"Cpus",
":",
"c",
",",
"Npages",
":",
"n",
",",
"Pagesize",
":",
"p",
",",
"Lost",
":",
"int64",
"(",
"l",
")",
",",
"Unknown",
":",
"int64",
"(",
"u",
")",
"}",
"\n\n",
"mp",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"ms",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"fmt",
".",
"Println",
"(",
"string",
"(",
"mp",
")",
")",
"\n",
"}"
] | // dumpStat prints out the monitor status in JSON. | [
"dumpStat",
"prints",
"out",
"the",
"monitor",
"status",
"in",
"JSON",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/monitor/monitor.go#L240-L256 |
163,069 | cilium/cilium | monitor/monitor.go | connectionHandler1_0 | func (m *Monitor) connectionHandler1_0(parentCtx context.Context, server net.Listener) {
for !isCtxDone(parentCtx) {
conn, err := server.Accept()
switch {
case isCtxDone(parentCtx) && conn != nil:
conn.Close()
fallthrough
case isCtxDone(parentCtx) && conn == nil:
return
case err != nil:
log.WithError(err).Warn("Error accepting connection")
continue
}
m.registerNewListener(parentCtx, conn, listener.Version1_0)
}
} | go | func (m *Monitor) connectionHandler1_0(parentCtx context.Context, server net.Listener) {
for !isCtxDone(parentCtx) {
conn, err := server.Accept()
switch {
case isCtxDone(parentCtx) && conn != nil:
conn.Close()
fallthrough
case isCtxDone(parentCtx) && conn == nil:
return
case err != nil:
log.WithError(err).Warn("Error accepting connection")
continue
}
m.registerNewListener(parentCtx, conn, listener.Version1_0)
}
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"connectionHandler1_0",
"(",
"parentCtx",
"context",
".",
"Context",
",",
"server",
"net",
".",
"Listener",
")",
"{",
"for",
"!",
"isCtxDone",
"(",
"parentCtx",
")",
"{",
"conn",
",",
"err",
":=",
"server",
".",
"Accept",
"(",
")",
"\n",
"switch",
"{",
"case",
"isCtxDone",
"(",
"parentCtx",
")",
"&&",
"conn",
"!=",
"nil",
":",
"conn",
".",
"Close",
"(",
")",
"\n",
"fallthrough",
"\n\n",
"case",
"isCtxDone",
"(",
"parentCtx",
")",
"&&",
"conn",
"==",
"nil",
":",
"return",
"\n\n",
"case",
"err",
"!=",
"nil",
":",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"m",
".",
"registerNewListener",
"(",
"parentCtx",
",",
"conn",
",",
"listener",
".",
"Version1_0",
")",
"\n",
"}",
"\n",
"}"
] | // connectionHandler1_0 handles all the incoming connections and sets up the
// listener objects. It will block on Accept, but expects the caller to close
// server, inducing a return. | [
"connectionHandler1_0",
"handles",
"all",
"the",
"incoming",
"connections",
"and",
"sets",
"up",
"the",
"listener",
"objects",
".",
"It",
"will",
"block",
"on",
"Accept",
"but",
"expects",
"the",
"caller",
"to",
"close",
"server",
"inducing",
"a",
"return",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/monitor/monitor.go#L261-L279 |
163,070 | cilium/cilium | monitor/monitor.go | send | func (m *Monitor) send(pl *payload.Payload) {
m.Lock()
defer m.Unlock()
for ml := range m.listeners {
ml.Enqueue(pl)
}
} | go | func (m *Monitor) send(pl *payload.Payload) {
m.Lock()
defer m.Unlock()
for ml := range m.listeners {
ml.Enqueue(pl)
}
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"send",
"(",
"pl",
"*",
"payload",
".",
"Payload",
")",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n",
"for",
"ml",
":=",
"range",
"m",
".",
"listeners",
"{",
"ml",
".",
"Enqueue",
"(",
"pl",
")",
"\n",
"}",
"\n",
"}"
] | // send enqueues the payload to all listeners. | [
"send",
"enqueues",
"the",
"payload",
"to",
"all",
"listeners",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/monitor/monitor.go#L305-L311 |
163,071 | cilium/cilium | pkg/mtu/mtu.go | NewConfiguration | func NewConfiguration(authKeySize int, encryptEnabled bool, encapEnabled bool, mtu int) Configuration {
encryptOverhead := 0
if mtu == 0 {
var err error
mtu, err = autoDetect()
if err != nil {
log.WithError(err).Warning("Unable to automatically detect MTU")
mtu = EthernetMTU
}
}
if encryptEnabled {
// Add the difference between the default and the actual key sizes here
// to account for users specifing non-default auth key lengths.
encryptOverhead = EncryptionIPsecOverhead + (authKeySize - EncryptionDefaultAuthKeyLength)
}
conf := Configuration{
standardMTU: mtu,
tunnelMTU: mtu - (TunnelOverhead + encryptOverhead),
encryptMTU: mtu - encryptOverhead,
encapEnabled: encapEnabled,
encryptEnabled: encryptEnabled,
}
if conf.tunnelMTU < 0 {
conf.tunnelMTU = 0
}
return conf
} | go | func NewConfiguration(authKeySize int, encryptEnabled bool, encapEnabled bool, mtu int) Configuration {
encryptOverhead := 0
if mtu == 0 {
var err error
mtu, err = autoDetect()
if err != nil {
log.WithError(err).Warning("Unable to automatically detect MTU")
mtu = EthernetMTU
}
}
if encryptEnabled {
// Add the difference between the default and the actual key sizes here
// to account for users specifing non-default auth key lengths.
encryptOverhead = EncryptionIPsecOverhead + (authKeySize - EncryptionDefaultAuthKeyLength)
}
conf := Configuration{
standardMTU: mtu,
tunnelMTU: mtu - (TunnelOverhead + encryptOverhead),
encryptMTU: mtu - encryptOverhead,
encapEnabled: encapEnabled,
encryptEnabled: encryptEnabled,
}
if conf.tunnelMTU < 0 {
conf.tunnelMTU = 0
}
return conf
} | [
"func",
"NewConfiguration",
"(",
"authKeySize",
"int",
",",
"encryptEnabled",
"bool",
",",
"encapEnabled",
"bool",
",",
"mtu",
"int",
")",
"Configuration",
"{",
"encryptOverhead",
":=",
"0",
"\n\n",
"if",
"mtu",
"==",
"0",
"{",
"var",
"err",
"error",
"\n\n",
"mtu",
",",
"err",
"=",
"autoDetect",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"Warning",
"(",
"\"",
"\"",
")",
"\n",
"mtu",
"=",
"EthernetMTU",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"encryptEnabled",
"{",
"// Add the difference between the default and the actual key sizes here",
"// to account for users specifing non-default auth key lengths.",
"encryptOverhead",
"=",
"EncryptionIPsecOverhead",
"+",
"(",
"authKeySize",
"-",
"EncryptionDefaultAuthKeyLength",
")",
"\n",
"}",
"\n\n",
"conf",
":=",
"Configuration",
"{",
"standardMTU",
":",
"mtu",
",",
"tunnelMTU",
":",
"mtu",
"-",
"(",
"TunnelOverhead",
"+",
"encryptOverhead",
")",
",",
"encryptMTU",
":",
"mtu",
"-",
"encryptOverhead",
",",
"encapEnabled",
":",
"encapEnabled",
",",
"encryptEnabled",
":",
"encryptEnabled",
",",
"}",
"\n\n",
"if",
"conf",
".",
"tunnelMTU",
"<",
"0",
"{",
"conf",
".",
"tunnelMTU",
"=",
"0",
"\n",
"}",
"\n\n",
"return",
"conf",
"\n",
"}"
] | // NewConfiguration returns a new MTU configuration. The MTU can be manually
// specified, otherwise it will be automatically detected. if encapEnabled is
// true, the MTU is adjusted to account for encapsulation overhead for all
// routes involved in node to node communication. | [
"NewConfiguration",
"returns",
"a",
"new",
"MTU",
"configuration",
".",
"The",
"MTU",
"can",
"be",
"manually",
"specified",
"otherwise",
"it",
"will",
"be",
"automatically",
"detected",
".",
"if",
"encapEnabled",
"is",
"true",
"the",
"MTU",
"is",
"adjusted",
"to",
"account",
"for",
"encapsulation",
"overhead",
"for",
"all",
"routes",
"involved",
"in",
"node",
"to",
"node",
"communication",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/mtu/mtu.go#L93-L125 |
163,072 | cilium/cilium | pkg/endpointmanager/manager.go | Insert | func Insert(ep *endpoint.Endpoint) error {
if ep.ID != 0 {
if err := endpointid.Reuse(ep.ID); err != nil {
return fmt.Errorf("unable to reuse endpoint ID: %s", err)
}
} else {
id := endpointid.Allocate()
if id == uint16(0) {
return fmt.Errorf("no more endpoint IDs available")
}
ep.ID = id
ep.UpdateLogger(map[string]interface{}{
logfields.EndpointID: ep.ID,
})
}
// No need to check liveness as an endpoint can only be deleted via the
// API after it has been inserted into the manager.
ep.UnconditionalRLock()
mutex.Lock()
// Now that the endpoint has its ID, it can be created with a name based on
// its ID, and its eventqueue can be safely started. Ensure that it is only
// started once it is exposed to the endpointmanager so that it will be
// stopped when the endpoint is removed from the endpointmanager.
ep.EventQueue = eventqueue.NewEventQueueBuffered(fmt.Sprintf("endpoint-%d", ep.ID), option.Config.EndpointQueueSize)
ep.EventQueue.Run()
endpoints[ep.ID] = ep
updateReferences(ep)
mutex.Unlock()
ep.RUnlock()
if EndpointSynchronizer != nil {
EndpointSynchronizer.RunK8sCiliumEndpointSync(ep)
}
ep.InsertEvent()
return nil
} | go | func Insert(ep *endpoint.Endpoint) error {
if ep.ID != 0 {
if err := endpointid.Reuse(ep.ID); err != nil {
return fmt.Errorf("unable to reuse endpoint ID: %s", err)
}
} else {
id := endpointid.Allocate()
if id == uint16(0) {
return fmt.Errorf("no more endpoint IDs available")
}
ep.ID = id
ep.UpdateLogger(map[string]interface{}{
logfields.EndpointID: ep.ID,
})
}
// No need to check liveness as an endpoint can only be deleted via the
// API after it has been inserted into the manager.
ep.UnconditionalRLock()
mutex.Lock()
// Now that the endpoint has its ID, it can be created with a name based on
// its ID, and its eventqueue can be safely started. Ensure that it is only
// started once it is exposed to the endpointmanager so that it will be
// stopped when the endpoint is removed from the endpointmanager.
ep.EventQueue = eventqueue.NewEventQueueBuffered(fmt.Sprintf("endpoint-%d", ep.ID), option.Config.EndpointQueueSize)
ep.EventQueue.Run()
endpoints[ep.ID] = ep
updateReferences(ep)
mutex.Unlock()
ep.RUnlock()
if EndpointSynchronizer != nil {
EndpointSynchronizer.RunK8sCiliumEndpointSync(ep)
}
ep.InsertEvent()
return nil
} | [
"func",
"Insert",
"(",
"ep",
"*",
"endpoint",
".",
"Endpoint",
")",
"error",
"{",
"if",
"ep",
".",
"ID",
"!=",
"0",
"{",
"if",
"err",
":=",
"endpointid",
".",
"Reuse",
"(",
"ep",
".",
"ID",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"id",
":=",
"endpointid",
".",
"Allocate",
"(",
")",
"\n",
"if",
"id",
"==",
"uint16",
"(",
"0",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"ep",
".",
"ID",
"=",
"id",
"\n\n",
"ep",
".",
"UpdateLogger",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"logfields",
".",
"EndpointID",
":",
"ep",
".",
"ID",
",",
"}",
")",
"\n",
"}",
"\n\n",
"// No need to check liveness as an endpoint can only be deleted via the",
"// API after it has been inserted into the manager.",
"ep",
".",
"UnconditionalRLock",
"(",
")",
"\n",
"mutex",
".",
"Lock",
"(",
")",
"\n\n",
"// Now that the endpoint has its ID, it can be created with a name based on",
"// its ID, and its eventqueue can be safely started. Ensure that it is only",
"// started once it is exposed to the endpointmanager so that it will be",
"// stopped when the endpoint is removed from the endpointmanager.",
"ep",
".",
"EventQueue",
"=",
"eventqueue",
".",
"NewEventQueueBuffered",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ep",
".",
"ID",
")",
",",
"option",
".",
"Config",
".",
"EndpointQueueSize",
")",
"\n",
"ep",
".",
"EventQueue",
".",
"Run",
"(",
")",
"\n\n",
"endpoints",
"[",
"ep",
".",
"ID",
"]",
"=",
"ep",
"\n",
"updateReferences",
"(",
"ep",
")",
"\n\n",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"ep",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"EndpointSynchronizer",
"!=",
"nil",
"{",
"EndpointSynchronizer",
".",
"RunK8sCiliumEndpointSync",
"(",
"ep",
")",
"\n",
"}",
"\n\n",
"ep",
".",
"InsertEvent",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Insert inserts the endpoint into the global maps. | [
"Insert",
"inserts",
"the",
"endpoint",
"into",
"the",
"global",
"maps",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L75-L117 |
163,073 | cilium/cilium | pkg/endpointmanager/manager.go | Lookup | func Lookup(id string) (*endpoint.Endpoint, error) {
mutex.RLock()
defer mutex.RUnlock()
prefix, eid, err := endpointid.Parse(id)
if err != nil {
return nil, err
}
switch prefix {
case endpointid.CiliumLocalIdPrefix:
n, err := endpointid.ParseCiliumID(id)
if err != nil {
return nil, err
}
return lookupCiliumID(uint16(n)), nil
case endpointid.CiliumGlobalIdPrefix:
return nil, ErrUnsupportedID
case endpointid.ContainerIdPrefix:
return lookupContainerID(eid), nil
case endpointid.DockerEndpointPrefix:
return lookupDockerEndpoint(eid), nil
case endpointid.ContainerNamePrefix:
return lookupDockerContainerName(eid), nil
case endpointid.PodNamePrefix:
return lookupPodNameLocked(eid), nil
case endpointid.IPv4Prefix:
return lookupIPv4(eid), nil
case endpointid.IPv6Prefix:
return lookupIPv6(eid), nil
default:
return nil, ErrInvalidPrefix{InvalidPrefix: prefix.String()}
}
} | go | func Lookup(id string) (*endpoint.Endpoint, error) {
mutex.RLock()
defer mutex.RUnlock()
prefix, eid, err := endpointid.Parse(id)
if err != nil {
return nil, err
}
switch prefix {
case endpointid.CiliumLocalIdPrefix:
n, err := endpointid.ParseCiliumID(id)
if err != nil {
return nil, err
}
return lookupCiliumID(uint16(n)), nil
case endpointid.CiliumGlobalIdPrefix:
return nil, ErrUnsupportedID
case endpointid.ContainerIdPrefix:
return lookupContainerID(eid), nil
case endpointid.DockerEndpointPrefix:
return lookupDockerEndpoint(eid), nil
case endpointid.ContainerNamePrefix:
return lookupDockerContainerName(eid), nil
case endpointid.PodNamePrefix:
return lookupPodNameLocked(eid), nil
case endpointid.IPv4Prefix:
return lookupIPv4(eid), nil
case endpointid.IPv6Prefix:
return lookupIPv6(eid), nil
default:
return nil, ErrInvalidPrefix{InvalidPrefix: prefix.String()}
}
} | [
"func",
"Lookup",
"(",
"id",
"string",
")",
"(",
"*",
"endpoint",
".",
"Endpoint",
",",
"error",
")",
"{",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"mutex",
".",
"RUnlock",
"(",
")",
"\n\n",
"prefix",
",",
"eid",
",",
"err",
":=",
"endpointid",
".",
"Parse",
"(",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"switch",
"prefix",
"{",
"case",
"endpointid",
".",
"CiliumLocalIdPrefix",
":",
"n",
",",
"err",
":=",
"endpointid",
".",
"ParseCiliumID",
"(",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"lookupCiliumID",
"(",
"uint16",
"(",
"n",
")",
")",
",",
"nil",
"\n\n",
"case",
"endpointid",
".",
"CiliumGlobalIdPrefix",
":",
"return",
"nil",
",",
"ErrUnsupportedID",
"\n\n",
"case",
"endpointid",
".",
"ContainerIdPrefix",
":",
"return",
"lookupContainerID",
"(",
"eid",
")",
",",
"nil",
"\n\n",
"case",
"endpointid",
".",
"DockerEndpointPrefix",
":",
"return",
"lookupDockerEndpoint",
"(",
"eid",
")",
",",
"nil",
"\n\n",
"case",
"endpointid",
".",
"ContainerNamePrefix",
":",
"return",
"lookupDockerContainerName",
"(",
"eid",
")",
",",
"nil",
"\n\n",
"case",
"endpointid",
".",
"PodNamePrefix",
":",
"return",
"lookupPodNameLocked",
"(",
"eid",
")",
",",
"nil",
"\n\n",
"case",
"endpointid",
".",
"IPv4Prefix",
":",
"return",
"lookupIPv4",
"(",
"eid",
")",
",",
"nil",
"\n\n",
"case",
"endpointid",
".",
"IPv6Prefix",
":",
"return",
"lookupIPv6",
"(",
"eid",
")",
",",
"nil",
"\n\n",
"default",
":",
"return",
"nil",
",",
"ErrInvalidPrefix",
"{",
"InvalidPrefix",
":",
"prefix",
".",
"String",
"(",
")",
"}",
"\n",
"}",
"\n",
"}"
] | // Lookup looks up the endpoint by prefix id | [
"Lookup",
"looks",
"up",
"the",
"endpoint",
"by",
"prefix",
"id"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L120-L161 |
163,074 | cilium/cilium | pkg/endpointmanager/manager.go | LookupCiliumID | func LookupCiliumID(id uint16) *endpoint.Endpoint {
mutex.RLock()
ep := lookupCiliumID(id)
mutex.RUnlock()
return ep
} | go | func LookupCiliumID(id uint16) *endpoint.Endpoint {
mutex.RLock()
ep := lookupCiliumID(id)
mutex.RUnlock()
return ep
} | [
"func",
"LookupCiliumID",
"(",
"id",
"uint16",
")",
"*",
"endpoint",
".",
"Endpoint",
"{",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"ep",
":=",
"lookupCiliumID",
"(",
"id",
")",
"\n",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"ep",
"\n",
"}"
] | // LookupCiliumID looks up endpoint by endpoint ID | [
"LookupCiliumID",
"looks",
"up",
"endpoint",
"by",
"endpoint",
"ID"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L164-L169 |
163,075 | cilium/cilium | pkg/endpointmanager/manager.go | LookupContainerID | func LookupContainerID(id string) *endpoint.Endpoint {
mutex.RLock()
ep := lookupContainerID(id)
mutex.RUnlock()
return ep
} | go | func LookupContainerID(id string) *endpoint.Endpoint {
mutex.RLock()
ep := lookupContainerID(id)
mutex.RUnlock()
return ep
} | [
"func",
"LookupContainerID",
"(",
"id",
"string",
")",
"*",
"endpoint",
".",
"Endpoint",
"{",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"ep",
":=",
"lookupContainerID",
"(",
"id",
")",
"\n",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"ep",
"\n",
"}"
] | // LookupContainerID looks up endpoint by Docker ID | [
"LookupContainerID",
"looks",
"up",
"endpoint",
"by",
"Docker",
"ID"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L172-L177 |
163,076 | cilium/cilium | pkg/endpointmanager/manager.go | LookupIPv4 | func LookupIPv4(ipv4 string) *endpoint.Endpoint {
mutex.RLock()
ep := lookupIPv4(ipv4)
mutex.RUnlock()
return ep
} | go | func LookupIPv4(ipv4 string) *endpoint.Endpoint {
mutex.RLock()
ep := lookupIPv4(ipv4)
mutex.RUnlock()
return ep
} | [
"func",
"LookupIPv4",
"(",
"ipv4",
"string",
")",
"*",
"endpoint",
".",
"Endpoint",
"{",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"ep",
":=",
"lookupIPv4",
"(",
"ipv4",
")",
"\n",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"ep",
"\n",
"}"
] | // LookupIPv4 looks up endpoint by IPv4 address | [
"LookupIPv4",
"looks",
"up",
"endpoint",
"by",
"IPv4",
"address"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L180-L185 |
163,077 | cilium/cilium | pkg/endpointmanager/manager.go | LookupIPv6 | func LookupIPv6(ipv6 string) *endpoint.Endpoint {
mutex.RLock()
ep := lookupIPv6(ipv6)
mutex.RUnlock()
return ep
} | go | func LookupIPv6(ipv6 string) *endpoint.Endpoint {
mutex.RLock()
ep := lookupIPv6(ipv6)
mutex.RUnlock()
return ep
} | [
"func",
"LookupIPv6",
"(",
"ipv6",
"string",
")",
"*",
"endpoint",
".",
"Endpoint",
"{",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"ep",
":=",
"lookupIPv6",
"(",
"ipv6",
")",
"\n",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"ep",
"\n",
"}"
] | // LookupIPv6 looks up endpoint by IPv6 address | [
"LookupIPv6",
"looks",
"up",
"endpoint",
"by",
"IPv6",
"address"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L188-L193 |
163,078 | cilium/cilium | pkg/endpointmanager/manager.go | LookupIP | func LookupIP(ip net.IP) (ep *endpoint.Endpoint) {
addr := ip.String()
mutex.RLock()
if ip.To4() != nil {
ep = lookupIPv4(addr)
} else {
ep = lookupIPv6(addr)
}
mutex.RUnlock()
return ep
} | go | func LookupIP(ip net.IP) (ep *endpoint.Endpoint) {
addr := ip.String()
mutex.RLock()
if ip.To4() != nil {
ep = lookupIPv4(addr)
} else {
ep = lookupIPv6(addr)
}
mutex.RUnlock()
return ep
} | [
"func",
"LookupIP",
"(",
"ip",
"net",
".",
"IP",
")",
"(",
"ep",
"*",
"endpoint",
".",
"Endpoint",
")",
"{",
"addr",
":=",
"ip",
".",
"String",
"(",
")",
"\n",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"if",
"ip",
".",
"To4",
"(",
")",
"!=",
"nil",
"{",
"ep",
"=",
"lookupIPv4",
"(",
"addr",
")",
"\n",
"}",
"else",
"{",
"ep",
"=",
"lookupIPv6",
"(",
"addr",
")",
"\n",
"}",
"\n",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"ep",
"\n",
"}"
] | // LookupIP looks up endpoint by IP address | [
"LookupIP",
"looks",
"up",
"endpoint",
"by",
"IP",
"address"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L196-L206 |
163,079 | cilium/cilium | pkg/endpointmanager/manager.go | LookupPodName | func LookupPodName(name string) *endpoint.Endpoint {
mutex.RLock()
ep := lookupPodNameLocked(name)
mutex.RUnlock()
return ep
} | go | func LookupPodName(name string) *endpoint.Endpoint {
mutex.RLock()
ep := lookupPodNameLocked(name)
mutex.RUnlock()
return ep
} | [
"func",
"LookupPodName",
"(",
"name",
"string",
")",
"*",
"endpoint",
".",
"Endpoint",
"{",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"ep",
":=",
"lookupPodNameLocked",
"(",
"name",
")",
"\n",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"ep",
"\n",
"}"
] | // LookupPodName looks up endpoint by namespace + pod name | [
"LookupPodName",
"looks",
"up",
"endpoint",
"by",
"namespace",
"+",
"pod",
"name"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L209-L214 |
163,080 | cilium/cilium | pkg/endpointmanager/manager.go | Remove | func Remove(ep *endpoint.Endpoint) <-chan struct{} {
epRemoved := make(chan struct{})
mutex.Lock()
defer mutex.Unlock()
// This must be done before the ID is released for the endpoint!
delete(endpoints, ep.ID)
go func(ep *endpoint.Endpoint) {
// The endpoint's EventQueue may not be stopped yet (depending on whether
// the caller of the EventQueue has stopped it or not). Call it here
// to be safe so that ep.WaitToBeDrained() does not hang forever.
ep.EventQueue.Stop()
// Wait for no more events (primarily regenerations) to be occurring for
// this endpoint.
ep.EventQueue.WaitToBeDrained()
releaseID(ep)
close(epRemoved)
}(ep)
if ep.ContainerID != "" {
delete(endpointsAux, endpointid.NewID(endpointid.ContainerIdPrefix, ep.ContainerID))
}
if ep.DockerEndpointID != "" {
delete(endpointsAux, endpointid.NewID(endpointid.DockerEndpointPrefix, ep.DockerEndpointID))
}
if ep.IPv4.IsSet() {
delete(endpointsAux, endpointid.NewID(endpointid.IPv4Prefix, ep.IPv4.String()))
}
if ep.IPv6.IsSet() {
delete(endpointsAux, endpointid.NewID(endpointid.IPv6Prefix, ep.IPv6.String()))
}
if ep.ContainerName != "" {
delete(endpointsAux, endpointid.NewID(endpointid.ContainerNamePrefix, ep.ContainerName))
}
if podName := ep.GetK8sNamespaceAndPodNameLocked(); podName != "" {
delete(endpointsAux, endpointid.NewID(endpointid.PodNamePrefix, podName))
}
return epRemoved
} | go | func Remove(ep *endpoint.Endpoint) <-chan struct{} {
epRemoved := make(chan struct{})
mutex.Lock()
defer mutex.Unlock()
// This must be done before the ID is released for the endpoint!
delete(endpoints, ep.ID)
go func(ep *endpoint.Endpoint) {
// The endpoint's EventQueue may not be stopped yet (depending on whether
// the caller of the EventQueue has stopped it or not). Call it here
// to be safe so that ep.WaitToBeDrained() does not hang forever.
ep.EventQueue.Stop()
// Wait for no more events (primarily regenerations) to be occurring for
// this endpoint.
ep.EventQueue.WaitToBeDrained()
releaseID(ep)
close(epRemoved)
}(ep)
if ep.ContainerID != "" {
delete(endpointsAux, endpointid.NewID(endpointid.ContainerIdPrefix, ep.ContainerID))
}
if ep.DockerEndpointID != "" {
delete(endpointsAux, endpointid.NewID(endpointid.DockerEndpointPrefix, ep.DockerEndpointID))
}
if ep.IPv4.IsSet() {
delete(endpointsAux, endpointid.NewID(endpointid.IPv4Prefix, ep.IPv4.String()))
}
if ep.IPv6.IsSet() {
delete(endpointsAux, endpointid.NewID(endpointid.IPv6Prefix, ep.IPv6.String()))
}
if ep.ContainerName != "" {
delete(endpointsAux, endpointid.NewID(endpointid.ContainerNamePrefix, ep.ContainerName))
}
if podName := ep.GetK8sNamespaceAndPodNameLocked(); podName != "" {
delete(endpointsAux, endpointid.NewID(endpointid.PodNamePrefix, podName))
}
return epRemoved
} | [
"func",
"Remove",
"(",
"ep",
"*",
"endpoint",
".",
"Endpoint",
")",
"<-",
"chan",
"struct",
"{",
"}",
"{",
"epRemoved",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n\n",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"// This must be done before the ID is released for the endpoint!",
"delete",
"(",
"endpoints",
",",
"ep",
".",
"ID",
")",
"\n\n",
"go",
"func",
"(",
"ep",
"*",
"endpoint",
".",
"Endpoint",
")",
"{",
"// The endpoint's EventQueue may not be stopped yet (depending on whether",
"// the caller of the EventQueue has stopped it or not). Call it here",
"// to be safe so that ep.WaitToBeDrained() does not hang forever.",
"ep",
".",
"EventQueue",
".",
"Stop",
"(",
")",
"\n\n",
"// Wait for no more events (primarily regenerations) to be occurring for",
"// this endpoint.",
"ep",
".",
"EventQueue",
".",
"WaitToBeDrained",
"(",
")",
"\n\n",
"releaseID",
"(",
"ep",
")",
"\n",
"close",
"(",
"epRemoved",
")",
"\n",
"}",
"(",
"ep",
")",
"\n\n",
"if",
"ep",
".",
"ContainerID",
"!=",
"\"",
"\"",
"{",
"delete",
"(",
"endpointsAux",
",",
"endpointid",
".",
"NewID",
"(",
"endpointid",
".",
"ContainerIdPrefix",
",",
"ep",
".",
"ContainerID",
")",
")",
"\n",
"}",
"\n\n",
"if",
"ep",
".",
"DockerEndpointID",
"!=",
"\"",
"\"",
"{",
"delete",
"(",
"endpointsAux",
",",
"endpointid",
".",
"NewID",
"(",
"endpointid",
".",
"DockerEndpointPrefix",
",",
"ep",
".",
"DockerEndpointID",
")",
")",
"\n",
"}",
"\n\n",
"if",
"ep",
".",
"IPv4",
".",
"IsSet",
"(",
")",
"{",
"delete",
"(",
"endpointsAux",
",",
"endpointid",
".",
"NewID",
"(",
"endpointid",
".",
"IPv4Prefix",
",",
"ep",
".",
"IPv4",
".",
"String",
"(",
")",
")",
")",
"\n",
"}",
"\n\n",
"if",
"ep",
".",
"IPv6",
".",
"IsSet",
"(",
")",
"{",
"delete",
"(",
"endpointsAux",
",",
"endpointid",
".",
"NewID",
"(",
"endpointid",
".",
"IPv6Prefix",
",",
"ep",
".",
"IPv6",
".",
"String",
"(",
")",
")",
")",
"\n",
"}",
"\n\n",
"if",
"ep",
".",
"ContainerName",
"!=",
"\"",
"\"",
"{",
"delete",
"(",
"endpointsAux",
",",
"endpointid",
".",
"NewID",
"(",
"endpointid",
".",
"ContainerNamePrefix",
",",
"ep",
".",
"ContainerName",
")",
")",
"\n",
"}",
"\n\n",
"if",
"podName",
":=",
"ep",
".",
"GetK8sNamespaceAndPodNameLocked",
"(",
")",
";",
"podName",
"!=",
"\"",
"\"",
"{",
"delete",
"(",
"endpointsAux",
",",
"endpointid",
".",
"NewID",
"(",
"endpointid",
".",
"PodNamePrefix",
",",
"podName",
")",
")",
"\n",
"}",
"\n",
"return",
"epRemoved",
"\n",
"}"
] | // Remove removes the endpoint from the global maps and releases the node-local
// ID allocated for the endpoint.
// Must be called with ep.Mutex.RLock held. Releasing of the ID of the endpoint
// is done asynchronously. Once the ID of the endpoint is released, the returned
// channel is closed. | [
"Remove",
"removes",
"the",
"endpoint",
"from",
"the",
"global",
"maps",
"and",
"releases",
"the",
"node",
"-",
"local",
"ID",
"allocated",
"for",
"the",
"endpoint",
".",
"Must",
"be",
"called",
"with",
"ep",
".",
"Mutex",
".",
"RLock",
"held",
".",
"Releasing",
"of",
"the",
"ID",
"of",
"the",
"endpoint",
"is",
"done",
"asynchronously",
".",
"Once",
"the",
"ID",
"of",
"the",
"endpoint",
"is",
"released",
"the",
"returned",
"channel",
"is",
"closed",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L255-L304 |
163,081 | cilium/cilium | pkg/endpointmanager/manager.go | RemoveAll | func RemoveAll() {
mutex.Lock()
defer mutex.Unlock()
endpointid.ReallocatePool()
endpoints = map[uint16]*endpoint.Endpoint{}
endpointsAux = map[string]*endpoint.Endpoint{}
} | go | func RemoveAll() {
mutex.Lock()
defer mutex.Unlock()
endpointid.ReallocatePool()
endpoints = map[uint16]*endpoint.Endpoint{}
endpointsAux = map[string]*endpoint.Endpoint{}
} | [
"func",
"RemoveAll",
"(",
")",
"{",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"endpointid",
".",
"ReallocatePool",
"(",
")",
"\n",
"endpoints",
"=",
"map",
"[",
"uint16",
"]",
"*",
"endpoint",
".",
"Endpoint",
"{",
"}",
"\n",
"endpointsAux",
"=",
"map",
"[",
"string",
"]",
"*",
"endpoint",
".",
"Endpoint",
"{",
"}",
"\n",
"}"
] | // RemoveAll removes all endpoints from the global maps. | [
"RemoveAll",
"removes",
"all",
"endpoints",
"from",
"the",
"global",
"maps",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L307-L313 |
163,082 | cilium/cilium | pkg/endpointmanager/manager.go | lookupCiliumID | func lookupCiliumID(id uint16) *endpoint.Endpoint {
if ep, ok := endpoints[id]; ok {
return ep
}
return nil
} | go | func lookupCiliumID(id uint16) *endpoint.Endpoint {
if ep, ok := endpoints[id]; ok {
return ep
}
return nil
} | [
"func",
"lookupCiliumID",
"(",
"id",
"uint16",
")",
"*",
"endpoint",
".",
"Endpoint",
"{",
"if",
"ep",
",",
"ok",
":=",
"endpoints",
"[",
"id",
"]",
";",
"ok",
"{",
"return",
"ep",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // lookupCiliumID looks up endpoint by endpoint ID | [
"lookupCiliumID",
"looks",
"up",
"endpoint",
"by",
"endpoint",
"ID"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L316-L321 |
163,083 | cilium/cilium | pkg/endpointmanager/manager.go | updateReferences | func updateReferences(ep *endpoint.Endpoint) {
if ep.ContainerID != "" {
endpointsAux[endpointid.NewID(endpointid.ContainerIdPrefix, ep.ContainerID)] = ep
}
if ep.DockerEndpointID != "" {
endpointsAux[endpointid.NewID(endpointid.DockerEndpointPrefix, ep.DockerEndpointID)] = ep
}
if ep.IPv4.IsSet() {
endpointsAux[endpointid.NewID(endpointid.IPv4Prefix, ep.IPv4.String())] = ep
}
if ep.IPv6.IsSet() {
endpointsAux[endpointid.NewID(endpointid.IPv6Prefix, ep.IPv6.String())] = ep
}
if ep.ContainerName != "" {
endpointsAux[endpointid.NewID(endpointid.ContainerNamePrefix, ep.ContainerName)] = ep
}
if podName := ep.GetK8sNamespaceAndPodNameLocked(); podName != "" {
endpointsAux[endpointid.NewID(endpointid.PodNamePrefix, podName)] = ep
}
} | go | func updateReferences(ep *endpoint.Endpoint) {
if ep.ContainerID != "" {
endpointsAux[endpointid.NewID(endpointid.ContainerIdPrefix, ep.ContainerID)] = ep
}
if ep.DockerEndpointID != "" {
endpointsAux[endpointid.NewID(endpointid.DockerEndpointPrefix, ep.DockerEndpointID)] = ep
}
if ep.IPv4.IsSet() {
endpointsAux[endpointid.NewID(endpointid.IPv4Prefix, ep.IPv4.String())] = ep
}
if ep.IPv6.IsSet() {
endpointsAux[endpointid.NewID(endpointid.IPv6Prefix, ep.IPv6.String())] = ep
}
if ep.ContainerName != "" {
endpointsAux[endpointid.NewID(endpointid.ContainerNamePrefix, ep.ContainerName)] = ep
}
if podName := ep.GetK8sNamespaceAndPodNameLocked(); podName != "" {
endpointsAux[endpointid.NewID(endpointid.PodNamePrefix, podName)] = ep
}
} | [
"func",
"updateReferences",
"(",
"ep",
"*",
"endpoint",
".",
"Endpoint",
")",
"{",
"if",
"ep",
".",
"ContainerID",
"!=",
"\"",
"\"",
"{",
"endpointsAux",
"[",
"endpointid",
".",
"NewID",
"(",
"endpointid",
".",
"ContainerIdPrefix",
",",
"ep",
".",
"ContainerID",
")",
"]",
"=",
"ep",
"\n",
"}",
"\n\n",
"if",
"ep",
".",
"DockerEndpointID",
"!=",
"\"",
"\"",
"{",
"endpointsAux",
"[",
"endpointid",
".",
"NewID",
"(",
"endpointid",
".",
"DockerEndpointPrefix",
",",
"ep",
".",
"DockerEndpointID",
")",
"]",
"=",
"ep",
"\n",
"}",
"\n\n",
"if",
"ep",
".",
"IPv4",
".",
"IsSet",
"(",
")",
"{",
"endpointsAux",
"[",
"endpointid",
".",
"NewID",
"(",
"endpointid",
".",
"IPv4Prefix",
",",
"ep",
".",
"IPv4",
".",
"String",
"(",
")",
")",
"]",
"=",
"ep",
"\n",
"}",
"\n\n",
"if",
"ep",
".",
"IPv6",
".",
"IsSet",
"(",
")",
"{",
"endpointsAux",
"[",
"endpointid",
".",
"NewID",
"(",
"endpointid",
".",
"IPv6Prefix",
",",
"ep",
".",
"IPv6",
".",
"String",
"(",
")",
")",
"]",
"=",
"ep",
"\n",
"}",
"\n\n",
"if",
"ep",
".",
"ContainerName",
"!=",
"\"",
"\"",
"{",
"endpointsAux",
"[",
"endpointid",
".",
"NewID",
"(",
"endpointid",
".",
"ContainerNamePrefix",
",",
"ep",
".",
"ContainerName",
")",
"]",
"=",
"ep",
"\n",
"}",
"\n\n",
"if",
"podName",
":=",
"ep",
".",
"GetK8sNamespaceAndPodNameLocked",
"(",
")",
";",
"podName",
"!=",
"\"",
"\"",
"{",
"endpointsAux",
"[",
"endpointid",
".",
"NewID",
"(",
"endpointid",
".",
"PodNamePrefix",
",",
"podName",
")",
"]",
"=",
"ep",
"\n",
"}",
"\n",
"}"
] | // UpdateReferences updates the mappings of various values to their corresponding
// endpoints, such as ContainerID, Docker Container Name, Pod Name, etc. | [
"UpdateReferences",
"updates",
"the",
"mappings",
"of",
"various",
"values",
"to",
"their",
"corresponding",
"endpoints",
"such",
"as",
"ContainerID",
"Docker",
"Container",
"Name",
"Pod",
"Name",
"etc",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L367-L391 |
163,084 | cilium/cilium | pkg/endpointmanager/manager.go | RegenerateAllEndpoints | func RegenerateAllEndpoints(owner endpoint.Owner, regenMetadata *endpoint.ExternalRegenerationMetadata) *sync.WaitGroup {
var wg sync.WaitGroup
eps := GetEndpoints()
wg.Add(len(eps))
log.Infof("regenerating all endpoints due to %s", regenMetadata.Reason)
for _, ep := range eps {
go regenerateEndpointBlocking(owner, ep, regenMetadata, &wg)
}
return &wg
} | go | func RegenerateAllEndpoints(owner endpoint.Owner, regenMetadata *endpoint.ExternalRegenerationMetadata) *sync.WaitGroup {
var wg sync.WaitGroup
eps := GetEndpoints()
wg.Add(len(eps))
log.Infof("regenerating all endpoints due to %s", regenMetadata.Reason)
for _, ep := range eps {
go regenerateEndpointBlocking(owner, ep, regenMetadata, &wg)
}
return &wg
} | [
"func",
"RegenerateAllEndpoints",
"(",
"owner",
"endpoint",
".",
"Owner",
",",
"regenMetadata",
"*",
"endpoint",
".",
"ExternalRegenerationMetadata",
")",
"*",
"sync",
".",
"WaitGroup",
"{",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n\n",
"eps",
":=",
"GetEndpoints",
"(",
")",
"\n",
"wg",
".",
"Add",
"(",
"len",
"(",
"eps",
")",
")",
"\n\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"regenMetadata",
".",
"Reason",
")",
"\n",
"for",
"_",
",",
"ep",
":=",
"range",
"eps",
"{",
"go",
"regenerateEndpointBlocking",
"(",
"owner",
",",
"ep",
",",
"regenMetadata",
",",
"&",
"wg",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"wg",
"\n",
"}"
] | // RegenerateAllEndpoints calls a SetStateLocked for each endpoint and
// regenerates if state transaction is valid. During this process, the endpoint
// list is locked and cannot be modified.
// Returns a waiting group that can be used to know when all the endpoints are
// regenerated. | [
"RegenerateAllEndpoints",
"calls",
"a",
"SetStateLocked",
"for",
"each",
"endpoint",
"and",
"regenerates",
"if",
"state",
"transaction",
"is",
"valid",
".",
"During",
"this",
"process",
"the",
"endpoint",
"list",
"is",
"locked",
"and",
"cannot",
"be",
"modified",
".",
"Returns",
"a",
"waiting",
"group",
"that",
"can",
"be",
"used",
"to",
"know",
"when",
"all",
"the",
"endpoints",
"are",
"regenerated",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L398-L410 |
163,085 | cilium/cilium | pkg/endpointmanager/manager.go | RegenerateEndpointSetSignalWhenEnqueued | func RegenerateEndpointSetSignalWhenEnqueued(owner endpoint.Owner, regenMetadata *endpoint.ExternalRegenerationMetadata, endpointIDs map[uint16]struct{}, wg *sync.WaitGroup) {
wg.Add(len(endpointIDs))
for endpointID := range endpointIDs {
ep := endpoints[endpointID]
go func() {
regenerateEndpointNonBlocking(owner, ep, regenMetadata)
wg.Done()
}()
}
} | go | func RegenerateEndpointSetSignalWhenEnqueued(owner endpoint.Owner, regenMetadata *endpoint.ExternalRegenerationMetadata, endpointIDs map[uint16]struct{}, wg *sync.WaitGroup) {
wg.Add(len(endpointIDs))
for endpointID := range endpointIDs {
ep := endpoints[endpointID]
go func() {
regenerateEndpointNonBlocking(owner, ep, regenMetadata)
wg.Done()
}()
}
} | [
"func",
"RegenerateEndpointSetSignalWhenEnqueued",
"(",
"owner",
"endpoint",
".",
"Owner",
",",
"regenMetadata",
"*",
"endpoint",
".",
"ExternalRegenerationMetadata",
",",
"endpointIDs",
"map",
"[",
"uint16",
"]",
"struct",
"{",
"}",
",",
"wg",
"*",
"sync",
".",
"WaitGroup",
")",
"{",
"wg",
".",
"Add",
"(",
"len",
"(",
"endpointIDs",
")",
")",
"\n\n",
"for",
"endpointID",
":=",
"range",
"endpointIDs",
"{",
"ep",
":=",
"endpoints",
"[",
"endpointID",
"]",
"\n",
"go",
"func",
"(",
")",
"{",
"regenerateEndpointNonBlocking",
"(",
"owner",
",",
"ep",
",",
"regenMetadata",
")",
"\n",
"wg",
".",
"Done",
"(",
")",
"\n",
"}",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // RegenerateEndpointSetSignalWhenEnqueued regenerates the endpoints represented
// by endpointIDs. It signals to the provided WaitGroup when all of the endpoints
// in said set have had regenerations queued up. | [
"RegenerateEndpointSetSignalWhenEnqueued",
"regenerates",
"the",
"endpoints",
"represented",
"by",
"endpointIDs",
".",
"It",
"signals",
"to",
"the",
"provided",
"WaitGroup",
"when",
"all",
"of",
"the",
"endpoints",
"in",
"said",
"set",
"have",
"had",
"regenerations",
"queued",
"up",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L452-L462 |
163,086 | cilium/cilium | pkg/endpointmanager/manager.go | HasGlobalCT | func HasGlobalCT() bool {
eps := GetEndpoints()
for _, e := range eps {
if !e.Options.IsEnabled(option.ConntrackLocal) {
return true
}
}
return false
} | go | func HasGlobalCT() bool {
eps := GetEndpoints()
for _, e := range eps {
if !e.Options.IsEnabled(option.ConntrackLocal) {
return true
}
}
return false
} | [
"func",
"HasGlobalCT",
"(",
")",
"bool",
"{",
"eps",
":=",
"GetEndpoints",
"(",
")",
"\n",
"for",
"_",
",",
"e",
":=",
"range",
"eps",
"{",
"if",
"!",
"e",
".",
"Options",
".",
"IsEnabled",
"(",
"option",
".",
"ConntrackLocal",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // HasGlobalCT returns true if the endpoints have a global CT, false otherwise. | [
"HasGlobalCT",
"returns",
"true",
"if",
"the",
"endpoints",
"have",
"a",
"global",
"CT",
"false",
"otherwise",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L465-L473 |
163,087 | cilium/cilium | pkg/endpointmanager/manager.go | GetEndpoints | func GetEndpoints() []*endpoint.Endpoint {
mutex.RLock()
eps := make([]*endpoint.Endpoint, 0, len(endpoints))
for _, ep := range endpoints {
eps = append(eps, ep)
}
mutex.RUnlock()
return eps
} | go | func GetEndpoints() []*endpoint.Endpoint {
mutex.RLock()
eps := make([]*endpoint.Endpoint, 0, len(endpoints))
for _, ep := range endpoints {
eps = append(eps, ep)
}
mutex.RUnlock()
return eps
} | [
"func",
"GetEndpoints",
"(",
")",
"[",
"]",
"*",
"endpoint",
".",
"Endpoint",
"{",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"eps",
":=",
"make",
"(",
"[",
"]",
"*",
"endpoint",
".",
"Endpoint",
",",
"0",
",",
"len",
"(",
"endpoints",
")",
")",
"\n",
"for",
"_",
",",
"ep",
":=",
"range",
"endpoints",
"{",
"eps",
"=",
"append",
"(",
"eps",
",",
"ep",
")",
"\n",
"}",
"\n",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"eps",
"\n",
"}"
] | // GetEndpoints returns a slice of all endpoints present in endpoint manager. | [
"GetEndpoints",
"returns",
"a",
"slice",
"of",
"all",
"endpoints",
"present",
"in",
"endpoint",
"manager",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L476-L484 |
163,088 | cilium/cilium | pkg/endpointmanager/manager.go | AddEndpoint | func AddEndpoint(owner endpoint.Owner, ep *endpoint.Endpoint, reason string) (err error) {
alwaysEnforce := policy.GetPolicyEnabled() == option.AlwaysEnforce
ep.SetDesiredIngressPolicyEnabled(alwaysEnforce)
ep.SetDesiredEgressPolicyEnabled(alwaysEnforce)
if ep.ID != 0 {
return fmt.Errorf("Endpoint ID is already set to %d", ep.ID)
}
return Insert(ep)
} | go | func AddEndpoint(owner endpoint.Owner, ep *endpoint.Endpoint, reason string) (err error) {
alwaysEnforce := policy.GetPolicyEnabled() == option.AlwaysEnforce
ep.SetDesiredIngressPolicyEnabled(alwaysEnforce)
ep.SetDesiredEgressPolicyEnabled(alwaysEnforce)
if ep.ID != 0 {
return fmt.Errorf("Endpoint ID is already set to %d", ep.ID)
}
return Insert(ep)
} | [
"func",
"AddEndpoint",
"(",
"owner",
"endpoint",
".",
"Owner",
",",
"ep",
"*",
"endpoint",
".",
"Endpoint",
",",
"reason",
"string",
")",
"(",
"err",
"error",
")",
"{",
"alwaysEnforce",
":=",
"policy",
".",
"GetPolicyEnabled",
"(",
")",
"==",
"option",
".",
"AlwaysEnforce",
"\n",
"ep",
".",
"SetDesiredIngressPolicyEnabled",
"(",
"alwaysEnforce",
")",
"\n",
"ep",
".",
"SetDesiredEgressPolicyEnabled",
"(",
"alwaysEnforce",
")",
"\n\n",
"if",
"ep",
".",
"ID",
"!=",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ep",
".",
"ID",
")",
"\n",
"}",
"\n",
"return",
"Insert",
"(",
"ep",
")",
"\n",
"}"
] | // AddEndpoint takes the prepared endpoint object and starts managing it. | [
"AddEndpoint",
"takes",
"the",
"prepared",
"endpoint",
"object",
"and",
"starts",
"managing",
"it",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L487-L496 |
163,089 | cilium/cilium | pkg/endpointmanager/manager.go | WaitForEndpointsAtPolicyRev | func WaitForEndpointsAtPolicyRev(ctx context.Context, rev uint64) error {
eps := GetEndpoints()
for i := range eps {
select {
case <-ctx.Done():
return ctx.Err()
case <-eps[i].WaitForPolicyRevision(ctx, rev, nil):
if ctx.Err() != nil {
return ctx.Err()
}
}
}
return nil
} | go | func WaitForEndpointsAtPolicyRev(ctx context.Context, rev uint64) error {
eps := GetEndpoints()
for i := range eps {
select {
case <-ctx.Done():
return ctx.Err()
case <-eps[i].WaitForPolicyRevision(ctx, rev, nil):
if ctx.Err() != nil {
return ctx.Err()
}
}
}
return nil
} | [
"func",
"WaitForEndpointsAtPolicyRev",
"(",
"ctx",
"context",
".",
"Context",
",",
"rev",
"uint64",
")",
"error",
"{",
"eps",
":=",
"GetEndpoints",
"(",
")",
"\n",
"for",
"i",
":=",
"range",
"eps",
"{",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"ctx",
".",
"Err",
"(",
")",
"\n",
"case",
"<-",
"eps",
"[",
"i",
"]",
".",
"WaitForPolicyRevision",
"(",
"ctx",
",",
"rev",
",",
"nil",
")",
":",
"if",
"ctx",
".",
"Err",
"(",
")",
"!=",
"nil",
"{",
"return",
"ctx",
".",
"Err",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // WaitForEndpointsAtPolicyRev waits for all endpoints which existed at the time
// this function is called to be at a given policy revision.
// New endpoints appearing while waiting are ignored. | [
"WaitForEndpointsAtPolicyRev",
"waits",
"for",
"all",
"endpoints",
"which",
"existed",
"at",
"the",
"time",
"this",
"function",
"is",
"called",
"to",
"be",
"at",
"a",
"given",
"policy",
"revision",
".",
"New",
"endpoints",
"appearing",
"while",
"waiting",
"are",
"ignored",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L501-L514 |
163,090 | cilium/cilium | pkg/endpointmanager/manager.go | CallbackForEndpointsAtPolicyRev | func CallbackForEndpointsAtPolicyRev(ctx context.Context, rev uint64, done func(time.Time)) error {
eps := GetEndpoints()
for i := range eps {
eps[i].WaitForPolicyRevision(ctx, rev, done)
}
return nil
} | go | func CallbackForEndpointsAtPolicyRev(ctx context.Context, rev uint64, done func(time.Time)) error {
eps := GetEndpoints()
for i := range eps {
eps[i].WaitForPolicyRevision(ctx, rev, done)
}
return nil
} | [
"func",
"CallbackForEndpointsAtPolicyRev",
"(",
"ctx",
"context",
".",
"Context",
",",
"rev",
"uint64",
",",
"done",
"func",
"(",
"time",
".",
"Time",
")",
")",
"error",
"{",
"eps",
":=",
"GetEndpoints",
"(",
")",
"\n",
"for",
"i",
":=",
"range",
"eps",
"{",
"eps",
"[",
"i",
"]",
".",
"WaitForPolicyRevision",
"(",
"ctx",
",",
"rev",
",",
"done",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // CallbackForEndpointsAtPolicyRev registers a callback on all endpoints that
// exist when invoked. It is similar to WaitForEndpointsAtPolicyRevision but
// each endpoint that reaches the desired revision calls 'done' independently.
// The provided callback should not block and generally be lightweight. | [
"CallbackForEndpointsAtPolicyRev",
"registers",
"a",
"callback",
"on",
"all",
"endpoints",
"that",
"exist",
"when",
"invoked",
".",
"It",
"is",
"similar",
"to",
"WaitForEndpointsAtPolicyRevision",
"but",
"each",
"endpoint",
"that",
"reaches",
"the",
"desired",
"revision",
"calls",
"done",
"independently",
".",
"The",
"provided",
"callback",
"should",
"not",
"block",
"and",
"generally",
"be",
"lightweight",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpointmanager/manager.go#L520-L526 |
163,091 | cilium/cilium | api/v1/server/restapi/service/delete_service_id_responses.go | WithPayload | func (o *DeleteServiceIDFailure) WithPayload(payload models.Error) *DeleteServiceIDFailure {
o.Payload = payload
return o
} | go | func (o *DeleteServiceIDFailure) WithPayload(payload models.Error) *DeleteServiceIDFailure {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"DeleteServiceIDFailure",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"Error",
")",
"*",
"DeleteServiceIDFailure",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the delete service Id failure response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"delete",
"service",
"Id",
"failure",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/service/delete_service_id_responses.go#L86-L89 |
163,092 | cilium/cilium | api/v1/health/server/server.go | NewServer | func NewServer(api *restapi.CiliumHealthAPI) *Server {
s := new(Server)
s.shutdown = make(chan struct{})
s.api = api
s.interrupt = make(chan os.Signal, 1)
return s
} | go | func NewServer(api *restapi.CiliumHealthAPI) *Server {
s := new(Server)
s.shutdown = make(chan struct{})
s.api = api
s.interrupt = make(chan os.Signal, 1)
return s
} | [
"func",
"NewServer",
"(",
"api",
"*",
"restapi",
".",
"CiliumHealthAPI",
")",
"*",
"Server",
"{",
"s",
":=",
"new",
"(",
"Server",
")",
"\n\n",
"s",
".",
"shutdown",
"=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"s",
".",
"api",
"=",
"api",
"\n",
"s",
".",
"interrupt",
"=",
"make",
"(",
"chan",
"os",
".",
"Signal",
",",
"1",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // NewServer creates a new api cilium health server but does not configure it | [
"NewServer",
"creates",
"a",
"new",
"api",
"cilium",
"health",
"server",
"but",
"does",
"not",
"configure",
"it"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/server/server.go#L47-L54 |
163,093 | cilium/cilium | api/v1/health/server/server.go | ConfigureAPI | func (s *Server) ConfigureAPI() {
if s.api != nil {
s.handler = configureAPI(s.api)
}
} | go | func (s *Server) ConfigureAPI() {
if s.api != nil {
s.handler = configureAPI(s.api)
}
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"ConfigureAPI",
"(",
")",
"{",
"if",
"s",
".",
"api",
"!=",
"nil",
"{",
"s",
".",
"handler",
"=",
"configureAPI",
"(",
"s",
".",
"api",
")",
"\n",
"}",
"\n",
"}"
] | // ConfigureAPI configures the API and handlers. | [
"ConfigureAPI",
"configures",
"the",
"API",
"and",
"handlers",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/server/server.go#L57-L61 |
163,094 | cilium/cilium | api/v1/health/server/server.go | Logf | func (s *Server) Logf(f string, args ...interface{}) {
if s.api != nil && s.api.Logger != nil {
s.api.Logger(f, args...)
} else {
log.Printf(f, args...)
}
} | go | func (s *Server) Logf(f string, args ...interface{}) {
if s.api != nil && s.api.Logger != nil {
s.api.Logger(f, args...)
} else {
log.Printf(f, args...)
}
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Logf",
"(",
"f",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"s",
".",
"api",
"!=",
"nil",
"&&",
"s",
".",
"api",
".",
"Logger",
"!=",
"nil",
"{",
"s",
".",
"api",
".",
"Logger",
"(",
"f",
",",
"args",
"...",
")",
"\n",
"}",
"else",
"{",
"log",
".",
"Printf",
"(",
"f",
",",
"args",
"...",
")",
"\n",
"}",
"\n",
"}"
] | // Logf logs message either via defined user logger or via system one if no user logger is defined. | [
"Logf",
"logs",
"message",
"either",
"via",
"defined",
"user",
"logger",
"or",
"via",
"system",
"one",
"if",
"no",
"user",
"logger",
"is",
"defined",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/server/server.go#L109-L115 |
163,095 | cilium/cilium | api/v1/health/server/server.go | Fatalf | func (s *Server) Fatalf(f string, args ...interface{}) {
if s.api != nil && s.api.Logger != nil {
s.api.Logger(f, args...)
os.Exit(1)
} else {
log.Fatalf(f, args...)
}
} | go | func (s *Server) Fatalf(f string, args ...interface{}) {
if s.api != nil && s.api.Logger != nil {
s.api.Logger(f, args...)
os.Exit(1)
} else {
log.Fatalf(f, args...)
}
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Fatalf",
"(",
"f",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"s",
".",
"api",
"!=",
"nil",
"&&",
"s",
".",
"api",
".",
"Logger",
"!=",
"nil",
"{",
"s",
".",
"api",
".",
"Logger",
"(",
"f",
",",
"args",
"...",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"else",
"{",
"log",
".",
"Fatalf",
"(",
"f",
",",
"args",
"...",
")",
"\n",
"}",
"\n",
"}"
] | // Fatalf logs message either via defined user logger or via system one if no user logger is defined.
// Exits with non-zero status after printing | [
"Fatalf",
"logs",
"message",
"either",
"via",
"defined",
"user",
"logger",
"or",
"via",
"system",
"one",
"if",
"no",
"user",
"logger",
"is",
"defined",
".",
"Exits",
"with",
"non",
"-",
"zero",
"status",
"after",
"printing"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/server/server.go#L119-L126 |
163,096 | cilium/cilium | api/v1/health/server/server.go | Listen | func (s *Server) Listen() error {
if s.hasListeners { // already done this
return nil
}
if s.hasScheme(schemeHTTPS) {
// Use http host if https host wasn't defined
if s.TLSHost == "" {
s.TLSHost = s.Host
}
// Use http listen limit if https listen limit wasn't defined
if s.TLSListenLimit == 0 {
s.TLSListenLimit = s.ListenLimit
}
// Use http tcp keep alive if https tcp keep alive wasn't defined
if int64(s.TLSKeepAlive) == 0 {
s.TLSKeepAlive = s.KeepAlive
}
// Use http read timeout if https read timeout wasn't defined
if int64(s.TLSReadTimeout) == 0 {
s.TLSReadTimeout = s.ReadTimeout
}
// Use http write timeout if https write timeout wasn't defined
if int64(s.TLSWriteTimeout) == 0 {
s.TLSWriteTimeout = s.WriteTimeout
}
}
if s.hasScheme(schemeUnix) {
domSockListener, err := net.Listen("unix", string(s.SocketPath))
if err != nil {
return err
}
s.domainSocketL = domSockListener
}
if s.hasScheme(schemeHTTP) {
listener, err := net.Listen("tcp", net.JoinHostPort(s.Host, strconv.Itoa(s.Port)))
if err != nil {
return err
}
h, p, err := swag.SplitHostPort(listener.Addr().String())
if err != nil {
return err
}
s.Host = h
s.Port = p
s.httpServerL = listener
}
if s.hasScheme(schemeHTTPS) {
tlsListener, err := net.Listen("tcp", net.JoinHostPort(s.TLSHost, strconv.Itoa(s.TLSPort)))
if err != nil {
return err
}
sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String())
if err != nil {
return err
}
s.TLSHost = sh
s.TLSPort = sp
s.httpsServerL = tlsListener
}
s.hasListeners = true
return nil
} | go | func (s *Server) Listen() error {
if s.hasListeners { // already done this
return nil
}
if s.hasScheme(schemeHTTPS) {
// Use http host if https host wasn't defined
if s.TLSHost == "" {
s.TLSHost = s.Host
}
// Use http listen limit if https listen limit wasn't defined
if s.TLSListenLimit == 0 {
s.TLSListenLimit = s.ListenLimit
}
// Use http tcp keep alive if https tcp keep alive wasn't defined
if int64(s.TLSKeepAlive) == 0 {
s.TLSKeepAlive = s.KeepAlive
}
// Use http read timeout if https read timeout wasn't defined
if int64(s.TLSReadTimeout) == 0 {
s.TLSReadTimeout = s.ReadTimeout
}
// Use http write timeout if https write timeout wasn't defined
if int64(s.TLSWriteTimeout) == 0 {
s.TLSWriteTimeout = s.WriteTimeout
}
}
if s.hasScheme(schemeUnix) {
domSockListener, err := net.Listen("unix", string(s.SocketPath))
if err != nil {
return err
}
s.domainSocketL = domSockListener
}
if s.hasScheme(schemeHTTP) {
listener, err := net.Listen("tcp", net.JoinHostPort(s.Host, strconv.Itoa(s.Port)))
if err != nil {
return err
}
h, p, err := swag.SplitHostPort(listener.Addr().String())
if err != nil {
return err
}
s.Host = h
s.Port = p
s.httpServerL = listener
}
if s.hasScheme(schemeHTTPS) {
tlsListener, err := net.Listen("tcp", net.JoinHostPort(s.TLSHost, strconv.Itoa(s.TLSPort)))
if err != nil {
return err
}
sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String())
if err != nil {
return err
}
s.TLSHost = sh
s.TLSPort = sp
s.httpsServerL = tlsListener
}
s.hasListeners = true
return nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Listen",
"(",
")",
"error",
"{",
"if",
"s",
".",
"hasListeners",
"{",
"// already done this",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"s",
".",
"hasScheme",
"(",
"schemeHTTPS",
")",
"{",
"// Use http host if https host wasn't defined",
"if",
"s",
".",
"TLSHost",
"==",
"\"",
"\"",
"{",
"s",
".",
"TLSHost",
"=",
"s",
".",
"Host",
"\n",
"}",
"\n",
"// Use http listen limit if https listen limit wasn't defined",
"if",
"s",
".",
"TLSListenLimit",
"==",
"0",
"{",
"s",
".",
"TLSListenLimit",
"=",
"s",
".",
"ListenLimit",
"\n",
"}",
"\n",
"// Use http tcp keep alive if https tcp keep alive wasn't defined",
"if",
"int64",
"(",
"s",
".",
"TLSKeepAlive",
")",
"==",
"0",
"{",
"s",
".",
"TLSKeepAlive",
"=",
"s",
".",
"KeepAlive",
"\n",
"}",
"\n",
"// Use http read timeout if https read timeout wasn't defined",
"if",
"int64",
"(",
"s",
".",
"TLSReadTimeout",
")",
"==",
"0",
"{",
"s",
".",
"TLSReadTimeout",
"=",
"s",
".",
"ReadTimeout",
"\n",
"}",
"\n",
"// Use http write timeout if https write timeout wasn't defined",
"if",
"int64",
"(",
"s",
".",
"TLSWriteTimeout",
")",
"==",
"0",
"{",
"s",
".",
"TLSWriteTimeout",
"=",
"s",
".",
"WriteTimeout",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"s",
".",
"hasScheme",
"(",
"schemeUnix",
")",
"{",
"domSockListener",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"string",
"(",
"s",
".",
"SocketPath",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"s",
".",
"domainSocketL",
"=",
"domSockListener",
"\n",
"}",
"\n\n",
"if",
"s",
".",
"hasScheme",
"(",
"schemeHTTP",
")",
"{",
"listener",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"net",
".",
"JoinHostPort",
"(",
"s",
".",
"Host",
",",
"strconv",
".",
"Itoa",
"(",
"s",
".",
"Port",
")",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"h",
",",
"p",
",",
"err",
":=",
"swag",
".",
"SplitHostPort",
"(",
"listener",
".",
"Addr",
"(",
")",
".",
"String",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"s",
".",
"Host",
"=",
"h",
"\n",
"s",
".",
"Port",
"=",
"p",
"\n",
"s",
".",
"httpServerL",
"=",
"listener",
"\n",
"}",
"\n\n",
"if",
"s",
".",
"hasScheme",
"(",
"schemeHTTPS",
")",
"{",
"tlsListener",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"net",
".",
"JoinHostPort",
"(",
"s",
".",
"TLSHost",
",",
"strconv",
".",
"Itoa",
"(",
"s",
".",
"TLSPort",
")",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"sh",
",",
"sp",
",",
"err",
":=",
"swag",
".",
"SplitHostPort",
"(",
"tlsListener",
".",
"Addr",
"(",
")",
".",
"String",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"s",
".",
"TLSHost",
"=",
"sh",
"\n",
"s",
".",
"TLSPort",
"=",
"sp",
"\n",
"s",
".",
"httpsServerL",
"=",
"tlsListener",
"\n",
"}",
"\n\n",
"s",
".",
"hasListeners",
"=",
"true",
"\n",
"return",
"nil",
"\n",
"}"
] | // Listen creates the listeners for the server | [
"Listen",
"creates",
"the",
"listeners",
"for",
"the",
"server"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/server/server.go#L340-L408 |
163,097 | cilium/cilium | api/v1/health/server/server.go | UnixListener | func (s *Server) UnixListener() (net.Listener, error) {
if !s.hasListeners {
if err := s.Listen(); err != nil {
return nil, err
}
}
return s.domainSocketL, nil
} | go | func (s *Server) UnixListener() (net.Listener, error) {
if !s.hasListeners {
if err := s.Listen(); err != nil {
return nil, err
}
}
return s.domainSocketL, nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"UnixListener",
"(",
")",
"(",
"net",
".",
"Listener",
",",
"error",
")",
"{",
"if",
"!",
"s",
".",
"hasListeners",
"{",
"if",
"err",
":=",
"s",
".",
"Listen",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"s",
".",
"domainSocketL",
",",
"nil",
"\n",
"}"
] | // UnixListener returns the domain socket listener | [
"UnixListener",
"returns",
"the",
"domain",
"socket",
"listener"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/server/server.go#L468-L475 |
163,098 | cilium/cilium | api/v1/health/server/server.go | HTTPListener | func (s *Server) HTTPListener() (net.Listener, error) {
if !s.hasListeners {
if err := s.Listen(); err != nil {
return nil, err
}
}
return s.httpServerL, nil
} | go | func (s *Server) HTTPListener() (net.Listener, error) {
if !s.hasListeners {
if err := s.Listen(); err != nil {
return nil, err
}
}
return s.httpServerL, nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"HTTPListener",
"(",
")",
"(",
"net",
".",
"Listener",
",",
"error",
")",
"{",
"if",
"!",
"s",
".",
"hasListeners",
"{",
"if",
"err",
":=",
"s",
".",
"Listen",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"s",
".",
"httpServerL",
",",
"nil",
"\n",
"}"
] | // HTTPListener returns the http listener | [
"HTTPListener",
"returns",
"the",
"http",
"listener"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/server/server.go#L478-L485 |
163,099 | cilium/cilium | api/v1/health/server/server.go | TLSListener | func (s *Server) TLSListener() (net.Listener, error) {
if !s.hasListeners {
if err := s.Listen(); err != nil {
return nil, err
}
}
return s.httpsServerL, nil
} | go | func (s *Server) TLSListener() (net.Listener, error) {
if !s.hasListeners {
if err := s.Listen(); err != nil {
return nil, err
}
}
return s.httpsServerL, nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"TLSListener",
"(",
")",
"(",
"net",
".",
"Listener",
",",
"error",
")",
"{",
"if",
"!",
"s",
".",
"hasListeners",
"{",
"if",
"err",
":=",
"s",
".",
"Listen",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"s",
".",
"httpsServerL",
",",
"nil",
"\n",
"}"
] | // TLSListener returns the https listener | [
"TLSListener",
"returns",
"the",
"https",
"listener"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/server/server.go#L488-L495 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.