Hardware-address filtering How can we send packets to just one node on our ‘anchor’ cluster?

Slides:



Advertisements
Similar presentations
Linux device-driver issues
Advertisements

Lecture 101 Lecture 10: Kernel Modules and Device Drivers ECE 412: Microcomputer Laboratory.
R4 Dynamically loading processes. Overview R4 is closely related to R3, much of what you have written for R3 applies to R4 In R3, we executed procedures.
CS 450 Module R4. R4 Overview Due on March 11 th along with R3. R4 is a small yet critical part of the MPX system. In this module, you will add the functionality.
What is a packet checksum? Here we investigate the NIC’s capabilities for computing and detecting errors using checksums.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Characters and Strings.
Module R2 Overview. Process queues As processes enter the system and transition from state to state, they are stored queues. There may be many different.
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
More 82573L details Getting ready to write and test a character-mode device-driver for our anchor-LAN’s ethernet controllers.
Fixing some driver problems Most software is discovered to have some ‘design-flaws’ after it has been put into use for awhile.
Receiver ‘packet-splitting’
I/o multiplexing On adding a ‘poll()’ method to our character-mode device-driver for an 82573L network controller.
Virtual Local Area Networks A look at how the Intel 82573L nic supports IEEE standard 802.1q for ethernet VLANs.
1 Fall 2005 Hardware Addressing and Frame Identification Qutaibah Malluhi CSE Department Qatar University.
Character Driver Issues Implementing ‘/dev/physmem’
The RealTek interface Introduction to the RTL-8139 network controller registers.
RTL-8139 experimentation Setting up an environment for studying the Network Controller.
Computer Network 實踐資管 Wang-Jiunn Cheng 2004 PART IV-2 Local Area Networks (LANs) Frame.
Examining network packets Information about the RTL8139 needed for understanding our ‘watch235.c’ pseudo driver.
The hardware ringbuffer Understanding the RTL-8139 mechanism for packet reception.
Standard C Library Application Programming Interface to System-Calls.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
Our ‘nic.c’ module We create a ‘character-mode’ device-driver for the 82573L NIC to use in futrure experiments.
Our ‘nic.c’ module We create a ‘character-mode’ device-driver for the 82573L NIC to use in future experiments.
Adjusting out device-driver Here we complete the job of modifying our ‘nicf.c’ Linux driver to support ‘raw’ packet-transfers.
Looking at kernel objects How a character-mode Linux device driver can be useful in viewing a ‘net_device’ structure.
What’s needed to transmit? A look at the minimum steps required for programming our anchor nic’s to send packets.
Hardware-address filtering How can we send packets to just one node on our ‘anchor’ cluster?
Detection of Promiscuous nodes Using Arp Packets By Engin Arslan.
Notes for Lab 10 On implementing ‘show’ and ‘hide’ for the SiS 315 hardware cursor.
The ‘zero-copy’ initiative A look at the ‘zero-copy’ concept and an x86 Linux implementation for the case of outgoing packets.
POSIX: Files Introduction to Operating Systems: Discussion 1 Read Solaris System Interface Guide: Ch. 5.1 Basic File I/O.
Protocol Headers Pre DA SA 0800h … version H L 6 TCP Header Data FCS
Operating System Program 5 I/O System DMA Device Driver.
Hardware Definitions –Port: Point of connection –Bus: Interface Daisy Chain (A=>B=>…=>X) Shared Direct Device Access –Controller: Device Electronics –Registers:
CP104 Introduction to Programming File I/O Lecture 33 __ 1 File Input/Output Text file and binary files File Input/output File input / output functions.
Raw Sockets Vivek Ramachandran. A day in the life of Network Packet.
Hyung-Min Lee ©Networking Lab., 2001 Chapter 8 ARP and RARP.
Ethernet Driver Changes for NET+OS V5.1. Design Changes Resides in bsp\devices\ethernet directory. Source code broken into more C files. Native driver.
UNIX Files File organization and a few primitives.
Queues, Pipes and Sockets. QUEUE A structure with a series of data elements with the first element waiting for an operation Used when an element is not.
Chapter 9 Hardware Address & Frame Type Identification Hardware address of frame Addressing schemes Ethernet Frame header format.
ECE 526 – Network Processing Systems Design Computer Architecture: traditional network processing systems implementation Chapter 4: D. E. Comer.
Chapter 9 Hardware Addressing and Frame Type Identification 1.Delivering and sending packets 2.Hardware addressing: specifying a destination 3. Broadcasting.
1 Ch 9 Hardware Addressing and Frame Type Identification.
Interfacing Device Drivers with the Kernel
CSCI 330 UNIX and Network Programming
GAME203 – C Files stdio.h C standard Input/Output “getchar()”
1 Hardware Addressing and Frame Type Identification.
CSE333 SECTION 3. Important Dates Jan 27 th – Homework 1 Due Feb 6 th – Midterm.
1 CSC103: Introduction to Computer and Programming Lecture No 28.
MINIX Presented by: Clinton Morse, Joseph Paetz, Theresa Sullivan, and Angela Volk.
FILES IN C. File Operations  Creation of a new file  Opening an existing file  Reading from a file  Writing to a file  Moving to a specific location.
C Programming Day 2. 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/LA07/003 Version No. 1.0 Union –mechanism to create user defined data types.
Address Resolution Protocol Yasir Jan 20 th March 2008 Future Internet.
Local Area Networks: Topologies. 2 Packet Identification & MAC Addresses Each packet specifies an intended recipient with an identifier. – Demultiplexing.
Using System Calls (Unix) Have to tell compiler (if C/C++) where to find the headers, etc. – i.e., the “include” files May have to tell compiler where.
DYNAMIC MEMORY ALLOCATION. Disadvantages of ARRAYS MEMORY ALLOCATION OF ARRAY IS STATIC: Less resource utilization. For example: If the maximum elements.
Introduction to Networks v6.0
Zero-copy Receive Path in Virtio
Instructor Materials Chapter 5: Ethernet
Local Area Networks: Topologies
Chapter 22 – part a Stream refer to any source of input or any destination for output. Many small programs, obtain all their input from one stream usually.
Linux Kernel Driver.
Ethernet : Framing and Addressing
Operation System Program 4
CSE 333 – Section 3 POSIX I/O Functions.
CSE 333 – Section 3 POSIX I/O Functions.
CSE 333 – Section 3 POSIX I/O Functions.
Who’s listening? Some experiments with an ‘echo’ service on our anchor-cluster’s local network of 82573L nic’s.
Presentation transcript:

Hardware-address filtering How can we send packets to just one node on our ‘anchor’ cluster?

Privacy, please! Our ‘xmit1000.c’ driver transmits all of its packets to every node on our LAN, and our ‘recv1000.c’ driver receives all of the packets transmitted by any of the nodes! Is this what we really want to happen? anchor01 anchor02 anchor03 anchor04 anchor05 anchor06 anchor07 anchor00

Receive address filtering Nowadays any network interface controller has a “filtering” capability which allows any packet NOT to be received by nodes that the packet’s sender didn’t intend it to go to Receive buffer Host memory Transmit FIFO Receive FIFO Network Interface Controller to/from LAN filtering engine

Our new ‘nic.c’ module This device-driver combines the ‘write()’ and ‘read()’ methods from our ‘xmit1000.c’ and ‘recv1000.c’ modules, but it adds an ‘ioctl()’ method that lets applications setup any ethernet-packet’s destination-address, as is illustrated in our companion program (named ‘sendto.cpp’) which finds a node’s hardware-address in our ‘ethers’ database

The ‘sendto’ algorithm Here are the steps which our ‘sendto.cpp’ demo-program performs: Find the destination’s node-name on the command-line Search our ‘ethers’ file for a line with that node’s name Convert that node’s MAC-address from ascii to numeric Open the ‘/dev/nic’ device-file Call our driver’s ‘ioctl()’ method to setup packets’ destination Write our application’s test-message to the ‘dev/nic’ device-file Print a message confirming the destination and bytes written

Notes on library functions Use ‘fopen()’ to open the ‘ethers’ textfile, so you can use the ‘fgets()’ function to read in its contents one-line-at-a-time: #include // for fopen(), fgets(), puts() #include // for strstr() int main( int argc, char *argv[ ] ) { if ( argc == 1 ) exit(1);// missing command-line argument FILE*fd = fopen( “ethers”, “ro” ); if ( fd == NULL ) exit(1);// file not found in current directory charline[ 80 ]; while ( fgets( line, 80, fd ) ) if ( strstr( line, argv[1] ) puts( line ); /* additional processing goes here */ }

‘ascii-to-numeric’ Use ‘strstr( string, substring )’ to find line in ‘ethers’ file with name of specified node Use ‘strtol( string, NULL, 16 )’ to convert a hexadecimal digit-string to a numeric value unsigned chardstn[ 6 ]; // storage for 6-byte MAC-address // loop converts colon-formatted hex-string to array of numbers for (int i = 0; i < 6; i++) dstn[ i ] = strtol( line+3*i, NULL, 16 );

Our ‘ioctl()’ function Our ‘nic.c’ driver implements an ‘ioctl()’ service allowing a user-program to setup the network hardware-address that will be used in the destination-field of any packet that the driver’s ‘write()’ function transmits // open the network interface controller’s device-file intfp = open( “/dev/nic”, O_RDWR ); if ( fp < 0 ) { perror( “/dev/nic” ); exit(1); } // setup packet-destination to be used when transmittting if ( ioctl( fp, 0, dstn ) < 0 ) { perror( “ioctl” ); exit(1); }

Driver’s ‘ioctl()’ function char mac[ 6 ];// packet source-address gets filled in by ‘module_init()’ char dstn[ 6 ];// packet destination-address gets filled in by our ‘ioctl()’ int my_ioctl( struct inode *, struct file*, unsigned int cmd, unsigned long address ) { unsigned char*from = (unsigned char *)address; switch ( cmd ) { case 0:// set the driver’s ethernet-packet destination-address if ( copy_from_user( dstn, from, 6 ) ) return –EFAULT; return 0; //SUCCESS default:break; } return –EINVAL; // requested command not implemented }

Change in ‘write()’ Our device-driver’s ‘write()’ method needs only a tiny change in order to make use of the user-supplied destination-address: ssize_t my_write( struct file *file, char *buf, size_t len, loff_t *pos ) { inttail = ioread32( io + E1000_TDT );// next tx-ring index char*packet = phys_to_virt( txdesc[ tail ].base_addr ); //memset( packet+0, 0xFF, 6 );// broadcast-address (NO!) memcpy( packet+0, dstn, 6 );// user-supplied MAC-address memcpy( packet+6, mac, 6 );// source MAC-address (ours!) /* other processing same as before */ }

Change in ‘init()’ To prevent reception of ethernet packets whose destination-address doesn’t match our device’s address, we need to alter the way we program our nic’s RCTL register: RCTL (0x0100) SECRC (Strip Ethernet CRC)BAM (Broadcast Accept Mode) MPE (Multicast Promiscuous Enable) UPE (Unicast Promiscuous Enable) SBP (Store Bad Packets) EN (Enable receive engine)

A change in memory-usage RxBuf 0 RxBuf 1 RxBuf 2 RxBuf 3 RxBuf 4 RxBuf 5 RxBuf 6 RxBuf 7 TxBuf RXDESCRXDESC TXDESCTXDESC 4 pages of kernel memory physaddrdescaddr Eight receive-buffers (0x600 bytes each) One ‘shared’ transmit-buffer (0x600 bytes) Eight receive-descriptors (0x80 bytes) Eight transmit-descriptors (0x80 bytes) When we “merged” the code from our two previous device-drivers, we needed to make sure that receive-buffers and transmit-buffers do not overlap, and likewise that the Rx and Tx descriptor-queues occupy distinct regions within the allocated kernel-memory region

Is 00:00:00:00:00:00 legal? If you comment out all the lines of code in our ‘sendto.cpp’ application that precede the ‘open()’ statement, then our driver’s ‘dstn[ 6 ]’ array will remain all zeros, and hence packets will be sent with a ‘zero’ destinatin-address (normally not legal) EXERCISE: Try this out and see if your test-message gets received any node

Receive-filter Array Filter-address 0 Filter-address 1 Filter-address 2 Filter-address 3 Filter-address 4 Filter-address 5 Filter-address 6 Filter-address 7 0x5400 0x5408 0x5410 0x5418 0x5420 0x5428 0x5430 0x5438 quadword (64-bits) ‘valid’-bit (1=yes, 0=no) The NIC’s own unique hardware-address gets programmed into this initial array-entry during initialization Other addresses may be added later by driver software …

In-class exercise Apply your knowledge of the Intel 82573L ‘Receive-filter Array’ to add the quadword 0x at offset 0x5408 in the NIC’s i/o-memory space Then test your modified ‘sendto.cpp’ code to see if you can ‘receive’ a packet which has ‘zero’ as its destination-address