Skip to content

Commit

Permalink
reduce plugin size
Browse files Browse the repository at this point in the history
  • Loading branch information
matmerr committed May 28, 2024
1 parent 40185dc commit bb0f414
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 390 deletions.
12 changes: 5 additions & 7 deletions controller/Dockerfile.windows-native
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,31 @@
# It can't be placed in the other Windows Dockerfile, as those use
# buildx targets, and this one requires legacy build.
# Maybe one day: https://github.com/moby/buildkit/issues/616

ARG BUILDER_IMAGE
FROM --platform=windows/amd64 ${BUILDER_IMAGE} as builder
FROM --platform=windows/amd64 mcr.microsoft.com/oss/go/microsoft/golang:1.22.2-windowsservercore-ltsc2022 as builder
WORKDIR C:\\retina
RUN gcc.exe --version
RUN go version
COPY go.mod .
COPY go.sum .
ENV CGO_ENABLED=1
RUN go mod download
RUN go mod verify
ADD . .
RUN cp -r c:/pktmon/ pkg/plugin/windows/pktmon/packetmonitorsupport/
RUN ls pkg/plugin/windows/pktmon/packetmonitorsupport/
ARG VERSION
ARG APP_INSIGHTS_ID
SHELL ["cmd", "/S", "/C"]
ENV VERSION=$VERSION
ENV APP_INSIGHTS_ID=$APP_INSIGHTS_ID

ENV APP_INSIGHTS_ID=$APP_INSIGHTS_ID
RUN go build -v -o controller.exe -ldflags="-X main.version=%VERSION% -X main.applicationInsightsID=%APP_INSIGHTS_ID%" .\controller
RUN go build -v -o captureworkload.exe -ldflags="-X main.version=%VERSION% -X main.applicationInsightsID=%APP_INSIGHTS_ID%" .\captureworkload

FROM --platform=windows/amd64 ${BUILDER_IMAGE} as pktmon-builder
WORKDIR C:\\retina

FROM --platform=windows/amd64 mcr.microsoft.com/windows/nanoserver:ltsc2022 as final
ADD https://github.com/microsoft/etl2pcapng/releases/download/v1.10.0/etl2pcapng.exe /etl2pcapng.exe
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue';"]
COPY --from=builder C:\\retina\\controller.exe controller.exe
COPY --from=pktmon-builder C:\\pktmon\\controller-pktmon.exe controller-pktmon.exe
COPY --from=builder C:\\retina\\captureworkload.exe captureworkload.exe
CMD ["controller.exe"]
2 changes: 1 addition & 1 deletion controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func init() {
}

func main() {
fmt.Printf("starting Retina %v", version)
fmt.Printf("starting Retina %v\n", version)
var metricsAddr string
var enableLeaderElection bool
var probeAddr string
Expand Down
41 changes: 18 additions & 23 deletions pkg/metrics/types_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@ import (
"github.com/cilium/cilium/api/v1/flow"
)

func GetDropTypeFlowDropReason(dr flow.DropReason) DropReasonType {
if v, ok := dropReasons[uint32(dr)]; ok {
return v.Reason
}

return fmt.Sprintf("UnknownDropReason(%d)", dr)
func GetDropTypeFlowDropReason(dr flow.DropReason) string {
return dr.String()
}

func GetDropReason(reason uint32) DropReasonType {
if v, ok := dropReasons[reason]; ok {
return v.Reason
}

return fmt.Sprintf("UnknownDropReason(%d)", reason)
return Drop_Unknown
}

func (d DropReasonType) String() string {
Expand Down Expand Up @@ -76,7 +71,7 @@ var dropReasons = map[uint32]DropReasonWin{
38: {Drop_LowPower, "Drop_LowPower"},

//
//Generalerrors
// Generalerrors
//
201: {Drop_Pause, "Drop_Pause"},
202: {Drop_Reset, "Drop_Reset"},
Expand Down Expand Up @@ -107,15 +102,15 @@ var dropReasons = map[uint32]DropReasonWin{
228: {Drop_SteeringMismatch, "Drop_SteeringMismatch"},

//
//NetVscerrors
// NetVscerrors
//
401: {Drop_MicroportError, "Drop_MicroportError"},
402: {Drop_VfNotReady, "Drop_VfNotReady"},
403: {Drop_MicroportNotReady, "Drop_MicroportNotReady"},
404: {Drop_VMBusError, "Drop_VMBusError"},

//
//TcpipFLerrors
// TcpipFLerrors
//
601: {Drop_FL_LoopbackPacket, "Drop_FL_LoopbackPacket"},
602: {Drop_FL_InvalidSnapHeader, "Drop_FL_InvalidSnapHeader"},
Expand All @@ -134,7 +129,7 @@ var dropReasons = map[uint32]DropReasonWin{
615: {Drop_FL_FlsNpiClientDrop, "Drop_FL_FlsNpiClientDrop"},

//
//VFPerrors
// VFPerrors
//
701: {Drop_ArpGuard, "Drop_ArpGuard"},
702: {Drop_ArpLimiter, "Drop_ArpLimiter"},
Expand All @@ -157,7 +152,7 @@ var dropReasons = map[uint32]DropReasonWin{
719: {Drop_NicSuspended, "Drop_NicSuspended"},

//
//TcpipNLerrors
// TcpipNLerrors
//
901: {Drop_NL_BadSourceAddress, "Drop_NL_BadSourceAddress"},
902: {Drop_NL_NotLocallyDestined, "Drop_NL_NotLocallyDestined"},
Expand Down Expand Up @@ -268,7 +263,7 @@ var dropReasons = map[uint32]DropReasonWin{
1002: {Drop_NL_SwUsoFailure, "Drop_NL_SwUsoFailure"},

//
//INETdiscardreasons
// INETdiscardreasons
//
1200: {Drop_INET_SourceUnspecified, "Drop_INET_SourceUnspecified"},
1201: {Drop_INET_DestinationMulticast, "Drop_INET_DestinationMulticast"},
Expand Down Expand Up @@ -305,7 +300,7 @@ var dropReasons = map[uint32]DropReasonWin{
1232: {Drop_INET_AcceptRedirection, "Drop_INET_AcceptRedirection"},

//
//SlbmuxError
// SlbmuxError
//
1301: {Drop_SlbMux_ParsingFailure, "Drop_SlbMux_ParsingFailure"},
1302: {Drop_SlbMux_FirstFragmentMiss, "Drop_SlbMux_FirstFragmentMiss"},
Expand Down Expand Up @@ -336,7 +331,7 @@ var dropReasons = map[uint32]DropReasonWin{
1327: {Drop_SlbMux_UnableToHandleRedirect, "Drop_SlbMux_UnableToHandleRedirect"},

//
//IpsecErrors
// IpsecErrors
//
1401: {Drop_Ipsec_BadSpi, "Drop_Ipsec_BadSpi"},
1402: {Drop_Ipsec_SALifetimeExpired, "Drop_Ipsec_SALifetimeExpired"},
Expand All @@ -358,7 +353,7 @@ var dropReasons = map[uint32]DropReasonWin{
1418: {Drop_Ipsec_Unsuccessful, "Drop_Ipsec_Unsuccessful"},

//
//NetCxDropReasons
// NetCxDropReasons
//
1501: {Drop_NetCx_NetPacketLayoutParseFailure, "Drop_NetCx_NetPacketLayoutParseFailure"},
1502: {Drop_NetCx_SoftwareChecksumFailure, "Drop_NetCx_SoftwareChecksumFailure"},
Expand All @@ -369,13 +364,13 @@ var dropReasons = map[uint32]DropReasonWin{
1507: {Drop_NetCx_BufferBounceFailureAndPacketIgnore, "Drop_NetCx_BufferBounceFailureAndPacketIgnore"},

//
//Httperrors3000-4000.
//Thesemustbeinsyncwithcmd\resource.h
// Httperrors3000-4000.
// Thesemustbeinsyncwithcmd\resource.h
//
3000: {Drop_Http_Begin, "Drop_Http_Begin"},

//
//UlErrors
// UlErrors
//
3001: {Drop_Http_UlError_Begin, "Drop_Http_UlError_Begin"},
3002: {Drop_Http_UlError, "Drop_Http_UlError"},
Expand Down Expand Up @@ -412,7 +407,7 @@ var dropReasons = map[uint32]DropReasonWin{
3030: {Drop_Http_UlError_End, "Drop_Http_UlError_End"},

//
//Stream-specificfaultcodes.
// Stream-specificfaultcodes.
//

3400: {Drop_Http_UxDuoFaultBegin, "Drop_Http_UxDuoFaultBegin"},
Expand Down Expand Up @@ -481,12 +476,12 @@ var dropReasons = map[uint32]DropReasonWin{
3463: {Drop_Http_UxDuoFaultEnd, "Drop_Http_UxDuoFaultEnd"},

//
//WSKlayerdrops
// WSKlayerdrops
//
3600: {Drop_Http_ReceiveSuppressed, "Drop_Http_ReceiveSuppressed"},

//
//Http/SSLlayerdrops
// Http/SSLlayerdrops
//
3800: {Drop_Http_Generic, "Drop_Http_Generic"},
3801: {Drop_Http_InvalidParameter, "Drop_Http_InvalidParameter"},
Expand Down
116 changes: 0 additions & 116 deletions pkg/plugin/windows/pktmon/pktmon_parsing_windows.go

This file was deleted.

Loading

0 comments on commit bb0f414

Please sign in to comment.