Skip to content

Commit

Permalink
patch BPF_PSEUDO_FUNC define
Browse files Browse the repository at this point in the history
  • Loading branch information
piax93 committed Nov 16, 2022
1 parent cdad9b7 commit 82d74a7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pidtree_bcc/probes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from typing import Any
from typing import Mapping

from bcc import __version__ as bccversion
from bcc import BPF
from jinja2 import Environment
from jinja2 import FileSystemLoader
Expand Down Expand Up @@ -142,7 +143,8 @@ def _has_buggy_headers(self) -> bool:
"""
kernel_version = platform.uname().release
kmajor, kminor = map(int, kernel_version.split('.', 2)[:2])
return (kmajor == 5 and kminor >= 15) or kmajor > 5
_, bccminor, _ = map(int, bccversion.split('.'))
return bccminor < 23 and ((kmajor == 5 and kminor >= 15) or kmajor > 5)

def _process_events(self, cpu: Any, data: Any, size: Any, from_bpf: bool = True):
""" BPF event callback
Expand Down
2 changes: 2 additions & 0 deletions pidtree_bcc/probes/utils.j2
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,7 @@ enum {
BPF_F_BROADCAST = (1ULL << 3),
BPF_F_EXCLUDE_INGRESS = (1ULL << 4),
};
// Missing header value in bcc <0.19.0 (Ubuntu Jammy comes with 0.18.0)
#define BPF_PSEUDO_FUNC 4
{%- endif %}
{%- endmacro %}
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

# Globally mock bcc module
bcc = MagicMock()
bcc.__version__ = '0.18.0'
sys.modules.setdefault('bcc', bcc)

0 comments on commit 82d74a7

Please sign in to comment.