-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bwmap: Reconcile cilium_throttle with StateDB reconciler
Store the per-endpoint EDT settings in Table[bwmap.Edt] and reconcile it to the cilium_throttle BPF map with the StateDB reconciler. This is the first BPF map being converted over to this style and aims to serve as an example. This improves resilience (failed operations are retried, and the map re-synced periodically). The reconciliation status of the entries can inspected with "cilium-dbg statedb bandwidth-edts" and the failed reconciliation is reported as part of module health ("cilium-dbg status --all-health") Signed-off-by: Jussi Maki <[email protected]>
- Loading branch information
Showing
15 changed files
with
299 additions
and
68 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -295,6 +295,7 @@ eBGP | |
eBPF | ||
eXpress | ||
ebpf | ||
edts | ||
effectful | ||
egressing | ||
elfutils | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ import ( | |
|
||
"github.com/cilium/cilium/pkg/datapath/linux/config/defines" | ||
"github.com/cilium/cilium/pkg/datapath/linux/probes" | ||
"github.com/cilium/cilium/pkg/datapath/types" | ||
"github.com/cilium/cilium/pkg/logging/logfields" | ||
"github.com/cilium/cilium/pkg/maps/bwmap" | ||
) | ||
|
@@ -28,8 +29,6 @@ const ( | |
// IngressBandwidth is the K8s Pod annotation. | ||
IngressBandwidth = "kubernetes.io/ingress-bandwidth" | ||
|
||
EnableBBR = "enable-bbr" | ||
|
||
// FqDefaultHorizon represents maximum allowed departure | ||
// time delta in future. Given applications can set SO_TXTIME | ||
// from user space this is a limit to prevent buggy applications | ||
|
@@ -69,11 +68,26 @@ func (m *manager) defines() (defines.Map, error) { | |
return cDefinesMap, nil | ||
} | ||
|
||
func (m *manager) DeleteEndpointBandwidthLimit(epID uint16) error { | ||
func (m *manager) UpdateBandwidthLimit(epID uint16, bytesPerSecond uint64) { | ||
if m.enabled { | ||
return bwmap.Delete(epID) | ||
txn := m.params.DB.WriteTxn(m.params.EdtTable) | ||
m.params.EdtTable.Insert( | ||
txn, | ||
bwmap.NewEdt(epID, bytesPerSecond), | ||
) | ||
txn.Commit() | ||
} | ||
} | ||
|
||
func (m *manager) DeleteBandwidthLimit(epID uint16) { | ||
if m.enabled { | ||
txn := m.params.DB.WriteTxn(m.params.EdtTable) | ||
obj, _, found := m.params.EdtTable.Get(txn, bwmap.EdtIDIndex.Query(epID)) | ||
if found { | ||
m.params.EdtTable.Delete(txn, obj) | ||
} | ||
txn.Commit() | ||
} | ||
return nil | ||
} | ||
|
||
func GetBytesPerSec(bandwidth string) (uint64, error) { | ||
|
@@ -111,7 +125,7 @@ func (m *manager) probe() error { | |
// - https://lpc.events/event/11/contributions/953/ | ||
// - https://lore.kernel.org/bpf/[email protected]/ | ||
if probes.HaveProgramHelper(ebpf.SchedCLS, asm.FnSkbSetTstamp) != nil { | ||
return fmt.Errorf("cannot enable --%s, needs kernel 5.18 or newer", EnableBBR) | ||
return fmt.Errorf("cannot enable --%s, needs kernel 5.18 or newer", types.EnableBBRFlag) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.