From owner-freebsd-net Thu Apr 27 4:31:43 2000 Delivered-To: freebsd-net@freebsd.org Received: from mailtoaster2.pipeline.ch (mailtoaster2.pipeline.ch [62.48.0.71]) by hub.freebsd.org (Postfix) with ESMTP id EF10F37B5B3 for ; Thu, 27 Apr 2000 04:31:33 -0700 (PDT) (envelope-from oppermann@pipeline.ch) Received: (qmail 71370 invoked from network); 27 Apr 2000 11:32:25 -0000 Received: from unknown (HELO pipeline.ch) ([62.48.0.53]) (envelope-sender ) by mailtoaster2.pipeline.ch (qmail-ldap-1.03) with RC4-MD5 encrypted SMTP for ; 27 Apr 2000 11:32:25 -0000 Message-ID: <3908253F.98A0B55C@pipeline.ch> Date: Thu, 27 Apr 2000 13:32:15 +0200 From: Andre Oppermann X-Mailer: Mozilla 4.72 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Larry Lile Cc: freebsd-net@freebsd.org, Archie Cobbs Subject: Re: Proposal for ethernet, bridging, netgraph References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Larry Lile wrote: > > After reading along with this thread I thought I might point > out a way for us to further reduce redundant code in the > network stack. It would allow any driver token-ring, atm, > ethernet, ... to use ether_input directly without having > to either replicate the code or fake ethernet headers. > So after discussing this with Archie he thought I should > post it to -net. So here goes, please feel free to make > suggestions or comments. > > Currently ethernet drivers call ether_input(ifp, eh, m) and the > token-ring driver calls iso88025_input(ifp, th, m). The two functions > are orthoganal. The real difference is how you arrive at ether_type. > So ether_input & iso88025_input are basically a big switch that > moves the packet into the appropriate stack. > > What has been suggested is moving the bpf & bridging code into > ether_input. That is fine for ethernet drivers, but it does > little or nothing for non-ethernet drivers. The only real reason > that it can't be used for other devices is that it can't find the > ether_type for non-ethernet frames. The llc gunk should be moved > out of ether_input and into a seperate function that calls > ether_input when neccesary. If this is becoming a general input packet handling routine then please don't call it ether_input() anymore. Maybe packet_input() is suitable name. > People have been going round and round about where to store > the link-level (mac/dlc) header. Applications have generally made the > broken assumption that the mac header starts 14 bytes before the data. > This is true for ethernet but not everything :-( There is a > field in the mbufs just for this, m->m_pkthdr.header. This is > how I recover source-routing data for arp. All of the ethernet > drivers set it to NULL. If all the drivers set m->m_pkthdr.header > to point to the mac header then every layer would know where to > find it and there would be no need to pass "eh" into ether_input. > > If m->m_pkthdr.header is set correctly then all of the upper layers > automatically have access to the mac header, no matter what the > interface type is or where the header physically resides. This could > also be helpful for tcpdump, dhcp, arp, bridging... If we are discussing such deep changes we IMHO we should look at the big picture and take also a replacement of the current (ethernet specific) ARP code with NetBSD's into consideration: http://www.daemonnews.org/199809/underhood.html I certainly would volunteer to port it from NetBSD to FreeBSD but that would be my first coding dive into the network stack. > So what I was proposing is change ether_input(ifp, eh, m) to > ether_input(struct *ifnet, u_short ether_type, struct mbuf *m). > Anyone who needs to know how to interpret the mac header from > this point on/up should be able do it using ifp->if_type.if_data.ifi_type. > For instance ether_input only uses the mac header to keep track of > the number of multicast packets and broadcasts. Then you hit the > switch(ether_type) which goes into the upper layers. The llc code > should be split out (and down). > > It would look like this: > > Remove Remove llc > MAC header header. > +------+ +-----------+ Route packets > | oltr |--llc->| llc_input |\ based on ether_type > +------+\ +-----------+ | +-------------+ [bridge] > Remove \--non-llc---------+------>| ether_input | - ->[netgraph] > MAC header | +-------------+ [vlan] > +------+ | (ether_type) > | ed |--------------------/ / | | \ \ > +------+ / [arp][ip][ipv6][ipx][...] > | fddi |----------------/ (may need llc?) > +------+ / > | atm |------------/ (may need llc?) > +------+ > > By Removing the * header, I mean adjusting m_data, m_len, > m_pkthdr.len, ... Not actually destroying them. > > Of course this is assuming the neccesary changes for the bridge > code being moved in to ether_input. I don't see a need to add > link headers, length, ... in the call to ether_input that is > why ifi_type and m_pkthdr.* exist. > > Currently the network stack is way too ethernet-centric, but > then I guess there is a lot of ethernet in the world :-) > > I will save my comments about ether_output and the arp code > until later, but they should be modified in a similar fashion. See my comments. -- Andre AO6-RIPE/AO137 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message