new routing protocol

Bruce M Simpson bms at spc.org
Wed Aug 20 03:02:36 PDT 2003


On Tue, Aug 19, 2003 at 04:02:40PM -0700, Jerry Toung wrote:
> dear hackers,

Hello!

> I am in the process of implementing a routing protocol under 5.0.

I, too, am in the process of implementing a routing protocol under -CURRENT.
:^)

> This routing protocol is source route based and requires its own header after
> the ip header and before any other one such as udp,tcp.
> 	
> (ip)(new_rt_hdr)(udp)(paylaod)

This sounds an awful lot like how IPSEC chains its headers in using the
type field of the IP datagram.

> I am requesting your input as to the best way to approach this. I am thinking 
> that the quick way would be to open netinet/ip_input.c and for every packet 
> with ip->ip_p = NEW_RT_TYPE do my processing. I am not using routing tables, 

When I originally wrote my GRE driver for FreeBSD, I found yes, indeed, I had
to add the protocol to the protosw table. This is one approach.

> I have another mechanism for routing decisions. and for outgoing packets, 
> before sending to the appropriate interface, in netinet/ip_output.c insert 
> the new routing header then pass the packet to ifp->if_output.

How do you intend to communicate with the kernel routing code? Do you
plan on rewriting it or on injecting routes into the table which it can use?

> My problem is dealing with debuging and portability. With this raw approach I 
> guess I will have to run builkernel and installkernel all the time. How can I 

You don't strictly need to use those targets to rebuild when only a few
files have changed, providing the dependencies haven't significantly changed.
Use the config(8) tool directly and perform your kernel build in the compile
directory.

> avoid that? I thought about kernel modules, but I don't know what kind to use 
> (SYSCALL_MODULE or DEV_MODULE,etc..)

You could use a KLD. Look at the if_gre and if_gif drivers for some hints on
how to dynamically load IP protocol handlers. They use the encap API, which
may or may not suit your needs. You could just use the DECLARE_MODULE()
macro directly but you have to pick a suitable sysinit level. This tells the
kernel in what order initialization routines should be called, it is important
for modules which are loaded by the loader at boot time.

> and how about netgraph.? does that make sense?

Netgraph might offer you an easier way of doing this, but I lack experience
in this area; Julian Elischer and Archie Cobbs are knowledgeable in this area.

BMS


More information about the freebsd-hackers mailing list