Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Windows drop reasons #406

Merged
merged 4 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions pkg/utils/flow_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,8 @@ func AddDropReason(f *flow.Flow, meta *RetinaMetadata, dropReason uint32) {
// Retina drop reasons are different from the drop reasons available in flow library.
// We map the ones available in flow library to the ones available in Retina.
// Rest are set to UNKNOWN. The details are added in the metadata.
switch meta.GetDropReason() { //nolint:exhaustive // We are handling all the cases.
case DropReason_IPTABLE_RULE_DROP:
f.DropReasonDesc = flow.DropReason_POLICY_DENIED
case DropReason_IPTABLE_NAT_DROP:
f.DropReasonDesc = flow.DropReason_SNAT_NO_MAP_FOUND
case DropReason_CONNTRACK_ADD_DROP:
f.DropReasonDesc = flow.DropReason_UNKNOWN_CONNECTION_TRACKING_STATE
default:
f.DropReasonDesc = flow.DropReason_DROP_REASON_UNKNOWN
}

f.DropReasonDesc = GetDropReasonDesc(meta.GetDropReason())
}

func DropReasonDescription(f *flow.Flow) string {
Expand Down
File renamed without changes.
File renamed without changes.
2,357 changes: 2,357 additions & 0 deletions pkg/utils/metadata_windows.pb.go

Large diffs are not rendered by default.

497 changes: 497 additions & 0 deletions pkg/utils/metadata_windows.proto

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions pkg/utils/utils_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"syscall"
"unsafe"

"github.com/cilium/cilium/api/v1/flow"
"github.com/pkg/errors"
"github.com/vishvananda/netlink"
"golang.org/x/exp/maps"
Expand Down Expand Up @@ -142,3 +143,20 @@ func isDefaultRoute(route netlink.Route) bool {

return false
}

func GetDropReasonDesc(dr DropReason) flow.DropReason {
// Set the drop reason.
// Retina drop reasons are different from the drop reasons available in flow library.
// We map the ones available in flow library to the ones available in Retina.
// Rest are set to UNKNOWN. The details are added in the metadata.
switch dr { //nolint:exhaustive // We are handling all the cases.
case DropReason_IPTABLE_RULE_DROP:
return flow.DropReason_POLICY_DENIED
case DropReason_IPTABLE_NAT_DROP:
return flow.DropReason_SNAT_NO_MAP_FOUND
case DropReason_CONNTRACK_ADD_DROP:
return flow.DropReason_UNKNOWN_CONNECTION_TRACKING_STATE
default:
return flow.DropReason_DROP_REASON_UNKNOWN
}
}
16 changes: 16 additions & 0 deletions pkg/utils/utils_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package utils

import (
"github.com/cilium/cilium/api/v1/flow"
)

func GetDropReasonDesc(dr DropReason) flow.DropReason {
switch dr { //nolint:exhaustive // We are handling all the cases.
case DropReason_Drop_INET_FinWait2:
return flow.DropReason_UNKNOWN_CONNECTION_TRACKING_STATE
default:
return flow.DropReason_DROP_REASON_UNKNOWN
}
}
Loading