forked from cilium/cilium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base layer which implements setup of BBR + {MQ/FQ, FQ} as well as EDT based rate-limiting in BPF. Agent code implements map setup and handling of egress bandwidth label for Pods. Signed-off-by: Daniel Borkmann <[email protected]>
- Loading branch information
Showing
36 changed files
with
590 additions
and
30 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* Copyright (C) 2020 Authors of Cilium */ | ||
|
||
#ifndef __EDT_H_ | ||
#define __EDT_H_ | ||
|
||
#include "common.h" | ||
#include "time.h" | ||
#include "maps.h" | ||
|
||
#ifdef ENABLE_BANDWIDTH_MANAGER | ||
static __always_inline void edt_set_aggregate(struct __ctx_buff *ctx, | ||
__u32 aggregate) | ||
{ | ||
/* 16 bit as current used aggregate, and preserved in host ns. */ | ||
ctx->queue_mapping = aggregate; | ||
} | ||
|
||
static __always_inline __u32 edt_get_aggregate(struct __ctx_buff *ctx) | ||
{ | ||
__u32 aggregate = ctx->queue_mapping; | ||
|
||
/* We need to reset queue mapping here such that new mapping will | ||
* be performed based on skb hash. See netdev_pick_tx(). | ||
*/ | ||
ctx->queue_mapping = 0; | ||
|
||
return aggregate; | ||
} | ||
|
||
static __always_inline int edt_sched_departure(struct __ctx_buff *ctx) | ||
{ | ||
__u64 delay, now, t, t_next; | ||
struct edt_id aggregate; | ||
struct edt_info *info; | ||
__u16 proto; | ||
|
||
if (!validate_ethertype(ctx, &proto)) | ||
return CTX_ACT_OK; | ||
if (proto != bpf_htons(ETH_P_IP) && | ||
proto != bpf_htons(ETH_P_IPV6)) | ||
return CTX_ACT_OK; | ||
|
||
aggregate.id = edt_get_aggregate(ctx); | ||
if (!aggregate.id) | ||
return CTX_ACT_OK; | ||
|
||
info = map_lookup_elem(&THROTTLE_MAP, &aggregate); | ||
if (!info) | ||
return CTX_ACT_OK; | ||
|
||
now = ktime_get_ns(); | ||
t = ctx->tstamp; | ||
if (t < now) | ||
t = now; | ||
delay = ((__u64)ctx_wire_len(ctx)) * NSEC_PER_SEC / info->bps; | ||
t_next = READ_ONCE(info->t_last) + delay; | ||
if (t_next <= t) { | ||
WRITE_ONCE(info->t_last, t); | ||
return CTX_ACT_OK; | ||
} | ||
/* FQ implements a drop horizon, see also 39d010504e6b ("net_sched: | ||
* sch_fq: add horizon attribute"). However, we explicitly need the | ||
* drop horizon here to i) avoid having t_last messed up and ii) to | ||
* potentially allow for per aggregate control. | ||
*/ | ||
if (t_next - now >= info->t_horizon_drop) | ||
return CTX_ACT_DROP; | ||
WRITE_ONCE(info->t_last, t_next); | ||
ctx->tstamp = t_next; | ||
return CTX_ACT_OK; | ||
} | ||
#else | ||
static __always_inline void | ||
edt_set_aggregate(struct __ctx_buff *ctx __maybe_unused, | ||
__u32 aggregate __maybe_unused) | ||
{ | ||
} | ||
#endif /* ENABLE_BANDWIDTH_MANAGER */ | ||
#endif /* __EDT_H_ */ |
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
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.