On 5/24/24 12:40 AM, Toke Høiland-Jørgensen wrote:
I think behaviour like this is potentially quite interesting and will allow some neat optimisations (skipping a redirect to a different interface and just directly enqueueing it to a different place comes to
hmm... I am not sure it is a good/safe optimization. From looking at skb_do_redirect, there are quite a few things bypassed from __dev_queue_xmit upto the final dequeue of the redirected dev. I don't know if all of them is not dev dependent.
mind). However, as you point out it may lead to weird things like a mismatched skb->dev, so if we allow this we should make sure that the kernel will disallow (or fix) such behaviour.
Have been thinking about the skb->dev "fix" but the thought is originally for the bpf_skb_set_dev() use case in patch 14.
Note that the struct_ops ".dequeue" is actually realized by a fentry trampoline (call it fentry ".dequeue"). May be using an extra fexit ".dequeue" here. The fexit ".dequeue" will be called after the fentry ".dequeue". The fexit ".dequeue" has the function arguments (sch here that has the correct dev) and the return value (skb) from the fentry ".dequeue". This will be an extra call (to the fexit ".dequeue") and very specific to this use case but may be the less evil solution I can think of now...