Skip to content

Commit

Permalink
Minor refactor (#116)
Browse files Browse the repository at this point in the history
* Update pr-tests.yaml

* Minor refactor
  • Loading branch information
jayanthvn authored Oct 26, 2023
1 parent 52bb111 commit d0dfca8
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pkg/ebpf/bpf_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,9 +715,10 @@ func (l *bpfClient) updateEbpfMap(mapToUpdate goebpfmaps.BpfMap, firewallRules [
return nil
}

func sortFirewallRulesByPrefixLength(rules []EbpfFirewallRules, prefixLen int) {
func sortFirewallRulesByPrefixLength(rules []EbpfFirewallRules, prefixLenStr string) {
sort.Slice(rules, func(i, j int) bool {

prefixLen, _ := strconv.Atoi(prefixLenStr)
prefixLenIp1 := prefixLen
prefixLenIp2 := prefixLen

Expand Down Expand Up @@ -751,11 +752,7 @@ func (l *bpfClient) computeMapEntriesFromEndpointRules(firewallRules []EbpfFirew
mapEntries[string(key)] = uintptr(unsafe.Pointer(&value[0]))

//Sort the rules
defaultPrefixLen := 32
if l.enableIPv6 {
defaultPrefixLen = 128
}
sortFirewallRulesByPrefixLength(firewallRules, defaultPrefixLen)
sortFirewallRulesByPrefixLength(firewallRules, l.hostMask)

//Check and aggregate L4 Port Info for Catch All Entries.
catchAllIPPorts, isCatchAllIPEntryPresent, allowAll = l.checkAndDeriveCatchAllIPPorts(firewallRules)
Expand Down

0 comments on commit d0dfca8

Please sign in to comment.