Skip to content

Commit

Permalink
update ebpf
Browse files Browse the repository at this point in the history
  • Loading branch information
pfandzelter committed Apr 30, 2024
1 parent ce5f7f8 commit 50acd9a
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 63 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ proto/celestial/celestial.pb.go proto/celestial/celestial_grpc.pb.go proto/celes
@protoc -I proto/celestial/ celestial.proto --go_out=proto/celestial --go_opt=paths=source_relative --go-grpc_out=proto/celestial --go-grpc_opt=require_unimplemented_servers=false,paths=source_relative
@python3 -m grpc_tools.protoc -I proto/celestial/ --python_out=proto/celestial --grpc_python_out=proto/celestial --mypy_out=proto/celestial celestial.proto --mypy_grpc_out=proto/celestial

ebpf: pkg/ebpfem/edt_bpfel_x86.go pkg/ebpfem/edt_bpfel_x86.o ## build ebpf files
pkg/ebpfem/edt_bpfel_x86.go pkg/ebpfem/edt_bpfel_x86.o: pkg/ebpfem/ebpfem.go pkg/ebpfem/ebpf/net.c pkg/ebpfem/ebpf/headers/helpers.h pkg/ebpfem/ebpf/headers/maps.h ## build ebpf files
ebpf: pkg/ebpfem/edt_x86_bpfel.go pkg/ebpfem/edt_x86_bpfel.o ## build ebpf files
pkg/ebpfem/edt_x86_bpfel.go pkg/ebpfem/edt_x86_bpfel.o: pkg/ebpfem/ebpfem.go pkg/ebpfem/ebpf/net.c pkg/ebpfem/ebpf/headers/helpers.h pkg/ebpfem/ebpf/headers/maps.h ## build ebpf files
## apt-get install -y clang gcc-multilib libbpf-dev llvm
@go generate ./pkg/ebpfem

Expand Down
2 changes: 1 addition & 1 deletion compile.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ARG OS=linux
ARG ARCH=x86_64
ARG GO_ARCH=amd64
ARG LIBPROTOC_VERSION=25.1
ARG GO_VERSION=1.21.6
ARG GO_VERSION=1.22.1
ARG PROTOC_GEN_GO_VERSION=1.31.0
ARG PROTOC_GEN_GO_GRPC_VERSION=1.3

Expand Down
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

module github.com/OpenFogStack/celestial

go 1.21
go 1.21.0

toolchain go1.21.3
toolchain go1.22.1

require (
github.com/cilium/ebpf v0.12.3
github.com/cilium/ebpf v0.15.0
github.com/firecracker-microvm/firecracker-go-sdk v1.0.0
github.com/go-ping/ping v1.1.0
github.com/gorilla/mux v1.8.1
Expand All @@ -31,7 +31,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.3
github.com/vishvananda/netlink v1.2.1-beta.2
golang.org/x/sys v0.14.1-0.20231108175955-e4099bfacb8c
golang.org/x/sys v0.15.0
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
Expand Down Expand Up @@ -63,7 +63,6 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
go.mongodb.org/mongo-driver v1.12.1 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
Expand Down
20 changes: 8 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,9 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
github.com/cilium/ebpf v0.0.0-20200110133405-4032b1d8aae3/go.mod h1:MA5e5Lr8slmEg9bt0VpxxWqJlO4iwu3FBdHUzV7wQVg=
github.com/cilium/ebpf v0.0.0-20200702112145-1c8d4c9ef775/go.mod h1:7cR51M8ViRLIdUjrmSXlK9pkrsDlLHbO8jiB8X8JnOc=
github.com/cilium/ebpf v0.2.0/go.mod h1:To2CFviqOWL/M0gIMsvSMlqe7em/l1ALkX1PyjrX2Qs=
github.com/cilium/ebpf v0.4.0 h1:QlHdikaxALkqWasW8hAC1mfR0jdmvbfaBdBPFmRSglA=
github.com/cilium/ebpf v0.4.0/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs=
github.com/cilium/ebpf v0.9.0 h1:ldiV+FscPCQ/p3mNEV4O02EPbUZJFsoEtHvIr9xLTvk=
github.com/cilium/ebpf v0.9.0/go.mod h1:+OhNOIXx/Fnu1IE8bJz2dzOA+VSfyTfdNUVdlQnxUFY=
github.com/cilium/ebpf v0.12.3 h1:8ht6F9MquybnY97at+VDZb3eQQr8ev79RueWeVaEcG4=
github.com/cilium/ebpf v0.12.3/go.mod h1:TctK1ivibvI3znr66ljgi4hqOT8EYQjz1KWBfb1UVgM=
github.com/cilium/ebpf v0.15.0 h1:7NxJhNiBT3NG8pZJ3c+yfrVdHY8ScgKD27sScgjLMMk=
github.com/cilium/ebpf v0.15.0/go.mod h1:DHp1WyrLeiBh19Cf/tfiSMhqheEiK8fXFZ4No0P1Hso=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
Expand Down Expand Up @@ -253,7 +250,6 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv
github.com/firecracker-microvm/firecracker-go-sdk v1.0.0 h1:HTnxnX9pvQkQOHjv+TppzUyi2BNFL/7aegSlqIK/usY=
github.com/firecracker-microvm/firecracker-go-sdk v1.0.0/go.mod h1:iXd7gqdwzvhB4VbNVMb70g/IY04fOuQbbBGM+PQEkgo=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY=
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
Expand Down Expand Up @@ -327,6 +323,8 @@ github.com/go-openapi/validate v0.22.1/go.mod h1:rjnrwK57VJ7A8xqfpAOEKRH8yQSGUri
github.com/go-ping/ping v0.0.0-20211130115550-779d1e919534/go.mod h1:xIFjORFzTxqIV/tDVGO4eDy/bLuSyawEeojSm3GfRGk=
github.com/go-ping/ping v1.1.0 h1:3MCGhVX4fyEUuhsfwPrsEdQw6xspHkv5zHsiSoDFZYw=
github.com/go-ping/ping v1.1.0/go.mod h1:xIFjORFzTxqIV/tDVGO4eDy/bLuSyawEeojSm3GfRGk=
github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI=
github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
Expand Down Expand Up @@ -652,8 +650,8 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4=
github.com/safchain/ethtool v0.0.0-20210803160452-9aa261dae9b1/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4=
Expand Down Expand Up @@ -972,10 +970,8 @@ golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.1-0.20231108175955-e4099bfacb8c h1:3kC/TjQ+xzIblQv39bCOyRk8fbEeJcDHwbyxPUU2BpA=
golang.org/x/sys v0.14.1-0.20231108175955-e4099bfacb8c/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
Expand Down
10 changes: 5 additions & 5 deletions pkg/ebpfem/ebpf/headers/maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
**/

// Adapted from: https://github.com/srnbckr/ebpf-network-emulation/blob/main/cmd/headers/maps.h
struct handle_bps_delay
struct handle_kbps_delay
{
__u32 throttle_rate_bps;
__u32 throttle_rate_kbps;
__u32 delay_us;
} HANDLE_BPS_DELAY;
} HANDLE_KBPS_DELAY;

struct
{
__uint(type, BPF_MAP_TYPE_HASH);
__type(key, __u32);
__type(value, HANDLE_BPS_DELAY);
__type(value, HANDLE_KBPS_DELAY);
__uint(max_entries, 65535);
} IP_HANDLE_BPS_DELAY SEC(".maps");
} IP_HANDLE_KBPS_DELAY SEC(".maps");
24 changes: 14 additions & 10 deletions pkg/ebpfem/ebpf/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ struct
__uint(max_entries, 65535);
} flow_map SEC(".maps");

static inline int throttle_flow(struct __sk_buff *skb, __u32 ip_address, uint32_t *throttle_rate_bps)
static inline int throttle_flow(struct __sk_buff *skb, __u32 ip_address, uint32_t *throttle_rate_kbps)
{
// use ip as key in map
int key = ip_address;

// find out if the packet should be dropped (i.e. if the rate is 0)
if (*throttle_rate_bps == 0)
if (*throttle_rate_kbps == 0)
{
return TC_ACT_SHOT;
// TODO: originally I wanted to set a mark and have iptables reject
Expand All @@ -70,8 +70,8 @@ static inline int throttle_flow(struct __sk_buff *skb, __u32 ip_address, uint32_

// when was the last packet sent?
uint64_t *last_tstamp = bpf_map_lookup_elem(&flow_map, &key);
// calculate delay between packets based on bandwidth and packet size (bps = byte/second)
uint64_t delay_ns = ((uint64_t)skb->len) * NS_PER_SEC / *throttle_rate_bps;
// calculate delay between packets based on bandwidth and packet size (kbps = byte/1000/second)
uint64_t delay_ns = ((uint64_t)skb->len) * NS_PER_SEC / 1000 / *throttle_rate_kbps;

uint64_t now = bpf_ktime_get_ns();
uint64_t tstamp, next_tstamp = 0;
Expand All @@ -88,8 +88,11 @@ static inline int throttle_flow(struct __sk_buff *skb, __u32 ip_address, uint32_
// if the delayed timestamp is already in the past, send the packet
if (next_tstamp <= tstamp)
{
// setting the timestamp
// if it does not work, drop the packet
if (bpf_map_update_elem(&flow_map, &key, &tstamp, BPF_ANY))
return TC_ACT_SHOT;
// return TC_ACT_OK;

return TC_ACT_OK;
}
Expand All @@ -105,6 +108,7 @@ static inline int throttle_flow(struct __sk_buff *skb, __u32 ip_address, uint32_
// update last timestamp in map
if (bpf_map_update_elem(&flow_map, &key, &next_tstamp, BPF_EXIST))
return TC_ACT_SHOT;
// return TC_ACT_OK;

// set delayed timestamp for packet
skb->tstamp = next_tstamp;
Expand Down Expand Up @@ -165,27 +169,27 @@ int tc_main(struct __sk_buff *skb)
// source IP, to be used as map lookup key
// see above
__u32 ip_address = iphdr->saddr;
__u32 *throttle_rate_bps;
__u32 *throttle_rate_kbps;
__u32 *delay_us;

struct handle_bps_delay *val_struct;
struct handle_kbps_delay *val_struct;
// Map lookup
val_struct = bpf_map_lookup_elem(&IP_HANDLE_BPS_DELAY, &ip_address);
val_struct = bpf_map_lookup_elem(&IP_HANDLE_KBPS_DELAY, &ip_address);

// Safety check, go on if no handle could be retrieved
if (!val_struct)
{
return TC_ACT_OK;
}

throttle_rate_bps = &val_struct->throttle_rate_bps;
throttle_rate_kbps = &val_struct->throttle_rate_kbps;
// Safety check, go on if no handle could be retrieved
if (!throttle_rate_bps)
if (!throttle_rate_kbps)
{
return TC_ACT_OK;
}

int ret = throttle_flow(skb, ip_address, throttle_rate_bps);
int ret = throttle_flow(skb, ip_address, throttle_rate_kbps);

if (ret != TC_ACT_OK)
{
Expand Down
22 changes: 11 additions & 11 deletions pkg/ebpfem/ebpfem.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/OpenFogStack/celestial/pkg/orchestrator"
)

//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -target amd64 edt ebpf/net.c -- -I./ebpf/headers
//go:generate env BPF2GO_FLAGS="-O3" go run github.com/cilium/ebpf/cmd/bpf2go -target amd64 edt ebpf/net.c -- -I./ebpf/headers

func New() *EBPFem {
return &EBPFem{
Expand All @@ -57,7 +57,7 @@ func (e *EBPFem) Register(id orchestrator.MachineID, netIf string) error {
v := &vm{
netIf: netIf,
objs: &edtObjects{},
hbd: make(map[string]*handleBpsDelay),
hbd: make(map[string]*handleKbpsDelay),
}

v.Lock()
Expand Down Expand Up @@ -108,15 +108,15 @@ func (e *EBPFem) Register(id orchestrator.MachineID, netIf string) error {
return nil
}

func (v *vm) getHBD(target net.IPNet) *handleBpsDelay {
func (v *vm) getHBD(target net.IPNet) *handleKbpsDelay {
hbd, ok := v.hbd[target.String()]
if ok {
return hbd
}

hbd = &handleBpsDelay{
throttleRateBps: DEFAULT_BANDWIDTH,
delayUs: DEFAULT_LATENCY_US,
hbd = &handleKbpsDelay{
throttleRateKbps: DEFAULT_BANDWIDTH_KBPS,
delayUs: DEFAULT_LATENCY_US,
}

v.hbd[target.String()] = hbd
Expand All @@ -140,7 +140,7 @@ func (e *EBPFem) SetBandwidth(source orchestrator.MachineID, target net.IPNet, b

hbd := v.getHBD(target)

hbd.throttleRateBps = uint32(bandwidth)
hbd.throttleRateKbps = uint32(bandwidth)

ips, err := parseNetToLongs(target)

Expand All @@ -150,7 +150,7 @@ func (e *EBPFem) SetBandwidth(source orchestrator.MachineID, target net.IPNet, b

for _, ip := range ips {
log.Tracef("updating bandwidth for %d to %d", ip, bandwidth)
err = v.objs.IP_HANDLE_BPS_DELAY.Put(ip, hbd)
err = v.objs.IP_HANDLE_KBPS_DELAY.Put(ip, hbd)
if err != nil {
return errors.WithStack(err)
}
Expand Down Expand Up @@ -181,7 +181,7 @@ func (e *EBPFem) SetLatency(source orchestrator.MachineID, target net.IPNet, lat

for _, ip := range ips {
log.Tracef("updating latency for %d to %d", ip, latency)
err = v.objs.IP_HANDLE_BPS_DELAY.Put(ip, hbd)
err = v.objs.IP_HANDLE_KBPS_DELAY.Put(ip, hbd)
if err != nil {
return errors.WithStack(err)
}
Expand Down Expand Up @@ -210,7 +210,7 @@ func (e *EBPFem) UnblockLink(source orchestrator.MachineID, target net.IPNet) er

for _, ip := range ips {
log.Tracef("unblocking for %d", ip)
err = v.objs.IP_HANDLE_BPS_DELAY.Put(ip, hbd)
err = v.objs.IP_HANDLE_KBPS_DELAY.Put(ip, hbd)
if err != nil {
return errors.WithStack(err)
}
Expand All @@ -237,7 +237,7 @@ func (e *EBPFem) BlockLink(source orchestrator.MachineID, target net.IPNet) erro

for _, ip := range ips {
log.Tracef("blocking for %d", ip)
err = v.objs.IP_HANDLE_BPS_DELAY.Put(ip, &handleBpsDelay{throttleRateBps: BLOCKED_BANDWIDTH, delayUs: BLOCKED_LATENCY_US})
err = v.objs.IP_HANDLE_KBPS_DELAY.Put(ip, &handleKbpsDelay{throttleRateKbps: BLOCKED_BANDWIDTH_KBPS, delayUs: BLOCKED_LATENCY_US})
if err != nil {
return errors.WithStack(err)
}
Expand Down
Binary file removed pkg/ebpfem/edt_bpfel_x86.o
Binary file not shown.
18 changes: 9 additions & 9 deletions pkg/ebpfem/edt_bpfel_x86.go → pkg/ebpfem/edt_x86_bpfel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added pkg/ebpfem/edt_x86_bpfel.o
Binary file not shown.
16 changes: 8 additions & 8 deletions pkg/ebpfem/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ import (
)

const (
DEFAULT_LATENCY_US = 0
DEFAULT_BANDWIDTH = 1_000_000_000
DEFAULT_LATENCY_US = 0
DEFAULT_BANDWIDTH_KBPS = 1_000_000

BLOCKED_LATENCY_US = 1_000_000_000
BLOCKED_BANDWIDTH = 0
BLOCKED_LATENCY_US = 1_000_000_000
BLOCKED_BANDWIDTH_KBPS = 0
)

type handleBpsDelay struct {
throttleRateBps uint32
delayUs uint32
type handleKbpsDelay struct {
throttleRateKbps uint32
delayUs uint32
}

type vm struct {
netIf string

// ebpf specific
objs *edtObjects
hbd map[string]*handleBpsDelay
hbd map[string]*handleKbpsDelay

sync.Mutex
}
Expand Down

0 comments on commit 50acd9a

Please sign in to comment.