netdev
[Top] [All Lists]

[PATCH] Make SO_BINDTODEVICE bind very tightly

To: netdev@xxxxxxxxxxx
Subject: [PATCH] Make SO_BINDTODEVICE bind very tightly
From: Casey Carter <Casey@xxxxxxxxxx>
Date: Tue, 07 Oct 2003 17:16:25 -0500
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5b) Gecko/20030903 Thunderbird/0.2
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().

--
Casey Carter
Casey@xxxxxxxxxx
ccarter@xxxxxxxxxxx
AIM: cartec69

--- linux-2.6.0-test6/net/ipv4/udp.c    2003-09-27 19:50:10.000000000 -0500
+++ linux-2.6.0-test6-patch/net/ipv4/udp.c      2003-10-07 17:08:10.000000000 
-0500
@@ -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) {
<Prev in Thread] Current Thread [Next in Thread>