aboutsummaryrefslogtreecommitdiffstats
path: root/net/packet
diff options
context:
space:
mode:
Diffstat (limited to 'net/packet')
-rw-r--r--net/packet/af_packet.c31
1 files changed, 4 insertions, 27 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 02e401cd683f..99b55e641e8d 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -86,20 +86,6 @@
86#define CONFIG_SOCK_PACKET 1 86#define CONFIG_SOCK_PACKET 1
87 87
88/* 88/*
89 Proposed replacement for SIOC{ADD,DEL}MULTI and
90 IFF_PROMISC, IFF_ALLMULTI flags.
91
92 It is more expensive, but I believe,
93 it is really correct solution: reentereble, safe and fault tolerant.
94
95 IFF_PROMISC/IFF_ALLMULTI/SIOC{ADD/DEL}MULTI are faked by keeping
96 reference count and global flag, so that real status is
97 (gflag|(count != 0)), so that we can use obsolete faulty interface
98 not harming clever users.
99 */
100#define CONFIG_PACKET_MULTICAST 1
101
102/*
103 Assumptions: 89 Assumptions:
104 - if device has no dev->hard_header routine, it adds and removes ll header 90 - if device has no dev->hard_header routine, it adds and removes ll header
105 inside itself. In this case ll header is invisible outside of device, 91 inside itself. In this case ll header is invisible outside of device,
@@ -159,7 +145,6 @@ static atomic_t packet_socks_nr;
159 145
160/* Private packet socket structures. */ 146/* Private packet socket structures. */
161 147
162#ifdef CONFIG_PACKET_MULTICAST
163struct packet_mclist 148struct packet_mclist
164{ 149{
165 struct packet_mclist *next; 150 struct packet_mclist *next;
@@ -179,7 +164,7 @@ struct packet_mreq_max
179 unsigned short mr_alen; 164 unsigned short mr_alen;
180 unsigned char mr_address[MAX_ADDR_LEN]; 165 unsigned char mr_address[MAX_ADDR_LEN];
181}; 166};
182#endif 167
183#ifdef CONFIG_PACKET_MMAP 168#ifdef CONFIG_PACKET_MMAP
184static int packet_set_ring(struct sock *sk, struct tpacket_req *req, int closing); 169static int packet_set_ring(struct sock *sk, struct tpacket_req *req, int closing);
185#endif 170#endif
@@ -205,9 +190,7 @@ struct packet_sock {
205 origdev:1; 190 origdev:1;
206 int ifindex; /* bound device */ 191 int ifindex; /* bound device */
207 __be16 num; 192 __be16 num;
208#ifdef CONFIG_PACKET_MULTICAST
209 struct packet_mclist *mclist; 193 struct packet_mclist *mclist;
210#endif
211#ifdef CONFIG_PACKET_MMAP 194#ifdef CONFIG_PACKET_MMAP
212 atomic_t mapped; 195 atomic_t mapped;
213 unsigned int pg_vec_order; 196 unsigned int pg_vec_order;
@@ -851,9 +834,7 @@ static int packet_release(struct socket *sock)
851 __sock_put(sk); 834 __sock_put(sk);
852 } 835 }
853 836
854#ifdef CONFIG_PACKET_MULTICAST
855 packet_flush_mclist(sk); 837 packet_flush_mclist(sk);
856#endif
857 838
858#ifdef CONFIG_PACKET_MMAP 839#ifdef CONFIG_PACKET_MMAP
859 if (po->pg_vec) { 840 if (po->pg_vec) {
@@ -1221,7 +1202,6 @@ static int packet_getname(struct socket *sock, struct sockaddr *uaddr,
1221 return 0; 1202 return 0;
1222} 1203}
1223 1204
1224#ifdef CONFIG_PACKET_MULTICAST
1225static void packet_dev_mc(struct net_device *dev, struct packet_mclist *i, int what) 1205static void packet_dev_mc(struct net_device *dev, struct packet_mclist *i, int what)
1226{ 1206{
1227 switch (i->type) { 1207 switch (i->type) {
@@ -1349,7 +1329,6 @@ static void packet_flush_mclist(struct sock *sk)
1349 } 1329 }
1350 rtnl_unlock(); 1330 rtnl_unlock();
1351} 1331}
1352#endif
1353 1332
1354static int 1333static int
1355packet_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen) 1334packet_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen)
@@ -1362,7 +1341,6 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv
1362 return -ENOPROTOOPT; 1341 return -ENOPROTOOPT;
1363 1342
1364 switch(optname) { 1343 switch(optname) {
1365#ifdef CONFIG_PACKET_MULTICAST
1366 case PACKET_ADD_MEMBERSHIP: 1344 case PACKET_ADD_MEMBERSHIP:
1367 case PACKET_DROP_MEMBERSHIP: 1345 case PACKET_DROP_MEMBERSHIP:
1368 { 1346 {
@@ -1383,7 +1361,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv
1383 ret = packet_mc_drop(sk, &mreq); 1361 ret = packet_mc_drop(sk, &mreq);
1384 return ret; 1362 return ret;
1385 } 1363 }
1386#endif 1364
1387#ifdef CONFIG_PACKET_MMAP 1365#ifdef CONFIG_PACKET_MMAP
1388 case PACKET_RX_RING: 1366 case PACKET_RX_RING:
1389 { 1367 {
@@ -1506,11 +1484,10 @@ static int packet_notifier(struct notifier_block *this, unsigned long msg, void
1506 1484
1507 switch (msg) { 1485 switch (msg) {
1508 case NETDEV_UNREGISTER: 1486 case NETDEV_UNREGISTER:
1509#ifdef CONFIG_PACKET_MULTICAST
1510 if (po->mclist) 1487 if (po->mclist)
1511 packet_dev_mclist(dev, po->mclist, -1); 1488 packet_dev_mclist(dev, po->mclist, -1);
1512 // fallthrough 1489 /* fallthrough */
1513#endif 1490
1514 case NETDEV_DOWN: 1491 case NETDEV_DOWN:
1515 if (dev->ifindex == po->ifindex) { 1492 if (dev->ifindex == po->ifindex) {
1516 spin_lock(&po->bind_lock); 1493 spin_lock(&po->bind_lock);