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 192.168.2.210/32 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 192.168.2.210/32 up
```
And the run the script containing the following lines:
```
ipr = IPRoute()
idx = ipr.link_lookup(ifname="veth1")[0]
print idx
```

It works fine.

`

#!/usr/bin/python
# 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:
ipr.tc("add", "ingress", idx, "ffff:")
ipr.tc("add-filter", "bpf", idx, ":1", fd=fn.fd,
name=fn.name, parent="ffff:", action="ok", classid=1)

raw_input("promt: ")
finally:
ipr.tc("del", "ingress", idx)

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

`

Traceback (most recent call last):
File "./helloworld.py", 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?

Thanks,

Mauricio




_______________________________________________
iovisor-dev mailing list
iovisor-dev@...
https://lists.iovisor.org/mailman/listinfo/iovisor-dev

Join iovisor-dev@lists.iovisor.org to automatically receive all group messages.