netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: gerrit@erg.abdn.ac.uk
Cc: akpm@osdl.org, yoshfuji@linux-ipv6.org, kuznet@ms2.inr.ac.ru,
	jmorris@namei.org, kaber@coreworks.de, pekkas@netcore.fi,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCHv2 2.6.18-rc1-mm2 1/3] net: UDP-Lite generic support
Date: Thu, 27 Jul 2006 22:30:10 -0700 (PDT)	[thread overview]
Message-ID: <20060727.223010.63131639.davem@davemloft.net> (raw)
In-Reply-To: <200607141719.02766@strip-the-willow>

From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Date: Fri, 14 Jul 2006 17:19:02 +0100

> Generic support (header files, configuration, and documentation) for
> the UDP-Lite protocol (RFC 3828).

Gerrit, I tried to bring myself over the edge to accept this
work and push it into my net-2.6.19 tree,  but I simply can't
The amount of code duplication is absolutely enormous and
totally unnecessary.

With proper abstractions, you can easily add UDP-lite support to the
existing UDP code.  And I would really like it to be in that format
before we put it into the tree.

Then all you need to do is something like add:

	__u16             pcslen;
	__u16             pcrlen;
/* checksum coverage set indicators used by pcflag */
#define UDPLITE_SEND_CC   0x1
#define UDPLITE_RECV_CC   0x2
	__u8              pcflag;

to struct udp_sock.

Add the seperate udp_port_rover and udlite_hash[] table to udp.c, make
the latter sized by UDP_HTABLE_SIZE, with suitable exports, and share
the udp_hash_lock for mutual exclusion.  Finally, parameterize all the
UDP hash table routines to take a hash table base and a port rover
pointer so that they can operate on both UDP and UDP-Lite sockets
transparently.

Next make 2 top-level routines for things like udp_err() etc.
So that you can go:

/* Common code */
static void __udp_err(struct sock *sk, struct sk_buff *skb, int type, int code, u32 info)
{
	struct inet_sock *inet;
	int type = skb->h.icmph->type;
	int code = skb->h.icmph->code;
	int harderr, err;

	if (sk == NULL) {
		ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
    	  	return;	/* No socket for error */
	}

	err = 0;
	harderr = 0;
	inet = inet_sk(sk);

	switch (type) {
 ...
	}

	/*
	 *      RFC1122: OK.  Passes ICMP errors back to application, as per 
	 *	4.1.3.3.
	 */
	if (!inet->recverr) {
		if (!harderr || sk->sk_state != TCP_ESTABLISHED)
			goto out;
	} else {
		ip_icmp_error(sk, skb, err, uh->dest, info, (u8*)(uh+1));
	}
	sk->sk_err = err;
	sk->sk_error_report(sk);
out:
	sock_put(sk);
}

void udp_err(struct sk_buff *skb, u32 info)
{
	struct iphdr *iph = (struct iphdr*)skb->data;
	struct udphdr *uh = (struct udphdr*)(skb->data+(iph->ihl<<2));
	int type = skb->h.icmph->type;
	int code = skb->h.icmph->code;
	struct sock *sk;

	sk = udp_v4_lookup(udp_hash,
			   iph->daddr, uh->dest, iph->saddr,
			   uh->source, skb->dev->ifindex);
	__udp_err(sk, skb, type, code, info);
}

void udplite_err(struct sk_buff *skb, u32 info)
{
	struct iphdr *iph = (struct iphdr*)skb->data;
	struct udphdr *uh = (struct udphdr*)(skb->data+(iph->ihl<<2));
	int type = skb->h.icmph->type;
	int code = skb->h.icmph->code;
	struct sock *sk;

	sk = udp_v4_lookup(udplite_hash,
			   iph->daddr, uh->dest, iph->saddr,
			   uh->source, skb->dev->ifindex);
	__udp_err(sk, skb, type, code, info);
}

Make similar abstractions for the send and recive path processing,
substituting in the specific UDP vs. UDP-Lite header and
checksum semantic handling along the way.

It's mostly clerical work, but it will mean that we will have one
copy of all this code and as a result we won't even need a config
option for UDP-Lite.

Thanks.


  parent reply	other threads:[~2006-07-28  5:30 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-14 16:19 [PATCHv2 2.6.18-rc1-mm2 1/3] net: UDP-Lite generic support Gerrit Renker
2006-07-15 13:33 ` Herbert Xu
2006-07-16  9:29   ` Gerrit Renker
2006-07-28  5:30 ` David Miller [this message]
2006-07-28  8:19   ` Gerrit Renker
2006-07-28  8:25     ` David Miller
2006-09-19  7:25   ` [PATCHv3 1/4][RFC] net/ipv4: consolidated UDP / UDP-Lite code Gerrit Renker
2006-10-09  9:51     ` [PATCH-update][RFC] net: " Gerrit Renker
2006-10-11  2:38       ` David Miller
2006-10-11  7:40         ` Gerrit Renker
2006-10-12  7:49       ` Gerrit Renker
2006-10-12  9:01         ` David Miller
2006-10-13 15:14           ` [PATCHv4 1/3] net/ipv4: UDP-Lite support (RFC 3828) Gerrit Renker
2006-10-13 15:14           ` [PATCHv4 2/3] net/ipv6: v6-side of UDP-Lite Gerrit Renker
2006-10-13 15:14           ` [PATCHv4 3/3] net: UDP-Lite misc files Gerrit Renker
2006-09-19  7:25   ` [PATCHv3 2/4][RFC] net/ipv4: self-contained UDP-Lite module Gerrit Renker
2006-09-19  7:25   ` [PATCHv3 3/4][RFC] net: basic xfrm/netfilter support for UDP-Lite Gerrit Renker
2006-09-19  7:37     ` Patrick McHardy
2006-09-19  7:25   ` [PATCHv3 4/4][RFC] net: misc. files to support UDP-Lite Gerrit Renker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060727.223010.63131639.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=akpm@osdl.org \
    --cc=gerrit@erg.abdn.ac.uk \
    --cc=jmorris@namei.org \
    --cc=kaber@coreworks.de \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pekkas@netcore.fi \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).