summaryrefslogtreecommitdiff
path: root/sys/net/rtsock.c
AgeCommit message (Collapse)Author
2011-02-14free mbuf in failure case. fix for pr6562. ok claudio.Ted Unangst
2011-01-06dst my point to memory inside rt so move the check up before theClaudio Jeker
rtfree(rt). Without this the sp_protocol on RTM_DELETE is garbage and rtsocket user that restrict the AF of the socket (like ospfd) will not see a single one of the RTM_DELETE. OK henning@, dlg@
2011-01-06Minor style nitClaudio Jeker
2010-10-28Do not send route messages to userland processes that the kernelClaudio Jeker
rejects because of bad encoding. Userland processes trust that the messages on the rtsock are correctly encoded. Moved some checks up to do the suser() check as soon as possible. After discussion with deraadt@, OK deraadt@ and sthen@ (earlier version)
2010-10-11Implement an rtsocket filter for rtableids. A process will initiallyClaudio Jeker
only get messages that are for the rtable the process is bound to. Depending on the rtm_type the rdomain or rtable id are used for comparison. It is possible to change the filter with a setsockopt(s, AF_ROUTE, ROUTE_TABLEFILTER,...) and if set to RTABLE_ANY the filter is deactivated. Additionally set the tableid in struct if_msghdr to the rdomain id and use the process rtableid in the sysctl if no table was specified. OK henning@
2010-09-08Switch the MPLS blocks for RTM_CHANGE. Do not always remove the MPLSClaudio Jeker
information if the gateway changes, since real MPLS routes need to change gateway and outgoing label on topology changes. So if there is MPLS information and an outgoing label do a proper change but if the gateway of a non-MPLS route is changed remove the MPLS path since it is no longer valid. OK michele@
2010-09-02don't attempt to enqueue routing messages on sockets marked SS_CANTRCVMOREBret Lambert
ok claudio@
2010-08-25Let rtable_add() return usefull errnos so that the ioctl handler and theClaudio Jeker
rtsock code can return a more reasonable error to the user. OK henning
2010-08-24last is a pointer so initialize to NULL and not 0. Also move initializationClaudio Jeker
up to the declaration.
2010-07-14The append side of a socketbuffer is not allowed to call sbflush().Claudio Jeker
Learned the hard way. dlg@ confirmed that it is save to just remove them, the desync will still work but the reader needs to dequeue all packets first.
2010-07-14if we produce a lot of rtsock messages it is possible we will hit aDavid Gwynne
condition that prevents us from queuing it, which in turn means that processes listening on the routing socket for changes to the kernel state will get out of sync. currently this is handled by the following comment: /* should notify about lost packet */ this change introduces a new rtsock message called RTM_DESYNC that notifies about lost packets and uses it instead of this comment. when we detect loss we flush all the message in the routing socket and attempt to queue an RTM_DESYNC message instead. to guarantee that we will enqueue DESYNC we keep trying it when an attempt to enqueue or dequeue any messages is made, and in the worst case a timeout tries to guarantee that desync is added to the socket. ive been running this in production for 2 or 3 weeks. tested by sthen@ ok sthen@ claudio@ deraadt@ code written by andrew sallaway at the univeristy of queensland.
2010-07-09When protocol filtering is used on the rtsocket filter only messages thatClaudio Jeker
actually have a protocol/address family set. Messages like RTM_IFINFO or RTM_IFANNOUNCE are family independent and should not be filtered but it is possible to use a ROUTE_MSGFILTER to filter these messages. This allows to reduce the messages sent to AF_INET or AF_INET6 only daemons. OK henning@, deraadt@
2010-07-02m_copyback can fail to allocate memory, but is a void fucntion so gymnasticsBret Lambert
are required to detect that. Change the function to take a wait argument (used in nfs server, but M_NOWAIT everywhere else for now) and to return an error ok claudio@ henning@ krw@
2010-06-28Add the rtable id as an argument to rn_walktree(). Functions likeClaudio Jeker
rt_if_remove_rtdelete() need to know the table id to be able to correctly remove nodes. Problem found by Andrea Parazzini and analyzed by Martin Pelikán. OK henning@
2010-05-19Require RTF_MPLS to be set when a mpls route is added or changed. To removeClaudio Jeker
only the MPLS bits from a route set rtm_fmask to RTF_MPLS. Additionally check if the nexthop is modified and in that case always remove the MPLS info since the path changed. This change makes life in userland a lot easier since the routing daemons normaly don't know about MPLS and until now they destroyed MPLS information when issuing RTM_CHANGEs. OK michele@
2010-04-21Implement a way to get information about a rtable. Currently only the rtableidClaudio Jeker
and rdomainid are returned. This is necessary to know where L2 information of a table is stored (which will be needed soon by bgpd). Also while there change the errno for non-existing routing tables to ENOENT. 'Fine' deraadt@
2010-03-23Set rtm_mpls on RTM_GET so that we get the correct options on mpls routes.Claudio Jeker
OK michele@
2010-02-09Set the rtm_priority when sending RTM_ADD/RTM_DELETE messages out inClaudio Jeker
rt_newaddrmsg(). Makes the routing daemons a bit less confused when interfaces are reconfigured.
2010-02-09Correctly track RTF_UP on RTM_CHANGE. Since the interface can changeClaudio Jeker
rt_if_linkstate_change() needs to be rerun for this route and the resulting rt_flags need to copied to the rtm_flags for userland. Problem found and diagnosed by Doran Mori. OK henning@, jsing@
2009-11-03rtables are stacked on rdomains (it is possible to have multiple routingClaudio Jeker
tables on top of a rdomain) but until now our code was a crazy mix so that it was impossible to correctly use rtables in that case. Additionally pf(4) only knows about rtables and not about rdomains. This is especially bad when tracking (possibly conflicting) states in various domains. This diff fixes all or most of these issues. It adds a lookup function to get the rdomain id based on a rtable id. Makes pf understand rdomains and allows pf to move packets between rdomains (it is similar to NAT). Because pf states now track the rdomain id as well it is necessary to modify the pfsync wire format. So old and new systems will not sync up. A lot of help by dlg@, tested by sthen@, jsg@ and probably more OK dlg@, mpf@, deraadt@
2009-09-17Remove the comaptibility structures for routing socket version 3.Claudio Jeker
The RTM_VERSION bump is 2 years ago and so there is no need for this. Diff made by tedu@ some time ago but got never commited so I do it now.
2009-07-07When adding or changing a MPLS route, add RTF_MPLS flag toMichele Marchetto
routing message. We can then rely on that flag to spot out MPLS routes coming from routing socket. ok claudio@
2009-06-26the pr_usrreq implementation for routing sockets shares exactly one lineBret Lambert
of code between cases, so stop pretending otherwise, and move the if() dance to a switch, as is done in every other pr_usrreq I'm aware of. ok claudio@ michele@
2009-06-22Remove unneeded sotorawpcb() call, as the PCB is unmolested betweenBret Lambert
malloc()ing it and calling that macro. No functional change, just tightening things up a bit. ok claudio@ michele@
2009-06-20Decrement routing socket count in MPLS detach caseBret Lambert
While here, fix whitespace (spaces -> tabs) issue spotted by michele@ ok michele@, claudio@
2009-06-06when xflags got changed, tell the userland by routing socketsRainer Giedat
ok henning@
2009-06-05Initial support for routing domains. This allows to bind interfaces toClaudio Jeker
alternate routing table and separate them from other interfaces in distinct routing tables. The same network can now be used in any doamin at the same time without causing conflicts. This diff is mostly mechanical and adds the necessary rdomain checks accross net and netinet. L2 and IPv4 are mostly covered still missing pf and IPv6. input and tested by jsg@, phessler@ and reyk@. "put it in" deraadt@
2009-05-31Hide RTP_DOWN in the kernel and don't expose it to userland. Userland isClaudio Jeker
not smart enough to handle it in a sensible way. Make sure the kernel selected routing priority is actually exported to userland or to help daemons like bgpd to keep correctly track of the routes. This should fix some of the rather strange errors seen by people having multipath routes on their bgpd boxes. While there make the interface priority inheritance on static routes work again. OK henning@
2009-05-31Fix for the rtfree 2 panic seen by some people before the release. A missingClaudio Jeker
refcnt bump caused the panic to be triggered. While there also make the priority so that the compare is working a bit better. henning@ cries in agony (I already gave up)
2009-04-18Make "route(8) change" aware of MPLS.Michele Marchetto
It is now possible to change routes' MPLS parameters via route change. ok laurent@, ok and input claudio@
2009-02-03Use our own flags to set the operations and not RTF_PROTOX.Michele Marchetto
Switch the padding field into a MPLS one in rt_msghdr to store relevant informations. OK claudio@ laurent@
2009-01-28Get rid of the ugly rtentry hack.Michele Marchetto
We can now act as edge node and allow ipv4 packets to enter a Label Switched Path and not just forwarding MPLS packets. OK claudio@
2009-01-28Implement basic routing socket filtering. It is possible to give a list --Claudio Jeker
actually a bitfield -- of routing messages a listener is interested in. This list can be changed with a setsockopt(s, AF_ROUTE, ROUTE_MSGFILTER, ...) call. OK henning@, dlg@
2009-01-08Fix sockaddr_mpls structure.Michele Marchetto
Now it contains just the label as it must be. This introduces a ugly hack in rtentry that will be removed as soon as possible. OK claudio@
2009-01-03Write back the priority the kernel used. Fixes a problem seen in ospfd whenClaudio Jeker
routes are added via route(8) -- those where added with the wrong priority and so where not correctly tracked later on. Found and tested by gollo@
2008-12-12Make sure that incomming routing messages don't have RTP_DOWN set. MaskClaudio Jeker
the rtm_priority with RTP_MASK so that userland (e.g. arp) can issue a RTM_GET and reissue the message as RTM_DELETE.
2008-11-22Allow rt_msg1() to get a NULL as struct rt_addrinfo this simplifies a fewClaudio Jeker
callers (plus an upcomming one). OK henning@, dlg@
2008-11-21Change rn_mpath_next() to be able to walk over the full multipath listClaudio Jeker
not only over routes of the same prio. This makes it possible to modify rt_mpath_matchgate() so that if only gateway is specified without a specific priority it will scan the full list and not only the first routes. This is also needed for upcoming link state tracking.
2008-08-07Remove workaround used for the 4.4 release. More route prio stuff is commingClaudio Jeker
soon.
2008-08-01force route priority to RTP_DEFAULT unconditionally, effectively disablingHenning Brauer
route prios. playing safe for 4.4-release, as not all parts of the system deal correctly with route prios yet. ok claudio
2008-07-28Align the route message length to the next natural boundary via ALIGN() toClaudio Jeker
ensure that the next message is nicely aligned as well. Some archs (sparc, m88k)have strict alignement issues since the inclusion of 64bit counters in the messages because those values could end up on non aligned addresses. Found and fix tested by miod@, OK deraadt@
2008-06-13Change the logic when selecting routes on RTM_CHANGE & RTM_GET. RTM_CHANGEClaudio Jeker
can not supply the correct nexthop if the nexthop is changed. So if the route we want to change is a non-multipath one allow the change to succeed. This unbreaks RTM_CHANGE in most situations. Found by jsing@ Ok henning@
2008-06-13Cleanup a bit. Instead of doing dst = 0 in every error handling block initClaudio Jeker
it once at start instead.
2008-05-23Deal with the situation when TCP nfs mounts timeout and processesThordur I. Bjornsson
get hung in nfs_reconnect() because they do not have the proper privilages to bind to a socket, by adding a struct proc * argument to sobind() (and the *_usrreq() routines, and finally in{6}_pcbbind) and do the sobind() with proc0 in nfs_connect. OK markus@, blambert@. "go ahead" deraadt@. Fixes an issue reported by bernd@ (Tested by bernd@). Fixes PR5135 too.
2008-05-07Implement routing priorities. Every route inserted has a priority assignedClaudio Jeker
and the one route with the lowest number wins. This will be used by the routing daemons to resolve the synchronisations issue in case of conflicts. The nasty bits of this are in the multipath code. If no priority is specified the kernel will choose an appropriate priority. Looked at by a few people at n2k8 code is much older
2008-04-23Import MPLS (Multi Protocol Label Switching)Esben Norby
MPLS support partly based on the (abandoned?) AYAME project. Basic LSR (Label Switch Router) functionality is present, but not fully functional yet. It is currently possible to insert entries in the LIB (Label Information Base) with route(8), but setting the operation type is not supported yet. Imported to allow more people to work on this in the coming weeks. ok claudio@ laurent@ dlg@
2007-09-15malloc sweep:Henning Brauer
-remove useless casts -MALLOC/FREE -> malloc/free -use M_ZERO where appropriate instead of seperate bzero feedback & ok krw, hshoexer
2007-09-09Only clear the message header if it is called from a sysctl walk. ThisClaudio Jeker
unbreaks RTM_GET. Problem reported by fkr@
2007-09-08Clear the message header (and only the message header) in rt_msg2.Claudio Jeker
By doing so we ensure that all the memory is initialised and we no longer have to ensure that none of the structure elements is forgotten in sysctl_iflist() and sysctl_dumpentry(). This solves the route flush issues seen by aanriot@ OK henning@
2007-09-07Check if rtm_hdrlen is smaller then the passed message or it would be possibleClaudio Jeker
to access uninitialised memory. Set dst to 0 on error, the error path tries to access dst but dst is inited later down the code. This fixes a kernel panic seen by aanriot@ OK henning@