diff mbox

[v2] Implement IP_UNICAST_IF socket option.

Message ID 1328263278.2157.5.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet Feb. 3, 2012, 10:01 a.m. UTC
Le jeudi 02 février 2012 à 18:22 -0700, Erich E. Hoover a écrit :

> I though I should double check this, and apparently I missed that
> there's an equivalent IPV6_UNICAST_IF on "other OS".  Should that be a
> patch 2 or should it be included in this one?

Do as you prefer.

BTW, do we really want the htonl() thing, and force device indexes in
2^24 range ? This seems odd anyway.

If yes, following patch is needed :



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Erich E. Hoover Feb. 3, 2012, 3:21 p.m. UTC | #1
On Fri, Feb 3, 2012 at 3:01 AM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> ...
> BTW, do we really want the htonl() thing, and force device indexes in
> 2^24 range ? This seems odd anyway.
> ...

I can easily perform both of these steps in Wine.  The 2^24 limitation
in particular seems artificial, and especially silly to add to the
kernel if it will change the fundamental range of the indices.  With
regard to htonl(), David Miller indicated that the API should match
what other systems use (a 32-bit network byte order word), though he
may not have meant his comment that specifically.  I can see the
merits of doing it both ways and I'm not particularly attached to
either one.

Erich Hoover
ehoover@mines.edu
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eric Dumazet Feb. 3, 2012, 3:43 p.m. UTC | #2
Le vendredi 03 février 2012 à 08:21 -0700, Erich E. Hoover a écrit :
> On Fri, Feb 3, 2012 at 3:01 AM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > ...
> > BTW, do we really want the htonl() thing, and force device indexes in
> > 2^24 range ? This seems odd anyway.
> > ...
> 
> I can easily perform both of these steps in Wine.  The 2^24 limitation
> in particular seems artificial, and especially silly to add to the
> kernel if it will change the fundamental range of the indices.  With
> regard to htonl(), David Miller indicated that the API should match
> what other systems use (a 32-bit network byte order word), though he
> may not have meant his comment that specifically.  I can see the
> merits of doing it both ways and I'm not particularly attached to
> either one.

I have no strong feeling, I only wanted to point out our current device
indexes range is [1 .. (2^31 - 1) ]



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/core/dev.c b/net/core/dev.c
index f124947..ce7ebde 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5193,7 +5193,10 @@  static int dev_new_index(struct net *net)
 {
 	static int ifindex;
 	for (;;) {
-		if (++ifindex <= 0)
+		/* Because of IP_UNICAST_IF support, we must limit indexes
+		 * to 24 bits. Zero value is also reserved.
+		 */
+		if (++ifindex >= (1<<24))
 			ifindex = 1;
 		if (!__dev_get_by_index(net, ifindex))
 			return ifindex;