/* * 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_rx.h" #include "built_in.h" void destroy_rx_ring(int sock, struct ring *ring) { int ret; bool v3 = get_sockopt_tpacket(sock) == TPACKET_V3; munmap(ring->mm_space, ring->mm_len); ring->mm_len = 0; xfree(ring->frames); /* In general, this is freed during close(2) anyway. */ if (v3) return; fmemset(&ring->layout, 0, sizeof(ring->layout)); ret = setsockopt(sock, SOL_PACKET, PACKET_RX_RING, &ring->layout, sizeof(ring->layout)); if (unlikely(ret)) panic("Cannot destroy the RX_RING: %s!\n", strerror(errno)); } void setup_rx_ring_layout(int sock, struct ring *ring, unsigned int size, bool jumbo_support, bool v3) { fmemset(&ring->layout, 0, sizeof(ring->layout)); ring->layout.tp_block_size = (jumbo_support ? getpagesize() << 4 : getpagesize() << 2); ring->layout.tp_frame_size = (jumbo_support ? TPACKET_ALIGNMENT << 12 : TPACKET_ALIGNMENT << 7); ring->layout.tp_block_nr = size / ring->layout.tp_block_size; ring->layout.tp_frame_nr = ring->layout.tp_block_size / ring->layout.tp_frame_size * ring->layout.tp_block_nr; if (v3) { /* Pass out, if this will ever change and we do crap on it! */ build_bug_on(offsetof(struct tpacket_req, tp_frame_nr) != offsetof(struct tpacket_req3, tp_frame_nr) && sizeof(struct tpacket_req) != offsetof(struct tpacket_req3, tp_retire_blk_tov)); ring->layout3.tp_retire_blk_tov = 100; /* 0: let kernel decide */ ring->layout3.tp_sizeof_priv = 0; ring->layout3.tp_feature_req_word = 0; set_sockopt_tpacket_v3(sock); } else { set_sockopt_tpacket_v2(sock); } ring_verify_layout(ring); } void create_rx_ring(int sock, struct ring *ring, int verbose) { int ret; bool v3 = get_sockopt_tpacket(sock) == TPACKET_V3; retry: ret = setsockopt(sock, SOL_PACKET, PACKET_RX_RING, &ring->raw, v3 ? sizeof(ring->layout3) : sizeof(ring->layout)); if (errno == ENOMEM && ring->layout.tp_block_nr > 1) { ring->layout.tp_block_nr >>= 1; ring->layout.tp_frame_nr = ring->layout.tp_block_size / ring->layout.tp_frame_size * ring->layout.tp_block_nr; goto retry; } if (ret < 0) panic("Cannot allocate RX_RING!\n"); ring->mm_len = ring->layout.tp_block_size * ring->layout.tp_block_nr; if (verbose) { if (!v3) { printf("RX,V2: %.2Lf MiB, %u Frames, each %u Byte allocated\n", (long double) ring->mm_len / (1 << 20), ring->layout.tp_frame_nr, ring->layout.tp_frame_size); } else { printf("RX,V3: %.2Lf MiB, %u Blocks, each %u Byte allocated\n", (long double) ring->mm_len / (1 << 20), ring->layout.tp_block_nr, ring->layout.tp_block_size); } } } void mmap_rx_ring(int sock, struct ring *ring) { mmap_ring_generic(sock, ring); } void alloc_rx_ring_frames(int sock, struct ring *ring) { int num; size_t size; bool v3 = get_sockopt_tpacket(sock) == TPACKET_V3; if (v3) { num = ring->layout3.tp_block_nr; size = ring->layout3.tp_block_size; } else { num = ring->layout.tp_frame_nr; size = ring->layout.tp_frame_size; } alloc_ring_frames_generic(ring, num, size); } void bind_rx_ring(int sock, struct ring *ring, int ifindex) { bind_ring_generic(sock, ring, ifindex); } void sock_rx_net_stats(int sock, unsigned long seen) { int ret; bool v3 = get_sockopt_tpacket(sock) == TPACKET_V3; union { struct tpacket_stats k2; struct tpacket_stats_v3 k3; } stats; socklen_t slen = v3 ? sizeof(stats.k3) : sizeof(stats.k2); memset(&stats, 0, sizeof(stats)); ret = getsockopt(sock, SOL_PACKET, PACKET_STATISTICS, &stats, &slen); if (ret > -1) { uint64_t packets = stats.k3.tp_packets; uint64_t drops = stats.k3.tp_drops; printf("\r%12ld packets incoming (%ld unread on exit)\n", v3 ? seen : packets, v3 ? packets - seen : 0); printf("\r%12ld packets passed filter\n", packets - drops); printf("\r%12ld packets failed filter (out of space)\n", drops); if (stats.k3.tp_packets > 0) printf("\r%12.4lf%% packet droprate\n", (1.0 * drops / packets) * 100.0); } } tch) treef63906f41699c8e38af9d12b063e2ceab0286ef2 /fs/nfs/nfs4_fs.h parente34bac726d27056081d0250c0e173e4b155aa340 (diff)parent868c97a846a73e937d835b09b8c885a69df50ec8 (diff)
Merge tag 'docs-4.10' of git://git.lwn.net/linuxHEADmaster
Pull documentation update from Jonathan Corbet: "These are the documentation changes for 4.10. It's another busy cycle for the docs tree, as the sphinx conversion continues. Highlights include: - Further work on PDF output, which remains a bit of a pain but should be more solid now. - Five more DocBook template files converted to Sphinx. Only 27 to go... Lots of plain-text files have also been converted and integrated. - Images in binary formats have been replaced with more source-friendly versions. - Various bits of organizational work, including the renaming of various files discussed at the kernel summit. - New documentation for the device_link mechanism. ... and, of course, lots of typo fixes and small updates" * tag 'docs-4.10' of git://git.lwn.net/linux: (193 commits) dma-buf: Extract dma-buf.rst Update Documentation/00-INDEX docs: 00-INDEX: document directories/files with no docs docs: 00-INDEX: remove non-existing entries docs: 00-INDEX: add missing entries for documentation files/dirs docs: 00-INDEX: consolidate process/ and admin-guide/ description scripts: add a script to check if Documentation/00-INDEX is sane Docs: change sh -> awk in REPORTING-BUGS Documentation/core-api/device_link: Add initial documentation core-api: remove an unexpected unident ppc/idle: Add documentation for powersave=off Doc: Correct typo, "Introdution" => "Introduction" Documentation/atomic_ops.txt: convert to ReST markup Documentation/local_ops.txt: convert to ReST markup Documentation/assoc_array.txt: convert to ReST markup docs-rst: parse-headers.pl: cleanup the documentation docs-rst: fix media cleandocs target docs-rst: media/Makefile: reorganize the rules docs-rst: media: build SVG from graphviz files docs-rst: replace bayer.png by a SVG image ...
Diffstat (limited to 'fs/nfs/nfs4_fs.h')