aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2007-10-22 13:44:26 -0400
committerJens Axboe <jens.axboe@oracle.com>2007-10-22 15:19:56 -0400
commitfa05f1286be25a8ce915c5dd492aea61126b3f33 (patch)
tree07d6d32733f3272d588410a64c0cfa25d794e3be
parent60c74f81933635bb4ccb4ee6f31909c51f5cd230 (diff)
Update net/ to use sg helpers
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r--net/core/skbuff.c4
-rw-r--r--net/ieee80211/ieee80211_crypt_tkip.c13
-rw-r--r--net/ieee80211/ieee80211_crypt_wep.c8
-rw-r--r--net/mac80211/wep.c8
-rw-r--r--net/sctp/auth.c3
-rw-r--r--net/sctp/sm_make_chunk.c6
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_crypto.c10
-rw-r--r--net/sunrpc/xdr.c2
-rw-r--r--net/xfrm/xfrm_algo.c4
9 files changed, 25 insertions, 33 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 70d9b5da96ae..4e2c84fcf276 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2045,7 +2045,7 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
2045 if (copy > 0) { 2045 if (copy > 0) {
2046 if (copy > len) 2046 if (copy > len)
2047 copy = len; 2047 copy = len;
2048 sg[elt].page = virt_to_page(skb->data + offset); 2048 sg_set_page(&sg[elt], virt_to_page(skb->data + offset));
2049 sg[elt].offset = (unsigned long)(skb->data + offset) % PAGE_SIZE; 2049 sg[elt].offset = (unsigned long)(skb->data + offset) % PAGE_SIZE;
2050 sg[elt].length = copy; 2050 sg[elt].length = copy;
2051 elt++; 2051 elt++;
@@ -2065,7 +2065,7 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
2065 2065
2066 if (copy > len) 2066 if (copy > len)
2067 copy = len; 2067 copy = len;
2068 sg[elt].page = frag->page; 2068 sg_set_page(&sg[elt], frag->page);
2069 sg[elt].offset = frag->page_offset+offset-start; 2069 sg[elt].offset = frag->page_offset+offset-start;
2070 sg[elt].length = copy; 2070 sg[elt].length = copy;
2071 elt++; 2071 elt++;
diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c
index 72e6ab66834f..c796661a021b 100644
--- a/net/ieee80211/ieee80211_crypt_tkip.c
+++ b/net/ieee80211/ieee80211_crypt_tkip.c
@@ -390,9 +390,7 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
390 icv[3] = crc >> 24; 390 icv[3] = crc >> 24;
391 391
392 crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); 392 crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16);
393 sg.page = virt_to_page(pos); 393 sg_init_one(&sg, pos, len + 4);
394 sg.offset = offset_in_page(pos);
395 sg.length = len + 4;
396 return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); 394 return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
397} 395}
398 396
@@ -485,9 +483,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
485 plen = skb->len - hdr_len - 12; 483 plen = skb->len - hdr_len - 12;
486 484
487 crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); 485 crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
488 sg.page = virt_to_page(pos); 486 sg_init_one(&sg, pos, plen + 4);
489 sg.offset = offset_in_page(pos);
490 sg.length = plen + 4;
491 if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { 487 if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
492 if (net_ratelimit()) { 488 if (net_ratelimit()) {
493 printk(KERN_DEBUG ": TKIP: failed to decrypt " 489 printk(KERN_DEBUG ": TKIP: failed to decrypt "
@@ -539,11 +535,12 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr,
539 printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); 535 printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n");
540 return -1; 536 return -1;
541 } 537 }
542 sg[0].page = virt_to_page(hdr); 538 sg_init_table(sg, 2);
539 sg_set_page(&sg[0], virt_to_page(hdr));
543 sg[0].offset = offset_in_page(hdr); 540 sg[0].offset = offset_in_page(hdr);
544 sg[0].length = 16; 541 sg[0].length = 16;
545 542
546 sg[1].page = virt_to_page(data); 543 sg_set_page(&sg[1], virt_to_page(data));
547 sg[1].offset = offset_in_page(data); 544 sg[1].offset = offset_in_page(data);
548 sg[1].length = data_len; 545 sg[1].length = data_len;
549 546
diff --git a/net/ieee80211/ieee80211_crypt_wep.c b/net/ieee80211/ieee80211_crypt_wep.c
index 8d182459344e..0af6103d715c 100644
--- a/net/ieee80211/ieee80211_crypt_wep.c
+++ b/net/ieee80211/ieee80211_crypt_wep.c
@@ -170,9 +170,7 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
170 icv[3] = crc >> 24; 170 icv[3] = crc >> 24;
171 171
172 crypto_blkcipher_setkey(wep->tx_tfm, key, klen); 172 crypto_blkcipher_setkey(wep->tx_tfm, key, klen);
173 sg.page = virt_to_page(pos); 173 sg_init_one(&sg, pos, len + 4);
174 sg.offset = offset_in_page(pos);
175 sg.length = len + 4;
176 return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); 174 return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
177} 175}
178 176
@@ -212,9 +210,7 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
212 plen = skb->len - hdr_len - 8; 210 plen = skb->len - hdr_len - 8;
213 211
214 crypto_blkcipher_setkey(wep->rx_tfm, key, klen); 212 crypto_blkcipher_setkey(wep->rx_tfm, key, klen);
215 sg.page = virt_to_page(pos); 213 sg_init_one(&sg, pos, plen + 4);
216 sg.offset = offset_in_page(pos);
217 sg.length = plen + 4;
218 if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) 214 if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4))
219 return -7; 215 return -7;
220 216
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c
index 6675261e958f..cc806d640f7a 100644
--- a/net/mac80211/wep.c
+++ b/net/mac80211/wep.c
@@ -138,9 +138,7 @@ void ieee80211_wep_encrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
138 *icv = cpu_to_le32(~crc32_le(~0, data, data_len)); 138 *icv = cpu_to_le32(~crc32_le(~0, data, data_len));
139 139
140 crypto_blkcipher_setkey(tfm, rc4key, klen); 140 crypto_blkcipher_setkey(tfm, rc4key, klen);
141 sg.page = virt_to_page(data); 141 sg_init_one(&sg, data, data_len + WEP_ICV_LEN);
142 sg.offset = offset_in_page(data);
143 sg.length = data_len + WEP_ICV_LEN;
144 crypto_blkcipher_encrypt(&desc, &sg, &sg, sg.length); 142 crypto_blkcipher_encrypt(&desc, &sg, &sg, sg.length);
145} 143}
146 144
@@ -204,9 +202,7 @@ int ieee80211_wep_decrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
204 __le32 crc; 202 __le32 crc;
205 203
206 crypto_blkcipher_setkey(tfm, rc4key, klen); 204 crypto_blkcipher_setkey(tfm, rc4key, klen);
207 sg.page = virt_to_page(data); 205 sg_init_one(&sg, data, data_len + WEP_ICV_LEN);
208 sg.offset = offset_in_page(data);
209 sg.length = data_len + WEP_ICV_LEN;
210 crypto_blkcipher_decrypt(&desc, &sg, &sg, sg.length); 206 crypto_blkcipher_decrypt(&desc, &sg, &sg, sg.length);
211 207
212 crc = cpu_to_le32(~crc32_le(~0, data, data_len)); 208 crc = cpu_to_le32(~crc32_le(~0, data, data_len));
diff --git a/net/sctp/auth.c b/net/sctp/auth.c
index 781810724714..cbd64b216cce 100644
--- a/net/sctp/auth.c
+++ b/net/sctp/auth.c
@@ -726,7 +726,8 @@ void sctp_auth_calculate_hmac(const struct sctp_association *asoc,
726 726
727 /* set up scatter list */ 727 /* set up scatter list */
728 end = skb_tail_pointer(skb); 728 end = skb_tail_pointer(skb);
729 sg.page = virt_to_page(auth); 729 sg_init_table(&sg, 1);
730 sg_set_page(&sg, virt_to_page(auth));
730 sg.offset = (unsigned long)(auth) % PAGE_SIZE; 731 sg.offset = (unsigned long)(auth) % PAGE_SIZE;
731 sg.length = end - (unsigned char *)auth; 732 sg.length = end - (unsigned char *)auth;
732 733
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index f983a369d4e2..d5a9785a158b 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1513,7 +1513,8 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
1513 struct hash_desc desc; 1513 struct hash_desc desc;
1514 1514
1515 /* Sign the message. */ 1515 /* Sign the message. */
1516 sg.page = virt_to_page(&cookie->c); 1516 sg_init_table(&sg, 1);
1517 sg_set_page(&sg, virt_to_page(&cookie->c));
1517 sg.offset = (unsigned long)(&cookie->c) % PAGE_SIZE; 1518 sg.offset = (unsigned long)(&cookie->c) % PAGE_SIZE;
1518 sg.length = bodysize; 1519 sg.length = bodysize;
1519 keylen = SCTP_SECRET_SIZE; 1520 keylen = SCTP_SECRET_SIZE;
@@ -1585,7 +1586,8 @@ struct sctp_association *sctp_unpack_cookie(
1585 1586
1586 /* Check the signature. */ 1587 /* Check the signature. */
1587 keylen = SCTP_SECRET_SIZE; 1588 keylen = SCTP_SECRET_SIZE;
1588 sg.page = virt_to_page(bear_cookie); 1589 sg_init_table(&sg, 1);
1590 sg_set_page(&sg, virt_to_page(bear_cookie));
1589 sg.offset = (unsigned long)(bear_cookie) % PAGE_SIZE; 1591 sg.offset = (unsigned long)(bear_cookie) % PAGE_SIZE;
1590 sg.length = bodysize; 1592 sg.length = bodysize;
1591 key = (char *)ep->secret_key[ep->current_key]; 1593 key = (char *)ep->secret_key[ep->current_key];
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c
index bfb6a29633dd..32be431affcf 100644
--- a/net/sunrpc/auth_gss/gss_krb5_crypto.c
+++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c
@@ -197,9 +197,9 @@ encryptor(struct scatterlist *sg, void *data)
197 int i = (page_pos + outbuf->page_base) >> PAGE_CACHE_SHIFT; 197 int i = (page_pos + outbuf->page_base) >> PAGE_CACHE_SHIFT;
198 in_page = desc->pages[i]; 198 in_page = desc->pages[i];
199 } else { 199 } else {
200 in_page = sg->page; 200 in_page = sg_page(sg);
201 } 201 }
202 desc->infrags[desc->fragno].page = in_page; 202 sg_set_page(&desc->infrags[desc->fragno], in_page);
203 desc->fragno++; 203 desc->fragno++;
204 desc->fraglen += sg->length; 204 desc->fraglen += sg->length;
205 desc->pos += sg->length; 205 desc->pos += sg->length;
@@ -215,11 +215,11 @@ encryptor(struct scatterlist *sg, void *data)
215 if (ret) 215 if (ret)
216 return ret; 216 return ret;
217 if (fraglen) { 217 if (fraglen) {
218 desc->outfrags[0].page = sg->page; 218 sg_set_page(&desc->outfrags[0], sg_page(sg));
219 desc->outfrags[0].offset = sg->offset + sg->length - fraglen; 219 desc->outfrags[0].offset = sg->offset + sg->length - fraglen;
220 desc->outfrags[0].length = fraglen; 220 desc->outfrags[0].length = fraglen;
221 desc->infrags[0] = desc->outfrags[0]; 221 desc->infrags[0] = desc->outfrags[0];
222 desc->infrags[0].page = in_page; 222 sg_set_page(&desc->infrags[0], in_page);
223 desc->fragno = 1; 223 desc->fragno = 1;
224 desc->fraglen = fraglen; 224 desc->fraglen = fraglen;
225 } else { 225 } else {
@@ -287,7 +287,7 @@ decryptor(struct scatterlist *sg, void *data)
287 if (ret) 287 if (ret)
288 return ret; 288 return ret;
289 if (fraglen) { 289 if (fraglen) {
290 desc->frags[0].page = sg->page; 290 sg_set_page(&desc->frags[0], sg_page(sg));
291 desc->frags[0].offset = sg->offset + sg->length - fraglen; 291 desc->frags[0].offset = sg->offset + sg->length - fraglen;
292 desc->frags[0].length = fraglen; 292 desc->frags[0].length = fraglen;
293 desc->fragno = 1; 293 desc->fragno = 1;
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 6a59180e1667..3d1f7cdf9dd0 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -1059,7 +1059,7 @@ xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len,
1059 do { 1059 do {
1060 if (thislen > page_len) 1060 if (thislen > page_len)
1061 thislen = page_len; 1061 thislen = page_len;
1062 sg->page = buf->pages[i]; 1062 sg_set_page(sg, buf->pages[i]);
1063 sg->offset = page_offset; 1063 sg->offset = page_offset;
1064 sg->length = thislen; 1064 sg->length = thislen;
1065 ret = actor(sg, data); 1065 ret = actor(sg, data);
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c
index 5ced62c19c63..fb2220a719bd 100644
--- a/net/xfrm/xfrm_algo.c
+++ b/net/xfrm/xfrm_algo.c
@@ -552,7 +552,7 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc,
552 if (copy > len) 552 if (copy > len)
553 copy = len; 553 copy = len;
554 554
555 sg.page = virt_to_page(skb->data + offset); 555 sg_set_page(&sg, virt_to_page(skb->data + offset));
556 sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE; 556 sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE;
557 sg.length = copy; 557 sg.length = copy;
558 558
@@ -577,7 +577,7 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc,
577 if (copy > len) 577 if (copy > len)
578 copy = len; 578 copy = len;
579 579
580 sg.page = frag->page; 580 sg_set_page(&sg, frag->page);
581 sg.offset = frag->page_offset + offset-start; 581 sg.offset = frag->page_offset + offset-start;
582 sg.length = copy; 582 sg.length = copy;
583 583