Commit Graph

2602 Commits

Author SHA1 Message Date
alnsn c676220d8a Move the main loop in bpfjit_generate_code() to a new function and make few
small changes.
2014-07-01 16:18:55 +00:00
msaitoh d917e28845 KNF. No functional change. 2014-07-01 15:03:58 +00:00
ozaki-r 5b9b847dc4 Unbreak lib/libc/net/getifaddrs.c
--- getifaddrs.o ---
  In file included from /tmp/bracket/build/2014.07.01.10.35.18-i386/src/lib/libc/net/getifaddrs.c:39:0:
  /tmp/bracket/build/2014.07.01.10.35.18-i386/src/sys/net/if.h:208:2: error: unknown type name 'kmutex_t'
    kmutex_t *ifq_lock;
      ^
2014-07-01 14:04:40 +00:00
ozaki-r 3745c9bdf3 Lock IFQ operations when NET_MPSAFE
- Introduce NET_MPSAFE
  - not defined by default
- Add ifq_lock to protect ifnet#if_snd
- Initialize ifq_lock and lock IFQ operations
  when NET_MPSAFE

When NET_MPSAFE isn't defined, this modification
doesn't change its behavior and adds trivial
performance overheads.

Discussed with matt@ on tech-net
2014-07-01 10:16:02 +00:00
rtr 0dedd9772f fix parameter types in pr_ioctl, called xx_control() functions and remove
abuse of pointer to struct mbuf type.

param2 changed to u_long type and uses parameter name 'cmd' (ioctl command)
param3 changed to void * type and uses parameter name 'data'
param4 changed to struct ifnet * and uses parameter name 'ifp'
param5 has been removed (formerly struct lwp *) and uses of 'l' have been
       replaced with curlwp from curproc(9).

callers have had (now unnecessary) casts to struct mbuf * removed, called
code has had (now unnecessary) casts to u_long, void * and struct ifnet *
respectively removed.

reviewed by rmind@
2014-07-01 05:49:18 +00:00
ozaki-r efbe326b4f Cleanup ppp_inproc
- Remove unnecessary variable isr
- Use pktq instead of rv to switch between inet/inet6 and other protocols

ok msaitoh@ and rmind@
2014-06-30 12:56:51 +00:00
ozaki-r 1a57926a63 Schedule pppoe_softintr only when a packet is enqueued 2014-06-30 10:03:41 +00:00
rmind c4a0527d4f NPF: use BPF JIT by default. 2014-06-30 00:01:23 +00:00
rmind 9c7a886e44 NPF:
- Populate the BPF external memory store with L3 information.
- Eliminate NPF_COP_L3 call and just use the data in the memstore.
- Bump NPF_VERSION.
2014-06-29 00:05:24 +00:00
alnsn 5706f5de50 Fix copyright years. 2014-06-25 19:32:37 +00:00
alnsn c9a2e5bb28 Default initialize external memwords.
This change doesn't affect performance of valid bpf kernel programs
because bpf_filter_ext() checks that all memwords are initialized
explicitly.
2014-06-25 13:53:40 +00:00
alnsn 6ba0a195e1 New jitcode takes two arguments. 2014-06-25 11:58:15 +00:00
alnsn e8d0d0ec8c Use SLJIT_MOV_P to copy extmem pointer. 2014-06-25 11:13:28 +00:00
alnsn 09ba0bba16 Check "preinited" argument of bpf_set_extmem(). 2014-06-25 09:51:34 +00:00
rmind 296dce2c93 bpfjit_generate_code: emit the instruction correctly. 2014-06-25 01:21:36 +00:00
rmind 263d30c43e Adjust NPF to the recent BPF / BPF JIT changes and make it work again.
All regression tests are happy now (hi alnsn!).
2014-06-25 00:20:06 +00:00
rmind f32e244083 - bpf_validate_ext: fix memword validation in BPF_ST/BPF_STX case.
- bpf_set_extmem: check the number of words against BPF_MAX_MEMWORDS.
2014-06-24 22:27:40 +00:00
rmind dd10cc70db - Improve the comments in bpf.h and KNF a little.
- Rename bpf_ctx_t member noinit to preinited (reflects the meaning better).
2014-06-24 22:19:36 +00:00
alnsn f9dc8d88ce Fix signatures of copfuncs. 2014-06-24 11:31:49 +00:00
alnsn 19fed70d36 Implement copfuncs and external memory in bpfjit. 2014-06-24 10:53:30 +00:00
rtr c5cb349386 where appropriate rename xxx_ioctl() struct mbuf * parameters from
`control' to `ifp' after split from xxx_usrreq().

sys_socket.c
    fix wrapping of arguments to be consistent with other function calls
    in the file after replacing pr_usrreq() call with pr_ioctl() which
    required one less argument.

link_proto.c
    fix indentation of parameters in link_ioctl() prototype to be
    consistent with the rest of the file.

discussed with rmind@
2014-06-23 17:18:45 +00:00
ozaki-r d82fb1f178 Get rid of unnecessary xc_broadcast after pktq_barrier
Pointed out by rmind@
2014-06-23 06:27:58 +00:00
rtr d54d7ab24a * split PRU_CONTROL functionality out of xxx_userreq() switches and place
into separate xxx_ioctl() functions.
* place KASSERT(req != PRU_CONTROL) inside xxx_userreq() as it is now
  inappropriate for req = PRU_CONTROL in xxx_userreq().
* replace calls to pr_generic() with req = PRU_CONTROL with pr_ioctl().
* remove & fixup references to PRU_CONTROL xxx_userreq() function comments.
* fix various comments references for xxx_userreq() that mentioned
  PRU_CONTROL as xxx_userreq() no longer handles the request.

a further change will follow to fix parameter and naming inconsistencies
retained from original code.

Reviewed by rmind@
2014-06-22 08:10:18 +00:00
ozaki-r 5efefa8603 Remove unnecessary sc_softintr 2014-06-20 14:22:48 +00:00
ws c05596e905 Enqueue the mbuf with the start of the packet,
not some intermediate one (hi, rmind!).
2014-06-19 16:54:40 +00:00
ozaki-r 10c5c9874c Restructure bridge_input and bridge_broadcast
There are two changes:
- Assemble the places calling pktq_enqueue (bridge_forward)
  for unicast and {b,m}cast frames into one
- Receive {b,m}cast frames in bridge_broadcast, not in
  bridge_input

The changes make the code clear and readable. bridge_input
now doesn't need to take care of {b,m}cast frames;
bridge_forward and bridge_broadcast have the responsibility.

The changes are based on a patch of Lloyd Parkes submitted
in PR 48104, but don't fix its issue yet.
2014-06-18 10:51:03 +00:00
ozaki-r 8f92986dca Tidy up bridge_input
No functional change.
2014-06-18 09:20:46 +00:00
ozaki-r 75ca0bace9 Make local functions static
This change unveiled some functions are unused. Remove some and
comment out the others.

No functional change.
2014-06-18 01:19:19 +00:00
alnsn 33abe179f5 Update code to the latest sljit version. 2014-06-17 16:52:33 +00:00
ozaki-r cb4cb63151 Restructure ether_input and bridge_input
The network stack of NetBSD is well organized and
layered. A packet reception is processed from a
lower layer to an upper layer one by one. However,
ether_input and bridge_input are not structured so.
bridge_input is called inside ether_input.

The new structure replaces ifnet#if_input of a bridge
member with bridge_input when the member is attached.
So a packet goes straight on a packet reception via
a bridge, bridge_input => ether_input => ip_input.

The change is part of a patch of Lloyd Parkes submitted
in PR 48104. Unlike the patch, the change doesn't
intend to change the behavior of the packet processing.
Another patch will fix PR 48104.
2014-06-17 10:39:46 +00:00
ozaki-r 8743b7c5c8 Include pktqueue.h only if _KERNEL 2014-06-16 03:43:10 +00:00
ozaki-r 14f6ebbe2b Add net.interfaces.bridgeN.fwdq.{maxlen,len,drops} sysctl 2014-06-16 01:05:25 +00:00
ozaki-r ac758954c5 Use pktqueue for bridge forwarding queue and softint 2014-06-16 01:03:57 +00:00
ozaki-r baef3a3b4a Move sysctl_pktq_{maxlen,count} to pktqueue.c and make them global
They will be used by bridge.

ok rmind@
2014-06-16 00:40:10 +00:00
ozaki-r e05f40117a Add 3rd argument to pktq_create to pass sc
It will be used to pass bridge sc for bridge_forward softint.

ok rmind@
2014-06-16 00:33:39 +00:00
ozaki-r 0ef36059a4 Get rid of unnecessary splnet for pool_{get,put}
A mutex prevents interrupts in the functions now.
2014-06-15 16:10:46 +00:00
rmind db8632f550 if_detach: drain ip6_pktq as well. 2014-06-13 13:54:08 +00:00
christos f6fa080675 PR/48901: Fail at compile time when trying to compile stf without inet6,
and print an explanatory message.
2014-06-12 16:43:09 +00:00
joerg 539332ecd5 Introduce new sysctls for obtaining interface-specific addresses:
- net.sdl for the active link-layer adddress (the MAC)
- net.ether.multicast for the Ethernet multicast addresses
- net.inet6.multicast for the IPv6 multicast groups
- net.inet6.multicast_kludge for temporarily removed multicast groups

Use this sysctls for replacing the kmem grovelling in ifmcstat(8).
2014-06-10 09:38:30 +00:00
rmind 4fab4afac7 pktqueue: add or fix some comments, remove some header inclusions. 2014-06-09 14:44:48 +00:00
rmind 264c0a1580 Restore the assert in RUMP's softint_schedule_cpu() and just ensure
curcpu() in the caller.
2014-06-09 13:03:16 +00:00
rmind ce450355ec Implement pktq_set_maxlen() and let sysctl net.inet.{ip,ip6}.ifq.maxlen be
changed on the fly again.
2014-06-09 12:57:04 +00:00
spz 57f4cb2745 fix typo in comment 2014-06-08 12:12:56 +00:00
he e2ec351127 Include <netinet/in.h> before <netinet/in_var.h> to avoid build failure
for the COMPUTEX7750 kernel of evbsh3-eb.
Also, don't reference ip_pktq if INET isn't defined (found by the same
kernel).
2014-06-07 13:25:33 +00:00
rmind 319afc4c4a lostart: silence gcc warning (XXX: gcc is not right though). 2014-06-07 11:00:29 +00:00
martin db893a74ff Try to untangle the ifdef mess a bit more 2014-06-07 09:34:02 +00:00
rmind 0cf67a7dfd sppp_input: handle pktqueue case correctly (fix for the previous). 2014-06-06 22:15:32 +00:00
rmind e0e5184593 rtfree: let's assert for a non-negative reference count and see what happens. 2014-06-06 01:27:32 +00:00
rmind 32293d340f - Eliminate RTFREE() macro in favour of rtfree() function.
- Make rtcache() function static.
2014-06-06 01:02:47 +00:00
rmind bc5cc9055a Adjust previous change for the #ifdef mess and fix the build. 2014-06-06 00:25:28 +00:00
rmind 60d350cf6d - Implement pktqueue interface for lockless IP input queue.
- Replace ipintrq and ip6intrq with the pktqueue mechanism.
- Eliminate kernel-lock from ipintr() and ip6intr().
- Some preparation work to push softnet_lock out of ipintr().

Discussed on tech-net.
2014-06-05 23:48:16 +00:00
rmind d9b974c9b7 - npf_nat_freepolicy: handle a race condition when a new connection might
be associated with a NAT policy which is going away and npfctl reload
  would wait for its natural expiration (potentially long time).
- Remove npf_ruleset_natreload() by merging into npf_ruleset_reload().
- npf_ruleset_reload: eliminate a small time period when a valid NAT
  policy might be inactive during the reload operation.
2014-05-30 23:26:06 +00:00
alnsn 08d17fbe34 Enable ABC optimization when one branch returns 0. 2014-05-23 22:04:09 +00:00
alnsn a9f8710044 Loads at offsets UINT32_MAX or greater are unreachable. 2014-05-23 19:51:16 +00:00
alnsn 1bf51582a4 Implement unconditional jump to "return 0" for loads at UINT32_MAX+1 or greater. 2014-05-23 19:11:22 +00:00
rmind f499e20dfc - Add in_init() and move some functions, variables and sysctls into in.c
where they belong to.  Make some functions and variables static.
- ip_input.c: reduce some #ifdefs, cleanup a little.
- Move some sysctls into ip_flow.c as they belong there.

No functional change.
2014-05-22 22:01:12 +00:00
dholland 39b82eecb9 Use accessor functions for the tty's table of control characters.
(at least from outside the core tty sources)

Move some xon/xoff code from net/ppp_tty.c to kern/tty.c.
2014-05-22 16:31:19 +00:00
alnsn 74e580d299 Some small changes in preparation for a bigger change.
- typedef for ABC variables and MAX_ABC_LENGTH constant,
- cast pc->k to uint32_t in more places,
- whitespaces.
2014-05-22 13:35:45 +00:00
rmind eb4d862469 raw_detach: rawpcb may be embedded, free using the real size (saved in rcb). 2014-05-21 20:43:56 +00:00
pooka 49165189ad if_free() instead of direct call to free() to avoid diagnostic panic
Bug exposed by justin's Lua ljsyscall tests:
http://build.myriabit.eu:8012/waterfall
2014-05-20 19:53:50 +00:00
rmind e401453f3f Adjust PR_WRAP_USRREQS() to include the attach/detach functions.
We still need the kernel-lock for some corner cases.
2014-05-20 19:04:00 +00:00
jakllsch 2f89c03432 Add ability to have mbufs disappear (to another interface) during
npf_rproc_run().  For upcoming npf_ext_route extension.

Guidance and ok by rmind@.
2014-05-19 18:45:51 +00:00
rmind 4ae03c1815 - Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.
2014-05-19 02:51:24 +00:00
rmind 39bd8dee77 Add struct pr_usrreqs with a pr_generic function and prepare for the
dismantling of pr_usrreq in the protocols; no functional change intended.
PRU_ATTACH/PRU_DETACH changes will follow soon.

Bump for struct protosw.  Welcome to 6.99.62!
2014-05-18 14:46:15 +00:00
rmind af0c2e41d7 - Move ifnet_list (and lo0ifp while here) under #ifdef _KERNEL.
- Make ifindex2ifnet, if_indexlim and some other variables static.
- Move if_index generation into its own function.
- if_alloc/if_free: replace malloc with kmem.
2014-05-18 00:33:20 +00:00
rmind 26e5a75962 - fsocreate: set SS_NBIO before the file descriptor is affixed as there is
a theoretical race condition (hard to trigger, though); remove the LWP
  parameter and clean up the code a little.
- Sprinkle few comments.
- Remove M_SOOPTS while here.
2014-05-17 23:27:59 +00:00
rmind f7741dab17 - Move IFNET_*() macros under #ifdef _KERNEL.
- Replace TAILQ_FOREACH on ifnet with IFNET_FOREACH().
2014-05-17 20:44:24 +00:00
rmind 2955673918 ppp_inproc: handle non-IP protocols correctly (hi msaitoh); PR/48813. 2014-05-17 14:51:09 +00:00
alnsn 98f8ebfbda Refactor bpfjit code.
- Implement Array Bounds Check Elimination for packet bytes.
 - Track initialization of registers and memwords.
 - Remove "bj_" prefix from struct members.
 - Shorten "BPFJIT_" prefix to "BJ_".
 - Other small improvements.
2014-05-15 22:20:08 +00:00
msaitoh e59c0b8f0f Save a NETISR_* value in a variable and call schednetisr() after enqueue
a packet for readability and future modification.
2014-05-15 09:23:03 +00:00
msaitoh 474c06e1a6 Put schednetisr() into splnet()/splx() pair.
This might avoids delay of processing a packet.
2014-05-15 09:04:03 +00:00
msaitoh 5233aa44e9 Put schednetisr(NETISR_IP) into splnet()/splx() pair. 2014-05-15 08:36:34 +00:00
msaitoh 5996d114f3 Put schednetisr(NETISR_IP) into splnet()/splx() pair.
This avoid extra ipintr() call with empty queue.
2014-05-15 07:48:41 +00:00
msaitoh a9419363c0 Usually schednetisr() is called after enqueueing a packet with IF_ENQUEUE().
In some functions, they do it in reverse order. It's not a bug because
the pair is protected with splnet()/splx(s). It's not good for readability
and someone might mistake when modifing a code. Yes, I'm one of the person :-(

 Save a NETISR_* value in a variable and call schednetisr() after enqueue
a packet for readability and future modification.
2014-05-15 07:35:38 +00:00
rmind 28ef1afe97 npf_session_inspect: do not silently drop the packet on state check failure.
Let the rules deal with it (e.g. we may want to log it).
2014-05-14 20:35:27 +00:00
bouyer 3910868948 Make sure *(if_output)() is called with KERNEL_LOCK held.
Add some KASSERT for this.
See http://mail-index.netbsd.org/tech-net/2014/04/09/msg004511.html
for details.
2014-05-13 19:36:16 +00:00
cube 1d53b5b172 Prevent a race between tap_dev_poll() and tap_start() by making sure the
call to selrecord() happens at splnet().  Fixes kern/47506 and kern/46199.
2014-05-07 22:53:34 +00:00
pooka 0f54014c8e Decouple sockets linkage from interface code by making ifioctl() a pointer. 2014-04-26 11:16:22 +00:00
pooka 1814443234 It's been > 20years since rtioctl() did something. Let's just
remove that special way of returning EOPNOTSUPP.
2014-04-26 11:10:10 +00:00
pooka 2393231e9a add a mask for currently valid ETHERCAP flags 2014-04-23 23:17:22 +00:00
aymeric 0a70cfa1fe Call mutex_destroy() on sc_kqlock in tap_detach(). Found by LOCKDEBUG. 2014-04-20 22:39:51 +00:00
christos 2a395ebf82 add LRO 2014-04-17 15:45:39 +00:00
maxv 2898b430e9 'newrt' is not supposed to be NULL. Therefore, the NULL-check in the if()
is pointless; and even if 'newrt' were NULL, 'rt' would be dereferenced
later. This is not a bug.

CID 270855

ok christos@
2014-03-22 07:46:35 +00:00
skrll 8f2cde0556 Mechanically replace simplelock with kmutex_t. 2014-03-20 06:48:54 +00:00
dholland a68f9396b6 Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
2014-03-16 05:20:22 +00:00
rmind 167f6f25d6 NPF: add support for "stateful-ends". 2014-03-14 11:29:44 +00:00
pooka d4373fc9e7 add a mask for valid capabilities
also add a comment stating why capabilities start from 0x80
2014-03-12 12:59:57 +00:00
pooka ed107912d9 If the in6 domain was not attached, do not attempt to process IPv6 packets. 2014-02-25 22:42:06 +00:00
pooka 4f6fb3bf35 Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
2014-02-25 18:30:08 +00:00
rmind 022864892f NPF: fix the recent breakage of the traceroute ALG. Also, simplify and
refactor a little bit.
2014-02-19 03:51:31 +00:00
rmind bab1756a9a npf_alg_session: fix inverted logic in the previous commit. 2014-02-17 02:38:46 +00:00
rmind ef728b81cb NPF: pass ALG functions via npfa_funcs_t structure. 2014-02-16 22:10:40 +00:00
rmind 068cee2998 NPF: add support for IPv6-to-IPv6 Network Prefix Translation (NPTv6),
as per RFC 6296.  Add a unit test.  Also, bump NPF_VERSION.

Thanks to S.P.Zeidler for the help with NPTv6 work!
2014-02-13 03:34:40 +00:00
rmind 8274d601f9 NPF: add support for static (stateless) NAT. 2014-02-07 23:45:22 +00:00
rmind ffcdc4af8d Add support for CDB based NPF tables. 2014-02-06 02:51:28 +00:00
christos 89c35f61ad add __USE 2014-01-25 21:10:41 +00:00
christos 68cffabfc3 add a lint comment 2014-01-25 21:10:29 +00:00
pooka 9d79315b3a missed one inet6 check 2014-01-03 12:49:59 +00:00
pooka acb676442c Allow kernels compiled with INET+INET6 to be booted as IPv4-only or IPv6-only. 2014-01-02 18:29:01 +00:00
pgoyette 1b0023ef9a Modularize net/zlib so it can be used by the vnd module (and, eventually,
by an opencrypto module).
2013-12-29 08:09:44 +00:00
pooka c4a2c1fa88 XXXgcc Wuninitialized kludge 2013-12-15 21:18:01 +00:00
rmind 8a8347bd05 NPF:
- Adjust NAT to not assume flow direction in some cases and thus support
  less usual setups which are possible when using 'map' with a custom
  filter criteria.
- Introduce NPF_SRC/NPF_DST and replace npc_src/npc_dst with npc_ips[2]
  for more convenient handling.
- ICMP ALG: restrict matching only to the outgoing traffic, but be more
  direction-agnostic elsewhere.
2013-12-06 01:33:37 +00:00
christos c16aecd187 It is silly to kill the system when an interface failed to clear promiscuous
mode. Some return EINVAL when they are dying, but others like USB return EIO.
Downgrade to a DIAGNOSTIC printf. Same should be done for the malloc/NOWAIT,
but this is rarely hit.
2013-12-05 15:55:35 +00:00
rmind 65c0517694 - npf_do_nat: fix a race condition and simplify the logic.
- npf_session_setnat: clear the NAT association on failure.
2013-12-04 01:38:49 +00:00
rmind c4d05d4533 Move initialisation of bpf_args_t into the npf_ruleset_inspect().
This allows us to reuse the BPF memory store as a cache.
2013-11-23 19:32:20 +00:00
rmind 85c1b3a579 Optimise checksum fixup routines:
- npf_fixup16_cksum: 1's complement sum is endian-independent.
- npf_fixup32_cksum: the first 32->16 bit reduction is not needed.

Pointed out by Valery Ushakov.
2013-11-22 01:48:36 +00:00
rmind 1c6c349315 npf_addr_mix: use xor rather than sum. 2013-11-22 01:24:21 +00:00
rmind 805a41fbfe Add npf_tableset_syncdict() to sync the table IDs in the proplib dictionary,
as they can change on reload now.  Also, fix table name checking in npfctl.
2013-11-22 00:25:51 +00:00
rmind c782c88894 NPF: convert to bpf_jit_generate()/bpf_jit_freecode(). 2013-11-16 01:18:58 +00:00
rmind 5bd8916144 bpf_deliver: convert to bpf_filter_ext(). 2013-11-16 01:13:52 +00:00
rmind df5750d833 Fix the bpfjit build. 2013-11-15 13:56:21 +00:00
rmind d0748eb941 - Add bpf_args_t and convert bpf_filter_ext() to use it. This allows the
caller to initialise (and re-use) the memory store.
- Add bpf_jit_generate() and bpf_jit_freecode() wrappers.
2013-11-15 00:12:44 +00:00
rmind 1e7342c150 NPF: add support for table naming and remove NPF_TABLE_SLOTS (there is
just an arbitrary sanity limit of NPF_MAX_TABLES currently set to 128).

Few misc fixes.  Bump NPF_VERSION.
2013-11-12 00:46:34 +00:00
martin d78727ed1e Add missing [0] (check for unused entries) when matching interface
names.
2013-11-11 15:28:37 +00:00
rmind a79812ea10 NPF: add support for specifying the interfaces before they are attached.
If an interface is or gets detached, all associated rules and connections
will be deactivated (it might be useful to have an option to invalidate
the associated connections).  Once the interface is reattached they will
become active.

Bump NPF_VERSION.
2013-11-08 00:38:26 +00:00
christos a6b92c971d eliminate unused variable 2013-11-07 21:44:48 +00:00
rmind 576b42c4d7 npf_generic_fsm and npf_tcp_fsm: use uint8_t and make the arrays more dense. 2013-11-04 22:17:21 +00:00
mrg 4cf2909a7b used __diagused where appropriate. 2013-10-30 08:41:38 +00:00
rmind ace4567cf1 npf_session_setnat: fix the race condition when the old connection is still
being expired while a new/duplicate is being created.
2013-10-29 16:39:10 +00:00
christos 0fca9a6115 add an alias for the linux name for the interface index 2013-10-28 21:38:01 +00:00
rmind e5a13e2c75 Add NPF_MAX_RULES, an artificial limit (set it to 1M). 2013-10-27 16:22:08 +00:00
martin 6a2419fedf Turn a few __unused into __diagused 2013-10-25 11:35:55 +00:00
kefren 829b00a60a RFC3032 conformance for Router Alert Label 2013-10-25 09:25:32 +00:00
mrg 7c99f5d74d adjust previous; old_link_state is also used in INET6. 2013-10-19 21:39:12 +00:00
martin 2610fadf05 Ifdef a variable like its use 2013-10-19 18:39:30 +00:00
christos 891807de18 remove unrelated diff. 2013-10-06 01:21:24 +00:00
christos d67ce930dc fix the source too, not just the doc. 2013-10-05 23:22:34 +00:00
christos cef26ebe03 Add SIOCGIFINDEX from Ty Sarna and Matthew Sporleder. 2013-10-05 23:16:54 +00:00
rmind 4da50fc205 bpf_filter: re-use some code. No functional change intended. 2013-10-05 22:38:52 +00:00
rmind fb41d25668 sess_hash_bucket: convert to murmurhash2, include ports, use random seed. 2013-09-26 00:24:36 +00:00
rmind 24e8f8767c bpfjit: replace malloc with kmem, KNF a little, add RCS ID. 2013-09-20 23:19:52 +00:00
rmind 7b5edfdc0d NPF: G/C n-code in favour of BPF byte-code. Delete lots of code, mmm! 2013-09-19 01:49:07 +00:00
rmind 4e592132ab - Convert NPF to use BPF byte-code by default. Compile BPF byte-code in
npfctl(8) and generate separate marks to describe the filter criteria.
- Rewrite 'npfctl show' functionality and fix some of the bugs.
- npftest: add a test for BPF COP.
- Bump NPF_VERSION.
2013-09-19 01:04:45 +00:00
rmind 60d47add10 npfctl_rule: fixes for the dynamic rules. 2013-09-19 00:50:56 +00:00
rmind 514e2368ee bpf_validate_ext: allow COP to modify the memstore. 2013-09-19 00:48:48 +00:00
rmind cb633e2d0c Add bpf_filter_ext() to use with BPF COP, restore bpf_filter() as it was
originally to preserve compatibility.  Similarly, add bpf_validate_ext()
which takes bpf_ctx_t.
2013-09-18 23:34:55 +00:00
martin 0d2f30103a Remove unused variable 2013-09-13 21:09:40 +00:00
martin 5b8d9098ad Remove unused variable 2013-09-13 21:05:02 +00:00
martin a37ce7da33 Remove unused variable 2013-09-12 20:47:59 +00:00
christos 4a5538bfa8 PR/48198: Peter Bex: Avoid kernel panic caused by setting a very small bpf
buffer size.
XXX: Pullup -6
2013-09-09 20:53:51 +00:00
rmind 4c45c55542 bpf_filter: add a custom argument which can be passed to coprocessor routine. 2013-08-30 15:00:08 +00:00
rmind 8088e72932 Remove SS_ISCONFIRMING, it is unused and TP4 will not come back. 2013-08-29 17:49:20 +00:00
rmind 1962fa8781 Implement BPF_COP/BPF_COPX instructions in the misc category (BPF_MISC)
which add a capability to call external functions in a predetermined way.

It can be thought as a BPF "coprocessor" -- a generic mechanism to offload
more complex packet inspection operations.  There is no default coprocessor
and this functionality is not targeted to the /dev/bpf.  This is primarily
targeted to the kernel subsystems, therefore there is no way to set a custom
coprocessor at the userlevel.

Discussed on: tech-net@
OK: core@
2013-08-29 14:25:40 +00:00
rmind 878c5e5866 - npf_cache_ip: re-fetch IPv6 header since nbufs might have been reallocated.
- npf_cache_all: clear NBUF_DATAREF_RESET since npf_cache_ip() handles it.
2013-08-23 10:37:03 +00:00
yamt 44ef5a4f25 - deal with softint_establish failure
- establish softint only when necessary
2013-08-20 12:28:12 +00:00
kiyohara 1ac3829df7 Fix build failed, if undef INET. 2013-08-04 07:05:15 +00:00
kefren 6da4e2e622 report about route tag in sysctl route walker 2013-07-24 15:31:04 +00:00
kefren 326bf6fa4a Implement RFC4182 changes - switchable via sysctl 2013-07-23 11:11:55 +00:00
oki 087ed689f5 if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.
2013-07-17 10:16:58 +00:00
kefren 931515b112 stop abusing kmem during softint context 2013-07-15 12:10:34 +00:00
rmind f04a92b1d6 - Rewrite parts of pfil(9): use array to store hooks and thus be more cache
friendly (there are only few hooks in the system).  Make the structures
  opaque and the interface more strict.
- Remove PFIL_HOOKS option by making pfil(9) mandatory.
2013-06-29 21:06:57 +00:00
roy 3643d6b4fe Move the detaching and making tentative addresses out if in6_if_up
and into in6_if_link_up.

This fixes a possible panic where link is up but not the interface.
Note that a better solution would be to listen to the routing socket
in the kernel, but I don't know how to do that.

Reachable Router tests for IFF_UP as well.
2013-06-20 13:56:29 +00:00
roy 49e60b0459 When an interface link state changes to down, mark all attached IPv6
addresses as detached.
Likewise, when the link state changes to up, mark all detached IPv6
as tentative and start DAD on them.

Advertised router reachability now checks that link state is not down.
This means that when an interface link state changes, the default IPv6
router may change as well.
2013-06-11 12:08:29 +00:00
christos 0e92ff1093 PR/44032: Proxy entries stopped working with pppd. The issue here is that
the route entry was added, but the RTF_LLINFO bit was not set, making arp -a
not showing the entry, but netstat -rn -f inet showing it with the missing
L bit. The order of resolution in ifa_ifwithroute() is that if a destination
address is found, then the interface chosen for the route is that of the
destination. This does not work for link-level addresses since the ppp
interface does not arp (uses link_rtrequest, not arp_rtrequest), so the
bit is never set. The easy solution here is to check that the gateway is
a link address, and use the interface which we chose for the link address
as opposed to the interface that routes to the destination. This restores
the previous behavior, but is it correct?
2013-06-08 02:42:56 +00:00
rmind bdfcfdcad8 - NPF connection tracking: rework synchronisation on tracking disable/enable
points and document it.  Split the worker thread into a separate module
  with an interface, so it could be re-used for other tasks.
- Replace ALG list with arrays and thus hit fewer cache lines.
- Misc bug fixes.
2013-06-02 02:20:04 +00:00
rmind ce38978248 - Add NPF table flushing functionality.
- Fix line numbering for npfctl debug command.
2013-05-19 20:45:34 +00:00
kardel f4c260b7f0 recover DLT_HIPPY and DLT_HDLC from before for if_hippisubr.c and hd64570.c 2013-04-07 14:12:05 +00:00
christos cefc406697 update from libpcap 2013-04-06 23:20:27 +00:00
christos bc0f55de88 Make ALG's autoloadable by providing in the config file:
alg "algname"
2013-03-20 00:29:46 +00:00
rmind 4183ea5f53 Always use BPF JIT for NPF rules (using BPF code) if it is available. 2013-03-18 02:24:45 +00:00
rmind 9ef92dc6c0 npf_session_establish: fix previous. 2013-03-18 00:17:20 +00:00
rmind 3b8a2fcf9c Add npf_session_trackable_p() and npf_session_fillent() for the common code.
Simplify.  No functional change.
2013-03-18 00:14:57 +00:00
christos ff7550039b add missing argument 2013-03-13 13:15:47 +00:00
christos fbfb5d3d8e don't auto-unload 2013-03-13 02:34:37 +00:00
christos 2c132b3129 normali{s,z}e 2013-03-12 20:47:48 +00:00
christos 12e775eb94 use sizeof(req) to find if it was empty or not (from uwe) 2013-03-11 17:20:02 +00:00
christos d89c031d8b *"" is not constant according to gcc. So we move the responsibility for adding
a , to the users of the macro.
2013-03-11 17:03:55 +00:00
christos 02ab91fbba - avoid trailing , in dependencies when there are none other the npf module
itself.
- remove if_npflog dependency from npf_ext_log.
2013-03-11 16:37:43 +00:00
christos fea1d0b382 prevent the lookup function from autoloading recursively. 2013-03-11 01:56:37 +00:00
christos 7e25e6910f move the module loading in the correct place. 2013-03-11 01:43:50 +00:00
christos 1066afcd4f remove the detach that does not belong here anymore. 2013-03-11 01:42:12 +00:00
christos 45d28ff77c Split the npflog cloner and auto-load the extensions. 2013-03-10 20:51:44 +00:00
christos a6e021428d allow cloners as modules. 2013-03-10 19:46:12 +00:00
joerg e240adbd0b Retire OSI network stack. OK core@ 2013-03-01 18:25:13 +00:00
rmind 3ae8914252 nbuf_ensure_contig: fix assert (can be equal if there is zero-length mbuf).
Found by npftest on sparc64.
2013-02-19 23:57:37 +00:00
rmind 56910be779 - Convert NPF dynamic rule ID to just incremented 64-bit counter.
- Fix multiple bugs.  Also, update the man page.
2013-02-16 21:11:12 +00:00
rmind 50c5afcad4 - Fix NPF config reload with dynamic rules present.
- Implement list and flush commands on a dynamic ruleset.
2013-02-10 23:47:37 +00:00
rmind 0e21825481 NPF:
- Implement dynamic NPF rules.  Controlled through npf(3) library of via
  npfctl rule command.  A rule can be removed using a unique identifier,
  returned on addition, or using a key which is SHA1 hash of the rule.
  Adjust npftest and add a regression test.
- Improvements to rule inspection mechanism.
- Initial BPF support as an alternative to n-code.
- Minor fixes; bump the version.
2013-02-09 03:35:31 +00:00
joerg 6c3b61dddd Remove remnants of AF_IMPLINK. 2013-02-05 17:30:01 +00:00
yamt aad8ef3224 use cprng_fast instead of getmicrouptime to generate "random" mac address
because the latter often produces the same addresses for subsequent tap
instances.
2013-01-28 15:05:03 +00:00
yamt cc345863dc whitespace 2013-01-28 15:01:13 +00:00
rmind 3107fd1eb5 - nbuf_ensure_contig: rework to use m_ensure_contig(9), which will not free
the mbuf chain on failure.  Fixes some corner cases.  Improve regression
  test and sprinkle some asserts.
- npf_reassembly: clear nbuf on IPv6 reassembly failure path (partial fix).
  The problem was found and fix provided by Anthony Mallet.
2013-01-20 18:45:56 +00:00
degroote 2b85e5b800 PR kern/47419: Antony Mallet: ifconfig doesn't diplay MTU on gif(4)
There is no special treatment for SIOCGITMTU in gif(4), so just pass it to
ifioctl_common().
2013-01-19 16:18:32 +00:00
rmind 2be35e5206 Silence gcc in npf_recache(). 2012-12-24 23:11:25 +00:00
rmind 352f160615 - Rework NPF's nbuf interface: use advancing and ensuring as a main method.
Eliminate unnecessary copy and simplify.  Adapt regression tests.
- Simplify ICMP ALG a little.  While here, handle ICMP ECHO for traceroute.
- Minor fixes, misc cleanup.
2012-12-24 19:05:42 +00:00
rmind 57ff5416fd - Add NPF version check in proplist as well, not only ioctl. Bump the version.
- Fix a bug in table entry lookup.
- Updates/fixes to the man pages.  Misc.
2012-12-23 21:01:03 +00:00
rmind f9e6e88c89 npf_rwrcksum: handle delayed checksums in the network stack; also fix
non-NPF_NAT_PORTS case and add some comments.  PR/47235.
2012-12-10 01:11:13 +00:00
rmind 333cdb0c5a Add NPF "rndblock" extension to randomly drop packets (using a random function
with a percentage or modulo operation).  This is a demo module, although it can
be used for packet loss simulation.  Example of a procedure in npf.conf:

procedure "somedrop" {
	# Drop 1.9% of the traffic
	rndblock: percentage 1.9
}
2012-12-10 00:32:23 +00:00
rmind af7272417a npf_table_list: avoid triggering assert on diagnostic. 2012-12-04 19:28:16 +00:00
mbalmer 9d9e15ed7b Don't check mp for NULL twice. From Michael W. Bomardieri <mb@il.net>
via tech-net@NetBSD.org.  Thanks!
2012-11-25 09:06:43 +00:00
alnsn 85151d38ab Add RCSID and fix -Wsign-compare warnings. 2012-11-10 22:12:31 +00:00
msaitoh c9d920062c Fix a bug that SIOCZIFDATA clears if_lastchage by zero.
Update if_lastchange with getnanotime().
2012-11-01 06:36:30 +00:00
msaitoh bbc956a9be Add SIOCGETHERCAP ioctl.
There was no way to know the setting of ec_capabilities and ec_capenable
other than grepping the source.

See http://mail-index.netbsd.org/tech-kern/2010/07/28/msg008613.html
2012-10-31 10:17:34 +00:00
rmind 64647e51e4 Implement NPF table listing and preservation of entries on reload.
Bump the version.
2012-10-29 02:27:11 +00:00
alnsn 87a1a6c0f7 Comment bd_jitcode member. 2012-10-28 21:12:44 +00:00
alnsn e8c0d6c662 Add bpfjit and enable it for amd64. 2012-10-27 22:36:11 +00:00
chs cbab9cadce split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
2012-10-27 17:17:22 +00:00
msaitoh a9ceb4700c Move the prototype definition of ether_input() from if.h to if_ether.h. 2012-10-25 11:53:14 +00:00
msaitoh 11dd166429 Add 1000baseT-FDX. 2012-10-25 10:59:43 +00:00
christos 202952fb98 PR/47058: Antti Kantee: If the ipv6 flow code modifies the mbuf, pass the
change up to the caller.
2012-10-11 20:05:50 +00:00