aboutsummaryrefslogtreecommitdiff
path: root/sbin/route
Commit message (Collapse)AuthorAgeFilesLines
* route: remove write-only struct hostent from getaddr()Ed Maste2022-01-061-21/+12
| | | | | | | | | | | | Under some INET/INET6 src.conf configurations sbin/route previously failed to build due to an unused variable warning. It was functionally write-only anyway, so just remove it. Reported by: melifaro Reviewed by: melifaro MFC after: 3 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33717
* route: use NULL for null ptr in getaddr call, not 0Ed Maste2022-01-011-7/+7
| | | | | | Style(9) prefers NULL. Sponsored by: The FreeBSD Foundation
* route(8): Remove obsolete informationWarner Losh2021-12-151-18/+1
| | | | | | | | xns and osi are no longer relevant (or supported) so remove their vestiges. Noticed by: phk Sponsored by: Netflix
* socket: Implement SO_RERRORRoy Marples2021-07-281-1/+12
| | | | | | | | | | | | | | | | | | SO_RERROR indicates that receive buffer overflows should be handled as errors. Historically receive buffer overflows have been ignored and programs could not tell if they missed messages or messages had been truncated because of overflows. Since programs historically do not expect to get receive overflow errors, this behavior is not the default. This is really really important for programs that use route(4) to keep in sync with the system. If we loose a message then we need to reload the full system state, otherwise the behaviour from that point is undefined and can lead to chasing bogus bug reports. Reviewed by: philip (network), kbowling (transport), gbe (manpages) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D26652
* route(8): Add an example how to print the routing tablesGordon Bergling2021-04-131-1/+6
| | | | | | | | | | | The manual page currently doesn't show an example how to print the routing table, so add one and .Xr netstat while here. PR: 231579 Reported by: Pekka Järvinen <pekka dot jarvinen at gmail dot com> Reviewed by: debdrup MFC after: 5 days Differential Revision: https://reviews.freebsd.org/D29702
* Revert "SO_RERROR indicates that receive buffer overflows should be handled ↵Alexander V. Chernikov2021-02-081-12/+1
| | | | | | | | as errors." Wrong version of the change was pushed inadvertenly. This reverts commit 4a01b854ca5c2e5124958363b3326708b913af71.
* SO_RERROR indicates that receive buffer overflows should be handled as errors.Alexander V. Chernikov2021-02-081-1/+12
| | | | | | | | | | | | Historically receive buffer overflows have been ignored and programs could not tell if they missed messages or messages had been truncated because of overflows. Since programs historically do not expect to get receive overflow errors, this behavior is not the default. This is really really important for programs that use route(4) to keep in sync with the system. If we loose a message then we need to reload the full system state, otherwise the behaviour from that point is undefined and can lead to chasing bogus bug reports.
* Remove remnants of classful behavior in route(8).Alexander V. Chernikov2021-01-161-55/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Curently route(8) treats some addresses as network addresses: RTA_DST: inet 10.0.0.0; RTA_NETMASK: inet 255.0.0.0; RTA_IFP: link ; RTM_GET: Report Metrics: len 240, pid: 0, seq 1, errno 0, flags:<UP,GATEWAY,STATIC> locks: inits: sockaddrs: <DST,NETMASK,IFP> 10.0.0.0 255.0.0.0 link#0 Note added `RTA_NETMASK` in the request. Host address from the same network is ok: route -nv get 10.0.0.1 RTA_DST: inet 10.0.0.1 RTA_IFP: link RTM_GET: Report Metrics: len 224, pid: 0, seq 1, errno 0, flags:<UP,GATEWAY,HOST,STATIC> ... route to: 10.0.0.1 destination: 10.0.0.0 mask: 255.255.255.0 This change eliminates network auto-guessing part AND reading network from /etc/networks. Reviewed By: rgrimes Differential Revision: https://reviews.freebsd.org/D24401
* Skip sbin/route tests if jail not installed (WITHOUT_JAIL).Olivier Cochard2020-08-041-2/+2
| | | | | | | | | Approved by: kp Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D25935 Notes: svn path=/head/; revision=363868
* Add tests for "add", "change" and "delete" functionality of /sbin/route.Tom Jones2020-07-224-0/+186
| | | | | | | | | | | | | | | | Add tests to cover "add", "change" and "delete" functionality of /sbin/route for ipv4 and ipv6. These tests for the existing route tool are the first step towards creating libroute. Submitted by: Ahsan Barkati Sponsored by: Google, Inc. (GSoC 2020) Reviewed by: kp, thj Approved by: bz (mentor) MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D25220 Notes: svn path=/head/; revision=363417
* route(8): clarify -prefixlen descriptionEnji Cooper2019-01-101-7/+7
| | | | | | | | | | | | | | | | | Try to reword -prefixlen section to more clearly and accurately describe how the -prefixlen modifier works. While here, fix a word that igor considered a typo: aggregatable addresses is a valid technical term per RFC-2374, however, it was superseded by the term "aggregator" in RFC-3587. MFC after: 1 week Reviewed by: 0mp, crees Approved by: emaste (mentor) Differential Revision: https://reviews.freebsd.org/D10087 Notes: svn path=/head/; revision=342904
* route(8): correctly return exit status when "-q" flag is used.Eugene Grosbein2018-10-271-4/+6
| | | | | | | | | | | Previously, route returned 1 in case of error properly signalling failure but "route -q" it returned 0 for same case. Fix it. PR: 186333 MFC after: 1 month Notes: svn path=/head/; revision=339811
* Fix memory leaks in route(8).Alexander V. Chernikov2018-03-311-0/+2
| | | | | | | | | Submitted by: Tom Rix (trix_juniper.net) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D9676 Notes: svn path=/head/; revision=331844
* route(8): make it possible to manually delete pinned routeEugene Grosbein2018-02-241-1/+3
| | | | | | | | | Reported by: Andreas Longwitz <longwitz@incore.de> Approved by: avg (mentor) MFC after: 1 week Notes: svn path=/head/; revision=329930
* Fix route manpage to show correct flush syntaxRyan Stone2018-02-211-1/+2
| | | | | | | | | | | | | | The current route(8) manpage shows that "flush" is an argument to the optional -n flag, rather than a separate subcommand. Correct this to properly show flush as a route subcommand. MFC after: 2 weeks Sponsored by: Dell EMC Isilon Reviewed by: rgrimes Differential Revision: https://reviews.freebsd.org/D14401 Notes: svn path=/head/; revision=329744
* Allow route change requests to not specify the gateway.Ryan Stone2018-02-211-3/+15
| | | | | | | | | | | | | | | | | | | Only require a gateway to be specified on a route add request. On a route change request that does not specify the gateway, the gateway will remain the same. This allows changing other route parameters without having to re-specifying the gateway, like in "route change 10.0.0.0/8 -mtu 9000". Update the route(8) manpage to explicitly call out this usage as being supported. MFC after: 2 weeks Sponsored by: Dell EMC Isilon Reviewed By: eugen (rtsock.c change), rgrimes Differential Revision: https://reviews.freebsd.org/D14291 Notes: svn path=/head/; revision=329743
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-1/+3
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* Typo, the '-6' option selects inet6.Konstantin Belousov2017-08-151-1/+1
| | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 3 days Notes: svn path=/head/; revision=322550
* Fix userland tools that don't check the format of routing socketPatrick Kelsey2017-04-161-9/+10
| | | | | | | | | | | | | | | | | | | messages before accessing message fields that may not be present, removing dead/duplicate/misleading code along the way. Document the message format for each routing socket message in route.h. Fix a bug in usr.bin/netstat introduced in r287351 that resulted in pointer computation with essentially random 16-bit offsets and dereferencing of the results. Reviewed by: ae MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D10330 Notes: svn path=/head/; revision=317035
* Delete trailing whitespace (no functional change)Enji Cooper2017-03-211-4/+4
| | | | | | | | MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315690
* Renumber copyright clause 4Warner Losh2017-02-282-2/+2
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* Due to dropped mbuf in netisr queue route(8) can fall into infinityAndrey V. Elsukov2016-07-271-1/+27
| | | | | | | | | | | | | | loop of reading the rtsock's feed. When it used by some scripts, this leads to growing number of not finished route(8) instances and thus growing number of rtsock consumers. Add SIGALRM handler to prevent this. Reviewed by: melifaro Obtained from: Yandex LLC MFC after: 2 weeks Sponsored by: Yandex LLC Notes: svn path=/head/; revision=303374
* MFHGlen Barber2016-03-021-2/+0
|\ | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=296318
| * DIRDEPS_BUILD: Regenerate without local dependencies.Bryan Drewery2016-02-241-2/+0
| | | | | | | | | | | | | | | | | | | | | | These are no longer needed after the recent 'beforebuild: depend' changes and hooking DIRDEPS_BUILD into a subset of FAST_DEPEND which supports skipping 'make depend'. Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=295989
* | Explicitly add more files to the 'runtime' package.Glen Barber2016-02-091-0/+1
|/ | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=295450
* Fix /sbin/route to never look up (invalid) interface names through DNSRyan Stone2015-09-171-0/+3
| | | | | | | | | | | | | | | | /sbin/route has a bug where if it is passed an interface name that does not exist, it falls through and winds up interpreting it as a hostname. It fails out eventually, but on a system where DNS lookup is broken you can end up waiting for up to 60 seconds waiting for the DNS lookup to timeout. I'm not quite sure what happens if the DNS lookup somehow succeeds but I doubt that can end well. Reviewed by: markj, cem MFC after: 2 weeks Sponsored by: EMC/Isilon Storage Division Notes: svn path=/head/; revision=287920
* Add META_MODE support.Simon J. Gerraty2015-06-131-0/+21
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Off by default, build behaves normally. WITH_META_MODE we get auto objdir creation, the ability to start build from anywhere in the tree. Still need to add real targets under targets/ to build packages. Differential Revision: D2796 Reviewed by: brooks imp Notes: svn path=/head/; revision=284345
| * dirdeps.mk now sets DEP_RELDIRSimon J. Gerraty2015-06-081-2/+0
| | | | | | | | Notes: svn path=/projects/bmake/; revision=284172
| * Merge sync of headSimon J. Gerraty2015-05-271-9/+1
| |\ | |/ |/| | | Notes: svn path=/projects/bmake/; revision=283595
| * Merge from head@274682Simon J. Gerraty2014-11-193-9/+14
| |\ | | | | | | | | | Notes: svn path=/projects/bmake/; revision=274683
| * | Updated dependenciesSimon J. Gerraty2014-05-161-1/+0
| | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=266219
| * | Updated dependenciesSimon J. Gerraty2014-05-101-0/+2
| | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265802
| * | Merge from headSimon J. Gerraty2014-05-082-3/+1
| |\ \ | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265720
| * \ \ Merge headSimon J. Gerraty2014-04-283-136/+154
| |\ \ \ | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265044
| * \ \ \ Merge head@256284Simon J. Gerraty2013-10-131-0/+5
| |\ \ \ \ | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=256424
| * \ \ \ \ Merge from headSimon J. Gerraty2013-09-052-405/+398
| |\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=255263
| * | | | | | Updated dependenciesSimon J. Gerraty2013-03-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=248169
| * | | | | | Updated dependenciesSimon J. Gerraty2013-02-161-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=246868
| * | | | | | Sync with HEAD.David E. O'Brien2013-02-083-203/+486
| |\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=246555
| * | | | | | | Sync FreeBSD's bmake branch with Juniper's internal bmake branch.Marcel Moolenaar2012-08-221-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Requested by: Simon Gerraty <sjg@juniper.net> Notes: svn path=/projects/bmake/; revision=239572
* | | | | | | | Eliminate incorrect IPv6 mask guessing:Alexander V. Chernikov2015-01-161-9/+1
| |_|_|_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RFC 2374 concept of 'IPv6 Aggregatable Global Unicast Address Format' was deprecated by RFC 3587 12 years ago. Before: 15:06 [1] edge# netstat -rn6 | grep 2a02:6b8:: 2a02:6b8::/32 2a02:978:2::1 UGS em0 15:06 [1] edge# route -6n get 2a02:6b8:: route: writing to routing socket: No such process After: 15:07 [1] edge# /usr/obj/usr/src/sbin/route/route -n6 get 2a02:6b8:: route to: 2a02:6b8:: destination: 2a02:6b8:: mask: ffff:ffff:: gateway: 2a02:978:2::1 fib: 0 interface: em0 flags: <UP,GATEWAY,DONE,STATIC> recvpipe sendpipe ssthresh rtt,msec mtu weight expire 0 0 0 0 1500 1 0 MFC after: 2 weeks Notes: svn path=/head/; revision=277241
* | | | | | | Finish r274175: do control plane MTU tracking.Alexander V. Chernikov2014-11-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update route MTU in case of ifnet MTU change. Add new RTF_FIXEDMTU to track explicitly specified MTU. Old behavior: ifconfig em0 mtu 1500->9000 -> all routes traversing em0 do not change MTU. User has to manually update all routes. ifconfig em0 mtu 9000->1500 -> all routes traversing em0 do not change MTU. However, if ip[6]_output finds route with rt_mtu > interface mtu, rt_mtu gets updated. New behavior: ifconfig em0 mtu 1500->9000 -> all interface routes in all fibs gets updated with new MTU unless RTF_FIXEDMTU flag set on them. ifconfig em0 mtu 9000->1500 -> all routes in all fibs gets updated with new MTU unless RTF_FIXEDMTU flag set on them AND rt_mtu is less than ifp mtu. route add ... -mtu XXX automatically sets RTF_FIXEDMTU flag. route change .. -mtu 0 automatically removes RTF_FIXEDMTU flag. PR: 194238 MFC after: 1 month CR: D1125 Notes: svn path=/head/; revision=274611
* | | | | | | Kill custom in_matroute() radix mathing function removing one rte mutex lock.Alexander V. Chernikov2014-11-113-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Initially in_matrote() in_clsroute() in their current state was introduced by r4105 20 years ago. Instead of deleting inactive routes immediately, we kept them in route table, setting RTPRF_OURS flag and some expire time. After that, either GC came or RTPRF_OURS got removed on first-packet. It was a good solution in that days (and probably another decade after that) to keep TCP metrics. However, after moving metrics to TCP hostcache in r122922, most of in_rmx functionality became unused. It might had been used for flushing icmp-originated routes before rte mutexes/refcounting, but I'm not sure about that. So it looks like this is nearly impossible to make GC do its work nowadays: in_rtkill() ignores non-RTPRF_OURS routes. route can only become RTPRF_OURS after dropping last reference via rtfree() which calls in_clsroute(), which, it turn, ignores UP and non-RTF_DYNAMIC routes. Dynamic routes can still be installed via received redirect, but they have default lifetime (no specific rt_expire) and no one has another trie walker to call RTFREE() on them. So, the changelist: * remove custom rnh_match / rnh_close matching function. * remove all GC functions * partially revert r256695 (proto3 is no more used inside kernel, it is not possible to use rt_expire from user point of view, proto3 support is not complete) * Finish r241884 (similar to this commit) and remove remaining IPv6 parts MFC after: 1 month Notes: svn path=/head/; revision=274363
* | | | | | | Put "break" after err() to please coverity.Alexander V. Chernikov2014-11-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reported by: Coverity CID: 1250795 Notes: svn path=/head/; revision=274086
* | | | | | | Print human-readable error for "route not found" case.Alexander V. Chernikov2014-10-311-2/+11
| |_|_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Submitted by: vsevolod (initial version) MFC after: 2 weeks Sponsored by: Yandex LLC Notes: svn path=/head/; revision=273906
* | | | | | Fix incorrect netmasks being passed via rtsock.Alexander V. Chernikov2014-05-081-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since radix has been ignoring sa_family in passed sockaddrs, no one ever has bothered filling valid sa_family in netmasks. Additionally, radix adjusts sa_len field in every netmask not to compare zero bytes at all. This leads us to rt_mask with sa_family of AF_UNSPEC (-1) and arbitrary sa_len field (0 for default route, for example). However, rtsock have been passing that rt_mask intact for ages, requiring all rtsock consumers to make ther own local hacks. We even have unfixed on in base: do `route -n monitor` in one window and issue `route -n get addr` for some directly-connected address. You will probably see the following: got message of size 304 on Thu May 8 15:06:06 2014 RTM_GET: Report Metrics: len 304, pid: 30493, seq 1, errno 0, flags:<UP,DONE,PINNED> locks: inits: sockaddrs: <DST,GATEWAY,NETMASK,IFP,IFA> 10.0.0.0 link#1 (255) ffff ffff ff em0:8.0.27.c5.29.d4 10.0.0.92 _________________^^^^^^^^^^^^^^^^^^ after the change: got message of size 312 on Thu May 8 15:44:07 2014 RTM_GET: Report Metrics: len 312, pid: 2895, seq 1, errno 0, flags:<UP,DONE,PINNED> locks: inits: sockaddrs: <DST,GATEWAY,NETMASK,IFP,IFA> 10.0.0.0 link#1 255.255.255.0 em0:8.0.27.c5.29.d4 10.0.0.92 _________________^^^^^^^^^^^^^^^^^^ Sponsored by: Yandex LLC MFC after: 1 month Notes: svn path=/head/; revision=265666
* | | | | | Use src.opts.mk in preference to bsd.own.mk except where we need stuffWarner Losh2014-05-061-1/+1
| |_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | from the latter. Notes: svn path=/head/; revision=265420
* | | | | When switching variables to flags in r243185 a few cases were missed.Bjoern A. Zeeb2014-04-161-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After r263152 this leaves unused variables if route(8) is compiled without INET support. Switch the remaining variable accesses to flags and remove now obsolete variables. Reviewed by: glebius MFC after: 1 week Notes: svn path=/head/; revision=264539
* | | | | Remove AppleTalk support.Gleb Smirnoff2014-03-143-70/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AppleTalk was a network transport protocol for Apple Macintosh devices in 80s and then 90s. Starting with Mac OS X in 2000 the AppleTalk was a legacy protocol and primary networking protocol is TCP/IP. The last Mac OS X release to support AppleTalk happened in 2009. The same year routing equipment vendors (namely Cisco) end their support. Thus, AppleTalk won't be supported in FreeBSD 11.0-RELEASE. Notes: svn path=/head/; revision=263152