Commit Graph

150 Commits

Author SHA1 Message Date
Hiroki Sato
0a16fa86cb - Fix strtol() error handling.
- Add a range condition of given FIB number and the related error messages.
- Fix free() problem.

Spotted by:	Artyom Mirgorodskiy
Discussed with:	glebius
2012-12-16 23:46:59 +00:00
Hiroki Sato
0bebb5448b - Move definition of V_deembed_scopeid to scope6_var.h.
- Deembed scope id in L3 address in in6_lltable_dump().
- Simplify scope id recovery in rtsock routines.
- Remove embedded scope id handling in ndp(8) and route(8) completely.
2012-12-05 19:45:24 +00:00
Gleb Smirnoff
7c283ae860 Fix fallout from r243019, which broke parsing of shortened network
prefixes.

Reported and tested by:	delphij
2012-12-04 20:05:01 +00:00
Hiroki Sato
5c9fa630f6 - Fix LOR in sa6_recoverscope() in rt_msg2()[1].
- Check V_deembed_scopeid before checking if sa_family == AF_INET6.
- Fix scope id handing in route(8)[2] and ifconfig(8).

Reported by:	rpaulo[1], Mateusz Guzik[1], peter[2]
2012-12-04 17:12:23 +00:00
Gleb Smirnoff
f1e17e139d Flush stdout after RTM_IFANNOUNCE message.
PR:		bin/151600
Submitted by:	Eric van Gyzen <eric vangyzen.net>
2012-12-04 11:10:01 +00:00
Gleb Smirnoff
3fa6535388 No need to be root when running with -t or -d. 2012-12-04 10:24:50 +00:00
Hiroki Sato
6bbfef9004 Fill sin6_scope_id in sockaddr_in6 before passing it from the kernel to
userland via routing socket or sysctl.  This eliminates the following
KAME-specific sin6_scope_id handling routine from each userland utility:

 sin6.sin6_scope_id = ntohs(*(u_int16_t *)&sin6.sin6_addr.s6_addr[2]);

This behavior can be controlled by net.inet6.ip6.deembed_scopeid.  This is
set to 1 by default (sin6_scope_id will be filled in the kernel).

Reviewed by:	bz
2012-11-17 20:19:00 +00:00
Hiroki Sato
9ba63ff592 Add -fib modifier to specify FIB number. The FIB number can be in a
comma-separated list and/or range specification:

 # route add -inet 192.0.2.0/24 198.51.100.1 -fib 1,3-5,6

Although all of the subcommands supports the modifier, "monitor" does not
support the list or range specification at this moment.

Reviewed by:	bz
2012-11-17 19:54:23 +00:00
Gleb Smirnoff
23454ad0e2 Remove remnants of classful addressing. These magic transformations
of supplied arguments is not what a modern sysadmin expect.
2012-11-14 08:05:21 +00:00
Joel Dahl
091eeb4841 Remove superfluous paragraph macro. 2012-03-25 09:21:09 +00:00
Joel Dahl
46b035eb2e Document the show alias and add an EXAMPLES section. 2012-03-24 06:40:41 +00:00
Hiroki Sato
87a688aaa1 Fix a possible infinite loop in "route flush" on 64-bit archs.
MFC after:	3 days
2012-02-04 17:53:22 +00:00
Hajimu UMEMOTO
324930d7f8 Handle the internal scope address representation of the KAME IPv6
stack for the node-local multicast address.

Spotted by:	Rainer Bredehorn <Bredehorn__at__gmx.de>
MFC after:	1 week
2012-01-07 09:01:19 +00:00
Gleb Smirnoff
8d5fa60980 - Fix array bounds checking. [1]
- Add message length checking.

PR:		151664 [1]
Submitted by:	Alexey Illarionov <littlesavage rambler.ru> [1]
Reviewed by:	yar
2010-12-08 15:12:37 +00:00
Gleb Smirnoff
82641e1d1a Add RTM_IEEE80211 to array of route message descriptions.
PR:		151664
Submitted by:	Alexey Illarionov <littlesavage rambler.ru>
2010-12-08 15:10:27 +00:00
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