Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 224799
b: refs/heads/master
c: 0af55bb
h: refs/heads/master
i:
  224797: c6a32a0
  224795: a2ecbbf
  224791: aa5dfc2
  224783: ac3e211
  224767: 20004d2
v: v3
  • Loading branch information
Changli Gao authored and David S. Miller committed Dec 6, 2010
1 parent 430cd00 commit 9f13e2a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f7fce74e387e0563e5a165704664aa5ee8b2f48b
refs/heads/master: 0af55bb58f8fa7865004ac48d16affe125ac1b7f
36 changes: 19 additions & 17 deletions trunk/net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ struct packet_skb_cb {

#define PACKET_SKB_CB(__skb) ((struct packet_skb_cb *)((__skb)->cb))

static inline struct page *pgv_to_page(void *addr)
{
if (is_vmalloc_addr(addr))
return vmalloc_to_page(addr);
return virt_to_page(addr);
}

static void __packet_set_status(struct packet_sock *po, void *frame, int status)
{
union {
Expand All @@ -236,11 +243,11 @@ static void __packet_set_status(struct packet_sock *po, void *frame, int status)
switch (po->tp_version) {
case TPACKET_V1:
h.h1->tp_status = status;
flush_dcache_page(virt_to_page(&h.h1->tp_status));
flush_dcache_page(pgv_to_page(&h.h1->tp_status));
break;
case TPACKET_V2:
h.h2->tp_status = status;
flush_dcache_page(virt_to_page(&h.h2->tp_status));
flush_dcache_page(pgv_to_page(&h.h2->tp_status));
break;
default:
pr_err("TPACKET version not supported\n");
Expand All @@ -263,10 +270,10 @@ static int __packet_get_status(struct packet_sock *po, void *frame)
h.raw = frame;
switch (po->tp_version) {
case TPACKET_V1:
flush_dcache_page(virt_to_page(&h.h1->tp_status));
flush_dcache_page(pgv_to_page(&h.h1->tp_status));
return h.h1->tp_status;
case TPACKET_V2:
flush_dcache_page(virt_to_page(&h.h2->tp_status));
flush_dcache_page(pgv_to_page(&h.h2->tp_status));
return h.h2->tp_status;
default:
pr_err("TPACKET version not supported\n");
Expand Down Expand Up @@ -800,15 +807,11 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
__packet_set_status(po, h.raw, status);
smp_mb();
{
struct page *p_start, *p_end;
u8 *h_end = h.raw + macoff + snaplen - 1;

p_start = virt_to_page(h.raw);
p_end = virt_to_page(h_end);
while (p_start <= p_end) {
flush_dcache_page(p_start);
p_start++;
}
u8 *start, *end;

end = (u8 *)PAGE_ALIGN((unsigned long)h.raw + macoff + snaplen);
for (start = h.raw; start < end; start += PAGE_SIZE)
flush_dcache_page(pgv_to_page(start));
}

sk->sk_data_ready(sk, 0);
Expand Down Expand Up @@ -915,7 +918,6 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
}

err = -EFAULT;
page = virt_to_page(data);
offset = offset_in_page(data);
len_max = PAGE_SIZE - offset;
len = ((to_write > len_max) ? len_max : to_write);
Expand All @@ -934,11 +936,11 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
return -EFAULT;
}

page = pgv_to_page(data);
data += len;
flush_dcache_page(page);
get_page(page);
skb_fill_page_desc(skb,
nr_frags,
page++, offset, len);
skb_fill_page_desc(skb, nr_frags, page, offset, len);
to_write -= len;
offset = 0;
len_max = PAGE_SIZE;
Expand Down

0 comments on commit 9f13e2a

Please sign in to comment.