tap.c (666c135b2d859a00ee74c8645b2affacfae45421) tap.c (37dfe5b8ddeb7c0bb97e3643dcfd8f9f1421ad25)
1// SPDX-License-Identifier: GPL-2.0-only
2#include <linux/etherdevice.h>
3#include <linux/if_tap.h>
4#include <linux/if_vlan.h>
5#include <linux/interrupt.h>
6#include <linux/nsproxy.h>
7#include <linux/compat.h>
8#include <linux/if_tun.h>

--- 520 unchanged lines hidden (view full) ---

529 goto err;
530 }
531
532 init_waitqueue_head(&q->sock.wq.wait);
533 q->sock.type = SOCK_RAW;
534 q->sock.state = SS_CONNECTED;
535 q->sock.file = file;
536 q->sock.ops = &tap_socket_ops;
1// SPDX-License-Identifier: GPL-2.0-only
2#include <linux/etherdevice.h>
3#include <linux/if_tap.h>
4#include <linux/if_vlan.h>
5#include <linux/interrupt.h>
6#include <linux/nsproxy.h>
7#include <linux/compat.h>
8#include <linux/if_tun.h>

--- 520 unchanged lines hidden (view full) ---

529 goto err;
530 }
531
532 init_waitqueue_head(&q->sock.wq.wait);
533 q->sock.type = SOCK_RAW;
534 q->sock.state = SS_CONNECTED;
535 q->sock.file = file;
536 q->sock.ops = &tap_socket_ops;
537 sock_init_data_uid(&q->sock, &q->sk, current_fsuid());
537 sock_init_data_uid(&q->sock, &q->sk, inode->i_uid);
538 q->sk.sk_write_space = tap_sock_write_space;
539 q->sk.sk_destruct = tap_sock_destruct;
540 q->flags = IFF_VNET_HDR | IFF_NO_PI | IFF_TAP;
541 q->vnet_hdr_sz = sizeof(struct virtio_net_hdr);
542
543 /*
544 * so far only KVM virtio_net uses tap, enable zero copy between
545 * guest kernel and host kernel when lower device supports zerocopy

--- 63 unchanged lines hidden (view full) ---

609 int noblock, int *err)
610{
611 struct sk_buff *skb;
612
613 /* Under a page? Don't bother with paged skb. */
614 if (prepad + len < PAGE_SIZE || !linear)
615 linear = len;
616
538 q->sk.sk_write_space = tap_sock_write_space;
539 q->sk.sk_destruct = tap_sock_destruct;
540 q->flags = IFF_VNET_HDR | IFF_NO_PI | IFF_TAP;
541 q->vnet_hdr_sz = sizeof(struct virtio_net_hdr);
542
543 /*
544 * so far only KVM virtio_net uses tap, enable zero copy between
545 * guest kernel and host kernel when lower device supports zerocopy

--- 63 unchanged lines hidden (view full) ---

609 int noblock, int *err)
610{
611 struct sk_buff *skb;
612
613 /* Under a page? Don't bother with paged skb. */
614 if (prepad + len < PAGE_SIZE || !linear)
615 linear = len;
616
617 if (len - linear > MAX_SKB_FRAGS * (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER))
618 linear = len - MAX_SKB_FRAGS * (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER);
617 skb = sock_alloc_send_pskb(sk, prepad + linear, len - linear, noblock,
619 skb = sock_alloc_send_pskb(sk, prepad + linear, len - linear, noblock,
618 err, 0);
620 err, PAGE_ALLOC_COSTLY_ORDER);
619 if (!skb)
620 return NULL;
621
622 skb_reserve(skb, prepad);
623 skb_put(skb, linear);
624 skb->data_len = len - linear;
625 skb->len += len - linear;
626

--- 775 unchanged lines hidden ---
621 if (!skb)
622 return NULL;
623
624 skb_reserve(skb, prepad);
625 skb_put(skb, linear);
626 skb->data_len = len - linear;
627 skb->len += len - linear;
628

--- 775 unchanged lines hidden ---