All of lore.kernel.org
 help / color / mirror / Atom feed
* [UDP] Check encap_type at config time
@ 2004-06-25 12:11 Herbert Xu
  2004-06-25 12:35 ` [IPSEC] " Herbert Xu
  2004-06-25 17:37 ` [UDP] Check encap_type at config time David S. Miller
  0 siblings, 2 replies; 8+ messages in thread
From: Herbert Xu @ 2004-06-25 12:11 UTC (permalink / raw)
  To: David S. Miller, netdev

[-- Attachment #1: Type: text/plain, Size: 797 bytes --]

Hi Dave:

My foray into the TTL stuff is turning into an all-out assault on NAT-T :)

The following patch moves the udp->encap_type check from the per-packet
hot-path into udp_setsockopt().

As a consequence, this allows user space to detect whether the kernel
actually supports the encap type that they're requesting.  Pity no one
did this before the NON-IKE patch was applied.  As it is there is no
easy way to detect whether NON-IKE support is present.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

PS I will be doing a similar patch for the encap_type in xfrm.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email:  Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[-- Attachment #2: p --]
[-- Type: text/plain, Size: 1272 bytes --]

===== net/ipv4/udp.c 1.61 vs edited =====
--- 1.61/net/ipv4/udp.c	2004-06-05 06:59:36 +10:00
+++ edited/net/ipv4/udp.c	2004-06-25 21:56:34 +10:00
@@ -964,6 +964,7 @@
 	len = skb->tail - udpdata;
 
 	switch (encap_type) {
+	default:
 	case UDP_ENCAP_ESPINUDP:
 		/* Check if this is a keepalive packet.  If so, eat it. */
 		if (len == 1 && udpdata[0] == 0xff) {
@@ -1016,12 +1017,6 @@
 		} else
 			/* Must be an IKE packet.. pass it through */
 			return 1;
-
-	default:
-		if (net_ratelimit())
-			printk(KERN_INFO "udp_encap_rcv(): Unhandled UDP encap type: %u\n",
-			       encap_type);
-		return 1;
 	}
 #endif
 }
@@ -1297,7 +1292,16 @@
 		break;
 		
 	case UDP_ENCAP:
-		up->encap_type = val;
+		switch (val) {
+		case 0:
+		case UDP_ENCAP_ESPINUDP:
+		case UDP_ENCAP_ESPINUDP_NON_IKE:
+			up->encap_type = val;
+			break;
+		default:
+			err = -ENOPROTOOPT;
+			break;
+		}
 		break;
 
 	default:
===== net/ipv6/udp.c 1.67 vs edited =====
--- 1.67/net/ipv6/udp.c	2004-06-21 09:37:54 +10:00
+++ edited/net/ipv6/udp.c	2004-06-25 20:13:50 +10:00
@@ -1044,7 +1044,14 @@
 		break;
 		
 	case UDP_ENCAP:
-		up->encap_type = val;
+		switch (val) {
+		case 0:
+			up->encap_type = val;
+			break;
+		default:
+			err = -ENOPROTOOPT;
+			break;
+		}
 		break;
 
 	default:

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-06-26 18:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-25 12:11 [UDP] Check encap_type at config time Herbert Xu
2004-06-25 12:35 ` [IPSEC] " Herbert Xu
2004-06-25 17:39   ` David S. Miller
2004-06-26  1:57     ` [IPSEC] Remove run-time encap_type checks in esp4 Herbert Xu
2004-06-26 10:07       ` [IPSEC] Drop bogus NAT-T printks in esp_input Herbert Xu
2004-06-26 18:36         ` David S. Miller
2004-06-26 18:35       ` [IPSEC] Remove run-time encap_type checks in esp4 David S. Miller
2004-06-25 17:37 ` [UDP] Check encap_type at config time David S. Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.