Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

packet: Kill CONFIG_PACKET_MMAP.

Early on this was an experimental facility that few
people other than Alexey Kuznetsov played with.

Now it's a pretty fundamental thing and as people add
more features to AF_PACKET sockets this config options
creates ifdef spaghetti.

So kill it off.

Signed-off-by: David S. Miller <davem@davemloft.net>

+4 -43
+4 -4
Documentation/networking/packet_mmap.txt
··· 2 2 + ABSTRACT 3 3 -------------------------------------------------------------------------------- 4 4 5 - This file documents the CONFIG_PACKET_MMAP option available with the PACKET 5 + This file documents the mmap() facility available with the PACKET 6 6 socket interface on 2.4 and 2.6 kernels. This type of sockets is used for 7 7 capture network traffic with utilities like tcpdump or any other that needs 8 8 raw access to network interface. ··· 44 44 supported by devices of your network. 45 45 46 46 -------------------------------------------------------------------------------- 47 - + How to use CONFIG_PACKET_MMAP to improve capture process 47 + + How to use mmap() to improve capture process 48 48 -------------------------------------------------------------------------------- 49 49 50 50 From the user standpoint, you should use the higher level libpcap library, which ··· 64 64 support. 65 65 66 66 -------------------------------------------------------------------------------- 67 - + How to use CONFIG_PACKET_MMAP directly to improve capture process 67 + + How to use mmap() directly to improve capture process 68 68 -------------------------------------------------------------------------------- 69 69 70 70 From the system calls stand point, the use of PACKET_MMAP involves ··· 105 105 the use of this buffer. 106 106 107 107 -------------------------------------------------------------------------------- 108 - + How to use CONFIG_PACKET_MMAP directly to improve transmission process 108 + + How to use mmap() directly to improve transmission process 109 109 -------------------------------------------------------------------------------- 110 110 Transmission process is similar to capture as shown below. 111 111
-10
net/packet/Kconfig
··· 14 14 be called af_packet. 15 15 16 16 If unsure, say Y. 17 - 18 - config PACKET_MMAP 19 - bool "Packet socket: mmapped IO" 20 - depends on PACKET 21 - help 22 - If you say Y here, the Packet protocol driver will use an IO 23 - mechanism that results in faster communication. 24 - 25 - If unsure, say N. 26 -
-29
net/packet/af_packet.c
··· 157 157 unsigned char mr_address[MAX_ADDR_LEN]; 158 158 }; 159 159 160 - #ifdef CONFIG_PACKET_MMAP 161 160 static int packet_set_ring(struct sock *sk, struct tpacket_req *req, 162 161 int closing, int tx_ring); 163 162 ··· 176 177 177 178 struct packet_sock; 178 179 static int tpacket_snd(struct packet_sock *po, struct msghdr *msg); 179 - #endif 180 180 181 181 static void packet_flush_mclist(struct sock *sk); 182 182 ··· 183 185 /* struct sock has to be the first member of packet_sock */ 184 186 struct sock sk; 185 187 struct tpacket_stats stats; 186 - #ifdef CONFIG_PACKET_MMAP 187 188 struct packet_ring_buffer rx_ring; 188 189 struct packet_ring_buffer tx_ring; 189 190 int copy_thresh; 190 - #endif 191 191 spinlock_t bind_lock; 192 192 struct mutex pg_vec_lock; 193 193 unsigned int running:1, /* prot_hook is attached*/ ··· 195 199 int ifindex; /* bound device */ 196 200 __be16 num; 197 201 struct packet_mclist *mclist; 198 - #ifdef CONFIG_PACKET_MMAP 199 202 atomic_t mapped; 200 203 enum tpacket_versions tp_version; 201 204 unsigned int tp_hdrlen; 202 205 unsigned int tp_reserve; 203 206 unsigned int tp_loss:1; 204 - #endif 205 207 struct packet_type prot_hook ____cacheline_aligned_in_smp; 206 208 }; 207 209 ··· 212 218 }; 213 219 214 220 #define PACKET_SKB_CB(__skb) ((struct packet_skb_cb *)((__skb)->cb)) 215 - 216 - #ifdef CONFIG_PACKET_MMAP 217 221 218 222 static void __packet_set_status(struct packet_sock *po, void *frame, int status) 219 223 { ··· 306 314 { 307 315 buff->head = buff->head != buff->frame_max ? buff->head+1 : 0; 308 316 } 309 - 310 - #endif 311 317 312 318 static inline struct packet_sock *pkt_sk(struct sock *sk) 313 319 { ··· 630 640 return 0; 631 641 } 632 642 633 - #ifdef CONFIG_PACKET_MMAP 634 643 static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, 635 644 struct packet_type *pt, struct net_device *orig_dev) 636 645 { ··· 1045 1056 mutex_unlock(&po->pg_vec_lock); 1046 1057 return err; 1047 1058 } 1048 - #endif 1049 1059 1050 1060 static inline struct sk_buff *packet_alloc_skb(struct sock *sk, size_t prepad, 1051 1061 size_t reserve, size_t len, ··· 1236 1248 static int packet_sendmsg(struct kiocb *iocb, struct socket *sock, 1237 1249 struct msghdr *msg, size_t len) 1238 1250 { 1239 - #ifdef CONFIG_PACKET_MMAP 1240 1251 struct sock *sk = sock->sk; 1241 1252 struct packet_sock *po = pkt_sk(sk); 1242 1253 if (po->tx_ring.pg_vec) 1243 1254 return tpacket_snd(po, msg); 1244 1255 else 1245 - #endif 1246 1256 return packet_snd(sock, msg, len); 1247 1257 } 1248 1258 ··· 1254 1268 struct sock *sk = sock->sk; 1255 1269 struct packet_sock *po; 1256 1270 struct net *net; 1257 - #ifdef CONFIG_PACKET_MMAP 1258 1271 struct tpacket_req req; 1259 - #endif 1260 1272 1261 1273 if (!sk) 1262 1274 return 0; ··· 1283 1299 1284 1300 packet_flush_mclist(sk); 1285 1301 1286 - #ifdef CONFIG_PACKET_MMAP 1287 1302 memset(&req, 0, sizeof(req)); 1288 1303 1289 1304 if (po->rx_ring.pg_vec) ··· 1290 1307 1291 1308 if (po->tx_ring.pg_vec) 1292 1309 packet_set_ring(sk, &req, 1, 1); 1293 - #endif 1294 1310 1295 1311 /* 1296 1312 * Now the socket is dead. No more input will appear. ··· 1854 1872 return ret; 1855 1873 } 1856 1874 1857 - #ifdef CONFIG_PACKET_MMAP 1858 1875 case PACKET_RX_RING: 1859 1876 case PACKET_TX_RING: 1860 1877 { ··· 1924 1943 po->tp_loss = !!val; 1925 1944 return 0; 1926 1945 } 1927 - #endif 1928 1946 case PACKET_AUXDATA: 1929 1947 { 1930 1948 int val; ··· 2021 2041 2022 2042 data = &val; 2023 2043 break; 2024 - #ifdef CONFIG_PACKET_MMAP 2025 2044 case PACKET_VERSION: 2026 2045 if (len > sizeof(int)) 2027 2046 len = sizeof(int); ··· 2056 2077 val = po->tp_loss; 2057 2078 data = &val; 2058 2079 break; 2059 - #endif 2060 2080 default: 2061 2081 return -ENOPROTOOPT; 2062 2082 } ··· 2174 2196 } 2175 2197 return 0; 2176 2198 } 2177 - 2178 - #ifndef CONFIG_PACKET_MMAP 2179 - #define packet_mmap sock_no_mmap 2180 - #define packet_poll datagram_poll 2181 - #else 2182 2199 2183 2200 static unsigned int packet_poll(struct file *file, struct socket *sock, 2184 2201 poll_table *wait) ··· 2456 2483 mutex_unlock(&po->pg_vec_lock); 2457 2484 return err; 2458 2485 } 2459 - #endif 2460 - 2461 2486 2462 2487 static const struct proto_ops packet_ops_spkt = { 2463 2488 .family = PF_PACKET,