Netdev List
 help / color / mirror / Atom feed
* [PATCH 4/7] [IPSEC]: Use IPv6 calling convention as the convention for x->mode->output
From: Herbert Xu @ 2007-10-10 14:40 UTC (permalink / raw)
  To: David S. Miller, netdev, Herbert Xu
In-Reply-To: <20071010143915.GA7650@gondor.apana.org.au>

[IPSEC]: Use IPv6 calling convention as the convention for x->mode->output

The IPv6 calling convention for x->mode->output is more general and could
help an eventual protocol-generic x->type->output implementation.  This
patch adopts it for IPv4 as well and modifies the IPv4 type output functions
accordingly.

It also rewrites the IPv6 mac/transport header calculation to be based off
the network header where practical.

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

 include/net/xfrm.h              |   12 ++++++++++++
 net/ipv4/ah4.c                  |    6 +++---
 net/ipv4/esp4.c                 |   11 +++++------
 net/ipv4/ipcomp.c               |   10 +++++-----
 net/ipv4/xfrm4_mode_beet.c      |   17 +++++++----------
 net/ipv4/xfrm4_mode_transport.c |    7 +++----
 net/ipv4/xfrm4_mode_tunnel.c    |    7 +++----
 net/ipv6/xfrm6_mode_beet.c      |    9 +--------
 net/ipv6/xfrm6_mode_ro.c        |    9 +--------
 net/ipv6/xfrm6_mode_transport.c |    9 +--------
 net/ipv6/xfrm6_mode_tunnel.c    |   14 +++-----------
 11 files changed, 44 insertions(+), 67 deletions(-)

diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 1c116dc..77be396 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -300,6 +300,18 @@ extern void xfrm_put_type(struct xfrm_type *type);
 
 struct xfrm_mode {
 	int (*input)(struct xfrm_state *x, struct sk_buff *skb);
+
+	/*
+	 * Add encapsulation header.
+	 *
+	 * On exit, the transport header will be set to the start of the
+	 * encapsulation header to be filled in by x->type->output and
+	 * the mac header will be set to the nextheader (protocol for
+	 * IPv4) field of the extension header directly preceding the
+	 * encapsulation header, or in its absence, that of the top IP
+	 * header.  The value of the network header will always point
+	 * to the top IP header while skb->data will point to the payload.
+	 */
 	int (*output)(struct xfrm_state *x,struct sk_buff *skb);
 
 	struct module *owner;
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index dbb1f11..e4f7aa3 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -82,14 +82,14 @@ static int ah_output(struct xfrm_state *x, struct sk_buff *skb)
 			goto error;
 	}
 
-	ah = (struct ip_auth_hdr *)((char *)top_iph+top_iph->ihl*4);
-	ah->nexthdr = top_iph->protocol;
+	ah = (struct ip_auth_hdr *)skb_transport_header(skb);
+	ah->nexthdr = *skb_mac_header(skb);
+	*skb_mac_header(skb) = IPPROTO_AH;
 
 	top_iph->tos = 0;
 	top_iph->tot_len = htons(skb->len);
 	top_iph->frag_off = 0;
 	top_iph->ttl = 0;
-	top_iph->protocol = IPPROTO_AH;
 	top_iph->check = 0;
 
 	ahp = x->data;
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 0f5e838..93153d1 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -60,10 +60,10 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
 
 	skb_push(skb, -skb_network_offset(skb));
 	top_iph = ip_hdr(skb);
-	esph = (struct ip_esp_hdr *)(skb_network_header(skb) +
-				     top_iph->ihl * 4);
+	esph = (struct ip_esp_hdr *)skb_transport_header(skb);
 	top_iph->tot_len = htons(skb->len + alen);
-	*(skb_tail_pointer(trailer) - 1) = top_iph->protocol;
+	*(skb_tail_pointer(trailer) - 1) = *skb_mac_header(skb);
+	*skb_mac_header(skb) = IPPROTO_ESP;
 
 	spin_lock_bh(&x->lock);
 
@@ -91,9 +91,8 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
 			break;
 		}
 
-		top_iph->protocol = IPPROTO_UDP;
-	} else
-		top_iph->protocol = IPPROTO_ESP;
+		*skb_mac_header(skb) = IPPROTO_UDP;
+	}
 
 	esph->spi = x->id.spi;
 	esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq);
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index 1929d45..bf74f64 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -98,10 +98,10 @@ out:
 static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb)
 {
 	struct ipcomp_data *ipcd = x->data;
-	const int ihlen = ip_hdrlen(skb);
+	const int ihlen = skb_transport_offset(skb);
 	const int plen = skb->len - ihlen;
 	int dlen = IPCOMP_SCRATCH_SIZE;
-	u8 *start = skb->data + ihlen;
+	u8 *start = skb_transport_header(skb);
 	const int cpu = get_cpu();
 	u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu);
 	struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu);
@@ -154,11 +154,11 @@ static int ipcomp_output(struct xfrm_state *x, struct sk_buff *skb)
 
 	/* Install ipcomp header, convert into ipcomp datagram. */
 	iph->tot_len = htons(skb->len);
-	ipch = (struct ip_comp_hdr *)((char *)iph + iph->ihl * 4);
-	ipch->nexthdr = iph->protocol;
+	ipch = (struct ip_comp_hdr *)skb_transport_header(skb);
+	ipch->nexthdr = *skb_mac_header(skb);
 	ipch->flags = 0;
 	ipch->cpi = htons((u16 )ntohl(x->id.spi));
-	iph->protocol = IPPROTO_COMP;
+	*skb_mac_header(skb) = IPPROTO_COMP;
 	ip_send_check(iph);
 	return 0;
 
diff --git a/net/ipv4/xfrm4_mode_beet.c b/net/ipv4/xfrm4_mode_beet.c
index 77888f5..7226c64 100644
--- a/net/ipv4/xfrm4_mode_beet.c
+++ b/net/ipv4/xfrm4_mode_beet.c
@@ -23,17 +23,14 @@
  * The following fields in it shall be filled in by x->type->output:
  *      tot_len
  *      check
- *
- * On exit, skb->h will be set to the start of the payload to be processed
- * by x->type->output and skb->nh will be set to the top IP header.
  */
 static int xfrm4_beet_output(struct xfrm_state *x, struct sk_buff *skb)
 {
+	struct ip_beet_phdr *ph;
 	struct iphdr *iph, *top_iph;
 	int hdrlen, optlen;
 
 	iph = ip_hdr(skb);
-	skb->transport_header = skb->network_header;
 
 	hdrlen = 0;
 	optlen = iph->ihl * 4 - sizeof(*iph);
@@ -42,17 +39,17 @@ static int xfrm4_beet_output(struct xfrm_state *x, struct sk_buff *skb)
 
 	skb_set_network_header(skb, IPV4_BEET_PHMAXLEN - x->props.header_len -
 				    hdrlen);
-	top_iph = ip_hdr(skb);
-	skb->transport_header += sizeof(*iph) - hdrlen;
-	__skb_pull(skb, sizeof(*iph) - hdrlen);
+	skb->mac_header = skb->network_header +
+			  offsetof(struct iphdr, protocol);
+	skb->transport_header = skb->network_header + sizeof(*iph);
+
+	ph = (struct ip_beet_phdr *)__skb_pull(skb, sizeof(*iph) - hdrlen);
 
+	top_iph = ip_hdr(skb);
 	memmove(top_iph, iph, sizeof(*iph));
 	if (unlikely(optlen)) {
-		struct ip_beet_phdr *ph;
-
 		BUG_ON(optlen < 0);
 
-		ph = (struct ip_beet_phdr *)skb_transport_header(skb);
 		ph->padlen = 4 - (optlen & 4);
 		ph->hdrlen = optlen / 8;
 		ph->nexthdr = top_iph->protocol;
diff --git a/net/ipv4/xfrm4_mode_transport.c b/net/ipv4/xfrm4_mode_transport.c
index 10499d2..fd840c7 100644
--- a/net/ipv4/xfrm4_mode_transport.c
+++ b/net/ipv4/xfrm4_mode_transport.c
@@ -17,17 +17,16 @@
  *
  * The IP header will be moved forward to make space for the encapsulation
  * header.
- *
- * On exit, skb->h will be set to the start of the payload to be processed
- * by x->type->output and skb->nh will be set to the top IP header.
  */
 static int xfrm4_transport_output(struct xfrm_state *x, struct sk_buff *skb)
 {
 	struct iphdr *iph = ip_hdr(skb);
 	int ihl = iph->ihl * 4;
 
-	skb->transport_header = skb->network_header + ihl;
 	skb_set_network_header(skb, -x->props.header_len);
+	skb->mac_header = skb->network_header +
+			  offsetof(struct iphdr, protocol);
+	skb->transport_header = skb->network_header + ihl;
 	__skb_pull(skb, ihl);
 	memmove(skb_network_header(skb), iph, ihl);
 	return 0;
diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
index bac1a91..f1d41ea 100644
--- a/net/ipv4/xfrm4_mode_tunnel.c
+++ b/net/ipv4/xfrm4_mode_tunnel.c
@@ -35,9 +35,6 @@ static inline void ipip6_ecn_decapsulate(struct iphdr *iph, struct sk_buff *skb)
  * in it shall be filled in by x->type->output:
  *      tot_len
  *      check
- *
- * On exit, skb->h will be set to the start of the payload to be processed
- * by x->type->output and skb->nh will be set to the top IP header.
  */
 static int xfrm4_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
 {
@@ -47,9 +44,11 @@ static int xfrm4_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
 	int flags;
 
 	iph = ip_hdr(skb);
-	skb->transport_header = skb->network_header;
 
 	skb_set_network_header(skb, -x->props.header_len);
+	skb->mac_header = skb->network_header +
+			  offsetof(struct iphdr, protocol);
+	skb->transport_header = skb->network_header + sizeof(*iph);
 	top_iph = ip_hdr(skb);
 
 	top_iph->ihl = 5;
diff --git a/net/ipv6/xfrm6_mode_beet.c b/net/ipv6/xfrm6_mode_beet.c
index bca018d..42c6ef8 100644
--- a/net/ipv6/xfrm6_mode_beet.c
+++ b/net/ipv6/xfrm6_mode_beet.c
@@ -24,13 +24,6 @@
  * The top IP header will be constructed per draft-nikander-esp-beet-mode-06.txt.
  * The following fields in it shall be filled in by x->type->output:
  *	payload_len
- *
- * On exit, skb->h will be set to the start of the encapsulation header to be
- * filled in by x->type->output and the mac header will be set to the
- * nextheader field of the extension header directly preceding the
- * encapsulation header, or in its absence, that of the top IP header.
- * The value of the network header will always point to the top IP header
- * while skb->data will point to the payload.
  */
 static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb)
 {
@@ -44,7 +37,7 @@ static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb)
 
 	skb_set_mac_header(skb, (prevhdr - x->props.header_len) - skb->data);
 	skb_set_network_header(skb, -x->props.header_len);
-	skb_set_transport_header(skb, hdr_len - x->props.header_len);
+	skb->transport_header = skb->network_header + hdr_len;
 	__skb_pull(skb, hdr_len);
 
 	top_iph = ipv6_hdr(skb);
diff --git a/net/ipv6/xfrm6_mode_ro.c b/net/ipv6/xfrm6_mode_ro.c
index 5c29b36..957ae36 100644
--- a/net/ipv6/xfrm6_mode_ro.c
+++ b/net/ipv6/xfrm6_mode_ro.c
@@ -37,13 +37,6 @@
  *
  * The IP header and mutable extension headers will be moved forward to make
  * space for the route optimization header.
- *
- * On exit, skb->h will be set to the start of the encapsulation header to be
- * filled in by x->type->output and the mac header will be set to the
- * nextheader field of the extension header directly preceding the
- * encapsulation header, or in its absence, that of the top IP header.
- * The value of the network header will always point to the top IP header
- * while skb->data will point to the payload.
  */
 static int xfrm6_ro_output(struct xfrm_state *x, struct sk_buff *skb)
 {
@@ -56,7 +49,7 @@ static int xfrm6_ro_output(struct xfrm_state *x, struct sk_buff *skb)
 	hdr_len = x->type->hdr_offset(x, skb, &prevhdr);
 	skb_set_mac_header(skb, (prevhdr - x->props.header_len) - skb->data);
 	skb_set_network_header(skb, -x->props.header_len);
-	skb_set_transport_header(skb, hdr_len - x->props.header_len);
+	skb->transport_header = skb->network_header + hdr_len;
 	__skb_pull(skb, hdr_len);
 	memmove(ipv6_hdr(skb), iph, hdr_len);
 
diff --git a/net/ipv6/xfrm6_mode_transport.c b/net/ipv6/xfrm6_mode_transport.c
index f2ee186..4e34410 100644
--- a/net/ipv6/xfrm6_mode_transport.c
+++ b/net/ipv6/xfrm6_mode_transport.c
@@ -18,13 +18,6 @@
  *
  * The IP header and mutable extension headers will be moved forward to make
  * space for the encapsulation header.
- *
- * On exit, skb->h will be set to the start of the encapsulation header to be
- * filled in by x->type->output and the mac header will be set to the
- * nextheader field of the extension header directly preceding the
- * encapsulation header, or in its absence, that of the top IP header.
- * The value of the network header will always point to the top IP header
- * while skb->data will point to the payload.
  */
 static int xfrm6_transport_output(struct xfrm_state *x, struct sk_buff *skb)
 {
@@ -37,7 +30,7 @@ static int xfrm6_transport_output(struct xfrm_state *x, struct sk_buff *skb)
 	hdr_len = x->type->hdr_offset(x, skb, &prevhdr);
 	skb_set_mac_header(skb, (prevhdr - x->props.header_len) - skb->data);
 	skb_set_network_header(skb, -x->props.header_len);
-	skb_set_transport_header(skb, hdr_len - x->props.header_len);
+	skb->transport_header = skb->network_header + hdr_len;
 	__skb_pull(skb, hdr_len);
 	memmove(ipv6_hdr(skb), iph, hdr_len);
 	return 0;
diff --git a/net/ipv6/xfrm6_mode_tunnel.c b/net/ipv6/xfrm6_mode_tunnel.c
index 01bd7d1..e79c6bd 100644
--- a/net/ipv6/xfrm6_mode_tunnel.c
+++ b/net/ipv6/xfrm6_mode_tunnel.c
@@ -36,13 +36,6 @@ static inline void ip6ip_ecn_decapsulate(struct sk_buff *skb)
  * The top IP header will be constructed per RFC 2401.  The following fields
  * in it shall be filled in by x->type->output:
  *	payload_len
- *
- * On exit, skb->h will be set to the start of the encapsulation header to be
- * filled in by x->type->output and the mac header will be set to the
- * nextheader field of the extension header directly preceding the
- * encapsulation header, or in its absence, that of the top IP header.
- * The value of the network header will always point to the top IP header
- * while skb->data will point to the payload.
  */
 static int xfrm6_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
 {
@@ -53,11 +46,10 @@ static int xfrm6_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
 
 	iph = ipv6_hdr(skb);
 
-	skb_set_mac_header(skb, offsetof(struct ipv6hdr, nexthdr) -
-				x->props.header_len);
 	skb_set_network_header(skb, -x->props.header_len);
-	skb_set_transport_header(skb, sizeof(struct ipv6hdr) -
-				      x->props.header_len);
+	skb->mac_header = skb->network_header +
+			  offsetof(struct ipv6hdr, nexthdr);
+	skb->transport_header = skb->network_header + sizeof(*iph);
 	top_iph = ipv6_hdr(skb);
 
 	top_iph->version = 6;

^ permalink raw reply related

* [PATCH 7/7] [IPSEC]: Move IP protocol setting from transforms into xfrm4_input.c
From: Herbert Xu @ 2007-10-10 14:40 UTC (permalink / raw)
  To: David S. Miller, netdev, Herbert Xu
In-Reply-To: <20071010143915.GA7650@gondor.apana.org.au>

[IPSEC]: Move IP protocol setting from transforms into xfrm4_input.c

This patch makes the IPv4 x->type->input functions return the next protocol
instead of setting it directly.  This is identical to how we do things in
IPv6 and will help us merge common code on the input path.

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

 net/ipv4/ah4.c          |    5 +++--
 net/ipv4/esp4.c         |    3 +--
 net/ipv4/ipcomp.c       |    7 ++++---
 net/ipv4/xfrm4_input.c  |    7 ++++++-
 net/ipv4/xfrm4_tunnel.c |    2 +-
 5 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index 60925fe..4e8e3b0 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -125,6 +125,7 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
 {
 	int ah_hlen;
 	int ihl;
+	int nexthdr;
 	int err = -EINVAL;
 	struct iphdr *iph;
 	struct ip_auth_hdr *ah;
@@ -136,6 +137,7 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
 
 	ah = (struct ip_auth_hdr *)skb->data;
 	ahp = x->data;
+	nexthdr = ah->nexthdr;
 	ah_hlen = (ah->hdrlen + 2) << 2;
 
 	if (ah_hlen != XFRM_ALIGN8(sizeof(*ah) + ahp->icv_full_len) &&
@@ -182,13 +184,12 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
 			goto out;
 		}
 	}
-	((struct iphdr*)work_buf)->protocol = ah->nexthdr;
 	skb->network_header += ah_hlen;
 	memcpy(skb_network_header(skb), work_buf, ihl);
 	skb->transport_header = skb->network_header;
 	__skb_pull(skb, ah_hlen + ihl);
 
-	return 0;
+	return nexthdr;
 
 out:
 	return err;
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 8377bed..6b1a31a 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -257,12 +257,11 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
 			skb->ip_summed = CHECKSUM_UNNECESSARY;
 	}
 
-	iph->protocol = nexthdr[1];
 	pskb_trim(skb, skb->len - alen - padlen - 2);
 	__skb_pull(skb, sizeof(*esph) + esp->conf.ivlen);
 	skb_set_transport_header(skb, -ihl);
 
-	return 0;
+	return nexthdr[1];
 
 out:
 	return -EINVAL;
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index 32b02de..0bfeb02 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -75,7 +75,6 @@ out:
 static int ipcomp_input(struct xfrm_state *x, struct sk_buff *skb)
 {
 	int err = -ENOMEM;
-	struct iphdr *iph;
 	struct ip_comp_hdr *ipch;
 
 	if (skb_linearize_cow(skb))
@@ -84,12 +83,14 @@ static int ipcomp_input(struct xfrm_state *x, struct sk_buff *skb)
 	skb->ip_summed = CHECKSUM_NONE;
 
 	/* Remove ipcomp header and decompress original payload */
-	iph = ip_hdr(skb);
 	ipch = (void *)skb->data;
-	iph->protocol = ipch->nexthdr;
 	skb->transport_header = skb->network_header + sizeof(*ipch);
 	__skb_pull(skb, sizeof(*ipch));
 	err = ipcomp_decompress(x, skb);
+	if (err)
+		goto out;
+
+	err = ipch->nexthdr;
 
 out:
 	return err;
diff --git a/net/ipv4/xfrm4_input.c b/net/ipv4/xfrm4_input.c
index 2fa1082..e9bbfde 100644
--- a/net/ipv4/xfrm4_input.c
+++ b/net/ipv4/xfrm4_input.c
@@ -54,12 +54,14 @@ static int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type)
 	int xfrm_nr = 0;
 	int decaps = 0;
 	int err = xfrm4_parse_spi(skb, ip_hdr(skb)->protocol, &spi, &seq);
+	unsigned int nhoff = offsetof(struct iphdr, protocol);
 
 	if (err != 0)
 		goto drop;
 
 	do {
 		const struct iphdr *iph = ip_hdr(skb);
+		int nexthdr;
 
 		if (xfrm_nr == XFRM_MAX_DEPTH)
 			goto drop;
@@ -82,9 +84,12 @@ static int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type)
 		if (xfrm_state_check_expire(x))
 			goto drop_unlock;
 
-		if (x->type->input(x, skb))
+		nexthdr = x->type->input(x, skb);
+		if (nexthdr <= 0)
 			goto drop_unlock;
 
+		skb_network_header(skb)[nhoff] = nexthdr;
+
 		/* only the first xfrm gets the encap type */
 		encap_type = 0;
 
diff --git a/net/ipv4/xfrm4_tunnel.c b/net/ipv4/xfrm4_tunnel.c
index e1fafc1..1312417 100644
--- a/net/ipv4/xfrm4_tunnel.c
+++ b/net/ipv4/xfrm4_tunnel.c
@@ -18,7 +18,7 @@ static int ipip_output(struct xfrm_state *x, struct sk_buff *skb)
 
 static int ipip_xfrm_rcv(struct xfrm_state *x, struct sk_buff *skb)
 {
-	return 0;
+	return IPPROTO_IP;
 }
 
 static int ipip_init_state(struct xfrm_state *x)

^ permalink raw reply related

* [PATCH 6/7] [IPSEC]: Move IP length/checksum setting out of transforms
From: Herbert Xu @ 2007-10-10 14:40 UTC (permalink / raw)
  To: David S. Miller, netdev, Herbert Xu
In-Reply-To: <20071010143915.GA7650@gondor.apana.org.au>

[IPSEC]: Move IP length/checksum setting out of transforms

This patch moves the setting of the IP length and checksum fields out of
the transforms and into the xfrmX_output functions.  This would help future
efforts in merging the transforms themselves.

It also adds an optimisation to ipcomp due to the fact that the transport
offset is guaranteed to be zero.

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

 net/ipv4/ah4.c               |    2 --
 net/ipv4/esp4.c              |    7 +------
 net/ipv4/ipcomp.c            |   22 +++++-----------------
 net/ipv4/xfrm4_mode_beet.c   |    3 ---
 net/ipv4/xfrm4_mode_tunnel.c |    5 +----
 net/ipv4/xfrm4_output.c      |    5 +++++
 net/ipv4/xfrm4_tunnel.c      |    5 -----
 net/ipv6/esp6.c              |    3 ---
 net/ipv6/ipcomp6.c           |   19 ++++++-------------
 net/ipv6/mip6.c              |    2 --
 net/ipv6/xfrm6_mode_beet.c   |    2 --
 net/ipv6/xfrm6_mode_tunnel.c |    4 +---
 net/ipv6/xfrm6_output.c      |    4 ++++
 net/ipv6/xfrm6_tunnel.c      |    5 -----
 14 files changed, 23 insertions(+), 65 deletions(-)

diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index d697064..60925fe 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -115,8 +115,6 @@ static int ah_output(struct xfrm_state *x, struct sk_buff *skb)
 		memcpy(top_iph+1, iph+1, top_iph->ihl*4 - sizeof(struct iphdr));
 	}
 
-	ip_send_check(top_iph);
-
 	err = 0;
 
 error:
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 66eb496..8377bed 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -16,7 +16,6 @@
 static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
 {
 	int err;
-	struct iphdr *top_iph;
 	struct ip_esp_hdr *esph;
 	struct crypto_blkcipher *tfm;
 	struct blkcipher_desc desc;
@@ -59,9 +58,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
 	pskb_put(skb, trailer, clen - skb->len);
 
 	skb_push(skb, -skb_network_offset(skb));
-	top_iph = ip_hdr(skb);
 	esph = ip_esp_hdr(skb);
-	top_iph->tot_len = htons(skb->len + alen);
 	*(skb_tail_pointer(trailer) - 1) = *skb_mac_header(skb);
 	*skb_mac_header(skb) = IPPROTO_ESP;
 
@@ -76,7 +73,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
 		uh = (struct udphdr *)esph;
 		uh->source = encap->encap_sport;
 		uh->dest = encap->encap_dport;
-		uh->len = htons(skb->len + alen - top_iph->ihl*4);
+		uh->len = htons(skb->len + alen - skb_transport_offset(skb));
 		uh->check = 0;
 
 		switch (encap->encap_type) {
@@ -136,8 +133,6 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
 unlock:
 	spin_unlock_bh(&x->lock);
 
-	ip_send_check(top_iph);
-
 error:
 	return err;
 }
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index 78d6ddb..32b02de 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -98,10 +98,9 @@ out:
 static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb)
 {
 	struct ipcomp_data *ipcd = x->data;
-	const int ihlen = skb_transport_offset(skb);
-	const int plen = skb->len - ihlen;
+	const int plen = skb->len;
 	int dlen = IPCOMP_SCRATCH_SIZE;
-	u8 *start = skb_transport_header(skb);
+	u8 *start = skb->data;
 	const int cpu = get_cpu();
 	u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu);
 	struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu);
@@ -118,7 +117,7 @@ static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb)
 	memcpy(start + sizeof(struct ip_comp_hdr), scratch, dlen);
 	put_cpu();
 
-	pskb_trim(skb, ihlen + dlen + sizeof(struct ip_comp_hdr));
+	pskb_trim(skb, dlen + sizeof(struct ip_comp_hdr));
 	return 0;
 
 out:
@@ -131,13 +130,8 @@ static int ipcomp_output(struct xfrm_state *x, struct sk_buff *skb)
 	int err;
 	struct ip_comp_hdr *ipch;
 	struct ipcomp_data *ipcd = x->data;
-	int hdr_len = 0;
-	struct iphdr *iph = ip_hdr(skb);
 
-	skb_push(skb, -skb_network_offset(skb));
-	iph->tot_len = htons(skb->len);
-	hdr_len = iph->ihl * 4;
-	if ((skb->len - hdr_len) < ipcd->threshold) {
+	if (skb->len < ipcd->threshold) {
 		/* Don't bother compressing */
 		goto out_ok;
 	}
@@ -146,25 +140,19 @@ static int ipcomp_output(struct xfrm_state *x, struct sk_buff *skb)
 		goto out_ok;
 
 	err = ipcomp_compress(x, skb);
-	iph = ip_hdr(skb);
 
 	if (err) {
 		goto out_ok;
 	}
 
 	/* Install ipcomp header, convert into ipcomp datagram. */
-	iph->tot_len = htons(skb->len);
 	ipch = ip_comp_hdr(skb);
 	ipch->nexthdr = *skb_mac_header(skb);
 	ipch->flags = 0;
 	ipch->cpi = htons((u16 )ntohl(x->id.spi));
 	*skb_mac_header(skb) = IPPROTO_COMP;
-	ip_send_check(iph);
-	return 0;
-
 out_ok:
-	if (x->props.mode == XFRM_MODE_TUNNEL)
-		ip_send_check(iph);
+	skb_push(skb, -skb_network_offset(skb));
 	return 0;
 }
 
diff --git a/net/ipv4/xfrm4_mode_beet.c b/net/ipv4/xfrm4_mode_beet.c
index 7226c64..73d2338 100644
--- a/net/ipv4/xfrm4_mode_beet.c
+++ b/net/ipv4/xfrm4_mode_beet.c
@@ -20,9 +20,6 @@
 /* Add encapsulation header.
  *
  * The top IP header will be constructed per draft-nikander-esp-beet-mode-06.txt.
- * The following fields in it shall be filled in by x->type->output:
- *      tot_len
- *      check
  */
 static int xfrm4_beet_output(struct xfrm_state *x, struct sk_buff *skb)
 {
diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
index f1d41ea..1ae9d32 100644
--- a/net/ipv4/xfrm4_mode_tunnel.c
+++ b/net/ipv4/xfrm4_mode_tunnel.c
@@ -31,10 +31,7 @@ static inline void ipip6_ecn_decapsulate(struct iphdr *iph, struct sk_buff *skb)
 
 /* Add encapsulation header.
  *
- * The top IP header will be constructed per RFC 2401.  The following fields
- * in it shall be filled in by x->type->output:
- *      tot_len
- *      check
+ * The top IP header will be constructed per RFC 2401.
  */
 static int xfrm4_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
 {
diff --git a/net/ipv4/xfrm4_output.c b/net/ipv4/xfrm4_output.c
index 04805c7..434ef30 100644
--- a/net/ipv4/xfrm4_output.c
+++ b/net/ipv4/xfrm4_output.c
@@ -44,6 +44,7 @@ static inline int xfrm4_output_one(struct sk_buff *skb)
 {
 	struct dst_entry *dst = skb->dst;
 	struct xfrm_state *x = dst->xfrm;
+	struct iphdr *iph;
 	int err;
 
 	if (x->props.mode == XFRM_MODE_TUNNEL) {
@@ -56,6 +57,10 @@ static inline int xfrm4_output_one(struct sk_buff *skb)
 	if (err)
 		goto error_nolock;
 
+	iph = ip_hdr(skb);
+	iph->tot_len = htons(skb->len);
+	ip_send_check(iph);
+
 	IPCB(skb)->flags |= IPSKB_XFRM_TRANSFORMED;
 	err = 0;
 
diff --git a/net/ipv4/xfrm4_tunnel.c b/net/ipv4/xfrm4_tunnel.c
index be572f9..e1fafc1 100644
--- a/net/ipv4/xfrm4_tunnel.c
+++ b/net/ipv4/xfrm4_tunnel.c
@@ -12,12 +12,7 @@
 
 static int ipip_output(struct xfrm_state *x, struct sk_buff *skb)
 {
-	struct iphdr *iph = ip_hdr(skb);
-
 	skb_push(skb, -skb_network_offset(skb));
-	iph->tot_len = htons(skb->len);
-	ip_send_check(iph);
-
 	return 0;
 }
 
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index a64295d..9eb9285 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -43,7 +43,6 @@
 static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
 {
 	int err;
-	struct ipv6hdr *top_iph;
 	struct ip_esp_hdr *esph;
 	struct crypto_blkcipher *tfm;
 	struct blkcipher_desc desc;
@@ -85,9 +84,7 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
 	pskb_put(skb, trailer, clen - skb->len);
 
 	skb_push(skb, -skb_network_offset(skb));
-	top_iph = ipv6_hdr(skb);
 	esph = ip_esp_hdr(skb);
-	top_iph->payload_len = htons(skb->len + alen - sizeof(*top_iph));
 	*(skb_tail_pointer(trailer) - 1) = *skb_mac_header(skb);
 	*skb_mac_header(skb) = IPPROTO_ESP;
 
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 8f3f32f..28fc8ed 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -119,20 +119,15 @@ out:
 static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb)
 {
 	int err;
-	struct ipv6hdr *top_iph;
 	struct ip_comp_hdr *ipch;
 	struct ipcomp_data *ipcd = x->data;
 	int plen, dlen;
 	u8 *start, *scratch;
 	struct crypto_comp *tfm;
 	int cpu;
-	int hdr_len;
-
-	skb_push(skb, -skb_network_offset(skb));
-	hdr_len = skb_transport_offset(skb);
 
 	/* check whether datagram len is larger than threshold */
-	if ((skb->len - hdr_len) < ipcd->threshold) {
+	if (skb->len < ipcd->threshold) {
 		goto out_ok;
 	}
 
@@ -140,9 +135,9 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb)
 		goto out_ok;
 
 	/* compression */
-	plen = skb->len - hdr_len;
+	plen = skb->len;
 	dlen = IPCOMP_SCRATCH_SIZE;
-	start = skb_transport_header(skb);
+	start = skb->data;
 
 	cpu = get_cpu();
 	scratch = *per_cpu_ptr(ipcomp6_scratches, cpu);
@@ -155,13 +150,9 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb)
 	}
 	memcpy(start + sizeof(struct ip_comp_hdr), scratch, dlen);
 	put_cpu();
-	pskb_trim(skb, hdr_len + dlen + sizeof(struct ip_comp_hdr));
+	pskb_trim(skb, dlen + sizeof(struct ip_comp_hdr));
 
 	/* insert ipcomp header and replace datagram */
-	top_iph = ipv6_hdr(skb);
-
-	top_iph->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
-
 	ipch = ip_comp_hdr(skb);
 	ipch->nexthdr = *skb_mac_header(skb);
 	ipch->flags = 0;
@@ -169,6 +160,8 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb)
 	*skb_mac_header(skb) = IPPROTO_COMP;
 
 out_ok:
+	skb_push(skb, -skb_network_offset(skb));
+
 	return 0;
 }
 
diff --git a/net/ipv6/mip6.c b/net/ipv6/mip6.c
index 0e7a60f..7fd841d 100644
--- a/net/ipv6/mip6.c
+++ b/net/ipv6/mip6.c
@@ -155,7 +155,6 @@ static int mip6_destopt_output(struct xfrm_state *x, struct sk_buff *skb)
 
 	skb_push(skb, -skb_network_offset(skb));
 	iph = ipv6_hdr(skb);
-	iph->payload_len = htons(skb->len - sizeof(*iph));
 
 	nexthdr = *skb_mac_header(skb);
 	*skb_mac_header(skb) = IPPROTO_DSTOPTS;
@@ -370,7 +369,6 @@ static int mip6_rthdr_output(struct xfrm_state *x, struct sk_buff *skb)
 
 	skb_push(skb, -skb_network_offset(skb));
 	iph = ipv6_hdr(skb);
-	iph->payload_len = htons(skb->len - sizeof(*iph));
 
 	nexthdr = *skb_mac_header(skb);
 	*skb_mac_header(skb) = IPPROTO_ROUTING;
diff --git a/net/ipv6/xfrm6_mode_beet.c b/net/ipv6/xfrm6_mode_beet.c
index 42c6ef8..13bb1e8 100644
--- a/net/ipv6/xfrm6_mode_beet.c
+++ b/net/ipv6/xfrm6_mode_beet.c
@@ -22,8 +22,6 @@
 /* Add encapsulation header.
  *
  * The top IP header will be constructed per draft-nikander-esp-beet-mode-06.txt.
- * The following fields in it shall be filled in by x->type->output:
- *	payload_len
  */
 static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb)
 {
diff --git a/net/ipv6/xfrm6_mode_tunnel.c b/net/ipv6/xfrm6_mode_tunnel.c
index e79c6bd..ea22838 100644
--- a/net/ipv6/xfrm6_mode_tunnel.c
+++ b/net/ipv6/xfrm6_mode_tunnel.c
@@ -33,9 +33,7 @@ static inline void ip6ip_ecn_decapsulate(struct sk_buff *skb)
 
 /* Add encapsulation header.
  *
- * The top IP header will be constructed per RFC 2401.  The following fields
- * in it shall be filled in by x->type->output:
- *	payload_len
+ * The top IP header will be constructed per RFC 2401.
  */
 static int xfrm6_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
 {
diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c
index f21596f..4618c18 100644
--- a/net/ipv6/xfrm6_output.c
+++ b/net/ipv6/xfrm6_output.c
@@ -47,6 +47,7 @@ static inline int xfrm6_output_one(struct sk_buff *skb)
 {
 	struct dst_entry *dst = skb->dst;
 	struct xfrm_state *x = dst->xfrm;
+	struct ipv6hdr *iph;
 	int err;
 
 	if (x->props.mode == XFRM_MODE_TUNNEL) {
@@ -59,6 +60,9 @@ static inline int xfrm6_output_one(struct sk_buff *skb)
 	if (err)
 		goto error_nolock;
 
+	iph = ipv6_hdr(skb);
+	iph->payload_len = htons(skb->len - sizeof(*iph));
+
 	IP6CB(skb)->flags |= IP6SKB_XFRM_TRANSFORMED;
 	err = 0;
 
diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index 00a1a3e..3f8a3ab 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -242,12 +242,7 @@ EXPORT_SYMBOL(xfrm6_tunnel_free_spi);
 
 static int xfrm6_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
 {
-	struct ipv6hdr *top_iph;
-
 	skb_push(skb, -skb_network_offset(skb));
-	top_iph = ipv6_hdr(skb);
-	top_iph->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
-
 	return 0;
 }
 

^ permalink raw reply related

* [PATCH 5/7] [IPSEC]: Get rid of ipv6_{auth,esp,comp}_hdr
From: Herbert Xu @ 2007-10-10 14:40 UTC (permalink / raw)
  To: David S. Miller, netdev, Herbert Xu
In-Reply-To: <20071010143915.GA7650@gondor.apana.org.au>

[IPSEC]: Get rid of ipv6_{auth,esp,comp}_hdr

This patch removes the duplicate ipv6_{auth,esp,comp}_hdr structures since
they're identical to the IPv4 versions.  Duplicating them would only create
problems for ourselves later when we need to add things like extended
sequence numbers.

I've also added transport header type conversion headers for these types
which are now used by the transforms.

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

 include/linux/ipv6.h |   21 ---------------------
 include/net/ah.h     |    7 +++++++
 include/net/esp.h    |    7 +++++++
 include/net/ipcomp.h |   11 ++++++++++-
 net/ipv4/ah4.c       |   18 +++++++++---------
 net/ipv4/esp4.c      |   10 +++++-----
 net/ipv4/ipcomp.c    |    2 +-
 net/ipv6/ah6.c       |   16 ++++++++--------
 net/ipv6/esp6.c      |   18 +++++++++---------
 net/ipv6/ipcomp6.c   |   17 ++++++++---------
 10 files changed, 64 insertions(+), 63 deletions(-)

diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 4ca60c3..5d35a4c 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -96,27 +96,6 @@ struct ipv6_destopt_hao {
 	struct in6_addr		addr;
 } __attribute__ ((__packed__));
 
-struct ipv6_auth_hdr {
-	__u8  nexthdr;
-	__u8  hdrlen;           /* This one is measured in 32 bit units! */
-	__be16 reserved;
-	__be32 spi;
-	__be32 seq_no;           /* Sequence number */
-	__u8  auth_data[0];     /* Length variable but >=4. Mind the 64 bit alignment! */
-};
-
-struct ipv6_esp_hdr {
-	__be32 spi;
-	__be32 seq_no;           /* Sequence number */
-	__u8  enc_data[0];      /* Length variable but >=8. Mind the 64 bit alignment! */
-};
-
-struct ipv6_comp_hdr {
-	__u8 nexthdr;
-	__u8 flags;
-	__be16 cpi;
-};
-
 /*
  *	IPv6 fixed header
  *
diff --git a/include/net/ah.h b/include/net/ah.h
index 5e758c2..ae1c322 100644
--- a/include/net/ah.h
+++ b/include/net/ah.h
@@ -38,4 +38,11 @@ out:
 	return err;
 }
 
+struct ip_auth_hdr;
+
+static inline struct ip_auth_hdr *ip_auth_hdr(const struct sk_buff *skb)
+{
+	return (struct ip_auth_hdr *)skb_transport_header(skb);
+}
+
 #endif
diff --git a/include/net/esp.h b/include/net/esp.h
index e793d76..c1bc529 100644
--- a/include/net/esp.h
+++ b/include/net/esp.h
@@ -53,4 +53,11 @@ static inline int esp_mac_digest(struct esp_data *esp, struct sk_buff *skb,
 	return crypto_hash_final(&desc, esp->auth.work_icv);
 }
 
+struct ip_esp_hdr;
+
+static inline struct ip_esp_hdr *ip_esp_hdr(const struct sk_buff *skb)
+{
+	return (struct ip_esp_hdr *)skb_transport_header(skb);
+}
+
 #endif
diff --git a/include/net/ipcomp.h b/include/net/ipcomp.h
index 87c1af3..330b74e 100644
--- a/include/net/ipcomp.h
+++ b/include/net/ipcomp.h
@@ -1,14 +1,23 @@
 #ifndef _NET_IPCOMP_H
 #define _NET_IPCOMP_H
 
-#include <linux/crypto.h>
 #include <linux/types.h>
 
 #define IPCOMP_SCRATCH_SIZE     65400
 
+struct crypto_comp;
+
 struct ipcomp_data {
 	u16 threshold;
 	struct crypto_comp **tfms;
 };
 
+struct ip_comp_hdr;
+struct sk_buff;
+
+static inline struct ip_comp_hdr *ip_comp_hdr(const struct sk_buff *skb)
+{
+	return (struct ip_comp_hdr *)skb_transport_header(skb);
+}
+
 #endif
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index e4f7aa3..d697064 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -82,7 +82,7 @@ static int ah_output(struct xfrm_state *x, struct sk_buff *skb)
 			goto error;
 	}
 
-	ah = (struct ip_auth_hdr *)skb_transport_header(skb);
+	ah = ip_auth_hdr(skb);
 	ah->nexthdr = *skb_mac_header(skb);
 	*skb_mac_header(skb) = IPPROTO_AH;
 
@@ -93,8 +93,7 @@ static int ah_output(struct xfrm_state *x, struct sk_buff *skb)
 	top_iph->check = 0;
 
 	ahp = x->data;
-	ah->hdrlen  = (XFRM_ALIGN8(sizeof(struct ip_auth_hdr) +
-				   ahp->icv_trunc_len) >> 2) - 2;
+	ah->hdrlen  = (XFRM_ALIGN8(sizeof(*ah) + ahp->icv_trunc_len) >> 2) - 2;
 
 	ah->reserved = 0;
 	ah->spi = x->id.spi;
@@ -134,15 +133,15 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
 	struct ah_data *ahp;
 	char work_buf[60];
 
-	if (!pskb_may_pull(skb, sizeof(struct ip_auth_hdr)))
+	if (!pskb_may_pull(skb, sizeof(*ah)))
 		goto out;
 
-	ah = (struct ip_auth_hdr*)skb->data;
+	ah = (struct ip_auth_hdr *)skb->data;
 	ahp = x->data;
 	ah_hlen = (ah->hdrlen + 2) << 2;
 
-	if (ah_hlen != XFRM_ALIGN8(sizeof(struct ip_auth_hdr) + ahp->icv_full_len) &&
-	    ah_hlen != XFRM_ALIGN8(sizeof(struct ip_auth_hdr) + ahp->icv_trunc_len))
+	if (ah_hlen != XFRM_ALIGN8(sizeof(*ah) + ahp->icv_full_len) &&
+	    ah_hlen != XFRM_ALIGN8(sizeof(*ah) + ahp->icv_trunc_len))
 		goto out;
 
 	if (!pskb_may_pull(skb, ah_hlen))
@@ -156,7 +155,7 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
 
 	skb->ip_summed = CHECKSUM_NONE;
 
-	ah = (struct ip_auth_hdr*)skb->data;
+	ah = (struct ip_auth_hdr *)skb->data;
 	iph = ip_hdr(skb);
 
 	ihl = skb->data - skb_network_header(skb);
@@ -266,7 +265,8 @@ static int ah_init_state(struct xfrm_state *x)
 	if (!ahp->work_icv)
 		goto error;
 
-	x->props.header_len = XFRM_ALIGN8(sizeof(struct ip_auth_hdr) + ahp->icv_trunc_len);
+	x->props.header_len = XFRM_ALIGN8(sizeof(struct ip_auth_hdr) +
+					  ahp->icv_trunc_len);
 	if (x->props.mode == XFRM_MODE_TUNNEL)
 		x->props.header_len += sizeof(struct iphdr);
 	x->data = ahp;
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 93153d1..66eb496 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -60,7 +60,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
 
 	skb_push(skb, -skb_network_offset(skb));
 	top_iph = ip_hdr(skb);
-	esph = (struct ip_esp_hdr *)skb_transport_header(skb);
+	esph = ip_esp_hdr(skb);
 	top_iph->tot_len = htons(skb->len + alen);
 	*(skb_tail_pointer(trailer) - 1) = *skb_mac_header(skb);
 	*skb_mac_header(skb) = IPPROTO_ESP;
@@ -157,7 +157,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
 	struct sk_buff *trailer;
 	int blksize = ALIGN(crypto_blkcipher_blocksize(tfm), 4);
 	int alen = esp->auth.icv_trunc_len;
-	int elen = skb->len - sizeof(struct ip_esp_hdr) - esp->conf.ivlen - alen;
+	int elen = skb->len - sizeof(*esph) - esp->conf.ivlen - alen;
 	int nfrags;
 	int ihl;
 	u8 nexthdr[2];
@@ -165,7 +165,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
 	int padlen;
 	int err;
 
-	if (!pskb_may_pull(skb, sizeof(struct ip_esp_hdr)))
+	if (!pskb_may_pull(skb, sizeof(*esph)))
 		goto out;
 
 	if (elen <= 0 || (elen & (blksize-1)))
@@ -193,7 +193,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
 
 	skb->ip_summed = CHECKSUM_NONE;
 
-	esph = (struct ip_esp_hdr*)skb->data;
+	esph = (struct ip_esp_hdr *)skb->data;
 
 	/* Get ivec. This can be wrong, check against another impls. */
 	if (esp->conf.ivlen)
@@ -206,7 +206,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
 		if (!sg)
 			goto out;
 	}
-	skb_to_sgvec(skb, sg, sizeof(struct ip_esp_hdr) + esp->conf.ivlen, elen);
+	skb_to_sgvec(skb, sg, sizeof(*esph) + esp->conf.ivlen, elen);
 	err = crypto_blkcipher_decrypt(&desc, sg, sg, elen);
 	if (unlikely(sg != &esp->sgbuf[0]))
 		kfree(sg);
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index bf74f64..78d6ddb 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -154,7 +154,7 @@ static int ipcomp_output(struct xfrm_state *x, struct sk_buff *skb)
 
 	/* Install ipcomp header, convert into ipcomp datagram. */
 	iph->tot_len = htons(skb->len);
-	ipch = (struct ip_comp_hdr *)skb_transport_header(skb);
+	ipch = ip_comp_hdr(skb);
 	ipch->nexthdr = *skb_mac_header(skb);
 	ipch->flags = 0;
 	ipch->cpi = htons((u16 )ntohl(x->id.spi));
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index ac6bae1..f9f6891 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -270,7 +270,7 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)
 			goto error_free_iph;
 	}
 
-	ah = (struct ip_auth_hdr *)skb_transport_header(skb);
+	ah = ip_auth_hdr(skb);
 	ah->nexthdr = nexthdr;
 
 	top_iph->priority    = 0;
@@ -280,8 +280,7 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)
 	top_iph->hop_limit   = 0;
 
 	ahp = x->data;
-	ah->hdrlen  = (XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) +
-				   ahp->icv_trunc_len) >> 2) - 2;
+	ah->hdrlen  = (XFRM_ALIGN8(sizeof(*ah) + ahp->icv_trunc_len) >> 2) - 2;
 
 	ah->reserved = 0;
 	ah->spi = x->id.spi;
@@ -327,7 +326,7 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
 	 * There is offset of AH before IPv6 header after the process.
 	 */
 
-	struct ipv6_auth_hdr *ah;
+	struct ip_auth_hdr *ah;
 	struct ipv6hdr *ip6h;
 	struct ah_data *ahp;
 	unsigned char *tmp_hdr = NULL;
@@ -346,13 +345,13 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
 		goto out;
 
 	hdr_len = skb->data - skb_network_header(skb);
-	ah = (struct ipv6_auth_hdr*)skb->data;
+	ah = (struct ip_auth_hdr *)skb->data;
 	ahp = x->data;
 	nexthdr = ah->nexthdr;
 	ah_hlen = (ah->hdrlen + 2) << 2;
 
-	if (ah_hlen != XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + ahp->icv_full_len) &&
-	    ah_hlen != XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + ahp->icv_trunc_len))
+	if (ah_hlen != XFRM_ALIGN8(sizeof(*ah) + ahp->icv_full_len) &&
+	    ah_hlen != XFRM_ALIGN8(sizeof(*ah) + ahp->icv_trunc_len))
 		goto out;
 
 	if (!pskb_may_pull(skb, ah_hlen))
@@ -474,7 +473,8 @@ static int ah6_init_state(struct xfrm_state *x)
 	if (!ahp->work_icv)
 		goto error;
 
-	x->props.header_len = XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + ahp->icv_trunc_len);
+	x->props.header_len = XFRM_ALIGN8(sizeof(struct ip_auth_hdr) +
+					  ahp->icv_trunc_len);
 	if (x->props.mode == XFRM_MODE_TUNNEL)
 		x->props.header_len += sizeof(struct ipv6hdr);
 	x->data = ahp;
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 21c93f0..a64295d 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -44,7 +44,7 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
 {
 	int err;
 	struct ipv6hdr *top_iph;
-	struct ipv6_esp_hdr *esph;
+	struct ip_esp_hdr *esph;
 	struct crypto_blkcipher *tfm;
 	struct blkcipher_desc desc;
 	struct sk_buff *trailer;
@@ -86,7 +86,7 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
 
 	skb_push(skb, -skb_network_offset(skb));
 	top_iph = ipv6_hdr(skb);
-	esph = (struct ipv6_esp_hdr *)skb_transport_header(skb);
+	esph = ip_esp_hdr(skb);
 	top_iph->payload_len = htons(skb->len + alen - sizeof(*top_iph));
 	*(skb_tail_pointer(trailer) - 1) = *skb_mac_header(skb);
 	*skb_mac_header(skb) = IPPROTO_ESP;
@@ -142,19 +142,19 @@ error:
 static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
 {
 	struct ipv6hdr *iph;
-	struct ipv6_esp_hdr *esph;
+	struct ip_esp_hdr *esph;
 	struct esp_data *esp = x->data;
 	struct crypto_blkcipher *tfm = esp->conf.tfm;
 	struct blkcipher_desc desc = { .tfm = tfm };
 	struct sk_buff *trailer;
 	int blksize = ALIGN(crypto_blkcipher_blocksize(tfm), 4);
 	int alen = esp->auth.icv_trunc_len;
-	int elen = skb->len - sizeof(struct ipv6_esp_hdr) - esp->conf.ivlen - alen;
+	int elen = skb->len - sizeof(*esph) - esp->conf.ivlen - alen;
 	int hdr_len = skb_network_header_len(skb);
 	int nfrags;
 	int ret = 0;
 
-	if (!pskb_may_pull(skb, sizeof(struct ipv6_esp_hdr))) {
+	if (!pskb_may_pull(skb, sizeof(*esph))) {
 		ret = -EINVAL;
 		goto out;
 	}
@@ -189,7 +189,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
 
 	skb->ip_summed = CHECKSUM_NONE;
 
-	esph = (struct ipv6_esp_hdr*)skb->data;
+	esph = (struct ip_esp_hdr *)skb->data;
 	iph = ipv6_hdr(skb);
 
 	/* Get ivec. This can be wrong, check against another impls. */
@@ -208,7 +208,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
 				goto out;
 			}
 		}
-		skb_to_sgvec(skb, sg, sizeof(struct ipv6_esp_hdr) + esp->conf.ivlen, elen);
+		skb_to_sgvec(skb, sg, sizeof(*esph) + esp->conf.ivlen, elen);
 		ret = crypto_blkcipher_decrypt(&desc, sg, sg, elen);
 		if (unlikely(sg != &esp->sgbuf[0]))
 			kfree(sg);
@@ -260,7 +260,7 @@ static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 		     int type, int code, int offset, __be32 info)
 {
 	struct ipv6hdr *iph = (struct ipv6hdr*)skb->data;
-	struct ipv6_esp_hdr *esph = (struct ipv6_esp_hdr*)(skb->data+offset);
+	struct ip_esp_hdr *esph = (struct ip_esp_hdr *)(skb->data + offset);
 	struct xfrm_state *x;
 
 	if (type != ICMPV6_DEST_UNREACH &&
@@ -356,7 +356,7 @@ static int esp6_init_state(struct xfrm_state *x)
 	if (crypto_blkcipher_setkey(tfm, x->ealg->alg_key,
 				    (x->ealg->alg_key_len + 7) / 8))
 		goto error;
-	x->props.header_len = sizeof(struct ipv6_esp_hdr) + esp->conf.ivlen;
+	x->props.header_len = sizeof(struct ip_esp_hdr) + esp->conf.ivlen;
 	if (x->props.mode == XFRM_MODE_TUNNEL)
 		x->props.header_len += sizeof(struct ipv6hdr);
 	x->data = esp;
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 87e6407..8f3f32f 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -65,7 +65,7 @@ static LIST_HEAD(ipcomp6_tfms_list);
 static int ipcomp6_input(struct xfrm_state *x, struct sk_buff *skb)
 {
 	int err = -ENOMEM;
-	struct ipv6_comp_hdr *ipch;
+	struct ip_comp_hdr *ipch;
 	int plen, dlen;
 	struct ipcomp_data *ipcd = x->data;
 	u8 *start, *scratch;
@@ -92,12 +92,10 @@ static int ipcomp6_input(struct xfrm_state *x, struct sk_buff *skb)
 	tfm = *per_cpu_ptr(ipcd->tfms, cpu);
 
 	err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen);
-	if (err) {
-		err = -EINVAL;
+	if (err)
 		goto out_put_cpu;
-	}
 
-	if (dlen < (plen + sizeof(struct ipv6_comp_hdr))) {
+	if (dlen < (plen + sizeof(*ipch))) {
 		err = -EINVAL;
 		goto out_put_cpu;
 	}
@@ -122,7 +120,7 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb)
 {
 	int err;
 	struct ipv6hdr *top_iph;
-	struct ipv6_comp_hdr *ipch;
+	struct ip_comp_hdr *ipch;
 	struct ipcomp_data *ipcd = x->data;
 	int plen, dlen;
 	u8 *start, *scratch;
@@ -151,7 +149,7 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb)
 	tfm = *per_cpu_ptr(ipcd->tfms, cpu);
 
 	err = crypto_comp_compress(tfm, start, plen, scratch, &dlen);
-	if (err || (dlen + sizeof(struct ipv6_comp_hdr)) >= plen) {
+	if (err || (dlen + sizeof(*ipch)) >= plen) {
 		put_cpu();
 		goto out_ok;
 	}
@@ -164,7 +162,7 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb)
 
 	top_iph->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
 
-	ipch = (struct ipv6_comp_hdr *)start;
+	ipch = ip_comp_hdr(skb);
 	ipch->nexthdr = *skb_mac_header(skb);
 	ipch->flags = 0;
 	ipch->cpi = htons((u16 )ntohl(x->id.spi));
@@ -179,7 +177,8 @@ static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 {
 	__be32 spi;
 	struct ipv6hdr *iph = (struct ipv6hdr*)skb->data;
-	struct ipv6_comp_hdr *ipcomph = (struct ipv6_comp_hdr*)(skb->data+offset);
+	struct ip_comp_hdr *ipcomph =
+		(struct ip_comp_hdr *)(skb->data + offset);
 	struct xfrm_state *x;
 
 	if (type != ICMPV6_DEST_UNREACH && type != ICMPV6_PKT_TOOBIG)

^ permalink raw reply related

* [PATCH 3/7] [IPSEC]: Set skb->data to payload in x->mode->output
From: Herbert Xu @ 2007-10-10 14:40 UTC (permalink / raw)
  To: David S. Miller, netdev, Herbert Xu
In-Reply-To: <20071010143915.GA7650@gondor.apana.org.au>

[IPSEC]: Set skb->data to payload in x->mode->output

This patch changes the calling convention so that on entry from
x->mode->output and before entry into x->type->output skb->data
will point to the payload instead of the IP header.

This is essentially a redistribution of skb_push/skb_pull calls
with the aim of minimising them on the common path of tunnel +
ESP.

It'll also let us use the same calling convention between IPv4
and IPv6 with the next patch.

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

 net/ipv4/ah4.c                  |    1 +
 net/ipv4/esp4.c                 |    6 ++----
 net/ipv4/ipcomp.c               |    1 +
 net/ipv4/xfrm4_mode_beet.c      |    5 +++--
 net/ipv4/xfrm4_mode_transport.c |    4 ++--
 net/ipv4/xfrm4_mode_tunnel.c    |    3 +--
 net/ipv4/xfrm4_tunnel.c         |    1 +
 net/ipv6/ah6.c                  |    1 +
 net/ipv6/esp6.c                 |    9 ++-------
 net/ipv6/ipcomp6.c              |    5 ++++-
 net/ipv6/mip6.c                 |    2 ++
 net/ipv6/xfrm6_mode_beet.c      |   13 +++++++------
 net/ipv6/xfrm6_mode_ro.c        |   12 ++++++------
 net/ipv6/xfrm6_mode_transport.c |   12 ++++++------
 net/ipv6/xfrm6_mode_tunnel.c    |   13 +++++++------
 net/ipv6/xfrm6_tunnel.c         |    1 +
 16 files changed, 47 insertions(+), 42 deletions(-)

diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index 3513149..dbb1f11 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -66,6 +66,7 @@ static int ah_output(struct xfrm_state *x, struct sk_buff *skb)
 		char 		buf[60];
 	} tmp_iph;
 
+	skb_push(skb, -skb_network_offset(skb));
 	top_iph = ip_hdr(skb);
 	iph = &tmp_iph.iph;
 
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 1af332d..0f5e838 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -28,9 +28,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
 	int alen;
 	int nfrags;
 
-	/* Strip IP+ESP header. */
-	__skb_pull(skb, skb_transport_offset(skb));
-	/* Now skb is pure payload to encrypt */
+	/* skb is pure payload to encrypt */
 
 	err = -ENOMEM;
 
@@ -60,7 +58,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
 	tail[clen - skb->len - 2] = (clen - skb->len) - 2;
 	pskb_put(skb, trailer, clen - skb->len);
 
-	__skb_push(skb, -skb_network_offset(skb));
+	skb_push(skb, -skb_network_offset(skb));
 	top_iph = ip_hdr(skb);
 	esph = (struct ip_esp_hdr *)(skb_network_header(skb) +
 				     top_iph->ihl * 4);
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index e787044..1929d45 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -134,6 +134,7 @@ static int ipcomp_output(struct xfrm_state *x, struct sk_buff *skb)
 	int hdr_len = 0;
 	struct iphdr *iph = ip_hdr(skb);
 
+	skb_push(skb, -skb_network_offset(skb));
 	iph->tot_len = htons(skb->len);
 	hdr_len = iph->ihl * 4;
 	if ((skb->len - hdr_len) < ipcd->threshold) {
diff --git a/net/ipv4/xfrm4_mode_beet.c b/net/ipv4/xfrm4_mode_beet.c
index a73e710..77888f5 100644
--- a/net/ipv4/xfrm4_mode_beet.c
+++ b/net/ipv4/xfrm4_mode_beet.c
@@ -40,10 +40,11 @@ static int xfrm4_beet_output(struct xfrm_state *x, struct sk_buff *skb)
 	if (unlikely(optlen))
 		hdrlen += IPV4_BEET_PHMAXLEN - (optlen & 4);
 
-	skb_push(skb, x->props.header_len - IPV4_BEET_PHMAXLEN + hdrlen);
-	skb_reset_network_header(skb);
+	skb_set_network_header(skb, IPV4_BEET_PHMAXLEN - x->props.header_len -
+				    hdrlen);
 	top_iph = ip_hdr(skb);
 	skb->transport_header += sizeof(*iph) - hdrlen;
+	__skb_pull(skb, sizeof(*iph) - hdrlen);
 
 	memmove(top_iph, iph, sizeof(*iph));
 	if (unlikely(optlen)) {
diff --git a/net/ipv4/xfrm4_mode_transport.c b/net/ipv4/xfrm4_mode_transport.c
index 6010471..10499d2 100644
--- a/net/ipv4/xfrm4_mode_transport.c
+++ b/net/ipv4/xfrm4_mode_transport.c
@@ -27,8 +27,8 @@ static int xfrm4_transport_output(struct xfrm_state *x, struct sk_buff *skb)
 	int ihl = iph->ihl * 4;
 
 	skb->transport_header = skb->network_header + ihl;
-	skb_push(skb, x->props.header_len);
-	skb_reset_network_header(skb);
+	skb_set_network_header(skb, -x->props.header_len);
+	__skb_pull(skb, ihl);
 	memmove(skb_network_header(skb), iph, ihl);
 	return 0;
 }
diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
index 9963700..bac1a91 100644
--- a/net/ipv4/xfrm4_mode_tunnel.c
+++ b/net/ipv4/xfrm4_mode_tunnel.c
@@ -49,8 +49,7 @@ static int xfrm4_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
 	iph = ip_hdr(skb);
 	skb->transport_header = skb->network_header;
 
-	skb_push(skb, x->props.header_len);
-	skb_reset_network_header(skb);
+	skb_set_network_header(skb, -x->props.header_len);
 	top_iph = ip_hdr(skb);
 
 	top_iph->ihl = 5;
diff --git a/net/ipv4/xfrm4_tunnel.c b/net/ipv4/xfrm4_tunnel.c
index 9275c79..be572f9 100644
--- a/net/ipv4/xfrm4_tunnel.c
+++ b/net/ipv4/xfrm4_tunnel.c
@@ -14,6 +14,7 @@ static int ipip_output(struct xfrm_state *x, struct sk_buff *skb)
 {
 	struct iphdr *iph = ip_hdr(skb);
 
+	skb_push(skb, -skb_network_offset(skb));
 	iph->tot_len = htons(skb->len);
 	ip_send_check(iph);
 
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index c51d775..ac6bae1 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -236,6 +236,7 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)
 		char hdrs[0];
 	} *tmp_ext;
 
+	skb_push(skb, -skb_network_offset(skb));
 	top_iph = ipv6_hdr(skb);
 	top_iph->payload_len = htons(skb->len - sizeof(*top_iph));
 
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 7355bb0..21c93f0 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -54,13 +54,8 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
 	int nfrags;
 	u8 *tail;
 	struct esp_data *esp = x->data;
-	int hdr_len = (skb_transport_offset(skb) +
-		       sizeof(*esph) + esp->conf.ivlen);
 
-	/* Strip IP+ESP header. */
-	__skb_pull(skb, hdr_len);
-
-	/* Now skb is pure payload to encrypt */
+	/* skb is pure payload to encrypt */
 	err = -ENOMEM;
 
 	/* Round to block size */
@@ -89,7 +84,7 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
 	tail[clen-skb->len - 2] = (clen - skb->len) - 2;
 	pskb_put(skb, trailer, clen - skb->len);
 
-	__skb_push(skb, -skb_network_offset(skb));
+	skb_push(skb, -skb_network_offset(skb));
 	top_iph = ipv6_hdr(skb);
 	esph = (struct ipv6_esp_hdr *)skb_transport_header(skb);
 	top_iph->payload_len = htons(skb->len + alen - sizeof(*top_iph));
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 71a14c0..87e6407 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -128,7 +128,10 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb)
 	u8 *start, *scratch;
 	struct crypto_comp *tfm;
 	int cpu;
-	int hdr_len = skb_transport_offset(skb);
+	int hdr_len;
+
+	skb_push(skb, -skb_network_offset(skb));
+	hdr_len = skb_transport_offset(skb);
 
 	/* check whether datagram len is larger than threshold */
 	if ((skb->len - hdr_len) < ipcd->threshold) {
diff --git a/net/ipv6/mip6.c b/net/ipv6/mip6.c
index 6475bac..0e7a60f 100644
--- a/net/ipv6/mip6.c
+++ b/net/ipv6/mip6.c
@@ -153,6 +153,7 @@ static int mip6_destopt_output(struct xfrm_state *x, struct sk_buff *skb)
 	u8 nexthdr;
 	int len;
 
+	skb_push(skb, -skb_network_offset(skb));
 	iph = ipv6_hdr(skb);
 	iph->payload_len = htons(skb->len - sizeof(*iph));
 
@@ -367,6 +368,7 @@ static int mip6_rthdr_output(struct xfrm_state *x, struct sk_buff *skb)
 	struct rt2_hdr *rt2;
 	u8 nexthdr;
 
+	skb_push(skb, -skb_network_offset(skb));
 	iph = ipv6_hdr(skb);
 	iph->payload_len = htons(skb->len - sizeof(*iph));
 
diff --git a/net/ipv6/xfrm6_mode_beet.c b/net/ipv6/xfrm6_mode_beet.c
index d9366df..bca018d 100644
--- a/net/ipv6/xfrm6_mode_beet.c
+++ b/net/ipv6/xfrm6_mode_beet.c
@@ -29,8 +29,8 @@
  * filled in by x->type->output and the mac header will be set to the
  * nextheader field of the extension header directly preceding the
  * encapsulation header, or in its absence, that of the top IP header.
- * The value of skb->data and the network header will always point to the
- * top IP header.
+ * The value of the network header will always point to the top IP header
+ * while skb->data will point to the payload.
  */
 static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb)
 {
@@ -38,16 +38,17 @@ static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb)
 	u8 *prevhdr;
 	int hdr_len;
 
-	skb_push(skb, x->props.header_len);
 	iph = ipv6_hdr(skb);
 
 	hdr_len = ip6_find_1stfragopt(skb, &prevhdr);
-	memmove(skb->data, iph, hdr_len);
 
 	skb_set_mac_header(skb, (prevhdr - x->props.header_len) - skb->data);
-	skb_reset_network_header(skb);
-	skb_set_transport_header(skb, hdr_len);
+	skb_set_network_header(skb, -x->props.header_len);
+	skb_set_transport_header(skb, hdr_len - x->props.header_len);
+	__skb_pull(skb, hdr_len);
+
 	top_iph = ipv6_hdr(skb);
+	memmove(top_iph, iph, hdr_len);
 
 	ipv6_addr_copy(&top_iph->saddr, (struct in6_addr *)&x->props.saddr);
 	ipv6_addr_copy(&top_iph->daddr, (struct in6_addr *)&x->id.daddr);
diff --git a/net/ipv6/xfrm6_mode_ro.c b/net/ipv6/xfrm6_mode_ro.c
index 2575804..5c29b36 100644
--- a/net/ipv6/xfrm6_mode_ro.c
+++ b/net/ipv6/xfrm6_mode_ro.c
@@ -42,8 +42,8 @@
  * filled in by x->type->output and the mac header will be set to the
  * nextheader field of the extension header directly preceding the
  * encapsulation header, or in its absence, that of the top IP header.
- * The value of skb->data and the network header will always point to the
- * top IP header.
+ * The value of the network header will always point to the top IP header
+ * while skb->data will point to the payload.
  */
 static int xfrm6_ro_output(struct xfrm_state *x, struct sk_buff *skb)
 {
@@ -51,14 +51,14 @@ static int xfrm6_ro_output(struct xfrm_state *x, struct sk_buff *skb)
 	u8 *prevhdr;
 	int hdr_len;
 
-	skb_push(skb, x->props.header_len);
 	iph = ipv6_hdr(skb);
 
 	hdr_len = x->type->hdr_offset(x, skb, &prevhdr);
 	skb_set_mac_header(skb, (prevhdr - x->props.header_len) - skb->data);
-	skb_reset_network_header(skb);
-	skb_set_transport_header(skb, hdr_len);
-	memmove(skb->data, iph, hdr_len);
+	skb_set_network_header(skb, -x->props.header_len);
+	skb_set_transport_header(skb, hdr_len - x->props.header_len);
+	__skb_pull(skb, hdr_len);
+	memmove(ipv6_hdr(skb), iph, hdr_len);
 
 	x->lastused = get_seconds();
 
diff --git a/net/ipv6/xfrm6_mode_transport.c b/net/ipv6/xfrm6_mode_transport.c
index 65c166b..f2ee186 100644
--- a/net/ipv6/xfrm6_mode_transport.c
+++ b/net/ipv6/xfrm6_mode_transport.c
@@ -23,8 +23,8 @@
  * filled in by x->type->output and the mac header will be set to the
  * nextheader field of the extension header directly preceding the
  * encapsulation header, or in its absence, that of the top IP header.
- * The value of skb->data and the network header will always point to the
- * top IP header.
+ * The value of the network header will always point to the top IP header
+ * while skb->data will point to the payload.
  */
 static int xfrm6_transport_output(struct xfrm_state *x, struct sk_buff *skb)
 {
@@ -32,14 +32,14 @@ static int xfrm6_transport_output(struct xfrm_state *x, struct sk_buff *skb)
 	u8 *prevhdr;
 	int hdr_len;
 
-	skb_push(skb, x->props.header_len);
 	iph = ipv6_hdr(skb);
 
 	hdr_len = x->type->hdr_offset(x, skb, &prevhdr);
 	skb_set_mac_header(skb, (prevhdr - x->props.header_len) - skb->data);
-	skb_reset_network_header(skb);
-	skb_set_transport_header(skb, hdr_len);
-	memmove(skb->data, iph, hdr_len);
+	skb_set_network_header(skb, -x->props.header_len);
+	skb_set_transport_header(skb, hdr_len - x->props.header_len);
+	__skb_pull(skb, hdr_len);
+	memmove(ipv6_hdr(skb), iph, hdr_len);
 	return 0;
 }
 
diff --git a/net/ipv6/xfrm6_mode_tunnel.c b/net/ipv6/xfrm6_mode_tunnel.c
index 3dd40af..01bd7d1 100644
--- a/net/ipv6/xfrm6_mode_tunnel.c
+++ b/net/ipv6/xfrm6_mode_tunnel.c
@@ -41,8 +41,8 @@ static inline void ip6ip_ecn_decapsulate(struct sk_buff *skb)
  * filled in by x->type->output and the mac header will be set to the
  * nextheader field of the extension header directly preceding the
  * encapsulation header, or in its absence, that of the top IP header.
- * The value of skb->data and the network header will always point to the
- * top IP header.
+ * The value of the network header will always point to the top IP header
+ * while skb->data will point to the payload.
  */
 static int xfrm6_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
 {
@@ -51,12 +51,13 @@ static int xfrm6_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
 	struct ipv6hdr *iph, *top_iph;
 	int dsfield;
 
-	skb_push(skb, x->props.header_len);
 	iph = ipv6_hdr(skb);
 
-	skb_set_mac_header(skb, offsetof(struct ipv6hdr, nexthdr));
-	skb_reset_network_header(skb);
-	skb_set_transport_header(skb, sizeof(struct ipv6hdr));
+	skb_set_mac_header(skb, offsetof(struct ipv6hdr, nexthdr) -
+				x->props.header_len);
+	skb_set_network_header(skb, -x->props.header_len);
+	skb_set_transport_header(skb, sizeof(struct ipv6hdr) -
+				      x->props.header_len);
 	top_iph = ipv6_hdr(skb);
 
 	top_iph->version = 6;
diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index aeb0607..00a1a3e 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -244,6 +244,7 @@ static int xfrm6_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
 {
 	struct ipv6hdr *top_iph;
 
+	skb_push(skb, -skb_network_offset(skb));
 	top_iph = ipv6_hdr(skb);
 	top_iph->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
 

^ permalink raw reply related

* [PATCH 2/7] [IPSEC] beet: Fix extension header support on output
From: Herbert Xu @ 2007-10-10 14:40 UTC (permalink / raw)
  To: David S. Miller, netdev, Herbert Xu
In-Reply-To: <20071010143915.GA7650@gondor.apana.org.au>

[IPSEC] beet: Fix extension header support on output

The beet output function completely kills any extension headers by replacing
them with the IPv6 header.  This is because it essentially ignores the
result of ip6_find_1stfragopt by simply acting as if there aren't any
extension headers.

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

 net/ipv6/xfrm6_mode_beet.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/xfrm6_mode_beet.c b/net/ipv6/xfrm6_mode_beet.c
index 65e6b2a..d9366df 100644
--- a/net/ipv6/xfrm6_mode_beet.c
+++ b/net/ipv6/xfrm6_mode_beet.c
@@ -44,9 +44,9 @@ static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb)
 	hdr_len = ip6_find_1stfragopt(skb, &prevhdr);
 	memmove(skb->data, iph, hdr_len);
 
-	skb_set_mac_header(skb, offsetof(struct ipv6hdr, nexthdr));
+	skb_set_mac_header(skb, (prevhdr - x->props.header_len) - skb->data);
 	skb_reset_network_header(skb);
-	skb_set_transport_header(skb, sizeof(struct ipv6hdr));
+	skb_set_transport_header(skb, hdr_len);
 	top_iph = ipv6_hdr(skb);
 
 	ipv6_addr_copy(&top_iph->saddr, (struct in6_addr *)&x->props.saddr);

^ permalink raw reply related

* [PATCH 1/7] [IPSEC] esp: Remove NAT-T checksum invalidation for BEET
From: Herbert Xu @ 2007-10-10 14:40 UTC (permalink / raw)
  To: David S. Miller, netdev, Herbert Xu
In-Reply-To: <20071010143915.GA7650@gondor.apana.org.au>

[IPSEC] esp: Remove NAT-T checksum invalidation for BEET

I pointed this out back when this patch was first proposed but it looks like
it got lost along the way.

The checksum only needs to be ignored for NAT-T in transport mode where
we lose the original inner addresses due to NAT.  With BEET the inner
addresses will be intact so the checksum remains valid.

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

 net/ipv4/esp4.c |    3 +--
 1 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 452910d..1af332d 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -261,8 +261,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
 		 *    as per draft-ietf-ipsec-udp-encaps-06,
 		 *    section 3.1.2
 		 */
-		if (x->props.mode == XFRM_MODE_TRANSPORT ||
-		    x->props.mode == XFRM_MODE_BEET)
+		if (x->props.mode == XFRM_MODE_TRANSPORT)
 			skb->ip_summed = CHECKSUM_UNNECESSARY;
 	}
 

^ permalink raw reply related

* [0/7] IPsec: More input/output clean-ups
From: Herbert Xu @ 2007-10-10 14:39 UTC (permalink / raw)
  To: David S. Miller, netdev

Hi Dave:

Here's a few more clean-up's on the IPsec input/output path.

Thanks,
-- 
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

^ permalink raw reply

* Re: [PATCH] Evict tmp variable from the stack in ip6_evictor
From: Patrick McHardy @ 2007-10-10 14:37 UTC (permalink / raw)
  To: Pavel Emelyanov; +Cc: David Miller, Linux Netdev List
In-Reply-To: <470CE1C8.9020000@openvz.org>

Pavel Emelyanov wrote:
> The list_head *tmp is used to help getting the first entry in
> the ip6_frag_lru_list list. There is a simpler way to do it


The exact same code exists in ip_fragment.c and nf_conntrack_reasm.c,
please also change it there.

^ permalink raw reply

* [NET_SCHED]: Show timer resolution instead of clock resolution in /proc/net/psched
From: Patrick McHardy @ 2007-10-10 14:34 UTC (permalink / raw)
  To: David S. Miller; +Cc: Linux Netdev List

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

Fix incorrect HTB burst rate calculation in userspace when
clock and timer resolution differ. I guess this should go
in stable 2.6.22/23 as well.


[-- Attachment #2: x --]
[-- Type: text/plain, Size: 1358 bytes --]

[NET_SCHED]: Show timer resolution instead of clock resolution in /proc/net/psched

The fourth parameter of /proc/net/psched is supposed to show the timer resultion
and is used by HTB userspace to calculate the necessary burst rate. Currently
we show the clock resolution, which results in a too low burst rate when the
two differ.

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit a3885788169f2f70634f8142344e5131ccf32595
tree 62bcf28c9706547228521dc4402ebea273326331
parent 0e52ab8ceb41df2104279938484267ab474286d1
author Patrick McHardy <kaber@trash.net> Wed, 10 Oct 2007 16:29:14 +0200
committer Patrick McHardy <kaber@trash.net> Wed, 10 Oct 2007 16:29:14 +0200

 net/sched/sch_api.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index dee0d5f..8f1bcf6 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -1225,10 +1225,13 @@ EXPORT_SYMBOL(tcf_destroy_chain);
 #ifdef CONFIG_PROC_FS
 static int psched_show(struct seq_file *seq, void *v)
 {
+	struct timespec ts;
+
+	hrtimer_get_res(CLOCK_MONOTONIC, &ts);
 	seq_printf(seq, "%08x %08x %08x %08x\n",
 		   (u32)NSEC_PER_USEC, (u32)PSCHED_US2NS(1),
 		   1000000,
-		   (u32)NSEC_PER_SEC/(u32)ktime_to_ns(KTIME_MONOTONIC_RES));
+		   (u32)NSEC_PER_SEC/(u32)ktime_to_ns(timespec_to_ktime(ts)));
 
 	return 0;
 }

^ permalink raw reply related

* [PATCH] do not give access to 1-1024 ports for autobinding
From: Denis V. Lunev @ 2007-10-10 14:34 UTC (permalink / raw)
  To: davem; +Cc: netdev, den

This patch prevents possibility to give 1-1024 port range for autobinding.
{1, 1} may only takes some sense for deep embedded people.

Signed-off-by: Denis V. Lunev <den@openvz.org>

--- ./net/ipv4/sysctl_net_ipv4.c.port2	2007-10-10 17:46:48.000000000 +0400
+++ ./net/ipv4/sysctl_net_ipv4.c	2007-10-10 18:08:00.000000000 +0400
@@ -25,7 +25,7 @@ extern int sysctl_ip_nonlocal_bind;
 #ifdef CONFIG_SYSCTL
 static int zero;
 static int tcp_retr1_max = 255;
-static int ip_local_port_range_min[] = { 1, 1 };
+static int ip_local_port_range_min[] = { 1024, 1024 };
 static int ip_local_port_range_max[] = { 65535, 65535 };
 #endif
 

^ permalink raw reply

* [PATCH] Evict tmp variable from the stack in ip6_evictor
From: Pavel Emelyanov @ 2007-10-10 14:29 UTC (permalink / raw)
  To: David Miller; +Cc: Linux Netdev List

The list_head *tmp is used to help getting the first entry in
the ip6_frag_lru_list list. There is a simpler way to do it.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---

diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 31601c9..8fad98b 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -261,7 +261,6 @@ static __inline__ void fq_kill(struct fr
 static void ip6_evictor(struct inet6_dev *idev)
 {
 	struct frag_queue *fq;
-	struct list_head *tmp;
 	int work;
 
 	work = atomic_read(&ip6_frag_mem) - sysctl_ip6frag_low_thresh;
@@ -274,8 +273,9 @@ static void ip6_evictor(struct inet6_dev
 			read_unlock(&ip6_frag_lock);
 			return;
 		}
-		tmp = ip6_frag_lru_list.next;
-		fq = list_entry(tmp, struct frag_queue, lru_list);
+
+		fq = list_first_entry(&ip6_frag_lru_list,
+				struct frag_queue, lru_list);
 		atomic_inc(&fq->refcnt);
 		read_unlock(&ip6_frag_lock);
 


^ permalink raw reply related

* Re: [Devel] [PATCH 1/5] net: Modify all rtnetlink methods to only work in the initial namespace
From: Denis V. Lunev @ 2007-10-10 14:29 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Eric W. Biederman, netdev, Pavel Emelianov, Linux Containers,
	David Miller
In-Reply-To: <470CDC26.6010608@fr.ibm.com>

Daniel Lezcano wrote:
> struct net *net = in?in->nd_net:out->nd_net;
> 
>> So, we are bound to the following options:
>> - perform additional non-uniform hacks around to place 'struct net' into
>>   other and other structures like xt_target
>> - add 7th parameter here and over
>> - introduce an skb_net field in the 'struct sk_buff' making all code
>>   uniform, at least when we have an skb
>>
>> I think that this is not the last place with such a parameter list and
>> we should make a decision at this point when the code in not mainline
>> yet.
>>
>> As far as I understand, netfilters are not touched by the Eric and we
>> can face some non-trivial problems there.
> 
> In Eric's git tree:
> http://git.kernel.org/?p=linux/kernel/git/ebiederm/linux-2.6-netns.git
> 
> There are some modifications concerning
> net/ipv4/netfiler/iptable_filter.c and at the ipt_hook function, there is:
> 
> struct net *net = (in?in:out)->nd_net;
> 
>> So, if my point about uniformity is valid, this patchset looks wrong and
>> should be re-worked :(
> 
> As Eric said, we want to build the network namespace step by step,
> taking care of not breaking the init network namespace.
> 
> If you want to make iptables per namespace or catch problems before the
> code goes to Dave's tree, IMHO it will be more convenient to post to
> containers@ the patches against netns49, where the modifications will be
> in a network namespace big picture.
> 

my point is somewhat another. Yes, this is enough for that place. If so,
I must scatter these checks all around in the netfilters code. Brr.

In forward chain the situation is different for Layer3 switching. Let's
assume that we have an OpenVZ scheme, where the packet flows from socket
to device and after that from device to device via forwarding path. You
can't call skb_orphan on namespace switching as this breaks UDP flow
regulation. Virtual network device is fast while real Ethernet is slow,
packets will be dropped on queue in real device. So, the situation with
packet on send path with a socket from other namespace is possible :(

I just pray for uniformity to concentrate on the code rather than on
guesses on which path we are :(

Regards,
	Den

^ permalink raw reply

* [PATCH] ip_local_port_range low > high check
From: Denis V. Lunev @ 2007-10-10 14:15 UTC (permalink / raw)
  To: davem; +Cc: aarapov, netdev, den

This patch adds check low > high for ip_local_port_range.

Signed-off-by: Denis V. Lunev <den@openvz.org>

diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 53ef0f4..686c0a4 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -186,6 +186,61 @@ static int strategy_allowed_congestion_control(ctl_table *table, int __user *nam
 
 }
 
+static int proc_port_range(ctl_table *table, int write, struct file *filp,
+		    void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+	int ret;
+	ctl_table tbl = {
+		.maxlen		= sizeof(sysctl_local_port_range),
+		.extra1		= ip_local_port_range_min,
+		.extra2		= ip_local_port_range_max
+	};
+	tbl.data = kmalloc(tbl.maxlen, GFP_USER);
+	if (tbl.data == NULL)
+		return -ENOMEM;
+	memcpy(tbl.data, sysctl_local_port_range, tbl.maxlen);
+
+	ret = proc_dointvec_minmax(&tbl, write, filp, buffer, lenp, ppos);
+	if (write && ret == 0) {
+		int *data = (int *)tbl.data;
+		if (data[0] > data[1])
+			ret = -EINVAL;
+		else
+			memcpy(sysctl_local_port_range, data,
+					sizeof(sysctl_local_port_range));
+	}
+	kfree(tbl.data);
+	return ret;
+}
+
+int sysctl_strategy_port_range(ctl_table *table, int __user *name, int nlen,
+		void __user *oldval, size_t __user *oldlenp,
+		void __user *newval, size_t newlen)
+{
+	int ret;
+	ctl_table tbl = {
+		.maxlen		= sizeof(sysctl_local_port_range),
+		.extra1		= ip_local_port_range_min,
+		.extra2		= ip_local_port_range_max
+	};
+	tbl.data = kmalloc(tbl.maxlen, GFP_USER);
+	if (tbl.data == NULL)
+		return -ENOMEM;
+	memcpy(tbl.data, sysctl_local_port_range, tbl.maxlen);
+
+	ret = sysctl_intvec(&tbl, name, nlen, oldval, oldlenp, newval, newlen);
+	if (ret == 0 && newval && newlen) {
+		int *data = (int *)tbl.data;
+		if (data[0] > data[1])
+			ret = -EINVAL;
+		else
+			memcpy(sysctl_local_port_range, data,
+					sizeof(sysctl_local_port_range));
+	}
+	kfree(tbl.data);
+	return ret;
+}
+
 ctl_table ipv4_table[] = {
 	{
 		.ctl_name	= NET_IPV4_TCP_TIMESTAMPS,
@@ -427,8 +482,8 @@ ctl_table ipv4_table[] = {
 		.data		= &sysctl_local_port_range,
 		.maxlen		= sizeof(sysctl_local_port_range),
 		.mode		= 0644,
-		.proc_handler	= &proc_dointvec_minmax,
-		.strategy	= &sysctl_intvec,
+		.proc_handler	= &proc_port_range,
+		.strategy	= &sysctl_strategy_port_range,
 		.extra1		= ip_local_port_range_min,
 		.extra2		= ip_local_port_range_max
 	},
Warning: 1 path touched but unmodified. Consider running git-status.

^ permalink raw reply related

* Re: [Devel] [PATCH 1/5] net: Modify all rtnetlink methods to only work in the initial namespace
From: Daniel Lezcano @ 2007-10-10 14:05 UTC (permalink / raw)
  To: Denis V. Lunev
  Cc: Eric W. Biederman, netdev, Pavel Emelianov, Linux Containers,
	David Miller
In-Reply-To: <470CC6F6.60706@sw.ru>

Denis V. Lunev wrote:
> Eric W. Biederman wrote:
>> Before I can enable rtnetlink to work in all network namespaces
>> I need to be certain that something won't break.  So this
>> patch deliberately disables all of the rtnletlink methods in everything
>> except the initial network namespace.  After the methods have been
>> audited this extra check can be disabled.
>>
> [...]
>>  static int br_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
>>  {
>> +	struct net *net = skb->sk->sk_net;
>>  	struct net_device *dev;
>>  	int idx;
>>  
> 
> I've read some code today greping 'init_net.loopback_dev' and found
> interesting non-trivial for me issue.
> 
> Network namespace is extracted from the packet in two different ways in
> TCP. This is a socket for outgoing path and a device for incoming.
> Though, there are some places called uniformly both from incoming and
> outgoing path.
> 
> Typical example is netfilters. They are called uniformly all around the
> code. The prototype is the following:
> 
> static unsigned int reject6_target(struct sk_buff **pskb,
>                            const struct net_device *in,
>                            const struct net_device *out,
>                            unsigned int hooknum,
>                            const struct xt_target *target,
>                            const void *targinfo);
> 

Thanks Denis for auditing the code.

As far as I see, struct net_device *in is NULL for outgoing traffic and 
struct net_device *out is NULL for ingress traffic. Except for the 
FORWARD rules where both are filled. If we are following network 
namespace semantic, we should not have two network devices belonging to 
two differents namespaces, right ?
In this case, the following line of code should be sufficient to 
retrieve the network namespace, no ?

struct net *net = in?in->nd_net:out->nd_net;

> So, we are bound to the following options:
> - perform additional non-uniform hacks around to place 'struct net' into
>   other and other structures like xt_target
> - add 7th parameter here and over
> - introduce an skb_net field in the 'struct sk_buff' making all code
>   uniform, at least when we have an skb
> 
> I think that this is not the last place with such a parameter list and
> we should make a decision at this point when the code in not mainline yet.
> 
> As far as I understand, netfilters are not touched by the Eric and we
> can face some non-trivial problems there.

In Eric's git tree:
http://git.kernel.org/?p=linux/kernel/git/ebiederm/linux-2.6-netns.git

There are some modifications concerning 
net/ipv4/netfiler/iptable_filter.c and at the ipt_hook function, there is:

struct net *net = (in?in:out)->nd_net;

> So, if my point about uniformity is valid, this patchset looks wrong and
> should be re-worked :(

As Eric said, we want to build the network namespace step by step, 
taking care of not breaking the init network namespace.

If you want to make iptables per namespace or catch problems before the 
code goes to Dave's tree, IMHO it will be more convenient to post to 
containers@ the patches against netns49, where the modifications will be 
in a network namespace big picture.

Regards.

   -- Daniel


^ permalink raw reply

* Re: [re] Possible 2.6.22 -> 2.6.23 HTB regression?
From: Denys @ 2007-10-10 13:31 UTC (permalink / raw)
  To: hadi, Patrick McHardy; +Cc: netdev
In-Reply-To: <1192021963.4853.21.camel@localhost>

Patch applied. Rebooted over kexec to 2.6.23 without nmi_watchdog, for now 
all seems fine.

visp-1 ~ # cat /proc/net/psched
000003e8 00000400 000f4240 3b9aca00

82942/82949 KBit/S (53083445/53087945) (106109614/106105114)
82955/82955 KBit/S (53091631/53091631) (159193059/159193059)
82955/82955 KBit/S (53091351/53091351) (212284690/212284690)
82951/82951 KBit/S (53088902/53088902) (265376041/265376041)
82940/82940 KBit/S (53081605/53081605) (318464943/318464943)
82959/82959 KBit/S (53094269/53094269) (371546548/371546548)
81596/81596 KBit/S (52221918/52221918) (424640817/424640817)
82909/82909 KBit/S (53062055/53062055) (476862735/476862735)
82939/82939 KBit/S (53081402/53081402) (529924790/529924790)
82963/82963 KBit/S (53096554/53096554) (583006192/583006192)
82954/82954 KBit/S (53090871/53090871) (636102746/636102746)
82030/82943 KBit/S (52499816/53084066) (689193617/689193617)
82945/82945 KBit/S (53085182/53085182) (741693433/742277683)
82964/82954 KBit/S (53097002/53091002) (794778615/795362865)



--
Denys Fedoryshchenko
Technical Manager
Virtual ISP S.A.L.


^ permalink raw reply

* Re: Possible 2.6.22 -> 2.6.23 HTB regression?
From: Denys @ 2007-10-10 13:20 UTC (permalink / raw)
  To: netdev; +Cc: kaber, hadi

I did complete reboot(without kexec) to 2.6.23 (same configuration) and seems 
it is working better (not stuck as before to 60-70Mbit/s).

On all cases current_clocksources was hpet, just i tried to change it (doesnt 
help at all).

visp-1 ~ # cat /sys/devices/system/clocksource/clocksource0/
current_clocksource
hpet
visp-1 ~ # cat /sys/devices/system/clocksource/clocksource0/
available_clocksource
hpet acpi_pm jiffies tsc

from pcap analyser i wrote (just filter by expression "ip" counting bytes on 
eth0.1000):

82957/82957 KBit/S (53092530/53092530) (3887135786/3889389904)
82931/82931 KBit/S (53076469/53076469) (3940228316/3942482434)
82965/82965 KBit/S (53097615/53097615) (3993304785/3995558903)
82946/82946 KBit/S (53085988/53085988) (4046402400/4048656518)
82867/82867 KBit/S (53035341/53035341) (4099488388/4101742506)
82941/82941 KBit/S (53082260/53082260) (4152523729/4154777847)
82952/82952 KBit/S (53089348/53089348) (4205605989/4207860107)
82948/82945 KBit/S (53086915/53085415) (4258695337/4260949455)


visp-1 ~ # cat /proc/net/psched
000003e8 00000400 000f4240 3b9aca00

How i can help more?

--
Denys Fedoryshchenko
Technical Manager
Virtual ISP S.A.L.


^ permalink raw reply

* Re: Possible 2.6.22 -> 2.6.23 HTB regression?
From: Patrick McHardy @ 2007-10-10 13:18 UTC (permalink / raw)
  To: Denys; +Cc: netdev
In-Reply-To: <20071010130653.M55961@visp.net.lb>

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

Denys wrote:
> Seems i am lost a bit. Now 2.6.22, i am not sure that working well. Possible 
> it is related, that i booted kernel over kexec.


Possibly.

> I will try to do full power cycle reboot if required, but it will cause for 
> me serious downtime. Please tell me, which kernel prefferable to boot?
> 
> If it is interesting 
> 2.6.22 (but also non-functional now).
> 
> visp-1 ~ # cat /proc/net/psched
> 000003e8 00000400 000f4240 3b9aca00
> 
> maybe it is related to 
> visp-1 ~ # dmesg|grep hpet
> hpet0: at MMIO 0xfed00000, IRQs 2, 8, 0
> hpet0: 3 64-bit timers, 14318180 Hz
> Time: hpet clocksource has been installed.
> hpet_resources: 0xfed00000 is busy <<< - this?


Thats appears on both 2.6.22 and 2.6.23.

> --- log.2.6.22  2007-10-10 16:08:04.000000000 +0300
> +++ log.2.6.23  2007-10-10 16:06:19.000000000 +0300

> @@ -314,12 +235,20 @@
>  usbcore: registered new device driver usb
>  PCI: Using ACPI for IRQ routing
>  PCI: If a device doesn't work, try "pci=routeirq".  If it helps, post a 
> report
> +Time: hpet clocksource has been installed.
> +Clockevents: could not switch to one-shot mode: lapic is not functional.
> +Could not switch to high resolution mode on CPU 0
> +Clockevents: could not switch to one-shot mode:<6>Clockevents: could not 
> switch to one-shot mode: lapic is not functional.
> + lapic is not functional.
> +Could not switch to high resolution mode on CPU 2
> +Could not switch to high resolution mode on CPU 3
> +Clockevents: could not switch to one-shot mode: lapic is not functional.
> +Could not switch to high resolution mode on CPU 1
>  pnp: 00:08: ioport range 0x800-0x87f has been reserved
>  pnp: 00:08: ioport range 0x880-0x8bf has been reserved
>  pnp: 00:08: ioport range 0x8c0-0x8df has been reserved
>  pnp: 00:08: ioport range 0x8e0-0x8e3 has been reserved
>  pnp: 00:08: ioport range 0xc00-0xc7f has been reserved
> -Time: hpet clocksource has been installed.
>  pnp: 00:08: ioport range 0xca0-0xca7 has been reserved
>  pnp: 00:08: ioport range 0xca9-0xcab has been reserved
>  pnp: 00:08: ioport range 0xcad-0xcaf has been reserved


>  Real Time Clock Driver v1.12ac
> -[ACPI Debug]  String: [0x09] "HPET _CRS"
> -[ACPI Debug]  Buffer: [0x1C]
>  hpet_resources: 0xfed00000 is busy
> -ACPI Error (utglobal-0126): Unknown exception code: 0xFFFFFFF0 [20070126]
>  intel_rng: FWH not detected
>  Hangcheck: starting hangcheck timer 0.9.0 (tick is 180 seconds, margin is 60 
> seconds).
>  Hangcheck: Using get_cycles().
> -input: Power Button (FF) as /class/input/input0
> -ACPI: Power Button (FF) [PWRF]
>  Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled
> +serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
> +serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
>  00:06: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
>  00:07: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
> +Clockevents: could not switch to one-shot mode:<6>Clockevents: could not 
> switch to one-shot mode:<6>Clockevents: could not switch to one-shot mode: 
> lapic is not functional.
> + lapic is not functional.
> +Could not switch to high resolution mode on CPU 3
> +Could not switch to high resolution mode on CPU 2
> +Clockevents: could not switch to one-shot mode: lapic is not functional.
> +Could not switch to high resolution mode on CPU 0
> + lapic is not functional.
> +Could not switch to high resolution mode on CPU 1


hrtimers seem to have worked on your system in 2.6.22 and not in
2.6.23 anymore. This patch should fix the incorrectly announced
/proc/net/psched timer resolution I mentioned earlier, causing HTB
to use larger burst rates by default, but that still won't be as
precise as with hrtimers.

Looking at the code, the reason for not using the lapic seems to
be nmi_watchdog=1:

+APIC timer registered as dummy, due to nmi_watchdog=1!

[-- Attachment #2: x --]
[-- Type: text/plain, Size: 594 bytes --]

diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index dee0d5f..8f1bcf6 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -1225,10 +1225,13 @@ EXPORT_SYMBOL(tcf_destroy_chain);
 #ifdef CONFIG_PROC_FS
 static int psched_show(struct seq_file *seq, void *v)
 {
+	struct timespec ts;
+
+	hrtimer_get_res(CLOCK_MONOTONIC, &ts);
 	seq_printf(seq, "%08x %08x %08x %08x\n",
 		   (u32)NSEC_PER_USEC, (u32)PSCHED_US2NS(1),
 		   1000000,
-		   (u32)NSEC_PER_SEC/(u32)ktime_to_ns(KTIME_MONOTONIC_RES));
+		   (u32)NSEC_PER_SEC/(u32)ktime_to_ns(timespec_to_ktime(ts)));
 
 	return 0;
 }

^ permalink raw reply related

* Re: [re] Possible 2.6.22 -> 2.6.23 HTB regression?
From: jamal @ 2007-10-10 13:12 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: Denys, netdev
In-Reply-To: <470CC97F.4000906@trash.net>

On Wed, 2007-10-10 at 14:45 +0200, Patrick McHardy wrote:

> OK, hrtimers are disabled on your system, but we still announce
> the usec clock resolution to userspace, which is used by HTB to
> calculate the burst rate. But actually that can't be the reason
> since that has already been the case in 2.6.22. Please post a diff
> of the bootlog from 2.6.22 and 2.6.23.

Any possible relation to clock source? logs seem to indicate acpi
source; how does tsc or jiffies do?

BTW, I could be wrong about this, but iirc in a xeon i had access to i
saw that i could not guarantee the same clock source would be selected
across reboots in about 2.6.22.

cheers,
jamal


^ permalink raw reply

* Re: [ofa-general] Re: [PATCH 2/3][NET_BATCH] net core use batching
From: jamal @ 2007-10-10 13:08 UTC (permalink / raw)
  To: David Miller
  Cc: johnpol, Robert.Olsson, herbert, gaagaan, jeff, rdreier,
	peter.p.waskiewicz.jr, mcarlson, andi, general, netdev, tgraf,
	randy.dunlap, sri, shemminger, kaber, mchan, jagana
In-Reply-To: <20071010.034446.85819294.davem@davemloft.net>

On Wed, 2007-10-10 at 03:44 -0700, David Miller wrote:

> I've always gotten very poor results when increasing the TX queue a
> lot, for example with NIU the point of diminishing returns seems to
> be in the range of 256-512 TX descriptor entries and this was with
> 1.6Ghz cpus.

Is it interupt per packet? From my experience, you may find interesting
results varying tx interupt mitigation parameters in addition to the
ring parameters.
Unfortunately when you do that, optimal parameters also depends on
packet size. so what may work for 64B, wont work well for 1400B.

cheers,
jamal

^ permalink raw reply

* Re: Possible 2.6.22 -> 2.6.23 HTB regression?
From: Denys @ 2007-10-10 13:06 UTC (permalink / raw)
  To: netdev; +Cc: kaber

Seems i am lost a bit. Now 2.6.22, i am not sure that working well. Possible 
it is related, that i booted kernel over kexec.

I will try to do full power cycle reboot if required, but it will cause for 
me serious downtime. Please tell me, which kernel prefferable to boot?

If it is interesting 
2.6.22 (but also non-functional now).

visp-1 ~ # cat /proc/net/psched
000003e8 00000400 000f4240 3b9aca00

maybe it is related to 
visp-1 ~ # dmesg|grep hpet
hpet0: at MMIO 0xfed00000, IRQs 2, 8, 0
hpet0: 3 64-bit timers, 14318180 Hz
Time: hpet clocksource has been installed.
hpet_resources: 0xfed00000 is busy <<< - this?



Diff 2.6.22 -> 2.6.23 dmesg

--- log.2.6.22  2007-10-10 16:08:04.000000000 +0300
+++ log.2.6.23  2007-10-10 16:06:19.000000000 +0300
@@ -1,4 +1,4 @@
-Linux version 2.6.22-gentoo-r5-insat1 (root@livecd) (gcc version 4.1.1 
(Gentoo 4.1.1-r3)) #4 SMP Tue Sep 4 14:32:32 EEST 2007
+Linux version 2.6.23-insat1 (root@visp-1) (gcc version 4.1.1 (Gentoo 4.1.1-
r3)) #1 SMP Wed Oct 10 01:41:17 EEST 2007
 BIOS-provided physical RAM map:
  BIOS-e820: 0000000000000100 - 00000000000a0000 (usable)
  BIOS-e820: 0000000000100000 - 000000003ffa8000 (usable)
@@ -14,6 +14,7 @@
   DMA             0 ->     4096
   Normal       4096 ->   229376
   HighMem    229376 ->   262056
+Movable zone start PFN for each node
 early_node_map[1] active PFN ranges
     0:        0 ->   262056
 On node 0 totalpages: 262056
@@ -24,6 +25,7 @@
   Normal zone: 223520 pages, LIFO batch:31
   HighMem zone: 255 pages used for memmap
   HighMem zone: 32425 pages, LIFO batch:7
+  Movable zone: 0 pages used for memmap
 DMI 2.4 present.
 Using APIC driver default
 ACPI: RSDP 000F2620, 0024 (r2 DELL  )
@@ -74,45 +76,46 @@
 ACPI: HPET id: 0x8086a201 base: 0xfed00000
 Using ACPI (MADT) for SMP configuration information
 Allocating PCI resources starting at 50000000 (gap: 40000000:a0000000)
-Built 1 zonelists.  Total pages: 260009
+Built 1 zonelists in Zone order.  Total pages: 260009
 Kernel command line: root=/dev/sda3 panic=10 nmi_watchdog=1
-mapped APIC to ffffd000 (fee00000)
-mapped IOAPIC to ffffc000 (fec00000)
-mapped IOAPIC to ffffb000 (fec80000)
-mapped IOAPIC to ffffa000 (fec81000)
-mapped IOAPIC to ffff9000 (fec82000)
+mapped APIC to ffffb000 (fee00000)
+mapped IOAPIC to ffffa000 (fec00000)
+mapped IOAPIC to ffff9000 (fec80000)
+mapped IOAPIC to ffff8000 (fec81000)
+mapped IOAPIC to ffff7000 (fec82000)
 Enabling fast FPU save and restore... done.
 Enabling unmasked SIMD FPU exception support... done.
 Initializing CPU#0
-CPU 0 irqstacks, hard=c0508000 soft=c04e8000
+CPU 0 irqstacks, hard=c050e000 soft=c04ee000
 PID hash table entries: 4096 (order: 12, 16384 bytes)
-Detected 3192.172 MHz processor.
+Detected 3192.148 MHz processor.
 Console: colour VGA+ 80x25
+console [tty0] enabled
 Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
 Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
-Memory: 1033592k/1048224k available (2456k kernel code, 14036k reserved, 
1265k data, 236k init, 130720k highmem)
+Memory: 1033564k/1048224k available (2453k kernel code, 14048k reserved, 
1305k data, 232k init, 130720k highmem)
 virtual kernel memory layout:
-    fixmap  : 0xffe16000 - 0xfffff000   (1956 kB)
+    fixmap  : 0xffe14000 - 0xfffff000   (1964 kB)
     pkmap   : 0xff800000 - 0xffc00000   (4096 kB)
     vmalloc : 0xf8800000 - 0xff7fe000   ( 111 MB)
     lowmem  : 0xc0000000 - 0xf8000000   ( 896 MB)
-      .init : 0xc04a8000 - 0xc04e3000   ( 236 kB)
-      .data : 0xc03660d1 - 0xc04a289c   (1265 kB)
-      .text : 0xc0100000 - 0xc03660d1   (2456 kB)
+      .init : 0xc04b1000 - 0xc04eb000   ( 232 kB)
+      .data : 0xc036544c - 0xc04ab97c   (1305 kB)
+      .text : 0xc0100000 - 0xc036544c   (2453 kB)
 Checking if this processor honours the WP bit even in supervisor mode... Ok.
 SLUB: Genslabs=22, HWalign=64, Order=0-1, MinObjects=4, CPUs=4, Nodes=1
 hpet0: at MMIO 0xfed00000, IRQs 2, 8, 0
 hpet0: 3 64-bit timers, 14318180 Hz
-Calibrating delay using timer specific routine.. 6388.07 BogoMIPS 
(lpj=3194038)
+Calibrating delay using timer specific routine.. 6388.11 BogoMIPS 
(lpj=3194056)
 Mount-cache hash table entries: 512
-CPU: After generic identify, caps: bfebfbff 20100000 00000000 00000000 
0000e43d 00000000 00000001
+CPU: After generic identify, caps: bfebfbff 20100000 00000000 00000000 
0000e43d 00000000 00000001 00000000
 monitor/mwait feature present.
 using mwait in idle threads.
 CPU: Trace cache: 12K uops, L1 D cache: 16K
 CPU: L2 cache: 2048K
 CPU: Physical Processor ID: 0
 CPU: Processor Core ID: 0
-CPU: After all inits, caps: bfebfbff 20100000 00000000 0000b180 0000e43d 
00000000 00000001
+CPU: After all inits, caps: bfebfbff 20100000 00000000 0000b180 0000e43d 
00000000 00000001 00000000
 Intel machine check architecture supported.
 Intel machine check reporting enabled on CPU#0.
 CPU0: Intel P4/Xeon Extended MCE MSRs (24) available
@@ -123,114 +126,81 @@
 ACPI: Core revision 20070126
 Parsing all Control Methods:
 Table [DSDT](id 0001) - 295 Objects with 44 Devices 111 Methods 8 Regions
- tbxface-0587 [02] tb_load_namespace     : ACPI Tables successfully acquired
-evxfevnt-0079 [02] enable                : System is already in ACPI mode
+ tbxface-0598 [00] tb_load_namespace     : ACPI Tables successfully acquired
+evxfevnt-0079 [00] enable                : System is already in ACPI mode
 CPU0: Intel(R) Xeon(TM) CPU 3.20GHz stepping 04
 Booting processor 1/1 eip 2000
-CPU 1 irqstacks, hard=c0509000 soft=c04e9000
+CPU 1 irqstacks, hard=c050f000 soft=c04ef000
 Initializing CPU#1
-Calibrating delay using timer specific routine.. 6383.70 BogoMIPS 
(lpj=3191853)
-CPU: After generic identify, caps: bfebfbff 20100000 00000000 00000000 
0000e43d 00000000 00000001
+Calibrating delay using timer specific routine.. 6383.75 BogoMIPS 
(lpj=3191875)
+CPU: After generic identify, caps: bfebfbff 20100000 00000000 00000000 
0000e43d 00000000 00000001 00000000
 monitor/mwait feature present.
 CPU: Trace cache: 12K uops, L1 D cache: 16K
 CPU: L2 cache: 2048K
 CPU: Physical Processor ID: 0
 CPU: Processor Core ID: 0
-CPU: After all inits, caps: bfebfbff 20100000 00000000 0000b180 0000e43d 
00000000 00000001
+CPU: After all inits, caps: bfebfbff 20100000 00000000 0000b180 0000e43d 
00000000 00000001 00000000
 Intel machine check architecture supported.
 Intel machine check reporting enabled on CPU#1.
 CPU1: Intel P4/Xeon Extended MCE MSRs (24) available
 CPU1: Thermal monitoring enabled
 CPU1: Intel(R) Xeon(TM) CPU 3.20GHz stepping 04
 Booting processor 2/2 eip 2000
-CPU 2 irqstacks, hard=c050a000 soft=c04ea000
+CPU 2 irqstacks, hard=c0510000 soft=c04f0000
 Initializing CPU#2
-Calibrating delay using timer specific routine.. 6383.76 BogoMIPS 
(lpj=3191884)
-CPU: After generic identify, caps: bfebfbff 20100000 00000000 00000000 
0000e43d 00000000 00000001
+Calibrating delay using timer specific routine.. 6383.77 BogoMIPS 
(lpj=3191888)
+CPU: After generic identify, caps: bfebfbff 20100000 00000000 00000000 
0000e43d 00000000 00000001 00000000
 monitor/mwait feature present.
 CPU: Trace cache: 12K uops, L1 D cache: 16K
 CPU: L2 cache: 2048K
 CPU: Physical Processor ID: 0
 CPU: Processor Core ID: 1
-CPU: After all inits, caps: bfebfbff 20100000 00000000 0000b180 0000e43d 
00000000 00000001
+CPU: After all inits, caps: bfebfbff 20100000 00000000 0000b180 0000e43d 
00000000 00000001 00000000
 Intel machine check architecture supported.
 Intel machine check reporting enabled on CPU#2.
 CPU2: Intel P4/Xeon Extended MCE MSRs (24) available
 CPU2: Thermal monitoring enabled
 CPU2: Intel(R) Xeon(TM) CPU 3.20GHz stepping 04
 Booting processor 3/3 eip 2000
-CPU 3 irqstacks, hard=c050b000 soft=c04eb000
+CPU 3 irqstacks, hard=c0511000 soft=c04f1000
 Initializing CPU#3
-Calibrating delay using timer specific routine.. 6383.78 BogoMIPS 
(lpj=3191894)
-CPU: After generic identify, caps: bfebfbff 20100000 00000000 00000000 
0000e43d 00000000 00000001
+Calibrating delay using timer specific routine.. 6383.75 BogoMIPS 
(lpj=3191876)
+CPU: After generic identify, caps: bfebfbff 20100000 00000000 00000000 
0000e43d 00000000 00000001 00000000
 monitor/mwait feature present.
 CPU: Trace cache: 12K uops, L1 D cache: 16K
 CPU: L2 cache: 2048K
 CPU: Physical Processor ID: 0
 CPU: Processor Core ID: 1
-CPU: After all inits, caps: bfebfbff 20100000 00000000 0000b180 0000e43d 
00000000 00000001
+CPU: After all inits, caps: bfebfbff 20100000 00000000 0000b180 0000e43d 
00000000 00000001 00000000
 Intel machine check architecture supported.
 Intel machine check reporting enabled on CPU#3.
 CPU3: Intel P4/Xeon Extended MCE MSRs (24) available
 CPU3: Thermal monitoring enabled
 CPU3: Intel(R) Xeon(TM) CPU 3.20GHz stepping 04
-Total of 4 processors activated (25539.33 BogoMIPS).
+Total of 4 processors activated (25539.39 BogoMIPS).
 ENABLING IO-APIC IRQs
 ..TIMER: vector=0x31 apic1=0 pin1=2 apic2=-1 pin2=-1
+APIC timer registered as dummy, due to nmi_watchdog=1!
 checking TSC synchronization [CPU#0 -> CPU#1]: passed.
 checking TSC synchronization [CPU#0 -> CPU#2]:
-Measured 972 cycles TSC warp between CPUs, turning off TSC clock.
+Measured 1056 cycles TSC warp between CPUs, turning off TSC clock.
 Marking TSC unstable due to: check_tsc_sync_source failed.
 Brought up 4 CPUs
-migration_cost=1000,2000
 NET: Registered protocol family 16
 ACPI: bus type pci registered
 PCI: Using MMCONFIG
 Setting up standard PCI resources
-evgpeblk-0952 [04] ev_create_gpe_block   : GPE 00 to 1F [_GPE] 4 regs on int 
0x9
-evgpeblk-1048 [03] ev_initialize_gpe_bloc: Found 1 Wake, Enabled 0 Runtime 
GPEs in this block
-Completing Region/Field/Buffer/Package initialization:....................
-Initialized 8/8 Regions 0/0 Fields 9/9 Buffers 3/4 Packages (304 nodes)
-Initializing Device/Processor/Thermal objects by executing _INI 
methods:[ACPI Debug]  String: [0x0B] "Method _INI"
-.
+evgpeblk-0956 [00] ev_create_gpe_block   : GPE 00 to 1F [_GPE] 4 regs on int 
0x9
+evgpeblk-1052 [00] ev_initialize_gpe_bloc: Found 1 Wake, Enabled 0 Runtime 
GPEs in this block
+ACPI: EC: Look up EC in DSDT
+Completing Region/Field/Buffer/Package initialization:.................
+Initialized 5/8 Regions 0/0 Fields 9/9 Buffers 3/4 Packages (304 nodes)
+Initializing Device/Processor/Thermal objects by executing _INI methods:.
 Executed 1 _INI methods requiring 0 _STA executions (examined 54 objects)
 ACPI: Interpreter enabled
+ACPI: (supports S0 S5)
 ACPI: Using IOAPIC for interrupt routing
-[ACPI Debug]  String: [0x04] "_PIC"
-[ACPI Debug]  Integer: 0x00000001
-[ACPI Debug]  String: [0x04] "SWZL"
-[ACPI Debug]  Integer: 0x00000000
-[ACPI Debug]  String: [0x09] "FDC _STA "
-[ACPI Debug]  String: [0x06] "LDN:  "
-[ACPI Debug]  Integer: 0x00000000
-[ACPI Debug]  Integer: 0x0000000D
-[ACPI Debug]  String: [0x09] "FDC _STA "
-[ACPI Debug]  String: [0x06] "LDN:  "
-[ACPI Debug]  Integer: 0x00000000
-[ACPI Debug]  Integer: 0x0000000D
-[ACPI Debug]  String: [0x0A] "COMA _STA "
-[ACPI Debug]  String: [0x06] "LDN:  "
-[ACPI Debug]  Integer: 0x00000004
-[ACPI Debug]  Integer: 0x0000000F
-[ACPI Debug]  String: [0x0A] "COMA _STA "
-[ACPI Debug]  String: [0x06] "LDN:  "
-[ACPI Debug]  Integer: 0x00000004
-[ACPI Debug]  Integer: 0x0000000F
-[ACPI Debug]  String: [0x0A] "COMB _STA "
-[ACPI Debug]  String: [0x06] "LDN:  "
-[ACPI Debug]  Integer: 0x00000005
-[ACPI Debug]  Integer: 0x0000000F
-[ACPI Debug]  String: [0x0A] "COMB _STA "
-[ACPI Debug]  String: [0x06] "LDN:  "
-[ACPI Debug]  Integer: 0x00000005
-[ACPI Debug]  Integer: 0x0000000F
-[ACPI Debug]  String: [0x0A] "KYBD _STA "
-[ACPI Debug]  Integer: 0x00000000
-[ACPI Debug]  String: [0x09] "MOU _STA "
-[ACPI Debug]  Integer: 0x00000000
 ACPI: PCI Root Bridge [PCI0] (0000:00)
-PCI: Dell PowerEdge 1950 detected, enabling pci=bfsort.
-PCI: Probing PCI hardware (bus 00)
 PCI: PXH quirk detected, disabling MSI for SHPC device
 PCI: PXH quirk detected, disabling MSI for SHPC device
 PCI: Transparent bridge - 0000:00:1e.0
@@ -257,55 +227,6 @@
 Linux Plug and Play Support v0.97 (c) Adam Belay
 pnp: PnP ACPI init
 ACPI: bus type pnp registered
-[ACPI Debug]  String: [0x0D] "HB0 _CRS.TOMR"
-[ACPI Debug]  String: [0x04] "Min:"
-[ACPI Debug]  Integer: 0x40000000
-[ACPI Debug]  String: [0x04] "Max:"
-[ACPI Debug]  Integer: 0xFDFFFFFF
-[ACPI Debug]  String: [0x07] "Length:"
-[ACPI Debug]  Integer: 0xBE000000
-[ACPI Debug]  Buffer: [0x6E]
-[ACPI Debug]  String: [0x09] "DMA_ _CRS"
-[ACPI Debug]  String: [0x08] "FPU _CRS"
-[ACPI Debug]  String: [0x0B] "SB_NMI _CRS"
-[ACPI Debug]  String: [0x08] "RTC _CRS"
-[ACPI Debug]  String: [0x09] "FDC _STA "
-[ACPI Debug]  String: [0x06] "LDN:  "
-[ACPI Debug]  Integer: 0x00000000
-[ACPI Debug]  Integer: 0x0000000D
-[ACPI Debug]  String: [0x09] "FDC _PRS "
-[ACPI Debug]  String: [0x0A] "COMA _STA "
-[ACPI Debug]  String: [0x06] "LDN:  "
-[ACPI Debug]  Integer: 0x00000004
-[ACPI Debug]  Integer: 0x0000000F
-[ACPI Debug]  String: [0x0A] "COMA _CRS "
-[ACPI Debug]  String: [0x06] "LDN:  "
-[ACPI Debug]  Integer: 0x00000004
-[ACPI Debug]  Integer: 0x00000003
-[ACPI Debug]  Integer: 0x000000F8
-[ACPI Debug]  String: [0x01] " "
-[ACPI Debug]  Integer: 0x00000010
-[ACPI Debug]  Buffer: [0x7B]
-[ACPI Debug]  String: [0x0A] "COMB _STA "
-[ACPI Debug]  String: [0x06] "LDN:  "
-[ACPI Debug]  Integer: 0x00000005
-[ACPI Debug]  Integer: 0x0000000F
-[ACPI Debug]  String: [0x0A] "COMB _CRS "
-[ACPI Debug]  String: [0x06] "LDN:  "
-[ACPI Debug]  Integer: 0x00000005
-[ACPI Debug]  Integer: 0x00000002
-[ACPI Debug]  Integer: 0x000000F8
-[ACPI Debug]  String: [0x01] " "
-[ACPI Debug]  Integer: 0x00000008
-[ACPI Debug]  Buffer: [0x7B]
-[ACPI Debug]  String: [0x0A] "KYBD _STA "
-[ACPI Debug]  Integer: 0x00000000
-[ACPI Debug]  String: [0x09] "MOU _STA "
-[ACPI Debug]  Integer: 0x00000000
-[ACPI Debug]  String: [0x09] "PEHB _CRS"
-[ACPI Debug]  Buffer: [0x1C]
-[ACPI Debug]  String: [0x09] "HPET _CRS"
-[ACPI Debug]  Buffer: [0x1C]
 pnp: PnP ACPI: found 12 devices
 ACPI: ACPI bus type pnp unregistered
 SCSI subsystem initialized
@@ -314,12 +235,20 @@
 usbcore: registered new device driver usb
 PCI: Using ACPI for IRQ routing
 PCI: If a device doesn't work, try "pci=routeirq".  If it helps, post a 
report
+Time: hpet clocksource has been installed.
+Clockevents: could not switch to one-shot mode: lapic is not functional.
+Could not switch to high resolution mode on CPU 0
+Clockevents: could not switch to one-shot mode:<6>Clockevents: could not 
switch to one-shot mode: lapic is not functional.
+ lapic is not functional.
+Could not switch to high resolution mode on CPU 2
+Could not switch to high resolution mode on CPU 3
+Clockevents: could not switch to one-shot mode: lapic is not functional.
+Could not switch to high resolution mode on CPU 1
 pnp: 00:08: ioport range 0x800-0x87f has been reserved
 pnp: 00:08: ioport range 0x880-0x8bf has been reserved
 pnp: 00:08: ioport range 0x8c0-0x8df has been reserved
 pnp: 00:08: ioport range 0x8e0-0x8e3 has been reserved
 pnp: 00:08: ioport range 0xc00-0xc7f has been reserved
-Time: hpet clocksource has been installed.
 pnp: 00:08: ioport range 0xca0-0xca7 has been reserved
 pnp: 00:08: ioport range 0xca9-0xcab has been reserved
 pnp: 00:08: ioport range 0xcad-0xcaf has been reserved
@@ -468,56 +397,51 @@
 assign_interrupt_mode Found MSI capability
 Allocate Port Service[0000:06:01.0:pcie20]
 Allocate Port Service[0000:06:01.0:pcie21]
-Evaluate _OSC Set fails. Status = 0x0005
-Evaluate _OSC Set fails. Status = 0x0005
-aer_init: AER service init fails - Run ACPI _OSC fails
-aer: probe of 0000:00:02.0:pcie01 failed with error 2
-Evaluate _OSC Set fails. Status = 0x0005
-Evaluate _OSC Set fails. Status = 0x0005
-aer_init: AER service init fails - Run ACPI _OSC fails
-aer: probe of 0000:00:03.0:pcie01 failed with error 2
-Evaluate _OSC Set fails. Status = 0x0005
-Evaluate _OSC Set fails. Status = 0x0005
-aer_init: AER service init fails - Run ACPI _OSC fails
-aer: probe of 0000:00:04.0:pcie01 failed with error 2
-aer_init: AER service init fails - No ACPI _OSC support
-aer: probe of 0000:00:05.0:pcie01 failed with error 1
-aer_init: AER service init fails - No ACPI _OSC support
-aer: probe of 0000:00:06.0:pcie01 failed with error 1
-aer_init: AER service init fails - No ACPI _OSC support
-aer: probe of 0000:00:07.0:pcie01 failed with error 1
+AER service couldn't init device 0000:00:02.0:pcie01 - no _OSC support
+AER service couldn't init device 0000:00:03.0:pcie01 - no _OSC support
+AER service couldn't init device 0000:00:04.0:pcie01 - no _OSC support
+AER service couldn't init device 0000:00:05.0:pcie01 - no _OSC support
+AER service couldn't init device 0000:00:06.0:pcie01 - no _OSC support
+AER service couldn't init device 0000:00:07.0:pcie01 - no _OSC support
+input: Power Button (FF) as /class/input/input0
+ACPI: Power Button (FF) [PWRF]
 Real Time Clock Driver v1.12ac
-[ACPI Debug]  String: [0x09] "HPET _CRS"
-[ACPI Debug]  Buffer: [0x1C]
 hpet_resources: 0xfed00000 is busy
-ACPI Error (utglobal-0126): Unknown exception code: 0xFFFFFFF0 [20070126]
 intel_rng: FWH not detected
 Hangcheck: starting hangcheck timer 0.9.0 (tick is 180 seconds, margin is 60 
seconds).
 Hangcheck: Using get_cycles().
-input: Power Button (FF) as /class/input/input0
-ACPI: Power Button (FF) [PWRF]
 Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled
+serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
+serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
 00:06: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
 00:07: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
+Clockevents: could not switch to one-shot mode:<6>Clockevents: could not 
switch to one-shot mode:<6>Clockevents: could not switch to one-shot mode: 
lapic is not functional.
+ lapic is not functional.
+Could not switch to high resolution mode on CPU 3
+Could not switch to high resolution mode on CPU 2
+Clockevents: could not switch to one-shot mode: lapic is not functional.
+Could not switch to high resolution mode on CPU 0
+ lapic is not functional.
+Could not switch to high resolution mode on CPU 1
 floppy0: no floppy controllers found
 RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
 loop: module loaded
-Broadcom NetXtreme II Gigabit Ethernet Driver bnx2 v1.5.11 (June 4, 2007)
-ACPI: PCI Interrupt 0000:04:00.0[A] -> GSI 16 (level, low) -> IRQ 16
-eth0: Broadcom NetXtreme II BCM5708 1000Base-T (B1) PCI-X 64-bit 133MHz 
found at mem f8000000, IRQ 16, node addr 001372f873ac
+Broadcom NetXtreme II Gigabit Ethernet Driver bnx2 v1.6.5 (September 20, 
2007)
 ACPI: PCI Interrupt 0000:08:00.0[A] -> GSI 16 (level, low) -> IRQ 16
-eth1: Broadcom NetXtreme II BCM5708 1000Base-T (B1) PCI-X 64-bit 133MHz 
found at mem f4000000, IRQ 16, node addr 001372f873ae
+eth0: Broadcom NetXtreme II BCM5708 1000Base-T (B1) PCI-X 64-bit 133MHz 
found at mem f4000000, IRQ 16, node addr 001372f873ae
+ACPI: PCI Interrupt 0000:04:00.0[A] -> GSI 16 (level, low) -> IRQ 16
+eth1: Broadcom NetXtreme II BCM5708 1000Base-T (B1) PCI-X 64-bit 133MHz 
found at mem f8000000, IRQ 16, node addr 001372f873ac
 Loading iSCSI transport class v2.0-724.
-Fusion MPT base driver 3.04.04
+Fusion MPT base driver 3.04.05
 Copyright (c) 1999-2007 LSI Logic Corporation
-Fusion MPT SPI Host driver 3.04.04
-Fusion MPT FC Host driver 3.04.04
-Fusion MPT SAS Host driver 3.04.04
+Fusion MPT SPI Host driver 3.04.05
+Fusion MPT FC Host driver 3.04.05
+Fusion MPT SAS Host driver 3.04.05
 PCI: Enabling device 0000:02:08.0 (0156 -> 0157)
 ACPI: PCI Interrupt 0000:02:08.0[A] -> GSI 64 (level, low) -> IRQ 17
 mptbase: Initiating ioc0 bringup
-ioc0: SAS1068: Capabilities={Initiator}
-scsi0 : ioc0: LSISAS1068, FwRev=00062800h, Ports=1, MaxQ=511, IRQ=17
+ioc0: LSISAS1068 B0: Capabilities={Initiator}
+scsi0 : ioc0: LSISAS1068 B0, FwRev=00062800h, Ports=1, MaxQ=511, IRQ=17
 scsi 0:0:0:0: Direct-Access     ATA      WDC WD800JD-75MS 1E04 PQ: 0 ANSI: 5
 sd 0:0:0:0: [sda] 156250000 512-byte hardware sectors (80000 MB)
 sd 0:0:0:0: [sda] Write Protect is off
@@ -530,7 +454,7 @@
  sda: sda1 sda2 sda3
 sd 0:0:0:0: [sda] Attached SCSI disk
 sd 0:0:0:0: Attached scsi generic sg0 type 0
-Fusion MPT misc device (ioctl) driver 3.04.04
+Fusion MPT misc device (ioctl) driver 3.04.05
 mptctl: Registered with Fusion MPT base driver
 mptctl: /dev/mptctl @ (major,minor=10,220)
 usbmon: debugfs is not available
@@ -576,12 +500,13 @@
 hub 1-5:1.0: USB hub found
 hub 1-5:1.0: 4 ports detected
 usbcore: registered new interface driver usblp
-drivers/usb/class/usblp.c: v0.13: USB Printer Device Class driver
 PNP: No PS/2 controller found. Probing ports directly.
 serio: i8042 KBD port at 0x60,0x64 irq 1
 serio: i8042 AUX port at 0x60,0x64 irq 12
 mice: PS/2 mouse device common for all mice
-EDAC MC: Ver: 2.0.1 Sep  4 2007
+EDAC MC: Ver: 2.1.0 Oct 10 2007
+EDAC MC0: Giving out device to 'i5000_edac.c' 'I5000': DEV 0000:00:10.0
+EDAC PCI0: Giving out device to module 'i5000_edac' controller 'EDAC PCI 
controller': DEV '0000:00:10.0' (POLLED)
 usb 3-2: new low speed USB device using uhci_hcd and address 2
 usb 3-2: configuration #1 chosen from 1 choice
 input: DELL DELL USB Keyboard as /class/input/input1
@@ -599,15 +524,21 @@
 EXT3-fs: recovery complete.
 EXT3-fs: mounted filesystem with ordered data mode.
 VFS: Mounted root (ext3 filesystem) readonly.
-Freeing unused kernel memory: 236k freed
+Freeing unused kernel memory: 232k freed
+net eth0_rename: device_rename: sysfs_create_symlink failed (-17)
+net eth0: device_rename: sysfs_create_symlink failed (-17)
+net eth1: device_rename: sysfs_create_symlink failed (-17)
 libata version 2.21 loaded.
-ata_piix 0000:00:1f.1: version 2.11
+ata_piix 0000:00:1f.1: version 2.12
 ACPI: PCI Interrupt 0000:00:1f.1[A] -> GSI 16 (level, low) -> IRQ 16
 PCI: Setting latency timer of device 0000:00:1f.1 to 64
 scsi1 : ata_piix
 scsi2 : ata_piix
 ata1: PATA max UDMA/100 cmd 0x000101f0 ctl 0x000103f6 bmdma 0x0001fc00 irq 14
 ata2: PATA max UDMA/100 cmd 0x00010170 ctl 0x00010376 bmdma 0x0001fc08 irq 15
+iTCO_wdt: Intel TCO WatchDog Timer Driver v1.02 (26-Jul-2007)
+iTCO_wdt: Found a 631xESB/632xESB TCO device (Version=2, TCOBASE=0x0860)
+iTCO_wdt: initialized. heartbeat=30 sec (nowayout=0)
 ata1.00: ATAPI: TEAC CD-ROM CD-224E-N, 3.AB, max UDMA/33
 ata1.00: configured for UDMA/33
 ata2: port disabled. ignoring.
@@ -621,17 +552,65 @@
 IPMI System Interface driver.
 ipmi_si: Trying SMBIOS-specified kcs state machine at i/o address 0xca8, 
slave address 0x20, irq 0
 ipmi: Found new BMC (man_id: 0x0002a2,  prod_id: 0x0100, dev_id: 0x20)
- IPMI kcs interface initialized
+IPMI kcs interface initialized
 ipmi device interface
+IPMI Watchdog: Unable to register misc device
 IPMI Watchdog: driver initialized
 Unable to find swap-space signature
 bnx2: eth1: using MSI
 bnx2: eth0: using MSI
-bnx2: eth0 NIC Link is Up, 1000 Mbps full duplex
 802.1Q VLAN Support v1.8 Ben Greear <greearb@candelatech.com>
 All bugs added by David S. Miller <davem@redhat.com>


--
Denys Fedoryshchenko
Technical Manager
Virtual ISP S.A.L.


^ permalink raw reply

* Re: [PATCH] division-by-zero in inet_csk_get_port
From: Anton Arapov @ 2007-10-10 12:49 UTC (permalink / raw)
  To: David Miller; +Cc: netdev
In-Reply-To: <20071010.030153.09951294.davem@davemloft.net>

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

David Miller <davem@davemloft.net> writes:
> From: Anton Arapov <aarapov@redhat.com>
> Date: Wed, 10 Oct 2007 11:56:23 +0200
>
>>   Yep, that's exactly I'm talking about. I'm sure that 
>>   [...] % (high - low) [...] erroneous from the begining, because
>> in such places we want to have 1 in denominator, for the cases when we
>> have only one port. Because 34000 34000 in sysctl's
>> ip_local_port_range means 1(one) port, not 0(zero).
>> 
>>   So it seems to me that we have to fix mentioned denominators in
>> kernel/net to have 1, that will be correct logically. And do the
>> MAX<MIN check in sysctl code.
>>   From this point of view, it's best idea to have two patches: one for
>> the kernel/net denominators and another one for the sysctl.c's
>> function dointvec_minmax(). Because they can live independently. And
>> the patch for the kernel/net will do the work at least because we
>> prevent kernel trap at all.
>>   
>>   Dave, am I right?
>
> Sure, two patches is fine.

  I have been mistaken. We can't modify sysctl code itself to do the
checks like (MAX_VAL < MIN_VAL), we have generic functions, and if we
want implement something like this we have to implement absolutely new
functionality, it's insane to do it. :)
  It seems to me, all we can is to make this check in code where the
MAX_VAL<MINVAL condition brakes logic.
  FTOH the patch that prevents do_divide_error trap is
enough... Kernel will keep working, with huge kernel panic notice in
dmesg. :)
  So, now the way suggested by Denis looks reasonable.

  What do you think?

-- 
Anton Arapov, <aarapov@redhat.com>
Kernel Development, Red Hat
GPG Key ID: 0x6FA8C812

[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]

^ permalink raw reply

* Re: [re] Possible 2.6.22 -> 2.6.23 HTB regression?
From: Patrick McHardy @ 2007-10-10 12:45 UTC (permalink / raw)
  To: Denys; +Cc: netdev
In-Reply-To: <20071010124510.M18768@visp.net.lb>

Denys wrote:
>>What does /proc/net/psched contain?
> 
> visp-1 ~ # cat /proc/net/psched
> 000003e8 00000400 000f4240 3b9aca00


OK, hrtimers are disabled on your system, but we still announce
the usec clock resolution to userspace, which is used by HTB to
calculate the burst rate. But actually that can't be the reason
since that has already been the case in 2.6.22. Please post a diff
of the bootlog from 2.6.22 and 2.6.23.


^ permalink raw reply

* [re] Possible 2.6.22 -> 2.6.23 HTB regression?
From: Denys @ 2007-10-10 12:45 UTC (permalink / raw)
  To: netdev; +Cc: kaber

> What does /proc/net/psched contain?
visp-1 ~ # cat /proc/net/psched
000003e8 00000400 000f4240 3b9aca00


--
Denys Fedoryshchenko
Technical Manager
Virtual ISP S.A.L.


^ permalink raw reply

* Re: Possible 2.6.22 -> 2.6.23 HTB regression?
From: Patrick McHardy @ 2007-10-10 12:38 UTC (permalink / raw)
  To: Denys; +Cc: netdev
In-Reply-To: <20071010123222.M71635@visp.net.lb>

Denys wrote:
>>>>>here is try to switch clocksource to acpi_pm
> 
> 
> Time: acpi_pm clocksource has been installed.
> Clockevents: could not switch to one-shot mode: lapic is not functional.
> Could not switch to high resolution mode on CPU 0


What does /proc/net/psched contain?

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox