summaryrefslogtreecommitdiffstats
path: root/sys/net/rtsock.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Use p_p->ps_pid as pid in the route header instead of the thread pid. Giveclaudio2012-03-281-2/+2
| | | | | userland a chance to compare the value against getpid(). This unbreaks transmission for me. OK deraadt@, guenther@
* Do not use NULL in integer comparisons. No functional change.miod2011-04-071-2/+2
| | | | ok matthew@ tedu@, also eyeballed by at least krw@ oga@ kettenis@ jsg@
* m_copyback is no longer a void function, so start using its error returnblambert2011-04-041-8/+6
| | | | | | instead of coming at it sideways to detect failure. ok claudio@
* Always reserve space in the routing socket for a desync mbuf. This allowsjsing2011-04-031-3/+5
| | | | | | | a desync to be appended when the socket buffer becomes full, rather than continuall retrying until space becomes available (which may be never). ok claudio@
* - use nitems(); no binary changejasper2011-03-311-2/+2
| | | | ok claudio@
* free mbuf in failure case. fix for pr6562. ok claudio.tedu2011-02-141-1/+3
|
* dst my point to memory inside rt so move the check up before theclaudio2011-01-061-3/+3
| | | | | | | 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@
* Minor style nitclaudio2011-01-061-3/+2
|
* Do not send route messages to userland processes that the kernelclaudio2010-10-281-20/+34
| | | | | | | 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)
* Implement an rtsocket filter for rtableids. A process will initiallyclaudio2010-10-111-6/+52
| | | | | | | | | | | | 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@
* Switch the MPLS blocks for RTM_CHANGE. Do not always remove the MPLSclaudio2010-09-081-11/+11
| | | | | | | | | 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@
* don't attempt to enqueue routing messages on sockets marked SS_CANTRCVMOREblambert2010-09-021-1/+3
| | | | ok claudio@
* Let rtable_add() return usefull errnos so that the ioctl handler and theclaudio2010-08-251-4/+2
| | | | | rtsock code can return a more reasonable error to the user. OK henning
* last is a pointer so initialize to NULL and not 0. Also move initializationclaudio2010-08-241-3/+2
| | | | up to the declaration.
* The append side of a socketbuffer is not allowed to call sbflush().claudio2010-07-141-3/+1
| | | | | 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.
* if we produce a lot of rtsock messages it is possible we will hit adlg2010-07-141-7/+89
| | | | | | | | | | | | | | | | | | | | | | 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.
* When protocol filtering is used on the rtsocket filter only messages thatclaudio2010-07-091-1/+2
| | | | | | | | 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@
* m_copyback can fail to allocate memory, but is a void fucntion so gymnasticsblambert2010-07-021-3/+3
| | | | | | | | | 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@
* Add the rtable id as an argument to rn_walktree(). Functions likeclaudio2010-06-281-3/+4
| | | | | | | 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@
* Require RTF_MPLS to be set when a mpls route is added or changed. To removeclaudio2010-05-191-42/+45
| | | | | | | | | 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@
* Implement a way to get information about a rtable. Currently only the rtableidclaudio2010-04-211-2/+15
| | | | | | | 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@
* Set rtm_mpls on RTM_GET so that we get the correct options on mpls routes.claudio2010-03-231-1/+2
| | | | OK michele@
* Set the rtm_priority when sending RTM_ADD/RTM_DELETE messages out inclaudio2010-02-091-1/+2
| | | | | rt_newaddrmsg(). Makes the routing daemons a bit less confused when interfaces are reconfigured.
* Correctly track RTF_UP on RTM_CHANGE. Since the interface can changeclaudio2010-02-091-1/+7
| | | | | | 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@
* rtables are stacked on rdomains (it is possible to have multiple routingclaudio2009-11-031-8/+7
| | | | | | | | | | | | | | 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@
* Remove the comaptibility structures for routing socket version 3.claudio2009-09-171-143/+5
| | | | | 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.
* When adding or changing a MPLS route, add RTF_MPLS flag tomichele2009-07-071-2/+7
| | | | | | | routing message. We can then rely on that flag to spot out MPLS routes coming from routing socket. ok claudio@
* the pr_usrreq implementation for routing sockets shares exactly one lineblambert2009-06-261-33/+38
| | | | | | | 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@
* Remove unneeded sotorawpcb() call, as the PCB is unmolested betweenblambert2009-06-221-2/+1
| | | | | | | | malloc()ing it and calling that macro. No functional change, just tightening things up a bit. ok claudio@ michele@
* Decrement routing socket count in MPLS detach caseblambert2009-06-201-3/+7
| | | | | | While here, fix whitespace (spaces -> tabs) issue spotted by michele@ ok michele@, claudio@
* when xflags got changed, tell the userland by routing socketsrainer2009-06-061-1/+2
| | | | ok henning@
* Initial support for routing domains. This allows to bind interfaces toclaudio2009-06-051-6/+11
| | | | | | | | | 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@
* Hide RTP_DOWN in the kernel and don't expose it to userland. Userland isclaudio2009-05-311-7/+8
| | | | | | | | | | 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@
* Fix for the rtfree 2 panic seen by some people before the release. A missingclaudio2009-05-311-2/+4
| | | | | | 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)
* Make "route(8) change" aware of MPLS.michele2009-04-181-2/+40
| | | | | | It is now possible to change routes' MPLS parameters via route change. ok laurent@, ok and input claudio@
* Use our own flags to set the operations and not RTF_PROTOX.michele2009-02-031-13/+11
| | | | | | | Switch the padding field into a MPLS one in rt_msghdr to store relevant informations. OK claudio@ laurent@
* Get rid of the ugly rtentry hack.michele2009-01-281-13/+20
| | | | | | | | 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@
* Implement basic routing socket filtering. It is possible to give a list --claudio2009-01-281-8/+147
| | | | | | 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@
* Fix sockaddr_mpls structure.michele2009-01-081-2/+34
| | | | | | | | | 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@
* Write back the priority the kernel used. Fixes a problem seen in ospfd whenclaudio2009-01-031-2/+5
| | | | | | 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@
* Make sure that incomming routing messages don't have RTP_DOWN set. Maskclaudio2008-12-121-1/+4
| | | | | the rtm_priority with RTP_MASK so that userland (e.g. arp) can issue a RTM_GET and reissue the message as RTM_DELETE.
* Allow rt_msg1() to get a NULL as struct rt_addrinfo this simplifies a fewclaudio2008-11-221-8/+4
| | | | callers (plus an upcomming one). OK henning@, dlg@
* Change rn_mpath_next() to be able to walk over the full multipath listclaudio2008-11-211-2/+2
| | | | | | | 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.
* Remove workaround used for the 4.4 release. More route prio stuff is commingclaudio2008-08-071-4/+1
| | | | soon.
* force route priority to RTP_DEFAULT unconditionally, effectively disablinghenning2008-08-011-1/+4
| | | | | route prios. playing safe for 4.4-release, as not all parts of the system deal correctly with route prios yet. ok claudio
* Align the route message length to the next natural boundary via ALIGN() toclaudio2008-07-281-1/+3
| | | | | | 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@
* Change the logic when selecting routes on RTM_CHANGE & RTM_GET. RTM_CHANGEclaudio2008-06-131-7/+31
| | | | | | 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@
* Cleanup a bit. Instead of doing dst = 0 in every error handling block initclaudio2008-06-131-11/+2
| | | | it once at start instead.
* Deal with the situation when TCP nfs mounts timeout and processesthib2008-05-231-3/+3
| | | | | | | | | | | | | 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.
* Implement routing priorities. Every route inserted has a priority assignedclaudio2008-05-071-5/+26
| | | | | | | | | 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