Rename python module name to 'bcc' from 'bpf'
* Rename python module to bcc
* Rename python-bpf (deb,rpm) package to python-bcc
* Pending this change, I will likely re-tag 0.1.6, and upload the bcc
package to pypi.python.org
Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
diff --git a/README.md b/README.md
index 6345134..3eb9ce5 100644
--- a/README.md
+++ b/README.md
@@ -55,7 +55,7 @@
First, we should include the BPF class from the bpf module:
```python
-from bpf import BPF
+from bcc import BPF
```
Since the C code is so short, we will embed it inside the python script.
@@ -158,7 +158,7 @@
to the stats BPF map. The python program could use that handle to modify the
kernel table as well.
```python
-from bpf import BPF
+from bcc import BPF
from time import sleep
b = BPF(src_file="task_switch.c")
diff --git a/SPECS/bcc.el6.spec.in b/SPECS/bcc.el6.spec.in
index f37a57b..3c4df2b 100644
--- a/SPECS/bcc.el6.spec.in
+++ b/SPECS/bcc.el6.spec.in
@@ -96,15 +96,14 @@
%description -n libbcc-examples
Examples for BPF Compiler Collection (BCC)
-%package -n python-bpf
+%package -n python-bcc
Summary: Python bindings for BPF Compiler Collection (BCC)
-%description -n python-bpf
+%description -n python-bcc
Python bindings for BPF Compiler Collection (BCC)
-%files -n python-bpf
-%{python_sitelib}/bpf*
+%files -n python-bcc
+%{python_sitelib}/bcc*
%exclude %{python_sitelib}/*.egg-info
-/usr/bin/bpf-run
%files -n libbcc
/usr/lib64/*
diff --git a/SPECS/bcc.el7.spec.in b/SPECS/bcc.el7.spec.in
index fa173d4..c3c0dfe 100644
--- a/SPECS/bcc.el7.spec.in
+++ b/SPECS/bcc.el7.spec.in
@@ -65,15 +65,14 @@
%description -n libbcc-examples
Examples for BPF Compiler Collection (BCC)
-%package -n python-bpf
+%package -n python-bcc
Summary: Python bindings for BPF Compiler Collection (BCC)
-%description -n python-bpf
+%description -n python-bcc
Python bindings for BPF Compiler Collection (BCC)
-%files -n python-bpf
-%{python_sitelib}/bpf*
+%files -n python-bcc
+%{python_sitelib}/bcc*
%exclude %{python_sitelib}/*.egg-info
-/usr/bin/bpf-run
%files -n libbcc
/usr/lib64/*
diff --git a/SPECS/bcc.f22.spec.in b/SPECS/bcc.f22.spec.in
index fa173d4..c3c0dfe 100644
--- a/SPECS/bcc.f22.spec.in
+++ b/SPECS/bcc.f22.spec.in
@@ -65,15 +65,14 @@
%description -n libbcc-examples
Examples for BPF Compiler Collection (BCC)
-%package -n python-bpf
+%package -n python-bcc
Summary: Python bindings for BPF Compiler Collection (BCC)
-%description -n python-bpf
+%description -n python-bcc
Python bindings for BPF Compiler Collection (BCC)
-%files -n python-bpf
-%{python_sitelib}/bpf*
+%files -n python-bcc
+%{python_sitelib}/bcc*
%exclude %{python_sitelib}/*.egg-info
-/usr/bin/bpf-run
%files -n libbcc
/usr/lib64/*
diff --git a/debian/control b/debian/control
index b94e0d4..40bfe6b 100644
--- a/debian/control
+++ b/debian/control
@@ -18,7 +18,7 @@
Depends: libbcc
Description: Shared Library for BPF Compiler Collection (BCC)
-Package: python-bpf
+Package: python-bcc
Architecture: all
Depends: libbcc, python
Description: Python wrappers for BPF Compiler Collection (BCC)
diff --git a/examples/bitehist.py b/examples/bitehist.py
index eb0518a..9bcfb5d 100755
--- a/examples/bitehist.py
+++ b/examples/bitehist.py
@@ -15,7 +15,7 @@
#
# 15-Aug-2015 Brendan Gregg Created this.
-from bpf import BPF
+from bcc import BPF
from ctypes import c_ushort, c_int, c_ulonglong
from time import sleep
from sys import argv
diff --git a/examples/disksnoop.py b/examples/disksnoop.py
index f65e524..c73bab9 100755
--- a/examples/disksnoop.py
+++ b/examples/disksnoop.py
@@ -11,7 +11,7 @@
# 11-Aug-2015 Brendan Gregg Created this.
from __future__ import print_function
-from bpf import BPF
+from bcc import BPF
import sys
REQ_WRITE = 1 # from include/linux/blk_types.h
diff --git a/examples/distributed_bridge/tunnel.py b/examples/distributed_bridge/tunnel.py
index 84dfaab..06ebbf1 100755
--- a/examples/distributed_bridge/tunnel.py
+++ b/examples/distributed_bridge/tunnel.py
@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License")
from sys import argv
-from bpf import BPF
+from bcc import BPF
from builtins import input
from ctypes import c_int, c_uint
from http.server import HTTPServer, SimpleHTTPRequestHandler
diff --git a/examples/distributed_bridge/tunnel_mesh.py b/examples/distributed_bridge/tunnel_mesh.py
index 64700a1..ad5c5c6 100644
--- a/examples/distributed_bridge/tunnel_mesh.py
+++ b/examples/distributed_bridge/tunnel_mesh.py
@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License")
from sys import argv
-from bpf import BPF
+from bcc import BPF
from builtins import input
from ctypes import c_int, c_uint
from http.server import HTTPServer, SimpleHTTPRequestHandler
diff --git a/examples/hello_world.py b/examples/hello_world.py
index 2ad21c6..77b2c2b 100755
--- a/examples/hello_world.py
+++ b/examples/hello_world.py
@@ -5,7 +5,7 @@
# run in project examples directory with:
# sudo ./hello_world.py"
-from bpf import BPF
+from bcc import BPF
prog = """
int hello(void *ctx) {
diff --git a/examples/simple_tc.py b/examples/simple_tc.py
index f0258e5..4dd8aa5 100755
--- a/examples/simple_tc.py
+++ b/examples/simple_tc.py
@@ -2,7 +2,7 @@
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
-from bpf import BPF
+from bcc import BPF
from pyroute2 import IPRoute
ipr = IPRoute()
diff --git a/examples/task_switch.py b/examples/task_switch.py
index c42d637..43a4f3f 100755
--- a/examples/task_switch.py
+++ b/examples/task_switch.py
@@ -2,7 +2,7 @@
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
-from bpf import BPF
+from bcc import BPF
from time import sleep
b = BPF(src_file="task_switch.c")
diff --git a/examples/tc_neighbor_sharing.py b/examples/tc_neighbor_sharing.py
index da2877c..f2ec8a8 100755
--- a/examples/tc_neighbor_sharing.py
+++ b/examples/tc_neighbor_sharing.py
@@ -25,7 +25,7 @@
# pass() |
-from bpf import BPF
+from bcc import BPF
from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
from simulation import Simulation
import sys
diff --git a/examples/tunnel_monitor/monitor.py b/examples/tunnel_monitor/monitor.py
index 057d6c4..bac3420 100644
--- a/examples/tunnel_monitor/monitor.py
+++ b/examples/tunnel_monitor/monitor.py
@@ -2,7 +2,7 @@
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
-from bpf import BPF
+from bcc import BPF
from ctypes import c_uint, c_int, c_ulonglong, Structure
import json
from netaddr import IPAddress
diff --git a/examples/vfsreadlat.py b/examples/vfsreadlat.py
index 6c61c22..784b609 100755
--- a/examples/vfsreadlat.py
+++ b/examples/vfsreadlat.py
@@ -15,7 +15,7 @@
#
# 15-Aug-2015 Brendan Gregg Created this.
-from bpf import BPF
+from bcc import BPF
from ctypes import c_ushort, c_int, c_ulonglong
from time import sleep
from sys import argv
diff --git a/examples/vlan_learning.py b/examples/vlan_learning.py
index a9bef11..200062f 100644
--- a/examples/vlan_learning.py
+++ b/examples/vlan_learning.py
@@ -23,7 +23,7 @@
# phys | veth |
# switch | |
-from bpf import BPF
+from bcc import BPF
from builtins import input
from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
from random import shuffle
diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt
index 0e04764..9f76137 100644
--- a/src/python/CMakeLists.txt
+++ b/src/python/CMakeLists.txt
@@ -5,18 +5,17 @@
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC} ${DST})
endmacro()
-symlink_file(${CMAKE_CURRENT_SOURCE_DIR}/bpf ${CMAKE_CURRENT_BINARY_DIR}/bpf)
-symlink_file(${CMAKE_CURRENT_SOURCE_DIR}/bpf-run ${CMAKE_CURRENT_BINARY_DIR}/bpf-run)
+symlink_file(${CMAKE_CURRENT_SOURCE_DIR}/bcc ${CMAKE_CURRENT_BINARY_DIR}/bcc)
-set(PIP_INSTALLABLE "${CMAKE_CURRENT_BINARY_DIR}/dist/bpf-${REVISION}.tar.gz")
+set(PIP_INSTALLABLE "${CMAKE_CURRENT_BINARY_DIR}/dist/bcc-${REVISION}.tar.gz")
configure_file(setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py @ONLY)
# build the pip installable
add_custom_command(OUTPUT ${PIP_INSTALLABLE}
COMMAND python setup.py sdist
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bpf/__init__.py ${CMAKE_CURRENT_BINARY_DIR}/setup.py
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bcc/__init__.py ${CMAKE_CURRENT_BINARY_DIR}/setup.py
)
-add_custom_target(bpf_py ALL DEPENDS ${PIP_INSTALLABLE})
+add_custom_target(bcc_py ALL DEPENDS ${PIP_INSTALLABLE})
if(EXISTS "/etc/debian_version")
set(PYTHON_FLAGS "${PYTHON_FLAGS} --install-layout deb")
diff --git a/src/python/MANIFEST b/src/python/MANIFEST
index 79f8a31..e72a537 100644
--- a/src/python/MANIFEST
+++ b/src/python/MANIFEST
@@ -1,4 +1,3 @@
# file GENERATED by distutils, do NOT edit
setup.py
-bpf/__init__.py
-bpf-run
+bcc/__init__.py
diff --git a/src/python/bpf/__init__.py b/src/python/bcc/__init__.py
similarity index 100%
rename from src/python/bpf/__init__.py
rename to src/python/bcc/__init__.py
diff --git a/src/python/bpf-run b/src/python/bpf-run
deleted file mode 100755
index b97cdb7..0000000
--- a/src/python/bpf-run
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-
-USAGE = """\
-usage: {argv0} <opts> -p probe_func -c cmd
- -c cmd contents of the program to run, omitting prototype (required)
- -d name dump table <name> upon exit
- -f format format string to apply to trace output (see python str.format())
- -n sec run for <sec> seconds and then exit (default=-1)
- -p probe kernel entry point to trace (required)
- -t attach to kernel trace output
- -v increase verbosity
-example:
- {argv0} -p sys_clone -c 'bpf_trace_printk("Hello, World!\\n");' -t\
-"""
-
-wrapper = """
-int run(void *ctx) {
- %s
- return 0;
-}
-"""
-
-def print_usage_and_exit(rc, msg=None):
- if rc != 0:
- sys.stdout = sys.stderr
- if msg:
- print(msg)
- print(USAGE.format(argv0=sys.argv[0]))
- sys.exit(rc)
-
-def main():
- import getopt
- import os
- import signal
-
- try:
- opts, args = getopt.getopt(sys.argv[1:], "c:d:f:hn:p:tv")
- except getopt.error, msg:
- print_usage_and_exit(2, msg)
-
- runcmd = None
- probe_fn = None
- trace = 0
- dump_tables = []
- verbose = 0
- nsec = 0
- format_str = None
-
- for o, a in opts:
- if o == "-c": runcmd = a
- if o == "-d": dump_tables.append(a)
- if o == "-f": format_str = a
- if o == "-h": print_usage_and_exit(0)
- if o == "-n": nsec = int(a)
- if o == "-p": probe_fn = a
- if o == "-t": trace = 1
- if o == "-v": verbose += 1
-
- if not runcmd or not probe_fn:
- print_usage_and_exit(2, "Error: -p and -c arguments are required")
-
- from bpf import BPF
-
- b = BPF(text=wrapper % runcmd, debug=verbose)
- fn = b.load_func("run", BPF.KPROBE)
- BPF.attach_kprobe(fn, probe_fn)
-
- if nsec:
- def receive_alarm(signo, stack):
- os.kill(os.getpid(), signal.SIGINT)
- signal.signal(signal.SIGALRM, receive_alarm)
- signal.alarm(nsec)
-
- try:
- if trace:
- with open("/sys/kernel/debug/tracing/trace_pipe") as f:
- while True:
- line = f.readline(128)
- line = line.rstrip()
- if format_str:
- args=line.split(None, 5)
- line = format_str.format(*args)
- print(line)
- sys.stdout.flush()
- elif nsec:
- signal.pause()
- except KeyboardInterrupt:
- pass
-
- if dump_tables:
- print("Table dump not yet implemented")
-
-if __name__ == "__main__":
- main()
diff --git a/src/python/setup.py.in b/src/python/setup.py.in
index 40afa05..8e05d4f 100644
--- a/src/python/setup.py.in
+++ b/src/python/setup.py.in
@@ -7,12 +7,11 @@
if os.environ.get('DESTDIR'):
sys.argv += ['--root', os.environ['DESTDIR']]
-setup(name='bpf',
+setup(name='bcc',
version='@REVISION@',
description='BPF Loader Library',
author='Brenden Blanco',
author_email='bblanco@plumgrid.com',
- url='http://plumgrid.com',
- packages=['bpf'],
- scripts=['bpf-run'],
+ url='https://github.com/iovisor/bcc',
+ packages=['bcc'],
platforms=['Linux'])
diff --git a/tests/cc/test_brb.py b/tests/cc/test_brb.py
index 8362286..005158d 100755
--- a/tests/cc/test_brb.py
+++ b/tests/cc/test_brb.py
@@ -63,7 +63,7 @@
from ctypes import c_uint
from netaddr import IPAddress, EUI
-from bpf import BPF
+from bcc import BPF
from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
import sys
from time import sleep
diff --git a/tests/cc/test_brb2.py b/tests/cc/test_brb2.py
index 69ce604..e4d3b20 100755
--- a/tests/cc/test_brb2.py
+++ b/tests/cc/test_brb2.py
@@ -55,7 +55,7 @@
# 9: OK
from ctypes import c_uint
-from bpf import BPF
+from bcc import BPF
from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
import sys
from time import sleep
diff --git a/tests/cc/test_call1.py b/tests/cc/test_call1.py
index eea364a..68d68de 100755
--- a/tests/cc/test_call1.py
+++ b/tests/cc/test_call1.py
@@ -4,7 +4,7 @@
from ctypes import c_ushort, c_int, c_ulonglong
from netaddr import IPAddress
-from bpf import BPF
+from bcc import BPF
from pyroute2 import IPRoute
from socket import socket, AF_INET, SOCK_DGRAM
import sys
diff --git a/tests/cc/test_clang.py b/tests/cc/test_clang.py
index b41e408..276f5eb 100755
--- a/tests/cc/test_clang.py
+++ b/tests/cc/test_clang.py
@@ -2,7 +2,7 @@
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
-from bpf import BPF
+from bcc import BPF
from unittest import main, TestCase
class TestClang(TestCase):
diff --git a/tests/cc/test_stat1.py b/tests/cc/test_stat1.py
index 7e9415f..98ff756 100755
--- a/tests/cc/test_stat1.py
+++ b/tests/cc/test_stat1.py
@@ -7,7 +7,7 @@
from ctypes import c_uint, c_ulong, Structure
from netaddr import IPAddress
-from bpf import BPF
+from bcc import BPF
from subprocess import check_call
import sys
from unittest import main, TestCase
diff --git a/tests/cc/test_trace1.py b/tests/cc/test_trace1.py
index a009bb6..685c946 100755
--- a/tests/cc/test_trace1.py
+++ b/tests/cc/test_trace1.py
@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License")
from ctypes import c_uint, c_ulong, Structure
-from bpf import BPF
+from bcc import BPF
import os
from time import sleep
import sys
diff --git a/tests/cc/test_trace2.py b/tests/cc/test_trace2.py
index dbd06e2..3d38d02 100755
--- a/tests/cc/test_trace2.py
+++ b/tests/cc/test_trace2.py
@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License")
from ctypes import c_uint, c_ulong, Structure
-from bpf import BPF
+from bcc import BPF
from time import sleep
import sys
from unittest import main, TestCase
diff --git a/tests/cc/test_trace3.py b/tests/cc/test_trace3.py
index 2f05f3a..d14b089 100755
--- a/tests/cc/test_trace3.py
+++ b/tests/cc/test_trace3.py
@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License")
from ctypes import c_uint, c_ulong, Structure
-from bpf import BPF
+from bcc import BPF
from time import sleep
import sys
from unittest import main, TestCase
diff --git a/tests/cc/test_trace4.py b/tests/cc/test_trace4.py
index 2cb94c0..bcfbfda 100755
--- a/tests/cc/test_trace4.py
+++ b/tests/cc/test_trace4.py
@@ -2,7 +2,7 @@
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
-from bpf import BPF
+from bcc import BPF
import os
import sys
from unittest import main, TestCase
diff --git a/tests/cc/test_xlate1.py b/tests/cc/test_xlate1.py
index a5f3fa8..4e1eb78 100755
--- a/tests/cc/test_xlate1.py
+++ b/tests/cc/test_xlate1.py
@@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License")
from netaddr import IPAddress
-from bpf import BPF
+from bcc import BPF
from pyroute2 import IPRoute
from socket import socket, AF_INET, SOCK_DGRAM
from subprocess import call
diff --git a/tools/pidpersec b/tools/pidpersec
index 75ceaa7..7e23fbb 100755
--- a/tools/pidpersec
+++ b/tools/pidpersec
@@ -13,7 +13,7 @@
#
# 11-Aug-2015 Brendan Gregg Created this.
-from bpf import BPF
+from bcc import BPF
from ctypes import c_ushort, c_int, c_ulonglong
from time import sleep, strftime
diff --git a/tools/syncsnoop b/tools/syncsnoop
index 869ca7d..4df1931 100755
--- a/tools/syncsnoop
+++ b/tools/syncsnoop
@@ -12,7 +12,7 @@
# 13-Aug-2015 Brendan Gregg Created this.
from __future__ import print_function
-from bpf import BPF
+from bcc import BPF
import sys
# load BPF program
diff --git a/tools/vfscount b/tools/vfscount
index 70f2f3a..9d06d7e 100755
--- a/tools/vfscount
+++ b/tools/vfscount
@@ -11,7 +11,7 @@
# 14-Aug-2015 Brendan Gregg Created this.
from __future__ import print_function
-from bpf import BPF
+from bcc import BPF
from ctypes import c_ushort, c_int, c_ulonglong
from time import sleep, strftime
from sys import stderr
diff --git a/tools/vfsstat b/tools/vfsstat
index d074faf..5925516 100755
--- a/tools/vfsstat
+++ b/tools/vfsstat
@@ -13,7 +13,7 @@
# 14-Aug-2015 Brendan Gregg Created this.
from __future__ import print_function
-from bpf import BPF
+from bcc import BPF
from ctypes import c_ushort, c_int, c_ulonglong
from time import sleep, strftime
from sys import argv