Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 183978
b: refs/heads/master
c: 889b8f9
h: refs/heads/master
v: v3
  • Loading branch information
David S. Miller committed Feb 6, 2010
1 parent 8190e5b commit 45f8e97
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 44 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7aeef972cce30b0ab04047e07918b04d867e7a29
refs/heads/master: 889b8f964f2f226b7cd5a0a515109e3d8d9d1613
8 changes: 4 additions & 4 deletions trunk/Documentation/networking/packet_mmap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
+ ABSTRACT
--------------------------------------------------------------------------------

This file documents the CONFIG_PACKET_MMAP option available with the PACKET
This file documents the mmap() facility available with the PACKET
socket interface on 2.4 and 2.6 kernels. This type of sockets is used for
capture network traffic with utilities like tcpdump or any other that needs
raw access to network interface.
Expand Down Expand Up @@ -44,7 +44,7 @@ enabled. For transmission, check the MTU (Maximum Transmission Unit) used and
supported by devices of your network.

--------------------------------------------------------------------------------
+ How to use CONFIG_PACKET_MMAP to improve capture process
+ How to use mmap() to improve capture process
--------------------------------------------------------------------------------

From the user standpoint, you should use the higher level libpcap library, which
Expand All @@ -64,7 +64,7 @@ the low level details or want to improve libpcap by including PACKET_MMAP
support.

--------------------------------------------------------------------------------
+ How to use CONFIG_PACKET_MMAP directly to improve capture process
+ How to use mmap() directly to improve capture process
--------------------------------------------------------------------------------

From the system calls stand point, the use of PACKET_MMAP involves
Expand Down Expand Up @@ -105,7 +105,7 @@ also the mapping of the circular buffer in the user process and
the use of this buffer.

--------------------------------------------------------------------------------
+ How to use CONFIG_PACKET_MMAP directly to improve transmission process
+ How to use mmap() directly to improve transmission process
--------------------------------------------------------------------------------
Transmission process is similar to capture as shown below.

Expand Down
10 changes: 0 additions & 10 deletions trunk/net/packet/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,3 @@ config PACKET
be called af_packet.

If unsure, say Y.

config PACKET_MMAP
bool "Packet socket: mmapped IO"
depends on PACKET
help
If you say Y here, the Packet protocol driver will use an IO
mechanism that results in faster communication.

If unsure, say N.

29 changes: 0 additions & 29 deletions trunk/net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ struct packet_mreq_max {
unsigned char mr_address[MAX_ADDR_LEN];
};

#ifdef CONFIG_PACKET_MMAP
static int packet_set_ring(struct sock *sk, struct tpacket_req *req,
int closing, int tx_ring);

Expand All @@ -177,19 +176,16 @@ struct packet_ring_buffer {

struct packet_sock;
static int tpacket_snd(struct packet_sock *po, struct msghdr *msg);
#endif

static void packet_flush_mclist(struct sock *sk);

struct packet_sock {
/* struct sock has to be the first member of packet_sock */
struct sock sk;
struct tpacket_stats stats;
#ifdef CONFIG_PACKET_MMAP
struct packet_ring_buffer rx_ring;
struct packet_ring_buffer tx_ring;
int copy_thresh;
#endif
spinlock_t bind_lock;
struct mutex pg_vec_lock;
unsigned int running:1, /* prot_hook is attached*/
Expand All @@ -199,13 +195,11 @@ struct packet_sock {
int ifindex; /* bound device */
__be16 num;
struct packet_mclist *mclist;
#ifdef CONFIG_PACKET_MMAP
atomic_t mapped;
enum tpacket_versions tp_version;
unsigned int tp_hdrlen;
unsigned int tp_reserve;
unsigned int tp_loss:1;
#endif
struct packet_type prot_hook ____cacheline_aligned_in_smp;
};

Expand All @@ -219,8 +213,6 @@ struct packet_skb_cb {

#define PACKET_SKB_CB(__skb) ((struct packet_skb_cb *)((__skb)->cb))

#ifdef CONFIG_PACKET_MMAP

static void __packet_set_status(struct packet_sock *po, void *frame, int status)
{
union {
Expand Down Expand Up @@ -315,8 +307,6 @@ static inline void packet_increment_head(struct packet_ring_buffer *buff)
buff->head = buff->head != buff->frame_max ? buff->head+1 : 0;
}

#endif

static inline struct packet_sock *pkt_sk(struct sock *sk)
{
return (struct packet_sock *)sk;
Expand Down Expand Up @@ -640,7 +630,6 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
return 0;
}

#ifdef CONFIG_PACKET_MMAP
static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev)
{
Expand Down Expand Up @@ -1056,7 +1045,6 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
mutex_unlock(&po->pg_vec_lock);
return err;
}
#endif

static inline struct sk_buff *packet_alloc_skb(struct sock *sk, size_t prepad,
size_t reserve, size_t len,
Expand Down Expand Up @@ -1248,13 +1236,11 @@ static int packet_snd(struct socket *sock,
static int packet_sendmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t len)
{
#ifdef CONFIG_PACKET_MMAP
struct sock *sk = sock->sk;
struct packet_sock *po = pkt_sk(sk);
if (po->tx_ring.pg_vec)
return tpacket_snd(po, msg);
else
#endif
return packet_snd(sock, msg, len);
}

Expand All @@ -1268,9 +1254,7 @@ static int packet_release(struct socket *sock)
struct sock *sk = sock->sk;
struct packet_sock *po;
struct net *net;
#ifdef CONFIG_PACKET_MMAP
struct tpacket_req req;
#endif

if (!sk)
return 0;
Expand Down Expand Up @@ -1299,15 +1283,13 @@ static int packet_release(struct socket *sock)

packet_flush_mclist(sk);

#ifdef CONFIG_PACKET_MMAP
memset(&req, 0, sizeof(req));

if (po->rx_ring.pg_vec)
packet_set_ring(sk, &req, 1, 0);

if (po->tx_ring.pg_vec)
packet_set_ring(sk, &req, 1, 1);
#endif

/*
* Now the socket is dead. No more input will appear.
Expand Down Expand Up @@ -1872,7 +1854,6 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv
return ret;
}

#ifdef CONFIG_PACKET_MMAP
case PACKET_RX_RING:
case PACKET_TX_RING:
{
Expand Down Expand Up @@ -1943,7 +1924,6 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv
po->tp_loss = !!val;
return 0;
}
#endif
case PACKET_AUXDATA:
{
int val;
Expand Down Expand Up @@ -2041,7 +2021,6 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,

data = &val;
break;
#ifdef CONFIG_PACKET_MMAP
case PACKET_VERSION:
if (len > sizeof(int))
len = sizeof(int);
Expand Down Expand Up @@ -2077,7 +2056,6 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
val = po->tp_loss;
data = &val;
break;
#endif
default:
return -ENOPROTOOPT;
}
Expand Down Expand Up @@ -2197,11 +2175,6 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
return 0;
}

#ifndef CONFIG_PACKET_MMAP
#define packet_mmap sock_no_mmap
#define packet_poll datagram_poll
#else

static unsigned int packet_poll(struct file *file, struct socket *sock,
poll_table *wait)
{
Expand Down Expand Up @@ -2483,8 +2456,6 @@ static int packet_mmap(struct file *file, struct socket *sock,
mutex_unlock(&po->pg_vec_lock);
return err;
}
#endif


static const struct proto_ops packet_ops_spkt = {
.family = PF_PACKET,
Expand Down

0 comments on commit 45f8e97

Please sign in to comment.