[PATCH 02/05] ipv6: RFC4214 Support (4)

2007-11-12 Thread osprey67

From: Fred L. Templin [EMAIL PROTECTED]

This is experimental support for the Intra-Site Automatic
Tunnel Addressing Protocol (ISATAP) per RFC4214. It uses
the SIT module, and is configured using the unmodified
ip utility with device names beginning with: isatap.

The following diffs are specific to the Linux 2.6.24-rc2
kernel distribution.

Signed-off-by: Fred L. Templin [EMAIL PROTECTED]

---

--- linux-2.6.24-rc2/net/ipv6/Kconfig.orig  2007-11-08 12:07:17.0 
-0800
+++ linux-2.6.24-rc2/net/ipv6/Kconfig   2007-11-08 08:27:48.0 -0800
@@ -57,6 +57,17 @@ config IPV6_ROUTE_INFO

  If unsure, say N.

+config IPV6_ISATAP
+   bool IPv6: ISATAP (RFC 4214) support (EXPERIMENTAL)
+   depends on IPV6  EXPERIMENTAL
+   ---help---
+ This is experimental support for the Intra-Site Automatic
+ Tunnel Addressing Protocol (ISATAP) per RFC4214. It uses
+ the SIT module, and is configured using the ip utility
+ with device names beginning with: isatap.
+
+ If unsure, say N.
+
 config IPV6_OPTIMISTIC_DAD
bool IPv6: Enable RFC 4429 Optimistic DAD (EXPERIMENTAL)
depends on IPV6  EXPERIMENTAL

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


[Resend] [PATCH 02/05] ipv6: RFC4214 Support (4)

2007-11-12 Thread Templin, Fred L
 

-Original Message-
From: osprey67 [mailto:[EMAIL PROTECTED] 
Sent: Monday, November 12, 2007 7:55 AM
To: netdev@vger.kernel.org
Subject: [PATCH 02/05] ipv6: RFC4214 Support (4)

From: Fred L. Templin [EMAIL PROTECTED]

This is experimental support for the Intra-Site Automatic
Tunnel Addressing Protocol (ISATAP) per RFC4214. It uses
the SIT module, and is configured using the unmodified
ip utility with device names beginning with: isatap.

The following diffs are specific to the Linux 2.6.24-rc2
kernel distribution.

Signed-off-by: Fred L. Templin [EMAIL PROTECTED]

---

--- linux-2.6.24-rc2/net/ipv6/Kconfig.orig  2007-11-08 12:07:17.0 
-0800
+++ linux-2.6.24-rc2/net/ipv6/Kconfig   2007-11-08 08:27:48.0 -0800
@@ -57,6 +57,17 @@ config IPV6_ROUTE_INFO

   If unsure, say N.

+config IPV6_ISATAP
+   bool IPv6: ISATAP (RFC 4214) support (EXPERIMENTAL)
+   depends on IPV6  EXPERIMENTAL
+   ---help---
+ This is experimental support for the Intra-Site Automatic
+ Tunnel Addressing Protocol (ISATAP) per RFC4214. It uses
+ the SIT module, and is configured using the ip utility
+ with device names beginning with: isatap.
+
+ If unsure, say N.
+
  config IPV6_OPTIMISTIC_DAD
 bool IPv6: Enable RFC 4429 Optimistic DAD (EXPERIMENTAL)
 depends on IPV6  EXPERIMENTAL

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


Re: [PATCH 02/05] ipv6: RFC4214 Support (2)

2007-11-09 Thread osprey67

YOSHIFUJI Hideaki / 吉藤英明 wrote:

In article [EMAIL PROTECTED] (at Thu, 08 Nov 2007 12:41:39 -0800), osprey67 
[EMAIL PROTECTED] says:


From: Fred L. Templin [EMAIL PROTECTED]

This is experimental support for the Intra-Site Automatic
Tunnel Addressing Protocol (ISATAP) per RFC4214. It uses
the SIT module, and is configured using the unmodified
ip utility with device names beginning with: isatap.

The following diffs are specific to the Linux 2.6.24-rc2
kernel distribution.

Signed-off-by: Fred L. Templin [EMAIL PROTECTED]


Hmm...tabs are still mangled, and it's better to have your
official address.  Anyway...


I have switched over to Thunderbird and POP mail. I submitted
the patches by cutting and pasting from a text file into the
mail message. Is there a way to stop it from clobbering tabs?


--- linux-2.6.24-rc2/include/net/addrconf.h.orig2007-11-08 
12:06:17.0 -0800
+++ linux-2.6.24-rc2/include/net/addrconf.h 2007-11-08 08:27:24.0 
-0800
@@ -241,6 +241,37 @@ static inline int ipv6_addr_is_ll_all_ro
 addr-s6_addr32[3] == htonl(0x0002));
  }

+#if defined(CONFIG_IPV6_ISATAP)
+static inline int ipv6_isatap_eui64(u8 *eui, __be32 addr)
+{
+
+   /* RFC3330 Special-Use IPv4 Addresses */
+   eui[0] = (((addr  htonl(0xFF00)) == htonl(0x)) ||
+ ((addr  htonl(0xFF00)) == htonl(0x0A00)) ||
+ ((addr  htonl(0xFF00)) == htonl(0x0D00)) ||
+ ((addr  htonl(0xFF00)) == htonl(0x1800)) ||
+ ((addr  htonl(0xFF00)) == htonl(0x7F00)) ||
+ ((addr  htonl(0x)) == htonl(0xA9FE)) ||
+ ((addr  htonl(0xFFF0)) == htonl(0xAC10)) ||
+ ((addr  htonl(0xFF00)) == htonl(0xC200)) ||
+ ((addr  htonl(0xFF00)) == htonl(0xC0586300)) ||
+ ((addr  htonl(0x)) == htonl(0xC0A8)) ||
+ ((addr  htonl(0xFFFE)) == htonl(0xC612)) ||
+ ((addr  htonl(0xF000)) == htonl(0xE000)) ||
+ ((addr  htonl(0xF000)) == htonl(0xF000))) ?
+   0x00 : 0x02;
+
+   eui[1] = 0; eui[2] = 0x5E; eui[3] = 0xFE;
+   memcpy (eui+4, addr, 4);
+   return 0;
+}
+


Please put this function in net/ipv6/addrconf.c as addrconf_ifid_isatap().

Please use MULTICAST, LOCALNET etc. (and probaly introduce new macro
for others).  IMHO, it's better to add a comment for each entry, e.g.,
MULTICAST(addr) ||  /* 224.0.0.0/4 */
instead of
((addr  htonl(0xF000)) == htonl(0xE000)) ||


OK - will do.


+static inline int ipv6_addr_is_isatap(const struct in6_addr *addr)
+{
+   return ((addr-s6_addr32[2] | htonl(0x0200)) == htonl(0x02005EFE));
+}
+#endif
+


ipv6_addr_isatap(), maybe (to align with ipv6_addr_any() etc.).


Well, if you look in addrconf.h immediately above this the convention
seems to be to call it as *_is_* if it is testing an address and
to omit the *_is_* if it is setting an address. Since this is an
address test, maybe more consistent to keep the *_is_*?

Thanks - Fred
[EMAIL PROTECTED]



--yoshfuji



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


Re: [PATCH 02/05] ipv6: RFC4214 Support

2007-11-09 Thread Ingo Oeser
YOSHIFUJI Hideaki / 吉藤英明 schrieb:
 In article [EMAIL PROTECTED] (at Wed, 7 Nov 2007 10:52:47 -0800), Templin, 
 Fred L [EMAIL PROTECTED] says:
 
   + if (((ipv4 = 0x0100)  (ipv4  0x0a00)) ||
   + ((ipv4 = 0x0b00)  (ipv4  0x7f00)) ||
   + ((ipv4 = 0x8000)  (ipv4  0xa9fe)) ||
   + ((ipv4 = 0xa9ff)  (ipv4  0xac10)) ||
   + ((ipv4 = 0xac20)  (ipv4  0xc0a8)) ||
   + ((ipv4 = 0xc0a9)  (ipv4  0xc612)) ||
   + ((ipv4 = 0xc614)  (ipv4  
   0xe000))) eui[0] |=
   0x2;
 
  Maybe it is I who did not understand. Can you suggest a clean solution?
 
 You could write each element as LOOPBACK(), MULTICAST()
 etc.
   eui[0] = (!ZERONETO(a) 
 !PRIVATE_10(a) 
 !LINKLOCAL(a) 
 !PRIVATE_172(a) 
 !PRIVATE_192(a) 
 !NETICDEVBENCH(a) 
 !MULTICAST(a)) ? 2 : 0;

Oh, yes that's great! Now even *I* can read what this is all about 
without reading any RFC :-)

Please Fred, try to do it that way.


Best Regards

Ingo Oeser
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/05] ipv6: RFC4214 Support (3)

2007-11-09 Thread osprey67

From: Fred L. Templin [EMAIL PROTECTED]

This is experimental support for the Intra-Site Automatic
Tunnel Addressing Protocol (ISATAP) per RFC4214. It uses
the SIT module, and is configured using the unmodified
ip utility with device names beginning with: isatap.

The following diffs are specific to the Linux 2.6.24-rc2
kernel distribution.

Signed-off-by: Fred L. Templin [EMAIL PROTECTED]

---

--- linux-2.6.24-rc2/net/ipv6/Kconfig.orig  2007-11-08 12:07:17.0 
-0800
+++ linux-2.6.24-rc2/net/ipv6/Kconfig   2007-11-08 08:27:48.0 -0800
@@ -57,6 +57,17 @@ config IPV6_ROUTE_INFO

  If unsure, say N.

+config IPV6_ISATAP
+   bool IPv6: ISATAP (RFC 4214) support (EXPERIMENTAL)
+   depends on IPV6  EXPERIMENTAL
+   ---help---
+ This is experimental support for the Intra-Site Automatic
+ Tunnel Addressing Protocol (ISATAP) per RFC4214. It uses
+ the SIT module, and is configured using the ip utility
+ with device names beginning with: isatap.
+
+ If unsure, say N.
+
 config IPV6_OPTIMISTIC_DAD
bool IPv6: Enable RFC 4429 Optimistic DAD (EXPERIMENTAL)
depends on IPV6  EXPERIMENTAL


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


Re: [PATCH 02/05] ipv6: RFC4214 Support (2)

2007-11-08 Thread YOSHIFUJI Hideaki / 吉藤英明
In article [EMAIL PROTECTED] (at Thu, 08 Nov 2007 12:41:39 -0800), osprey67 
[EMAIL PROTECTED] says:

 From: Fred L. Templin [EMAIL PROTECTED]
 
 This is experimental support for the Intra-Site Automatic
 Tunnel Addressing Protocol (ISATAP) per RFC4214. It uses
 the SIT module, and is configured using the unmodified
 ip utility with device names beginning with: isatap.
 
 The following diffs are specific to the Linux 2.6.24-rc2
 kernel distribution.
 
 Signed-off-by: Fred L. Templin [EMAIL PROTECTED]

Hmm...tabs are still mangled, and it's better to have your
official address.  Anyway...

 --- linux-2.6.24-rc2/include/net/addrconf.h.orig2007-11-08 
 12:06:17.0 -0800
 +++ linux-2.6.24-rc2/include/net/addrconf.h 2007-11-08 08:27:24.0 
 -0800
 @@ -241,6 +241,37 @@ static inline int ipv6_addr_is_ll_all_ro
  addr-s6_addr32[3] == htonl(0x0002));
   }
 
 +#if defined(CONFIG_IPV6_ISATAP)
 +static inline int ipv6_isatap_eui64(u8 *eui, __be32 addr)
 +{
 +
 +   /* RFC3330 Special-Use IPv4 Addresses */
 +   eui[0] = (((addr  htonl(0xFF00)) == htonl(0x)) ||
 + ((addr  htonl(0xFF00)) == htonl(0x0A00)) ||
 + ((addr  htonl(0xFF00)) == htonl(0x0D00)) ||
 + ((addr  htonl(0xFF00)) == htonl(0x1800)) ||
 + ((addr  htonl(0xFF00)) == htonl(0x7F00)) ||
 + ((addr  htonl(0x)) == htonl(0xA9FE)) ||
 + ((addr  htonl(0xFFF0)) == htonl(0xAC10)) ||
 + ((addr  htonl(0xFF00)) == htonl(0xC200)) ||
 + ((addr  htonl(0xFF00)) == htonl(0xC0586300)) ||
 + ((addr  htonl(0x)) == htonl(0xC0A8)) ||
 + ((addr  htonl(0xFFFE)) == htonl(0xC612)) ||
 + ((addr  htonl(0xF000)) == htonl(0xE000)) ||
 + ((addr  htonl(0xF000)) == htonl(0xF000))) ?
 +   0x00 : 0x02;
 +
 +   eui[1] = 0; eui[2] = 0x5E; eui[3] = 0xFE;
 +   memcpy (eui+4, addr, 4);
 +   return 0;
 +}
 +

Please put this function in net/ipv6/addrconf.c as addrconf_ifid_isatap().

Please use MULTICAST, LOCALNET etc. (and probaly introduce new macro
for others).  IMHO, it's better to add a comment for each entry, e.g.,
MULTICAST(addr) ||  /* 224.0.0.0/4 */
instead of
((addr  htonl(0xF000)) == htonl(0xE000)) ||

 +static inline int ipv6_addr_is_isatap(const struct in6_addr *addr)
 +{
 +   return ((addr-s6_addr32[2] | htonl(0x0200)) == 
 htonl(0x02005EFE));
 +}
 +#endif
 +

ipv6_addr_isatap(), maybe (to align with ipv6_addr_any() etc.).

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


[PATCH 02/05] ipv6: RFC4214 Support (2)

2007-11-08 Thread osprey67

From: Fred L. Templin [EMAIL PROTECTED]

This is experimental support for the Intra-Site Automatic
Tunnel Addressing Protocol (ISATAP) per RFC4214. It uses
the SIT module, and is configured using the unmodified
ip utility with device names beginning with: isatap.

The following diffs are specific to the Linux 2.6.24-rc2
kernel distribution.

Signed-off-by: Fred L. Templin [EMAIL PROTECTED]

---

--- linux-2.6.24-rc2/include/net/addrconf.h.orig2007-11-08 
12:06:17.0 -0800
+++ linux-2.6.24-rc2/include/net/addrconf.h 2007-11-08 08:27:24.0 
-0800
@@ -241,6 +241,37 @@ static inline int ipv6_addr_is_ll_all_ro
addr-s6_addr32[3] == htonl(0x0002));
 }

+#if defined(CONFIG_IPV6_ISATAP)
+static inline int ipv6_isatap_eui64(u8 *eui, __be32 addr)
+{
+
+   /* RFC3330 Special-Use IPv4 Addresses */
+   eui[0] = (((addr  htonl(0xFF00)) == htonl(0x)) ||
+ ((addr  htonl(0xFF00)) == htonl(0x0A00)) ||
+ ((addr  htonl(0xFF00)) == htonl(0x0D00)) ||
+ ((addr  htonl(0xFF00)) == htonl(0x1800)) ||
+ ((addr  htonl(0xFF00)) == htonl(0x7F00)) ||
+ ((addr  htonl(0x)) == htonl(0xA9FE)) ||
+ ((addr  htonl(0xFFF0)) == htonl(0xAC10)) ||
+ ((addr  htonl(0xFF00)) == htonl(0xC200)) ||
+ ((addr  htonl(0xFF00)) == htonl(0xC0586300)) ||
+ ((addr  htonl(0x)) == htonl(0xC0A8)) ||
+ ((addr  htonl(0xFFFE)) == htonl(0xC612)) ||
+ ((addr  htonl(0xF000)) == htonl(0xE000)) ||
+ ((addr  htonl(0xF000)) == htonl(0xF000))) ?
+   0x00 : 0x02;
+
+   eui[1] = 0; eui[2] = 0x5E; eui[3] = 0xFE;
+   memcpy (eui+4, addr, 4);
+   return 0;
+}
+
+static inline int ipv6_addr_is_isatap(const struct in6_addr *addr)
+{
+   return ((addr-s6_addr32[2] | htonl(0x0200)) == htonl(0x02005EFE));
+}
+#endif
+
 #ifdef CONFIG_PROC_FS
 extern int if6_proc_init(void);
 extern void if6_proc_exit(void);
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 02/05] ipv6: RFC4214 Support

2007-11-07 Thread Templin, Fred L
 

 -Original Message-
 From: YOSHIFUJI Hideaki / 吉藤英明 [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, November 07, 2007 10:49 AM
 To: Templin, Fred L
 Cc: [EMAIL PROTECTED]; netdev@vger.kernel.org; [EMAIL PROTECTED]
 Subject: Re: [PATCH 02/05] ipv6: RFC4214 Support
 
 In article 
 [EMAIL PROTECTED]
 eing.com (at Wed, 7 Nov 2007 10:24:50 -0800), Templin, Fred 
 L [EMAIL PROTECTED] says:
 
   
  
   -Original Message-
   From: YOSHIFUJI Hideaki / 吉藤英明 [mailto:[EMAIL PROTECTED] 
   Sent: Wednesday, November 07, 2007 10:12 AM
   To: [EMAIL PROTECTED]
   Cc: Templin, Fred L; netdev@vger.kernel.org; 
 [EMAIL PROTECTED]
   Subject: Re: [PATCH 02/05] ipv6: RFC4214 Support
   
   Hello.
   
   In article [EMAIL PROTECTED] (at Wed, 7 
   Nov 2007 16:58:59 +0100), Ingo Oeser [EMAIL PROTECTED] says:
   
 + eui[0] = 0;
 +
 + /* Check for RFC3330 global address ranges */
 + if (((ipv4 = 0x0100)  (ipv4  0x0a00)) ||
 + ((ipv4 = 0x0b00)  (ipv4  0x7f00)) ||
 + ((ipv4 = 0x8000)  (ipv4  0xa9fe)) ||
 + ((ipv4 = 0xa9ff)  (ipv4  0xac10)) ||
 + ((ipv4 = 0xac20)  (ipv4  0xc0a8)) ||
 + ((ipv4 = 0xc0a9)  (ipv4  0xc612)) ||
 + ((ipv4 = 0xc614)  (ipv4  
 0xe000))) eui[0] |=
 0x2;
 +

Instead of converting network to host byte order at runtime 
and comparing the results to constants, let the compiler convert
the constants to network byte order and compare in 
 network order.

so use:

 if (((*addr = htonl(0x0100))  (*addr  
   htonl(0x0a00))) || 

instead. The compiler will notice that 0x0100 is a 
   constant and will
use _constant_htonl() automatically.
   
   No, you cannot do this.
   When you check the range, you need to use host-byte order.
  
  I think the original poster was correct on this one; the addr comes
  in in network byte order, and the constants are depicted in host
  byte order. So, the suggested fix was to have htonl(const) to make
  all of the constants into network byte order while leaving addr
  alone.
 
 I don't understand.
 
 For example, 1.0.0.11 is valid IPv4 global address.
 In little-endian, this is not in the range of
 0x0001 = addr = 0x000a (addr is 0x0b01).

Maybe it is I who did not understand. Can you suggest a clean solution?

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


Re: [PATCH 02/05] ipv6: RFC4214 Support

2007-11-07 Thread Simon Arlott
On 07/11/07 18:52, Templin, Fred L wrote:
 +eui[0] = 0;
 +
 +/* Check for RFC3330 global address ranges */
 +if (((ipv4 = 0x0100)  (ipv4  0x0a00)) ||
 +((ipv4 = 0x0b00)  (ipv4  0x7f00)) ||
 +((ipv4 = 0x8000)  (ipv4  0xa9fe)) ||
 +((ipv4 = 0xa9ff)  (ipv4  0xac10)) ||
 +((ipv4 = 0xac20)  (ipv4  0xc0a8)) ||
 +((ipv4 = 0xc0a9)  (ipv4  0xc612)) ||
 +((ipv4 = 0xc614)  (ipv4  
 0xe000))) eui[0] |=
 0x2;
 I don't understand.
 
 For example, 1.0.0.11 is valid IPv4 global address.
 In little-endian, this is not in the range of
 0x0001 = addr = 0x000a (addr is 0x0b01).
 
 Maybe it is I who did not understand. Can you suggest a clean solution?

((ipv4  htonl(0xFF00)) == htonl(0x0A00)) etc.?

-- 
Simon Arlott
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/05] ipv6: RFC4214 Support

2007-11-07 Thread YOSHIFUJI Hideaki / 吉藤英明
In article [EMAIL PROTECTED] (at Wed, 7 Nov 2007 10:24:50 -0800), Templin, 
Fred L [EMAIL PROTECTED] says:

  
 
  -Original Message-
  From: YOSHIFUJI Hideaki / 吉藤英明 [mailto:[EMAIL PROTECTED] 
  Sent: Wednesday, November 07, 2007 10:12 AM
  To: [EMAIL PROTECTED]
  Cc: Templin, Fred L; netdev@vger.kernel.org; [EMAIL PROTECTED]
  Subject: Re: [PATCH 02/05] ipv6: RFC4214 Support
  
  Hello.
  
  In article [EMAIL PROTECTED] (at Wed, 7 
  Nov 2007 16:58:59 +0100), Ingo Oeser [EMAIL PROTECTED] says:
  
+   eui[0] = 0;
+
+   /* Check for RFC3330 global address ranges */
+   if (((ipv4 = 0x0100)  (ipv4  0x0a00)) ||
+   ((ipv4 = 0x0b00)  (ipv4  0x7f00)) ||
+   ((ipv4 = 0x8000)  (ipv4  0xa9fe)) ||
+   ((ipv4 = 0xa9ff)  (ipv4  0xac10)) ||
+   ((ipv4 = 0xac20)  (ipv4  0xc0a8)) ||
+   ((ipv4 = 0xc0a9)  (ipv4  0xc612)) ||
+   ((ipv4 = 0xc614)  (ipv4  0xe000))) eui[0] |=
0x2;
+
   
   Instead of converting network to host byte order at runtime 
   and comparing the results to constants, let the compiler convert
   the constants to network byte order and compare in network order.
   
   so use:
   
if (((*addr = htonl(0x0100))  (*addr  
  htonl(0x0a00))) || 
   
   instead. The compiler will notice that 0x0100 is a 
  constant and will
   use _constant_htonl() automatically.
  
  No, you cannot do this.
  When you check the range, you need to use host-byte order.
 
 I think the original poster was correct on this one; the addr comes
 in in network byte order, and the constants are depicted in host
 byte order. So, the suggested fix was to have htonl(const) to make
 all of the constants into network byte order while leaving addr
 alone.

I don't understand.

For example, 1.0.0.11 is valid IPv4 global address.
In little-endian, this is not in the range of
0x0001 = addr = 0x000a (addr is 0x0b01).

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


Re: [PATCH 02/05] ipv6: RFC4214 Support

2007-11-07 Thread YOSHIFUJI Hideaki / 吉藤英明
Hello.

In article [EMAIL PROTECTED] (at Wed, 7 Nov 2007 16:58:59 +0100), Ingo Oeser 
[EMAIL PROTECTED] says:

  +   eui[0] = 0;
  +
  +   /* Check for RFC3330 global address ranges */
  +   if (((ipv4 = 0x0100)  (ipv4  0x0a00)) ||
  +   ((ipv4 = 0x0b00)  (ipv4  0x7f00)) ||
  +   ((ipv4 = 0x8000)  (ipv4  0xa9fe)) ||
  +   ((ipv4 = 0xa9ff)  (ipv4  0xac10)) ||
  +   ((ipv4 = 0xac20)  (ipv4  0xc0a8)) ||
  +   ((ipv4 = 0xc0a9)  (ipv4  0xc612)) ||
  +   ((ipv4 = 0xc614)  (ipv4  0xe000))) eui[0] |=
  0x2;
  +
 
 Instead of converting network to host byte order at runtime 
 and comparing the results to constants, let the compiler convert
 the constants to network byte order and compare in network order.
 
 so use:
 
  if (((*addr = htonl(0x0100))  (*addr  htonl(0x0a00))) || 
 
 instead. The compiler will notice that 0x0100 is a constant and will
 use _constant_htonl() automatically.

No, you cannot do this.
When you check the range, you need to use host-byte order.

  +
  +static inline int ipv6_addr_is_isatap(const struct in6_addr *addr)
  +{
  +   return (addr-s6_addr32[2] == __constant_htonl(0x02005EFE) ||
  +   addr-s6_addr32[2] == __constant_htonl(0x5EFE));
  +}
  +#endif
 
 The compiler will notice that 0x0100 is a constant and will
 use _constant_htonl() automatically. Please use simply htonl().

Right.  And, maybe, you can write as follows:
return ((addr-s6_addr32[2] | htonl(0x0200)) == htonl(0x02005EFE));

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


RE: [PATCH 02/05] ipv6: RFC4214 Support

2007-11-07 Thread Templin, Fred L
Thanks for these, Ingo. Will fix and test immediately.

Fred
[EMAIL PROTECTED] 

 -Original Message-
 From: Ingo Oeser [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, November 07, 2007 7:59 AM
 To: Templin, Fred L
 Cc: netdev@vger.kernel.org
 Subject: Re: [PATCH 02/05] ipv6: RFC4214 Support
 
 Hi Fred,
 
 some comments.
 
 Templin, Fred L schrieb:
  From: Fred L. Templin [EMAIL PROTECTED]
  
  This is experimental support for the Intra-Site Automatic
  Tunnel Addressing Protocol (ISATAP) per RFC4214. It uses
  the SIT module, and is configured using the unmodified
  ip utility with device names beginning with: isatap.
  
  The following diffs are specific to the Linux 2.6.23
  kernel distribution.
  
  Signed-off-by: Fred L. Templin [EMAIL PROTECTED]
  
  ---
  
  --- linux-2.6.23/include/net/addrconf.h.orig2007-10-09
  13:31:38.0 -0700
  +++ linux-2.6.23/include/net/addrconf.h 2007-10-26 
 10:49:40.0
  -0700
  @@ -241,6 +241,34 @@ static inline int ipv6_addr_is_ll_all_ro
  addr-s6_addr32[3] == htonl(0x0002));
   }
   
  +#if defined(CONFIG_IPV6_ISATAP)
  +static inline int ipv6_isatap_eui64(u8 *eui, __be32 *addr)
 addr is only used for reading, not writing. No need to pass 
 it as a pointer.
 
  +{
  +   __be32 ipv4 = ntohl(*addr);
 
 ntohl(be32_value) != be32_value, so the _be32 attribution of ipv4 
 is wrong here and sparse will scream.
 
  +
  +   eui[0] = 0;
  +
  +   /* Check for RFC3330 global address ranges */
  +   if (((ipv4 = 0x0100)  (ipv4  0x0a00)) ||
  +   ((ipv4 = 0x0b00)  (ipv4  0x7f00)) ||
  +   ((ipv4 = 0x8000)  (ipv4  0xa9fe)) ||
  +   ((ipv4 = 0xa9ff)  (ipv4  0xac10)) ||
  +   ((ipv4 = 0xac20)  (ipv4  0xc0a8)) ||
  +   ((ipv4 = 0xc0a9)  (ipv4  0xc612)) ||
  +   ((ipv4 = 0xc614)  (ipv4  0xe000))) eui[0] |=
  0x2;
  +
 
 Instead of converting network to host byte order at runtime 
 and comparing the results to constants, let the compiler convert
 the constants to network byte order and compare in network order.
 
 so use:
 
  if (((*addr = htonl(0x0100))  (*addr  
 htonl(0x0a00))) || 
 
 instead. The compiler will notice that 0x0100 is a 
 constant and will
 use _constant_htonl() automatically.
 
 
  +   eui[1] = 0; eui[2] = 0x5E; eui[3] = 0xFE;
  +   memcpy (eui+4, addr, 4);
  +   return (0);
  +}
 
 Nitpick: 
   return is not a function. Please write return 0; instead.
 
  +
  +static inline int ipv6_addr_is_isatap(const struct in6_addr *addr)
  +{
  +   return (addr-s6_addr32[2] == 
 __constant_htonl(0x02005EFE) ||
  +   addr-s6_addr32[2] == __constant_htonl(0x5EFE));
  +}
  +#endif
 
 The compiler will notice that 0x0100 is a constant and will
 use _constant_htonl() automatically. Please use simply htonl().
 
 
 Best Regards
 
 Ingo Oeser
 
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/05] ipv6: RFC4214 Support

2007-11-07 Thread Ingo Oeser
Hi Fred,

some comments.

Templin, Fred L schrieb:
 From: Fred L. Templin [EMAIL PROTECTED]
 
 This is experimental support for the Intra-Site Automatic
 Tunnel Addressing Protocol (ISATAP) per RFC4214. It uses
 the SIT module, and is configured using the unmodified
 ip utility with device names beginning with: isatap.
 
 The following diffs are specific to the Linux 2.6.23
 kernel distribution.
 
 Signed-off-by: Fred L. Templin [EMAIL PROTECTED]
 
 ---
 
 --- linux-2.6.23/include/net/addrconf.h.orig  2007-10-09
 13:31:38.0 -0700
 +++ linux-2.6.23/include/net/addrconf.h   2007-10-26 10:49:40.0
 -0700
 @@ -241,6 +241,34 @@ static inline int ipv6_addr_is_ll_all_ro
   addr-s6_addr32[3] == htonl(0x0002));
  }
  
 +#if defined(CONFIG_IPV6_ISATAP)
 +static inline int ipv6_isatap_eui64(u8 *eui, __be32 *addr)
addr is only used for reading, not writing. No need to pass it as a pointer.

 +{
 + __be32 ipv4 = ntohl(*addr);

ntohl(be32_value) != be32_value, so the _be32 attribution of ipv4 
is wrong here and sparse will scream.

 +
 + eui[0] = 0;
 +
 + /* Check for RFC3330 global address ranges */
 + if (((ipv4 = 0x0100)  (ipv4  0x0a00)) ||
 + ((ipv4 = 0x0b00)  (ipv4  0x7f00)) ||
 + ((ipv4 = 0x8000)  (ipv4  0xa9fe)) ||
 + ((ipv4 = 0xa9ff)  (ipv4  0xac10)) ||
 + ((ipv4 = 0xac20)  (ipv4  0xc0a8)) ||
 + ((ipv4 = 0xc0a9)  (ipv4  0xc612)) ||
 + ((ipv4 = 0xc614)  (ipv4  0xe000))) eui[0] |=
 0x2;
 +

Instead of converting network to host byte order at runtime 
and comparing the results to constants, let the compiler convert
the constants to network byte order and compare in network order.

so use:

 if (((*addr = htonl(0x0100))  (*addr  htonl(0x0a00))) || 

instead. The compiler will notice that 0x0100 is a constant and will
use _constant_htonl() automatically.


 + eui[1] = 0; eui[2] = 0x5E; eui[3] = 0xFE;
 + memcpy (eui+4, addr, 4);
 + return (0);
 +}

Nitpick: 
return is not a function. Please write return 0; instead.

 +
 +static inline int ipv6_addr_is_isatap(const struct in6_addr *addr)
 +{
 +   return (addr-s6_addr32[2] == __constant_htonl(0x02005EFE) ||
 +   addr-s6_addr32[2] == __constant_htonl(0x5EFE));
 +}
 +#endif

The compiler will notice that 0x0100 is a constant and will
use _constant_htonl() automatically. Please use simply htonl().


Best Regards

Ingo Oeser
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 02/05] ipv6: RFC4214 Support

2007-11-07 Thread Templin, Fred L
 

 -Original Message-
 From: Simon Arlott [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, November 07, 2007 11:02 AM
 To: Templin, Fred L
 Cc: YOSHIFUJI Hideaki / 吉藤英明; [EMAIL PROTECTED]; netdev@vger.kernel.org
 Subject: Re: [PATCH 02/05] ipv6: RFC4214 Support
 
 On 07/11/07 18:52, Templin, Fred L wrote:
  +  eui[0] = 0;
  +
  +  /* Check for RFC3330 global address ranges */
  +  if (((ipv4 = 0x0100)  (ipv4  0x0a00)) ||
  +  ((ipv4 = 0x0b00)  (ipv4  0x7f00)) ||
  +  ((ipv4 = 0x8000)  (ipv4  0xa9fe)) ||
  +  ((ipv4 = 0xa9ff)  (ipv4  0xac10)) ||
  +  ((ipv4 = 0xac20)  (ipv4  0xc0a8)) ||
  +  ((ipv4 = 0xc0a9)  (ipv4  0xc612)) ||
  +  ((ipv4 = 0xc614)  (ipv4  
  0xe000))) eui[0] |=
  0x2;
  I don't understand.
  
  For example, 1.0.0.11 is valid IPv4 global address.
  In little-endian, this is not in the range of
  0x0001 = addr = 0x000a (addr is 0x0b01).
  
  Maybe it is I who did not understand. Can you suggest a 
 clean solution?
 
 ((ipv4  htonl(0xFF00)) == htonl(0x0A00)) etc.?

I'm not sure this works when we consider disjoint ranges
of globally-unique IP prefixes. Do you have a vision for
how the entire conditional would look like?

Thanks - Fred
[EMAIL PROTECTED]

 Simon Arlott
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 02/05] ipv6: RFC4214 Support

2007-11-07 Thread Templin, Fred L
 

 -Original Message-
 From: YOSHIFUJI Hideaki / 吉藤英明 [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, November 07, 2007 10:12 AM
 To: [EMAIL PROTECTED]
 Cc: Templin, Fred L; netdev@vger.kernel.org; [EMAIL PROTECTED]
 Subject: Re: [PATCH 02/05] ipv6: RFC4214 Support
 
 Hello.
 
 In article [EMAIL PROTECTED] (at Wed, 7 
 Nov 2007 16:58:59 +0100), Ingo Oeser [EMAIL PROTECTED] says:
 
   + eui[0] = 0;
   +
   + /* Check for RFC3330 global address ranges */
   + if (((ipv4 = 0x0100)  (ipv4  0x0a00)) ||
   + ((ipv4 = 0x0b00)  (ipv4  0x7f00)) ||
   + ((ipv4 = 0x8000)  (ipv4  0xa9fe)) ||
   + ((ipv4 = 0xa9ff)  (ipv4  0xac10)) ||
   + ((ipv4 = 0xac20)  (ipv4  0xc0a8)) ||
   + ((ipv4 = 0xc0a9)  (ipv4  0xc612)) ||
   + ((ipv4 = 0xc614)  (ipv4  0xe000))) eui[0] |=
   0x2;
   +
  
  Instead of converting network to host byte order at runtime 
  and comparing the results to constants, let the compiler convert
  the constants to network byte order and compare in network order.
  
  so use:
  
   if (((*addr = htonl(0x0100))  (*addr  
 htonl(0x0a00))) || 
  
  instead. The compiler will notice that 0x0100 is a 
 constant and will
  use _constant_htonl() automatically.
 
 No, you cannot do this.
 When you check the range, you need to use host-byte order.

I think the original poster was correct on this one; the addr comes
in in network byte order, and the constants are depicted in host
byte order. So, the suggested fix was to have htonl(const) to make
all of the constants into network byte order while leaving addr
alone.

   +
   +static inline int ipv6_addr_is_isatap(const struct 
 in6_addr *addr)
   +{
   +   return (addr-s6_addr32[2] == 
 __constant_htonl(0x02005EFE) ||
   +   addr-s6_addr32[2] == 
 __constant_htonl(0x5EFE));
   +}
   +#endif
  
  The compiler will notice that 0x0100 is a constant and will
  use _constant_htonl() automatically. Please use simply htonl().
 
 Right.  And, maybe, you can write as follows:
   return ((addr-s6_addr32[2] | htonl(0x0200)) == htonl(0x02005EFE));

This looks good, and the change will be made.

Fred
[EMAIL PROTECTED]

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


Re: [PATCH 02/05] ipv6: RFC4214 Support

2007-11-07 Thread Simon Arlott
On 07/11/07 19:32, Templin, Fred L wrote:
  
 
 -Original Message-
 From: Simon Arlott [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, November 07, 2007 11:02 AM
 To: Templin, Fred L
 Cc: YOSHIFUJI Hideaki / 吉藤英明; [EMAIL PROTECTED]; netdev@vger.kernel.org
 Subject: Re: [PATCH 02/05] ipv6: RFC4214 Support
 
 On 07/11/07 18:52, Templin, Fred L wrote:
  + eui[0] = 0;
  +
  + /* Check for RFC3330 global address ranges */
  + if (((ipv4 = 0x0100)  (ipv4  0x0a00)) ||
  + ((ipv4 = 0x0b00)  (ipv4  0x7f00)) ||
  + ((ipv4 = 0x8000)  (ipv4  0xa9fe)) ||
  + ((ipv4 = 0xa9ff)  (ipv4  0xac10)) ||
  + ((ipv4 = 0xac20)  (ipv4  0xc0a8)) ||
  + ((ipv4 = 0xc0a9)  (ipv4  0xc612)) ||
  + ((ipv4 = 0xc614)  (ipv4  
  0xe000))) eui[0] |=
  0x2;
  I don't understand.
  
  For example, 1.0.0.11 is valid IPv4 global address.
  In little-endian, this is not in the range of
  0x0001 = addr = 0x000a (addr is 0x0b01).
  
  Maybe it is I who did not understand. Can you suggest a 
 clean solution?
 
 ((ipv4  htonl(0xFF00)) == htonl(0x0A00)) etc.?
 
 I'm not sure this works when we consider disjoint ranges
 of globally-unique IP prefixes. Do you have a vision for
 how the entire conditional would look like?

You need to match RFC3330 addresses, not anything that isn't.

((ipv4  htonl(0xFF00)) == htonl(0x0A00))
|| ((ipv4  htonl(0x)) == htonl(0xC0A8))
|| ((ipv4  htonl(0xFF00)) == htonl(0x8000))
etc.

-- 
Simon Arlott
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/05] ipv6: RFC4214 Support

2007-11-06 Thread Templin, Fred L
From: Fred L. Templin [EMAIL PROTECTED]

This is experimental support for the Intra-Site Automatic
Tunnel Addressing Protocol (ISATAP) per RFC4214. It uses
the SIT module, and is configured using the unmodified
ip utility with device names beginning with: isatap.

The following diffs are specific to the Linux 2.6.23
kernel distribution.

Signed-off-by: Fred L. Templin [EMAIL PROTECTED]

---

--- linux-2.6.23/include/net/addrconf.h.orig2007-10-09
13:31:38.0 -0700
+++ linux-2.6.23/include/net/addrconf.h 2007-10-26 10:49:40.0
-0700
@@ -241,6 +241,34 @@ static inline int ipv6_addr_is_ll_all_ro
addr-s6_addr32[3] == htonl(0x0002));
 }
 
+#if defined(CONFIG_IPV6_ISATAP)
+static inline int ipv6_isatap_eui64(u8 *eui, __be32 *addr)
+{
+   __be32 ipv4 = ntohl(*addr);
+
+   eui[0] = 0;
+
+   /* Check for RFC3330 global address ranges */
+   if (((ipv4 = 0x0100)  (ipv4  0x0a00)) ||
+   ((ipv4 = 0x0b00)  (ipv4  0x7f00)) ||
+   ((ipv4 = 0x8000)  (ipv4  0xa9fe)) ||
+   ((ipv4 = 0xa9ff)  (ipv4  0xac10)) ||
+   ((ipv4 = 0xac20)  (ipv4  0xc0a8)) ||
+   ((ipv4 = 0xc0a9)  (ipv4  0xc612)) ||
+   ((ipv4 = 0xc614)  (ipv4  0xe000))) eui[0] |=
0x2;
+
+   eui[1] = 0; eui[2] = 0x5E; eui[3] = 0xFE;
+   memcpy (eui+4, addr, 4);
+   return (0);
+}
+
+static inline int ipv6_addr_is_isatap(const struct in6_addr *addr)
+{
+   return (addr-s6_addr32[2] == __constant_htonl(0x02005EFE) ||
+   addr-s6_addr32[2] == __constant_htonl(0x5EFE));
+}
+#endif
+
 #ifdef CONFIG_PROC_FS
 extern int if6_proc_init(void);
 extern void if6_proc_exit(void);
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html