Commit Graph

135 Commits

Author SHA1 Message Date
Ulrich Spörlein
f62e48f536 route(8): make WARNS=3 clean
- add static and const where appropriate
- check pointers against NULL
- minor styling nits
- it is actually WARNS=6 clean for non-strict alignment platforms

This is shamelessly stolen from DragonflyBSD and reduces our diff.

PR:		bin/140078
Approved by:	ed (co-mentor)
2010-02-27 10:18:33 +00:00
Kip Macy
996de02413 remove stale references to RTF_CLONING and RTF_LLINFO
MFC after:	3 days
2009-09-04 18:52:26 +00:00
Philippe Charnier
80469c1b25 ANSIfy functions declarations, adjust prototypes. Rename local variable
to not conflict with err().
2009-08-25 04:09:09 +00:00
Kip Macy
427ac07f05 Extend route command:
- add show as alias for get
	- add weights to allow mpath to do more than equal cost
	- add sticky / nostick to disable / re-enable per-connection load balancing

This adds a field to rt_metrics_lite so network bits of world will need to be re-built.

Reviewed by:	jeli & qingli
2009-04-14 23:05:36 +00:00
Randall Stewart
5412227e19 Fix broken case where caused by last patch where
a user uses 0.0.0.0/0 as an alias for default.
Obtained from:	Mykola Dzham (freebsd@levsha.org.ua)
2009-04-11 10:08:26 +00:00
Randall Stewart
5695251a13 Ok, looking at the solution a bit closer, the level
calculation was too agressive. Instead we should only
look at each nibble. This makes it so we make
10.2.0.0 become 10.2/16 NOT 10.2/17.

Need to explore the non-cidr address issue. The two
may not be seperable..

MFC after:	1 week
2009-04-06 14:27:28 +00:00
Randall Stewart
7f749ed938 Class based addressing went out in the early 90's. Basically
if a entry is not route add -net xxx/bits then we should use
the addr (xxx) to establish the number of bits by looking at
the first non-zero bit. So if we enter
route add -net 10.1.1.0 10.1.3.5
this is the same as doing
route add -net 10.1.1.0/24
Since the 8th bit (zero counting) is set to 1 we set bits
to 32-8.

Users can of course still use the /x to change this behavior
or in cases where the network is in the trailing part
of the address, a "netmask" argument can be supplied to
override what is established from the interpretation of the
address itself. e.g:

route add -net 10.1.1.8 -netmask 0xff00ffff

should overide and place the proper CIDR mask in place.

PR:		131365
MFC after:	1 week
2009-04-06 10:09:20 +00:00
Alexander Motin
b814ca8a4f Fix regression introduced in rev. 173124:
0.0.0.0/1 is not the same as 0.0.0.0/0.

MFC after:	1 month
2009-01-18 11:38:35 +00:00
Qing Li
6e6b3f7cbc This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
   possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,

The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.

Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:

- Kip Macy revised the locking code completely, thus completing
  the last piece of the puzzle, Kip has also been conducting
  active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
  provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
  me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
Ruslan Ermilov
d4f2098b47 Fix printing of sockaddr prefixes in verbose mode.
PR:		bin/122403
Submitted by:	az
MFC after:	3 days
2008-04-10 12:16:20 +00:00
Remko Lodder
6764f54349 In route.c in newroute() there's a call to exit(0) if the command was
'get'. Since rtmsg() always gets called and returns 0 on success and -1
on failure, it's possible to exit with a suitable exit code by calling
exit(ret != 0) instead, as is done at the end of newroute().

PR:		bin/112303
Submitted by:	bruce@cran.org.uk
MFC after:	1 week
2008-03-22 12:50:43 +00:00
Mike Makonnen
5ab965347e Don't mask the address in inet_makenetandmask() according to what class
it appears to be in: there is also CIDR.

Noticed by: tegge
2007-11-04 11:12:40 +00:00
David E. O'Brien
31a1fa7932 Document -t. 2007-11-01 19:54:59 +00:00
Mike Makonnen
530378f8b9 Fix an error in bit shifting logic for network addresses. The route
command would add incorrect routing entries if network numbers weren't
fully "spelled" out according to their class. For example:
  # route add 128.0/16   (works)
  # route add 128/16     (doesn't work)
  # route add 193.0.0/24 (works)
  # route add 193/24     (doesn't work)

Also, rework the way a netmask is deduced from network number if
it [netmask] is not specified.

Submitted by:	Nuno Antunes <nuno.antunes@gmail.com> (mostly)
MFC after:	1 week
2007-10-29 00:08:24 +00:00
Yaroslav Tykhiy
491bafe5c6 Obey MK_INET6_SUPPORT.
This is also a good chance to apply style.Makefile(5) in some cases.
2006-07-27 13:26:29 +00:00
Ruslan Ermilov
259fcfd358 Document that -q option is also applicable to the "change" command.
PR:		docs/85095
Submitted by:	Rostislav Krasny
2005-10-02 12:55:34 +00:00
Anton Berezin
064b93d5ea Introduce "route del" as an alias to "route delete".
Reviewed by:	arch
2005-09-28 12:12:15 +00:00
Gleb Smirnoff
7278e14c38 - Understand EADDRINUSE, and forget EDQUOT. [1]
- Add description for EEXIST.
- Change description for ENOBUFS. Routing socket can return
  this error for many different reasons, including general
  memory shortage, mbuf memory shortage and rtentry zone.

PR:		kern/64090 [1]
2005-09-21 12:24:46 +00:00
Hajimu UMEMOTO
c60a8b32a2 - do DNS lookup for symbolic names specified for a destination
or gateway.
- improves error reporting using gai_strerror(3) instead of
  printing "bad value".
- remove "0" for servname argument for getaddrinfo(3).

Submitted by:	Andreas Kohn <andreas __at__ syndrom23.de>
MFC after:	1 week
2005-05-23 14:12:32 +00:00
Hajimu UMEMOTO
4f10131848 NI_WITHSCOPEID cleanup. Neither RFC 2553 nor RFC 3493 defines
NI_WITHSCOPEID, and our getaddrinfo(3) does nothing special
for it, now.
2005-05-13 16:31:11 +00:00
Juli Mallett
b894acfb2a shutdown(2)'s how argument as 0 is nowhere near as cool as SHUT_RD 2005-05-11 02:50:41 +00:00
Ruslan Ermilov
0227791b40 Expand *n't contractions. 2005-02-13 22:25:33 +00:00
Ruslan Ermilov
6087df9e8b Sort sections. 2005-01-18 10:09:38 +00:00
Ruslan Ermilov
a866e17077 Added the EXIT STATUS section where appropriate. 2005-01-17 07:44:44 +00:00
Ruslan Ermilov
214144704b Scheduled mdoc(7) sweep. 2005-01-10 16:17:34 +00:00
Bruce M Simpson
fa967069e0 Fix markup: .Dv -> .Va
Update document dates.

Prodded by:	ru
2004-11-04 08:29:28 +00:00
Bruce M Simpson
2c9743caad Document the fact that blackhole routes normally need to be bound
to lo(4) interfaces to have an effect, and that this is not needed
when using IP fast forwarding.

Sponsored by:	eXtensible Open Router Project <URL:http://www.xorp.org/>
MFC after:	3 weeks
2004-11-04 02:15:03 +00:00
Ruslan Ermilov
9806e23132 Mechanically kill hard sentence breaks. 2004-07-02 21:45:06 +00:00
Bruce M Simpson
3a7d7a8b39 When parsing an argument as an address in getaddr(), heed the -host option
in all cases.  The failure mode in the PR is easily reproducible without
this patch.

PR:		bin/43139
2004-06-16 06:29:41 +00:00
Ruslan Ermilov
d04b5dfe6c Assorted markup, grammar, and spelling fixes. 2004-05-17 08:35:43 +00:00
Christian S.J. Peron
9251dd77ca Teach route(8) how to deal with root being in a prison. If prison
root is allowed to create raw sockets, then they will be able to create
routing sockets, too.  However prison-root is not able to manipulate
routing tables.  So when route(8) attempts to write to a routing
socket and recieves EPERM from the kernel, exit rather than moving
on with execution.

Approved by:    bmilekic (mentor)
2004-05-07 15:33:17 +00:00
Andre Oppermann
9063f422e2 Link state change notification of ethernet media to the routing socket.
o Print the link state for interface messages in monitor mode.

No objections by:	sam, wpaul, ru, bms
Brucification by:	bde
2004-05-03 16:30:32 +00:00
Doug Ambrisko
41b0ee744a For both ifconfig and route if we didn't get enough memory from the
prior sysctl due to the structure growing between calls try again.

Also try again for deleting routes if things fail.  We've seen
route -f fail this way which does not actually flush all routes.
This fixes it.  It will whine but it will do the work.

PR:		56732
Obtained from:	IronPort
2004-04-30 22:34:12 +00:00
Luigi Rizzo
0b46c08590 Replace ROUNDUP/ADVANCE with SA_SIZE 2004-04-13 11:24:43 +00:00
Mark Murray
4c723140a4 Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core, imp
2004-04-09 19:58:40 +00:00
Johan Karlsson
604d24db95 style.Makefile(5):
Use WARNS?= instead of WARNS=.
2004-02-23 20:25:27 +00:00
Hajimu UMEMOTO
711eaadb3c link-local multicast address must be converted to KAME specific
embeded scopeid form.

Reported by:	dwmalone
MFC after:	3 days
2003-12-07 11:11:26 +00:00
Christian Brueffer
76a8862646 Add a describtion for the '-d' flag
While I'm here, add a missing comma

PR:		41787
Obtained from:	OpenBSD
MFC after:	5 days
2003-11-10 14:28:33 +00:00
Bruce M Simpson
a441e6c4c5 Add the -xresolve flag to the route(8) man page.
Reviewed by:	ru
2003-09-26 17:03:09 +00:00
Andrey A. Chernov
90862ca23d LANG->LC_ALL
Pointed by:     ru
2003-08-04 21:31:53 +00:00
Andrey A. Chernov
b13fdf9999 Fix problem differently, use 
LANG=C tr 'a-z' 'A-Z'                                                         
for hypotetical case that script may generate non-ascii characters
2003-08-04 15:25:39 +00:00
Andrey A. Chernov
7f0ea49c84 Use tr '[:lower:]' '[:upper:]' to work with any locale 2003-08-04 14:32:56 +00:00
Ruslan Ermilov
1becd59e62 There is an undocument feature that ``route -vnd flush'' prints
a nice dump of the entire routing table.  Allow non-root users
to see it too.
2003-04-16 12:06:53 +00:00
Peter Wemm
059c32d2eb Kill #ifdef NS code 2003-03-05 19:18:05 +00:00
Kelly Yancey
ed92abc56b Since route(8) itself is no longer setuid, we can get a meaningful
answer for the euid.  As a result, fix it such that setuid scripts or
programs may call route(8) to do work on their behalf.

Reviewed by:	ru
MFC after:	3 days
2003-01-25 01:28:11 +00:00
Philippe Charnier
629e80effb The .Nm utility. 2002-07-06 19:35:14 +00:00
Hajimu UMEMOTO
56c5d32d37 Don't have -prefixlen 128 on host routes.
Obtained from:	KAME
2002-06-08 19:49:22 +00:00
Garrett Wollman
5c7417c4d1 Avoid construction which results in label at end of block. 2002-05-30 21:41:42 +00:00
Ruslan Ermilov
999ffea58a Respect -q with "add" and "delete". Document who respects -q.
PR:		bin/38531
2002-05-25 12:51:34 +00:00
Hajimu UMEMOTO
720bbc8244 Allow prefix/prefixlen syntax for IPv6 to have consistency
with IPv4.
2002-05-21 18:11:31 +00:00