Re: Is this possible to attach eBPF programs to virtual interfaces?

Yonghong Song

On Tue, Feb 6, 2018 at 8:33 AM, Mauricio Vasquez via iovisor-dev
<iovisor-dev@...> wrote:
Hello All,

I tried to load a PROG_TYPE_SCHED_CLS eBPF program and attach it to a linux
interface, netlink fails because it is not able to find the interface.

Those are the steps I did:

sudo ifconfig veth1:1 up
How veth1:1 is created? Looks like a vlan interface?
I am using a simple veth interface like below
$ sudo ip link add veth1 type veth peer name veth2
$ sudo ifconfig veth1 up
And the run the script containing the following lines:
ipr = IPRoute()
idx = ipr.link_lookup(ifname="veth1")[0]
print idx

It works fine.


# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")

from bcc import BPF
from pyroute2 import IPRoute

ipr = IPRoute()

b = BPF(src_file="helloworld.c", debug=0)
fn = b.load_func("hello", BPF.SCHED_CLS)

idx = ipr.link_lookup(ifname="veth1:1")[0]

try:"add", "ingress", idx, "ffff:")"add-filter", "bpf", idx, ":1", fd=fn.fd,, parent="ffff:", action="ok", classid=1)

raw_input("promt: ")
finally:"del", "ingress", idx)

print("BPF tc functionality - SCHED_CLS: OK")


Traceback (most recent call last):
File "./", line 13, in <module>
idx = ipr.link_lookup(ifname="veth1:1")[0]
IndexError: list index out of range


It is possible to attach eBPF programs to virtual interfaces?



iovisor-dev mailing list

Join to automatically receive all group messages.