Skip to content

Commit

Permalink
[py] Add support for CGROUP_SOCKOPT program type
Browse files Browse the repository at this point in the history
Testing: Added a new test to test_clang that loads a program of type `CGROUP_SOCKOPT`

```
16: .
16: ----------------------------------------------------------------------
16: Ran 84 tests in 83.695s
16:
16: OK (skipped=4)
16: 0
16/41 Test iovisor#16: py_test_clang ....................   Passed   84.14 sec
```
  • Loading branch information
chantra committed Jul 8, 2022
1 parent ba0af23 commit d21c85e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/python/bcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class BPFProgType:
SK_MSG = 16
RAW_TRACEPOINT = 17
CGROUP_SOCK_ADDR = 18
CGROUP_SOCKOPT = 25
TRACING = 26
LSM = 29

Expand Down
12 changes: 11 additions & 1 deletion tests/python/test_clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")

from bcc import BPF
from bcc import BPF, BPFAttachType, BPFProgType
from bcc.libbcc import lib
import ctypes as ct
from unittest import main, skipUnless, TestCase
Expand Down Expand Up @@ -55,6 +55,16 @@ def test_probe_read1(self):
b = BPF(text=text, debug=0)
fn = b.load_func("count_sched", BPF.KPROBE)

def test_load_cgroup_sockopt_prog(self):
text = """
int sockopt(struct bpf_sockopt* ctx){
return 0;
}
"""
b = BPF(text=text, debug=0)
fn = b.load_func("sockopt", BPFProgType.CGROUP_SOCKOPT, device = None, attach_type = BPFAttachType.CGROUP_SETSOCKOPT)

def test_probe_read2(self):
text = """
#include <linux/sched.h>
Expand Down

0 comments on commit d21c85e

Please sign in to comment.