Skip to contentSkip to conversation

net/ipv4: UDP-Lite extensions

RFC PATCH In review [email protected] 2 participants 5 messages Aug 23, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/3 net/ipv4: UDP-Lite extensions

[Net/IPv4]: UDP-Lite standalone support and shared UDP/-Lite socket structure.

---

 include/linux/udp.h   |   19 ++++
 include/net/udplite.h |   35 ++++++++
 net/ipv4/udplite.c    |  209 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 262 insertions(+), 1 deletion(-)
include/linux/udp.h +18 -1
index 90223f0..76fb1a1 100644
@@ -19,6 +19,12 @@ #define _LINUX_UDP_H
 
 #include <linux/types.h>
 
+/**
+ *   struct udphdr  -  UDP/-Lite header
+ *
+ *   UDP (RFC 768) and UDP-Lite (RFC 3828) share the same header structure,
+ *   the only difference is that UDP-Lite interprets `len' as checksum coverage.
+ */
 struct udphdr {
 	__u16	source;
 	__u16	dest;
@@ -50,13 +56,24 @@ struct udp_sock {
 	 * when the socket is uncorked.
 	 */
 	__u16		 len;		/* total length of pending frames */
+/*
+ * 	Fields specific to UDP-Lite.
+ */
+	__u16		 pcslen;
+	__u16		 pcrlen;
+/* indicator bits used by pcflag: */
+#define UDPLITE_BIT      0x1  		/* set by udplite proto init function */
+#define UDPLITE_SEND_CC  0x2  		/* set via udplite setsockopt         */
+#define UDPLITE_RECV_CC  0x4		/* set via udplite setsocktopt        */
+	__u8		 pcflag;        /* marks socket as UDP-Lite if > 0    */
 };
 
 static inline struct udp_sock *udp_sk(const struct sock *sk)
 {
 	return (struct udp_sock *)sk;
 }
+#define IS_UDPLITE(__sk) (udp_sk(__sk)->pcflag)
 
-#endif
+#endif	/* __KERNEL__   */
 
 #endif	/* _LINUX_UDP_H */
net/ipv4/udplite.c new file +209 -0

209 lines not on this page · raw message

include/net/udplite.h new file +35 -0
new file mode 100644
index 0000000..1a32c42
@@ -0,0 +1,35 @@
+/*
+ *	Definitions for the UDP-Lite (RFC 3828) code.
+ */
+#ifndef _UDPLITE_H
+#define _UDPLITE_H
+
+/* UDP-Lite socket options */
+#define UDPLITE_SEND_CSCOV   10 /* sender partial coverage (as sent)      */
+#define UDPLITE_RECV_CSCOV   11 /* receiver partial coverage (threshold ) */
+
+extern struct proto 		udplite_prot;
+extern struct hlist_head 	udplite_hash[UDP_HTABLE_SIZE];
+
+/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
+DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics);
+
+/*
+ *	Checksum computation is all in software, hence simpler getfrag.
+ */
+static __inline__ int udplite_getfrag(void *from, char *to, int  offset,
+				      int len, int odd, struct sk_buff *skb)
+{
+	return memcpy_fromiovecend(to, (struct iovec *) from, offset, len);
+}
+
+/*
+ *  	net/ipv4/udplite.c
+ */
+extern void	udplite4_register(void);
+#ifdef CONFIG_PROC_FS
+extern int	udplite4_proc_init(void);
+extern void	udplite4_proc_exit(void);
+#endif
+
+#endif	/* _UDPLITE_H */
#1 lore raw
Quoted 7 lines · On Wed, 23 Aug 2006, [email protected] wrote:
net/ipv4/udplite.c new file +7 -0
+void __init udplite4_register(void)
+{
+	if (proto_register(&udplite_prot, 1))
+		goto out_register_err;
+
+	if (inet_add_protocol(&udplite_protocol, IPPROTO_UDPLITE) < 0)
+		goto out_unregister_proto;

net/ipv4/udplite.c line 184

Quoted 10 lines
net/ipv4/udplite.c new file +10 -0
+
+	inet_register_protosw(&udplite4_protosw);
+
+	return;
+
+out_unregister_proto:
+	proto_unregister(&udplite_prot);
+out_register_err:
+	printk(KERN_ERR "udplite4_register: Cannot add UDP-Lite protocol\n");
+}

Other protocols & network components call panic() if they fail during boot initialization. Not sure if this is a great thing, but it raises the issue of whether udp-lite should remain consistent here.

- James

Signature · 2 lines
James Morris
<[email protected]>
#2 lore raw

Hi James,

Quoting James Morris:

|  On Wed, 23 Aug 2006, [email protected] wrote:
|  
|  > +void __init udplite4_register(void)
|  > +{
|  > +	if (proto_register(&udplite_prot, 1))
|  > +		goto out_register_err;
|  > +
|  > +	if (inet_add_protocol(&udplite_protocol, IPPROTO_UDPLITE) < 0)
|  > +		goto out_unregister_proto;
|  > +
|  > +	inet_register_protosw(&udplite4_protosw);
|  > +
|  > +	return;
|  > +
|  > +out_unregister_proto:
|  > +	proto_unregister(&udplite_prot);
|  > +out_register_err:
|  > +	printk(KERN_ERR "udplite4_register: Cannot add UDP-Lite protocol\n");
|  > +}
|  
|  Other protocols & network components call panic() if they fail during boot 
|  initialization.  Not sure if this is a great thing, but it raises the 
|  issue of whether udp-lite should remain consistent here.

The behaviour is consistent (modulo loglevel) with inet_init() of net/ipv4/af_inet.c:

	// ...

	rc = proto_register(&udp_prot, 1);
	if (rc)
		goto out_unregister_tcp_proto;

	// ... 
      	if (inet_add_protocol(&udp_protocol, IPPROTO_UDP) < 0)
		printk(KERN_CRIT "inet_init: Cannot add UDP protocol\n");
	if (inet_add_protocol(&tcp_protocol, IPPROTO_TCP) < 0)
		printk(KERN_CRIT "inet_init: Cannot add TCP protocol\n");

	// ...
	for (q = inetsw_array; q < &inetsw_array[INETSW_ARRAY_LEN]; ++q)
		inet_register_protosw(q);

// ...

        /* UDP Lite is called here, but the code of udplite4_register()
         * could as well be put in place within inet_init()              */

	udplite4_register();

But your question raises another:
* if TCP cannot init, there is no layer-4 protocol
* if UDP cannot register, TCP is unregistered also
* if RAW cannot register, only UDP is unregistered, but not TCP

Quoted 1 line

From that I could not deduct a rule what would happen if UDP-Lite failed

to register. If control had reached that above point, it means that all other protocols have already successfully registered -- if then UDP-Lite could not register and called a panic(), it would abort the remainder of the stack.

So how should the code be integrated:
(a) following the same scheme as in af_inet.c (like f.e. raw_prot ) or
(b) keep separate initialisation (as it is used e.g. in net/dccp/ipv4, dccp_v4_init())
(c) ... ?

Gerrit

#3 lore raw
Quoted 6 lines · On Wed, 23 Aug 2006, [email protected] wrote:
|  Other protocols & network components call panic() if they fail during boot 
|  initialization.  Not sure if this is a great thing, but it raises the 
|  issue of whether udp-lite should remain consistent here.

The behaviour is consistent (modulo loglevel) with inet_init() of net/ipv4/af_inet.c:

Some things will panic there, just deeper in the call chain.

Quoted 5 lines
Quoted 1 line

From that I could not deduct a rule what would happen if UDP-Lite failed

to register. If control had reached that above point, it means that all other protocols have already successfully registered -- if then UDP-Lite could not register and called a panic(), it would abort the remainder of the stack.

Other functions can also panic on failure after this, e.g. tcp_init().

I think ideally it'd be best if components did not panic during initialization unless it _really_ meant that the kernel should not continue executing. Although, it's not entirely clear how to determine this, e.g. perhaps the system should panic if netfilter initialization failed, as it might mean that the systems comes up without a firewall. But how do we know precisely which components are being used for security critical purposes?

It seems like a signifcant overhaul of existing code, so probably best just to leave yours as-is (which I suspect is the correct behavior anyway).

- James

Signature · 2 lines
James Morris
<[email protected]>
#4 lore raw
Quoted 3 lines · James Morris

continue executing. Although, it's not entirely clear how to determine this, e.g. perhaps the system should panic if netfilter initialization failed, as it might mean that the systems comes up without a firewall.

Actually, I guess it's up to userspace to figure this out.

- James

Signature · 2 lines
James Morris
<[email protected]>