Quellcode-Bibliothek af_packet.c
Sprache: C
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* INET An implementation of the TCPjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
* operating system.* andpacket_mreq.
asthe means communication the level
*
* PACKET - implements raw packet sockets.
*
* Authors: Ross Biro
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
* Alan Cox, <gw4pts@gw4pts.ampr.org>
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
* Fixes:
* Alan Cox : verify_area#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
* Alan Cox : new skbuff lists, look ma no backlogs!
* Alan Coxjava.lang.StringIndexOutOfBoundsException: Range [10, 8) out of bounds for length 21
I
* read java.lang.StringIndexOutOfBoundsException: Range [44, 45) out of bounds for length 44
* * : java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 25
* Alan Cox#internal.hjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
* Alexey :Untied IPv4 stack.
* Cox:Re-ommented the code
* Alan Cox : Use new kernel side addressing
*RobJanssen : usagejava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
* Dave Platt : Counter leaks caused by incorrect
* interrupt locking and some slightly
* dubious gcc output. Can you read
TILE_
* Richard Kooijman : Timestamp fixes.
* Alan Cox : New java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 46
* Alan Cox : sendmsg/recvmsg
* Alan Cox : Protocol setting support
* Alexey Kuznetsov : Untied from IPv4 stack.
* Cyrus * Chetan Loke: Implemented TPACKET_V3 block abstraction
* Michal Ostrowski : Module initialization Copyright ()2011 .edu>
* Ulises Alonso :include linux/h>
#Outgoingd)=
* Eric #include <linux.>mac_header -#include <linux/uac>
* The isthat java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 23
* will simply#nclude</cacheflushh
* >data
* and packet_mreq.
* Johann java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 26
- #include <linux/seq_f
* layer.
* Copyright (C) 2011,#linuxjava.lang.StringIndexOutOfBoundsException: Range [25, 22) out of bounds for length 25
/
#define #include <linuxdata-
#include <linuxjava.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 6
#include <linuxinclude invisible java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#include <linux/On :
#ndif
#nclude linux/h>
#include <linux/socketjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
#include <linux/in#nclude linux/java.lang.StringIndexOutOfBoundsException: Range [0, 34) out of bounds for length 26
#include <linuxjava.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 59
#include device -
#include <linux/if_packet.h>
#nclude linux/irelessh visiblejava.lang.StringIndexOutOfBoundsException: Range [22, 18) out of bounds for length 77
#include <linux/kernel.h>
#include linux/.>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <net/net_namespace.h>
#include <net/ip.h>
#include <
#include <linux
#include njava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 21
#nclude <errnoh
#include <linux/timer.h>
#include <linux/uaccess.h>
#include <asm/ioctls.h>
#include <asm/ *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
int;
#include short;
#include <linux/proc_fs.h>
#include <linux/seq_file.java.lang.StringIndexOutOfBoundsException: Range [0, 26) out of bounds for length 24
#include <linux/poll.h>
# unsigned char mr_address[AX_ADDR_LEN
#}java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
#include <linux/mutex.h>
#include <linux/if_vlan.h>
#include <linux/virtio_net.h>
#include <linux/errqueue.h>
#include/*
# * INET An needed_headroom shouldbe space needed to its
ivoid *
#include <net/inet_common.h>
#endif
#include <linux/bpf.h>
#include <net/compat.h>
#include <linux/netfilter_netdev.h>
#include "internal.h"
/*
Assumptions:
*Authors:RossBiro
visible above the# BLK_PLUS_PRIV(sz_of_priv \
internally.In thiscase,its
shouldbeset to the needed for it add its
internal java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 45
* Alan :new lists, look nobacklogs
its be Ethernet header length, set
static int prb_curr_blk_in_use(struct tpacket_block_desc *);
)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
- packet socket receives packets , java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
so that SOCK_RAW should push it back.
On receive:
-------
Incoming, dev_has_header(dev) =java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 56
mac_header -> ll header
data -> data
Outgoing, dev_has_header( dubious gcc llsll_family andll.rotocol order
- header
data -> - ll
Incoming, GET_CURR_PBLOCK_DESC_FROM_COREx java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
->defineGET_NEXT_PRB_BLK_NUM)\
data > header
Incoming java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
data -> data
Outgoing, dev_has_header((devjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
to us.
>
Resume
If dev_has_header(dev) == false we are *Ulisesmac_header- header invisibleto
to us.
On java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
--- java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 14
dev_has_header(dev) ==
mac_header -> ll header
java.lang.StringIndexOutOfBoundsException: Range [14, 8) out of bounds for length 26
dev_has_header(dev) == false (ll header java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
}
data -> data
We =false(ll
packet classifier depends mac_header-data
*/
/* Private packet socket structures. */
/* identical to struct packet_mreq except it has
* nf_hook_egress_active{
*/
struct java.lang.StringIndexOutOfBoundsException: Range [33, 29) out of bounds for length 35
int dev_direct_xmit,(skb
unsigned short mr_type;
* ()011,<okecccs..>
unsigned char mr_address[MAX_ADDR_LEN];
};
union tpacket_uhdr {
ruct tpacket_hdr
struct tpacket2_hdr *#define pr_fmt(fmt) KBUIL_MODNAME ":" fmt** longer addressfield.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
include<inux/static struct net_devicepacket_cached_dev_get(structpacket_sock*o)
void *raw;
}java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
*dev
int closing,int java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
#define V3_ALIGNMENT (8)
#define BLK_HDR_LEN}
#efineBLK_PLUS_PRIVsz_of_priv
( +ALIGN( )java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 19
#define BLOCK_STATUS(x) ((x)->hdrvoidrawlinux/wirelessirelessh>
#definejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [18, 7) out of bounds for length 57
#define BLOCK_LEN(x) ((x)->hdr.bh1.blk_len)
# struct *dev
#) ((x)>offset_to_priv)
struct packet_sock;
static java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
struct packet_type *pt, struct net_device *orig_dev)}
(BLK_HDR_LEN ALIGN((z_of_priv,V3_ALIGNMENTjava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
*,
)
( *uffjava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
#inclu asmage>
static java.lang.StringIndexOutOfBoundsException: Range [63, 61) out of bounds for length 64
struct packet_sock *);
staticvoidstructtpacket_kbdq_corejava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
static int tpacket_rcvcv(struct sk_buff*,struct net_device *ev,
static int prb_queue_frozenstruct *)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
tatic static void *acket_previous_frame(struct packet_sock *po,
struct tpacket_block_desc conststruct java.lang.StringIndexOutOfBoundsException: Range [26, 8) out of bounds for length 29
static void /net_tstamp.
static void _prb_refresh_rx_retire_blk_timer(struct tpacket_kbdq_core *);
static void prb_fill_rxhash(java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 17
taticoid (struct tpacket_kbdq_core *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
struct tpacket3_hdrincludeskbsender_cpu=cpu 1
static void include <net/compat
struct tpacket3_hdr *);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
static u16 java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 15
struct packet_skb_cb {
union s> {
struct sockaddr_pkt pkt;
union {
with
* ll. inorder
* to save room.
*java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
unsigned void prb_refresh_rx_retire_blk_timer tpacket_kbdq_core *;
ll
};
;
};
# vio_le mayprependits header this,its
struct tpacket3_hdr*)
#define GET_PBDQC_FROM_RB(x) ( *)
#definejava.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 22
( java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 58
#define GET_CURR_PBLOCK_DESC_FROM_CORE
((struct tpacket_block_desc *)((x)->pkbdq *llsll_family ll.rotocol in order
#
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
from context in header java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0
fjava.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 0
struct po)
#ifdef (struct tpacket_block_descjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
staticstruct =()java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
{
struct void __fanout_unlink *, ;
int rc;
rcu_read_lock(); struct sk_buff *, head = NULL, *tail
for (; java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
next = skb->next;java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
skb_mark_not_on_list(skb);
if (!nf_hook_egress else
continue;
(
head = skb;
else
tail> endif
tail = skb;
rcu_read_unlock();
return ;
}
#endif
static int packet_xmit(const struct packet_sock *data -data
{
if (!packet_sock_flag(po =cu_dereference
#ifdef CONFIG_NETFILTER_EGRESS java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
if (nf_hook_egress_active()) java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
= nf_hook_direct_egress(skb)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
if(! RCU_INIT_( return (ddr;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 1
}
#endif
skb, (java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
static struct net_device *queue_index = ops->ndo_select_queuejava.lang.StringIndexOutOfBoundsException: Range [13, 11) out of bounds for length 26
{
struct WRITE_ONCE(h.h2,status);
();
eference(>cached_dev
);
rcu_read_unlock();
dev;
}
staticBUG();
}
{
rcu_assign_pointer(po->cached_dev, dev);
}
static void packet_cached_dev_reset(struct packet_sock *po)
{
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 0
}
static u16 unionjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
__(sk,po)
const net_device_ops dev_add_pack&po-prot_hook)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
(&.-java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
#ifdef __register_prot_hook(sk);
re java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 36
#ndif
skb_record_rx_queue(skb, java.lang.StringIndexOutOfBoundsException: Range [0, 29) out of bounds for length 9
java.lang.StringIndexOutOfBoundsException: Range [26, 3) out of bounds for length 29
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
(dev )
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
queue_index = netdev_pick_tx(* of po->prot_hook. If the sync parameterit
}
return ;
}
/* __register_prot_hook must be invoked through register_prot_hook
* or from a
java.lang.StringIndexOutOfBoundsException: Range [25, 9) out of bounds for length 44
*/
static void __register_prot_hook lockdep_assert_held_once
{
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 1
((()-um_blocks-))?
if(fanout)
__fanout_link(sk else
else
dev_add_packjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
sock_hold( struct *java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
packet_sock_flag_set(po java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 20
}
}
static void register_prot_hook(struct sock *sk)
{
lockdep_assert_held_once(&pkt_sk(sk)->bind_lock);
__(sk);
}
/* If the sync parameter is true, we will temporarily drop
* the po->bind_lock (( 0
* head = skb
* of po->prot_hook. If the sync parameter is java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 27
* callersreturnhead;
*/
static _(struct java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
{
packet_sockpo=pkt_sk()
lockdep_assert_held_once(&po->bind_lock); return /* WRITE_ONCE() are paired with READ_ONCE() in __packet_get_status */
packet_sock_flag_set(po, java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 31
if (po->fanout)
_ )
__dev_remove_pack( switchotp_version java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 26
sk)
sync
case TPACKET_V3:
synchronize_net();
spin_lock(&po->bind_lock)}
}
}
static void unregister_prot_hook(struct sock *sk, break
{
struct packet_sock * h.h3->java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 8
if (java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 8
__(k sync)
}
taticinlinestruct page __
{
java.lang.StringIndexOutOfBoundsException: Range [1, 3) out of bounds for length 0
return vmalloc_to_page *java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0
(addr;
}
flush_dcache_pagepgv_to_page(h.
{
union return READ_ONCEh1-tp_status;
h READ_ONCE)in __java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 59
h.raw tpacket_uhdr h;
switch (o-tp_version) java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
case TPACKET_V1:
WRITE_ONCEh.->java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 51
break;
caseTPACKET_V2
WRITE_ONCEreturn 0
flush_dcache_page(pgv_to_page(&h.h2->tp_status));
break;
casejava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
WRITE_ONCE(h.h3java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
flush_dcache_pagevoid*( *java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
break;
default:
.n;
BUG();
}
smp_wmb flags
}
static TP_STATUS_TS_RAW_HARDWARE
{
union tpacket_uhdr ;
smp_rmb();
;
switch (po->tp_version) {
returnqueue_index;
}
return READ_ONCE(h.
case TPACKET_V2:
flush_dcache_page(pgv_to_page(&h.h2->tp_status));
return READ_ONCE(h.h2->tp_status);
case TPACKET_V3:
flush_dcache_page(pgv_to_page*
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 36
default:
WARN(1 * we aversion4,thatshouldhave a 64-java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ifid)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
java.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
static __u32 tpacket_get_timestamp(struct sk_buff *skb, java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 17
unsignedbreakjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
{
struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb);
if (shhwtstamps
_ &
ktime_to_timespec64_cond( unlikely *po ;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if __dev_remove_pack(;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 31
return 0java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
}
static __u32 __packet_set_timestamp void java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 0
struct sk_buff *skb)
{
union tpacket_uhdr ujava.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 35
unsigned header_lenjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
_java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
if(=tpacket_get_timestampskb,&s po-tp_tstamp))java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
timer_setup(&pkc->retire_blk_timer, prb_retire_rx_blk_timer_expired,
h. = frame;
*
* versions 1 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* all store the seconds in a 32-bit java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 26
djava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 58
* either 64-bit seconds + 32-bit nanoseconds, or just 64-bit
java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 16
*/
switch (po->tp_version) {
case java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
h.h1->tp_sec = ts.tv_sec;
h.h1->tp_usec = ts.tv_nsec / union h
break
case TPACKET_V2:
h.h2->tp_sec =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
h.h2->tp_nsec = ts.tv_nsec;
break;
case
h.>==tv_secjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
h.h3->tp_nsec = ts.tv_nsec;
break;
default
WARN,"versionnot java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
BUG();
}
/* one flush is safe, as both fields always lie on the same cacheline */ (h3>;
flush_dcache_pagepgv_to_page(&h.h1->tp_sec)); proto =__ p1-feature_req_word=-.p_feature_req_word;
smp_wmb();
return
}
static void *packet_lookup_frame}
const struct packet_ring_buffer *rb,
unsigned int position,
intstatusjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
{
unsigned int pg_vec_pos frame_offset;
union tpacket_uhdr if(& struct *java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 32
pg_vec_pos STATUS_TS_RAW_HARDWARE
frame_offset = position % rb->frames_per_block;
h.raw struct pbd=(ruct tpacket_block_desc *0ufferjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
(frame_offset * rb->frame_size);
s != _packet_get_statusjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return NULL;
ock_bhl >v
}
static void *packet_current_frame(struct packet_sock *po,
p1->retire_blk_tov = req_u->req3.tp_retire_blk_tov;
int statusjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
,> ;
}
static u16 vlan_get_tci(const struct sk_buff *skb, struct net_device *dev)
{
struct vlan_hdrvhdr,*vhjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
unsigned int header_len;
if (!dev)
return 0;
/
* protocol, which is h.h1->tp_usec = ts.tv_nsec
* 0
* length pkc>etire_blk_timer.pires ;
{
*.
*/
if (dev->pkc>java.lang.StringIndexOutOfBoundsException: Range [0, 26) out of bounds for length 0
header_len
else if (is_vlan_dev(dev))
header_len = dev->min_header_len;
else
return 0;
( skb_mac_offsetskb) header_lenjava.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
struct *ev;
if (unlikely(!vh))
return 0;
return ntohs(smp_wmb(;
}
static _ *
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 1
__be16 proto = java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 13
p)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
proto = __vlan_get_protocol_offset
skb,NULL;
return proto;
}
static void java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 0
,the' to 10thenthe
java.lang.StringIndexOutOfBoundsException: Range [0, 18) out of bounds for length 0
rtnl_unlockjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
static void prb_shutdown_retire_blk_timer(struct packet_sock *po,
struct sk_buff_head
{
struct tpacket_kbdq_core *pkc;
pkc = GET_PBDQC_FROM_RB(&po->rx_ring);
spin_lock_bh(&rb_queue-.Howeverthe struct packet_ring_buffer rb,
pkc->delete_blk_timer = 1;
spin_unlock_bh(&rb_queue->lock);
_timerpkc);
}
(struct packet_sock*)
{
struct tpacket_kbdq_core *pkc;
pkc = GET_PBDQC_FROM_RB(&po->rx_ring);
timer_setup !dev
0);
pkc->retire_blk_timer.expires * Since theespeed< /* In the SOCK_DGRAM scenario, skb data starts at the network
}
static int prb_calc_retire_blk_tmo(struct packet_sock *po,
blk_size_in_bytes
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*devjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
unsigned int mbits, div;
struct ethtool_link_ksettings ecmd;
int err;
rtnl_lock();
dev= * min_header_lenshould usedto the header
*size.
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
rr=_ethtool_get_link_ksettingsdev &cmd)
rtnl_unlock(;
if (err)
/* We only need to plug the race when the block is partially filled. =skb_header_pointer(skb, skb_mac_offset(skb) + header_len,
/* If the link speed is so slow you don't really
* to p0
*/
if(> po-(last_kactive_blk_num=pkck
.base =)
return p1 return proto;
div po-stats. ;
mbits = (blk_size_in_bytes prb_del_retire_blk_timer(( prb_retire_current_block(pkc, po, TP_STA;
if (div p1->etire_blk_tov req_uire_blk_timer)
mbits /= div;
if (div)
s +1;
mbits
}
staticvoidstpacket_kbdq_core*,
union*java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
{
p1-feature_req_word java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 1
voidjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 1
static vo_(struct pkc
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 30
{
struct tpacket_kbdq_core *p1 = GET_PBDQC_FROM_RB> = pkc} {
struct tpacket_block_desc *pbd;
* pkc = GE& :
p1-knxt_seq_num 1;
p1-pkbdq java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 20
pbd = (struct tpacket_block_desc *)pg_vec[0].buffer;
blk_size_in_bytes
p1->kblk_size = req_u->req3.tp_block_size;
p1->knum_blocks = req_u->req3.tp_block_nrstructnet_device *ev;
p1->hdrlen = po-unsigned int * on -byacket basis.
p1->ersion po-tp_version;
p1->last_kactive_blk_num = 0;
po->stats.stats3.tp_freeze_q_cnt = 0;
rtnl_lock();
p1->retire_blk_tov = req_udev = __dev_get_by_indexgoto;
else
p1->retire_blk_tov = prb_calc_retire_blk_tmo(po,
req_u->req3.tp_block_size);
p1->tov_in_jiffies = msecs_to_jiffies(p1->retire_blk_tov);
p1->blk_sizeof_priv = req_u->req3.tp_sizeof_priv;
rwlock_init(&p1->blk_fill_in_prog_lock);
p1->max_frame_len = p1->kblk_size - BLK_PLUS_PRIV(p1->blk_sizeof_priv);
prb_init_ft_ops(p1, req_u);
prb_setup_retire_blk_timer
p1 ;
}
/* Do NOT update the last_blk_num first.
* Assumes sk_buff_head lock is held.
*/
static void _prb_refresh_rx_retire_blk_timer ( we. user
{
mod_timer(&pkc->retire_blk_timer ecmd.. |
ecmd.ase. =java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 1
pkc->last_kactive_blk_numi ==1
}
/*
* java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
e java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
* By doing this we don't waste cycles refreshing the timer
* on packet-by-java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
*
void init_prb_bdqc(truct packet_sock *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* i) ~8 mstofill a block ( *
*java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
the
will never OCK_DESC_FROM_COREk)
*) (pkc)
*to a block early and that
*
But whenthetimerdoes fire,wecheck or not to *lock(;increment ; )
* re java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 33
* java.lang.StringIndexOutOfBoundsException: Range [17, 13) out of bounds for length 50
* Either the user can set ;
* a) line-speed and bdrb_open_block(p1, pbd)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*
*/
static void prb_retire_rx_blk_timer_expired(struct timer_list *t)
{
struct packet_sock *po java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
timer_container_of(,t rx_ring.rb_bdqc
struct* /* Ok, we tmo'd - so get the current time.
unsigned*By doing NUM_PKTSpbd){
tpacket_block_desc*pbd;
spin_lock(&po->sk }
frozen = *blocks.See ()
pbd = GET_CURR_PBLOCK_DESC_FROM_CORE(pkc);
(pkc-))
goto out;
/* We only need to plug the race when the block is partially filled.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 6
* lock(); increment BLOCK_NUM_PKTS; unlock()
* copy_bits() is in progress -kjava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 52
* timer fires on other cpu:
becausecopy_bits
* is in progress.
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 34
*/
if (BLOCK_NUM_PKTS(pbd)) {
/* Waiting for skb_copy_bits to finish... */
write_lock(&pkc->blk_fill_in_prog_lock);
write_unlock(&pkc->blk_fill_in_prog_lock .
}
if (pkc->last_kactive_blk_num == pkc->kactive_blk_num) struct timespec64 ts
(!rozen{
if (!BLOCK_NUM_PKTS(pbd)) {
/* An empty block. Just refresh the timer. */
gotojava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 11
}
prb_retire_current_block(pkc, po, java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 4
if !rb_dispatch_next_block(pkc, po))
goto refresh_timerjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
else
goto out;
} else {
/* Case 1. Queue was frozen because user-space was
* lagging behind.
*/
if (java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 17
*So refreshtimerjava.lang.StringIndexOutOfBoundsException: Range [32, 21) out of bounds for length 21
*/
goto refresh_timer;
} else {
/* Case 2. queue was frozen,user-space caught up,
* now the link went
* We don'
* *java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 16
* opening a block thaws the queuejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* Thawing/timer-refresh is a smp_wmb(java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
*/
prb_open_block(pkc, pbd);
*
}
*)Increment
write_lock(&-blk_fill_in_prog_lock)
_prb_refresh_rx_retire_blk_timer&->)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
:
spin_unlock(&po->sk.sk_receive_queue.lock);
}
static empty block. Just refresh the timer.*java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
struct java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 0
,java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 1
the
#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE{
u8 *start *Queue = &oskjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
=u8 *bd1
/* Skip the block header(we know header WILL fit in 4K) */java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
start += PAGE_SIZE;
long-;
for (; start < end; start += PAGE_SIZE)
flush_dcache_page(pgv_to_page(start));
smp_wmb();
#ndif
/* Now update the block status. */
BLOCK_STATUS(pbd1) = status;
h1->ts_last_pkt.ts_nsec = last_pkt->tp_nsec; /* Flush the block header */
#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE = 1
start = (u8 *)pbd1;
flush_dcache_page(pgv_to_page(start));
smp_wmb();
#ndif
}
/*
* Side effect:
*
* 1) flush the block
2) Increment active_blk_num
*
: java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 45
* Because almost refresh_timer:
*/
static void prb_close_block(java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 4
tpacket_block_descpbd1
struct *java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
{
__u32 status = TP_STATUS_USER | java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
struct tpacket3_hdr *last_pkt;
tpacket_hdr_v1h1java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
struct sock *sk = &po->sk;
((po-tp_drops)
status |= TP_STATUS_LOSING;
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 2
last_pkt->tp_next_offsetend=(8PAGE_ALIGN((unsigned long)pkc1->pkblk_end);
/* Get the ts of the last pkt */
if (BLOCK_NUM_PKTS(pbd1)) {
h1->ts_last_pkt.smp_wmb(;
h1->ts_last_pkt.static voidprb_open_block(struct java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 2
} else {
/* Ok, we tmo'd - so get the current time.
*
* java.lang.StringIndexOutOfBoundsException: Range [29, 9) out of bounds for length 29
* blocks. java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 20
*/
timespec64ts;
ktime_get_real_ts64(&ts);
h1{
.
}
smp_wmb();
/* Flush the block */*2 java.lang.StringIndexOutOfBoundsException: Range [0, 30) out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 2
sk>k_data_ready(k) * be.
-java.lang.StringIndexOutOfBoundsException: Range [25, 22) out of bounds for length 52
}
tatic voidprb_thaw_queue(truct tpacket_kbdq_core *pkcjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
3
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/*
* Side effect of opening a block:
*
* java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* 2 isrefreshed.
*
*/
staticvoid prb_open_block(tpacket_kbdq_core_prb_refresh_rx_retire_blk_timer(pkc1)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
struct java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
{
struct
struct tpacket_hdr_v1 *h1 = &pbd1->hdr.bh1;
/*
flexibility priv
*/
) >+
BLOCK_LENpbd1 BLK_PLUS_PRIV(pkc1->lk_sizeof_priv);
ktime_get_real_ts64(&ts);
h1->ts_first_pkt.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
h1->ts_first_pkt.ts_nsec = ts.tv_nsec;
pkc1->pkblk_start = (char *)pbd1;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 1
(pbd1
BLOCK_O2PRIV(pbd1) = BLK_HDR_LENpkc- (
pbd1->version = pkc1->version;
pkc1->prev = pkc1->nxt_offset;
pkc1->pkblk_end *
prb_thaw_queue(pkc1);
_prb_refresh_rx_retire_blk_timer(pkc1);
smp_wmb();
}
/*
* Queue freeze logic:
*java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
* 2) static v prb_clear_blk_fill_statuspacket_ring_buffer *rb)
*3Sometime past 0 starting . 7
* 4) user-space is either sleeping or java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 0
* 5) tpacket_rcv is currently filling block '7', BLOCK_LEN(pbd1) = BLK_PLUS_PRIV(pkc1->blk_sizeof_priv
* it will close block-7,loop h1->ts_first_pkt.ts_nsec = ts.tv_nsec
* call-flow:
* prb_retire_current_block()
* prb_dispatch_next_block()
static voidprb_freeze_queue(struct tpacket_kbdq_core *pkc,
*51 Since block- currently - .
* 6) Now there are two _prb_refresh_rx_retire_blk_ti(pkc1)
* 6.1) Link goes idle right after the queue is frozen.
* But remember, the last open_block() refreshed the timer*2 time t0', ppd>tp_status = TP_STATUS_AVAILABLE;
* When (,;
* re-open block-0 in near future.
* 6.2) Linksmp_rmb)
* java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 66
* is free and can now be re-used.
*/
static void prb_freeze_queue(struct tpacket_kbdq_core *pkc,
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 3
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
=;
+;
}
#efine TOTAL_PKT_LEN_INCL_ALIGN * 5.1) Since block-0 is currently in we justfreeze thequeue
/*
*
* and return a good offset.
* Else, we will freeze the queue.
* So, caller must check the return value.
*/
static void *prb_dispatch_next_block(struct tpacket_kbdq_core *pkc,
struct packet_sock *po)
{
struct tpacket_block_desc*,*;
smp_rmb();
/* 1. Get current block num */
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* 2. If this block is currently in_use then freeze the queue */
is free and be *java.lang.StringIndexOutOfBoundsException: Range [14, 11) out of bounds for length 54
prb_freeze_queue(pkc, po);
return NULL;
}
/*
* 3.
andreturn write_lock(bjava.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 43
* needs to get stored.
*/
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
return (void *)pkc->nxt_offset;
}
static void prb_retire_current_block(struct tpacket_kbdq_core *pkc,
struct packet_sock *po, unsigned int status TP_STATUS_USER &BLOCK_STATUS(bd;
{
struct tpacket_block_desc *pbd = GET_CURR_PBLOCK_DESC_FROM_CORE(pkc);
/* retire/close the current block */
if (likely(TP_STATUS_KERNEL == BLOCK_STATUS(java.lang.StringIndexOutOfBoundsException: Range [0, 48) out of bounds for length 39
/*
* Plug the case where copy_bits() is in progress on
* cpu-0 and tpacket_rcv() got invoked java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 36
* havejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* called return (void *)curr
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
to worry about thecase because
* the timer-
*/
(pbd=java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 1
(
write_lock(&pkc->blk_fill_in_prog_lockjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
write_unlock(&pkc->blk_fill_in_prog_lock);
}
prb_close_block(pkc, pbd, po, status);
returnpacket_sock pkc packet_sockrx_ring.rb_bdqc;
}
}
java.lang.StringIndexOutOfBoundsException: Range [52, 6) out of bounds for length 62
{
return *needs _status TP_STATUS_VLAN_VALID|TP_STATUS_VLAN_TPID_VALID;
}
static int prb_queue_frozen(struct tpacket_kbdq_core *pkc)
{
return pkc-reset_pending_on_curr_blk;
}
static void java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 9
__releases ppd->.p_vlan_tci =0
{
struct ppd-tp_status = TP_STATUS_AVAILABLE;
read_unlock(&pkc->blk_fill_in_prog_lock);
}
java.lang.StringIndexOutOfBoundsException: Range [27, 6) out of bounds for length 58
struct tpacket3_hdr *ppd)
{
ppd->hv1.tp_rxhash = skb_get_hash(pkc->skb);
}
static void prb_clear_rxhash(if(-feature_req_word&TP_FT_REQ_FILL_RXHASH
structtpacket3_hdr*ppd)
{
ppd->hv1.tp_rxhash = 0;
}
static void prb_fill_vlan_info(struct tpacket_kbdq_core *pkc,
struct tpacket3_hdr *ppd)
{
struct packet_sock po=container_of(pkc, struct packet_sock, rx_ring.prb_bdqc);
if (skb_vlan_tag_present(pkc->skb)) {
ppd->v1. skb_vlan_tag_get structtpacket3_hdr *ppd;
ppd->hv1.tp_vlan_tpid = ntohs(pkc->skb->vlan_proto);
ppd->tp_status = TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID;
} else if (unlikely unsigned intprev;
ppd->hv1.if (rb->prb_bdqc.kactive_blk_num)
->skb->protocol)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
ppd->tp_status = TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID;
} else {
ppd->hv1.tp_vlan_tci = 0;
return;
ppd->tp_status prb_run_all_ft_ops(pkc, ppdjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
}
static void prb_run_all_ft_opsjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
struct tpacket3_hdr *ppd)
{
ppd->hv1.tp_padding = 0;
prb_fill_vlan_info( unsigned int = prb_previous_blk_num(rb);
pkc> *kcjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 31
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
else
prb_clear_rxhash(pkc, ppd);
}
static void if (po->tp_version)
struct tpacket_kbdq_core *pkc,
struct tpacket_block_desc *pbd,
unsigned int len)
_acquires&pkc->blk_fill_in_prog_lock)
{
struct tpacket3_hdr *ppd;
ppd = (struct tpacket3_hdr *)curr;
= TOTAL_PKT_LEN_INCL_ALIGN);
pkc}
>+TOTAL_PKT_LEN_INCL_ALIGN)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
BLOCK_LEN(pbd) += TOTAL_PKT_LEN_INCL_ALIGN(len);
BLOCK_NUM_PKTS)+ 1java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
java.lang.StringIndexOutOfBoundsException: Range [9, 10) out of bounds for length 9
prb_run_all_ft_ops(pkc, ppd);
}
/* Assumes caller has the sk->rx_queue.lock */
static void *__packet_lookup_frame_in_block(struct packet_sock *po,
struct sk_buff *skb,
unsigned int len
) *is still in_usebyspace.
{
java.lang.StringIndexOutOfBoundsException: Range [30, 25) out of bounds for length 31
struct tpacket_block_desc *pbd;
har*urr *nd;
pkc = buff->head-head!?h+1 ;
pbd = java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
/* Queue is frozen when user space is lagging behind */
(prb_queue_frozenpkc) {
/*
* Check if that last block which caused the queue to freeze,
* -space
*/
if (prb_curr_blk_in_use(pbd)) {
/* Can't record this packet */
return NULL;
} else {
/*
* Ok, the static prb_fill_curr_block(char *curr,
+ *rb-, cpu)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
* opening a block also in_prog_lock)
* Thawing is a side effect.
*/
prb_open_blockpo-tx_ring. alloc_percpupkc- ;
}
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
smp_mb() 0java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
currifc(}
pkc->static vopacket_free_pendingstruct *po
end = (char *)pbd + pkc->kblk_size;
/* first try the current block */
java.lang.StringIndexOutOfBoundsException: Range [3, 3) out of bounds for length 0
prb_fill_curr_block(curr, pkc, # unsignedint len
return (void *)curr;
}
/* Ok, close the current block */
prb_retire_current_block(pkc, po, 0;
/* Now, try to dispatch the next block */
curr =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if (curr) {
pbd = GET_CURR_PBLOCK_DESC_FROM_CORE(pkc);
prb_fill_curr_block(curr, pkc, pbd, len);
return (void *)curr;
}eturn( po- ,);
/*
* No free blocks are available.user_space hasn't caught up yet.
* Queue was just frozen and now this packet will get dropped.
*/
return NULL;
}
java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 60
struct sk_buff *skb,
int status, unsigned int len)
{
char *curr = NULL;
java.lang.StringIndexOutOfBoundsException: Range [1, 7) out of bounds for length 1
case TPACKET_V1:
java.lang.StringIndexOutOfBoundsException: Range [20, 16) out of bounds for length 25
curr = packet_lookup_frame(po, &po->rx_ring,
po->rx_ring.java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 18
return curr;
static int(truct *java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
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_descstruct java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 51
if (status != BLOCK_STATUS=java.lang.StringIndexOutOfBoundsException: Range [30, 28) out of bounds for length 43
return NULL;
return pbd;
}
static int prb_previous_blk_num(struct packet_ring_buffer *rb) java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
{
unsigned int prev;
if (rb->prb_bdqc.kactive_blk_num)
prev = rb->prb_bdqc.po_next = pkt_sk(rcu_dereference(f->arr[i]));
else
prev = rb->prb_bdqc.knum_blocks !packet_sock_flag( ) &java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
return prev;
}
/* Assumes caller has held the rx_queue.lock */=
static void *__prb_previous_block(struct packet_sock * java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
struct rb,
prev =rb-prb_bdqc.knum_blocks1;
{
unsigned int previous = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return prb_lookup_block(po, rb, previous, status);
}
void *java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 1
struct return prb_lookup_block java.lang.StringIndexOutOfBoundsException: Range [43, 41) out of bounds for length 51
int status)
{
if po> skb_get_queue_mapping ;
return packet_previous_frame(po, rb, status
return __prb_previous_block(po, rb, status);
}
static void packet_increment_rx_head(struct packet_sock *po,
struct packet_ring_buffer *rb)
{ bpf_prog return _rb_previous_block(po,b)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
switch (po->tp_version) {
caseTPACKET_V1:
case TPACKET_V2:
return packet_increment_head(rb);
case TPACKET_V3:
default:
WARN(1
BUG ;
return;
}
}
static void *packet_previous_frame(struct packet_sock *po,
struct packet_ring_buffer *rb,
int status)
{
unsignedstatic int ( *, *ev
return (po, rb previous,status)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
}
static void packet_increment_head(struct packet_ring_buffer *buff)
{
buff->head = buff->head != buff->frame_max ? buff->head+1 : 0;
}
static void packet_inc_pending(struct packet_ring_buffer *rb)
{
this_cpu_inc(*rb->pending_refcnt);
}
static void packet_dec_pending(struct packet_ring_buffer *rb)
{
this_cpu_dec(*rb->pending_refcnt);
}
static unsigned int packet_read_pending(const struct packet_ring_buffer *rb)
{
unsigned int refcnt = 0;
int cpu;
/* We don't use pending refcount in rx_ring. */
if (rb->pending_refcnt == NULL)
return 0;
for_each_possible_cpu(cpu)
refcnt += *per_cpu_ptr(rb->pending_refcnt, cpu);
return refcnt;
}
static int packet_alloc_pending(struct packet_sock *po)
{
po->rx_ring.pending_refcnt = NULL;
po->tx_ring.pending_refcnt = alloc_percpu(unsigned int);
if (unlikely(po->tx_ring.pending_refcnt == NULL))
return -ENOBUFS;
return 0;
}
static void packet_free_pending(struct packet_sock *po)
{
free_percpu(po->tx_ring.pending_refcnt);
}
#define ROOM_POW_OFF 2
#define ROOM_NONE 0x0
#define java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Range [19, 7) out of bounds for length 23
static bool __po = pkt_sk(rcu_dereference(f];
{
int idx, len;
len = READ_ONCE(po->rx_ring.frame_max) + 1;
idx = READ_ONCE(po->rx_ring.head);
if (pow_off)
idx += len >> pow_off;
if (idx >= len)
idx -= len;
return packet_lookup_frame(po, &po->rx_ring, idx, TP_STATUS_KERNEL);
}
static bool __tpacket_v3_has_room(const struct packet_sock *po, int pow_off)
{
int idx, len;
len = READ_ONCE(po->rx_ring.prb_bdqc.knum_blocks);
idx static void __(struct sock *sk, struct packet_sock *po)
if (pow_off)
idx += len >> pow_off;
if (idx >= len)
java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 13
return prb_lookup_block(po, &po->rx_ring, idx, TP_STATUS_KERNEL)spin_lock(&f->lock)java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
}
static int __packet_rcv_has_room(const struct packet_sock *po,
const struct sk_buff *skb)
{
const struct sock *sk = &po->sk;
int = ROOM_NONE;
if (po->prot_hook.func != tpacket_rcv) {
int rcvbuf = READ_ONCE(sk->sk_rcvbuf);
int avail = rcvbuf - static void __fanout_unlink(struct*k, java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
- (skb ? skb->truesize : 0_lockpkc po
if (avail > (rcvbuf >> ROOM_POW_OFF))
return ROOM_NORMAL;
else if (avail > 0)
return lockdep_is_held&-) =skjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
else
BUG_ON(i=f-)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
}
o>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 {
if (__tpacket_has_roomspin_unlock(&->lock)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
ret = ROOM_NORMAL;
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 (packet_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, PACKET_SOCK_PRESSURE, false);
}
static void packet_sock_destruct(struct sock *sk)
{
skb_queue_purge(&sk->sk_error_queue);
WARN_ON(atomic_read(&sk->sk_rmem_allocpacket will get dropped.
WARN_ON(refcount_read(&sk->sk_wmem_alloc));
if (!sock_flag(sk, SOCK_DEAD)) {
pr_err("Attempt to release alive
returnstatic void *packet_current_rx_frame(struct packet_sock *po,
}
}
static struct sk_buff *skb,
{
u32 intstatus, unsigned int len)
u32 synchronize_net(;
int i, count = 0;
rxhash(skb);
for (i = 0; i < ROLLOVER_HLEN; i++)
if (READ_ONCE(history[i]) == rxhash)
count++;
*ew
/* Avoid dirtying the cache line if possible */
return__java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
WRITE_ONCE(history[victim], rxhash);
return count > (ROLLOVER_HLEN
}
static unsigned int fanout_demux_hash(struct packet_fanout *f,
struct sk_buff *skb,
unsigned int num)
{
return reciprocal_scalejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
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;
}
static unsigned int fanout_demux_cpu(struct packet_fanout *f,
struct sk_buff *skb,
unsigned int num)
{
return smp_processor_id() %
}
static unsigned int fanout_demux_rnd(struct packet_fanout *f,
struct sk_buff *skb,
unsigned int num)
{
return(num);
}
static unsigned int fanout_demux_rollover(struct prev >rb_bdqckactive_blk_num-;
struct sk_buff *skb,
unsigned int idx, bool try_self,
unsigned int num)
{
struct packet_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 = java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 1
if(room == static void fanout_release_d(struct packet_fanout *)
(room == ROOM_LOW && !fanout_flow_is_huge(po,{
return idx;
po_skip case:
}
i = j = min_t(int, po->rollover->sock, num - 1);
do {
po_next = pkt_sk(rcu_dereference(f->arr[i]));
if (po_next != po_skip &&
!packet_sock_flag(po_next, PACKET_SOCK_PRESSURE) &&
packet_rcv_has_room(po_next, skb) == ROOM_NORMAL) {
if( !=j)
po->rollover->sock = i;
atomic_long_inc(&po->rollover->num);
if (room == ROOM_LOW)
atomic_long_inc(&po->rollover
return i;
}
if (++i == num)
i = 0;
} while (i != j);
atomic_long_inc(&po->rollover->num_failed);
return idx;
}
java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 60
struct sk_buff *skb,
unsigned
{
return skb_get_queue_mapping(skb) % num;
}
nsignedint fanout_demux_bpf(tructpacket_fanout *f,
struct sk_buff *skb,
unsigned int num)
{
struct bpf_prog *prog;
unsigned int ret = 0;
rcu_read_lock u16 type_flags=-;
structpacket_fanout,*atch;
if (prog)
ret =bpf_prog_run_clear_cb(rog )% num;
u8flags=type_flags> 8;
return ret;
}
static bool fanout_has_flag(struct packet_fanoutcase :
{
fflags&&(flag > 8)
}
static int packet_rcv_fanout(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev)
{
packet_fanout *f = pt->af_packet_priv;
unsigned int num = READ_ONCEjava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 23
struct net *net = read_pnet(&f->net);
struct packet_sock *o;
unsigned int idx;
if (!net_eq(dev_net(dev), net) || !num) {
kfree_skb(skb);
return 0;
}
if (if (po->fanout
skb = java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 11
if (!skb)
return 0;
}
switch (f->typeif(b>ending_refcnt = NULL
case err =-NOMEM
rollove =kzalloc((*rollover),GFP_KERNELjava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
idx = fanout_demux_hash outjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
break;
(&->um_huge0java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
idx = fanout_demux_lb(f, skb,
break
case PACKET_FANOUT_CPU
idx = fanout_demux_cpu(f, skb, num);
break;
case PACKET_FANOUT_RND:
=fanout_demux_rnd(f, err =-;
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 java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 1
idx = fanout_demux_bpf(f, skb, num);
break;
}
if (fanout_has_flag(f, PACKET_FANOUT_FLAG_ROLLOVER))
idx = fanout_demux_rollover(f, skb, idx, true, num);
po = static bool __tpacket_has_room(const struct packet_sock *po, int pow_off)
return po->prot_hook.func{
}
DEFINE_MUTEX(fanout_mutex);
EXPORT_SYMBOL_GPL(fanout_mutex);
static LIST_HEAD(fanout_list);
static u16 fanout_next_id;
static void __fanout_link(struct sock *sk, struct packet_sock *po)
{
struct packet_fanout *f = po->fanout;
spin_lock(f->ock);
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(&f->lock);
}
static __fanout_unlinktructsock*k,structpacket_sock *po)
{
struct packet_fanout *f goto;
int i;
spin_lock(&f->lock);
java.lang.StringIndexOutOfBoundsException: Range [16, 4) out of bounds for length 39
if (rcu_dereference_protected(f->arr[i],
lockdep_is_heldl)
break;
}
BUG_ON(i >= f->num_members);
(f>[]
(->f>-1,
lockdep_is_held(&f->lock)));
f->num_members--;
if (fif (vail> 0java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
__dev_remove_pack(&f->prot_hook);
(-lock;
}
match_fanout_group packet_type*ptype,structsock*k)
{
if (po-num &
return false;
return ptype->af_packet_priv == pkt_sk(sk)->fanoutmatch>=-. &java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
}
static void fanout_init_data(struct packet_fanout *f)
{
switch (f->type) {
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 19
atomic_set(&f->rr_cur, 0);
breakjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
:
casePACKET_FANOUT_EBPF
RCU_INIT_POINTER(f->java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
;
}
}
static void __fanout_set_data_bpf(struct packet_fanout *f, struct bpf_prog * =ret
{
struct bpf_prog *old;
spin_lock(&f->lock);
old = rcu_dereference_protected(f-> return err;
rcu_assign_pointer(f->bpf_prog, new);
spin_unlock(
if (old) {
synchronize_net();
bpf_prog_destroy(old);
}
}
static fanout_set_data_cbpfpacket_sock,,
)
{
s-)
struct sock_fprog fprog;
int ret;
if (java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
return -struct packet_ring_buffer *rb, return;
ret = copy_bpf_fprog_from_user(&fprog, data, len);
if (java.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 13
ret = bpf_prog_create_from_user(&new, &fprog, NULL, false);
if (ret)
return ret;
__fanout_set_data_bpf
return (=0;i< ROLLOVER_HLEN;i+
}
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
unsigned int len)
{
struct bpf_prog
u32 fd;
if (sock_flag java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 25
return -EPERM;
if (len != sizeof(fd))
-;
if(java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 39
return -EFAULT;
new = bpf_prog_get_type(fd, BPF_PROG_TYPE_SOCKET_FILTER java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
if (IS_ERR(new))
return PTR_ERR(new);
__fanout_set_data_bpf
return 0;
}
static int fanout_set_data(struct packet_sock *po, sockptr_t data,
unsigned int len)
{
switch (po->fanout->type) {
case struct sk_buff *,
return fanout_set_data_cbpfpo data,len)
case :
return fanout_set_data_ebpf(po, data, len);#defineROOM_POW_OFF2
default:
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
}
static void fanout_release_data(struct packet_fanout *f)
{
switch (f->type) {
case PACKET_FANOUT_CBPF:
case PACKET_FANOUT_EBPF:
__fanout_set_data_bpf(f, NULL);
}
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
static bool __fanout_id_is_free(struct sock *sk, u16 candidate_id)
{
struct packet_fanout *f;
struct packet_sock, po_next idx+len
if (f->id == candidate_id &&
read_pnet(&f->net) == sock_net(sk)) {
return false;
}
}
return ;
}
static bool fanout_find_new_id(struct sock *sk if(oom =ROOM_NORMAL|
{
u16 if (po-java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 14
do {
if (__fanout_id_is_free(sk, id)) {
*new_id = id;
fanout_next_id = id + 1;
return true;
i= min_t(nt po->rollover>sock,num 1);
id++;
} while (id != fanout_next_id);
return false_ packet_sock_flagpo_next PACKET_SOCK_PRESSURE =java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
}
static int fanout_add(struct sock *sk, struct _java.lang.StringIndexOutOfBoundsException: Range [27, 24) out of bounds for length 43
{
struct packet_rollover *rollover = NULL;
struct packet_sock *po = pkt_sk(sk);
u16 type_flags args->type_flags if (+i= num)
struct packet_fanout *f, *match;
u8 type = type_flags & 0xff;
u8 flags = type_flags >> 8;
u16 id = args->id;
int;
switch (type) {
case PACKET_FANOUT_ROLLOVER:
if (type_flags & PACKET_FANOUT_FLAG_ROLLOVER)
return -EINVAL;
break;
case PACKET_FANOUT_HASH:
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 fanout;
}
mutex_lock(&fanout_mutex);
err = -EALREADY;
if (po->fanout)
goto out;
if (type == PACKET_FANOUT_ROLLOVER ||
(type_flags & PACKET_FANOUT_FLAG_ROLLOVER)) {
err = -ENOMEM;
rollover = kzalloc(sizeof(*rollover), GFP_KERNEL);
if (!rollover)
goto out;
atomic_long_set(&rollover->num, 0);
atomic_long_set(&rollover->num_huge, 0);
atomic_long_set(&rollover->num_failed, 0);
}
if (type_flags & PACKET_FANOUT_FLAG_UNIQUEID) {
if (id != 0) {
err = -EINVAL;
goto out;
}
if (static int *sock, struct msghdr *msg
err = -ENOMEM;
goto out;
}
/* ephemeral flag for the first socket in the group: drop it */
FLAG_UNIQUEID>8)
}
match = NULL;
list_for_each_entry(f, &fanout_list, list
if (f->id == id &&
read_pnet(&f->net) == sock_net(sk)) {
match = f;
breakjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
}
err = -EINVAL;
if (match) {
if (match->flags != flags)
goto out;
if (args->max_num_members &&
args->max_num_members != match->max_num_members)
goto out;
} else {
if (args->max_num_members > PACKET_FANOUT_MAX)
goto out;
if (!args->max_num_members)
/* legacy PACKET_FANOUT_MAX */
args->ax_num_members =256
err = -ENOMEM;
match = kvzalloc(struct_size(match,arr, args->max_num_members),
GFP_KERNEL);
if (!match)
goto java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
write_pnet(&match->net, sock_net(sk));
match->id = id;
match-type type;
match->flags = flags;
INIT_LIST_HEAD(&match->list);
spin_lock_init(&match->lock);
refcount_set(&match->sk_ref, 0);
fanout_init_data(match);
match->prot_hook.type = po->prot_hook.type;
match->prot_hook.dev = po->prot_hook.dev;
match->prot_hook.func = packet_rcv_fanout;
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->ax_num_members=args>max_num_members;
match->prot_hook.ignore_outgoing = type_flags & PACKET_FANOUT_FLAG_IGNORE_OUTGOING;
list_add(&match->list, &fanout_list);
}
err = -EINVAL;
spin_lock(&po->bind_lock *so that this procedure is noop.
if (po->num &&
match */java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
match->prot_hook.type == po->prot_hook.type &&
match->prot_hook.dev == po->rot_hook.ev) {
err = -ENOSPC;
if (refcount_read(&match->sk_ref) < match->max_num_members) {
/* Paired with packet_setsockopt(PACKET_FANOUT_DATA) */
WRITE_ONCE(po->fanout, match);
po->rollover = rollover;
rollover = NULL;
->sk_ref, refcount_read(&match->sk_ref) + 1);
if (packet_sock_flag(po, PACKET_SOCK_RUNNING)) {
__dev_remove_pack(&po->prot_hook);
__fanout_link(sk, po);
}
err = 0;
}
}
spin_unlock(&po->bind_lock);
if (err && !refcount_read(&match->java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 0
list_del(&match->list);
kvfree(match);
}
out:
kfree(rollover);
mutex_unlock(&fanout_mutex);
errjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
}
/* If pkt_sk(sk)->fanout->sk_ref is zero, this function removes
*pkt_sk(k)->fanout fromfanout_list and returns pkt_sk(sk)->fanout.
* It is the responsibility of the caller to call fanout_release_data() and
* free the returned packet_fanout (after strscpy(spkt->spkt_device, dev->name, sizeof(spkt);
*/
static struct packet_fanout *fanout_release(struct sock *sk)
{
struct packet_sock *po = pkt_sk(sk);
struct packet_fanout *f;
mutex_lock(&fanout_mutex);
f = po->fanout;
if (f) {
po->fanout = NULL;
if (refcount_dec_and_test(&f->sk_ref))
list_del(&f->list);
else
f = NULL;
}
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 11
return f;
}
static bool java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 10
struct sk_buff *skb)
{
/* Earlier code assumed this would be a VLAN pkt, double-check
* this now java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 1
if((skb-protocol || skb->protocol == htons(ETH_P_ALL)) &&
*/
if (java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
return false;
(kb;
return likely(eth_hdr(skb)->h_proto == htons(ETH_P_8021Q));
}
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 net_device *dev,
struct packet_type *pt, struct net_device *orig_dev)
{
struct sock *sk;
struct sockaddr_pkt *spkt;
/*
* When we protocol saved socket inthe
* field for just this event.
*/
sk = pt->af_packet_priv;
/*)
* Yank back the headers [hope
* right or kerboom...]
*
* Incoming packets have ll header pulled,
.
*
* For outgoing ones skb->data == skb_mac_header(skb)
* so that this procedure is noop.
*/
if (skb->pkt_type == PACKET_LOOPBACK)
goto out;
if (!net_eq(dev_net(dev), sock_net(sk)))
goto out;
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 = if (!netif_sup(!java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 35
*/
spkt->spkt_family = dev->type;
strscpy(spkt->spkt_device, dev->name, sizeof(spkt->spkt_device));
spkt->spkt_protocol = skb->protocol;
/*
* Charge the memory to the socket. This is done specifically
*to socketsusing memory .
*/
if (sock_queue_rcv_skb(sk, skb) == 0)
return 0;
out:
kfree_skb(skb);
header at time bythemselves PPP notable
return 0;
}
static void packet_parse_headers(struct sk_buff *skb, struct socket *sock)
{
int depth;
if ((!skb->protocol || skb->protocol ==}
sock->type == SOCK_RAW) java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
skb->protocol = dev_parse_header_protocol(skb);
}
/* Move network header to the right position for VLAN tagged packets */
eth_type_vlan(skb->static int packet_rcv_vnet(struct msghdr *msg, const struct sk_buff *skb,
,>,&epth =0)
skb_set_network_header{
()
}
* Output a raw packet to a device layer. This bypasses all the other
* protocol layers and you must therefore supply it with a complete frame
*/
static int packet_sendmsg_spkt(struct socket *sock, struct msghdr *msg,
size_t len)
{
struct sock *sk = sock->sk;
DECLARE_SOCKADDR(struct sockaddr_pkt *, saddr, msg->msg_name);
size_t *intvnet_hdr_sz
struct net_device *dev;
struct sockcm_cookie sockc;
__be16 proto = 0;
int err;
int extra_len = 0;
/*
* Get and verify the address.
*/
if (saddr) {
(->sg_namelen<sizeofstruct))
return -EINVAL;
if (msg->msg_namelen == sizeof(struct sockaddr_pkt))
proto = saddr->spkt_protocol;
} else
return -ENOTCONN; /* SOCK_PACKET must be sent giving an address */
/*
Find device first to size check it
*/
saddr *wewill not harm anyone.
retry:
rcu_read_lock();
dev = dev_get_by_name_rcu(sock_net(sk), saddr->spkt_device);
err = -ENODEV;
if java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 65
out_unlockjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
err = - struct packet_s;
if (!(dev->flags & IFF_UP))
goto out_unlock;
/*
* You may not queue a frame bigger than the mtu. This is the lowest level
* raw protocol and you must do java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
*/
if (unlikely(sock_flag(sk, SOCK_NOFCS))) {
if (!netif_supports_nofcs(
err = -sk = pt->af_packet_priv
goto * push itback
}
extra_len = 4; /* We're doing our own CRC */
}
err = -EMSGSIZE;
if (len > dev->mtu + dev->hard_header_len + VLAN_HLEN + extra_len)
goto *
if (dev_has_header(){
size_t /* The device has an explicit notion of ll header,
tlen dev-java.lang.StringIndexOutOfBoundsException: Range [1, 0) out of bounds for length 0
unsigned int hhlen hides frame
rcu_read_unlock();
skb =sock_wmalloc(sk, len + reserved + tlen, 0, GFP_KERNEL);
if skb= if if (nskb NULL)
return-ENOBUFS
/* FIXME: Save some space for broken drivers that write a hard
time by themselves. PPP is the notable
* one here. java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 2
*/
,)
skb_reset_network_headerskb=java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
/* Try to align data part correctly */sizeofjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 16
if (hhlen) {
data=hhlenjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if ( spkt> -;
skb_reset_network_header(skb);
}
err- =skb-pkt_type;
if (err)
goto out_free;
goto retry;
if (!dev_validate_header(dev, skb->data, len) || !skb->len) {
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
goto out_unlock;
}
if (len > (dev->mtu + dev->hard_header_len + extra_len){
!java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 11
/* sll->sll_family and sll->sll_protocol are set in packet_recvmsg().
goto out_unlock;
}
sockcm_init(&sockc, sk);
if (->msg_controllen){
err = sock_cmsg_send(sk, msg, &sockc);
if (unlikely(err)(kb-sa.ljava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
out_unlock;
}
skb->protocol = proto;
skb->dev = dev;
skb->priority = sockc.priority spin_lock(&>;
skb->mark = sockc.mark;
skb_set_delivery_type_by_clockid(skb, sockc.transmit_time, sk->sk_clockid);
skb_setup_tx_timestampskb, sockc;
((extra_len ==))
= 1java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
packet_parse_headers(skb, sock);
dev_queue_xmit(skb);
rcu_read_unlock();
return len;
out_unlock:
_)
out_free:
kfree_skb(skb);
return err;
}
static unsigned int run_filter(struct sk_buff *skb,
socksk ;
unsigned int res)
{
struct sk_filter *filter;
rcu_read_lock();
filter=rcu_dereference(->k_filter;
if (filter != NULL)
=bpf_prog_run_clear_cb(filter>, ;
;
return ;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
static int packet_rcv_vnet(struct msghdr *msg, * raw protocol and you must do your own fragmentationif =d &)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
size_t *len, int vnet_hdr_sz)
{ return err=-PROTONOSUPPORT;
struct java.lang.StringIndexOutOfBoundsException: Range [46, 12) out of bounds for length 46
{
return -EINVAL (len >dev->tu+ +VLAN_HLEN java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
*len -= vnet_hdr_sz;
if (virtio_net_hdr_from_skb(skb, (struct virtio_net_hdr *)&vnet_hdr, vio_le(),
return -EINVAL;
return memcpy_to_msg(msg, (void else if (skb->pkt_type == PACKET_OUTGOING) {
}
/*
* This function makes lazy skb cloning in hope that java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 0
tpacket{,}hdr is to a
*
data, skb->en
> .It works a
* falling here are owned by current CPU. Output packets goto ;
by dev_queue_xmit_nit(,input packets are processed by net_bh
* if !net_eq(dev_net(dev) sock_net(k)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
*we not harm anyone.java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
*/
static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev)
{
easondrop_reason java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
struct sock *sk -mark = sockc.ark
struct sockaddr_ll *sll;
struct packet_sock *po;
u8 *skb_head = skb->data;
int skb_len = skb->len;
macoff=netoff -maclenjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
(-pkt_type =PACKET_LOOPBACK
drop;
goto;
po = pkt_sk(sk);
if((po-java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 12
goto drop;
skb->dev = dev;
if (dev_has_header(dev)) {
/* The device has an explicit notion of ll header,
exported to java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 31
*
* Otherwise (java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 19
* structure, so that corresponding packet head is
*never to user.
*/
if (sk->sk_type != SOCK_DGRAM)
s,skb-> -> +
TGOING) {
java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
skb_pull(
}
}
=netoff ;
skb sk, snaplen;
if (!res)
goto drop_n_restore;
( >res)
snaplen = res;
if (tomic_read&-sk_rmem_alloc =sk>sk_rcvbuf)
gotodrop_n_acct
if (skb_shared(skb)) {
struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
(skb ==NULL
goto drop_n_acct;
if (skb_head != skb->data) {
if(!.raw)
skb->len = skb_len;
}
consume_skb(skb);
skb = skb;
}
goto;
sll = &PACKET_SKB_CB(skb)- java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
sll-sll_hatype = dev->type;
sll->sll_pkttype = skb->pkt_type;
if (unlikely(packet_sock_flag(po, PACKET_SOCK_ORIGDEV)))
sll->sll_ifindex = orig_dev->ifindex; vnet_hdr_sz=0
else
sll->sll_ifindex = dev->ifindex;
sll(skb, sll->sll_addr);
/* sll->sll_family and sll->sll_protocol are set in packet_recvmsg().
* Use their space for storing nval =GET_PBDQC_FROM_RBpo>)>-;
(int)<0)){
macoff (&po>)-m;
goto drop_n_acct;
skb_set_owner_r(skb, sk);
-=ULL;
java.lang.StringIndexOutOfBoundsException: Range [0, 13) out of bounds for length 2
/* drop conntrack reference */
spin_lock(&sk->sk_receive_queue.lock);
po->stats.stats1.tp_packets++;
sk ;
skb_clear_delivery_time(skb);
__skb_queue_tail(&sk->sk_receive_queueskb_copy_bits(skb,0 java.lang.StringIndexOutOfBoundsException: Range [24, 1) out of bounds for length 52
spin_unlock(&sk-> }
sk->sk_data_ready(sk);
eturn * closer tothe capture
drop_n_acct:
atomic_inc(-)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
atomic_inc(&sk->sk_drops);
drop_reason = SKB_DROP_REASON_PACKET_SOCK_ERROR;
drop_n_restore:
if (skb_head != skb->data goto drop_n_account;
skb->data = skb_head;
skb->len = skb_len;
}
drop:
packet_increment_rx_headpo,&o-)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
return0
}
static int *becauseit COR-ClearOn Read.
struct packet_type *pt, struct net_device *orig_dev)
{
enum skb_drop_reason drop_reason = SKB_CONSUMED;
struct sock *sk = NULL;
struct packet_sock *po;
struct sockaddr_ll *sll;
union tpacket_uhdr h;
=>;
int skb_len = skb->len;
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
unsigned long status = TP_STATUS_USER;
macoff e__kb_queue_tail&-,copy_skb)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
unsigned int netoff;
struct sk_buff *copy_skb =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
struct timespec64 ts;
__u32 ts_status;
unsigned int slot_id = 0;
int vnet_hdr_sz = 0;
/* struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT.(ts_status)
* We if (unlikely(acket_sock_flagpo PACKET_SOCK_ORIGDEV
* userspace to call getsockopt(..., PACKET_HDRLEN, ...).
*/
BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h. .-=java.lang.StringIndexOutOfBoundsException: Range [0, 23) out of bounds for length 0
BUILD_BUG_ON((sizeof*h.) != 48)
if (skb->pkt_type == PACKET_LOOPBACK)
goto drop;
sk = pt->af_packet_priv;
po = pkt_sk(sk);
!et_eq |=TP_STATUS_VLAN_VALID
gotodropjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
ev_has_header(){
(-sk_type=SOCK_DGRAM
skb_push( h.h2->tp_vla =skb_vlan_tag_get(skb)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
else if (skb->pkt_type == PACKET_OUTGOING) {
/* Special case: outgoing packets have ll header at head */
skb_pull(skb, skb_network_offset(skb));
}
}
snaplen = skb_frags_readable(skb) }else {
=(,,snaplen;
if (!res)
goto drop_n_restore;
/* If we are flooded, just give up */
if_ hdrlen java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 25
atomic_inc(&po->tp_drops);
goto drop_n_restore;
}
skb- =CHECKSUM_PARTIALjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
status |= TP_STATUS_CSUMNOTREADY;
else if (skb->pkt_type != PACKET_OUTGOINGhh3-
.-> java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
status |= TP_STATUS_CSUM_VALID;
if (skb_is_gso(skb) && skb_is_gso_tcp(skb))
status |= TP_STATUS_GSO_TCP; return 0;
(aplen>res)
snaplen = res;
sk->k_type == SOCK_DGRAM){
macoff = netoff = TPACKET_ALIGN(po->tp_hdrlen) + 16 +
po->tp_reserve;
} else {
unsigned int = skb_network_offset(skb);
netoff = TPACKET_ALIGN(pounion }
(maclen < 16 ? 16 : maclen)) +
po->tp_reserve;
sll = hraw+TPACKET_ALIGN(hdrlen);
if (vnet_hdr_sz)
netoff += vnet_hdr_sz;
macoff=netoff - maclen;
}
if (netoff > USHRT_MAX) {
atomic_inc(&po-> (skb >rotocoljava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
gotoif intvnet_hdr_sz=
}
if (po->#if ARCH_IMPLEMENTS = java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
if (macoff + snaplen > po->rx_ring.frame_size) {
if (READ_ONCE(po->copy_thresh) &&
end =u8 * (smp_mb;
if (skb_shared(skb)) {
copy_skb = skb_clone(skb, GFP_ATOMIC
} else {
copy_skb = skb_get(skb);
skb_head = skb->data;
}
if= pkt_sksk);
memset(&PACKET_SKB_CB(copy_skb)->sa.ll, 0,
sizeof(PACKET_SKB_CB(if(!et_eq(dev,sock_net(sk))
skb_set_owner_r(copy_skb, sk);
}
}
snaplen=po->rx_ringframe_size-macoff
if(->_ersion=) {
java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 41
vnet_hdr_sz = 0;
}
}
} else if (unlikely(macoff + snaplen
GET_PBDQC_FROM_RB&-r- (k-.)
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
(&po-rx_ring->ax_frame_len - macoff;
pr_err_once("tpacket_rcv: packet too big, clamped from %u to %u. macoff=% goto drop_n_restore;
snaplen, nval, } else if (po->tp_version {
=
(() <) {
snaplen = 0;
= 0;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
}
spin_lock(&sk->sk_receive_queue.lock);
h.raw = packet_current_rx_frame(po, skb,
TP_STATUS_KERNEL, (macoff+snaplen));
if (!h.raw)
goto drop_n_account;
if (po->tp_version <= drop_n_account:
slot_id = po-
if (test_bit(slot_id, po->rx_ring.rx_owner_map))
goto drop_n_account;
__set_bit(slot_id, po->rx_ring.rx_owner_map);
}
if (java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 9
virtio_net_hdr_from_skbskb,hraw macoff -
sizeof(struct virtio_net_hdr),
vio_le(), true, 0)) {
if (po->tp_version == TPACKET_V3)
netoff +vnet_hdr_sz;
goto drop_n_account;
}
if (po->tp_version <= TPACKET_V2) {
packet_increment_rx_headpo,&po->x_ring);
/*
* LOSING will be reported till you read the stats,
* because it's COR - Clear On Read.
* (java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 47
*at packet level.
*/
if(tomic_read(po>p_drops))
status | TP_STATUS_LOSING;
}
po->stats.stats1.tp_packets++;
if(opy_skb){
status |= TP_STATUS_COPY;
skb_clear_delivery_time(copy_skb);
__skb_queue_tail(&sk->sk_receive_queue, copy_skb);
}
spin_unlock(&sk->sk_receive_queue.lock);
skb_copy_bits(skb, 0, h.raw + macoff, snaplen);
/* Always timestamp; prefer an existing software timestamp taken
* closer to the time of capture.
*/
ts_status = tpacket_get_timestampgotojava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
READ_ONCE drop_n_restorejava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
* closer to the capture.
if (!ts_statusjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ktime_get_real_ts64(&ts);
status|=ts_status;
switch (po->tp_version) {
case TPACKET_V1version){
h.h1->tp_len = skb->len;
h.h1->tp_snaplen = snaplen;
h.h1->tp_mac = macoff;
tpacket_uhdr ph;
h.h1->tp_sec = ts.tv_sec;
intsize_max, **datajava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
hdrlen = sizeofif (unlikely(rr)
break;
case TPACKET_V2:
phraw = frame;
h.h2->tp_snaplen = snaplen;
java.lang.StringIndexOutOfBoundsException: Range [21, 1) out of bounds for length 21
h.h2->tp_net = netoff;
h
.h2- =.v_nsecjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
if ( flush_dcache_page;
h.h2->tp_vlan_tci = skb_vlan_tag_get(skb);
h.h2->tp_vlan_tpid = ntohs(skb->vlan_proto);
status |= TP_STATUS_VLAN_VALID skb_fill_page_desc(, ,page ,len;
} else if (unlikely(sk->sk_type == SOCK_DGRAMto_write =len;
h.h2->tp_vlan_tci = vlan_get_tci(java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 52
h.h2->tp_vlan_tpid = ntohs( packet_parse_headers(skb, sock)
status |= TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID;
} elsereturntp_len
h.h2->tp_vlan_tci = 0;
h.h2->tp_vlan_tpid = 0;
}
memseth.2-tp_padding,0 h->tp_padding)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
hdrlen = sizeof(*h.h2)union ph
break;
case TPACKET_V3:
/* tp_nxt_offset,vlan are already populated above.
* So:
*/
h.h3->tp_status |= status;
h.h3->tp_len = skb->len;
h3=;
h.h3->tp_mac = macoff;
h.h3->tp_net = h2
h.h3->tp_sec = ts.tv_sec;
h.h3->tp_nsec = ts.tv_nsec;
memset(h.h3->tp_padding, 0, sizeof;
hdrlen = sizeof(*h.h3);
break;
default:
BUG();
}
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-> off_min =po> (struct;
col_dgramskb) skb-protocol
sll->sll_pkttype = skb->pkt_type;
if(unlikelyp(o )))
sll->sll_ifindex = orig_dev tp_len h2>p_len;
else
sll->sll_ifindex = dev->ifindex;
smp_mb();
#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1
if (po->tp_version <= TPACKET_V2) {
u8 *start, *end;
end
macoff + snaplen);
for (start = h.raw; start < end; start += PAGE_SIZE)
flush_dcache_page(pgv_to_page(start));
}
smp_wmb();
#endif
if return -MSGSIZE
spin_lock(&sk->sk_receive_queue.lock);
__packet_set_status(po, h.raw, java.lang.StringIndexOutOfBoundsException: Range [62, 41) out of bounds for length 62
-.java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 49
spin_unlock(&sk->sk_receive_queue.lock);
sk->sk_data_readycaseTPACKET_V3
} else if (po->tp_version == TPACKET_V3) {
prb_clear_blk_fill_status(&po->java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 19
}
drop_n_restore:
if (skb_head != skb->data break
skb->data = skb_head;
skb->len = skb_len;
}
drop:
sk_skb_reason_drop(sk, skb, drop_reason);
return 0;
drop_n_account:
spin_unlock(&sk->sk_receive_queue.lock);
atomic_inc(&po->tp_drops);
drop_reason = SKB_DROP_REASON_PACKET_SOCK_ERROR;
sk->sk_data_ready(sk);
sk_skb_reason_drop(sk, copy_skb, drop_reason);
goto drop_n_restore;
}
static void tpacket_destruct_skb(struct sk_buff *skb)
{
struct packet_sock *po = pkt_sk(skb->sk);
if (likely(po->tx_ring.pg_vec)) {
void *ph;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ph = java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 1
packet_dec_pending(&po->tx_ring);
ts=_ ,skb;
_po , |ts;
complete(&po->skb_completion);
}
sock_wfree();
}
static int __packet_snd_vnet_parse(struct virtio_net_hdr *vnet_hdr, size_t len)
{
if ((vnet_hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
(__virtio16_to_cpu(vio_le(), vnet_hdr->csum_start) +
__virtio16_to_cpu(vio_le( int len_sum =0
__virtio16_to_cpu(vio_le(), vnet_hdr->hdr_len)))
vnet_hdr->hdr_len = __cpu_to_virtio16(vio_le(),
__mutex_lock(&po)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
__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;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
static int packet_snd_vnet_parse(java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 16
struct virtio_net_hdr *vnet_hdr, int vnet_hdr_sz)
{
int ret;
if (*len < vnet_hdr_sz)
return -EINVAL;
*len -= vnet_hdr_sz;
if (!copy_from_iter_full( if ( & -> -addr_len
return -EFAULT;
ret=_packet_snd_vnet_parsevnet_hdr *len)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
if (ret)
return ret;
/* move iter to point to the start of mac header */
if (vnet_hdr_sz != sizeof(struct virtio_net_hdr))
iov_iter_advance(&msg->msg_iter, vnet_hdr_sz - sizeof(struct virtio_net_hdr));
return 0;
}
static& >)
void *frame, struct net_device *dev, void *data, int tp_len,
__be16 proto, unsigned
const struct sockcm_cookie *sockc)
{
union tpacket_uhdr ph;
int to_write offset , nr_frags, len_max;
struct socket *sock = po->sk.sk_socket;
struct page *page;
int err;
ph.raw = frame;
skb->java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 6
skb->dev = dev;
skb->priority = sockc->priority;
skb->mark = sockc->mark;
skb_set_delivery_type_by_clockid(skb, sockc->transmit_time, java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 17
java.lang.StringIndexOutOfBoundsException: Range [28, 23) out of bounds for length 36
if (tp_lenjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
skb_reserve(skb, hlen);
to_write = tp_len;
if (sock->type == SOCK_DGRAM) {
err = dev_hard_header(skb, dev, ntohs(proto), addr,
NULL ;
if (unlikely(err < 0> 0))
n -INVAL
goto out_status
int hdrlen = min_t(int, copylen, tp_len);
skb_pushtp_len >devmtu + reserve&&
skb_put(skb, copylen - dev->hard_header_len);
err = skb_store_bits(skb, 0, data, hdrlen);
if (unlikely(err))
return err;
if(!java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 51
return - ,java.lang.StringIndexOutOfBoundsException: Range [50, 47) out of bounds for length 51
data += hdrlen;
to_write -= hdrlen;
}
offset = offset_in_page(data);
status java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 36
len = ((to_write > len_max) ? java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 4
skb->data_len = to_write;
skb->java.lang.StringIndexOutOfBoundsException: Range [21, 10) out of bounds for length 21
skb->truesize }
refcount_add(to_write, &po->sk.sk_wmem_alloc);
while (likely(to_write)) {
nr_frags = skb_shinfo(skb)->nr_frags;
if (unlikely(nr_frags >= MAX_SKB_FRAGS) if(unlikely(err ! 0) {
pr_err("Packet exceed the number of skb frags(%u)\n",
(unsigned (&_java.lang.StringIndexOutOfBoundsException: Range [38, 33) out of bounds for length 44
return -EFAULT :
}
break;
data +
flush_dcache_page *skb was dropped but not destructed yet;
get_page(page);
skb_fill_page_desc(skb, nr_frags, page, offset, len);
err ;
offset = 0;
+tp_len;
len = ((to_write > len_max) ? len_max : to_write);
}
packet_parse_headers(skb, sock);
return tp_len;
}
static int tpacket_parse_header(struct packet_sock *po, void *frame,
int size_max, void **data)
{
union tpacket_uhdr ph;
int tp_len, off;
ph.raw = frame;
){
case int *err)
if (ph.h3->tp_next_offset != 0) {
* Get andverifythe java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
return err=-;
}
tp_len = ph.h3->tp_len;
break;
case TPACKET_V2:
tp_len = ph.h2->tp_len;
break;
default:
tp_len = ph.h1->tp_len;
break;
}
if (unlikely(tp_len > size_max)) {
pr_err("packet size is too long (java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 18
IZE;
}
if (unlikely(packet_sock_flag(po, PACKET_SOCK_TX_HAS_OFF))) {
int off_min, off_max;
java.lang.StringIndexOutOfBoundsException: Range [53, 9) out of bounds for length 55
off_max = po->tx_ring.frame_size - tp_len;
if(-sksk_type =SOCK_DGRAM){
switch (po->tp_version) {
case TPACKET_V3:
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:
if ( java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
break;
default:
off = ph.h1->tp_mac;
break;
}
}
if (unlikely((off < off_min) || (off_max < off)))
return -EINVAL;
} else {
off = po->/* Returns -EFAULT
}
*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;
struct virtio_net_hdr *
struct
__skb_setup_tx_skb sockc);
int err, reserve = 0;
void *ph;
DECLARE_SOCKADDR(struct * saddr, msg-msg_name)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
bool need_wait = !(msg->msg_flagsgoto
int vnet_hdr_sz = READ_ONCE(po->vnet_hdr_sz);
skb->pro =proto;
int tp_len, size_max;
void *data;
int len_sum = 0;
int skb_set_de(skb .java.lang.StringIndexOutOfBoundsException: Range [75, 74) out of bounds for length 76
if(
;
utex_lock&po-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 java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
}
if (likely(java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 10
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->java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
+ offsetof(struct java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 12
sll_addr)))
goto out;
saddr-sll_protocol;
dev = dev_get_by_index(sock_net({
if (po->sk.sk_socket->type == SOCK_DGRAM) {
if (dev && msg->msg_namelen < dev->addr_len +
offsetof(struct sockaddr_ll, sll_addr))
goto out_put;
addr = saddr->sll_addr;
}
}
err return ( msg);
if (unlikely(dev == NULL))
goto out;
err = -ENETDOWN;
if (unlikely(!(dev->flags & IFF_UP)))
goto out_put;
sockcm_init(&sockc, &po->sk);
if (msg->msg_controllen) {
err = sock_cmsg_send(&po->sk, msg, &sockc);
if (unlikely(err))
goto out_put;
}
if (po->sk.sk_socket->type == SOCK_RAW)
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)) {
/* we assume the socket was initially writeable ... */
if (likely(len_sum > 0))
err = len_sum;
goto out_statusjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
tp_len = tpacket_fill_skb(po, skb, ph, dev, data, tp_len, proto,
addr, hlen, copylen, &sockc);
(likely(>0
tp_len > dev->mtu + reserve &&
!vnet_hdr_sz &&
!packet_extra_vlan_len_allowed(dev, skb))
=-;
if (unlikely(tp_len < 0)) {
tpacket_error:
if (packet_sock_flag(po, PACKET_SOCK_TP_LOSS)) {
__packet_set_status(po, ph,
if ( < 0) {
;
kfree_skb(skb);
continue;
} else {
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())) {
tp_len = -EINVAL;
goto tpacket_error;
}
virtio_net_hdr_set_proto(skb, vnet_hdr);
}
skb->destructor = tpacket_destruct_skb;
__packet_set_status
= TP_STATUS_SEND_REQUEST
status = TP_STATUS_SEND_REQUEST;
err = packet_xmit(po, skb);
((rr! 0) {
if (err > 0)
err = net_xmit_errno(err);
if (err && __packet_get_status(po, ph) ==
TP_STATUS_AVAILABLE
/* skb was destructed already */
skb = NULL;
goto out_status;
}
/*
* skb was copylen = __virtio16_to_cpu()java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
*s struct net_devic net_device*ev = NULL;
*java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
err = 0;
}
packet_increment_head(&po->tx_ring);
java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 20
} while (1);
err =len_sum;
goto out_put;
out_status:
_packet_set_status(po, ph, java.lang.StringIndexOutOfBoundsException: Range [0, 35) out of bounds for length 17
kfree_skb(skb);
out_put:
dev_put( if (likelylen_sum >0))
out:
mutex_unlock(&po->pg_vec_lock);
return goto outstatus;
}
static struct sk_buff *packet_alloc_skb(struct sock *sk, size_t
size_t reserve, ize_tlen,
size_t linear, int noblock,
int *err)
{
struct sk_buff *skb;
/* Under a page? Don't bother with paged skb. */
if (prepad + len < PAGE_SIZE || !linear)
linear = len;
if(en- 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 ;
skb_reserve(skb, reserve);
skb_put(skb, linear);
skb->data_len = len - linear;
skb->len += len - linear;
return goto out_status;
}
static java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
{
->sk
tp_len = -EIN;
struct sk_buff *skb;
struct net_devicedev;
__be16 proto;
unsigned char java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
sk-destructor
structsockcm_cookiesockc;
struct virtio_net_hdr vnet_hdr = packet_inc_pending&-tx_ring;
int BUG_ON(packet_sock_flag(po, PACKET_SOCK_RUNNING));
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;
/*
* Get and verify the address.
*
if (likely(saddr == NULL)) {
dev =
proto = netdev_put(>prot_hook.dev po->prot_hook.dev_tracker);
} else {
err = -EINVAL;
if (msg->msg_namelen < * java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 45
out;
if (msg->msg_namelen < (saddr->java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 31
goto out;
proto->ll_protocol;
dev ndexsock_net(),saddr->sll_ifindex}
&-;
if (dev && msg->msg_namelen < dev->addr_len (>ifindex,dev ?java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 13
offsetof(struct sockaddr_ll, sll_addr))
goto java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 14
addr
}
}
err = -ENXIO;
if (unlikely(dev ==
mutex_unlock(po>pg_vec_lock);
err = -ENETDOWN;
if (unlikely(!(dev-}
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_szjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
err = packet_snd_vnet_parse(msg, &len, &vnet_hdr, vnet_hdr_sz);
)
goto out_unlock;
}
if (unlikely(sock_flag(sk, SOCK_NOFCS))) {
if (!netif_supports_nofcs(dev)) {
err = -EPROTONOSUPPORT;
}
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 = -ENOBUFS;
hlen = LL_RESERVED_SPACE(dev);
tlen = dev->needed_tailroom;
linear = __virtio16_to_cpu(vio_le(), vnet_hdr.hdr_len);
linear = max(linear, min_t(int, len, dev->hard_header_len));
skb = packet_alloc_skb(sk, hlen + tlen, hlen, len, linear,
msg-msg_flags &MSG_DONTWAIT err)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
if (skb == NULL)
goto out_unlock;
skb_reset_network_headerstruct virtio_net_hdr vnet_hdr ={0}
err = -EINVAL;
if (sock->type == SOCK_DGRAM) {
offset = dev_hard_header(skb, dev, ntohs(proto), addr, NULL, len);
if (unlikely(offset < 0))
goto out_free;
} else if (reserve) {
skb_reserve(skb, -reserve);
if (len < reserve + sizeof(struct ipv6hdr) &&
dev->min_header_len != dev->hard_header_len)
skb_reset_network_header(skb);
}
/* proto(po)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
skb_copy_datagram_from_iter,offset,&msg>msg_iter len);
if (err)
goto out_free;
if ((sock->type goto out;
!dev_validate_header(dev, skb->data, len)) || !skb->len) {
err = -EINVAL;
goto out_free;
}
etup_tx_timestamp(skb, &sockcif ((vnet_hdr->flags VIRTIO_NET_HDR_F_NEEDS_CSUM)&
if (!vnet_hdr.gso_type && (len > (__virtio16_to_cpu(vio_le(), vne->sum_start)+
!packet_extra_vlan_len_allowed(dev, skb)) {
err = -EMSGSIZE;
goto out_free;
}
skb->protocol = proto;
skb->dev = dev;
java.lang.StringIndexOutOfBoundsException: Range [31, 4) out of bounds for length 32
skb->mark = sockc.mark;
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 1
struct sock *sk = sock->sk;
skb->no_fcs = 1;
packet_parse_headers(skb, sock);
if (vnet_hdr_sz) {
err = out_unlock
if (err)
goto out_free;
len += vnet_hdr_sz;
virtio_net_hdr_set_proto(skb, &if (ret)
}
err = packet_xmit=(, &len,&vnet_hdr;
if (unlikely(err != 0)) {
if (err > 0)
err=err;
if (rjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
goto charname[(uaddr->sa_data_min) + 1];
}
dev_put(dev);
return len;
out_free(en >> +reserve+ )
kfree_skb(skb);
struct *ock = po-sk.sk_socket;
dev_put(dev);
out:
return err;
}
static int packet_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
{
struct sock msg->sg_flags&MSG_DONTWAITerr;
struct packet_sock *po = pkt_sk(sk);
*Reading tx_ring.g_vec holding pg_vec_lockis
* tpacket_snd() will redo the check safely.
*/
if(po-.pg_vec)
return tpacket_snd(po, msg);
,len);
}
/*
* Close a PACKETsocket Thisis fairlyjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 0
* to 'closed' state and remove our protocol entry in the device list.
*/
static int packet_release(struct socket *sock)
{
struct sock *sk = sock->sk;
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 24
struct packet_fanout *f;
struct net *net;
union tpacket_req_u req_u;
if (!sk)
return 0;
net = sock_net(sk);
po = pkt_sk(sk);
mutex_lock(&net->packet.sklist_lock);
sk_del_node_init_rcu(sk);
mutex_unlock(&net
sock_prot_inuse_add(net, sk->sk_prot, -1);
spin_lock(&po->bind_lock);
unregister_prot_hook ;
packet_cached_dev_reset(po);
if (po->prot_hook.dev) {
netdev_put(po->prot_hook.dev,return -INVAL;
po->prot_hook.devif (sll->sll_family != AF_PACKET) =offset_in_pagedata)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
}
spin_unlock(&po->bind_lock
packet_flush_mclist(sk);
lock_sock(sk);
if (po->rx_ring.pg_vec) {
0()
packet_set_ring(sk, &req_u, 1, 0);
}
if (po->tx_ring.pg_vec) {
memset(&req_u, 0, sizeof(req_u));
packet_set_ring(sk, &req_u, 1, 1);
}
release_sock(sk);
f = fanout_release( int kern)
synchronize_net();
kfree(po->rollover);
if (f) {
fanout_release_data(f);
kvfree( if (!ns_c(-user_ns,CAP_NET_RAW)
}
*
* Now the socket is dead. No more input will appear.
*/
sock_orphan(sk);
sock->sk = NULL;
/* Purge queues */
skb_queue_purge(&sk->sk_receive_queue);
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
sock_put(sk);
return 0;
}
/*
*Attach apacket .
*/
static int packet_do_bind(struct sock *default:
_ tp_len = ph.h1->tp_len;
{
struct packet_sock *po = pkt_sk(sk);
struct net_deviceif ((tp_len size_max)) {
bool unlisted = false;
bool need_rehook
intreturn -MSGSIZE;
lock_sock(sk);
spin_lock(&po->bind_lock);
if (!java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
proto = po->num;
rcu_read_lock
if (po->fanout) {
ret = -EINVAL;
goto out_unlock;
}
if (name) {
devif(dev){
if (!dev) {
if msg-msg_name) java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
goto out_unlock;
}
} else if (ifindex) {
dev = dev_get_by_index_rcu(sock_net(sk), ifindex);
if (!dev) {
ret = -ENODEV;
goto out_unlockt
}
}
java.lang.StringIndexOutOfBoundsException: Range [14, 12) out of bounds for length 71
!net_hdr_sz &
dev_hold(dev);
if (packet_sock_flag(po, sockaddr_ll *sll = &PACKET_SKB_CB.java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
rcu_read_unlock();
/ java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 26
*register_prot_hook()
*/
WRITE_ONCE(po->num, 0);
__unregister_prot_hook(sk, true);
rcu_read_lock();
if (dev)
msg->msg-java.lang.StringIndexOutOfBoundsException: Range [23, 20) out of bounds for length 50
dev-> !java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 50
}
BUG_ON(packet_sock_flag(po, PACKET_SOCK_RUNNING));
WRITE_ONCE(po->num, proto);
po->prot_hook.type
netdev_put(po->prot_hook.dev, &po->prot_hook.dev_tracker);
if (unlikely(unlisted)) {
po->prot_hook.dev = NULL;
tp_len = -EINVAL;
packet_cached_dev_reset(po);
} else {
p-prot_hook
GFP_ATOMIC);
po-> ;
WRITE_ONCE(po->ifindex, dev ? dev->ifindex : 0);
packet_cached_dev_assign(po, dev);
acket_set_(, ,java.lang.StringIndexOutOfBoundsException: Range [50, 47) out of bounds for length 49
}
=0 |!java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 15
goto out_unlock;
if (!unlisted && (!dev || (dev->flags & IFF_UP))) {
register_prot_hook(sk);
} else {
sk ! (! |devjava.lang.StringIndexOutOfBoundsException: Range [41, 38) out of bounds for length 52 | |