0

Lets assume below given is the set of net devices that my frame is intended to traverse over.

eth0(1) -> bond0(2) -> bridge(3) -> vlan100(4). >>> (number) is the ifindex for each netdevice

I have created a RAW socket ( not binded to any interface) , attached with a socket filter to trap only a specific set of packets.

I am getting a copy of frame trapped from each of the netdevice. Is this expected?

Printing from.sll_ifindex for each trapped packet.

frame trapped from eth0 has from.sll_ifindex=1 
frame trapped from bond0 has from.sll_ifindex=2 
frame trapped from bridge has from.sll_ifindex=3 
frame trapped from vlan100 has from.sll_ifindex=4

Now I set the following socket option PACKET_ORIGDEV , I get the following result

frame trapped from eth0 has from.sll_ifindex=1
frame trapped from bond0 has from.sll_ifindex=1   >> acceptable since the originating device is eth0 whose ifindex is 1.
frame trapped from bridge has from.sll_ifindex=3  >> why is this not set to 1?
frame trapped from vlan100 has from.sll_ifindex=3 >> why is this not set to 1?

can someone help me understand the role played by PACKET_ORIGDEV socket option in the above scenario.

0

The way that the frame transitions from bond0 to bridge inside the kernel is different from the other two transitions. Instead of looping around for another_round inside __netif_receive_skb_core(), the frame is forwarded inside br_handle_frame_finish(). The orig_dev information is not preserved by that call path. I think the input port is recorded only long enough to make it available to some netfilter hooks of the bridge family. It's not available to user space.

PACKET_ORIGDEV, when it was introduced, was meant to cover encapsulation cases. It could be argued that it should work for bridging too but it doesn't look to me like a change that can be implemented lightly. Some of the involved functions are hot in the receive path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.