Question about XDP on multiple NICs with the same driver


William Tu
 

Hi,

I'm not sure if we discussed this before, but I'm thinking that if I
have two identical NICs (ex: two e1000 cards with ifindex 1 and 2),
and I load the e1000.ko driver. At userspace, I run
$ /samples/bpf/xdp 1
$ /samples/bpf/xdp 2

Then the latter XDP BPF actually overwrites the former because they
share the same driver. And there is no way to trigger different XDP
BPFs from different input ports. For example, if I want to return
XDP_DROP for packet from ifindex 1, and return XDP_PASS for packets
from ifindex 2. Am I understand correct?

Thanks
William


Alexei Starovoitov
 

On Mon, Aug 22, 2016 at 4:26 PM, William Tu via iovisor-dev
<iovisor-dev@...> wrote:
Hi,

I'm not sure if we discussed this before, but I'm thinking that if I
have two identical NICs (ex: two e1000 cards with ifindex 1 and 2),
and I load the e1000.ko driver. At userspace, I run
$ /samples/bpf/xdp 1
$ /samples/bpf/xdp 2

Then the latter XDP BPF actually overwrites the former because they
share the same driver. And there is no way to trigger different XDP
BPFs from different input ports. For example, if I want to return
XDP_DROP for packet from ifindex 1, and return XDP_PASS for packets
from ifindex 2. Am I understand correct?
why do you see it's being overwritten?
How did you test that?

two ifindex = two different netdev.
And in case of e1k:
struct e1000_adapter *adapter = netdev_priv(netdev);
adapter->prog
so we can have different programs on different netdevs
even when they're both e1k, mlx or anything else.


William Tu
 

I see, thanks!

I miss the fact that the xdp prog is attached to struct e1000_adapter
*adapter, which is different per netdev, and thus different per
ifindex.


On Mon, Aug 22, 2016 at 4:47 PM, Alexei Starovoitov
<alexei.starovoitov@...> wrote:
On Mon, Aug 22, 2016 at 4:26 PM, William Tu via iovisor-dev
<iovisor-dev@...> wrote:
Hi,

I'm not sure if we discussed this before, but I'm thinking that if I
have two identical NICs (ex: two e1000 cards with ifindex 1 and 2),
and I load the e1000.ko driver. At userspace, I run
$ /samples/bpf/xdp 1
$ /samples/bpf/xdp 2

Then the latter XDP BPF actually overwrites the former because they
share the same driver. And there is no way to trigger different XDP
BPFs from different input ports. For example, if I want to return
XDP_DROP for packet from ifindex 1, and return XDP_PASS for packets
from ifindex 2. Am I understand correct?
why do you see it's being overwritten?
How did you test that?

two ifindex = two different netdev.
And in case of e1k:
struct e1000_adapter *adapter = netdev_priv(netdev);
adapter->prog
so we can have different programs on different netdevs
even when they're both e1k, mlx or anything else.