Merge pull request #71 from Masaq-/sheep_net

fixes for sheep_net kernel panic and memory leak
This commit is contained in:
asvitkine 2015-05-28 00:53:42 -04:00
commit 48b838e1cc

View File

@ -425,6 +425,11 @@ static ssize_t sheep_net_read(struct file *f, char *buf, size_t count, loff_t *o
* Driver write() function
*/
static inline void do_nothing(struct sk_buff *skb)
{
return;
}
static ssize_t sheep_net_write(struct file *f, const char *buf, size_t count, loff_t *off)
{
struct SheepVars *v = (struct SheepVars *)f->private_data;
@ -457,7 +462,9 @@ static ssize_t sheep_net_write(struct file *f, const char *buf, size_t count, lo
}
/* Transmit packet */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
atomic_add(skb->truesize, &v->skt->wmem_alloc);
#endif
skb->sk = v->skt;
skb->dev = v->ether;
skb->priority = 0;
@ -498,6 +505,7 @@ static ssize_t sheep_net_write(struct file *f, const char *buf, size_t count, lo
/* Outgoing packet (will be on the net) */
demasquerade(v, skb);
skb->destructor = do_nothing;
skb->protocol = PROT_MAGIC; /* Magic value (we can recognize the packet in sheep_net_receiver) */
dev_queue_xmit(skb);
return count;