If the kernel decides to change the interface index for some reason, our userspace code cached interface index does not gets updated and it starts dropping the packet because their is mismatch between interface index cached in userspace and what is actually present in kernel.
I've used if_indextoname(index, interfaceName) to solve this problem. Basically kernel knows which index maps to correct interface name.
Now comes my requirement: I need to test my code. Is there a way by which I can simulate index change so that I can verify my code? I have a gut feeling that since index is something which is very much particular to kernel thus it can only be accessed by calls(if_nametoindex()/etc.) but we can't change it. So how do I validate my changeset?