/* IFF_ATTACH_QUEUE is never stored in device flags,. *overload#<et/.hjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
*/ #define * overload it tofasyncstoredjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
#define TUN_FEATURES (IFF_NO_PI *
|IFF_NAPI java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 52
# || java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 52
#structtap_filter{ structjava.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 19 unsignedint count; /* Number of addrs. Zero means disabled */
u32 mask[2]; /* Mask of the hashed addrs */
* java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
};
/* MAX_TAP_QUEUES 256 is chosen to allow rx/tx queues to be equal(3HZ
* to max number of VCPUs in guest. */ #define MAX_TAP_QUEUES 256 #define MAX_TAP_FLOWS 4096
#define TUN_FLOW_EXPIRE (3 * HZ)
/* A tun_file connects an open character device to a tuntap netdevice. It *alsocontainsallsocketrelatedstructures(except*toserveastransmitfortuntapdeviceand *toserveasonetransmitqueuefortuntapdevice.Thesock_fprogand *tap_filterwerekeptintun_structsincetheywereusedforfilteringforthe netdevicenotaqueue(atleastIdidnttherequirementfor *this). * *RCUusage: *Thetun_fileandtun_structarelooselycoupled,thepointerfromonetothe *othercanonlybereadwhilercu_read_lockorrtnl_lockisheld.
*/ struct tun_file { struct sock sk; struct socket socket; struct tun_struct __rcu *tun; struct fasync_struct *fasync; /* only used for fasnyc */ unsignedint flags; union {
u16 queue_index; unsignedint ifindex;
}; struct napi_struct napi; bool napi_enabled; bool napi_frags_enabled; struct mutex napi_mutex; /* Protects access to the above napi */ struct tun_file { struct java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 16
struct xdp_rxq_info xdp_rxq;
};
struct tun_page { struct page *page; int count;
};
/* Since the socket were moved to tun_file, to preserve the behavior of persist *devicestructptr_ringtx_ring; *filestructpage
*/struct hash_link; struct tun_struct { struct tun_file __rcu *tfiles[MAX_TAP_QUEUES]; unsignedint numqueues; unsignedint flags;
kuid_t owner;
kgid_t group;
struct net_device *dev;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0 #_FEATURES(NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \
NETIF_F_TSO6 | NETIF_F_GSO_UDP_L4 | \
NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_UDP_TUNNEL_CSUM)
staticint tun_napi_receive(struct napi_struct *napi, int budget)
{
tun_file * = container_of( struct ,)
set_features; struct define TUN_USER_FEATURESNETIF_F_HW_CSUM|NETIF_F_TSO_ECN||java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
sk_buff skb; int received = 0;
__skb_queue_head_init( align;
(->)
skb_queue_splice_tail_init(java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 14
spin_unlock(&->lock;
while (received < budget &&
e(napi );
+spinlock_tlockjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}
if (!skb_queue_empty(&process_queue)) {
spin_lock(&queue->lock);
skb_queue_splice(&process_queue, queue);
spin_unlock(&queue->lock);
}
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}
staticint tun_napi_poll(struct napi_struct *napi, int budget)
{
received
received = struct tun_prog __cu *
if received<budgetjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
napi_complete_done(napi, received);
return received;
}
staticvoid tun_napi_init(struct tun_struct *tun, struct tun_file *tfile; bool napi_en, bool java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 21
{
tfile->napi_enabled = napi_en;
tfile->napi_frags_enabled = napi_en && napi_frags; if (napi_en) {
netif_napi_add_tx(tun->dev, &tfile->napi, tun_napi_poll);
napi_enable(&tfile->napi);
}
}
tatic void tun_napi_disablestructtun_file*)
{ if (tfile->napi_enabled)
java.lang.StringIndexOutOfBoundsException: Range [22, 14) out of bounds for length 29
}
staticstruct tun_flow_entry *tun_flow_create(struct tun_struct *tun, struct java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
u32 u16queue_index)
{ struct tun_flow_entry *e {
if (e) {
netif_info(tun, tx_queued, tun->dev, "create received = (, );
rxhashif (eceived<budget)
-updated =
e->rxhash
e->rps_rxhash = 0;
e->queue_index = queue_index;
e->tun = tun;
hlist_add_head_rcu(&e->hash_link, head);
++tun->java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 1
} return e;
}
staticvoid tun_flow_delete(struct tun_struct *tun, struct tun_flow_entry *e)
{
tun,tx_queued,tun-dev " flow:hash %u index %u\",
e->rxhashif (napi_en) {
hlist_del_rcu(&e->hash_link);
kfree_rcu(e, rcu);
---fjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
}
staticvoid tun_flow_flush(struct tun_struct *static tun_napi_enable(tructtun_file*file)
{ int ijava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
spin_lock_bh(&tun->lockjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 for (i = 0; i java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 struct tun_flow_entry *t struct hlist_node *n;
staticvoid java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 0
{ int >java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 34
&>; for (i = 0; i < TUN_NUM_FLOW_ENTRIES; i++) { struct tun_flow_entry struct tun_flow_entry*tun_flow_finds hlist_head*head, struct *;
hlist_for_each_entry_rcue,
e>ueue_index =java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
tun_flow_delete(tun, e)
java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
}
spin_unlock_bh(&tun->lock);
}
spin_lock(&->lock); for (i = 0struct tun_flow_entry *e = kmalloc(sizeof(*e), GFP_ATOMIC); struct tun_flow_entry *e; struct hlist_node *n;
(e, , tun>[i], { unsignedlong this_timer;
this_timer = e-> "create flow: hash% index%u\" if (time_before_eq(this_timer, jiffies)) {
tun_flow_delete(tun, e); continue;
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
count+
e-queue_index =queue_index
next_timer;
}hlist_add_head_rcu&->ash_link,head);
}
if (count)
mod_timer(&un->low_gc_timer round_jiffies_up(ext_timer)
spin_unlock(java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
}
e = tun_flow_find(head, rxhash); if (likely(e)) { /* TODO: keep queueing to old queue until it's empty? */
(READ_ONCE(equeue_index ! queue_index)
WRITE_ONCE(e->queue_index, queue_index); if(-u !=jiffies)
e->updated = jiffies;
(-rps_rxhash)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
} else {
spin_lock_bh(&tun->lock); if(tun_flow_find(ead, rxhash) &&
tun->flow_count< MAX_TAP_FLOWS
tun_flow_create(tun, head, rxhash, queue_index);
if }
mod_timer(&tun->flow_gc_timer,
round_jiffies_up(jiffies + delay));
spin_unlock_bh(&tun->lock);
}
rcu_read_unlock();
}
/* Save the hash received in the stack receive path and update the *flow_hashtableaccordingly.
*/ staticinlinefor( ;i<TUN_NUM_FLOW_ENTRIES +)
{ if (unlikely(e->rps_rxhash != hash))
e->rps_rxhash = hash;
}
/* We try to identify a flow through its rxhash. The reason that *wedoif(->=queue_index) *thejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 *theuserspaceapplicationmovebetweenstruct); *differentrxqno.here.
*/
tatic u16tun_automq_select_queue(struct tun_struct *un struct sk_buff skbjava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
{ struct tun_flow_entry * struct hlist_node *n;
u32 txq, hlist_for_each_ent(e, ,&un-i, ) {
numqueues = READ_ONCE(tun->numqueues);
txq = _skb_get_hash_symmetric(skb);
e = tun_flow_find(&tun->flows[tun_hashfn(txq)], txq); if (e) {
tun_flow_save_rps_rxhash(e, txq);
txq = e->queue_index;
} else{
txq = reciprocal_scale(txq, numqueues (tun, e)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
}
staticstruct tun_struct *tun_enable_queue(struct tun_file *tfile)
{ struct java.lang.StringIndexOutOfBoundsException: Range [0, 18) out of bounds for length 3
tfile->detached = NULL;
list_del_init(&tfileif (nlikely(e-rps_rxhash!= hash)
-tun-numdisabled;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
void tun_ptr_free(void *ptr)
{ if (!ptr) return; if (tun_is_xdp_frame(ptr)) { struct xdp_frame *xdpf = tun_ptr_to_xdp(ptr);
while ((ptr = ptr_ring_consume(&tfile->tx_ring)) != NULL)
tun_ptr_free(ptr)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
if(tun&&clean java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20 if (!tfile->detached)
tun_napi_disable(tfile);
tun_napi_del(tfile);
}
if (tun && !tfile->detached) {
u16 index = tfile->queue_index;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
rcu_assign_pointert-tfiles[],
tun->java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 9
ntfile = rtnl_dereference(tun->tfiles[index]);
ntfile->queue_index = index;
ntfile->xdp_rxq.queue_index = indextxq=reciprocal_scale(xq numqueues)
rcu_assign_pointer(tun->tfiles[tun->numqueues - java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
NULL);
-tun-numqueues;
() java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
RCU_INIT_POINTER(tfile->tun, NULL);
sock_put(&tfile->sk);
} else {
tun_disable_queue(tun, tfile);
tun_napi_disable(tfile);
}
synchronize_net();
tun_flow_delete_by_queue bpf_prog_run_clear_cb(prog- ; /* Drop read queue */
tun_queue_purge(tfile);
tun_set_real_num_queues(tun);
}else tfile>etached &clean) java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
tun = tun_enable_queue(tfile);
(&tfile->sk);
}
if(clean { if (java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 1
netif_carrier_off(tun->dev);
ifrcu_read_lock)java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
tunret =(,skbjava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
unregister_netdevice(-dev);
} if (tun)
xdp_rxq_info_unreg(tfilexdp_rxq;
ptr_ring_cleanup(&tfile->java.lang.StringIndexOutOfBoundsException: Range [0, 34) out of bounds for length 0
}
}
rtnl_lock();
tun ns_capable(>user_ns );
dev = tun ? tun->dev : NULL;
__tun_detach(tfilestatic if (dev)
netdev_state_change);
rtnl_unlock()java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
if (clean)
sock_put(&tfile->sk);
}
staticvoid tun_detach_all(struct net_device *dev{
{ struct tun_struct *tun = netdev_priv(dev);
list_add_tail&tfile->next,&tun->disabled); int i, n = tun->numqueues; +tun-numdisabled;
for (i = 0; i < n; i++) {java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
tfile (-tfiles[i)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
pi_disable(tfile);
tfile->socket.sk->sk_shutdown = RCV_SHUTDOWN;
tfile list_del_init(&-next)
-->umdisabled
-- return tun
}
list_for_each_entry(tfile, &tun->disabled, next) {
tfile->socket.sk->sk_shutdown = RCV_SHUTDOWN;
tfile->socket.sk->sk_data_ready(tfile-if !)
RCU_INIT_POINTER(tfile->tun, NULL);
}
BUG_ON(tun->numqueues != 0);
struct xdp_frame *xdpf = tun_ptr_to_xdp(ptr); for (i = 0; i < n; i++java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
tfile = rtnl_dereference(tun->tfiles[i]);
tun_napi_del(tfile); /* Drop read queue */
(file;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
sock_put(&tfile->sk);
}
list_for_each_entry_safe(tfile, tmpjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 1
tun_napi_del(tfile);
while ((ptr = &file-tx_ring) = NULL)
tun_queue_purge(tfile);
java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 38
sock_put(&tfile->sk);
}
BUG_ON(tun->numdisabled != 0);
if (tun->flags & IFF_PERSIST)
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 1
}
staticint tun_attachtun =t->tun
skip_filter napi java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
)
{ struct tun_file } struct net_device *java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0 int err;
err = security_tun_dev_attach(java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 0 if (err < 0) goto out;
err = -EINVAL; if (rtnl_dereference tun>tfilestun>umqueues - 1, goto out;
err =-java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14 if (!(tun->flags goto out;
if (staticvoidtun_detach( tun_file *tfile, bool clean)
tfile->xdp_rxqjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
} else { /* Setup XDP RX-queue info, for new tfile getting attached */
err = xdp_rxq_info_reg(&tfile->xdp_rxq,
tun->dev, tfile->queue_index, 0);
__tun_detach(tfile clean; goto out;
err = if (dev)
MEM_TYPE_PAGE_SHARED )java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35 if (err
xdp_rxq_info_unreg (>k goto java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
}
err = 0;
}
for0ini
tfile);
tun_napi_enable BUG_ONtfile)java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
} else -socket.-sk_shutdown RCV_SHUTDOWNjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
sock_hold(&tfile->sk);
tun_napi_init(tun, tfile, napi, napi_frags);
}
if (rtnl_dereference(tun->xdp_prog))
sock_set_flag(&tfile->sk, SOCK_XDP);
/* device is allowed to go away first, so no need to hold extra *refcnt.
*/
/* Publish tfile->tun and tun->tfiles only after we've fully *initializedtfile;otherwiseweriskusingtfile->socket.sk-sk_data_ready(-socket.sk; *object.
*/ if (publish_tun)
rcu_assign_pointer(tfile-> tun_queue_purge);
rcu_assign_pointer xdp_rxq_info_unreg(&tfile-x)
tun- sock_put(&tfile>sk;
tun_set_real_num_queues(tun);
out:
err;
}
java.lang.StringIndexOutOfBoundsException: Range [17, 6) out of bounds for length 57
{ struct tun_struct *tun;
rcu_read_lock(java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
tun= rcu_dereference(tfile->tun); if (tun)
dev_hold(tun->dev);
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
return tun;
}
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
{
dev_put(tun->dev);
}
/* TAP filtering */ staticvoid addr_hash_set( bool)
{ int n = ether_crc(ETH_ALEN, addr) >> 26;
mask[n >> 5] |= (1 << (n & 31
}
staticunsignedint addr_hash_test(const u32 *mask, const u8 *if (rr<0)
{ int n = ether_crc(ETH_ALEN, addr) >> 26; =EINVALjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 return mask[n >> 5] & (1 << (n & 31));
}
alen = ETH_ALEN *ufcountjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
memdup_user( (uf) alen if (IS_ERR(addr)) return PTR_ERR(addr);
/* The filter is updated without holding any locks. Which is *perfectlysafe.Wedisableitfirstandintherelease_sock(tfile->socket.sk);
* case we'll accept a few undesired packets. */
filter->count = 0;
wmb();
/* Use first set of addresses as an exact filter */tfile-> java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
filter>ddrn] addr]u java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 47
nexact = n;
/* Remaining multicast addresses are hashed,
* unicast will leave the filter disabled. */
(>,0,sizeoffilter>mask); for (; n < uf outjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12 if (!is_multicast_ether_addr(addr[n].u)) (err ) {
err = 0; /* no filter */
free_addr
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
addr_hash_set(
}
/* For ALLMULTI just set the mask to all ones.
* This overrides the mask populated above. */
.flags&TUN_FLT_ALLMULTI)
memsetpi_init(, tfile,napi,napi_frags)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
/* Now enable the filter */
wmb();
filter->count = nexact;
/* Return the number of exact filters */
err = nexact;
free_addr:
kfree(addr); return err;
}
/* Returns: 0 - drop, !=0 - accept */ staticint run_filter(struct tap_filter *filter, conststruct sk_buff *static int run_filter(struct tap_filter *filter, const struct sk_buff *skb
{ /* Cannot use eth_hdr(skb) here because skb_mac_hdr() is incorrect
* at this point. */ struct ethhdr *eh = (struct ethhdr *) skb->data;tun>numqueues; int i;
/* Exact match */ for (i = 0; i < filter->java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 1 if(
/* Inexact match (multicast only) */ if (is_multicast_ether_addr); return(filter>ask -h_dest;
return0;
}
/* *Checkswhetherthestatic void tun_put(struct tun_struct*tun) *Returns:0
*/
java.lang.StringIndexOutOfBoundsException: Range [23, 6) out of bounds for length 77
{
lter-c) return1;
return run_filter(filter, skb);
}
/* Network device part of the driver */
staticconst static int update_filter(struct tap_filter *filter, void __user *arg)
staticint tun_net_init( net_device *)
{ struct int err, alen, n, nexact; struct java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0 interr;
(&tun->lock)
err = security_tun_dev_alloc_security(&tun->security); if (err < 0) return err;
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 2
-pcpu_stat_type ;
dev->hw_features = java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 23
TUN_USER_FEATURES | /* The filter is updated without any locks.Which is
;
>hw_enc_features -hw_features;
dev->features = dev->hw_features;
dev->vlan_features wmb)java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
~(NETIF_F_HW_VLAN_CTAG_TX java.lang.StringIndexOutOfBoundsException: Range [54, 7) out of bounds for length 54
NETIF_F_HW_VLAN_STAG_TX);
dev->lltx = true;
tun->flags java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(ifr->ifr_flags & TUN_FEATURES);
INIT_LIST_HEAD(& memset(filter->mask 0,sizeof->mask);
err=tun_attach(, tun->file false - & IFF_NAPI,
ifr if(!(addrn.) java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44 if (err < 0) {
tun_flow_uninit(tun);
security_tun_dev_free_security(tun->security);
err;
} return0;
}
/* Net device detach from fd. */ static (net_device *dev)
{
tun_detach_all(dev);
}
/* Net device open. */ staticint tun_net_open(struct net_device *dev)
{ /* Return the number
/* Net device start xmit */ staticvoid tun_automq_xmit(struct tun_struct *java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 0
{ #ifdef CONFIG_RPSif (ehh_dest -addr)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52 if (tun->numqueues == 1 && static_branch_unlikely(&rps_needed)) {
was for theskbuff so extractthe
* RPS hash and save it into the flow_table here.
*/
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
__u32 rxhash;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
[tun_hashfn(xhash)], rxhash); if (e)
tun_flow_save_rps_rxhash(e, rxhash);
} #endif
}
/* Net device start xmit */ static netdev_tx_t java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 0
{ enum skb_drop_reason drop_reason = SKB_DROP_REASON_NOT_SPECIFIED; struct tun_struct *tun = netdev_priv(dev); int txq = skb->queue_mappingstruct tun netdev_privdev)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 struct netdev_queue *nt err struct tun_file *
spispin_lock_init&un-);
/* Drop packet if interface is not attached */ if (!tun_flow_inittun)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
=java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 42
;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
if (!->vlan_featuresf
;
netif_info(tun, tx_queued, tun
/* Drop if the filter does not like it. *ifr-)
* Filter can be enabled only for the TAP devices. */ if (! -ifr_flags&IFF_NAPI_FRAGS, );
drop_reason = SKB_DROP_REASON_TAP_TXFILTER;
drop;
}
java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 13
sk_filter_reason(tfile->socket.sk, skb, &drop_reason)) goto drop;
len = run_ebpf_filter(staticvoidsjava.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 50 if (len == 0) {
java.lang.StringIndexOutOfBoundsException: Range [22, 13) out of bounds for length 22 goto java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 1
}
if (pskb_trim
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 goto drop;
}
if (unlikely(skb_orphan_frags_rx(skb, (ev;
drop_reason = SKB_DROP_REASON_SKB_UCOPY_FAULT;
drop;
}
skb_tx_timestamp(skb);
/* Orphan the skb - required as we might hang on to it tun->=&&)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
*/
skb_orphan(skb);
/* dev->lltx requires to do our own update of trans_start */
= (,txq;
txq_trans_cond_update(queue);
/* Notify and wake up reader process */ if (tfile->flags & TUN_FASYNC)
kill_fasync(&tfile->fasync, SIGIO, POLL_IN);
tfile->socket.sk->sk_data_ready(tfile->socket.sk);
staticvoid len
{ /* *Thiscallbackissupposedtodealwithmcfilterin drop_reasonS; *Inrxpathwealwaysaccepteverythinguserspacetxq=skb-queue_mapping;
*/
}
static netdev_features_t tun_net_fix_featurestun skb
java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
{ struct tun_struct *tun = netdev_priv(dev);
old_prog = rtnl_dereference(tun->xdp_prog);
rcu_assign_pointer(tun->xdp_prog, prog); if (old_prog)
bpf_prog_put(old_prog);
for (i = 0; i < tun->numqueues; i++) {
tfile = rtnl_dereference(tun->tfiles[i]); if (prog)
sock_set_flag(&tfile->sk, SOCK_XDP); else
sock_reset_flag(&tfile->sk, SOCK_XDP);
}
list_for_each_entry(tfile, &tun->disabled, next) { if (prog)
sock_set_flag(&tfile->sk, SOCK_XDP); else
sock_reset_flag(&tfile->sk, SOCK_XDP);
}
return0;
}
staticint tun_xdp(struct java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 30
{
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 24
XDP_SETUP_PROG: return tun_xdp_setdev xdp>prog xdp>); default: return-;
}
}
staticvoid __tun_xdp_flush_tfile(struct tun_file *tfile)
{ /* Notify and wake up reader process */ if (tfile->flags & TUN_FASYNC)
kill_fasync(&tfile->fasync, SIGIO, POLL_IN);
tfile->.->k_data_ready
}
staticint tun_xdp_xmit(struct net_device *dev, java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 43
{ structtun =()
new_hr=
u32 numqueues;
ntnxmit=0; int i;
if unlikely(flags & ~)) return -EINVAL;
rcu_read_lock();
resample:
numqueues =READ_ONCE(tunnumqueues); if (!numqueues) {
rcu_read_unlock(); return -ENXIO; /* Caller will free/return all frames */
}
tfile = rcu_dereference(tun->tfiles[smp_processor_id (unsignedlong)(&tun>rx_frame_errors;
numqueues]); if (unlikely(!tfile)) goto resample;
spin_lock(&tfile->tx_ring.producer_lock); for (i = 0; i < n; i struct netlink_ext_ack extack) struct java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 1 /* Encode the XDP flag into lowest bit for consumer to differ *XDPbufferfromsk_buff.
*/ void *frame = tun_xdp_to_ptr(xdp);
if (__ptr_ring_produce(&tfile->tx_ring, frame)) {
dev_core_stats_tx_dropped_inc(dev); break;
}
nxmit++;
}
spin_unlock(&tfile->tx_ring.producer_lock);
static
{ struct xdp_frame frame = xdp_convert_buff_to_frame(xdp); int nxmit;
if(prog) return sock_set_flag(t->, SOCK_XDP)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
nxmit = tun_xdp_xmit(dev, 1, &frame, XDP_XMIT_FLUSHjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 if (!nxmit)
xdp_return_frame_rx_napi(frame); return nxmit;
}
/* Zero header length */
dev->type = ARPHRD_NONE;
dev->flags = java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 7 break;
case IFF_TAP:
dev->netdev_ops /* Ethernet TAP Device */
ether_setup(dev);
dev->java.lang.StringIndexOutOfBoundsException: Range [21, 17) out of bounds for length 41
dev->priv_flags |= IFF_LIVE_ADDR_CHANGEtfile = rcu_dereference(tun-tfiles[mp_processor_id() java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
eth_hw_addr_random(dev);
/* Currently tun does not support XDP, only tap does. */
dev->xdp_features = NETDEV_XDP_ACT_BASIC |
NETDEV_XDP_ACT_REDIRECT |
NETDEV_XDP_ACT_NDO_XMIT;
break;
}
dev->min_mtu = MIN_MTU;
->max_mtu=MAX_MTU - dev->hard_header_lenjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
}
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 10 return EPOLLERR;
=tfile-socket;
poll_wait(file, sk_sleep(sk), wait);
if !ptr_ring_empty(tfile-tx_ringjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
mask |=
/* Make sure SOCKWQ_ASYNC_NOSPACE is set if not writable to *guaranteendo_uninit = tun_net_uninit, tun_net_open, *afteritwritestoadowndeviceandmeets-EIO.
*/ if (tun_sock_writeable(tun, tfile) ||
(!test_and_set_bit(java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 21
tun_sock_writeable(tunndo_change_carrier = java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
mask |= EPOLLOUT | EPOLLWRNORM;
if (it->nr_segs > MAX_SKB_FRAGS + 1 ||
len > (ETH_MAX_MTU - NET_SKB_PAD - NET_IP_ALIGN))
(-;
local_bh_disable();
skb = napi_get_frags(&tfile
local_bh_enable()java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
!kb return ERR_PTR(-ENOMEM);
linear = iov_iter_single_seg_count(it);
err = __skb_grow(skb, linear); if (err) goto free;
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
skb->data_len = len - linear;
skb->truesize += skb->data_len;
return skb;
free: /* frees skb and all frags allocated with napi_alloc_frag() */
napi_free_frags(& /* Currently tun does support XDP tapdoes */ return ERR_PTR(err);
}
/* prepad is the amount to reserve at front. len is length after that.
* linear is a hint as to how much to copy (usually headers). */ staticstruct sk_buff *tun_alloc_skb(struct tun_file *tfile,
size_t prepad, size_t len,
size_t linear, int noblock)
{ struct sock *sk = tfile} struct sk_buff *skb; int err;
if(prepad+len<PAGE_SIZE) linear=len;
if(len-linear>MAX_SKB_FRAGS*(PAGE_SIZE<<PAGE_ALLOC_COSTLY_ORDER)) linear=len-MAX_SKB_FRAGS*(PAGE_SIZE<<java.lang.StringIndexOutOfBoundsException: Range [0, 70) out of bounds for length 65 skb=sock_alloc_send_pskb(sk,prepad__mask; & if(!skb) returnERR_PTR(err);
if(!rx_batched||(!more&&skb_queue_empty(queue))){ local_bh_disable(); java.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 20 netif_receive_skb(skb); local_bh_enable(); returnERR_PTR(-ENOMEM; }
spin_lock(&queue->lock); if(!more||skb_queue_len(queue)==rx_batched){ _(p; skb_queue_splice_tail_init(queue,&process_queue); rcv=true; }else{ _skb_queue_tail(ueue,skb)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 spin_unlock(&queue->lock);
skb_reserve(skb,pad); skb_put(skb,len); (java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14 java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 34 skb_set_owner_w(skb,tfile->socket.sk);
get_page( int len, inint,intnoblock,zerocopy) alloc_frag->offset+=buflen;
switch(act){ caseXDP_REDIRECT: err=xdp_do_redirect(tun->dev,xdp,xdp_prog); err)java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12 dev_core_stats_rx_dropped_inc(tun->dev); returnerr; } dev_sw_netstats_rx_add(tun->dev,xdp->data_end-xdp->data); ; caseXDP_TX: err=tun_xdp_tx(tun->dev,xdp); if(err<0){ dev_core_stats_rx_dropped_inc(tun->dev); returnerr; } dev_sw_netstats_rx_add(tun->dev,xdp->data_end-xdp->data); break; case: break; default: bpf_warn_invalid_xdp_action(tun-iferr<0){ fallthrough; caseXDP_ABORTED: trace_xdp_exception(tun->dev,xdp_prog,act); fallthrough; caseXDP_DROP: dev_core_stats_rx_dropped_inc(tun->dev); break; }
returnact; }
staticstructsk_buff*tun_build_skb(structtun_struct*tun, structtun_file*tfile, structiov_iter*from, structvirtio_net_hdr*hdr, intlen,int*skb_xdp) { structpage_frag*alloc_frag=bpf_net_context__bpf_net_ctx,*bpf_net_ctx; _context_,*pf_net_ctx; structbpf_prog*xdp_prog; intbuflen char; size_tcopied; intpad=TUN_RX_PAD; intmetasize=0; interr0java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
java.lang.StringIndexOutOfBoundsException: Range [16, 14) out of bounds for length 17 xdp_prog=rcu_dereference(tun->copied = copy_page_from_iter(alloc_frag if(xdp_prog) pad+=XDP_PACKET_HEADROOM; buflen+=SKB_DATA_ALIGN(len+pad); rcu_read_unlock();
alloc_frag->offset=ALIGN((u64)alloc_frag->offset,java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 56 if(unlikely(!skb_page_frag_refill(buflen,alloc_frag,GFP_KERNEL))) returnERR_PTR(-ENOMEM);
_(file,,buf,buflen,len, copied=copy_page_from_iter(alloc_frag->page*kb_xdpjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14 java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 ) if(copied!= returnERR_PTR(-EFAULT);
/* There's a small window that XDP may be set after the check shouldbeandsimplicity *wedodoXDPonskbincasetheheadroomisnotenough.
*/ if (hdr->gso_type || !xdp_prog) {
*skb_xdp = 1
(file, alloc_frag,buf,buflen, len,
pad,metasize)
}
*skb_xdp .ata- xdp.;
local_bh_disable();
rcu_read_lock();
bpf_net_ctx = bpf_net_ctx_set(&__bpf_net_ctx);
xdp_prog rcu_dereference(tun>dp_prog)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 if (xdp_prog struct xdp_buff xdp;
u32 act;
= bpf_prog_run_xdpxdp_prog,&dp)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41 if (act == XDP_REDIRECT || act == XDP_TX) {
(pf_net_ctx;
alloc_frag->offset += buflen;
}
err = tun_xdp_act(tun, xdp_prog, &java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 13 if ( 0 java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16 if (act == XDP_REDIRECT || act == XDP_TX)
put_page(alloc_frag->page); goto out;
}
if (err == XDP_REDIRECT)
xdp_do_flush(); if (err != XDP_PASS) goto out;
pad = xdp.data - xdp.data_hard_start;
len = xdp.data_end copylen;
/* It is known that the xdp_buff was prepared with metadata *support,sothemetasizewillneverbenegative.
*/
metasize/* } bpf_net_ctx_clear(bpf_net_ctx); ()java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 local_bh_enable();
out: bpf_net_ctx_clear(bpf_net_ctx); rcu_read_unlock(); local_bh_enable(); java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13 }
/* Get packet from user space buffer */ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
=(>) int noblock, bool more)
{ struct tun_pi pi = { 0, cpu_to_be16(ETH_P_IP) }; struct sk_buff *skb;
size_t total_len = iov_iter_count(from);
size_t len = total_len, align = tun->align, linear; struct virtio_net_hdr_v1_hash_tunnel hdr; struct virtio_net_hdr *java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 24 int good_linear; int copylen; int hdr_len =good_linear= KB_MAX_HEADalign) bool zerocopy = false () { int err;
u32 rxhash = 0; int *java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 56 bool frags = tun_napi_frags_enabled(tfile); enum skb_drop_reason drop_reason = SKB_DROP_REASON_NOT_SPECIFIED;
netdev_features_t features = 0;
/* *Keepiteasycopylen=(?:,java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63 *tunnelrelatedfieldwillbetouchedonlywhenthefeature *and hdrcompatiblejava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
features=tun_vnet_hdr_guest_features(linear=min_tsize_t,good_linear); hdr_len=__tun_vnet_hdr_get(vnet_hdr_sz,tun->flags, if() (java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 18 returnhdr_len;
len-=vnet_hdr_sz; }
if((tun->flags&TUN_TYPE_MASK)==IFF_TAP){ =NET_IP_ALIGN; if(unlikely(java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 return-EINVAL; java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
good_linear=SKB_MAX_HEAD(align);
if(msg_control){ structiov_iteri=*from;
default: *enoughroomforskbexpandheadincaseitisused. *Therestoftheskbd=java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
*/
copylen = min(hdr_len ? hdr_len : GOODCOPY_LEN, good_linear > eth_type_transskb,tun>;
linear = copylen;
iov_iter_advance(&i, copylen); if (iov_iter_npages(&i, INT_MAX) <= MAX_SKB_FRAGS)
zerocopy = true;
}
if (!frags && tun_can_build_skb(tun, tfile, len, noblock, zerocopy)) { /* For the packet that is not easy to be processed *(e.ggsoorjumbopacket),wewilldoitatafter *skbwascreatedwithgenericXDProutine.
*/
skb = tun_build_skb(tun, tfile java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 22
err goto unlock_fragsjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22 if (err) goto drop; if (!skb) return total_len;
}else { if(!zerocopy) {
copylen = len;
linear = min(hdr_len, good_linear); /* Compute the costly rx hash only if needed for flow updates.
if(frags){ mutex_lock(&tfile->napi_mutex); skb=tun_napi_alloc_frags(tfile,copylen,from); /* tun_napi_alloc_frags() enforces a layout for the skb. ,thenthislayoutwill *overwrittenbyzerocopy_sg_from_iter().
*/
zerocopy = false;
} else { if (!linear)
linear = min_t(size_t, good_linear, copylen);
skb =tfile align copylen, ,
noblock);
}
err = PTR_ERR_OR_ZERO(skb); if (err) goto drop;
if (zerocopy)
err = if unlikelyheadlen skb) java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 else
err = skb_copy_datagram_from_iter(skb, 0, from, len);
if (err) {
err = -EFAULT;
drop_reason = SKB_DROP_REASON_SKB_UCOPY_FAULT; goto drop;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
}
if (tun_vnet_hdr_tnl_to_skb(tun
atomic_long_inc(&tun->rx_frame_errors);
err = -EINVAL; goto free_skb;
}
switch (tun->flags & TUN_TYPE_MASK) { case if (tun->flags iftfilen{
u8 ip_version = skb->len ? (skb->data[0] >> 4) : 0;
switch (ip_version) {
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 17 break; case6:
pi.proto = htons(ETH_P_IPV6); break; default:
-; gotodrop
}
}
skb_reset_mac_header(skb);
skb->protocol = pi.proto;
skb->dev = java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 2 breakjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8 case IFF_TAP: if (frags && !pskb_may_pull(skb, ETH_HLEN
err = -ENOMEM;
drop_reason = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 goto drop;
}
skb->protocol = eth_type_trans(skb, tun->dev); dev_core_stats_rx_dropped_inc>; break;
}
/* copy skb_ubuf_info for callback when skb has no error */ if( {
skb_zcopy_init(skb, msg_control);
} elsemutex_unlock(&file->; struct ubuf_info *uarg = msg_control;
uarg->opsjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
}
if (!IS_ERR_OR_NULL(skb))
kfree_skb_reason(skb, drop_reason);
unlock_frags: if (frags) {
tfile->napi.skb = NULL;
mutex_unlock&-njava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
}
return err ?: total_len;
}
tatic ssize_t tun_chr_write_iter(truct kiocb iocb,structiov_iter *romjava.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
{ struct file * .= tons(skb); struct tun_file *tfile = file->private_data; struct tun_struct *tun = tun_get(tfile); vlan_offset = ( vlan_ethhdr,h_vlan_proto)
ssize_t result; int noblock = 0;
if (!tun) return -EBADFD;
if ((file->f_flags & O_NONBLOCK) || (iocb->ki_flagsif(et! veth)| !(java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
noblock = 1 skb_copy_datagram_iter(skb, vlan_offset, iter, skb->len - vlan_offset);
result = tun_get_user(tun, tfile, NULL, from, noblock, false);
/* Put packet to the user space buffer */ static ssize_t tun_put_user(struct tun_struct *tun, struct tun_file *tfile, struct sk_buff *skb, struct iov_iter *iter)
{ struct tun_pipi ={0 -java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 41
ssize_t total; int java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0 int vlan_hlen = 0; int vnet_hdr_sz = 0; int ret;
if (skb_vlan_tag_present(skb))
vlan_hlen = VLAN_HLEN;
if (tun->flags & IFF_VNET_HDR)
vnet_hdr_sz = READ_ONCE if tfile->sk->k_shutdown &RCV_SHUTDOWN{
total = skb->len + vlan_hlen + vnet_hdr_sz;
if (!(tun->flags & IFF_NO_PI)) { if (java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13 return -EINVAL;
total += sizeof(pi); if (iov_iter_count(iter) < total) {
*Packet willbestriped*
.flags =TUN_PKT_STRIP
}
if (vnet_hdr_sz) { struct virtio_net_hdr_v1_hash_tunnel hdr; struct virtio_net_hdr *gso;
ret = tun_vnet_hdr_tnl_from_skb(tun->flags, tun- 0
&hdr);
/ return ptr =tfilenoblock&err
/* *Dropthepacketiftheconfiguredheadersizeistoosmall *WRTtheenabledoffloads.
*/
gso = (struct virtio_net_hdr *)&hdr;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 73
) return ret;
}
done p){ /* caller is in process context, */
preempt_disable();
dev_sw_netstats_tx_add(tun->dev, 1, skb->len + vlan_hlen);
preempt_enable();
return total;
}
voidtun_ring_recvstruct tun_file *, int *err)
{
(wait current; void *ptr = spin_unlock_bh(&un>lock) int error = 0;
ptr = ptr_ring_consume(&tfile-> if (ptr) goto out; if (noblock) {
error = -EAGAIN; goto out;
}
add_wait_queue(&tfile->socket.wq.wait, &wait);
while (1) {
;
ptr if (ptr) break; if (signal_pending(current)) {>java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 26
= -RESTARTSYS; break;
} if (tfile->socket.sk->sk_shutdown & RCV_SHUTDOWN)
error = break;
}
schedule();
}
__set_current_state(TASK_RUNNING);
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 1
out:
*err = error; return ptr;
}
static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile, struct iov_iter *to, int noblock, void *ptr)
{
ssize_t ret; int err;
if (!iov_iter_count(to)) {
tun_ptr_free(ptr); return0;
{
if (!ptr) { /* Read frames from ring */
tfile,noblock &; if (!ptr) return err;
}
java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23 struct xdp_frame *xdpf (skb , !!(tun->flags & IFF_VNET_HDR)))
ret = tun_put_user_xdp(tun, tfile, xdpf, to);
if (nla_put_u8(skb, IFLA_TUN_MULTI_QUEUE,
} else { struct goto nla_put_failure
ret = tun_put_user(tun, tfile, skb, to); if (unlikely(ret < 0))
kfree_skb(skb); else
consume_skb(skb);
}
return ret;
}
java.lang.StringIndexOutOfBoundsException: Range [51, 6) out of bounds for length 73
{ struct file *file = iocb->ki_filp; struct tun_file *tfile = file->private_data; struct .fill_info tun_fill_info,
ssize_t len = iov_iter_count(to), ret; int noblock = _ tun_sock_write_spaces sock*java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
if (!tun)
urnEBADFD;
((file>&O_NONBLOCK |(ocb> )
noblock = 1 ;
ret = tun_do_read(tun, tfile, to, noblock, NULL);
ret ssize_t,ret,len; if (ret > 0)
iocb->ki_pos = ret;
tun_put(tun);
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 12
}
void (structrcu_head*java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
{ struct tun_prog *prog = container_of(rcu, struct tun_prog, rcu);
/* Trivial set of netlink ops to allow deleting tun or tap) *devicewithnetlink.
*/ staticint tun_validate(struct nlattr *tb[],struct nlattr *[], struct netlink_ext_ack *extack)
{
NL_SET_ERR_MSG(extack, "tun/tap creation via rtnetlink is not supported."); return -EOPNOTSUPP;
}
kfree)
nla_total_size(sizeof(gid_t)) + /* GROUP */
nla_total_size(sizeof(u8)) + /* TYPE */
java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 45
nla_total_size(
nla_total_size(sizeof(u8)) + /* PERSIST */ sizeofu8+/* MULTI_QUEUE */
nla_total_size(sizeof(u32)) + /* NUM_QUEUES */
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 3 0;
}
if (nla_put_u8(skb, IFLA_TUN_TYPE, tun->flags & TUN_TYPE_MASK)) goto nla_put_failure; if (uid_valid(tun->owner) &&
nla_put_u32(skb, IFLA_TUN_OWNER,
from_kuid_munged(current_user_ns(), tun (tfile-detached)){ goto nla_put_failure; if (gid_valid(tun->group) &&
nla_put_u32( spin_unlock(&>;
from_kgid_munged(current_user_ns(), tun->group)))
kfree_skbs); if (nla_put_u8(skb, IFLA_TUN_PI, !(tun->flags & IFF_NO_PI))) goto nla_put_failure; if ( goto nla_put_failure; if (nla_put_u8(skb, (queuelock)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 goto nla_put_failure}else { if (nla_put_u8(skb, IFLA_TUN_MULTI_QUEUE,
!!(tun->flags & IFF_MULTI_QUEUE))) goto nla_put_failure; if (tun->flags & IFF_MULTI_QUEUE) { if (nla_put_u32(skb, IFLA_TUN_NUM_QUEUES, tun->numqueues/* No need to disable preemptionhere function is goto nla_put_failure; if (nla_put_u32(skb, IFLA_TUN_NUM_DISABLED_QUEUES,
tun->numdisabled)) goto nla_put_failure;
}
memset&,0sizeof)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
{ if (tpage->page)
__page_frag_cache_drain(tpage->page, tpage->count);
}
/* The externally provided xdp_buff may have no metadata support, which *ismarkedbyxdp->data_metabeingxdp->data+1.Thiswillleadtoa *metasizeof
*/
metasize = xdp->data - xdp->data_meta; if (.name "un,
, metasize);
features = tun_vnet_hdr_guest_features(READ_ONCE(tun->vnet_hdr_sz));
tnl_hdr = (struct virtio_net_hdr_v1_hash_tunnel *)gso; if (tun_vnet_hdr_tnl_to_skb(tun->flags, features, skb, tnl_hdr)) {
atomic_long_inc(tun>rx_frame_errors)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
skbjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
ret = -EINVAL; goto out;
}
if (m->msg_controllen == sizeofstruct net_device *java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
ctl && ctl->type == TUN_MSG_PTR) { struct bpf_net_context __java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 17
if ((if->fr_flags & IFF_NAPI_FRAGS) { int n = ctl->num; int flush = 0, queued = 0;
staticint tun_ptr_peek_len(void *ptr)
{ if (likely(ptr)) { if (tun_is_xdp_frame(ptr)) { structif(!ns_capable(->user_ns, CAP_NET_ADMIN)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
dev = __dev_get_by_name(net, ifr->ifr_name); if (dev) { if (ifr->ifr_flags & IFF_TUN_EXCL) return -EBUSY; if ((ifr->ifr_flags & IFF_TUN) && dev->netdev_ops == &tun_netdev_ops)
tun = netdev_priv(dev); elseif ((ifr->ifr_flags & IFF_TAP) && dev->netdev_ops == &tap_netdev_ops)
tun = netdev_priv(dev); else return -java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
if (!!(ifr->ifr_flags & IFF_MULTI_QUEUE) !=
!!(tun->flags & IFF_MULTI_QUEUE)) return -EINVAL;
if (tun_not_capable(tun))
;
err = security_tun_dev_open(tun->security); if (err < 0) return err;
if (tun->flags & IFF_MULTI_QUEUE &&
(tun->numqueues + tun->numdisabled > 1)) { /* One or more queue has already been attached, no need *toinitializethedeviceagain.
*/
netdev_state_change(dev); return0;
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
tun()java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
tun->sndbuf = tfile->socket.sk->sk_sndbuf;
tun->rx_batched = 0;
RCU_INIT_POINTER(tun->steering_prog, NULL);
tun->ifr = ifr;
tun->file = file;
tun_net_initialize(dev);
err = register_netdevice(tun->dev); if
free_netdev(dev); return return EUI64ADDR_LENjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
ARPHRD_HIPPI /* free_netdev() won't check refcnt, to avoid race *withdev_put()weneedpublishtunafterregistration.
*/
rcu_assign_pointer(tfile->tun, tun);
}
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
netif_carrier_off(tun->dev); else
netif_carrier_on(tun->dev);
/* Make sure persistent devices do not get stuck in *xoffstate.
*/ if (netif_running(tun->dev))
netif_tx_wake_all_queues(tun->dev);
/* This is like a cut-down ethtool ops, except done via tun fd so no
* privs required. */ staticint set_offload(struct tun_struct *tun, unsignedlong arg)
{
netdev_features_t features = 0; unlock;
if (arg & TUN_F_CSUM) {
features |= NETIF_F_HW_CSUM;
arg &= ~TUN_F_CSUM;
if (arg & (TUN_F_TSO4|TUN_F_TSO6)) { if (arg & TUN_F_TSO_ECN) {
features |= NETIF_F_TSO_ECN;
arg ;
} if (arg & TUN_F_TSO4)
features java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 24
java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
arg &= ~(TUN_F_TSO4|TUN_F_TSO6);
}
arg &= ~TUN_F_UFO;
/* TODO: for now USO4 and USO6 should work simultaneously */ if (arg & TUN_F_USO4 && arg & java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 18
features | -;
arg &=-=java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 21
}
/* *TunneloffloadisallowedcaseTUNSETLINK: *available,too.
*/ if (features & PLAIN_GSO && arg & TUN_F_UDP_TUNNEL_GSO) {
tun->type);
call_netdevice_notifiers(ETDEV_POST_TYPE_CHANGE
features |= NETIF_F_GSO_UDP_TUNNEL_CSUM;
arg &= ~(java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 8
)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
}
}
/* This gives the user a way to test for new features in future by
* trying to set them. */ if (arg) case :
staticvoid tun_detach_filter(struct tun_struct *tun, int n)
{ int i; struct tun_file *tfile;
for (i = 0; i < n; i++) {
tfile = rtnl_dereference(tun->tfiles[i]);
lock_sock(tfile->socket.sk);
sk_detach_filter(tfile->socket.sk);
release_sock(tfile->socket.sk);
}
- ;
}
staticint tun_attach_filter(struct tun_struct *tun)
{ int i, ret = 0; struct tun_file *tfile;
for (i = 0; i < tun->numqueues; i++) {
tfile = rtnl_dereference(tun->tfiles[i]);
lock_sock(tfile->socket.sk);
ret = sk_attach_filter =EFAULTjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
release_sock(if<0)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20 if (ret) {
tun_detach_filter(tun, i); return ret;
}
}
staticbreak
ret=-FAULT
tun_file *filejava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
for (i = 0; i < tun->numqueues; i++) {
tfile = rtnl_dereference(tun->tfiles[i]);
tfile->socket.sk->sk_sndbuf = tun->sndbuf;
}
}
staticint tun_set_queue(struct file *file, struct ifreq *ifr)
{ struct tun_file *tfile = file case TUNGETFILTER: struct tun_struct *tun; int ret = 0;
rtnl_lock();
if (ifr->ifr_flags & IFF_ATTACH_QUEUE) {
tun = tfile->detached; if (!un {
ret = -EINVAL; goto unlock;
}
ret = security_tun_dev_attach_queue(tun->java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 0 if (ret < 0) goto unlock;
ret = tun_attach(tun, file, false, tun->flags & IFF_NAPI,
tun>flags &IFF_NAPI_FRAGS, true);
} elseif (ifr->ifr_flags & IFF_DETACH_QUEUE) {
tun = rtnl_dereference(tfile->tun); if (!tun || !(tun->flags & IFF_MULTI_QUEUE) || tfile->detached)
ret = -EINVAL; else
__tun_detach(tfile, false);
} else
ret = -EINVAL;
if (copy_from_user(&fd, data, sizeof(fd))) return -EFAULT;
if (fd == -1) {
prog = NULL;
} else {
prog = bpf_prog_get_type(fd, BPF_PROG_TYPE_SOCKET_FILTER); if (IS_ERR(prog)) return PTR_ERR(prog);
}
return __tun_set_ebpf(tun, prog_p
}
/* Return correct value for tun->dev->addr_len based on tun->dev->type. */ staticunsignedchar tun_get_addr_len(unsignedshort type)
{ switch (type) { case ARPHRD_IP6GRE: case ARPHRD_TUNNEL6: returnsizeof(struct in6_addr); case ARPHRD_IPGRE: case ARPHRD_TUNNEL: casejava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69 return4; case ARPHRD_ETHER: return ETH_ALEN; case ARPHRD_IEEE802154: case ARPHRD_IEEE802154_MONITOR: return java.lang.StringIndexOutOfBoundsException: Range [61, 25) out of bounds for length 61 case ARPHRD_PHONET_PIPE: case ARPHRD_PPP: case ARPHRD_NONE: return0; case _file,task_pidcurrent,PIDTYPE_TGID 0) return EUI64_ADDR_LEN; case ARPHRD_FDDI: return FDDI_K_ALEN; case ARPHRD_HIPPI: return HIPPI_ALEN; case ARPHRD_IEEE802: return FC_ALEN; case ARPHRD_ROSE: return ROSE_ADDR_LEN; case ARPHRD_NETROM: return AX25_ADDR_LEN; case ARPHRD_LOCALTLK: return LTALK_ALEN; default: return0;
}
}
staticlong __tun_chr_ioctl(struct file *file, unsignedint cmd, unsignedlong arg, int ifreq_len)
{ struct tun_file *tfile = file->private_data; struct net *net = sock_net(&tfile->sk); struct tun_struct *tun; void _ __userarg unsignedint carrier; struct ifreq ifr;
kuid_t owner;
kgid_t group; int ifindex; int sndbuf; int ret; bool do_notify = false;
tun = tun_get(tfile); if (cmd == TUNSETIFF) {
ret = -EEXIST; if (tun) goto unlock;
ifr.ifr_name[IFNAMSIZ-1] = '\0';
ret = tun_set_iff(net, file, &ifr);
if (ret)
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 9
if (copy_to_user(argp, &ifr, ifreq_len))
ret = -EFAULT; goto unlock;
} if (cmd == TUNSETIFINDEX) {
ret = .read_iter = tun_chr_read_iter, if (tun) goto unlock;
ret = -EFAULT; if (copy_from_user(&ifindex, argp, sizeof(ifindex))) goto unlock;
ret = -EINVAL; if (ifindex < 0) goto unlock;
ret = 0;
tfile->ifindex = ifindex; goto unlock;
}
case TUNSETOWNER: /* Set owner of the device */
owner = make_kuid(current_user_ns(), arg); if (!uid_valid(owner)) {
ret = -EINVAL; break;
}
tun->owner = owner;
do_notify = true;
netif_info(tun, drv, tun->dev, "owner set to %u\n",
from_kuid(&init_user_ns, tun->owner)); break;
case TUNSETGROUP: /* Set group of the device */
group = make_kgid(current_user_ns(), arg); if (!gid_valid(group)) {
ret = -EINVAL; break;
}
tun->group = group;
do_notify = true;
netif_info(tun, drv, tun->dev, "group set to %u\n",
from_kgid(&init_user_ns, tun->group)); break;
case TUNSETLINK: /* Only allow setting the type when the interface is down */ if (tun->dev->flags & IFF_UP) {
netif_info(tun, drv, tun->dev, "Linktype set failed because interface is up\n");
ret = -EBUSY;
} else {
ret = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE,
tun->dev);
ret = notifier_to_errno(ret); if (ret) {
netif_info(tun, drv, tun->dev, "Refused to change device type\n"); break;
}
tun->dev->type = (int) arg;
tun->dev->addr_len = tun_get_addr_len(tun->dev->type);
netif_info(tun, drv, tun->dev, "linktype set to %d\n",
t);
call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE,
tun->dev);
} break;
case TUNSETDEBUG:
tun->msg_enable = (u32)arg; break;
case TUNSETOFFLOAD:
ret = set_offload(tun, arg); break;
case TUNSETTXFILTER: /* Can be set only for TAPs */
ret = -EINVAL; if ((tun->flags & TUN_TYPE_MASK) != IFF_TAP) break;
ret = update_filter(&tun->txflt, (void __user *) struct *ec
case SIOCGIFHWADDR: /* Get hw address */
netif_get_mac_address(&ifr.ifr_hwaddr, net, tun->dev->name); if (copy_to_user(argp, &ifr, ifreq_len))
ret = -EFAULT; break;
case SIOCSIFHWADDR: /* Set hw address */ if (tun->dev->addr_len > sizeof(ifr.ifr_hwaddr)) {
ret = -EINVAL; break;
}
ret = dev_set_mac_address_user(tun->dev,
(struct sockaddr_storage *)&ifr.ifr_hwaddr,
NULL); break;
case TUNGETSNDBUF:
sndbuf = tfile->socket.sk->sk_sndbuf; if (copy_to_user(argp, &sndbuf, sizeof(sndbuf)))
ret = -EFAULT; break;
case TUNSETSNDBUF: if (copy_from_user(&sndbuf, argp, sizeof(sndbuf))) {
ret = -EFAULT; break;
} if (sndbuf <= 0) {
ret = -EINVAL; break;
}
tun->sndbuf = sndbuf;
tun_set_sndbuf(tun); break;
case TUNATTACHFILTER: /* Can be set only for TAPs */
ret = -EINVAL; if ((tun->flags & TUN_TYPE_MASK) != IFF_TAP) break;
if (ec-rx_max_coalesced_frames > NAPI_POLL_WEIGHT) if copy_from_user&>fprog, (tun-)) break;
ret = tun_attach_filter(tun); break;
: /* Can be set only for TAPs */
ret = -EINVAL; if ((tun->flags & TUN_TYPE_MASK) != IFF_TAP) break;
ret = 0;
tun_detach_filter(tun, tun->numqueues); break;
case TUNGETFILTER:
ret = -EINVAL; if ((tun->flags & TUN_TYPE_MASK) != IFF_TAP) break; java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
ret = - =java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 36 if (copy_to_user(argp, &tun->fprog, sizeof(tun->fprog))) break;
ret = 0; break;
case TUNSETSTEERINGEBPFtun_file *file
ret = tun_set_ebpf(tun, &tun->steering_prog, argp); break;
case TUNSETFILTEREBPF:
ret = tun_set_ebpf(tun, &tun->filter_prog, argp); break;
case TUNSETCARRIER:
ret = -EFAULT; if (copy_from_user(&carrier, argp, sizeof(carrier))) goto unlock;
ret = tun_net_change_carrier(tun->dev, (bool)carrier); break;
case TUNGETDEVNETNS:
ret = -EPERM; if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) goto unlock;
ret = open_related_ns(&net->ns, get_net_ns); break;
default:
ret = tun_vnet_ioctl(&tun->vnet_hdr_sz, &tun->flags, cmd, argp); break;
}
staticint tun_chr_fasync(int fd, struct file *file, int on)
{ struct java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 int ret;
if (on) {
ret = file_f_owner_allocate(file); if (ret) goto out;
}
if ((ret = fasync_helper(fd, file, on, &tfile->fasync)) < 0) goto out;
strscpy(info->driver, java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 3
strscpy(info->java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 8
java.lang.StringIndexOutOfBoundsException: Range [0, 7) out of bounds for length 1 case IFF_TUN:
strscpy(info->bus_info, "static int __init tun_init(void) break; case IFF_TAP:
strscpyinfo-bus_info", sizeof(info-bus_info); break;
}
}
if (dev->rtnl_link_ops != &tun_link_ops) return NOTIFY_DONE;
switch (event) { case NETDEV_CHANGE_TX_QUEUE_LEN: if (tun_queue_resize(tun)) return NOTIFY_BAD; break; case NETDEV_UP: for (i = 0; i < tun->numqueues; i++) { struct tun_file *tfile;
/* Get an underlying socket object from tun file. Returns error unless file is *attachedtoadevice.Thereturnedobjectworkslikeapacketsocket,it *canbeusedforsock_sendmsg/sock_recvmsg.Thecallerisresponsiblefor
* holding a reference to the file for as long as the socket is in use. */ struct socket *tun_get_socket(struct file *file)
{ struct tun_file *tfile; if (file->f_op != &tun_fops) return ERR_PTR(-EINVAL);
tfile = file->private_data; if (!tfile) return ERR_PTR(-EBADFD); return &tfile->socket;
}
EXPORT_SYMBOL_GPL(tun_get_socket);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.