clen = (clen + esp->conf.padlen-1)&~(esp->conf.padlen-1); 
clen = ALIGN(clen, esp->conf.padlen); 
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_tfm *tfm;	struct esp_data *esp;	struct sk_buff *trailer;	int blksize;	int clen;	int alen;	int nfrags;	/* Strip IP+ESP header. */	__skb_pull(skb, skb->h.raw - skb->data);	/* Now skb is pure payload to encrypt */	err = -ENOMEM;	/* Round to block size */	clen = skb->len;	esp = x->data;	alen = esp->auth.icv_trunc_len;	tfm = esp->conf.tfm;	blksize = (crypto_tfm_alg_blocksize(tfm) + 3) & ~3;	clen = (clen + 2 + blksize-1)&~(blksize-1);	if (esp->conf.padlen)		clen = (clen + esp->conf.padlen-1)&~(esp->conf.padlen-1);	if ((nfrags = skb_cow_data(skb, clen-skb->len+alen, &trailer)) < 0)		goto error;	/* Fill padding... */	do {		int i;		for (i=0; i<clen-skb->len - 2; i++)			*(u8*)(trailer->tail + i) = i+1;	} while (0);	*(u8*)(trailer->tail + clen-skb->len - 2) = (clen - skb->len)-2;	pskb_put(skb, trailer, clen - skb->len);	__skb_push(skb, skb->data - skb->nh.raw);	top_iph = skb->nh.iph;	esph = (struct ip_esp_hdr *)(skb->nh.raw + top_iph->ihl*4);	top_iph->tot_len = htons(skb->len + alen);	*(u8*)(trailer->tail - 1) = top_iph->protocol;	/* this is non-NULL only with UDP Encapsulation */	if (x->encap) {		struct xfrm_encap_tmpl *encap = x->encap;		struct udphdr *uh;		u32 *udpdata32;		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->check = 0;		switch (encap->encap_type) {		default:		case UDP_ENCAP_ESPINUDP:			esph = (struct ip_esp_hdr *)(uh + 1);			break;		case UDP_ENCAP_ESPINUDP_NON_IKE:			udpdata32 = (u32 *)(uh + 1);			udpdata32[0] = udpdata32[1] = 0;			esph = (struct ip_esp_hdr *)(udpdata32 + 2);			break;		}		top_iph->protocol = IPPROTO_UDP;	} else		top_iph->protocol = IPPROTO_ESP;	esph->spi = x->id.spi;	esph->seq_no = htonl(++x->replay.oseq);	if (esp->conf.ivlen)		crypto_cipher_set_iv(tfm, esp->conf.ivec, crypto_tfm_alg_ivsize(tfm));	do {		struct scatterlist *sg = &esp->sgbuf[0];		if (unlikely(nfrags > ESP_NUM_FAST_SG)) {			sg = kmalloc(sizeof(struct scatterlist)*nfrags, GFP_ATOMIC);			if (!sg)				goto error;		}		skb_to_sgvec(skb, sg, esph->enc_data+esp->conf.ivlen-skb->data, clen);		crypto_cipher_encrypt(tfm, sg, sg, clen);		if (unlikely(sg != &esp->sgbuf[0]))			kfree(sg);	} while (0);	if (esp->conf.ivlen) {		memcpy(esph->enc_data, esp->conf.ivec, crypto_tfm_alg_ivsize(tfm));		crypto_cipher_get_iv(tfm, esp->conf.ivec, crypto_tfm_alg_ivsize(tfm));	}	if (esp->auth.icv_full_len) {		esp->auth.icv(esp, skb, (u8*)esph-skb->data,		              sizeof(struct ip_esp_hdr) + esp->conf.ivlen+clen, trailer->tail);		pskb_put(skb, trailer, alen);	}	ip_send_check(top_iph);	err = 0;error:	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/a02a64223eddb410712b015fb3342c9a316ab70b/esp4.c/buggy/net/ipv4/esp4.c