Raw can socket close and disabling filters
Hi all,
i'm using a 3.10 kernel with rtpatch applied, with raw can features. Running some debug in the release function, i've seen something weird (for me).
In the function, we get the socket informations
and then we unregister the notifier.
After this, we test if the socket is bound and which is the ifindex.
But when the unregister function is called, there is a call to the notifier with the event NETDEV_UNREGISTER, who leads to clear the socket inforamtions like bound and ifindex.
So in the release function we can never enter in the code specific to a device.
Is there something i've missed?
Thanks in advance for your answer.
Regards
Laurent
Hi Laurent,
Quoted 7 lines · laurent vaudoit
i'm using a 3.10 kernel with rtpatch applied, with raw can features. Running some debug in the release function, i've seen something weird (for me).
In the function, we get the socket informations
and then we unregister the notifier.
Quoted 8 lines
After this, we test if the socket is bound and which is the ifindex.
But when the unregister function is called, there is a call to the notifier with the event
NETDEV_UNREGISTER, who leads to clear the socket inforamtions like bound and ifindex.So in the release function we can never enter in the code specific to a device.
The relevant removal is protected by lock_sock().
So when the notifier runs with NETDEV_UNREGISTER it will remove the filters & bind status.
In this case the block in raw_release() won't have anything to do to release the filters and the bind state, right?
Looks double work - but I wonder why we can rely on a notifier call when we call unregister_netdevice_notifier() ??
Regards,
Oliver
Hi Oliver,
Quoted 23 lines · Oliver Hartkopp
Hi Laurent,
Quoted 9 lines · laurent vaudoit
i'm using a 3.10 kernel with rtpatch applied, with raw can features. Running some debug in the release function, i've seen something weird (for me).
In the function, we get the socket informations
and then we unregister the notifier.After this, we test if the socket is bound and which is the ifindex.
Quoted 8 lines
But when the unregister function is called, there is a call to the notifier
with the eventNETDEV_UNREGISTER, who leads to clear the socket inforamtions
like bound and ifindex.So in the release function we can never enter in the code specific to a device.
Quoted 7 lines
The relevant removal is protected by
lock_sock().So when the notifier runs with
NETDEV_UNREGISTERit will remove the filters & bind status.In this case the block in
raw_release()won't have anything to do to release the filters and the bind state, right?
i agree with this. The fact is that on my setup i need to send an information to another µc when releasing a socket on a device, and so my specific code was done in the release function, after the unregister.
This is how i've seen this behaviour.
Quoted 3 lines
Looks double work - but I wonder why we can rely on a notifier call when we call
unregister_netdevice_notifier()??
For me, the disable_all_filter part of code in release can not be called, as the ro->bound will allways be 0.
Quoted 4 lines
Regards,
Oliver
Regards
Laurent
Quoted 10 lines · laurent vaudoit
Quoted 5 lines
So when the notifier runs with
NETDEV_UNREGISTERit will remove the filters & bind status.In this case the block in
raw_release()won't have anything to do to release the filters and the bind state, right?i agree with this. The fact is that on my setup i need to send an information to another µc when releasing a socket on a device, and so my specific code was done in the release function, after the unregister.
I think using raw_release() as trigger is always a good choice.
Quoted 1 line
This is how i've seen this behaviour.
Interesting information. I didn't know about the notifier running at unregister_netdevice_notifier() time.
Quoted 5 lines
Quoted 2 lines
Looks double work - but I wonder why we can rely on a notifier call when we call
unregister_netdevice_notifier()??For me, the
disable_all_filterpart of code in release can not be called, as thero->boundwill allways be 0.
The question remains whether we can really rely on the notifier call which is obviously invoked by unregister_netdevice_notifier() ... I'll have to dig if this behaviour is intentional and documented.
Until then I feel better to leave it as-is.
Regards,
Oliver
Quoted 30 lines · Oliver Hartkopp
Quoted 9 lines · laurent vaudoit
Quoted 7 lines
So when the notifier runs with
NETDEV_UNREGISTERit will remove the filters
& bind status.In this case the block in
raw_release()won't have anything to do to release
the filters and the bind state, right?Quoted 4 lines
i agree with this. The fact is that on my setup i need to send an information to another µc when releasing a socket on a device, and so my specific code was done in the release function, after the unregister.
I think using
raw_release()as trigger is always a good choice.Quoted 1 line
This is how i've seen this behaviour.
Interesting information. I didn't know about the notifier running at
unregister_netdevice_notifier()time.Quoted 5 lines
Quoted 3 lines
Looks double work - but I wonder why we can rely on a notifier call when we
callunregister_netdevice_notifier()??
Quoted 9 lines
Quoted 2 lines
For me, the
disable_all_filterpart of code in release can not be called, as thero->boundwill allways be 0.The question remains whether we can really rely on the notifier call which is obviously invoked by
unregister_netdevice_notifier()... I'll have to dig if this behaviour is intentional and documented. Until then I feel better to leave it as-is.
Ok, i will adapt my specific code, as i know this is not a weird behaviour due to rtpatch or to my specificity.
Thanks
Quoted 2 lines
Regards,
Oliver
Regards
Laurent