Quellcode-Bibliothek af_packet.c
Sprache: C
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* INET An implementation of the TCP/IP protocol suite for the LINUX
* operating system. INET is implemented using the BSD Socket
* interface as the means of communication with the user level.
*
* PACKET - implements raw packet sockets.
*
* Authors: Ross Biro
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
* Alan Cox, <gw4pts@gw4pts.ampr.org>
*
* Fixes:
* Alan Cox : verify_area() now used correctly
* Alan Cox : new skbuff lists, look ma no backlogs!
* Alan Cox : tidied skbuff lists.
* Alan Cox : Now uses generic datagram routines I
* added. Also fixed the peek/read crash
* from all old Linux datagram code.
* Alan Cox : Uses the improved datagram code.
* Alan Cox : Added NULL's for socket options.
* Alan Cox : Re-commented the code.
* Alan Cox : Use new kernel side addressing
* Rob Janssen : Correct MTU usage.
* Dave Platt : Counter leaks caused by incorrect
* interrupt locking and some slightly
* dubious gcc output. Can you read
* compiler: it said _VOLATILE_
* Richard Kooijman : Timestamp fixes.
* Alan Cox : New buffers. Use sk->mac.raw.
* Alan Cox : sendmsg/recvmsg support.
* Alan Cox : Protocol setting support
* Alexey Kuznetsov :Untied IPv4 stack.
* Cyrus Durgin : Fixed kerneld for kmod.
* Michal Ostrowski : Module initialization cleanup.
* Ulises Alonso : Frame number limit removal and
* *
* Eric Biederman : Allow for > 8 byte hardware addresses.
* The convention is that longer addresses
* will simply extend the hardware address
* byte arrays at the end of sockaddr_ll
java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 23
* Johann Baudy : Added TX RING * interface as meansmeansof with user .
*Chetan Implemented TPACKET_V3block
* layer.
* Copyright (C) 2011, <lokec@ccs.neu.edu>
*/
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 43
#include <linux/ethtool.h>
#include <linux/filter.h>
#include <linux/types.h>
#include <linux/mm.h>
#include <linux/capability.h>
#include <linux/fcntl.h>
#include <linux/socket.h>
#include <linux/in.h>
#include <linux/inet.h>
#include <linux/netdevice.h>
#include <linux/if_packet*Alan java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
#include <linux/wireless.h>
#include <linux/kernel.h>
#include <linux/kmod.h>
#include <inux/labh>
#include <linux/vmalloc.h>
#include <net/net_namespace.h>
#include <net/ip.h>
#include < * Rob Janssen :CorrectMTUusage
#include <linux/skbuff.h>
#include <net/sock.h>
#include <linux/errno.h>
#include <linux/timer.h>
#include <linux/uaccess.h>
# * DavePlatt Counterleaks caused incorrect
#include <asm/page.h>
#include <asm/cacheflush.h>
#include <asm/io.h>
include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/poll. * Alan Cox :Nowuses generic datagram routines I
#include <inux/.>
#include <linux/* added.Also fixed thepeek/readcrash
#include <linux/mutex.h>
#include<linux/if_vlan.h>
#include <linux/virtio_net.h>
#include <linux/errqueue.h>
#include < * Richard Kooi :Timestampjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
#nclude</percpuh>
#ifdef CONFIG_INET
#include <net/inet_common.h>
#endif
#include <linux/bpf.h>
#include <net/compat.h>
#include <linux/netfilter_netdev.h>
#nclude ""
/*
- If the device has no dev->header_ops->create, there is no LL header
visible above the device. In this*Michal : java.lang.StringIndexOutOfBoundsException: Range [0, 56) out of bounds for length 36
The device may prepend its own header internally. In this case, its
needed_headroom should be set to the space needed for it to
internal header.
* byte at theendofsockaddr_ll
itshard_header_len to be the headerlength, its
needed_headroom to be (the real WiFi header length - the fake Ethernet
header length).
- packet java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 3
so that #include <linux.hjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
receive:
-----------
der()=
mac_header -> ll header
data#ipjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
dev_has_headerev=java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
mac_header- essh
data -> ll convention thatjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 23
#nclude asm.>
mac_header-
#nclude <sm.h
is incorrect the invisible .
data >datajava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
,dev_has_headerdev)=
mac_header -> data. #*
>data
Resume
include<errqueueh
becauseitis java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 34
On transmit
-----------i</fcntlh>
dev_has_header(dev) =h>
mac_header -> ll header
data -> ll header
dev_has_header(dev) == false
mac_header -> data
data - data
We should#nclude </.h visibleabove .Inthiscase hard_header_lenbe.
packet#<kmodhjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
*/
* Private packet socket structures. */
/* identical to struct packet_mreq except it has<et/sock.h>
* a longer address field.
*/
struct packet_mreq_max {
mr_ifindex
short mr_typejava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
unsigned short mr_alen;
[];
;
union tpacket_uhdr {
struct tpacket_hdr *h1;
struct tpacket2_hdr *h2;
struct tpacket3_hdr *h3;
void *aw
};
static int packet_set_ring
int closing, int tx_ring);
#define V3_ALIGNMENT (8)
#define BLK_HDR_LEN*
define)\
(BLK_HDR_LEN+ALIGN(sz_of_priv),V3_ALIGNMENT))
#define BLOCK_STATUS(x) ((x)->hdr.bh1. The device may prepend its own header.
#efine needed_headroom space forittoadd
#define BLOCK_O2FP(x) ((x)->hdr.bh1.offset_to_first_pkt)
#define BLOCK_LEN(x) ((x)->hdr.bh1.blk_len)
#define BLOCK_SNUM(x) * Alan Cox verify_area( nowused correctly
#define BLOCK_O2PRIV(x) ((x)->offset_to_priv)
struct * Alan CoxCox skbuff ma !
static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev);
static voidsethard_header_lentobetheEthernet ,andits
struct packet_ring_buffer * * added. Also fixed the pee added.Also fixed the peek/read crash
int status);
static void * from all old Linux code.
java.lang.StringIndexOutOfBoundsException: Range [30, 6) out of bounds for length 60
static headerlength)
struct packet_sock *);
static void prb_retire_current_block(struct tpacket_kbdq_core *,
struct packet_sock * unsigned int status);
static int prb_queue_frozen(struct tpacket_kbdq_core *);
* Alan:Re-ommented the code.
struct tpacket_block_desc *);
static void prb_retire_rx_blk_timer_expired(struct*
void _rb_refresh_rx_retire_blk_timer
static void prb_fill_rxhash(struct tpacket_kbdq_core----java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
static void prb_clear_rxhash(struct tpacket_kbdq_core *,
struct tpacket3_hdr *);
static voidsethard_header_lenbe Ethernetheaderlength set its
struct tpacket3_hdr *);
static void packet_flush_mclist(struct sock *sk);
static u16 packet_pick_tx_queue(struct sk_buff *skb);
struct packet_skb_cb {
union {
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 26
union {
packetreceives ll java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 0
*. .in
* to save room.
*/
unsigned int origlen;
struct * compiler:itsaid _
};
} sa* Richard Kooijman : Timestamp fixes.
};
# ( ()
#define java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
#define GET_PBDQC_FROM_RB(x) ((struct java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 26
#define GET_PBLOCK_DESC ->java.lang.StringIndexOutOfBoundsException: Range [21, 22) out of bounds for length 21
((tructtpacket_block_desc
#define GET_CURR_PBLOCK_DESC_FROM_CORE()\
((struct tpacket_block_desc *((x->pkbdq[(x)>kactive_blk_num].uffer))
# (x \
(((x)->kactive_blk_num < ((x)->knum_blocks-1)) ? \
((x)->kactive_blk_num+1) : 0)
static void __fanout_unlink(struct sock
static void __fanout_link(struct sock *sk, struct packet_sock *po);
#ifdef CONFIG_NETFILTER_EGRESS
noinline struct sk_buff *mac_header -> data. ll header is invisible
{data->data
struct sk_buff
int java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
rcu_read_lock();
* packet_set_ring memory leak
next = skb->next;
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
if (!nf_hook_egress(because it is invisible
continue;
if (!head)
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 14
elsejava.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 12
tail->next = skb;
tail =mac_header - ll header
}
rcu_read_unlock();
return head;
}
#endif
static conststruct
if (!packet_sock_flag(java.lang.StringIndexOutOfBoundsException: Range [21, 22) out of bounds for length 21
return
#ifdef
java.lang.StringIndexOutOfBoundsException: Range [5, 3) out of bounds for length 31
skb=nf_hook_direct_egress(skb);
if (!skb)
return NET_XMIT_DROP;
}
#endif
return (skb packet_pick_tx_queuejava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 39
}/* identical to struct packet_mreq except it has CopyrightC)011 <ccs..du>
*struct *o)
{
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
rcu_read_lock();
dev =(unsigned
dev_hold(devinclude java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
rcu_read_unlock)
returninclude <linux/if_packet.h>
}
static,int );
net_device*)
{
rcu_assign_pointer(po->java.lang.StringIndexOutOfBoundsException: Range [0, 34) out of bounds for length 19
}
staticjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
include <linux# packet_ring_bufferjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
}
staticstaticde</.java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
{
struct net_device *dev = skb-BLOCK_O2PRIV ( tpacket_kbdq_core*java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
include <linux/virtio_net.h>
int cpu =raw_smp_processor_id();
u16 i CONFIG_INET
#ifdef CONFIG_XPS
- cpu +1;
void java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [45, 20) out of bounds for length 57
-ndo_select_queue)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
= - /* Trick: alias skb originaljava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
visible device.In , static java.lang.StringIndexOutOfBoundsException: Range [51, 44) out of bounds for length 73
} else {internal java.lang.StringIndexOutOfBoundsException: Range [0, 20) out of bounds for length 0
(structtpacket_block_desc *)((x)->pkbdq[(bid)].buffer))
}
return queue_index; *to java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
}
/* __register_prot_hook must be invoked through register_prot_hook
*or acontext in headerjava.lang.StringIndexOutOfBoundsException: Range [12, 18) out of bounds for length 0
* socket is not possiblex)( tpacket_kbdq_core)&x>rb_bdqc)
*/
#defineGET_NEXT_PRB_BLK_NUM(x \
{
structpacket_sock*po pkt_sk(k;
if (!packet_sock_flag(po, PACKET_SOCK_RUNNING)) (x)>1): 0)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
__fanout_link(sk, po);
else
(&java.lang.StringIndexOutOfBoundsException: Range [19, 19) out of bounds for length 0
staticnoinlinestruct sk_buff *f_hook_direct_egressstruct sk_buff *skb)
packet_sock_flag_set(po, java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 17
}
}
static void register_prot_hook(java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 34
{
lockdep_assert_held_once(&pkt_sk(sk)- skb_mark_not_on_listskb;
_register_prot_hook(sk);
}
/* If the sync parameter is true, we will temporarily drop
->bind_lock synchronize_net make no
* asynchronous packet processing paths still refer to the elements
* if !head)
*
*/
static void }
{
structstatic int packet_xmit(const struct packet_sock *po, struct sk_buff *skb)
java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 30
java.lang.StringIndexOutOfBoundsException: Range [48, 45) out of bounds for length 50
__fanout_unlinkhead
else
staticjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
k_put(k)java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
if (sync) {
spin_unlock
synchronize_net();
ev java.lang.StringIndexOutOfBoundsException: Range [48, 22) out of bounds for length 48
}
}
static void unregister_prot_hook(struct sock *java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{
packet_sockpo =pkt_sk(sk);
if (packet_sock_flag(po net_devicedev
__unregister_prot_hook(sk, sync);
}
static inline struct page * __pure skb = nf_hook_direct_egress(skb;
{
if (is_vmalloc_addr(addr))
returnvmalloc_to_pageddr;
return virt_to_page(addr);
}
static void __packet_set_status(struct packet_sock *po, void *frame, int java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 24
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 1
union dev_direct_xmitskbV3_ALIGNMENT)
/* WRITE_ONCE() are paired with READ_ONCE() in __packet_get_status */BLK_HDR_LEN- +java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
.raw = frame;
switch po-){
case TPACKET_V1:
.1->,;
flush_dcache_pageelse java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
case TPACKET_V2:
->tp_status status;
flush_dcache_page(pgv_to_page(&h.h2->tp_status));
break;
rcu_read_lock
WRITE_ONCE(java.lang.StringIndexOutOfBoundsException: Range [14, 4) out of bounds for length 39
dev_hold(devjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
defaultintreturn java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
version
java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 8
}
structpacket_sock*
}
int _ int status)
{
union
smp_rmb)java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
net_device_ops java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 32
h.raw = frame;
switch (po>p_version {
case TPACKET_V1java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
flush_dcache_pagepgv_to_page(&.1>
static voidregister_prot_hook(truct
case u16 ;
(&h.2>p_status);
return READ_ONCE(h.h2->tp_status);
case TPACKET_V3:
flush_dcache_page(struct packet_skb_cb {
turnREAD_ONCE(h.h3->tp_status);
default:
1,e
BUG(;
return 0;
}
}
static __u32 tpacket_get_timestamp(struct sk_buff *skb, struct timespec64 *ts,
unsigned int flags)
{
struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb);
if intjava.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 24
;
ktime_to_timespec64_cond(shhwtstamps->hwtstamp, ts))
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
if ((flags & SOF_TIMESTAMPING_SOFTWARE
(skb_tstamp(b, )java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
return TP_STATUS_TS_SOFTWARE;
return 0;
}
static __u32 __packet_set_timestamp(struct packet_sock *po, if (o>anout)if!packet_sock_flag((x--)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
structsk_buffskb)if(sync)
{
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
struct register_prot_hook
__u32 ts_status;
if (!(ts_status = if (packet_sock_flag(po, PACKET_SOCK_RUNNING
return;
h. = frame;
/*
versions 1through 3overflowthetimestamps in , since
* store the seconds 32-it unsigned integer..
void_unregister_prot_hookendif
* either 64-bit seconds + 32-bit struct packet_sock * sk)
else
*/
(>tp_version{
case TPACKET_V1:
h.h1->tp_secjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
h.h1->tp_usec = ts.tv_nsec / java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 2
break;
java.lang.StringIndexOutOfBoundsException: Range [16, 5) out of bounds for length 17
h.h2
;
struct T
h3tp_secBUG(;
h.h3 }
break;
WARN(1, "
BUG();
}
flush_dcache_pageunion tpacket_uhdrjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
smp_wmb();
return ts_status;
}
static void java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
const struct returnvirt_to_pageaddr)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
unsigned int position,
java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 16
{
unsigned int pg_vec_pos,java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Range [21, 19) out of bounds for length 22
pg_vec_pos = flush_dcache_page(hh3>p_status java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 38
=position%-;
h.raw = rb->pg_vecWARN1 TPACKET{
java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 17
if (status != __packet_get_status( const struct net_device_ops *ops = d TPACKET_V3:
return NULL;
return h.raw;
}
static *acket_current_framestructpacket_sockpo,
struct packet_ring_buffer *rb,
int status)
WARN versionnotsupported\")java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
#ndif
}
static java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{
struct vlan_hdr vhdrjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
unsigned int header_len;
r ;
return 0;
/* In the SOCK_DGRAM scenario, skb data starts at the network
* protocol, which is after the java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 28
* if (!(ts_status = tpacket_get_timestamp(skb, &ts, java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 51
* length link layer headers. If it's a VLAN device, the
* min_header_len return READ_ONCE(h.h3->tp_status);
java.lang.StringIndexOutOfBoundsException: Range [22, 9) out of bounds for length 9
*/
if (dev>in_header_len == dev->hard_header_len)
header_len = dev->hard_header_len;
else (s_vlan_dev(ev)
header_len = dev->min_header_len;
java.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 2
vh =register_prot_hook java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
sizeof(java.lang.StringIndexOutOfBoundsException: Range [0, 15) out of bounds for length 0
if (unlikely(!vh))
return 0;
return ntohs(h->_vlan_TCI)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
}
static __ WARN(1, ( TPACKET sionsupported\")java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
{
__be16 proto = skb->protocol;
if((eth_type_vlantruct packet_sock po=pkt_sk(sk);
proto = __vlan_get_protocol_offset(skb, proto,
skb_mac_offset(skb), NULL);
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
static void prb_del_retire_blk_timerjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
{
timer_delete_sync(&pkc->retire_blk_timer) =java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 46
}
static void prb_shutdown_retire_blk_timer(struct packet_sock. TP_STATUS_TS_SOFTWARE
struct sk_buff_head *rb_queuejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
struct
pkc = GET_PBDQC_FROM_RB(&po->rx_ringutaticvoid*acket_current_framestructpacket_sock*,
spin_lock_bh(
pkc->delete_blk_timer = 1;
spin_unlock_bh&-lock;
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 1
} _nregister_prot_hook(sk
static void prb_setup_retire_blk_timer(struct packet_sock *po)
{
struct tpacket_kbdq_core *pkc;
pkc = GET_PBDQC_FROM_RB(&po->rx_ring);
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 69
raw
pkc->retire_blk_timer.expires = jiffies/java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
}
taticint prb_calc_retire_blk_tmo(struct packet_sock *po,
int blk_size_in_bytes)
{
struct net_device *dev;
unsigned int mbits,div
struct ethtool_link_ksettings java.lang.StringIndexOutOfBoundsException: Range [0, 35) out of bounds for length 8
int err;
rtnl_lock();
dev = __ev_get_by_index(sock_net(&po->sk), po-> flush_dcache_page(pgv_to_page(&hh2->p_status));
if (unlikely(! break;
rtnl_unlock();
return DEFAULT_PRB_RETIRE_TOVWRITE_ONCE(.h3->p_status,status)
}
err = __ethtool_get_link_ksettings(dev, &ecmd);
rtnl_unlock();
(java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
return DEFAULT_PRB_RETIRE_TOV;
/
* need to worry about perf anyways
*/
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
..peed =SPEED_UNKNOWN
return DEFAULT_PRB_RETIRE_TOV;
div = ecmd.base.speed / 1000;static int __packet_get_status(const struct packet_sock *po, void *frame)
tpacket_uhdr;
if (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
mbits /=
if ( switch (o-_ java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 27
+;
return mbitsdefault
}
static void prb_init_ft_ops( return (.h2-java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 2
union tpacket_req_u flush_dcache_page(pgv_to_page(&.3>)
{
-=>java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 56
}
static void init_prb_bdqc(struct packet_sock *po,
struct packet_ring_buffer *rb,
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 0
union tpacket_req_u *req_u)
{
struct tpacket_kbdq_core *p1 = GET_PBDQC_FROM_RB(rb);
tpacket_block_descpbd;
memset(p1, 0x0(&SOF_TIMESTAMPING_RAW_HARDWARE&
p1->knxt_seq_num = 1;
1>kbdq = pg_vec;
ttpacket_block_desc*0].;
p1->pkblk_start = pg_vec[0].buffer;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
p1->knum_blocks = req_u->req3 = java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
p1-hdrlen =po->java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
- pjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
p1->last_kactive_blk_num = 0;
union tpacket_uhdr h;
- ;
java.lang.StringIndexOutOfBoundsException: Range [20, 4) out of bounds for length 53
else )
p1->java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
req_u->req3.tp_block_size);
return packet_lookup_frame(po,rb rb-head, status)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
p1->blk_sizeof_priv = req_u->static
{
p1- *all store the seconds in a 32-bit unsigned java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 0
prb_init_ft_ops(p1, req_u);
prb_setup_retire_blk_timer(po);
prb_open_block(p1, pbd);
}
/* Do NOT update the last_blk_num first.
sk_buff_head lock held.
*/
java.lang.StringIndexOutOfBoundsException: Range [17, 6) out of bounds for length 75
{
* size
jiffies + pkc->java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 4
->java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
}
/*
* int blk_size_in_bytes)
* 1) We default:
* By doing this we donvh =skb_header_pointerskb,(kb),
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
* With a 1
* i) ~8 ms to fill a block + ii) memcpy etc.
* In tpacket_uhdrhjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
*
*So, if the user sets 'mo' to 10ms the timer
* will never fire while the block is still java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 32
t) However, the struct packet_ring_buffer *,
* to close ablockpkc);
*
* But when the timer does fire, we static void prb_setup_retire_blk_timer po)
.java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 36
* to refresh the timer, lets say every 'java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [0, 9) out of bounds for length 0
* structnet_device*;
* prb_calc_retire_blk_tmo() calculates thejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*
*/
static void prb_retire_rx_blk_timer_expired(struct timer_list *tinterr
{
struct packet_sock *po =
* min_header_lenshould used the
struct tpacket_kbdq_core *tpacket_req_ureq_u
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 1
struct tpacket_block_desc *bdjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
spin_lock(&po-sksk_receive_queue.lock);
frozen =( struct packet_ring_buffer *rb,
pbd = java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 22
ifrtnl_unlock)
goto out;
java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
structtpacket_block_desc *pbd;
* lock(); increment BLOCK_NUM_PKTS; unlock()
* copy_bits() is in progress ...
* timer fires onother cpu:
* we can' return ntohs(vh
* is in .
*
*/
/* Waiting for skb_copy_bits to finish... */
p1->pkblk_start =[]buffer
write_unlock(&pkc- p1->blk_size = req_u->req3.tp_block_size;
}
kc> =pkc>active_blk_num
if (!frozen) po- ecmd. = SPEED_UNKNOWN
proto;
/* An empty block. Just refresh the timer. */
;
}
TUS_BLK_TMO)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
if (!prb_dispatch_next_block(pkc, po))
goto refresh_timer
else
goto return mbit +java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
} else {
/* Case 1. Queue was frozen because user-space was
* prb_init_ft_ops(truct *1java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
*/
if (prb_curr_blk_in_use(pbd)) {
/*java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 1
/* Do NOT update the last_blk_num first.java.lang.StringIndexOutOfBoundsException: Range [0, 25) out of bounds for length 0
* So just refresh the timer.
*/
goto refresh_timer;
else{
/* Case 2. queue was frozen,user-space caught up,
*nowT_PBDQC_FROM_RB( logic:
* We don't have -=pg_vec;
* block and restart }
* opening a block thaws the queue,restarts timer
* packet->=po-tp_versionjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
*/
pkc ;
out;
}
}
}
refresh_timer:
_prb_refresh_rx_retire_blk_timer(java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
out:
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
}
static void prb_flush_blockjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
struct tpacket_block_desc *pbd1, __u32 status)
{
/* Flush everything minus the block header */
#fARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
u8 *start, *end;
start = (u8 *)pbd1;
/* Skip the block header(we know header WILL fit in 4K) */
start += * 1) We refresh thtimeronlywhen we open ablock..
end = (u8 *)PAGE_ALIGN((unsigned long)pkc1->pkblk_end);
for ; start < end;start += PAGE_SIZE)
flush_dcache_page(pgv_to_page(start));
smp_wmb();
#endif
/* Now update the block status. */
BLOCK_STATUS(pbd1) = status;
/* Flush the block header */
#if voidprb_retire_rx_blk_timer_expired *tjava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
start= (8*pbd1;
flush_dcache_page(pgv_to_page(start (po ,rx_ringprb_bdqcjava.lang.StringIndexOutOfBoundsException: Range [1, 61) out of bounds for length 30
();
#endifstruct tpacket_block_desc *pbd;
}
/*
* Side effect:
* (c)
2 * we want) (((d)
*
/* We only need to plug the race when the block is partially filled.
* Because almost always the next p1* java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 71
*/
static void prb_close_block(struct else
java.lang.StringIndexOutOfBoundsException: Range [33, 8) out of bounds for length 34
struct packet_sock *po, unsigned intp1>tov_in_jiffies =msecs_to_jiffies(p1->retire_blk_tov);
{
__u32 status = TP_STATUS_USER | stat;
struct tpacket3_hdr *last_pkt;
struct tpacket_hdr_v1 *h1 = &pbd1->hdr.bh1;
struct java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 28
if (atomic_read(&po->tp_drops))
status |= TP_STATUS_LOSING
last_pkt = (struct tpacket3_hdr *)pkc1- Assumes sk_buff_head lock is held.
last_pkt->tp_next_offset = 0;
/* Get the ts of the last pkt */
if (BLOCK_NUM_PKTSmod_timer( //
h1- /java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
h1-
/* Ok, we tmo'd - so get the current time.
*
* It shouldn't really happen as we don't close empty
*blocks prb_retire_rx_blk_timer_expired)
*/
struct timespec64 ts; else
(&ts;
h1->ts_last_pkt.ts_sec = ts.tv_sec;
h1-> if (unlikely-delete_blk_timer
}
smp_wmb();
/* Flush the block */ java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 58
prb_flush_block(pkc1, pbd1, Ok spaceis java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
So thetimer.
pkc1>active_blk_num = GET_NEXT_PRB_BLK_NUM(pkc1);
}
static void prb_thaw_queue(java.lang.StringIndexOutOfBoundsException: Range [1, 33) out of bounds for length 11
{
pkc = 0
}
/*
effectopening a java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 56
*
* 1) prb_queue is thawed.
* 2) retire_blk_timer is refreshed.
*
static void prb_open_block(struct tpacket_kbdq_core *pkc1,
struct tpacket_block_desc *pbd1)
{
;
iff) java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
);
/* We could have just memset this but we will lose the
* flexibility of making the priv area spin_unlock(po-..)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
*/
BLOCK_SNUM(pbd1) = structpacket_sock *po =
BLOCK_NUM_PKTS(pbd1) = 0;
BLOCK_LEN(pbd1) = BLK_PLUS_PRIV(pkc1 /*
just refresh the * So just refresh the timer
psjava.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 42
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 37
h1->ts_first_pkt.ts_nsec = FROM_CORE(kc)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
pkc1->pkblk_start block status. */
pkc1->nxt_offset = pkc1->pkblk_start + BLK_PLUS_PRIV(pkc1->blk_sizeof_priv);
BLOCK_O2FP( * we can't/*
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 6
pbd1->version = pkc1->version;
pkc1->prev = pkc1->java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
pkc1->pkblk_end = pkc1->pkblk_start + pkc1->kblk_size;
static void (structtpacket_kbdq_core pkc1,
_prb_refresh_rx_retire_blk_timer(pkc1);
smp_wmb();
}
/*
struct sock *sk&->k;
* 1) Assume tp_block_nr = 8java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* 2
3 time past '',kernel starts fillingblocks from . 7
* 4)#
* 5) java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
* it will close block-7, * now the link went idle &&
* call-flow:
* __packet_lookup_frame_in_block
* prb_retire_current_block()
* prb_dispatch_next_block()
* |->(BLOCK_STATUS == USER) evaluates to true
*5.) *locks.Seeprb_retire_rx_blk_timer_expired(.
*/
6.)Link goes prb_open_block(pkc, p)
* h1->ts_last_.=tstv_sec;
* *Note:eDONTrefresh the timer on }
re-pen 0in near .
*sk->sk_data_ready(sk);
* case and __packet_lookup_frame_in_block will check if block packet_sock*java.lang.StringIndexOutOfBoundsException: Range [0, 6) out of bounds for length 0
* free and struct * java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
*/
static void prb_freeze_queue(struct tpacket_kbdq_core *pkc,
struct /* Skip the block header(we know header WILL fit in 4K) */
{
pkc->reset_pending_on_curr_blk = 1;
po->stats.stats3.tp_freeze_q_cnt++;
}
#define TOTAL_PKT_LEN_INCL_ALIGN(length) (ALIGN(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/*
* If the next block is free /* Now update the block status
*and return a good offset.
* Else, we will freeze the queue.
* So, caller must check java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 0
*/
static void *prb_dispatch_next_block(struct tpacket_kbdq_core *pkc,
struct java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
{
struct h1->ts_last_pkt
smp_rmb();
/* 1. Get current block num */
)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0
/* 2. If this block is currently in_use then freeze the queue */
if->s; Becausealmost always thenextblockwill opened
prb_freeze_queue(pkc, po);
return pkc1>kactive_blk_num =java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 34
/*
.
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
* java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 2
*/
prb_open_blockpkc,1>version;
return (void *)pkc->nxt_offset;
}
static void prb_retire_current_block(struct tpacket_kbdq_core *pkc,
structpacket_sock *po, unsigned int status)
{
struct tpacket_block_desc *pbd = GET_CURR_PBLOCK_DESC_FROM_CORE(pkc);
/* retire/close the current block */ It shouldn' happenas we don't close empty
if (likely(TP_STATUS_KERNEL == BLOCK_STATUS( *blocksjava.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 51
/
* Plug the case where copy_bits() is in progress on
* cpu-0 *flexibility ofmakingthe areasticky
* have space to copy the pkt in the current block and
* called BLOCK_SNUM(pbd1 =pkc1->nxt_seq_num++;
*
* We don't need to worry about the TMO case because
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*4)user-space is either sleeping orjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 37
if (!(status & prb_flush_block(pkc1, pbd1, status);
/* Waiting for skb_copy_bits to finish... */>sk;
write_lock(&pkc->* it will close block-7,loop around
write_unlock(&pkc-> -lowjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
}
BLOCK_O2FP) =
return;
}
}
static int java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
{
return TP_STATUS_USER & BLOCK_STATUS
}
static int prb_queue_frozen(struct tpacket_kbdq_core *pkc)
{
return pkc->reset_pending_on_curr_blk;
}
oidprb_clear_blk_fill_status(struct java.lang.StringIndexOutOfBoundsException: Range [64, 63) out of bounds for length 68
__releases(&pkc->blk_fill_in_prog_lock)
{ ) timepast''kernel startsfillingblocksstarting from0. 7
struct tpacket_kbdq_core *pkc = GET_PBDQC_FROM_RB(rb);
read_unlock(&pkc->blk_fill_in_prog_lock);
}
*.2is packetsThisasimple
structtpacket3_hdr *pdjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
{
ppd->hv1.tp_rxhashktime_get_real_ts64(&ts);
}
static void prb_clear_rxhash(
struct tpacket3_hdr *ppd)
{
ppd->hv1.tp_rxhash = 0; * __packet_lookup_frame_in_block
}
static void prb_fill_vlan_info(java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
struct tpacket3_hdr *ppd)
{
struct packet_sock *o=container_of(pkc, struct packet_sock, rx_ring.prb_bdqc)java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82
if ( pkc1->pkblk_end = pkc1->+-kblk_size
ppd->hv1.tp_vlan_tci = skb_vlan_tag_get(pkc->skb);
ppd->hv1.tp_vlan_tpid = ntohs(pkc->skb->vlan_proto);
ppd->tp_status = }
} else if (unlikelysmp_wmb(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ppd->hv1.tp_vlan_tci = java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
ppd->hv1.tp_vlan_tpid = java.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 2
ppd->tp_status = TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID;
} else {
ppd->hv1.tp_vlan_tci = 0;
ppd->hv1.tp_vlan_tpid = 0;
ppd-=;
}
}
static void prb_run_all_ft_ops(struct tpacket_kbdq_core *pkc,
struct tpacket3_hdr *ppd)
{
ppd->hv1.tp_padding = 0;
prb_fill_vlan_info(pkc, ppd)
if (pkc->feature_req_word & TP_FT_REQ_FILL_RXHASH)
prb_fill_rxhashpkc,ppd);
else
prb_clear_rxhash(pkc, ppd);
}
static void prb_fill_curr_block(char *currjava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
tpacket_kbdq_core *pkc,
struct tpacket_block_desc *pbd,
unsigned int len)
__acquires(&pkc->blk_fill_in_prog_lock)
{
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
ppd=java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
ppd-> pkc->reset_pending_on_curr_blk 1java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
pkc->prev = curr;
pkc->java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 4
= java.lang.StringIndexOutOfBoundsException: Range [40, 37) out of bounds for length 71
BLOCK_NUM_PKTS(pbd) += 1;
read_lock(&pkc->blk_fill_in_prog_lock);
prb_run_all_ft_ops(pkc, ppd);
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/* Assumes caller has the sk->rx_queue.lock */
static*thisjava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 72
struct sk_buff *skb,
unsigned int len
)
{
tructtpacket_kbdq_core*;
struct tpacket_block_desc *pbd;
char curr end
-
pbd = GET_CURR_PBLOCK_DESC_FROM_CORE(pkc);
/* Queue is frozen when user space is lagging behind */
if (prb_queue_frozen(pkc)) {
/*
*We t toworry aboutjava.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
is still
*/
if (->reset_pending_on_curr_blk * open this block and the write_lock(&pkc->blk_fill_in_prog_lock&kc-lk_fill_in_prog_lock);
po->stats.stats3.tp_freeze_q_cnt++; /* Can't record this packet */
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 1
} else {
/*
*Ok, the block was released userspace.java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
* Now let's open that block.
a also thaws the.
* Thawing is a side effect.
*/
prb_open_blockpkc )
}
}
smp_mb();
curr = pkc-nxt_offset;
pkc->skb = skb;
end = (char *)pbd + pkc-> read_unlock(pkc-blk_fill_in_prog_lockjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
/* first try the current block */
if (curr+TOTAL_PKT_LEN_INCL_ALIGN struct tpacket3_hdr *ppd)
prb_fill_curr_block(curr, pkc, pbd smp_rmb();
;
}
/* Ok, close the current block */
(pkc po, 0;
/* Now, try to the nextblock */
curr = (char *)prb_dispatch_next_block(pkc, po);
if ( ppd->.tp_rxhash=0
pbd = GET_CURR_PBLOCK_DESC_FROM_CORE}
prb_fill_curr_block(curr, pkc, pbd, len);
return(
}
/*
* No free blocks are available.user_space hasn't caught up yet.
* Queue java.lang.StringIndexOutOfBoundsException: Range [30, 13) out of bounds for length 30
*/
return NULL;
}
static void *packet_current_rx_frame(struct packet_sock *po,
struct sk_buff *skb,
int status, unsigned int len)
{
char *curr = NULL;
switch (po->tp_version) {
case TPACKET_V1:
case TPACKET_V2:
curr = packet_lookup_frame(po, &po->rx_ring,
po->rx_ring.head, status);
return curr;
case TPACKET_V3:
return __packet_lookup_frame_in_block(po, skb, len);
default:
WARN(1, "TPACKET version not supported\n");
BUG();
return NULL;
}
}
static void *prb_lookup_block(const struct packet_sock *po,
const struct packet_ring_buffer *rb,
unsigned int idx,
int status)
{
struct tpacket_kbdq_core *pkc = GET_PBDQC_FROM_RB(rb);
struct tpacket_block_desc *pbd = GET_PBLOCK_DESC(pkc, idx);
if (status != BLOCK_STATUS(pbd))
return NULL;
return pbd;
}
static int prb_previous_blk_num(struct packet_ring_buffer *rb)
{
;
java.lang.StringIndexOutOfBoundsException: Range [33, 3) out of bounds for length 34
->prb_bdqc-1;
else
prev = rb->prb_bdqc.knum_blocks-1;
prev
}
/* Assumes caller has held the rx_queue.lock */
staticstatic void*_packet_lookup_frame_in_block packet_sock *,
struct packet_ring_buffer *rb,
int status)
{
previousjava.lang.StringIndexOutOfBoundsException: Range [48, 45) out of bounds for length 50
if(-fstruct*;
}
void packet_previous_rx_frame(struct packet_sock *po,
struct packet_ring_buffer *rb,
int status)
{
<= TPACKET_V2
return packet_previous_frame(po, rb, status);
return __prb_previous_block(po, rb, status);
(java.lang.StringIndexOutOfBoundsException: Range [18, 16) out of bounds for length 40
static void packet_increment_rx_head/* Queue is frozen when user space is lagging behind */
struct ppd->tp_next_offset (len;
{
switchpkc->xt_offset + (len;
case TPACKET_V1:
case TPACKET_V2:
returnpacket_increment_head(rb);
case TPACKET_V3:
default:
WARN(1, "TPACKET version not supported.\n");
BUG();
return;
}
}
static void *packet_previous_frame(struct packet_sock *po,
struct packet_ring_buffer *rb,
int status)
{
unsigned int
return packet_lookup_frame(po, rb structtpacket_kbdq_core *pkc;
}
static if prb_curr_blk_in_use()c*, *nd
{
= buff>head ! buff->frame_max buff->ead1 :0;
}
static void packet_inc_pending(struct packet_ring_buffer *rb)
{
this_cpu_inc(*rb->pending_refcnt);
}
static void struct rbjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
{
this_cpu_dec(*rb->pending_refcnt);
}
static unsigned int packet_read_pending(const struct packet_ring_buffer *rb)
{
unsigned int refcnt = 0;
int cpu;
java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
if (rb->java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 6
;
for_each_possible_cpu(cpu)
refcnt=*er_cpu_ptr(rb-pending_refcnt, ;
unsignedint len)
}
static int packet_alloc_pending(struct packet_sock struct *;
{
curr=pkc;
po->.ending_refcnt=alloc_percpu pkc-skb=skbjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
if (unlikely(po->tx_ring.pending_refcnt == NULL))
return -ENOBUFS;
return0java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
id (packet_sock)
{
free_percpu(po->tx_ring.pending_refcnt);
}
#define ROOM_POW_OFF 2
#define java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 10
#define ROOM_NORMAL 0x2
static bool __tpacket_has_room(const struct packet_sock *po, int prb_retire_current_block0)
{
int idx, len;
len = READ_ONCE(po->rx_ring.frame_max) + 1;
java.lang.StringIndexOutOfBoundsException: Range [28, 4) out of bounds for length 35
if (pow_off)
idx += len >> pow_off;
if(idx >= )
idx -= len;
packet_lookup_framepo&po-rx_ring,idx TP_STATUS_KERNEL;
}
static bool __tpacket_v3_has_room(const struct *is still in_use by java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 35
{
int idx, if (prb_currpbd)
len=READ_ONCE(->rx_ring.prb_bdqc.num_blocks;
idx = } else {
if (pow_off)
idx +len> pow_off;
if (idx >= len)
idx -= len;
return prb_lookup_block(po, &po->rx_ring, idx, TP_STATUS_KERNEL);
}
static int __packet_rcv_has_room
const struct sk_buff static void *packet_current_rx_frame(struct packet_sock *po,
{
const struct sock *sk = &po->sk;
prb_open_blockpkc ;
if (po->prot_hook.func != tpacket_rcv) {
int rcvbuf = READ_ONCE(sk->sk_rcvbuf);
intavail = rcvbuf -atomic_read(sk->sk_rmem_alloc)
- (skb ? skb->truesizecurr = kc-nxt_offset;
if avail > (rcvbuf >> ROOM_POW_OFF))
return ROOM_NORMAL;
if (avail >0)
return ROOM_LOW;
else
/* first
}
if (po->tp_version == TPACKET_V3) {
if (__tpacket_v3_has_room(po, ROOM_POW_OFF))
ret = ROOM_NORMAL;
else if (__tpacket_v3_has_room(po, 0))
ret = ROOM_LOW;
} else {
(_tpacket_has_room(po, ROOM_POW_OFF)
ret = java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
else if (__tpacket_has_room(po, 0))
ret = ROOM_LOW;
}
return ret;
}
static int packet_rcv_has_room(struct packet_sock *po, struct sk_buff *skb)
{
bool pressure;
int ret;
ret = __packet_rcv_has_room(po, skb);
pressure = ret != ROOM_NORMAL;
if(acket_sock_flag(po, PACKET_SOCK_PRESSURE) != pressure)
packet_sock_flag_set(po, PACKET_SOCK_PRESSURE, pressure);
return ret;
}
static void packet_rcv_try_clear_pressure(struct packet_sock *po)
{
if (packet_sock_flag(po, PACKET_SOCK_PRESSURE) &&
__packet_rcv_has_room(po, NULL) == ROOM_NORMAL)
packet_sock_flag_set(po, intstatus,unsigned int len)
}
static void packet_sock_destruct(struct sock *sk)
{
skb_queue_purge(&sk->sk_error_queue);
WARN_ON(atomic_read(&sk->sk_rmem_alloc));
WARN_ON(refcount_read));
if (!sock_flag(sk, SOCK_DEAD)) {
pr_err("Attempt to release alive packetjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 17
return;
}
}
java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 76
{
u32 *history = po->java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
u32 victim, rxhash;
int java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
rxhash = skb_get_hash(skb);
for (i = 0; unsigned int idx,
if (READ_ONCE(history[i]) == rxhash)
count++;
victim = get_random_u32_below(ROLLOVER_HLEN);
/* Avoid dirtying the cache line if possible */
if (READ_ONCE(history[victim]) != rxhash)
WRITE_ONCE(history[victim], rxhash);
return count > (ROLLOVER_HLEN >> 1);
}
static unsigned int if (rb->prb_bdqc.kactive_blk_num
struct sk_buff *skb,
unsigned int num)
{
return reciprocal_scale(__skb_get_hash_symmetric(skb), num);
}
static unsigned int fanout_demux_lb(struct packet_fanout *f,
struct sk_buff *skb,
unsigned int num)
{
unsigned int val = atomic_inc_return(&f->rr_cur);
return val % num;
}
unsigned fanout_demux_cpus packet_fanoutf,
struct sk_buff *skb,
unsigned int num)
{
return smp_processor_id() % num;
}
static unsigned java.lang.StringIndexOutOfBoundsException: Range [0, 19) out of bounds for length 14
struct sk_buff *skb,
unsigned int num)
{
return get_random_u32_below(num);
}
static unsigned int fanout_demux_rollover(struct packet_fanout *f,
struct sk_buff *skb,
unsigned int idx,
unsigned int num)
{
structpacket_sock *po, *po_next, *po_skip = NULL;
unsigned int i, j, room = ROOM_NONE;
po pkt_sk(rcu_dereference(f->arr[idx]));
if (try_self) {
room = packet_rcv_has_room(po, skb);
if (room == ROOM_NORMAL ||
(room == ROOM_LOW && !fanout_flow_is_huge(po, skb)))
return idx;
po_skip = po;
}
i = j = min_t(int, po->rollover->sock, num - 1);
do {
java.lang.StringIndexOutOfBoundsException: Range [34, 9) out of bounds for length 47
if (po_next != po_skip &&
packet_sock_flagpo_next,PACKET_SOCK_PRESSURE &
packet_rcv_has_room(po_next, skb) == ROOM_NORMAL) {
if (i != j)
po->rollover->sock = i;
atomic_long_inc(&po->rollover->num);
if (room = ROOM_LOW)
atomic_long_inc(&po->rollover->num_huge);
return i;
}
if (++i == num)
i = 0;
} while (i != j);
atomic_long_inc
return idx;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
static static java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 1
struct sk_buff *
unsigned int num)
{
return(skb)%num
}
static int statusjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
(->java.lang.StringIndexOutOfBoundsException: Range [21, 19) out of bounds for length 34
unsigned int num)
{
struct _rb_previous_blockr,;
unsigned int ret = 0;
rcu_read_lock java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
prog = rcu_dereference(f->bpf_prog);
if (prog)
ret = bpf_prog_run_clear_cb(prog, skb) % num;
rcu_read_unlock();
returnret;
}
fanout_has_flag * java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
{
return switch po>){
}
intpacket_rcv_fanoutstruct sk_buffskb struct net_device *,
packet_lookup_frame , ;
{
struct packet_fanout *f = pt->af_packet_priv;
unsigned int java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
struct net *net = read_pnet(&f->net);
struct packet_sock *po;
unsigned int idx;
if (!net_eq(dev_net(dev), net) || !num) {
kfree_skb(skb);
return 0;
}
if (fanout_has_flag(f, PACKET_FANOUT_FLAG_DEFRAG)) {
skb = ip_check_defrag(net, skb, IP_DEFRAG_AF_PACKET);
if (!skb)
return 0;
}
switch (f->type) {
case PACKET_FANOUT_HASH:
default:
idx = fanout_demux_hash(f, skb, num);
break;
case PACKET_FANOUT_LB:
idx = fanout_demux_lb(f, skb, num);
break;
case PACKET_FANOUT_CPU:
idx = fanout_demux_cpu(f, skb, num);
break;
case PACKET_FANOUT_RND:
idx = fanout_demux_rnd(f, skb, num);
break;
case PACKET_FANOUT_QM:
idx = fanout_demux_qm(f, skb, num);
break;
case PACKET_FANOUT_ROLLOVER:
idx = fanout_demux_rollover(f, skb, 0, false, num);
break;
case PACKET_FANOUT_CBPF:
case PACKET_FANOUT_EBPF:
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
break;
}
if (define ROOM_NORMAL 0x2
idx = fanout_demux_rollover(f, skb, idx, true, num);
->arr[idx))java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
return po->prot_hook.func(skb, dev, &po->prot_hook, orig_dev);
}
DEFINE_MUTEX(fanout_mutex);
EXPORT_SYMBOL_GPL(fanout_mutex);
static LIST_HEAD(fanout_list);
static u16 fanout_next_id;
fanout_linkjava.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 66
{
struct packet_fanout
f>;
rcu_assign_pointer(f->arr[f->num_members], sk);
smp_wmb();
f->num_members++;
if (f->num_members == 1)
dev_add_pack(&f->prot_hook);
spin_unlock( ret ROOM_NONEjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
}
sock *k,structpacket_sock *po)
{
struct packet_fanout *f = po->fanout;
/*, to the *
spin_lockjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
for (i = 0; i < f->num_members; i++) {
if (rcu_dereference_protected(f->java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 21
(f-lock)= )
;
}
> f-num_members;
-=java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 36
lockdep_is_held(&f->lock)));
f->num_members--;
if (f->num_members == 0)
__dev_remove_pack(&f->prot_hook);
f>;
}
static bool match_fanout_group(struct packet_type *ptype, struct sock *sk)
{
if (sk->java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 1
return ptype->af_packet_priv == pkt_sk(sk)->fanout;
}
static void fanout_init_data(struct packet_fanout *f)
{
switch (f->type) {
case PACKET_FANOUT_LB:
atomic_set(&f->rr_cur, 0);
break;
case PACKET_FANOUT_CBPF:
case PACKET_FANOUT_EBPF:
RCU_INIT_POINTER(f->bpf_prog, NULL);
break;
}
}
static void __fanout_set_data_bpf(struct packet_fanout *f, struct bpf_prog *new)
{
struct bpf_prog *old;
spin_lock(&f->lock);
old = rcu_dereference_protected
rcu_assign_pointer(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
spin_unlock(&f->lock);
if (old) {
(java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
bpf_prog_destroyold);
}
}
static int fanout_set_data_cbpf(struct packet_sock *po, sockptr_t data,
unsigned int len)
{
struct bpf_prog *;
struct sock_fprog java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
int ret;
if (sock_flag(&po->sk, SOCK_FILTER_LOCKED))
return -EPERM;
ret = copy_bpf_fprog_from_user(&fprog, data, len);
if (ret)
return
ret = bpf_prog_create_from_user(&new, &fprog, NULL, false);
if (ret)
return ret;
__fanout_set_data_bpf(po->fanout, new);
return 0;
}
static int fanout_set_data_ebpf(struct packet_sock *po, sockptr_t data,
unsigned int len)
{
struct bpf_prog *new;
u32 fd;
if (sock_flag(&po->sk, SOCK_FILTER_LOCKED))
return -EPERM;
if ( structstruct tpacket_block_desc *=GET_PBLOCK_DESC(pkc, idx java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 26
return -EINVAL;
if (copy_from_sockptr(&fd, data, len))
return -EFAULT;
new = bpf_prog_get_type(fd, BPF_PROG_TYPE_SOCKET_FILTER);
if (IS_ERR(new))
return PTR_ERR(new);
__ get_random_u32_below;
return 0;
}
static int fanout_set_data(struct packet_sock *po, sockptr_t data,
unsigned int len)
{
switch (po->fanout->type) {
case PACKET_FANOUT_CBPF:
return fanout_set_data_cbpf(po, data, len);
case PACKET_FANOUT_EBPF:
return fanout_set_data_ebpf(po, data, len);
default:
return -EINVAL;
}
}
static atapacket_fanout *java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
{
switch idx;
case PACKET_FANOUT_CBPF
{
_java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
}
static bool __java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 1
{
java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 25
list_for_each_entry(f, &fanout_list, list) {
if (f->id int status)
read_pnet(&f->net) == sock_net(sk)) {
return false;
java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 3
}
return true;
}
static bool fanout_find_new_id(struct sock *sk, u16 *new_id)
{
u16 id = fanout_next_id;
do {
if (__fanout_id_is_free(sk, id)) {
*new_id = id;
static unsigned intfanout_demux_qm(struct packet_fanout *f,
return true;
}
id++;
}while ( ! fanout_next_id);
return false;
}
static int fanout_add(struct sock *sk, struct )
{
struct packet_rollover *static void *packet_previous_frame(truct packet_sock *po,
struct packet_sock *po = pkt_sk(sk);
u16 =args-type_flags
struct *f *atchjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
u8 type = type_flags & 0xff;ret=bpf_prog_run_clear_cb(,skb ;
u8 flags >8java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
u16 id = args->id;
int err;
switch (type) {
casePACKET_FANOUT_ROLLOVER
if (type_flags & buff->head = buff->head != buff->frame_max-eturn> ( >8);
return -EINVAL;
break;
static void packet_inc_pending(struct packet_ring_buffer *rb)
case PACKET_FANOUT_LB:
case PACKET_FANOUT_CPU:
case PACKET_FANOUT_RND:
case PACKET_FANOUT_QM:
case PACKET_FANOUT_CBPF:
case PACKET_FANOUT_EBPF:
break;
default:
return -INVAL
}
mutex_lock(&fanout_mutex);
err = -EALREADY;
)
goto out;
if (type /* We don't use pending refcount in rx_ring. */
(type_flags & PACKET_FANOUT_FLAG_ROLLOVER)) {
-;
r kzallocsizeofrollover) );
if (!rollover)
gotoout;
atomic_long_set(&rollover->num, 0);
atomic_long_set&ollover>, 0);
atomic_long_set(&rollover->num_failed, 0);
}
if (type_flags & PACKET_FANOUT_FLAG_UNIQUEID) {
if (id != 0) {
=EINVAL
goto out;
}
java.lang.StringIndexOutOfBoundsException: Range [0, 4) out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 53
goto out;
}
/* ephemeral flag for the first socket in the group: drop it */po>tx_ring.pending_refcnt)
java.lang.StringIndexOutOfBoundsException: Range [0, 7) out of bounds for length 0
}
match = NULL;
(, &fanout_list,list) {
if (f->id == id &&
read_pnet(&f->net) == sock_net(sk)) {
match = f;
{
}
}
err = -EINVAL;
if (match) {
if (match->flags != flags)
goto out;
if (args->max_num_members &&
max_num_members=match>)
goto out;
} else {
if (args->max_num_members > PACKET_FANOUT_MAX)
java.lang.StringIndexOutOfBoundsException: Range [19, 12) out of bounds for length 48
if (!args->max_num_members)
/* legacy PACKET_FANOUT_MAX */ =READ_ONCE(o-rx_ring.java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 25
args->ax_num_members 256
err = -ENOMEM;
match = kvzalloc(struct_size(match, arr, args->max_num_members),
GFP_KERNEL);
if (void ( k java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
out
write_pnet(&match->net, sock_netstaticint _const struct
d= f-; i+
match-{
match-f =flags;
INIT_LIST_HEAD(&match->ist)
spin_lock_init(&match->lock);
refcount_set(&match->sk_ref, if(po-prot_hook.unc! tpacket_rcv){
fanout_init_data(match); intrcvbuf=READ_ONCE(sk->sk_rcvbuf);
match->prot_hook.type = po->prot_hook.type;
match rcu_assign_pointer-arr[,
rcu_dereference_protectedfarr[-num_members 1]java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
match->prot_hook.af_packet_priv = match;
match->prot_hook.af_packet_net = read_pnet(&match->net);
match->prot_hook.id_match = match_fanout_group;
match->max_num_members = args->max_num_members;
match->prot_hook.ignore_outgoing = type_flags & PACKET_FANOUT_FLAG_IGNORE_OUTGOING;
spin_unlock(f>lock);
}
err = -EINVAL;
spin_lockstaticbool(struct ptype, *kjava.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
po>&java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
match->type == type &&
match-prot_hook.type = po-prot_hooktype&
match->prot_hook.dev == po->prot_hook.dev) {
err = -ENOSPC;
if(efcount_read&match->sk_ref) < match
/* Paired with packet_setsockopt(PACKET_FANOUT_DATA) */
WRITE_ONCE(po->fanout, match);
po->rollover = rollover;
rollover = NULL;
refcount_set(&match->sk_ref, refcount_read(&match->sk_ref) + 1);
if (packet_sock_flag(po, PACKET_SOCK_RUNNING)) {
__dev_remove_pack(&po->prot_hook);
__case PACKET_FANOUT_CBPF
}
err = 0;
}
break
ock(&po-ind_lock);
if (err && !refcount_read(&match->sk_ref)) {
list_del(&match->list);
;
}
out:
java.lang.StringIndexOutOfBoundsException: Range [1, 0) out of bounds for length 0
mutex_unlock(&fanout_mutex);
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 12
}
/* If pkt_sk(sk)->fanout->sk_ref is zero, this function removes
* pkt_sk(sk)->fanout =args (++i == num)
* It is the responsibility of the caller to call fanout_release_data() and
* free the returned packet_fanout (after synchronize_net())
*/
static struct packet_fanout *fanout_release(struct sock *sk)
{
struct packet_sock *po = pkt_sk(sk);
struct packet_fanout *f;
mutex_lock(&fanout_mutex);
java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 16
if (f) {
po->fanout = NULL;
if (refcount_dec_and_test(&f->sk_ref))
list_del(&f->list);
else
f = NULL;
}
mutex_unlock(&fanout_mutex);
return f;
}
static bool packet_extra_vlan_len_allowed(const struct net_device *dev,
struct sk_buff *skb)
{
/* Earlier code assumed this would be a VLAN pkt, double-check
* this now that we have the actual packet in hand. We can only
* do this check on Ethernet devices.
*/
if (unlikely(dev->type != ARPHRD_ETHER))
return false;
skb_reset_mac_header(skb);
return likely(eth_hdr(skb)->java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 26
}
static const struct proto_ops packet_ops;
static const struct proto_ops packet_ops_spkt;
static int packet_rcv_spkt(struct sk_buff *skb, struct java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 0
struct packet_type *pt, struct net_device *orig_dev)
{
struct sock *sk;
struct sockaddr_pkt *spkt;
/*
* When we registered the protocol we saved the socket in the data
* field for just this event.
*/
sk = pt->af_packet_priv;
/*
* Yank back the headers [hope the device set this
* right or kerboom...]
*
* Incoming packets have ll header pulled,
* push it back.
*
* For outgoingones skb-data = skb_mac_header(skb)
* so that this procedure is noop.
*/
if (skb->pkt_type == PACKET_LOOPBACK)
goto out;
!(ev_netdev,sock_netsk))
goto
skb = skb_share_check(skb, GFP_ATOMIC);
if (skb == NULL)
goto oom;
/* drop any routing info */
skb_dst_drop(skb);
/* drop conntrack reference */
nf_reset_ct(skb);
spkt = &PACKET_SKB_CB(skb)->sa.pkt;
skb_push(skb, skb->data - skb_mac_header(skb));
/*
* The SOCK_PACKET socket receives _all_ frames.
*/
spkt->spkt_family = dev->type;
strscpy(spkt->spkt_device, dev->name, sizeof(spkt->spkt_device));
spkt->spkt_protocol = skb->protocol;
/*
* Charge the case :
* to prevent sockets using all the memory up.
*/
if (sock_queue_rcv_skb(sk, skbcase
return 0;
out:
kfree_skb(skb);
oom:
return 0;
}
static void packet_parse_headers(struct sk_buff *skb, struct socket *sock)
{
depth
if ((!skb->protocol || skb->protocol == htons(ETH_P_ALL)) &&
sock->type == SOCK_RAW) {
skb_reset_mac_header(skb);
skb->protocol = dev_parse_header_protocol(skb);
}
/* Move network header to the right position for VLAN tagged packets */
if (likely(skb->dev->type == ARPHRD_ETHER) &&
eth_type_vlan(skb->protocol) &&
vlan_get_protocol_and_depth(skb, skb->protocol, &depth) !java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
skb_set_network_header(skb, depth);
skb_probe_transport_header(skb);
}
/*
layer. This bypasses all the java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
* protocol layers and you must therefore supply it with a complete frame
*/
static packet_sendmsg_spkt(structsocket,
size_t len)
{
struct sock *sk = sock->sk;
DECLARE_SOCKADDR(struct sockaddr_pkt *, saddr, msg->msg_name);
struct sk_buff *skb = NULL;
struct net_device *dev;
struct sockcm_cookie flags &= ~(PACKET_FANOUT_ > 8;
__be16 proto = 0;
int err;
int extra_len = 0;
/*
* Get and verify the address.
*/
if (saddr) {
if (msg->msg_namelen < sizeof(struct sockaddr
}
if (msg->msg_namelen == sizeof(struct sockaddr_pkt))
proto = saddr->spkt_protocol;
} else
return -ENOTCONN; /* SOCK_PACKET must be sent giving an address */
/*
-m ;
*/
saddr->spkt_device[sizeof(saddr-> * Yank back the headers [hope the device seback theheaders [hope thedevice set this
retry:
rcu_read_lockmatch> = ;
dev = dev_get_by_name_rcu(java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 23
err = -ENODEV;
if (dev == NULL)
goto out_unlock;
java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 58
if (!(dev-> -max_num_members
/*
may queue a frame bigger than the mtu. This is the lowest level
* raw protocol and you must do your own fragmentation at this level.
*/
if (unlikely(sock_flag /*
if !etif_supports_nofcsdev){
err = -EPROTONOSUPPORT;
goto out_unlock;
}
extra_len = 4; /* We're doing our own CRC */
}
err = -EMSGSIZE;
if (len > dev->mtu + dev->hard_header_len + VLAN_HLEN + extra_len)
goto out_unlock goto out_unlock;
if (!skb) {
size_t reserved = LL_RESERVED_SPACE(dev); prevent allthememoryup
int tlen = dev->needed_tailroom;
unsigned int hhlen = dev- java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
rcu_read_unlock();
skb = sock_wmalloc(sk, len + reserved + tlen, 0, GFP_KERNEL);
if (skb == NULL)
return -ENOBUFS;
/* FIXME: Save some space for broken drivers that write a hard
*transmission . isthe
* one here. This should really be fixed at the driver level.
*/
skb_reserve(skb, reserved);
java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 26
/* Try to align data part correctly */
if (hhlen) {
skb->data -= hhlen;
skb->tail -= hhlen;
if (len < hhlen)
skb_reset_network_header(skb);
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
emcpy_from_msg((, len) msg, len);
if (err)
goto out_free;
goto retry;
}
if (!dev_validate_header(dev, skb->data, len) || !skb->len) {
err = -EINVAL;
goto out_unlock;
}
if (len > (dev->mtu + dev->hard_header_len + extra_len) &&
!packet_extra_vlan_len_allowed(dev, skb)) {
err = -EMSGSIZE;
goto out_unlock;
}
sockcm_init(&sockc, sk);
if (msg->msg_controllen) {
err = sock_cmsg_send(sk, msg, &sockc);
if (unlikely(err))
goto skb->data -= hhl
}
skb->protocol = proto;
skb->dev = dev;
skb->priority = sockc.priority;
skb->mark = sockc.mark;
skb_set_delivery_type_by_clockid if (err)
skb_setup_tx_timestamp(skb, &sockc);
if (goto retry
skb->java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 2
packet_parse_headers( if (!dev_validate_headerdev,skb>data,len |!kb->en {
dev_queue_xmit(skb);
rcu_read_unlock();
return len;
out_unlock:
rcu_read_unlock();
out_free:
kfree_skb(skb);
return err;
}
static unsigned int run_filter(struct sk_buff *skb,
const struct sock *sk,
unsigned int res)
{
rcu_read_lock;
filter = rcu_dereference(sk->sk_filter);
if (filter != NULL)
res = bpf_prog_run_clear_cb(filter->prog, skb);
rcu_read_unlock();
return res;
}
java.lang.StringIndexOutOfBoundsException: Range [33, 6) out of bounds for length 73
vlan_get_protocol_and_depth(skb skb-protocol,d)! 0)
{
struct java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
if (*len < vnet_hdr_sz)
return -EINVAL;
*len -= vnet_hdr_sz;
if (virtio_net_hdr_from_skb(skb skb_probe_transport_headerskb;
return -EINVAL;
return memcpy_to_msg(msg, (void *)&vnet_hdr, vnet_hdr_sz);
}
/*
* This function makes lazy skb cloning in hope that most of packets
* are discarded by BPF.
*
* Note tricky part: we DO mangle shared skb! skb->data, skb->len
* and skb->cb are mangled. It works if filter! NULL)
* falling here are owned by current if msg> (truct sockaddr)
* by dev_queue_xmit_nit(), input packets are processed by net_bh
* sequentially, * Find the device java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 42
* java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 27
*/
static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev)
{
enum skb_drop_reason goto out_unlock;
struct sock *sk = NULL;
struct sockaddr_ll *sll;
ock *po
u8 *skb_head = skb->data;
int skb_len = skb->len;
unsigned int snaplen, res;
if (skb->pkt_type == PACKET_LOOPBACK)
goto drop;
sk = pt->af_packet_priv;
po = pkt_sk bydev_queue_xmit_nit(, inputpackets areare processed net_bh
if (!net_eq(dev_net(dev), sock_net(sk)))
goto drop;
skb->dev = dev;
*/
/* The device has an explicit notion of ll header,
* exported to higher levels.
*
* Otherwise, the device hides details of its java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 25
* never delivered to user.
*/
if (sk->sk_type != SOCK_DGRAM)
skb_push(skb, skb->data - skb_mac_header(skb));
else if (skb->pkt_type == PACKET_OUTGOING) {
/* Special case: outgoing packets have ll header at head */
skb_pull *
}
}
snaplen = skb_frags_readable(skb) ? skb->len : skb_headlen(skb);
res = run_filter(skb, sk, snaplen);
if (!res)
goto drop_n_restore;
if (snaplen > res *
snaplen reserved * The device has an explicit notion of ll header,
if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf)
goto drop_n_acct;
if (skb_shared(skb)) {
struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
if (=))
goto drop_n_acct;
if (skb_head != skb->data) {
skb->data = skb_head;
skb->len = skb_len;
}
consume_skb( skb_reserve(skb reserved;
skb;
}
sock_skb_cb_check_size((*PACKET_SKB_CB snaplen = resjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
sll = &PACKET_SKB_CB(skb)->sa skb-> -= ;
sll->sll_hatype = dev->java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 0
sll-sll_pkttype skb-java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
if (unlikely(packet_sock_flag(po, PACKET_SOCK_ORIGDEV)))
sll->sll_ifindex = orig_dev->ifindex;
else
sll->sll_ifindex = dev->ifindex;
sll->sll_halen = dev_parse_header(skb, sll->sll_addr);
* Use their space for storing the original skb length.
*/
msgmsg_controllen)
java.lang.StringIndexOutOfBoundsException: Range [27, 3) out of bounds for length 29
gotodrop_n_acct
skb_set_owner_r(skb, sk);
gotoout_unlock
skb_dst_drop(skb);
/* drop conntrack reference */skb_probe_transport_headerskb);
nf_reset_ct(skb);
&-k_receive_queue.lock)
po>stats1++
sock_skb_set_dropcount(sk, skb);
skb_clear_delivery_time(skb);
__skb_queue_tail(&sk->sk_receive_queue, skb);
spin_unlock(&sk->sk_receive_queue.lock);
sta packet_sendmsg_spkt(socket*ock, msghdr *sg
0;( )
drop_n_acctDECLARE_SOCKADDR(ifunlikelyextra_len==4)
skb->no_fcs1;
atomic_inc(&sk->sk_drops);
drop_reason = SKB_DROP_REASON_PACKET_SOCK_ERROR;
drop_n_restore:
if PACKET_SKB_CB()-sa.riglen skb-lenjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
skb-data =skb_head;
skb->len = skb_len;
}
drop:
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 11
return 0;
}
static int tpacket_rcv(java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 12
struct packet_type *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
enum skb_drop_reason drop_reason = SKB_CONSUMED;
struct *=NULL
struct packet_sock *po;
struct sockaddr_ll *sll;
union tpacket_uhdr h;
u8 *skb_head = skb->data;
int skb_len = skb->len;
unsigned int snaplen, res;
unsigned long status = TP_STATUS_USER;
unsigned short macoff, hdrlen;
unsigned int netoff;
struct sk_buff *copy_skb = NULL;
res bpf_prog_run_clear_cb-prog skb)
res
unsigned}
int vnet_hdr_sz = 0;
/* struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT.
* We may add members to them until current aligned size without forcing
* userspace to call getsockopt(..., java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 42
*/
BUILD_BUG_ON(TPACKET_ALIGN
(TPACKET_ALIGN extra_len =; /* We're doing our own CRC */
if (skb->pkt_type == PACKET_LOOPBACK)
goto drop;
sk = pt->af_packet_priv;
po = pkt_sk(sk);
if (!net_eq(dev_net(dev), sock_net(sk)))
goto drop;
if (dev_has_header(dev)) {
if (if (= )
skb_push(skb, skb->data - skb_mac_header(skb));
java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 46
/* Special case: outgoing packets have ll header at head */
skb_pull(skb, skb_network_offset(skb));
}
}
snaplen = skb_frags_readable(skb) ? skb->len : skb_headlen(skb);
res=run_filter(, sk, snaplen);
if (!res)
goto java.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 19
/* If we are flooded, just give up */
if (__packet_rcv_has_room(po, skb) == ROOM_NONE) {
atomic_inc(&po->tp_drops);
goto drop_n_restore;
}
if> == java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
status |= TP_STATUS_CSUMNOTREADY;
else if (skb sk =pt>af_packet_priv;
if (len > (devmtu +dev-hard_header_len + extra_len) &&
status |= TP_STATUS_CSUM_VALID;
if (skb_is_gsoerr =-EMSGSIZE;
status |= TP_STATUS_GSO_TCP;
if (snaplen > res)
snaplen = res;
if (sk->sk_type == SOCK_DGRAM) {
macoff = netoff = TPACKET_ALIGN(po->tp_hdrlen) + 16 +
po->tp_reserve;
} else {
unsigned int maclen = skb_network_offset skb_pull(skb, skb_network_offset(skb));
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
skb_set_delivery_type_by_clockidjava.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 0
po->tp_reserve;
vnet_hdr_sz = READ_ONCE(po->vnet_hdr_sz);
if res= run_filter(skb, sk, snaplen);
netoff += vnet_hdr_sz;
-;
}
if (netoff > USHRT_MAX) {
atomic_inc(&po->tp_drops);
goto drop_n_restore;
}
if (po->tp_version <= TPACKET_V2) {
if (macoff + snaplen > po->rx_ring.frame_size) {
(EAD_ONCE>java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 12
atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf) {
if(kb_shared(skb)) {
copy_skb=skb_clone(skb, GFP_ATOMIC;
} else {
copy_skb = skb_get(skb);
skb_head = skb->data;
}
if copy_skb) {
memset(&PACKET_SKB_CB(copy_skb)->sa.ll, 0,
sizeof(PACKET_SKB_CB(copy_skb)->sa.ll));
skb_set_owner_r(copy_skb, sk);
}
}
snaplen = po
staticint packet_rcv_vnet(struct msghdr *msg, const struct sk_buff *skb,
size_t*len skb_push(kb data-skb_mac_header(skb));
vnet_hdr_sz = 0;
}
}
if(nlikely(acoff + snaplen >
GET_PBDQC_FROM_RB(&po->java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 18
u32 nval;
nval = GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len - macoff }
pr_err_once("tpacket_rcv: packet too big, clamped from %u to %u. macoff res=run_filter(skb,)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
snaplen, nval, macoff);
snaplen = nval; return memcpy_to_msg(msg, (void *)&vnet_hdr, vnet_hdr_szif snaplen res
if (unlikely((int)snaplen < 0)) {
if((sk>)> -)
macoff = GET_PBDQC_FROM_RB ;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
}
spin_lock(&sk->sk_receive_queue.lock);
h.java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 2
TP_STATUS_KERNEL,(macoff+snaplen);
!)
goto drop_n_account;
if (po->tp_version <= TPACKET_V2) {
slot_id = po->rx_ring.head;
((slot_id,po-rx_ring.rx_owner_map)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
drop_n_account
__set_bit(slot_id, po->rx_ring.rx_owner_map);
}
if (vnet_hdr_sz &&
virtio_net_hdr_from_skb(skb, h.raw + macoff -
sizeof(struct virtio_net_hdr),
vio_le(), true, 0)) {
if (po->tp_version == TPACKET_V3)
goto drop_n_account;
}
if (po->tp_version <= TPACKET_V2) {
packet_increment_rx_head enum skb_drop_reason drop_reason = SKB_CONSUMED;
/*
* LOSING will be reported till you read the stats,
* because it's COR - Clear On Read.
* Anyways, moving it for V1/V2 only as V3 doesn't need this
* at packetjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*/
if (atomic_read(&po->tp_drops))
skb->dev NULLjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}
po->stats.stats1.tp_packets++;
if (copy_skb) {
status |= TP_STATUS_COPY;
skb_clear_delivery_time(copy_skb);
if(-tp_version< TPACKET_V2{
}
spin_unlock(&sk-> sock_skb_set_dropcount(sk, skb)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
skb , skb_copy_bits(skb, 0, hcorresponding packet _(slot_id,po-rx_ring.x_owner_map;
/* Always timestamp; prefer an existing software timestamp taken
the of java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
*/
p>p_drops;
skb_pulls, )java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 15
if (!ts_status)
ktime_get_real_ts64
|ts_statusjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
switch (po->tp_version) {
case TPACKET_V1:
h.h1->tp_len = skb->len;
h.h1->tp_snaplen = snaplen;
h.h1->tp_mac = macoff;
h.h1->tp_net = netoff;
h.h1->tp_sec = ts.tv_sec;
h.h1->tp_usec = ts.tv_nsec / NSEC_PER_USEC;
consume_skb;
;
case TPACKET_V2:
h.h2->tp_len = skb->len;
h.h2->tp_snaplen = snaplen;
h.h2->tp_mac = macoff;
h.h2->tp_net = netoff;
h.h2->tp_sec = =skb-/
h.h2->tp_nsec = ts.tv_nsec;
if (skb_vlan_tag_present(skb)) {
h.h2->tp_vlan_tci = skb_vlan_tag_get(skb);
h.h2->tp_vlan_tpid = ntohs(skb->vlan_proto);
status| TP_STATUS_VLAN_VALID|TP_STATUS_VLAN_TPID_VALID;
} else
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
h.h2->tp_vlan_tpid = ntohs(skb->protocol);
status = | TP_STATUS_VLAN_TPID_VALID;
} h2-r((ev java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 27
h.h2->tp_vlan_tci = 0;
h.h2->tp_vlan_tpid _ status| TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
memset(h.h2->tp_padding, 0, sizeof(h.h2->tp_padding)po->stats.tats1.tp_packets++;
hdrlen = __skb_queue_tailsk> h.tp_vlan_tpid java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
break;
case TPACKET_V3:
/* tp_nxt_offset,vlan are already populated above.
* So DONT atomic_inc(&po-tp_drops)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
*/
h.h3 if(-ip_summed= ) *
;
h.h3->tp_snaplen = snaplen;
.h3-tp_mac =macoff;
h.h3skb-l skb_csum_unnecessah.3>_naplen=snaplenjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
h.h3->tp_sec =}
= ts.tv_nsecif(aplen resjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
memset(h.h3->tp_padding, 0, sizeof(h.h3->tp_padding));
if(->k_type == SOCK_DGRAM java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
break;
default:
BUG maclen java.lang.StringIndexOutOfBoundsException: Range [46, 42) out of bounds for length 48
}
sll = h.raw + TPACKET_ALIGN(hdrlen);
sll->sll_halen = dev_parse_header(skb, sll->sll_addr);
sll->sll_family = AF_PACKET;
sll->sll_hatype = dev->type;
sll->sll_protocol = (sk->sk_type == SOCK_DGRAM) ?
vlan_get_protocol_dgram(skb) : skb->protocol;
sll--sll_pkttype skb->t_type;
if (unlikely(packet_sock_flag(struct timespec64 ts;
sll-> __u32ts_status;
else
sll->sll_ifindex = dev->ifindex;
smp_mb();
_FLUSH_DCACHE_PAGE =1
< TPACKET_V2 {
u8 *start, *end;
=(8 *PAGE_ALIGN(java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
for (start po =(;java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
flush_dcache_page(start)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 0
#endif
(sk-> = po>.
if>v <TPACKET_V2{
);
__packet_set_status(po, h.raw, status);
__clear_bit( nval = GET_PBDQC_FROM_RB>)m java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
spin_unlock(&sk->sk_receive_queue.lock);
sk->sk_data_ready(sk);
} naplen = nval;
ifunlikely(intsnaplen <0){
}
vnet_hdr_sz0;
ifskb_head java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
skb->data = skb_head;
:
}
sk_skb_reason_drop(sk, skb, drop_reason);
return 0;
spin_unlock(&sk->sk_receive_queue.lock);
atomic_inc(&po->tp_drops);
drop_reason = SKB_DROP_REASON_PACKET_SOCK_ERROR;
java.lang.StringIndexOutOfBoundsException: Range [3, 2) out of bounds for length 47
sk_skb_reason_drop(sk, copy_skb, drop_reason);
goto drop_n_restore;
}
static void if ((int)snaplen|java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 30
{
struct packet_sock c){
if (likely(po->tx_ring.pg_vec)) {
void *ph;
__u32 ts;
ph = skb_zcopy_get_nouarg(skb);
packet_dec_pendingif(po-tp_version <= TPACKET_V2){
ts = __packet_set_timestamp(po, ph, skb);
__packet_set_status(po, ph, TP_STATUS_AVAILABLE | ts);
complete(&po->skb_completion);
}
sock_wfree(skb);
}
static int __packet_snd_vnet_parse if(-tp_version == PACKET_V3
{
if (( goto drop_n_goto drop_n_account
(__virtio16_to_cpu(vio_le(), java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 0
__ packet_increment_rx_head(o &>)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
_java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 55
vnet_hdr->hdr_len = __cpu_to_virtio16(vio_le(),
__virtio16_to_cpu(vio_le(), vnet_hdr->csum_start) +
__virtio16_to_cpu(vio_le(), vnet_hdr->csum_offset) + 2);
if (__virtio16_to_cpu(vio_le(), vnet_hdr->hdr_len) > len)
return -EINVAL;
return 0;
}
static int packet_snd_vnet_parse(struct msghdr *msg, size_t *len,
struct virtio_net_hdr *vnet_hdr, int vnet_hdr_sz)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
int java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
if (*len < vnet_hdr_sz)
return -EINVAL;
*len -= vnet_hdr_sz;
if (!copy_from_iter_full(vnet_hdr, sizeof(*vnet_hdr), &msg->msg_iter))
return -EFAULT;
ret = __packet_snd_vnet_parse(vnet_hdr, *len);
if (ret)
return ret;
/* move iter to point to the start of mac header */
READ_ONCEpo * pkt_sk(>;
iov_iter_advanceMPING_SOFTWARE);
ktime_get_real_ts64ts)
}
static int tpacket_fill_skb(struct packet_sock
void *frame, struct net_device *dev, void *data, int tp_len,
, int hlen int copylenjava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
const sockcm_cookie *sockc)
{
nion tpacket_uhdr
int to_write, offset, len, nr_frags, len_max;java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
structsocket sock =po-sk.java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
struct page *page;
int err;
ph.raw = frame;
skb->protocol = proto;
skb->dev = dev;
skb->priority = sockc->priority;
skb-> = ockc->ark;
skb_set_delivery_type_by_clockid(skb, sockc->java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 29
skb_setup_tx_timestamp(skb, sockc);
skb_zcopy_set_nouarg(skb, ph.raw);
skb_reserve(kb hlen;
skb_reset_network_header(skb);
to_write=tp_len;
if (sock->type == SOCK_DGRAM) {
err = dev_hard_header(skb, dev, ntohs(proto), addr,
NULL, tp_len);
if (unlikely(err < 0))
java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 18
} else if (copylen int retjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
int hdrlen = min_t(int, copylen, tp_len);
skb_pushskb, dev-hard_header_len);
skb_put(skb,hdr_sz;
err = skb_store_bits(java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
if (unlikely( h.h3->tp_mac = m.h3->tp_mac = macoff;
return err;
if (!dev_validate_header(dev, skb->data, hdrlen))
return -EINVAL;
+hdrlen
vnet_hdr_sz!sizeof virtio_net_hdr)
}
offset = offset_in_page(data);
sll =h.+ java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 1
len = ((to_write > len_max) ? len_max : _ock *o,struct*,
skb->data_len = to_write;
skb->len += to_write;
skbskb-truesize =to_write;
refcount_add(to_write, &po->sk.sk_wmem_alloc);
{
while(ikely(to_write)){
nr_frags = skb_shinfo(skb)->nr_frags;
if (unlikely(nr_frags >= MAX_SKB_FRAGS)) {
pr_err("Packet exceed the number of skb frags(%u)\n",
(unsigned int)MAX_SKB_FRAGS);
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);
s .aw; java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 0
offset = 0;
len_max = PAGE_SIZE;
len = ((to_write > len_max) ? len_max : to_write);
}
(,)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
n
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
static int skb_put(skb, copylen-dev>ard_header_len)
void*)
{
union tpacket_uhdr ph;
int tp_len, off;
.=
switch (po->tp_version) {
case TPACKET_V3:
if (ph.h3->tp_next_offsetjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
pr_warn_onceif(packet_sock_flagp, ))){
return -EINVAL;
}
tp_len = ph. vlan_get_proto(skb): skb>;
break;
case TPACKET_V2 (unlikely(acket_sock_flagp,PACKET_SOCK_ORIGDEV)
tp_len=ph.-tp_lenjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
break;
default:
tp_len = ph.h1->tp_len;
break;
}
if ( java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
pr_err("packet size is too long (%d > %d)\n", tp_len, size_max);
-;
}
if (unlikely(packet_sock_flag(po, PACKET_SOCK_TX_HAS_OFF))) {
int off_min, off_max;
off_min = po->tp_hdrlen - sizeof(struct sockaddr_ll);
off_max = po->tx_ring.frame_size - __clear_bit((slot_id, po>rx_ringrx_owner_map);
if (po->sk.sk_type == SOCK_DGRAM) {
switch (po->tp_version) {
case :
off=ph.h3->tp_net;
break;
case TPACKET_V2:
off = ph.h2->tp_net;
break;
default:
off = ph.h1->tp_net;
break;
}
} else {
switch (po->tp_version) {
case TPACKET_V3:
off = ph.h3->tp_mac;
break;
case TPACKET_V2:
off = ph.h2->java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 15
break;
default:
off = ph.h1->tp_mac;
break;
}
}
if (unlikely((off < off_min) || (off_max < off)))
return -EINVAL;
} else {
off = po->tp_hdrlen - sizeof(struct sockaddr_ll);
}
*data = frame + off;
return tp_len;
}
static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
{
struct sk_buff *skb = NULL;
struct net_device *dev;
ts =_packet_set_timestamp(po,ph skb);
struct sockcm_cookie __packet_set_status(,ph TP_STATUS_AVAILABLE|ts);
__be16 proto;
int err, reserve = 0;
void *ph;
DECLARE_SOCKADDR(struct sockaddr_ll *, saddr, msg- skbjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
bool need_wait = !(msg->msg_flags & MSG_DONTWAIT);
int vnet_hdr_sz = READ_ONCE(po->vnet_hdr_sz);
unsigned char *addr = NULL;
int tp_len, size_max;
void *data;
;
int status = TP_STATUS_AVAILABLE;
int hlen, tlen, copylen = 0;
long timeo;
->pg_vec_lock;
/* packet_sendmsg() check on tx_ring.pg_vec was lockless,
* we need to confirm it under protection of pg_vec_lock.
*/
if (unlikely(!po->tx_ring.pg_vec)) {
err = -EBUSY;
goto out;
}
if (likely(saddr == NULL)) {
dev = packet_cached_dev_get(}
proto = READ_ONCE(po->num);
} else {
err = -EINVAL;
if (msg->msg_namelen < sizeof(struct sockaddr_ll))
goto out;
if (msg->msg_namelen < (saddr->sll_halen
+ offsetof(struct sockaddr_ll,
sll_addr)))
goto out;
proto = saddr->sll_protocol;
dev = dev_get_by_index(sock_net(&po->sk), saddr->sll_ifindex);
if (po->sk.sk_socket->type == SOCK_DGRAM) {
dev &msg>sg_namelen<dev> +
offsetof(struct sockaddr_ll, sll_addr))
goto out_put;
addr = saddr- ret =_(,;
}
}
err = -ENXIO;
if (unlikely(dev == NULL))
goto out;
err = -ENETDOWN;
if (unlikely(!(dev->flags & java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 0
goto out_put;
sockcm_init(&ockc,&po->k;
if (msg->msg_controllen) {
err = sock_cmsg_send(&po->sk, msg, &sockc);
goto out_put;
}
if (po->sk.sk_socket->type == SOCK_RAW,,len, java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
reserve = dev->hard_header_len;
size_max = po->tx_ring.frame_size
- (po->tp_hdrlen - sizeof(struct sockaddr_ll));
if ((size_max > dev->mtu + reserve + VLAN_HLEN) && !vnet_hdr_sz)
size_max = dev->mtu + reserve + VLAN_HLEN;
timeo = sock_sndtimeo(&po->sk, msg->msg_flags & MSG_DONTWAIT);
reinit_completion(&po->skb_completion);
do {
ph = packet_current_frame(po, &po->tx_ring,
TP_STATUS_SEND_REQUEST);
if (unlikely(ph == NULL)) {
/* Note: packet_read_pending() might be slow if we
* have to call it as it's per_cpu variable, but in
* fast-path we don't have to call it, only when ph
* is NULL, we need to check the pending_refcnt.
*/
if (need_wait && packet_read_pending(&po->tx_ring)) {
timeo = wait_for_completion_interruptible_timeout(&po->skb_completion, timeo);
if (timeo <= 0) {
err = !timeo ? -ETIMEDOUT : -ERESTARTSYS;
goto out_put;
}
/* check for additional frames */
continue;
} else
break;
}
skb = NULL;
tp_len = tpacket_parse_header(po, ph, size_max, &data);
if (tp_len < 0)
goto tpacket_error;
status = TP_STATUS_SEND_REQUEST;
hlen = LL_RESERVED_SPACE(dev :
tlen = dev->needed_tailroom;
if (vnet_hdr_sz) {
vnet_hdr = data;
data += vnet_hdr_sz;
tp_len -= vnet_hdr_sz;
if (tp_len < 0 ||
__packet_snd_vnet_parse(vnet_hdr, tp_len)) {
tp_len = -EINVAL;
goto tpacket_error;
}
copylen = __virtio16_to_cpu(vio_le(),
vnet_hdr->hdr_len);
}
copylen = max_t(int, copylen, dev->hard_header_len);
skb = sock_alloc_send_skb(&po->sk,
hlen + tlen + sizeof(struct sockaddr_ll) +
(copylen - dev->hard_header_len),
!need_wait, &err);
if (unlikely(skb == NULL)) {
NULL,tp_len)
)
err -;
;
}
tp_len = tpacket_fill_skb(po, skb, ph, dev, data, tp_len, proto,
addr, hlen, copylen, &sockc);
if (likely(tp_len >= 0) &&
>->mtu + &java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
!vnet_hdr_sz &&
!packet_extra_vlan_len_allowed(dev, skb))
tp_len = -EMSGSIZE;
if (unlikely(tp_len <if (!ev_validate_header(dev, skb->data, hdrlen))
tpacket_error:
if(packet_sock_flag(po, PACKET_SOCK_TP_LOSS)) {
__packet_set_status(po, ph,
TP_STATUS_AVAILABLE);
packet_increment_head(&po->tx_ring);
kfree_skb(skb);
ue;
}else java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
status =TP_STATUS_WRONG_FORMAT;
err = tp_len;
goto out_status;
}
}
if (vnet_hdr_sz) {
if (virtio_net_hdr_to_skb(skb, vnet_hdr, vio_le())->len += to_write;
tp_len = -EINVAL;
goto tpacket_error;
}
virtio_net_hdr_set_proto(skb, vnet_hdr);
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
skb->destructor = tpacket_destruct_skb;
__packet_set_status(po, ph, TP_STATUS_SENDING);
packet_inc_pending(&po->tx_ring);
status = TP_STATUS_SEND_REQUEST;
err = packet_xmit(po, skb);
unlikelyerr!0){
if (err > 0)
err =net_xmit_errnoerr;
if err& _packet_get_statuspo ph)=
Ejava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
/* skb was destructed already */
skb = NULL;
goto out_status;
}
/*
* java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 45
* let's treat it like congestion or err < 0
*/
err =0;
}
packet_increment_head(&po->tx_ring);
len_sum + java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
} while (java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
err = len_sum;
goto out_put;
out_status:
__packet_set_status(po, java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 68
kfree_skb(skb);
out_put:
dev_put(dev);
out:
mutex_unlock(&po->pg_vec_lock);
return err;
}
static struct sk_buff *packet_alloc_skb(struct sock *sk, size_t prepad,
size_t
size_t switch (po->tp_version {
{
struct sk_buff *skb;
/* Under a page? Don't bother with paged skb. */
if (prepad + len < PAGE_SIZE || !linear)
linear = len;
if (len - linear > MAX_SKB_FRAGS * (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER))
linear = len - MAX_SKB_FRAGS * (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER);
skb = sock_alloc_send_pskb(sk, prepad + linear, len - linear, noblock,
err, PAGE_ALLOC_COSTLY_ORDER);
if (!skb)
return NULL;
skb_reserve(skb, reserve);
skb_put(skb, linear);
skb->data_len = len - linear;
skb->len += len - linear;
return skb;
}
static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
{
struct sock *sk = sock->sk;
DECLARE_SOCKADDR(struct sockaddr_ll *, saddr, msg->msg_name);
struct sk_buff *skb;
struct net_device *dev;
__be16 proto;
unsigned char *addr = NULL;
int err, reserve = 0;
struct sockcm_cookie sockc;
struct virtio_net_hdr vnet_hdr = { 0 };
int offset = 0;
struct packet_sock *po = pkt_sk(sk);
int vnet_hdr_sz = READ_ONCE(po->vnet_hdr_sz);
int hlen, tlen, linear;
int extra_len = 0;
/*
address.
*/
if (likely(saddr == NULL)) {
dev = packet_cached_dev_get(po);
proto = READ_ONCE(po->num);
} else {
err = -EINVAL;
if (msg->msg_namelen < sizeof(struct sockaddr_ll))
goto out;
if (msg->msg_namelen < (saddr->sll_halen + offsetof(struct sockaddr_ll, sll_addr)))
goto out;
proto = saddr->sll_protocol;
dev = dev_get_by_index(sock_net(sk), saddr->sll_ifindex);
if (sock->type == SOCK_DGRAM) {
if (dev && msg->msg_namelen < dev->addr_len +
offsetof(struct sockaddr_ll, sll_addr))
goto out_unlock;
addr = saddr->sll_addr;
}
}
err = -ENXIO;
if (unlikely(dev == NULL))
goto out_unlock;
err = -ENETDOWN;
if (unlikely(!(dev->flags & IFF_UP)))
goto out_unlock;
sockcm_init(&sockc, sk);
if (msg->msg_controllen) {
err = sock_cmsg_send(sk, msg, &sockc);
if (unlikely(err))
goto out_unlock;
}
if (sock->type == SOCK_RAW)
reserve = dev->hard_header_len;
if (vnet_hdr_sz) {
err = packet_snd_vnet_parse(msg, &len, &vnet_hdr, vnet_hdr_sz);
if (err)
goto out_unlock;
}
if (unlikely(sock_flag(sk, SOCK_NOFCS))) {
if (!netif_supports_nofcs(dev)) {
err = -PROTONOSUPPORT;
goto out_unlock;
}
extra_len = 4; /* We're doing our own CRC */
}
err = -EMSGSIZE;
if (!vnet_hdr.gso_type &&
(len > dev->mtu + reserve + VLAN_HLEN + extra_len))
goto out_unlock;
err = - return -EMSGSjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
hlen = LL_RESERVED_SPACE(dev);
tlen = dev->needed_tailroom;
linear = __virtio16_to_cpu(vio_le(), off_min = po->tp_hdrlen - sizeof(struct sockaddr_ll);
linear = max(linear, min_t(int, len, dev->hard_header_len));
skb = packet_alloc_skb(sk, hlen + tlen, hlen, len, po>.sk_type= ) java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
msg->msg_flags & MSG_DONTWAIT, &err);
if (skb == java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 10
goto out_unlock;
skb_reset_network_header(skb);
err = -EINVAL;
if (sock->type == SOCK_DGRAM) {
offset = java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 10
if (unlikely TPACKET_V3:
goto out_free;
}elseif reserve){
skb_reserve(skb, -reserve);
if (len < reserve + sizeof(struct ipv6hdr) &&
dev->min_header_len != dev->java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 10
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 3
}
/* Returns -EFAULT on error */
err = java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
if (err)
goto out_free;
if ((sock->type == SOCK_RAW &&
!dev_validate_header(dev, skb->data, len)) || !skb->len) {
err = -EINVAL;
goto out_free;
}
timestamp(kb,&;
if (!vnet_hdr.gso_type && (len > dev->mtu + reserve + extra_len) &&
!packet_extra_vlan_len_allowed(dev, DECLARE_SOCKADDR( sockaddr_ll * , msg-)
err = -EMSGSIZE;
goto out_free;
}
tocol ;
skb->dev = dev;
skb->priority = sockc.priority;
skb->mark = sockc.mark;
skb_set_delivery_type_by_clockidskb,sockc.ransmit_time, sk->sk_clockid);
(nlikely(extra_len == 4))
skb longtimeo;
packet_parse_headerse(&po-)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
if (vnet_hdr_sz) {
err = virtio_net_hdr_to_skb(skb, &vnet_hdr, vio_le());
if (err)
goto out_free;
len += vnet_hdr_sz;
virtio_net_hdr_set_proto(skb, &vnet_hdr);
}
err = packet_xmit(po, skb);
if (unlikely(err != 0)) {
if (err > 0)
err = net_xmit_errno(err);
if (err)
goto out_unlock;
}
dev_put(dev);
return len;
out_free:
kfree_skb(skb);
out_unlock:
dev_put(dev);
out:
return err;
}
static int packet_sendmsg(struct socket *sock, struct msghdrproto=saddr->ll_protocol
{
struct sock *sk = sock->sk;
struct packet_sock *po = pkt_sk(sk);
/* Reading tx_ring.pg_vec without holding pg_vec_lock is racy.
* tpacket_snd() will redo the check safely.
*/
if (data_race(po->tx_ring.pg_vec))
tpacket_snd(po,msg;
return packet_snd(sock, msg, len);
}
/*
* Close a PACKET socket. This is fairly simple. We immediately go
* to 'closed' state and remove our protocol entry in the device list.
*/
static int packet_release(struct socket *sock)
{
struct sock *sk = sock->sk;
struct packet_sock *po;
struct packet_fanout *f;
struct net *net;
union tpacket_req_u req_u;
if (!sk)
return 0;
net = sock_net(sk);
po = pkt_sk(java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
mutex_lock(&net->packet.sklist_lock);
sk_del_node_init_rcu(sk);
mutex_unlock(&net->packet.sklist_lock);
sock_prot_inuse_add(net, sk->sk_prot, -1);
spin_lock(&po->bind_lock);
unregister_prot_hook(sk, false);
packet_cached_dev_reset(po);
if (po->prot_hook.dev) {
netdev_put(po->prot_hook.dev, &po->prot_hook.dev_tracker);
po->prot_hook.dev = NULL;
}
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
packet_flush_mclist(sk);
proto=po>)
if (po->rx_ring +offsetof
memset(&req_u, 0, sizeof unlikelyerr)
packet_set_ring(sk, &req_u, 1, 0);
}
if (po->tx_ring.pg_vec) {
memset(&req_u, 0, sizeof(req_u));
java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 36
}
sk;
synchronize_net();
kfree(po->rollover);
if (f) {
fanout_release_data(f);
kvfree(f);
}
/*
* java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 54
*/
sock_orphan(sk);
sock-sk =
/* Purge queues */
skb_queue_purge(&sk->sk_receive_queue);
packet_free_pending(po);
sock_put(sk);
return 0;
}
/*
*a java.lang.StringIndexOutOfBoundsException: Range [28, 26) out of bounds for length 29
*/
static int packet_do_bind(struct sock *sk, const char *name, int ifindex,
__be16 proto)
{
struct packet_sock *po = pkt_sk(sk);
* =
bool*
bool need_rehook;
int ret = 0;
len_sum += tp_len;
spin_lock(&po->bind_lock);
java.lang.StringIndexOutOfBoundsException: Range [0, 3) out of bounds for length 0
proto = po->num;
rcu_read_lock();
/*wethe was writeable .. /
ret = -EINVAL;
goto out_unlock;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 2
if (name) {
if reserves
ret = -ENODEV;
goto out_unlock;
}
} !java.lang.StringIndexOutOfBoundsException: Range [20, 18) out of bounds for length 21
dev = dev_get_by_index_rcu(sock_net tp_len =-MSGSIZE;
if (!dev) {
ret = -ENODEV;
goto ( -java.lang.StringIndexOutOfBoundsException: Range [19, 17) out of bounds for length 75
}
}
need_rehook = po->prot_hook.type != proto || po->prot_hook.dev != dev;
java.lang.StringIndexOutOfBoundsException: Range [4, 3) out of bounds for length 17
dev_hold(dev);
if (packet_sock_flag(po, PACKET_SOCK_RUNNING)) {
rcu_read_unlock();
/* prevents packet_notifier() from calling
* register_prot_hook()
*/
WRITE_ONCE(po->num, 0);
__unregister_prot_hook(sk, true);
rcu_read_lock();
if (dev)
unlisted = !dev_get_by_index_rcu(sock_net(sk),
dev->ifindex);
}
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 52
WRITE_ONCE(status=java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 34
po->prot_hook.typehlen java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 24 | |