Skip to content

Commit

Permalink
Rule sorting/strict mode fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Chen committed Jul 24, 2024
1 parent da05900 commit f2c03b7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.21.11
1.21.12
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/aws/aws-network-policy-agent

go 1.21.11
go 1.21.12

require (
github.com/aws/amazon-vpc-cni-k8s v1.18.1
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
github.com/aws/amazon-vpc-cni-k8s v1.18.1 h1:u/OeBgnUUX6f3PCEOpA4dbG0+iZ71CnY6tEljjrl3iw=
github.com/aws/amazon-vpc-cni-k8s v1.18.1/go.mod h1:m/J5GsxF0Th2iQTOE3ww4W9LFvwdC0tGyA9dIL4h6iQ=
github.com/aws/aws-ebpf-sdk-go v1.0.9-rc1 h1:vDtkvNEvdF8L+2/qBahIuyLvOTeQs+ToVbkGw4QGJvI=
github.com/aws/aws-ebpf-sdk-go v1.0.9-rc1/go.mod h1:6lwTHtNgTp/kQzx4pdnp09LJevvIVqYf0ce8pP2u66E=
github.com/aws/aws-ebpf-sdk-go v1.0.9-rc2 h1:W2mdC1KjMk/fh7jfF/YP6s+Y9FsiEYc33PdJVsfix1g=
github.com/aws/aws-ebpf-sdk-go v1.0.9-rc2/go.mod h1:SBy1vl1WXMingLbqPZfHd1VXTqB9cD473JwUfoEM+Qs=
github.com/aws/aws-ebpf-sdk-go v1.0.9 h1:FvkyeRUKNvbUFgzh+Ia7XbBb5U86dHW6dCrljt76Fao=
github.com/aws/aws-ebpf-sdk-go v1.0.9/go.mod h1:SBy1vl1WXMingLbqPZfHd1VXTqB9cD473JwUfoEM+Qs=
github.com/aws/aws-sdk-go v1.50.30 h1:2OelKH1eayeaH7OuL1Y9Ombfw4HK+/k0fEnJNWjyLts=
Expand Down
3 changes: 2 additions & 1 deletion pkg/ebpf/bpf_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,8 @@ func (l *bpfClient) updateEbpfMap(mapToUpdate goebpfmaps.BpfMap, firewallRules [
func sortFirewallRulesByPrefixLength(rules []EbpfFirewallRules, prefixLenStr string) {
sort.Slice(rules, func(i, j int) bool {

prefixLen, _ := strconv.Atoi(prefixLenStr)
prefixSplit := strings.Split(prefixLenStr, "/")
prefixLen, _ := strconv.Atoi(prefixSplit[1])
prefixLenIp1 := prefixLen
prefixLenIp2 := prefixLen

Expand Down
8 changes: 8 additions & 0 deletions pkg/rpc/rpc_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ type server struct {

// EnforceNpToPod processes CNI Enforce NP network request
func (s *server) EnforceNpToPod(ctx context.Context, in *rpc.EnforceNpRequest) (*rpc.EnforceNpReply, error) {
if s.policyReconciler.GeteBPFClient() == nil {
s.log.Info("Network policy is disabled, returning success")
success := rpc.EnforceNpReply{
Success: true,
}
return &success, nil
}

s.log.Info("Received Enforce Network Policy Request for Pod", "Name", in.K8S_POD_NAME, "Namespace", in.K8S_POD_NAMESPACE)
var err error

Expand Down
2 changes: 2 additions & 0 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"crypto/sha1"
"encoding/binary"
"encoding/hex"
"errors"
"fmt"
"net"
"strings"
Expand Down Expand Up @@ -165,6 +166,7 @@ func ComputeTrieValue(l4Info []v1alpha1.Port, log logr.Logger, allowAll, denyAll

for _, l4Entry := range l4Info {
if startOffset >= TRIE_VALUE_LENGTH {
log.Error(errors.New("trie value exceeds max trie value length"), "trie value exceeds the 24 port/protocol combinations")
return value
}
endPort = 0
Expand Down

0 comments on commit f2c03b7

Please sign in to comment.