Commit Graph

2102 Commits

Author SHA1 Message Date
tsutsui d6f76b4a7b Fix off by one in ether_aton_r(). Noticed by "arp info overwritten" warning.
(how could it be missed for months?)
2011-01-12 15:30:40 +00:00
pooka 8d1e86d12d Apply patch from PR kern/44369 by Wolfgang Stukenbrock. 2011-01-11 10:52:42 +00:00
christos d232460a0a kern/44310: Alexander Nasonov: write to /dev/bpf truncates size_t to int 2011-01-02 21:03:45 +00:00
uebayasi ddbd4f2fb0 Fix build. 2010-12-27 14:58:55 +00:00
christos d5760f00f3 merge the length getting code from rt_msg1 and rt_msg2 and make it fail
when the compatibility ifinfo is missing instead of returning junk.
2010-12-25 20:37:44 +00:00
rmind 628e094cdc NPF checkpoint:
- Add support for session saving/restoring.
- Add packet logging support (can tcpdump a pseudo-interface).
- Support reload without flushing of sessions; rework some locking.
- Revisit session mangement, replace linking with npf_sentry_t entries.
- Add some counters for statistics, using percpu(9).
- Add IP_DF flag cleansing.
- Fix various bugs; misc clean-up.
2010-12-18 01:07:25 +00:00
pooka 91a3d3404c linkset no more 2010-12-08 17:10:13 +00:00
pooka 55fde99bfe _KERNEL_TOP 2010-12-07 20:38:26 +00:00
mrg f705e59458 revert another part of bpf_filter 1.38 that broke the check for divide
by zero while validating the bpf program.

originally spotted by skrll@, and broke atf the month-old atf test for
this exact problem: net_bpf_t_div-by-zero_div_by_zero.
2010-12-05 22:40:56 +00:00
mrg b5dcdd394e consider BPF_ABS, BPF_IND and BPF_MSH as they used to be in rev 1.37.
this fixes dhclient, and i'm told dhcpcd as well.


this patch from skrll@netbsd.org, tested by me.
2010-12-05 09:42:20 +00:00
mrg 51b69d29cc apply the smallest hack to allow this to build without warnings again. 2010-12-05 08:45:46 +00:00
christos 70d66231fe make bpf_validate available in userland. 2010-12-05 02:40:40 +00:00
christos d639454cac constify 2010-12-05 00:34:21 +00:00
christos 420ea92013 PR/44131: Matthew Mondor: if_tap.c tap_dev_ioctl() not propagating error,
always returns 0.
2010-11-22 21:31:51 +00:00
dyoung 7ef5c7d564 Cosmetic: fix indentation. 2010-11-17 00:20:49 +00:00
pooka 6f2301fb3c Implement ifconfig linkstr as proposed on tech-net. 2010-11-15 22:42:36 +00:00
roy a4784ce051 Add RTM_CHGADDR to signal that an address on the interface has changed.
This is mainly used for notifying userland about active link address changes.
2010-11-12 16:30:26 +00:00
rmind 97b932f123 NPF checkpoint:
- Add proper TCP state tracking as described in Guido van Rooij paper,
  plus handle TCP Window Scaling option.
- Completely rework npf_cache_t, reduce granularity, simplify code.
- Add npf_addr_t as an abstraction, amend session handling code, as well
  as NAT code et al, to use it.  Now design is prepared for IPv6 support.
- Handle IPv4 fragments i.e. perform packet reassembly.
- Add support for IPv4 ID randomization and minimum TTL enforcement.
- Add support for TCP MSS "clamping".
- Random bits for IPv6.  Various fixes and clean-up.
2010-11-11 06:30:39 +00:00
christos 882dc7b484 remove unused variables. 2010-11-06 23:28:58 +00:00
christos 4b64d01d9d PR/44054: Onno van der Linden: Stacksmashing in handling of ioctl OOSIO*
parameter.
2010-11-06 17:17:13 +00:00
christos 0118eafd5d PR/44030: Onno van der Linden: ifreqn2o gets called with the parameters the
wrong way around in /sys/net/if.c
2010-11-02 22:34:21 +00:00
pooka 177b6d9664 Remove XXX comment with the text "going away soon". It was added
in September 1989 -- I think we passed "soon" around last week.
2010-10-20 15:02:17 +00:00
rmind e2137dd128 npf_packet_handler: clear M_CANFASTFWD flag, so inspection would work when
fast forwarding is enabled (e.g. with GATEWAY kernel option).  Thanks matt@
for the tip.
2010-10-10 15:29:01 +00:00
rmind dc69e25ffd - npf_session_gc: fix for previous RB-tree conversion.
- npf_session_free: rename (to singular).
2010-10-03 19:36:38 +00:00
rmind a21e0fbdda nbuf_advfetch: fix bug and change behaviour on error case. 2010-10-03 19:30:22 +00:00
matt 19e6c76b2d Rename rb.h to rbtree.h, as it is more appropriate (c.f. ptree.h). Also
helps find code that hasn't been updated to use the new rbtree API.
2010-09-25 01:42:38 +00:00
rmind 57fb328f93 Add nbuf_advfetch() and simplify some code slightly. 2010-09-25 00:25:31 +00:00
rmind 879d5dfb5e Fixes/improvements to RB-tree implementation:
1. Fix inverted node order, so that negative value from comparison operator
   would represent lower (left) node, and positive - higher (right) node.
2. Add an argument (i.e. "context"), passed to comparison operators.
3. Change rb_tree_insert_node() to return a node - either inserted one or
   already existing one.
4. Amend the interface to manipulate the actual object, instead of the
   rb_node (in a similar way as Patricia-tree interface does).
5. Update all RB-tree users accordingly.

XXX: Perhaps rename rb.h to rbtree.h, since cleaning-up..

1-3 address the PR/43488 by Jeremy Huddleston.

Passes RB-tree regression tests.
Reviewed by: matt@, christos@
2010-09-24 22:51:50 +00:00
christos 14032335ad prevent integer oveflow. From Maksymilian Arciemowicz 2010-09-23 21:16:42 +00:00
rmind 63012b51f1 NPF checkpoint:
- Add support for bi-directional NAT and redirection / port forwarding.
- Finish filtering on ICMP type/code and add filtering on TCP flags.
- Add support for TCP reset (RST) or ICMP destination unreachable on block.
- Fix a bunch of bugs; misc cleanup.
2010-09-16 04:53:27 +00:00
tls cb72c101ad From Coyote Point source tree: "fix" srt IPv4 lookup on little-endian
hosts.  IPv6 is probably still broken, and, actually, the lookup table
for mask values should be kept in network byte order, not host byte order
and the corresponding change to the srtconfig ioctl interface made.

But at least this works.
2010-09-09 03:24:57 +00:00
spz 445e6acd20 fix two bugs in the PFKEY interface:
1) RFC2367 says in 2.3.3 Address Extension: "All non-address
   information in the sockaddrs, such as sin_zero for AF_INET sockaddrs,
   and sin6_flowinfo for AF_INET6 sockaddrs, MUST be zeroed out."
   the IPSEC_NAT_T code was expecting the port information it needs
   to be conveyed in the sockaddr instead of exclusively by
   SADB_X_EXT_NAT_T_SPORT and SADB_X_EXT_NAT_T_DPORT,
   and was not zeroing out the port information in the non-nat-traversal
   case.
   Since it was expecting the port information to reside in the sockaddr
   it could get away with (re)setting the ports after starting to use them.
   -> Set the natt ports before setting the SA mature.

2) RFC3947 has two Original Address fields, initiator and responder,
   so we need SADB_X_EXT_NAT_T_OAI and SADB_X_EXT_NAT_T_OAR and not just
   SADB_X_EXT_NAT_T_OA

The change has been created using vanhu's patch for FreeBSD as reference.

Note that establishing actual nat-t sessions has not yet been tested.

Likely fixes the following:
PR bin/41757
PR net/42592
PR net/42606
2010-09-05 06:52:53 +00:00
rmind 2e6f2099c6 Import NPF - a packet filter. Some features:
- Designed to be fully MP-safe and highly efficient.

- Tables/IP sets (hash or red-black tree) for high performance lookups.

- Stateful filtering and Network Address Port Translation (NAPT).
  Framework for application level gateways (ALGs).

- Packet inspection engine called n-code processor - inspired by BPF -
  supporting generic RISC-like and specific CISC-like instructions for
  common patterns (e.g. IPv4 address matching).  See npf_ncode(9) manual.

- Convenient userland utility npfctl(8) with npf.conf(8).

NOTE: This is not yet a fully capable alternative to PF or IPFilter.
Further work (support for binat/rdr, return-rst/return-icmp, common ALGs,
state saving/restoring, logging, etc) is in progress.

Thanks a lot to Matt Thomas for various useful comments and code review.
Aye by: board@
2010-08-22 18:56:18 +00:00
pgoyette 23d5409e7e Update the rest of the kernel to conform to the module subsystem's new
locking protocol.
2010-08-21 13:19:39 +00:00
pgoyette 5ef3a6df9b Keep condvar wmesg within 8 char limit 2010-08-11 11:47:29 +00:00
kefren d4ccc143a1 we need to set rt_ifp even if ifa is the same. Fixes the case when one
changes route to a different ifp but wants to keep the same ifa
2010-06-28 17:26:11 +00:00
kefren 00914d6d55 Don't assume that rt_tag family is AF_MPLS but verify it.
This way rt_tag can be used for other future work also, not only MPLS
2010-06-27 13:39:11 +00:00
kefren aeb8fe1fa4 Style fix: Tab consistency with the lines around it 2010-06-27 06:48:40 +00:00
kefren 25133d6d8f Fix build for MPLS import: add options MPLS, changed pseudo-device mpls
to pseudo-device ifmpls
2010-06-26 15:17:56 +00:00
kefren 826653c190 Add MPLS support, proposed on tech-net@ a couple of days ago
Welcome to 5.99.33
2010-06-26 14:24:27 +00:00
skrll 6a978a976d Correct the argument order of ifreqn2o conversion.
Fixes PR/42585.
2010-06-12 08:12:03 +00:00
dyoung 0d73006091 Prevent if_detach() from crashing while it walks the routing table
to find and unlink routes that reference the detached ifnet: make
if_rt_walktree() return ERESTART whenever it has deleted a route.
Whenever rt_walktree() returns ERESTART, if_detach() restarts it.

I believe that this fix resembles one by Jonathan Kollasch or by someone
else, which has languished in a PR for too long.  Sorry!

Tested by me and by Jeff Rizzo.

XXX It's supposed to be safe for rn_walktree() to apply to the routing
XXX table a routine that may delete routes.  Why isn't it safe in
XXX practice?
2010-06-02 23:41:14 +00:00
mjf e0e10b0607 Add __cacheline_aligned and __read_mostly annotations.
These annotations help to mitigate false sharing on multiprocessor
systems.

Variables annotated with __cacheline_aligned are placed into the
.data.cacheline_aligned section in the kernel. Each item in this
section is aligned on a cachline boundary - this avoids false
sharing. Highly contended global locks are a good candidate for
__cacheline_aligned annotation.

Variables annotated with __read_mostly are packed together tightly
into a .data.read_mostly section in the kernel. The idea here is that
we can pack infrequently modified data items into a cacheline and
avoid having to purge the cache, which would happen if read mostly
data and write mostly data shared a cachline. Initialisation variables
are a prime candiate for __read_mostly annotations.
2010-06-01 22:13:30 +00:00
dyoung a5a3d4c202 Change sc_wrports from an int to a bool and "test truth" instead of
comparing with 0.

Add 'volatile' to several other state variables that need it.
2010-05-26 23:46:44 +00:00
christos e0734521a4 delint previous 2010-05-19 20:43:51 +00:00
christos 5cbb2aa881 Replace ether_nonstatic_aton with a
- better named one
- not suffering from buffer oveflow
- simpler
- handling different separators
- returning error codes for errors

Some ideas from one posted on tech-net by Jonathan A. Kollasch
2010-05-19 20:41:59 +00:00
jakllsch fdc252ea81 Changes to ether_nonstatic_aton():
Be more leinent on input string format.  Each nibble pair may optionally be
followed by any of ':', '-', '.' or ' '.

Make source string const and work on a temporary copy.  The caller may not
expect their string to be destroyed.
2010-05-19 18:58:22 +00:00
dyoung ffd45aaae7 Constify some ether_output() arguments so that it's clear that they
can never be re-assigned.
2010-05-05 18:12:24 +00:00
kefren f4183d10ff Permit the existence of a route with unlinked ifp and ifa,
enabling this way the posibility to send a packet on an interface with
source address from another interface.
2010-05-02 19:17:56 +00:00
drochner 14f78ca302 the correct check for BPF_K is with BPF_SRC for BPF_ALU ops, from
Guy Harris per PR kern/43185
fixes possible division-by-zero crashes by evil filter expressions
like "len / 0 = 1"
pullup candidate
2010-04-21 16:35:09 +00:00