From owner-freebsd-questions Wed Aug 20 03:57:00 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id DAA14688 for questions-outgoing; Wed, 20 Aug 1997 03:57:00 -0700 (PDT) Received: from ot.stpn.soft.net (freebie.opentech.stpn.soft.net [204.143.126.74]) by hub.freebsd.org (8.8.5/8.8.5) with SMTP id DAA14681 for ; Wed, 20 Aug 1997 03:56:49 -0700 (PDT) Received: from andes (andes.opentech.stpn.soft.net [204.143.126.66]) by ot.stpn.soft.net (8.6.12/8.6.12) with ESMTP id QAA19449; Wed, 20 Aug 1997 16:25:26 +0530 Message-ID: <33FB5F8E.DBAE6CFB@opentech.stpn.soft.net> Date: Wed, 20 Aug 1997 16:20:15 -0500 From: Prashant Dongre Reply-To: pdongre@opentech.stpn.soft.net Organization: Open Technologies X-Mailer: Mozilla 4.01 [en] (WinNT; I) MIME-Version: 1.0 To: ETX-B-SL Martti Kuparinen CC: freebsd-questions@FreeBSD.ORG Subject: Re: poll() for ethernet devices X-Priority: 3 (Normal) References: <199708200928.LAA12825@kk662.kk.etx.ericsson.se> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk ETX-B-SL Martti Kuparinen wrote: > Ok, seems like my description was not clear enough... I try to make > a better story now :-) > > > > I am running FreeBSD 2.2.2 on a PPro 200 MHz PC. I have created a > > > loadable kernel module which will schedule IP-packets on user-defineable > > > interfaces and priorities. > > So I have a router which is able to prioritize outgoing packets > based on {address, port, protocol}-decision. To achieve this I have > two different tables in memory: > > addresstable: { address, port, protocol, priority } > interfacetable: list of interfaces which are scheduled > > So the user is able to type e.g. > > schconfig attach fxp0 fxp1 fxp2 fxp3 > schconfig add 192.168.100.200 icmp high > schconfig add \* \* \* low > > (schconfig is a user-space control program like ifconfig to > modify the scheduler at run-time) > > This means that icmp packets (e.g. ping) to 192.168.100.200 have the > high priority whereas all other packets are low priority traffic. These > actions take effect on fxp[0-3] interfaces. > > I have modified ether_output() to put the packet in to the correct > position inside the if_snd queue. The position is calculated from > { address, port, protocol, priority }-information. > > In order to do the prioritity queueing one must always read packets > from interfaces before writing them out. So inside ether_output() > I want to force the kernel to execute ether_input(). > > My version work great (checking the priority and the position > in the queue for every packet) expect that it is always writing > someting out from ether_output. As a "minor" side effect packets > are not prioritized :-('So I need to check if there is more packets > to read from any of the attached interfaces. Of course I have a "timeout" > mechanism to prevent the system from not writing anything out... > > Any ideas how to check for new incoming packets on all interfaces in > the system? > > /Martti Hi, Have you checked code in 'if_ethersubr.c' in directory '/usr/src/sys/net' ????. Check ether_input() function. Here you can directly read ethernet packets from all the interfaces attached. But here you need to check for wheather the packet is IP, ARP (from ether_header) stc. etc. and you may also incorporate routing mechanism, as you need to schedule incoming packet to the right interface queue. I think, the trick is, hijacking the packet off the ether interface before it reaches IP level. Let me know if this is what you were looking for. Good luck !! Prashant.