Make SO_BINDTODEVICE bind very tightly
Subsystems (3)
PATCH 1/1 Make SO_BINDTODEVICE bind very tightly
In the presence of both sockets that are and sockets that are not bound to a specific interface, those bound to the interface should always be favored for packet delivery over those not so bound. Attached patch (against 2.6.0-test6) enforces these semantics by a slight adjustment to udp_v4_lookup_longway in net/ipv4/udp.c The consequence of this change is to make SO_BINDTODEVICE bind more tightly than simple bind().
Signature · 4 lines
Casey Carter [email protected] [email protected] AIM: cartec69
net/ipv4/udp.c +2 -2
@@ -246,9 +246,9 @@if (sk->sk_bound_dev_if) {if (sk->sk_bound_dev_if != dif)continue ; - score+=2 ; + score+=8 ; } -if (score ==9 ) { +if (score ==15 ) { result = sk;break ; }else if (score > badness) {
Quoted 3 lines · On Tue, 07 Oct 2003 17:16:25 -0500 Casey Carter <[email protected]> wrote:
In the presence of both sockets that are and sockets that are not bound to a specific interface, those bound to the interface should always be favored for packet delivery over those not so bound.
No, the fix made in the original posting of this thread is the correct one. One may not have some sockets with SO_BINDTODEVICE and some with not bound at the same time to the same identity. Therefore the fix should be a bind() time.