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

beceem: remove ARP spoofing

Linux support NOARP flag, so the whole Arp spoofing routines
are not needed.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

+7 -107
-94
drivers/staging/bcm/Arp.c
··· 1 - 2 - /* 3 - * File Name: Arp.c 4 - * Abstract: This file contains the routines for handling ARP PACKETS 5 - */ 6 - #include "headers.h" 7 - #define ARP_PKT_SIZE 60 8 - 9 - /* ========================================================================= 10 - * Function - reply_to_arp_request() 11 - * 12 - * Description - When this host tries to broadcast ARP request packet through 13 - * the virtual interface (veth0), reply directly to upper layer. 14 - * This function allocates a new skb for ARP reply packet, 15 - * fills in the fields of the packet and then sends it to 16 - * upper layer. 17 - * 18 - * Parameters - skb: Pointer to sk_buff structure of the ARP request pkt. 19 - * 20 - * Returns - None 21 - * =========================================================================*/ 22 - 23 - VOID 24 - reply_to_arp_request(struct sk_buff *skb) 25 - { 26 - PMINI_ADAPTER Adapter; 27 - struct ArpHeader *pArpHdr = NULL; 28 - struct ethhdr *pethhdr = NULL; 29 - UCHAR uiIPHdr[4]; 30 - /* Check for valid skb */ 31 - if(skb == NULL) 32 - { 33 - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Invalid skb: Cannot reply to ARP request\n"); 34 - return; 35 - } 36 - 37 - 38 - Adapter = GET_BCM_ADAPTER(skb->dev); 39 - /* Print the ARP Request Packet */ 40 - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, "ARP Packet Dump :"); 41 - BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, (PUCHAR)(skb->data), skb->len); 42 - 43 - /* 44 - * Extract the Ethernet Header and Arp Payload including Header 45 - */ 46 - pethhdr = (struct ethhdr *)skb->data; 47 - pArpHdr = (struct ArpHeader *)(skb->data+ETH_HLEN); 48 - 49 - if(Adapter->bETHCSEnabled) 50 - { 51 - if(memcmp(pethhdr->h_source, Adapter->dev->dev_addr, ETH_ALEN)) 52 - { 53 - dev_kfree_skb(skb); 54 - return; 55 - } 56 - } 57 - 58 - // Set the Ethernet Header First. 59 - memcpy(pethhdr->h_dest, pethhdr->h_source, ETH_ALEN); 60 - if(!memcmp(pethhdr->h_source, Adapter->dev->dev_addr, ETH_ALEN)) 61 - { 62 - pethhdr->h_source[5]++; 63 - } 64 - 65 - /* Set the reply to ARP Reply */ 66 - pArpHdr->arp.ar_op = ntohs(ARPOP_REPLY); 67 - 68 - /* Set the HW Address properly */ 69 - memcpy(pArpHdr->ar_sha, pethhdr->h_source, ETH_ALEN); 70 - memcpy(pArpHdr->ar_tha, pethhdr->h_dest, ETH_ALEN); 71 - 72 - // Swapping the IP Adddress 73 - memcpy(uiIPHdr,pArpHdr->ar_sip,4); 74 - memcpy(pArpHdr->ar_sip,pArpHdr->ar_tip,4); 75 - memcpy(pArpHdr->ar_tip,uiIPHdr,4); 76 - 77 - /* Print the ARP Reply Packet */ 78 - 79 - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, "ARP REPLY PACKET: "); 80 - 81 - /* Send the Packet to upper layer */ 82 - BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, (PUCHAR)(skb->data), skb->len); 83 - 84 - skb->protocol = eth_type_trans(skb,skb->dev); 85 - skb->pkt_type = PACKET_HOST; 86 - 87 - // skb->mac.raw=skb->data+LEADER_SIZE; 88 - skb_set_mac_header (skb, LEADER_SIZE); 89 - netif_rx(skb); 90 - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, "<=============\n"); 91 - return; 92 - } 93 - 94 -
+3
drivers/staging/bcm/Bcmnet.c
··· 124 124 net->ethtool_ops = &bcm_ethtool_ops; 125 125 net->mtu = MTU_SIZE; /* 1400 Bytes */ 126 126 net->tx_queue_len = TX_QLEN; 127 + net->flags |= IFF_NOARP; 128 + net->flags &= ~(IFF_BROADCAST|IFF_MULTICAST); 129 + 127 130 netif_carrier_off(net); 128 131 129 132 SET_NETDEV_DEVTYPE(net, &wimax_type);
+1 -1
drivers/staging/bcm/Makefile
··· 6 6 7 7 bcm_wimax-y := InterfaceDld.o InterfaceIdleMode.o InterfaceInit.o InterfaceRx.o \ 8 8 InterfaceIsr.o InterfaceMisc.o InterfaceTx.o \ 9 - Arp.o CmHost.o IPv6Protocol.o Qos.o Transmit.o\ 9 + CmHost.o IPv6Protocol.o Qos.o Transmit.o\ 10 10 Bcmnet.o DDRInit.o HandleControlPacket.o\ 11 11 LeakyBucket.o Misc.o sort.o Bcmchar.o hostmibs.o PHSModule.o\ 12 12 led_control.o nvm.o vendorspecificextn.o
+3 -12
drivers/staging/bcm/Transmit.c
··· 6 6 digraph transmit1 { 7 7 node[shape=box] 8 8 edge[weight=5;color=red] 9 - bcm_transmit->reply_to_arp_request[label="ARP"] 9 + 10 10 bcm_transmit->GetPacketQueueIndex[label="IP Packet"] 11 11 GetPacketQueueIndex->IpVersion4[label="IPV4"] 12 12 GetPacketQueueIndex->IpVersion6[label="IPV6"] ··· 63 63 64 64 qindex = GetPacketQueueIndex(Adapter, skb); 65 65 66 - if (INVALID_QUEUE_INDEX==qindex) { 67 - if (ntohs(eth_hdr(skb)->h_proto) != ETH_ARP_FRAME) 68 - goto drop; 69 - 70 - /* 71 - Reply directly to ARP request packet 72 - ARP Spoofing only if NO ETH CS rule matches for it 73 - */ 74 - reply_to_arp_request(skb); 75 - return NETDEV_TX_OK; 76 - } 66 + if (INVALID_QUEUE_INDEX==qindex) 67 + goto drop; 77 68 78 69 if (Adapter->PackInfo[qindex].uiCurrentPacketsOnHost >= SF_MAX_ALLOWED_PACKETS_TO_BACKUP) 79 70 return NETDEV_TX_BUSY;