/* * netsniff-ng - the packet sniffing beast * Copyright 2009, 2010 Daniel Borkmann. * Subject to the GPL, version 2. */ #include #include #include #include #include #include #include #include #include #include "xmalloc.h" #include "die.h" #include "ring.h" #include "built_in.h" void mmap_ring_generic(int sock, struct ring *ring) { ring->mm_space = mmap(NULL, ring->mm_len, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED | MAP_POPULATE, sock, 0); if (ring->mm_space == MAP_FAILED) panic("Cannot mmap {TX,RX}_RING!\n"); } void alloc_ring_frames_generic(struct ring *ring, int num, size_t size) { int i; size_t len = num * sizeof(*ring->frames); ring->frames = xmalloc_aligned(len, CO_CACHE_LINE_SIZE); fmemset(ring->frames, 0, len); for (i = 0; i < num; ++i) { ring->frames[i].iov_len = size; ring->frames[i].iov_base = ring->mm_space + (i * size); } } void bind_ring_generic(int sock, struct ring *ring, int ifindex, bool tx_only) { int ret; /* The {TX,RX}_RING registers itself to the networking stack with * dev_add_pack(), so we have one single RX_RING for all devs * otherwise you'll get the packet twice. */ fmemset(&ring->s_ll, 0, sizeof(ring->s_ll)); ring->s_ll.sll_family = AF_PACKET; if (tx_only) ring->s_ll.sll_protocol = 0; else ring->s_ll.sll_protocol = htons(ETH_P_ALL); ring->s_ll.sll_ifindex = ifindex; ring->s_ll.sll_hatype = 0; ring->s_ll.sll_halen = 0; ring->s_ll.sll_pkttype = 0; ret = bind(sock, (struct sockaddr *) &ring->s_ll, sizeof(ring->s_ll)); if (ret < 0) panic("Cannot bind {TX,RX}_RING!\n"); } /?h=nds-private-remove&id=c73e44269369e936165f0f9b61f1f09a11dae01c'>refslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent <vincent.stehle@laposte.net>2017-01-30 15:06:43 +0100
committerDavid S. Miller <davem@davemloft.net>2017-01-31 13:07:40 -0500
commitc73e44269369e936165f0f9b61f1f09a11dae01c (patch)
treee2188e900ba06302f8ed2746cb07edd3efbc5c35 /Documentation/devicetree
parent040587af31228d82c52267f717c9fcdb65f36335 (diff)
net: thunderx: avoid dereferencing xcv when NULL
This fixes the following smatch and coccinelle warnings: drivers/net/ethernet/cavium/thunder/thunder_xcv.c:119 xcv_setup_link() error: we previously assumed 'xcv' could be null (see line 118) [smatch] drivers/net/ethernet/cavium/thunder/thunder_xcv.c:119:16-20: ERROR: xcv is NULL but dereferenced. [coccinelle] Fixes: 6465859aba1e66a5 ("net: thunderx: Add RGMII interface type support") Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net> Cc: Sunil Goutham <sgoutham@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'Documentation/devicetree')