Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add XDP_FLAGS* in python lib #3447

Merged
merged 2 commits into from
May 24, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/networking/xdp/xdp_drop_count.py
Original file line number Diff line number Diff line change
@@ -33,12 +33,12 @@ def usage():
if len(sys.argv) == 3:
if "-S" in sys.argv:
# XDP_FLAGS_SKB_MODE
flags |= (1 << 1)
flags |= BPF.XDP_FLAGS_SKB_MODE
if "-H" in sys.argv:
# XDP_FLAGS_HW_MODE
maptype = "array"
offload_device = device
flags |= (1 << 3)
flags |= BPF.XDP_FLAGS_HW_MODE

mode = BPF.XDP
#mode = BPF.SCHED_CLS
2 changes: 1 addition & 1 deletion examples/networking/xdp/xdp_macswap_count.py
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ def usage():
if len(sys.argv) == 3:
if "-S" in sys.argv:
# XDP_FLAGS_SKB_MODE
flags |= 2 << 0
flags |= BPF.XDP_FLAGS_SKB_MODE

if "-S" == sys.argv[1]:
device = sys.argv[2]
11 changes: 11 additions & 0 deletions src/python/bcc/__init__.py
Original file line number Diff line number Diff line change
@@ -171,6 +171,17 @@ class BPF(object):
XDP_TX = 3
XDP_REDIRECT = 4

# from xdp_flags uapi/linux/if_link.h
XDP_FLAGS_UPDATE_IF_NOEXIST = (1 << 0)
XDP_FLAGS_SKB_MODE = (1 << 1)
XDP_FLAGS_DRV_MODE = (1 << 2)
XDP_FLAGS_HW_MODE = (1 << 3)
XDP_FLAGS_REPLACE = (1 << 4)
XDP_FLAGS_MODES = (XDP_FLAGS_SKB_MODE | XDP_FLAGS_DRV_MODE | \
XDP_FLAGS_HW_MODE)
XDP_FLAGS_MASK = (XDP_FLAGS_UPDATE_IF_NOEXIST | XDP_FLAGS_MODES | \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XDP_FLAGS_MODES and XDP_FLAGS_MASK are mostly used by some library and kernel for sanity checks. bcc probably won't need this as user space knows exactly what to set. Could you remove them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

XDP_FLAGS_REPLACE)

# from bpf_attach_type uapi/linux/bpf.h
TRACE_FENTRY = 24
TRACE_FEXIT = 25