Skip to content

Commit fa05f12

Browse files
author
Jens Axboe
committed
Update net/ to use sg helpers
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
1 parent 60c74f8 commit fa05f12

File tree

9 files changed

+25
-33
lines changed

9 files changed

+25
-33
lines changed

net/core/skbuff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,7 +2045,7 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
20452045
if (copy > 0) {
20462046
if (copy > len)
20472047
copy = len;
2048-
sg[elt].page = virt_to_page(skb->data + offset);
2048+
sg_set_page(&sg[elt], virt_to_page(skb->data + offset));
20492049
sg[elt].offset = (unsigned long)(skb->data + offset) % PAGE_SIZE;
20502050
sg[elt].length = copy;
20512051
elt++;
@@ -2065,7 +2065,7 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
20652065

20662066
if (copy > len)
20672067
copy = len;
2068-
sg[elt].page = frag->page;
2068+
sg_set_page(&sg[elt], frag->page);
20692069
sg[elt].offset = frag->page_offset+offset-start;
20702070
sg[elt].length = copy;
20712071
elt++;

net/ieee80211/ieee80211_crypt_tkip.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,7 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
390390
icv[3] = crc >> 24;
391391

392392
crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16);
393-
sg.page = virt_to_page(pos);
394-
sg.offset = offset_in_page(pos);
395-
sg.length = len + 4;
393+
sg_init_one(&sg, pos, len + 4);
396394
return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
397395
}
398396

@@ -485,9 +483,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
485483
plen = skb->len - hdr_len - 12;
486484

487485
crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
488-
sg.page = virt_to_page(pos);
489-
sg.offset = offset_in_page(pos);
490-
sg.length = plen + 4;
486+
sg_init_one(&sg, pos, plen + 4);
491487
if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
492488
if (net_ratelimit()) {
493489
printk(KERN_DEBUG ": TKIP: failed to decrypt "
@@ -539,11 +535,12 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr,
539535
printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n");
540536
return -1;
541537
}
542-
sg[0].page = virt_to_page(hdr);
538+
sg_init_table(sg, 2);
539+
sg_set_page(&sg[0], virt_to_page(hdr));
543540
sg[0].offset = offset_in_page(hdr);
544541
sg[0].length = 16;
545542

546-
sg[1].page = virt_to_page(data);
543+
sg_set_page(&sg[1], virt_to_page(data));
547544
sg[1].offset = offset_in_page(data);
548545
sg[1].length = data_len;
549546

net/ieee80211/ieee80211_crypt_wep.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,7 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
170170
icv[3] = crc >> 24;
171171

172172
crypto_blkcipher_setkey(wep->tx_tfm, key, klen);
173-
sg.page = virt_to_page(pos);
174-
sg.offset = offset_in_page(pos);
175-
sg.length = len + 4;
173+
sg_init_one(&sg, pos, len + 4);
176174
return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
177175
}
178176

@@ -212,9 +210,7 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
212210
plen = skb->len - hdr_len - 8;
213211

214212
crypto_blkcipher_setkey(wep->rx_tfm, key, klen);
215-
sg.page = virt_to_page(pos);
216-
sg.offset = offset_in_page(pos);
217-
sg.length = plen + 4;
213+
sg_init_one(&sg, pos, plen + 4);
218214
if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4))
219215
return -7;
220216

net/mac80211/wep.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@ void ieee80211_wep_encrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
138138
*icv = cpu_to_le32(~crc32_le(~0, data, data_len));
139139

140140
crypto_blkcipher_setkey(tfm, rc4key, klen);
141-
sg.page = virt_to_page(data);
142-
sg.offset = offset_in_page(data);
143-
sg.length = data_len + WEP_ICV_LEN;
141+
sg_init_one(&sg, data, data_len + WEP_ICV_LEN);
144142
crypto_blkcipher_encrypt(&desc, &sg, &sg, sg.length);
145143
}
146144

@@ -204,9 +202,7 @@ int ieee80211_wep_decrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
204202
__le32 crc;
205203

206204
crypto_blkcipher_setkey(tfm, rc4key, klen);
207-
sg.page = virt_to_page(data);
208-
sg.offset = offset_in_page(data);
209-
sg.length = data_len + WEP_ICV_LEN;
205+
sg_init_one(&sg, data, data_len + WEP_ICV_LEN);
210206
crypto_blkcipher_decrypt(&desc, &sg, &sg, sg.length);
211207

212208
crc = cpu_to_le32(~crc32_le(~0, data, data_len));

net/sctp/auth.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,8 @@ void sctp_auth_calculate_hmac(const struct sctp_association *asoc,
726726

727727
/* set up scatter list */
728728
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));
730731
sg.offset = (unsigned long)(auth) % PAGE_SIZE;
731732
sg.length = end - (unsigned char *)auth;
732733

net/sctp/sm_make_chunk.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,8 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
15131513
struct hash_desc desc;
15141514

15151515
/* 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));
15171518
sg.offset = (unsigned long)(&cookie->c) % PAGE_SIZE;
15181519
sg.length = bodysize;
15191520
keylen = SCTP_SECRET_SIZE;
@@ -1585,7 +1586,8 @@ struct sctp_association *sctp_unpack_cookie(
15851586

15861587
/* Check the signature. */
15871588
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));
15891591
sg.offset = (unsigned long)(bear_cookie) % PAGE_SIZE;
15901592
sg.length = bodysize;
15911593
key = (char *)ep->secret_key[ep->current_key];

net/sunrpc/auth_gss/gss_krb5_crypto.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ encryptor(struct scatterlist *sg, void *data)
197197
int i = (page_pos + outbuf->page_base) >> PAGE_CACHE_SHIFT;
198198
in_page = desc->pages[i];
199199
} else {
200-
in_page = sg->page;
200+
in_page = sg_page(sg);
201201
}
202-
desc->infrags[desc->fragno].page = in_page;
202+
sg_set_page(&desc->infrags[desc->fragno], in_page);
203203
desc->fragno++;
204204
desc->fraglen += sg->length;
205205
desc->pos += sg->length;
@@ -215,11 +215,11 @@ encryptor(struct scatterlist *sg, void *data)
215215
if (ret)
216216
return ret;
217217
if (fraglen) {
218-
desc->outfrags[0].page = sg->page;
218+
sg_set_page(&desc->outfrags[0], sg_page(sg));
219219
desc->outfrags[0].offset = sg->offset + sg->length - fraglen;
220220
desc->outfrags[0].length = fraglen;
221221
desc->infrags[0] = desc->outfrags[0];
222-
desc->infrags[0].page = in_page;
222+
sg_set_page(&desc->infrags[0], in_page);
223223
desc->fragno = 1;
224224
desc->fraglen = fraglen;
225225
} else {
@@ -287,7 +287,7 @@ decryptor(struct scatterlist *sg, void *data)
287287
if (ret)
288288
return ret;
289289
if (fraglen) {
290-
desc->frags[0].page = sg->page;
290+
sg_set_page(&desc->frags[0], sg_page(sg));
291291
desc->frags[0].offset = sg->offset + sg->length - fraglen;
292292
desc->frags[0].length = fraglen;
293293
desc->fragno = 1;

net/sunrpc/xdr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len,
10591059
do {
10601060
if (thislen > page_len)
10611061
thislen = page_len;
1062-
sg->page = buf->pages[i];
1062+
sg_set_page(sg, buf->pages[i]);
10631063
sg->offset = page_offset;
10641064
sg->length = thislen;
10651065
ret = actor(sg, data);

net/xfrm/xfrm_algo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc,
552552
if (copy > len)
553553
copy = len;
554554

555-
sg.page = virt_to_page(skb->data + offset);
555+
sg_set_page(&sg, virt_to_page(skb->data + offset));
556556
sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE;
557557
sg.length = copy;
558558

@@ -577,7 +577,7 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc,
577577
if (copy > len)
578578
copy = len;
579579

580-
sg.page = frag->page;
580+
sg_set_page(&sg, frag->page);
581581
sg.offset = frag->page_offset + offset-start;
582582
sg.length = copy;
583583

0 commit comments

Comments
 (0)