Home | History | Annotate | Download | only in net
History log of /src/sys/net/if_spppsubr.c
RevisionDateAuthorComments
 1.272  07-Oct-2025  andvar Fix few typos in comments.
 1.271  05-Jun-2025  ozaki-r Apply in6ifa_first_lladdr() and in6ifa_first_lladdr_psref()
 1.270  05-Jun-2025  ozaki-r Apply if_first_addr() and if_first_addr_psref()
 1.269  05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.268  17-Feb-2024  martin branches: 1.268.2;
PR 57941: remove duplciate declaration (copy+pasto)
 1.267  25-Mar-2023  andvar branches: 1.267.4;
s/deteted/detected/ in log message.
 1.266  03-Sep-2022  thorpej branches: 1.266.4;
Garbage-collect the remaining vestiges of netisr.
 1.265  03-Sep-2022  thorpej Only use configured RPS hash functions for IPv4 and IPv6 packets.

This is NFC change now because only IPv4 and IPv6 use pktqueue,
but that will change in future commits.
 1.264  27-Aug-2022  thorpej Ensure that all queues passed to ifq_enqueue2() have a valid ifq_lock.
 1.263  27-Aug-2022  thorpej Use IFQ_SET_MAXLEN() rather than open-coding it.
 1.262  07-Mar-2022  knakahara Don't change ifp->if_link_state directly. Pointed out by yamaguchi@n.o.
 1.261  25-Oct-2021  knakahara kpreempt_disable() before sppp_get_{ip,ip6}_addrs() are unnecessary now.
 1.260  25-Oct-2021  knakahara Fix missing curlwp_bind() for ifa_release(), ok'ed by yamaguchi@n.o.

This causes the following KASSERT failure in pppoe server.
- sppp_rcr_event()
- sppp_ipcp_confreq()
- sppp_get_ip_addrs()
- psref_release()

After if_spppsubr.c:1.227, sppp_ipcp_confreq() is done in workqueue
instead of softint.
 1.259  11-Oct-2021  knakahara Make pktq_rps_hash() pluggable for each interface type. Reviewed by gdt@n.o, thorpej@n.o, and riastradh@n.o, thanks.
 1.258  02-Jun-2021  yamaguchi Added missing definition of sppp_ipv6cp_tld

Fixed build without INET6
 1.257  01-Jun-2021  yamaguchi Fix the wrong timeout event handler for PAP

sppp_auth_to_event() is a implementation of TO+/TO- event for
authentication protocol and it drops TO+ event in Ack-rcvd state.
 1.256  01-Jun-2021  yamaguchi Send Up event in tlu action of LCP

When LCP is stopping, the layer send Down event and Close event
(Down -> Close). To align the sequence, Up event is moved
before Open event.
 1.255  01-Jun-2021  yamaguchi Added logs when IPCP and IPv6CP are up or down
 1.254  01-Jun-2021  yamaguchi Added SPPP_LOG() for refactoring around log
 1.253  01-Jun-2021  yamaguchi Send RTM_IFINFO when a network configuration protocol
is up or down
 1.252  01-Jun-2021  yamaguchi Drop the Open event of LCP to stop the interface
even a reconnection is scheduled

The queue for events in if_spppsubr.c is not possible
to enqueue the same event. So, The close event caused
while a close event and open event are enqueued for
reconnection is not possible to stop interface.
To solve this issue, The open event after
"ifconfig pppoe? down" is dropped.
 1.251  01-Jun-2021  yamaguchi remove PP_CISCO that was used in obsoleted drivers e.g. lmc(4)
 1.250  01-Jun-2021  yamaguchi Remove open event on tlf of PAP/CHAP when retry of them is over
to prevent that LCP stops at Starting state.

And also remove retry counter check on tls of LCP because of
unnecessary.
 1.249  01-Jun-2021  yamaguchi Do not if_down() when a down event of the lower layer of LCP is happened
since the layer try to reconnect.
 1.248  01-Jun-2021  yamaguchi Fix not to do if_down() before reconnect

Almost network interface do not use if_down() even when there is no
connectivity. So, pppoe(4) is also made be not used it.
This behavior can be rollbacked by SPPP_IFDOWN_RECONNECT option.
 1.247  01-Jun-2021  yamaguchi restart LCP when loopback packets are detected

In if_spppsubr.c down and up do not mean that LCP is stopping
or running, but mean that the lower layer of LCP is up or down.
And, restarting of LCP is had to use close event and open event.
 1.246  19-May-2021  yamaguchi Make functions that use for logging MP-safe

There is no change in behavior.
 1.245  19-May-2021  yamaguchi Added clear of dns addresses when IPCP is closed
 1.244  19-May-2021  yamaguchi Added logs on dropping IPCP and IPv6CP packets
 1.243  19-May-2021  yamaguchi remove a wrong ntohs().

The variable is already host-byte-order.
 1.242  19-May-2021  yamaguchi Added a log about rejection of IPCP address option
 1.241  14-May-2021  yamaguchi Add a parameter to change keepalive interval in each PPPoE I/F
 1.240  14-May-2021  yamaguchi Added SPPP_NORECV_TIME option to change pp_max_noreceive
 1.239  14-May-2021  yamaguchi Send echo request even while user data is received
if pp_max_noreceive is 0
 1.238  14-May-2021  yamaguchi Introduce SPPP_KEEPALIVE_INTERVAL option
to change the interval between LCP echo requests
 1.237  11-May-2021  yamaguchi clear authentication protocol when SPPP_AUTHPROTO_NONE is specified
 1.236  11-May-2021  yamaguchi Drop packets that have no NCP not to start auto-dial
 1.235  11-May-2021  yamaguchi Added missing if_oerror incrementing
 1.234  11-May-2021  yamaguchi Move RCA event after RCR event

A authentication failed by TO+ event between RCA and RCR events
1. RCA event in REQ-SENT state
- REQ-SENT => ACK-RCVD
2. TO+ event
- ACK-RCVD => REQ-SENT
3. RCR+ event
- REQ-SENT => ACK-SENT

By moving RCA after RCR, the state is transisted to OPENED
1. RCR event
- REQ-SENT => ACK-SENT
2. TO+ event
- state is not changed
3. RCA event
- ACK-SENT => OPENED
 1.233  11-May-2021  yamaguchi Added ioctl commands for configuring NCP of pppoe(4)
 1.232  11-May-2021  yamaguchi Revert previous commit because of mistake of commit log

back to r1.230(if_spppsubr.c) and r1.31(if_sppp.h)
 1.231  11-May-2021  yamaguchi Added keywords that are ipcp, noipcp, ipv6cp, noipv6cp
for configuring NCP
 1.230  06-May-2021  yamaguchi branches: 1.230.2;
do not clear destination address if there is no saved address
and add initialization of saved_hisaddr for safety

0.0.0.0 was sometimes configured to destination address when
ipcp close was occurred before ipcp tlu.
Following messages will be appeared when the issue is encountered and
debug for pppoe(4) is enabled.

tc-so:[ 1.890005] pppoe0: ipcp close(starting)
(snip)
tc-so:[ 1.890005] pppoe0: ipcp_open(): no IP interface
 1.229  06-May-2021  yamaguchi Added m_freem for safety

pointed out by knakahara@, thanks.
 1.228  28-Apr-2021  yamaguchi Introduce a pointer to refer sp->scp[cp->protoidx]

There is no functional difference.
 1.227  28-Apr-2021  yamaguchi Move paese of conf-req, conf-nak and conf-rej into workqueue
from softint context

When the pases were processed in softint, the state machine
in if_spppsubr.c had been broken by simultaneous events
on rare occasions.

Example:
1. Do ifconfig pppoe* up
- lcp open event is enqueued to workqueue
2. Receive conf-ack, and parse the packet
- save mru to sp->lcp.their_mru
- lcp RCR+ event is enqueued to workqueue
3. Process lcp open event
- initialize data including sp->lcp.their_mru
4. Process lcp RCR+ event
- Use sp->lcp.their_mru
- but it was initialized
 1.226  26-Apr-2021  yamaguchi Fix the wrong CHAP option length in conf-nak

RFC 1994 defines that the CHAP option length in conf-nak is 5.
However, 4 was used when CHAP is cofigured and PPP is proposed
by a peer.
 1.225  26-Apr-2021  yamaguchi Avoid updating of the state if the state is not changed
not to reset the timer for state machine
 1.224  26-Apr-2021  yamaguchi Reset LCP fail counter when doing "ifconfig pppoe* up"
 1.223  26-Apr-2021  yamaguchi Added ipcp option name for logging
 1.222  26-Apr-2021  yamaguchi Ignore 0.0.0.0 offered from PPPoE server
 1.221  26-Apr-2021  yamaguchi Fix locking order since IFNET_LOCK must be held
before acquiring SPPP_LOCK
 1.220  23-Apr-2021  yamaguchi branches: 1.220.2;
Adjust mtu at LCP instead at IPCP

The adjustment must be done at LCP when a PPPoE connection
does not use IPCP.
 1.219  23-Apr-2021  yamaguchi Fix to set mtu even if it is bigger than mru notified at LCP
 1.218  23-Apr-2021  yamaguchi Introduct a new flag to accept different authentication protocol
in myauthproto and hisauthproto

When the flag is enabled, a authentication protocol notified
at LCP negotiation is used as my authentication protocol.
When the flags is NOT enabled, my authentication protoco is
not changed at LCP negotiation.
 1.217  16-Apr-2021  yamaguchi Remove unnecessaly lock holdings to avoid dead lock

The locks were held while callout_halt() and workqueue_wait()
without reason.
And the locks also were held at callout and workqueue handler
so that the handler kicked by those function couldn't acquire
the lock.

The reasons why those are unneccesary are:
- Items of callout_t are protected by callout_lock
- Items of struct workqueue and struct work are protected
by q_mutex in struct workqueue
- Items of struct sppp_work protected by atomic_cas(3)
- struct pppoe_softc does not free before workqueue_wait() and
callout_halt() even if the locks are not held
 1.216  16-Apr-2021  yamaguchi Fix not to put the wrong error message
 1.215  27-Nov-2020  yamaguchi branches: 1.215.2;
Fix missing disable of kpreempt while getting interface address
 1.214  25-Nov-2020  yamaguchi add KASSERT(!cpu_softintr_p());

pointed out by knakahara@n.o., thanks.
 1.213  25-Nov-2020  yamaguchi Add commands to refer params of control protocols in if_spppsubr.c

reviewed by knakahara@n.o.
 1.212  25-Nov-2020  yamaguchi Reconnect when a down event caused by tlf caught
 1.211  25-Nov-2020  yamaguchi Move code related to module to bottom
 1.210  25-Nov-2020  yamaguchi Reconnect lcp after authentication or network phase finish
 1.209  25-Nov-2020  yamaguchi Close lcp when the lower layer down if the interface is passive or on-demand

reivewed by knakahara@n.o.
 1.208  25-Nov-2020  yamaguchi Update ip addresses in the workqueue for control protocols

reviewed by knakahara@n.o.
 1.207  25-Nov-2020  yamaguchi Add the id check for TERM_ACK
 1.206  25-Nov-2020  yamaguchi remove double newlines
 1.205  25-Nov-2020  yamaguchi change function name(RCR => parse_confreq)

reviewed by knakahara@n.o.
 1.204  25-Nov-2020  yamaguchi Add a function to initialize parameters
 1.203  25-Nov-2020  yamaguchi Remove unused and unimplemented code related to CP_QUAL
 1.202  25-Nov-2020  yamaguchi Simplify commonly used functions

reviewed by knakahara@n.o.
 1.201  25-Nov-2020  yamaguchi implement auth protocols on the state-machine of control protocols

reviewed by knakahara@n.o.
 1.200  25-Nov-2020  yamaguchi Insert an entry after initialization
 1.199  25-Nov-2020  yamaguchi call if_down() in workqueue instead of callout(9)
 1.198  25-Nov-2020  yamaguchi Change a state of control protocol in thread context

reviewed by knakahara@n.o.
 1.197  25-Nov-2020  yamaguchi Add a function for RXJ event
 1.196  25-Nov-2020  yamaguchi Add a function for RTR and RTA event
 1.195  25-Nov-2020  yamaguchi Add a function for RCA and RCN event
 1.194  25-Nov-2020  yamaguchi Add a function for RCR event
 1.193  25-Nov-2020  yamaguchi Refactoring functions for RCR and RCN
 1.192  25-Nov-2020  yamaguchi Add a structure for params related to control protocols
 1.191  25-Nov-2020  yamaguchi remove variable names in function declaration
 1.190  05-Oct-2020  roy branches: 1.190.2;
ppp: Remove media

There is none after all.
Applications should be using ifi_link_state and not checking media.
 1.189  04-Apr-2020  is Multilink PPP: sanity check of option values, storage of remote MRRU.
 1.188  01-Apr-2020  is Define a few more LCP options. Recognize, sanity-check and report (but
still reject for the moment) multilink PPP configuration options received.
 1.187  06-Mar-2020  knakahara branches: 1.187.2;
remove unnecessary lock in sppp_mediastatus() as it doesn't touch struct sppp.

ok'ed by yamaguchi@n.o.
 1.186  04-Feb-2020  thorpej Use ifmedia_fini().
 1.185  29-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.184  13-Sep-2019  msaitoh branches: 1.184.2;
if_flags is neither int nor short. It's unsigned short.
 1.183  11-Jul-2019  msaitoh Fix typo (s/supress/suppress/).
 1.182  01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.181  27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.180  30-Mar-2018  mlelstv branches: 1.180.2;
Reset fail counter when link goes down so that next session starts
with the correct retry count.
 1.179  06-Feb-2018  knakahara branches: 1.179.2;
Fix breaking character limit. Pointed out by ozaki-r@n.o, thanks.
 1.178  28-Dec-2017  ozaki-r Ensure the timer isn't running by using workqueue_wait
 1.177  11-Dec-2017  ozaki-r Wrap if_ioctl_lock with IFNET_* macros (NFC)

Also if_ioctl_lock perhaps needs to be renamed to something because it's now
not just for ioctl...
 1.176  07-Dec-2017  ozaki-r Ensure to call if_addr_init with holding if_ioctl_lock
 1.175  22-Nov-2017  christos fix non-diagnostic compilation
 1.174  22-Nov-2017  ozaki-r Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref (more)
 1.173  22-Nov-2017  ozaki-r Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref
 1.172  15-Nov-2017  knakahara Mark callouts of pppoe(4) CALLOUT_MPSAFE. Suggested by ozaki-r@n.o.
 1.171  13-Oct-2017  knakahara fix no INET6 build.
 1.170  12-Oct-2017  knakahara sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.
 1.169  28-Mar-2017  ozaki-r branches: 1.169.6;
Avoid touching a mbuf after enqueuing it
 1.168  28-Mar-2017  ozaki-r Use sp->pp_framebytes instead of the constant value "3"

It seems that it was forgotten to be converted in v1.22.
 1.167  16-Jan-2017  christos ip6_sprintf -> IN6_PRINT so that we pass the size.
 1.166  16-Jan-2017  ryo Make ip6_sprintf(), in_fmtaddr(), lla_snprintf() and icmp6_redirect_diag() mpsafe.

Reviewed by ozaki-r@
 1.165  27-Dec-2016  christos branches: 1.165.2;
Another missed patch
 1.164  26-Dec-2016  christos pfil(9) improvements to handle address changes:

Add:
PFIL_IFADDR call on interface reconfig (mbuf is ioctl #)
PFIL_IFNET call on interface attach/detach (mbuf is PFIL_IFNET_*)

from rmind@
 1.163  13-Dec-2016  knakahara MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.
 1.162  06-Dec-2016  knakahara add API to manipulate ifa->ia_hash and ia_hash_pslist_entry, and fix ia_hash_pslist_entry race by using them.

in_ifaddr_lock is required before writing ifa->ia_hash and
ia_hash_pslist_entry to serialize writer processings.

reviewed by ozaki-r@n.o.
 1.161  01-Dec-2016  knakahara fix two races between set_ip_addrs and clear_ip_addrs race.

(1) if set_ip_addrs and clear_ip_addrs run parallel, they can parallel call
IN_ADDRHASH_WRITER_REMOVE to the same ifa.
(2) if set_ip_addrs's workqueue is separated from clear_ip_addrs's one,
the workers can run in reverse order of enqueued.
 1.160  01-Dec-2016  knakahara fix CID 1396600: Null pointer dereferences
 1.159  25-Nov-2016  knakahara make workqueue sppp_{set,clear}_ip_addrs to be able to call pserialize_perform.
 1.158  25-Nov-2016  knakahara refactor sppp_{set,clear}_ip_addrs(). reduce iterating if_addr_pslist.
 1.157  18-Nov-2016  knakahara We must use PSLIST_ENTRY_DESTROY after PSLIST_WRITER_REMOVE and waiting all readers done.

And then, if we want to re-insert the removed pslist element, we need to
call PSLIST_ENTERY_INIT again.

advised by riastradh@n.o and reviewed by ozaki-r@n.o, thanks.
 1.156  08-Oct-2016  joerg Use uint8_t for opt as some of the values don't fit into the (positive)
range of a signed char.
 1.155  03-Oct-2016  ozaki-r Fix race condition on ifqueue used by traditional netisr

If a underlying network device driver supports MSI/MSI-X, RX interrupts
can be delivered to arbitrary CPUs. This means that Layer 2 subroutines
such as ether_input (softint) and subsequent Layer 3 subroutines (softint)
which are called via traditional netisr can be dispatched on an arbitrary
CPU. Layer 2 subroutines now run without any locks (expected) and so a
Layer 2 subroutine and a Layer 3 subroutine can run in parallel.

There is a shared data between a Layer 2 routine and a Layer 3 routine,
that is ifqueue and IF_ENQUEUE (from L2) and IF_DEQUEUE (from L3) on it
are racy now.

To fix the race condition, use ifqueue#ifq_lock to protect ifqueue
instead of splnet that is meaningless now.

The same race condition exists in route_intr. Fix it as well.

Reviewed by knakahara@
 1.154  29-Sep-2016  roy Set dstaddr in in_ifinit so that sppp consumers announce the correct
dstaddr in routing messages.
 1.153  29-Sep-2016  roy Ensure we only call pfil_run_hooks if if_init succeeded.
While here, improve improve some logging.
 1.152  16-Sep-2016  roy Drop hostIsNew from in_ifinit, let the function work out if the address
has changed.
Sync address flag setup with the IPv6 counterpart.
When scrubbing the address, or setting up the address fails, restore the
old address flags as well as the old address.
 1.151  14-Sep-2016  roy Call ifmedia_delete_instance() for safety.
 1.150  14-Sep-2016  roy Add interface media for sppp consumers.
While there is no actual media to select,
the ioctl is used to query link status from userland.
 1.149  13-Sep-2016  joerg Report link state changes for sppp consumers. The link is considered up,
if the current phase is SPPP_PHASE_NETWORK, otherwise it is down. Useful
when using dhcpcd for DHCPv6 PD.
 1.148  09-Sep-2016  christos PR/51464: Shoichi YAMAGUCHI: chap authenticator of pppoe does not work
 1.147  06-Aug-2016  pgoyette Modularize the sppp_subr stuff so it can be shared by pppoe and lmc
drivers as they get modularized.
 1.146  07-Jul-2016  ozaki-r branches: 1.146.2;
Switch the address list of intefaces to pslist(9)

As usual, we leave the old list to avoid breaking kvm(3) users.
 1.145  06-Jul-2016  ozaki-r Add and use pslist(9)-based hashtable for IPv4 addresses

Note that we leave the old hashtable to keep vmstat -H working.
 1.144  30-Jun-2016  ozaki-r Make sure that ifaddr is published after its initialization finished

Basically we should insert an item to a collection (say a list) after
item's initialization has been completed to avoid accessing an item
that is initialized halfway. ifaddr (in{,6}_ifaddr) isn't processed
like so and needs to be fixed.

In order to do so, we need to tweak {arp,nd6}_rtrequest that depend
on that an ifaddr is inserted during its initialization; they explore
interface's address list to determine that rt_getkey(rt) of a given
rtentry is in the list to know whether the route's interface should
be a loopback, which doesn't work after the change. To make it work,
first check RTF_LOCAL flag that is set in rt_ifa_addlocal that calls
{arp,nd6}_rtrequest eventually. Note that we still need the original
code for the case to remove and re-add a local interface route.
 1.143  20-Jun-2016  knakahara apply if_start_lock() to L2 callers which call ifp->if_start() of device derivers
 1.142  10-Jun-2016  ozaki-r Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.141  28-Apr-2016  ozaki-r Constify rtentry of if_output

We no longer need to change rtentry below if_output.

The change makes it clear where rtentries are changed (or not)
and helps forthcoming locking (os psrefing) rtentries.
 1.140  24-Apr-2016  christos CID 1210544: Tainted scalar
 1.139  24-Apr-2016  christos CID 980345: missing breaks
 1.138  24-Apr-2016  christos CID 980057, 980058, use strlcpy()
 1.137  23-Apr-2016  martin Add missing breaks (cosmetic change only)
 1.136  20-Apr-2016  knakahara IFQ_ENQUEUE refactor (3/3) : eliminate pktattr argument from IFQ_ENQUEUE caller
 1.135  20-Aug-2015  christos include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.
 1.134  25-May-2015  ozaki-r Remove leftover IPX-related stuffs

No objection on tech-kern and tech-net.
 1.133  02-May-2015  roy Add IPv4 address flags IN_IFF_TENTATIVE, IN_IFF_DUPLICATED and
IN_IFF_DETATCHED to mimic the IPv6 address behaviour.
Add SIOCGIFAFLAG_IN ioctl to retrieve the address flag via the
ifreq structure.
Add IPv4 DAD detection via the ARP methods described in RFC 5227.
Add sysctls net.inet.ip.dad_count and net.inet.arp.debug.

Discussed on tech-net@
 1.132  20-Apr-2015  roy Introduce p2p_rtrequest() so that IFF_POINTOPOINT interfaces can work
with RTF_LOCAL.
Fixes PR kern/49829.
 1.131  28-Nov-2014  ozaki-r branches: 1.131.2;
Remove dead codes and make if_free_sadl static

No functional change.
 1.130  06-Jun-2014  rmind branches: 1.130.2; 1.130.6;
sppp_input: handle pktqueue case correctly (fix for the previous).
 1.129  05-Jun-2014  rmind - 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.
 1.128  15-May-2014  msaitoh Save a NETISR_* value in a variable and call schednetisr() after enqueue
a packet for readability and future modification.
 1.127  29-Jun-2013  rmind branches: 1.127.4;
- 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.
 1.126  01-Mar-2013  joerg branches: 1.126.6;
Retire OSI network stack. OK core@
 1.125  17-Dec-2011  tls branches: 1.125.6;

Separate /dev/random pseudodevice implemenation from kernel entropy pool
implementation. Rewrite pseudodevice code to use cprng_strong(9).

The new pseudodevice is cloning, so each caller gets bits from a stream
generated with its own key. Users of /dev/urandom get their generators
keyed on a "best effort" basis -- the kernel will rekey generators
whenever the entropy pool hits the high water mark -- while users of
/dev/random get their generators rekeyed every time key-length bits
are output.

The underlying cprng_strong API can use AES-256 or AES-128, but we use
AES-128 because of concerns about related-key attacks on AES-256. This
improves performance (and reduces entropy pool depletion) significantly
for users of /dev/urandom but does cause users of /dev/random to rekey
twice as often.

Also fixes various bugs (including some missing locking and a reseed-counter
overflow in the CTR_DRBG code) found while testing this.

For long reads, this generator is approximately 20 times as fast as the
old generator (dd with bs=64K yields 53MB/sec on 2Ghz Core2 instead of
2.5MB/sec) and also uses a separate mutex per instance so concurrency
is greatly improved. For reads of typical key sizes for modern
cryptosystems (16-32 bytes) performance is about the same as the old
code: a little better for 32 bytes, a little worse for 16 bytes.
 1.124  19-Nov-2011  tls branches: 1.124.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.123  28-Oct-2011  dyoung branches: 1.123.2;
For these interfaces, the implementation of SIOCSIFDSTADDR is identical
to SIOCINITIFADDR, and SIOCSIFDSTADDR callers always fall back to
SIOCINITIFADDR, so just get rid of the SIOCSIFDSTADDR case.
 1.122  05-Sep-2011  rjs Add support for RFC 4638 to pppoe(4).

The change to if_spppsubr.c moves the test for whether LCP should
request a mru change until after the pppoe device has picked up the
mtu of the underlying ethernet device.
 1.121  17-Jul-2011  joerg Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.120  20-Apr-2010  jmcneill COMPAT_50 support for SPPP[GS]ETIDLETO and SPPP[GS]ETKEEPALIVE, ok martin@
 1.119  28-Feb-2010  snj branches: 1.119.2;
Fight the ever-increasing size of src checkouts by spelling "useful"
without an extra l.
 1.118  18-Apr-2009  tsutsui branches: 1.118.2;
Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
 1.117  18-Mar-2009  cegger bcopy -> memcpy
 1.116  13-Nov-2008  martin branches: 1.116.4;
Pass SIOCAIFADDR to ifioctl_common, fixes PR kern/39900.
 1.115  07-Nov-2008  dyoung *** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.114  03-Oct-2008  pooka branches: 1.114.2;
Fix pointer size typo - affects only debug output.

Henning Petersen, PR lib/39689
 1.113  22-Aug-2008  martin Backout previous/restore initial fix for PR kern/39280.
The later changes were only cosmetic, cause problems in IPv6-only-
connections (reported by Wolfgang Solfrank in private mail), as well
as reintroducing the original bug again.
 1.112  04-Aug-2008  christos keep the loop, but arrange IDX_COUNT to be correct.
 1.111  04-Aug-2008  martin PR kern/39280: Uninitialized callout stopped in if_spppsubr layer
in kernels without options INET6.
 1.110  24-Jun-2008  gmcgarry branches: 1.110.2;
ioctl commands are unsigned long.
 1.109  20-Feb-2008  matt branches: 1.109.6; 1.109.10; 1.109.12; 1.109.14;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)
 1.108  07-Feb-2008  dyoung Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.107  25-Dec-2007  perry Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.106  09-Jul-2007  ad branches: 1.106.8; 1.106.14; 1.106.16; 1.106.20;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.105  23-Jun-2007  scw If the underlying link's MTU is less than PP_MTU (e.g. PPPoE), set our
MRU to the link's MTU and initiate an MRU negotiation with the peer.

This is useful when the PPP session is bridged from Ethernet to ATM
by an ADSL modem (such as the Linksys AM200). Unless we negotiate the
lower MRU, the peer is unaware that 1500-byte packets will not make
it umolested across the link (the Linksys AM200 silently truncates them
to 1498 bytes, creating a nice PMTU blackhole).

Note that the PPP RFC says peers MUST accept 1500 byte packets,
regardless of the negotiated MRU, so most ISPs which use PPPoA will
probably still send 1500-byte packets. However, I persuaded my ISP
(Andrews and Arnold) to modify their software to generate an ICMP error
"fragment needed" for packets with IP.DF set which are larger than the
negotiated MRU. They will still forward non-IP.DF packets, with the
associated truncation, but at least my PMTU troubles have gone.
 1.104  04-Mar-2007  christos branches: 1.104.2; 1.104.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.103  17-Feb-2007  dyoung KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous
parentheses in return statements.

Cosmetic: don't open-code TAILQ_FOREACH().

Cosmetic: change types of variables to avoid oodles of casts: in
in6_src.c, avoid casts by changing several route_in6 pointers
to struct route pointers. Remove unnecessary casts to caddr_t
elsewhere.

Pave the way for eliminating address family-specific route caches:
soon, struct route will not embed a sockaddr, but it will hold
a reference to an external sockaddr, instead. We will set the
destination sockaddr using rtcache_setdst(). (I created a stub
for it, but it isn't used anywhere, yet.) rtcache_free() will
free the sockaddr. I have extracted from rtcache_free() a helper
subroutine, rtcache_clear(). rtcache_clear() will "forget" a
cached route, but it will not forget the destination by releasing
the sockaddr. I use rtcache_clear() instead of rtcache_free()
in rtcache_update(), because rtcache_update() is not supposed
to forget the destination.

Constify:

1 Introduce const accessor for route->ro_dst, rtcache_getdst().

2 Constify the 'dst' argument to ifnet->if_output(). This
led me to constify a lot of code called by output routines.

3 Constify the sockaddr argument to protosw->pr_ctlinput. This
led me to constify a lot of code called by ctlinput routines.

4 Introduce const macros for converting from a generic sockaddr
to family-specific sockaddrs, e.g., sockaddr_in: satocsin6,
satocsin, et cetera.
 1.102  24-Nov-2006  wiz branches: 1.102.2; 1.102.4; 1.102.6;
Correct spelling of "immediate(ly)". From Zafer.
 1.101  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.100  26-Oct-2006  elad Kill a couple of KAUTH_GENERIC_ISSUSER usages.

I had to refactor the code a bit, I hope it's okay.
 1.99  13-Oct-2006  dogcow More -Wunused fallout. sprinkle __unused when possible; otherwise, use the
do { if (&x) {} } while (/* CONSTCOND */ 0);
construct as suggested by uwe in <20061012224845.GA9449@snark.ptc.spbu.ru>.
 1.98  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.97  07-Sep-2006  dogcow branches: 1.97.2; 1.97.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.
 1.96  23-Aug-2006  adrianp A problem has been identified in the in-kernel PPP code shared by ISDN PPP
interfaces ippp(4) and pppoe(4). Insufficient checking of options presented
by the peer may cause writing of copies of the malicious input beyond the
end of a buffer allocated for that purpose.

Issue found by pavel@
Fix from martin@

This is SA2006-019 (CVE-2006-4304)
 1.95  23-Jul-2006  ad branches: 1.95.2;
Use the LWP cached credentials where sane.
 1.94  13-Jul-2006  martin Small simplification, pointed out by Christian Hattemer in private mail.
 1.93  13-Jul-2006  martin Do not automagically UP the interface when setting the address.
Together with previous ifconfig changes, this fixes PR 30694, at
least for pppoe (and other sppp based) interfaces.
 1.92  07-Jun-2006  kardel branches: 1.92.2;
merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.91  21-May-2006  christos Fixes from David Boggs; in his words:

/sys/net/if_spppvar.h says:

"Lower layer drivers that are always ready to communicate
(like hardware HDLC) can shortcut pp_up from pp_tls,
and pp_down from pp_tlf."

When I follow those instructions, I get a kernel stack
overflow as soon as I open the HDLC device.

Here is the loop:
sppp_ioctl calls sppp_lcp_open
sppp_lcp_open calls sppp_open_event
sppp_open_event calls sppp_lcp_tls
sppp_lcp_tls calls pp_tls
pp_tls is the SHORTCUT to sppp_lcp_up
sppp_lcp_up calls spp_lcp_open
...and around we go until the stack overflows.

The fix is to reverse the order of the action (tls)
and the state change (from INITIAL to STARTING) in
sppp_open_event.

There is a similar loop during closing:
sppp_ioctl calls sppp_lcp_close
sppp_lcp_close calls sppp_close_event
spp_close_event calls sppp_lcp_tlf
sppp_lcp_tlf calls pp_tlf
pp_tlf is the SHORTCUT to sppp_lcp_down
sppp_lcp_down calls sppp_lcp_close
...and around we go until the stack overflows.

The fix is to reverse the order of the action (tlf)
and the state change (from STARTING to INITIAL) in
sppp_close_event.

Separately, while I was discovering this, I noticed
that pp_tlf was being called unconditionally rather
than first checking to see if it is NULL. pp_tlf
is a callout from sppp to the hdlc device driver.
Elsewhere in sppp, this is always checked for NULL
before calling it, and the comments in if_spppvar.h
imply that filling it in is optional.

From spppvar.h:
"These functions need to be filled in by the lower layer
(hardware) drivers if they request notification from the
PPP layer whether the link is actually required."
This clearly says that pp_tlf and pp_tls are optional
and so sppp must check before calling them.
 1.90  14-May-2006  elad branches: 1.90.2;
integrate kauth.
 1.89  14-May-2006  christos XXX: GCC uninitialized.
 1.88  20-Apr-2006  christos Add an empty attach function. Reported by David Boggs
 1.87  21-Jan-2006  rpaulo branches: 1.87.2; 1.87.4; 1.87.6; 1.87.8; 1.87.10;
Better support of IPv6 scoped addresses.

- most of the kernel code will not care about the actual encoding of
scope zone IDs and won't touch "s6_addr16[1]" directly.
- similarly, most of the kernel code will not care about link-local
scoped addresses as a special case.
- scope boundary check will be stricter. For example, the current
*BSD code allows a packet with src=::1 and dst=(some global IPv6
address) to be sent outside of the node, if the application do:
s = socket(AF_INET6);
bind(s, "::1");
sendto(s, some_global_IPv6_addr);
This is clearly wrong, since ::1 is only meaningful within a single
node, but the current implementation of the *BSD kernel cannot
reject this attempt.
- and, while there, don't try to remove the ff02::/32 interface route
entry in in6_ifdetach() as it's already gone.

This also includes some level of support for the standard source
address selection algorithm defined in RFC3484, which will be
completed on in the future.

From the KAME project via JINMEI Tatuya.
Approved by core@.
 1.86  11-Dec-2005  christos branches: 1.86.2;
merge ktrace-lwp.
 1.85  29-May-2005  christos branches: 1.85.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.
 1.84  27-Apr-2005  martin Fix typo, from C. Plasschaert in PR kern/30069.
 1.83  31-Mar-2005  christos factor out the interface queueing code into two functions. One used by
the non point-to-point interfaces that has one queue, and one used by
the point to point interfaces that has two queues. No functional changes.
XXX: The ALTQ stuff makes the code ugly.
XXX: More cleanup to come
 1.82  26-Feb-2005  perry branches: 1.82.2; 1.82.4;
nuke trailing whitespace
 1.81  24-Jan-2005  matt branches: 1.81.2;
Add IFNET_FOREACH and IFADDR_FOREACH macros and start using them.
 1.80  22-Dec-2004  itojun branches: 1.80.2;
whitespace
 1.79  06-Dec-2004  christos Sprinkle #ifdef INET to make a GENERIC kernel compile with INET undefined.
 1.78  18-Sep-2004  yamt call PFIL_IFADDR hooks where appropriate.
 1.77  21-Apr-2004  itojun sprintf -> snprintf
 1.76  08-Apr-2004  martin Be more paranoid about data a non-root user may query.
Fixes PR kern/25099 by Christian Biere.
 1.75  26-Dec-2003  martin branches: 1.75.2;
Add a new ioctl SPPPGETSTATUSNCP to query the PPP phase and check wether
any NCP is UP.
 1.74  10-Nov-2003  wiz Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.
 1.73  28-Oct-2003  mycroft Fix previous differently.
 1.72  26-Oct-2003  christos Fix uninitialized variable warnings.`
 1.71  03-Oct-2003  oki Correct debug message, mine is myauth, not hisauth.
 1.70  02-Oct-2003  itojun minor KNF
 1.69  05-Sep-2003  itojun u_short -> u_int16_t
 1.68  03-Sep-2003  martin Rearange dead link detection slightly:
As long as we receive data from the peer, don't worry. When we have not
received anything within the "max_noreceive" period, we start sending LCP
echo requests and count them, until we receive an answer (or some data)
or the "maxalive" count of not answered echo requests is reached.
All this is checked at a global 10 seconds interval for all interfaces.
The "max_noreceive" period and the "maxalive" count are configurable per
interface.
 1.67  09-Jul-2003  martin We should use IFQ_DEQUEUE to get packets from the send queue, not IF_DEQUEUE.
Hopefully this will fix ALTQ for ISDN and PPPoE interfaces.

While there remove an unsued function which contained dubious code
(accessing interface queue internals w/o the proper macros).
 1.66  23-May-2003  itojun branches: 1.66.2;
don't call if_free_sadl() until very end of if_detach() logic. many of
routing table manipulation code assumes the presense of AF_LINK sockaddr.
should fix PR 21581
 1.65  14-May-2003  itojun use arc4random
 1.64  14-May-2003  itojun remove #ifdef __FreeBSD__ (code already diverged enough)
 1.63  28-Jan-2003  tron Use MRU negotiated with remote system as MTU. This fixes PR kern/18850
by Curt Sampson.
 1.62  19-Jan-2003  simonb Remove a break after a goto.
 1.61  28-Dec-2002  kristerw Restore the system priority level in case of errors.

OK:ed by martin.
 1.60  27-Sep-2002  itojun license clarification from the author, via openbsd
>BSD-style license from Serge Vakulenko <vak@cronyx.ru>
 1.59  25-Sep-2002  itojun KNF
 1.58  11-Sep-2002  itojun KNF - return is not a function.
 1.57  01-Sep-2002  martin If the peer did not answer LCP echo requests in-time, but we got user
data through within the last LCP keepalive interval, do not count this
as a keepalive failure.

Addresses parts of kern/17723.
 1.56  30-Jul-2002  christos Fix async map handling. Many thanks to Joerg Wunsch for the explanation.
 1.55  28-Jul-2002  christos Patches from Frank Kardel:
- length was one off in names and secrets.
- add win 98 kludge but we keep it disabled for now.
- setup the authorization bit early so that we don't end up doing ppp
negotiations without authorization.
 1.54  28-Jul-2002  christos Don't throw away the name and the secret lengths. This eliminates all the
strlen() calls, and there was a whole bunch of them.
 1.53  28-Jul-2002  christos avoid modifying the buffers, by checking for matching lengths first. From
Frank Kardel.
 1.52  27-Jul-2002  christos Use strcmp() instead of memcmp() because if we get passed a 0 length name
and secret, we'll authenticate successfully! While there, rename passwd to
secret so that code looks nicer.
 1.51  13-Jul-2002  martin Use "mono_time" instead of "time" for timeout calculations.
 1.50  11-Jul-2002  yamt don't access freed memory.
 1.49  11-Jul-2002  yamt don't access freed memory.
 1.48  06-Jul-2002  itojun correct tcp header chasing in pp_fastq processing. should fix kern/17491.
 1.47  29-May-2002  itojun don't panic on invalid CONF_ACK from remote (in general, issueing panic
on remote input is bad practice)
 1.46  29-Apr-2002  martin branches: 1.46.2; 1.46.4;
"if (debug)" some log messages not signaling real errors but happening
in normal operation.
 1.45  02-Mar-2002  martin Add support to query the peer for DNS addreses when negotiating IPCP.
Add ioctls to retrieve the results.

While here remove a malloc()/free() of an unused buffer.
 1.44  10-Feb-2002  martin Use IF_IS_EMPTY and IFQ_IS_EMPTY instead of accessing queue members
directly. Noticed by Thomas Klausner.
 1.43  21-Jan-2002  martin Fix copy&pasto: truncate strings copied in at *their* right length, not
some other strings length.

Found by Arne Helme.
 1.42  18-Jan-2002  jdolecek couple cosmetic style fixes, and drop ^L's
 1.41  15-Jan-2002  martin Make fields in ioctl parameters that are not allowed to be negative u_ints.
Better range & sanity checking for ioctl arguments (thanks, Jaromir!)
 1.40  14-Jan-2002  martin Initialize the activity timestamp when opening a connection. Only idle-
timeout connection that made it to phase NETWORK yet. (For drivers using
the internal timeout mechanism; isdnd, that does the timeout handling for
ISDN drivers, still needs to be fixed.)

Thanks to Wolfgang Solfrank for finding this.
 1.39  07-Jan-2002  martin Implement a retry counter for failed authorizations and limit it to
a configurable maximum (default: 5).

Some ISPs shut down accounts (at least temporarily) after to many bad
retries. This hit me recently due to a stupid pilot error and the fast
retry rate.
 1.38  06-Jan-2002  martin Implement an activity timestamp, recording the last time payload data
passed through.

Implement optional idle timeout.
 1.37  05-Jan-2002  thorpej Fix LP64 printf format problem.
 1.36  04-Jan-2002  martin Move net/if_sppp.h to net/if_spppvar.h, create a new net/if_sppp.h
containing the userland visible thinks (i.e. ioctl definitions).

Remove all (both) old ioctls, as they had a brain dead API and made keeping
binary compatibility more or less impossible.

Replace by several new ioctls. While there, remove any arbitrary limits
(resulting from the old, broken ioctls) and allow any length of names
and passwords.
 1.35  16-Dec-2001  martin Remove yet another spurious (debug?) output.
 1.34  16-Dec-2001  martin Remove some spurious (debug?) output.
 1.33  15-Dec-2001  martin Make reconnects after LCP keepalive detected an error actually work.
 1.32  10-Dec-2001  martin We explicitly close LCP when going to state CLOSED, so we better open
it again when going from INITIAL to STARTING. This has been done for
passive or auto-conecting interfaces always, but not for permanent
ones.

This fixes session reestablishement for PPPoE interfaces without LINK1 set,
and probably also closes PR kern/11161.

Thanks to Jared D. McNeill and Ross Harvey for sugesting debug methology.
 1.31  08-Dec-2001  martin Change the way IPCP negotiation is handled.

Collect both local and remote address and set them to the interface in
one step (the peer adress was not set at all before).

This causes the peer address now to show up on the interface and all
messages to the routing socket to be send with correct data. The latter
has been the last missing piece to complete PPPoE support.
 1.30  04-Dec-2001  ross code cleanup for portability
 1.29  12-Nov-2001  lukem add RCSIDs
 1.28  05-Nov-2001  matt Switch to using queue access macros instead of refering to the member
fields explicitly.
 1.27  29-Oct-2001  martin In preparation for further changes: remove big parts of the ifdef mess
for OSes we no longer share this file with.
 1.26  23-Aug-2001  itojun branches: 1.26.4;
IFQ_PURGE cannot be used against ifqueue. use IF_PURGE.
 1.25  18-Jul-2001  thorpej bzero -> memset
 1.24  17-Jul-2001  martin Fix a slight bug introduced with revision 1.9 (IPv6 integration) where
the bit mask of open NCPs got out of sync.
Defer the (potential) closing of LCP after a NCP went down until after
the state machines got updated.

This fixes PR kern/11161.
 1.23  13-Apr-2001  thorpej branches: 1.23.2;
Remove the use of splimp() from the NetBSD kernel. splnet()
and only splnet() is allowed for the protection of data structures
used by network devices.
 1.22  09-Apr-2001  martin Add another option for encapsulation: PP_NOFRAMING.
In this mode, the PPP packets start with the protocol identifier and don't
have any explicit framing (which may be added by the lower level driver).

Make input/output statistics a little bit more correct by adding a hardware
driver adjustable framing length for each packet (instead of the constant
value "3" used before).

While there, bump authentication name length from 32 to 48 (I have a
connection where I need more than 32). XXX - this should not be artificialy
limited at all.
 1.21  25-Mar-2001  martin Make the 'cmd' argument to ioctl an unsigned long, as it is everywhere
else.
 1.20  17-Jan-2001  thorpej branches: 1.20.2;
Fix a rather annoying problem where the sockaddr_dl which holds
the link level name for the interface (ifp->if_sadl) is allocated
before ifp->if_addrlen is initialized, which could lead to allocating
too little space for the link level address.

Do this by splitting allocation of the link level name out of
if_attach() and into if_alloc_sadl(), which is normally called
by functions like ether_ifattach(). Network interfaces which
don't have a link-specific attach routine must call if_alloc_sadl()
themselves (example: gif).

Link level names are freed by if_free_sadl(), which can be called
from e.g. ether_ifdetach(). Drivers never need call if_free_sadl()
themselves as if_detach() will do it if it is not already done.

While here, add the ability to pass an AF_LINK address to
SIOCSIFADDR in ether_ioctl() (this is what caused me to notice
the problem that the above fixes).
 1.19  16-Jan-2001  itojun run IPCP only if we have IPv4 in kernel
 1.18  15-Jan-2001  martin Don't peek at part of a structure via fuword. Does not work well on
64bit architectures. XXX - have to check other changes in the I4B
distribution, this had been fixed there a long time ago.
 1.17  07-Jan-2001  martin 64bit police.
Rumors say there are archs without ISA busses, so avoid including
(uneccesarily) isa bus headers in MI files.
XXX this is the minimal solution, layer interface calls will have
XXX to be revisited later
 1.16  18-Dec-2000  thorpej Use IFQ_PURGE().
 1.15  13-Dec-2000  thorpej Add ALTQ glue.
 1.14  10-Oct-2000  itojun fix comment (s/IPv6/IP/)
 1.13  08-Oct-2000  itojun fix operator precedence (& and &&). do not transmit too much message
from LCP layer to NCP layer. PR 11161.
 1.12  02-Oct-2000  itojun fix compilation without INET
 1.11  02-Jul-2000  sommerfeld Merge if_spppsubr.c PPP protocol declarations list with the one found
in ppp_defs.h, and have if_spppsubr.c include ppp_defs.h rather than
duplicate its definitions.

[This is a stopgap measure to clean up build lossage.]
 1.10  16-May-2000  itojun branches: 1.10.4;
propose better IPv6 ifid alternative to the peer, when ifid collides
during IPv6CP negotiation. it is very rare to see collision.
 1.9  02-May-2000  itojun IPv6CP support. if IPv6 link-local address is configured to the interface,
the interface tries to negotiate ifid with the other end by using IPv6CP.

other changes:
- do not share ppp sequence number across protocols.
- if LCP proto-rej is received, drop the protocol mentioned by the message.
this is to be friendly with non-IPv6 peer (if the peer complains due to
lack of IPv6CP, drop IPv6CP). this basically implements "RXJ+" state
transition in the RFC.
- cleanup debugging message. always print blank just before message.

CAVEAT:
- if the peer uses the same MAC address as our side (pretty unlikely)
the code may go into req-rej loop.
- even though we negotiate ifid, we don't configure destination address
onto the interface. it is not really necessary to do so (IMHO).
- I've tested this code on a NetBSD 1.4.2 node, which was with fair amount
of modifications. not sure if the committed code does it right... (please
test and send reports)
 1.8  12-Apr-2000  itojun add more IPv6 cases. not tested.
TODO: IPv6CP support. currently IPv6 packet will be generated right
after link up (spec violation)
 1.7  23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.6  19-Nov-1999  thorpej Add the `packed' attribute to structures which describe wire protocol
data formats.
 1.5  30-Jul-1999  itojun branches: 1.5.2; 1.5.8;
remove reference to in6_systm.h (file itself will be removed afterwords)
 1.4  04-Apr-1999  explorer Add NetBSD rcsid tags, and preserve old ones from i4b source
 1.3  04-Apr-1999  explorer switch to the i4b version of if_sppp*.[ch] (with mods)
 1.2  25-Mar-1999  explorer branches: 1.2.2;
put RCS ids in the right place. And yes, this is a SYNC ppp interface,
used for high-speed (T1, HSSI, DS3) interfaces.
 1.1  25-Mar-1999  explorer port FreeBSD's serial ppp layer to NetBSD. The PPP part seems broken still,
but the lmc driver uses the HDLC bits from here anyway.
 1.2.2.1  04-Apr-1999  explorer branches: 1.2.2.1.2;
Pull up recent changes to if_sppp*.[ch] (i4b code) with RCS id fixes
 1.2.2.1.2.2  02-Aug-1999  thorpej Update from trunk.
 1.2.2.1.2.1  21-Jun-1999  thorpej Sync w/ -current.
 1.5.8.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.5.2.5  21-Apr-2001  bouyer Sync with HEAD
 1.5.2.4  27-Mar-2001  bouyer Sync with HEAD.
 1.5.2.3  18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.5.2.2  05-Jan-2001  bouyer Sync with HEAD
 1.5.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.10.4.2  29-Jul-2001  he Pull up revision 1.24 (requested by martin):
Fix bug causing NCP bit mask to get out of sync. Fixes PR#11161.
 1.10.4.1  17-Oct-2000  tv Pullup 1.13 [itojun]:
fix operator precedence (& and &&). do not transmit too much message
from LCP layer to NCP layer. PR 11161.
 1.20.2.17  29-Dec-2002  thorpej Sync with HEAD.
 1.20.2.16  18-Oct-2002  nathanw Catch up to -current.
 1.20.2.15  17-Sep-2002  nathanw Catch up to -current.
 1.20.2.14  01-Aug-2002  nathanw Catch up to -current.
 1.20.2.13  12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.20.2.12  24-Jun-2002  nathanw Curproc->curlwp renaming.

Change uses of "curproc->l_proc" back to "curproc", which is more like the
original use. Bare uses of "curproc" are now "curlwp".

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.20.2.11  20-Jun-2002  nathanw Catch up to -current.
 1.20.2.10  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.20.2.9  28-Feb-2002  nathanw Catch up to -current.
 1.20.2.8  01-Feb-2002  gmcgarry lwp'ify
 1.20.2.7  11-Jan-2002  nathanw More catchup.
 1.20.2.6  08-Jan-2002  nathanw Catch up to -current.
 1.20.2.5  14-Nov-2001  nathanw Catch up to -current.
 1.20.2.4  21-Sep-2001  nathanw Catch up to -current.
 1.20.2.3  24-Aug-2001  nathanw Catch up with -current.
 1.20.2.2  21-Jun-2001  nathanw Catch up to -current.
 1.20.2.1  09-Apr-2001  nathanw Catch up with -current.
 1.23.2.8  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.23.2.7  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.23.2.6  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.23.2.5  16-Mar-2002  jdolecek Catch up with -current.
 1.23.2.4  11-Feb-2002  jdolecek Sync w/ -current.
 1.23.2.3  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.23.2.2  25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.23.2.1  03-Aug-2001  lukem update to -current
 1.26.4.1  12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.46.4.19  10-Jul-2003  tron Pull up revision 1.67 via patch (requested by martin in ticket #1374):
We should use IFQ_DEQUEUE to get packets from the send queue, not IF_DEQUEUE.
Hopefully this will fix ALTQ for ISDN and PPPoE interfaces.
While there remove an unsued function which contained dubious code
(accessing interface queue internals w/o the proper macros).
 1.46.4.18  24-Jun-2003  grant Pull up revision 1.66 (requested by itojun in ticket #1325):

don't call if_free_sadl() until very end of if_detach() logic. many of
routing table manipulation code assumes the presense of AF_LINK sockaddr.
should fix PR 21581
 1.46.4.17  07-Feb-2003  tron Pull up revision 1.62 (requested by martin in ticket #1152):
Remove a break after a goto.
 1.46.4.16  07-Feb-2003  tron Pull up revision 1.61 (requested by martin in ticket #1152):
Restore the system priority level in case of errors.
OK:ed by martin.
 1.46.4.15  07-Feb-2003  tron Pull up revision 1.60 (requested by martin in ticket #1152):
license clarification from the author, via openbsd
BSD-style license from Serge Vakulenko <vak@cronyx.ru>
 1.46.4.14  07-Feb-2003  tron Pull up revision 1.59 (requested by martin in ticket #1152):
KNF
 1.46.4.13  07-Feb-2003  tron Pull up revision 1.58 (requested by martin in ticket #1152):
KNF - return is not a function.
 1.46.4.12  07-Feb-2003  tron Pull up revision 1.57 (requested by martin in ticket #1152):
If the peer did not answer LCP echo requests in-time, but we got user
data through within the last LCP keepalive interval, do not count this
as a keepalive failure.
Addresses parts of kern/17723.
 1.46.4.11  07-Feb-2003  tron Pull up revision 1.56 (requested by martin in ticket #1152):
Fix async map handling. Many thanks to Joerg Wunsch for the explanation.
 1.46.4.10  07-Feb-2003  tron Pull up revision 1.51 (requested by martin in ticket #1152):
Use "mono_time" instead of "time" for timeout calculations.
 1.46.4.9  07-Feb-2003  tron Pull up revision 1.50 (requested by martin in ticket #1152):
don't access freed memory.
 1.46.4.8  07-Feb-2003  tron Pull up revision 1.49 (requested by martin in ticket #1152):
don't access freed memory.
 1.46.4.7  07-Feb-2003  tron Pull up revision 1.47 (requested by martin in ticket #1152):
don't panic on invalid CONF_ACK from remote (in general, issueing panic
on remote input is bad practice)
 1.46.4.6  28-Jan-2003  jmc Pullup revisions 1.62-1.63 (requested by tron in ticket #1133)
Use MRU negotiated with remote system as MTU. Fixes PR#18850.
 1.46.4.5  10-Jan-2003  jmc Pull up revisions 1.47-1.48 (requested by tron in ticket #1061)
correct tcp header chasing in pp_fastq processing. should fix kern/17491.
 1.46.4.4  17-Aug-2002  lukem Pull up revision 1.55 (requested by groo in ticket #669):
Patches from Frank Kardel:
- length was one off in names and secrets.
- add win 98 kludge but we keep it disabled for now.
- setup the authorization bit early so that we don't end up doing ppp
negotiations without authorization.
 1.46.4.3  17-Aug-2002  lukem Pull up revision 1.54 (requested by groo in ticket #669):
Don't throw away the name and the secret lengths. This eliminates all the
strlen() calls, and there was a whole bunch of them.
 1.46.4.2  17-Aug-2002  lukem Pull up revision 1.53 (requested by groo in ticket #669):
avoid modifying the buffers, by checking for matching lengths first. From
Frank Kardel.
 1.46.4.1  17-Aug-2002  lukem Pull up revision 1.52 (requested by groo in ticket #669):
Use strcmp() instead of memcmp() because if we get passed a 0 length name
and secret, we'll authenticate successfully! While there, rename passwd to
secret so that code looks nicer.
 1.46.2.3  29-Aug-2002  gehenna catch up with -current.
 1.46.2.2  15-Jul-2002  gehenna catch up with -current.
 1.46.2.1  30-May-2002  gehenna Catch up with -current.
 1.66.2.10  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.66.2.9  01-Apr-2005  skrll Sync with HEAD.
 1.66.2.8  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.66.2.7  04-Feb-2005  skrll Sync with HEAD.
 1.66.2.6  17-Jan-2005  skrll Sync with HEAD.
 1.66.2.5  18-Dec-2004  skrll Sync with HEAD.
 1.66.2.4  24-Sep-2004  skrll Sync with HEAD.
 1.66.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.66.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.66.2.1  03-Aug-2004  skrll Sync with HEAD
 1.75.2.2  23-Aug-2006  tron Pull up following revision(s) (requested by adrianp in ticket #10677):
sys/net/if_spppsubr.c: revision 1.96
A problem has been identified in the in-kernel PPP code shared by ISDN PPP
interfaces ippp(4) and pppoe(4). Insufficient checking of options presented
by the peer may cause writing of copies of the malicious input beyond the
end of a buffer allocated for that purpose.
Issue found by pavel@
Fix from martin@
This is SA2006-019 (CVE-2006-4304)
 1.75.2.1  08-Apr-2004  jdc branches: 1.75.2.1.2; 1.75.2.1.4;
Pull up revision 1.76 (requested by martin in ticket #98)

Be more paranoid about data a non-root user may query.
Fixes PR kern/25099 by Christian Biere.
 1.75.2.1.4.1  23-Aug-2006  tron Pull up following revision(s) (requested by adrianp in ticket #10677):
sys/net/if_spppsubr.c: revision 1.96
A problem has been identified in the in-kernel PPP code shared by ISDN PPP
interfaces ippp(4) and pppoe(4). Insufficient checking of options presented
by the peer may cause writing of copies of the malicious input beyond the
end of a buffer allocated for that purpose.
Issue found by pavel@
Fix from martin@
This is SA2006-019 (CVE-2006-4304)
 1.75.2.1.2.1  23-Aug-2006  tron Pull up following revision(s) (requested by adrianp in ticket #10677):
sys/net/if_spppsubr.c: revision 1.96
A problem has been identified in the in-kernel PPP code shared by ISDN PPP
interfaces ippp(4) and pppoe(4). Insufficient checking of options presented
by the peer may cause writing of copies of the malicious input beyond the
end of a buffer allocated for that purpose.
Issue found by pavel@
Fix from martin@
This is SA2006-019 (CVE-2006-4304)
 1.80.2.1  29-Apr-2005  kent sync with -current
 1.81.2.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.82.4.1  23-Aug-2006  tron Pull up following revision(s) (requested by adrianp in ticket #1476):
sys/net/if_spppsubr.c: revision 1.96
A problem has been identified in the in-kernel PPP code shared by ISDN PPP
interfaces ippp(4) and pppoe(4). Insufficient checking of options presented
by the peer may cause writing of copies of the malicious input beyond the
end of a buffer allocated for that purpose.
Issue found by pavel@
Fix from martin@
This is SA2006-019 (CVE-2006-4304)
 1.82.2.2  15-Jun-2007  liamjfoy Pull up following revision(s) (requested by msaitoh in ticket #1802):
sys/net/if_spppsubr.c 1.93-1.94

Do not automagically UP the interface when setting the address.
This is the interface level (e.g. pppoe) fix for PR 30694.
 1.82.2.1  23-Aug-2006  tron Pull up following revision(s) (requested by adrianp in ticket #1476):
sys/net/if_spppsubr.c: revision 1.96
A problem has been identified in the in-kernel PPP code shared by ISDN PPP
interfaces ippp(4) and pppoe(4). Insufficient checking of options presented
by the peer may cause writing of copies of the malicious input beyond the
end of a buffer allocated for that purpose.
Issue found by pavel@
Fix from martin@
This is SA2006-019 (CVE-2006-4304)
 1.85.2.7  27-Feb-2008  yamt sync with head.
 1.85.2.6  11-Feb-2008  yamt sync with head.
 1.85.2.5  21-Jan-2008  yamt sync with head
 1.85.2.4  03-Sep-2007  yamt sync with head.
 1.85.2.3  26-Feb-2007  yamt sync with head.
 1.85.2.2  30-Dec-2006  yamt sync with head.
 1.85.2.1  21-Jun-2006  yamt sync with head.
 1.86.2.1  01-Feb-2006  yamt sync with head.
 1.87.10.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.87.8.4  11-May-2006  elad sync with head
 1.87.8.3  06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.87.8.2  10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.87.8.1  08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.87.6.5  14-Sep-2006  yamt sync with head.
 1.87.6.4  03-Sep-2006  yamt sync with head.
 1.87.6.3  11-Aug-2006  yamt sync with head
 1.87.6.2  26-Jun-2006  yamt sync with head.
 1.87.6.1  24-May-2006  yamt sync with head.
 1.87.4.3  01-Jun-2006  kardel Sync with head.
 1.87.4.2  22-Apr-2006  simonb Sync with head.
 1.87.4.1  04-Feb-2006  simonb Adapt for timecounters: mostly use get*time(), use bintime's for timeout
calculations and use "time_second" instead of "time.tv_sec".
 1.87.2.1  09-Sep-2006  rpaulo sync with head
 1.90.2.1  19-Jun-2006  chap Sync with head.
 1.92.2.1  13-Jul-2006  gdamore Merge from HEAD.
 1.95.2.1  23-Aug-2006  tron Pull up following revision(s) (requested by adrianp in ticket #55):
sys/net/if_spppsubr.c: revision 1.96
A problem has been identified in the in-kernel PPP code shared by ISDN PPP
interfaces ippp(4) and pppoe(4). Insufficient checking of options presented
by the peer may cause writing of copies of the malicious input beyond the
end of a buffer allocated for that purpose.
Issue found by pavel@
Fix from martin@
This is SA2006-019 (CVE-2006-4304)
 1.97.4.2  10-Dec-2006  yamt sync with head.
 1.97.4.1  22-Oct-2006  yamt sync with head
 1.97.2.2  12-Jan-2007  ad Sync with head.
 1.97.2.1  18-Nov-2006  ad Sync with head.
 1.102.6.1  04-Sep-2008  skrll Sync with netbsd-4.
 1.102.4.2  12-Mar-2007  rmind Sync with HEAD.
 1.102.4.1  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.102.2.1  20-Aug-2008  bouyer Pull up following revision(s) (requested by martin in ticket #1185):
sys/net/if_spppsubr.c: revision 1.111
PR kern/39280: Uninitialized callout stopped in if_spppsubr layer
in kernels without options INET6.
 1.104.4.1  11-Jul-2007  mjf Sync with head.
 1.104.2.2  15-Jul-2007  ad Sync with head.
 1.104.2.1  01-Jul-2007  ad Adapt to callout API change.
 1.106.20.1  02-Jan-2008  bouyer Sync with HEAD
 1.106.16.1  26-Dec-2007  ad Sync with head.
 1.106.14.1  18-Feb-2008  mjf Sync with HEAD.
 1.106.8.2  23-Mar-2008  matt sync with HEAD
 1.106.8.1  09-Jan-2008  matt sync with HEAD
 1.109.14.1  27-Jun-2008  simonb Sync with head.
 1.109.12.2  10-Oct-2008  skrll Sync with HEAD.
 1.109.12.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.109.10.3  11-Aug-2010  yamt sync with head.
 1.109.10.2  11-Mar-2010  yamt sync with head
 1.109.10.1  04-May-2009  yamt sync with head.
 1.109.6.4  17-Jan-2009  mjf Sync with HEAD.
 1.109.6.3  05-Oct-2008  mjf Sync with HEAD.
 1.109.6.2  28-Sep-2008  mjf Sync with HEAD.
 1.109.6.1  29-Jun-2008  mjf Sync with HEAD.
 1.110.2.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.110.2.1  19-Oct-2008  haad Sync with HEAD.
 1.114.2.2  28-Apr-2009  skrll Sync with HEAD.
 1.114.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.116.4.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.118.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.119.2.1  30-May-2010  rmind sync with head
 1.123.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.123.2.1  17-Apr-2012  yamt sync with head
 1.124.2.1  18-Feb-2012  mrg merge to -current.
 1.125.6.3  03-Dec-2017  jdolecek update from HEAD
 1.125.6.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.125.6.1  23-Jun-2013  tls resync from head
 1.126.6.2  18-May-2014  rmind sync with head
 1.126.6.1  28-Aug-2013  rmind sync with head
 1.127.4.1  10-Aug-2014  tls Rebase.
 1.130.6.1  18-Jan-2017  skrll Sync with netbsd-5
 1.130.2.1  25-Sep-2016  bouyer Pull up following revision(s) (requested by joerg in ticket #1254):
sys/net/if_spppsubr.c: revision 1.149
Report link state changes for sppp consumers. The link is considered up,
if the current phase is SPPP_PHASE_NETWORK, otherwise it is down. Useful
when using dhcpcd for DHCPv6 PD.
 1.131.2.9  28-Aug-2017  skrll Sync with HEAD
 1.131.2.8  05-Feb-2017  skrll Sync with HEAD
 1.131.2.7  05-Dec-2016  skrll Sync with HEAD
 1.131.2.6  05-Oct-2016  skrll Sync with HEAD
 1.131.2.5  09-Jul-2016  skrll Sync with HEAD
 1.131.2.4  29-May-2016  skrll Sync with HEAD
 1.131.2.3  22-Apr-2016  skrll Sync with HEAD
 1.131.2.2  22-Sep-2015  skrll Sync with HEAD
 1.131.2.1  06-Jun-2015  skrll Sync with HEAD
 1.146.2.4  26-Apr-2017  pgoyette Sync with HEAD
 1.146.2.3  20-Mar-2017  pgoyette Sync with HEAD
 1.146.2.2  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.146.2.1  04-Nov-2016  pgoyette Sync with HEAD
 1.165.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.169.6.5  08-Mar-2018  martin Pull up following revision(s) (requested by knakahara in ticket #613):
sys/net/if_pppoe.c: revision 1.130,1.134
sys/net/if_spppsubr.c: revision 1.172,1.175,1.179
sys/net/if_gif.c: revision 1.138,1.139

Mark callouts of pppoe(4) CALLOUT_MPSAFE. Suggested by ozaki-r@n.o.

fix non-diagnostic compilation

Fix spl leak.
ifconfig gif0 create
ifconfig gif0 destroy
WARNING: SPL NOT LOWERED ON ...

Fix breaking character limit. Pointed out by ozaki-r@n.o, thanks.

Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.
 1.169.6.4  16-Jan-2018  martin Pull up following revision(s) (requested by ozaki-r in ticket #497):
tests/rump/rumpkern/Makefile: revision 1.16
tests/rump/kernspace/Makefile: revision 1.6
tests/rump/kernspace/workqueue.c: revision 1.1
tests/rump/kernspace/workqueue.c: revision 1.2
tests/rump/kernspace/workqueue.c: revision 1.3
tests/rump/kernspace/workqueue.c: revision 1.4
tests/rump/kernspace/workqueue.c: revision 1.5
tests/rump/kernspace/workqueue.c: revision 1.6
tests/rump/rumpkern/t_workqueue.c: revision 1.1
sys/sys/workqueue.h: revision 1.10
tests/rump/rumpkern/t_workqueue.c: revision 1.2
tests/rump/kernspace/kernspace.h: revision 1.5
tests/rump/kernspace/kernspace.h: revision 1.6
sys/net/if_bridge.c: revision 1.147
distrib/sets/lists/debug/mi: revision 1.225
sys/kern/subr_workqueue.c: revision 1.34
share/man/man9/workqueue.9: revision 1.12
sys/net/if_spppsubr.c: revision 1.178
distrib/sets/lists/tests/mi: revision 1.763
Add simple test for workqueue(9)
Add declaration. build fix
sorry, I forgot to commit this file.
Tweak use of cv_timedwait
- Handle its return value
- Specify more appropriate time-out periods (2 ticks is too short)
Fix a race condition on taking the mutex
The workqueue worker can take the mutex before the tester tries to take it after
calling workqueue_enqueue. If it happens, the worker calls cv_broadcast before
the tester calls cv_timedwait and the tester will wait until the cv timed out
Take the mutex before calling workqueue_enqueue so that the tester surely calls
cv_timedwait before the worker calls cv_broadcast.
The fix stabilizes the test, t_workqueue/workqueue1.
Add workqueue_wait that waits for a specific work to finish
The caller must ensure that no new work is enqueued before calling
workqueue_wait. Note that Note that if the workqueue is WQ_PERCPU, the caller
can enqueue a new work to another queue other than the waiting queue.
Discussed on tech-kern@
Ensure the timer isn't running by using workqueue_wait
Functionalize some routines to add new tests easily (NFC)
Add a test case for workqueue_wait
Fix build
 1.169.6.3  02-Jan-2018  snj Pull up following revision(s) (requested by ozaki-r in ticket #456):
sys/arch/arm/sunxi/sunxi_emac.c: 1.9
sys/dev/ic/dwc_gmac.c: 1.43-1.44
sys/dev/pci/if_iwm.c: 1.75
sys/dev/pci/if_wm.c: 1.543
sys/dev/pci/ixgbe/ixgbe.c: 1.112
sys/dev/pci/ixgbe/ixv.c: 1.74
sys/kern/sys_socket.c: 1.75
sys/net/agr/if_agr.c: 1.43
sys/net/bpf.c: 1.219
sys/net/if.c: 1.397, 1.399, 1.401-1.403, 1.406-1.410, 1.412-1.416
sys/net/if.h: 1.242-1.247, 1.250, 1.252-1.257
sys/net/if_bridge.c: 1.140 via patch, 1.142-1.146
sys/net/if_etherip.c: 1.40
sys/net/if_ethersubr.c: 1.243, 1.246
sys/net/if_faith.c: 1.57
sys/net/if_gif.c: 1.132
sys/net/if_l2tp.c: 1.15, 1.17
sys/net/if_loop.c: 1.98-1.101
sys/net/if_media.c: 1.35
sys/net/if_pppoe.c: 1.131-1.132
sys/net/if_spppsubr.c: 1.176-1.177
sys/net/if_tun.c: 1.142
sys/net/if_vlan.c: 1.107, 1.109, 1.114-1.121
sys/net/npf/npf_ifaddr.c: 1.3
sys/net/npf/npf_os.c: 1.8-1.9
sys/net/rtsock.c: 1.230
sys/netcan/if_canloop.c: 1.3-1.5
sys/netinet/if_arp.c: 1.255
sys/netinet/igmp.c: 1.65
sys/netinet/in.c: 1.210-1.211
sys/netinet/in_pcb.c: 1.180
sys/netinet/ip_carp.c: 1.92, 1.94
sys/netinet/ip_flow.c: 1.81
sys/netinet/ip_input.c: 1.362
sys/netinet/ip_mroute.c: 1.147
sys/netinet/ip_output.c: 1.283, 1.285, 1.287
sys/netinet6/frag6.c: 1.61
sys/netinet6/in6.c: 1.251, 1.255
sys/netinet6/in6_pcb.c: 1.162
sys/netinet6/ip6_flow.c: 1.35
sys/netinet6/ip6_input.c: 1.183
sys/netinet6/ip6_output.c: 1.196
sys/netinet6/mld6.c: 1.90
sys/netinet6/nd6.c: 1.239-1.240
sys/netinet6/nd6_nbr.c: 1.139
sys/netinet6/nd6_rtr.c: 1.136
sys/netipsec/ipsec_output.c: 1.65
sys/rump/net/lib/libnetinet/netinet_component.c: 1.9-1.10
kmem_intr_free kmem_intr_[z]alloced memory
the underlying pools are the same but api-wise those should match
Unify IFEF_*_MPSAFE into IFEF_MPSAFE
There are already two flags for if_output and if_start, however, it seems such
MPSAFE flags are eventually needed for all if_XXX operations. Having discrete
flags for each operation is wasteful of if_extflags bits. So let's unify
the flags into one: IFEF_MPSAFE.
Fortunately IFEF_*_MPSAFE flags have never been included in any releases, so
we can change them without breaking backward compatibility of the releases
(though the kernel version of -current should be bumped).
Note that if an interface have both MP-safe and non-MP-safe operations at a
time, we have to set the IFEF_MPSAFE flag and let callees of non-MP-safe
opeartions take the kernel lock.
Proposed on tech-kern@ and tech-net@
Provide macros for softnet_lock and KERNEL_LOCK hiding NET_MPSAFE switch
It reduces C&P codes such as "#ifndef NET_MPSAFE KERNEL_LOCK(1, NULL); ..."
scattered all over the source code and makes it easy to identify remaining
KERNEL_LOCK and/or softnet_lock that are held even if NET_MPSAFE.
No functional change
Hold KERNEL_LOCK on if_ioctl selectively based on IFEF_MPSAFE
If IFEF_MPSAFE is set, hold the lock and otherwise don't hold.
This change requires additions of KERNEL_LOCK to subsequence functions from
if_ioctl such as ifmedia_ioctl and ifioctl_common to protect non-MP-safe
components.
Proposed on tech-kern@ and tech-net@
Ensure to hold if_ioctl_lock when calling if_flags_set
Fix locking against myself on ifpromisc
vlan_unconfig_locked could be called with holding if_ioctl_lock.
Ensure to not turn on IFF_RUNNING of an interface until its initialization completes
And ensure to turn off it before destruction as per IFF_RUNNING's description
"resource allocated". (The description is a bit doubtful though, I believe the
change is still proper.)
Ensure to hold if_ioctl_lock on if_up and if_down
One exception for if_down is if_detach; in the case the lock isn't needed
because it's guaranteed that no other one can access ifp at that point.
Make if_link_queue MP-safe if IFEF_MPSAFE
if_link_queue is a queue to store events of link state changes, which is
used to pass events from (typically) an interrupt handler to
if_link_state_change softint. The queue was protected by KERNEL_LOCK so far,
but if IFEF_MPSAFE is enabled, it becomes unsafe because (perhaps) an interrupt
handler of an interface with IFEF_MPSAFE doesn't take KERNEL_LOCK. Protect it
by a spin mutex.
Additionally with this change KERNEL_LOCK of if_link_state_change softint is
omitted if NET_MPSAFE is enabled.
Note that the spin mutex is now ifp->if_snd.ifq_lock as well as the case of
if_timer (see the comment).
Use IFADDR_WRITER_FOREACH instead of IFADDR_READER_FOREACH
At that point no other one modifies the list so IFADDR_READER_FOREACH
is unnecessary. Use of IFADDR_READER_FOREACH is harmless in general though,
if we try to detect contract violations of pserialize, using it violates
the contract. So avoid using it makes life easy.
Ensure to call if_addr_init with holding if_ioctl_lock
Get rid of outdated comments
Fix build of kernels without ether
By throwing out if_enable_vlan_mtu and if_disable_vlan_mtu that
created a unnecessary dependency from if.c to if_ethersubr.c.
PR kern/52790
Rename IFNET_LOCK to IFNET_GLOBAL_LOCK
IFNET_LOCK will be used in another lock, if_ioctl_lock (might be renamed then).
Wrap if_ioctl_lock with IFNET_* macros (NFC)
Also if_ioctl_lock perhaps needs to be renamed to something because it's now
not just for ioctl...
Reorder some destruction routines in if_detach
- Destroy if_ioctl_lock at the end of the if_detach because it's used in various
destruction routines
- Move psref_target_destroy after pr_purgeif because we want to use psref in
pr_purgeif (otherwise destruction procedures can be tricky)
Ensure to call if_mcast_op with holding IFNET_LOCK
Note that CARP doesn't deal with IFNET_LOCK yet.
Remove IFNET_GLOBAL_LOCK where it's unnecessary because IFNET_LOCK is held
Describe which lock is used to protect each member variable of struct ifnet
Requested by skrll@
Write a guideline for converting an interface to IFEF_MPSAFE
Requested by skrll@
Note that IFNET_LOCK must not be held in softint
Don't set IFEF_MPSAFE unless NET_MPSAFE at this point
Because recent investigations show that interfaces with IFEF_MPSAFE need to
follow additional restrictions to work with the flag safely. We should enable it
on an interface by default only if the interface surely satisfies the
restrictions, which are described in if.h.
Note that enabling IFEF_MPSAFE solely gains a few benefit on performance because
the network stack is still serialized by the big kernel locks by default.
 1.169.6.2  30-Nov-2017  martin Pull up following revision(s) (requested by ozaki-r in ticket #407):
sys/compat/linux32/common/linux32_socket.c: revision 1.28
sys/net/if.c: revision 1.400
sys/netipsec/key.c: revision 1.243
sys/compat/linux/common/linux_socket.c: revision 1.139
sys/netinet/ip_carp.c: revision 1.93
sys/netinet6/in6.c: revision 1.252
sys/netinet6/in6.c: revision 1.253
sys/netinet6/in6.c: revision 1.254
sys/net/if_spppsubr.c: revision 1.173
sys/net/if_spppsubr.c: revision 1.174
sys/compat/common/uipc_syscalls_40.c: revision 1.14
Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref
Fix usage of FOREACH macro
key_sad.lock is held there so SAVLIST_WRITER_FOREACH is enough.
Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref
Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref (more)
Fix and make consistent of usages of psz/psref in ifconf variants
Remove unnecessary goto because there is no cleanup code to share (NFC)
Tweak a condition; we don't need to care ifacount to be negative
Fix a race condition of in6_ifinit
in6_ifinit checks the number of IPv6 addresses on a given interface and
if it's zero (i.e., an IPv6 address being assigned to the interface
is the first one), call if_addr_init. However, the actual assignment of
the address (ifa_insert) is out of in6_ifinit. The check and the
assignment must be done atomically.
Fix it by holding in6_ifaddr_lock during in6_ifinit and ifa_insert.
And also add missing pserialize to IFADDR_READER_FOREACH.
 1.169.6.1  02-Nov-2017  snj Pull up following revision(s) (requested by knakahara in ticket #332):
sys/net/if_pppoe.c: 1.127-1.128
sys/net/if_pppoe.h: 1.15
sys/net/if_spppsubr.c: 1.170-1.171
sys/net/if_spppvar.h: 1.21-1.22
Integrate two locks used to protect PPPoE softc. Contributed by s-yamaguchi@IIJ.
PPPOE_SESSION_LOCK protects variables used in PPP packet
processing, on the other hand PPPOE_PARAM_LOCK protects
the other variables used to establish a PPPoE session id.
Those locks isn't acquired in the same time because the
PPP packet processing doesn't work without PPPoE session id.
By the reason, the locks can be integrated into PPPOE_LOCK.
Add locking notes later.
--
sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.
Add locking notes later.
--
Add a locking notes for if_pppoe
--
Add a locking notes for if_spppsubr
--
fix no INET6 build.
 1.179.2.11  22-Jan-2019  pgoyette Convert the MODULE_{,VOID_}HOOK_CALL macros to do everything in-line
rather than defining an intermediate hook##call function. Almost
all of the hooks are called only once, and although we lose the
ability of doing things like

if (MODULE_HOOK_CALL(...) == 0) ...

we simplify things quite a bit. With this change, we no longer need
to have both declaration and definition macros, and the definition
no longer needs to have both prototype argument list and a "real"
argument list.

FWIW, the above if now needs to written as

int ret;

MODULE_HOOK_CALL(..., ret);
if (ret == 0) ...

with appropriate use of braces {}.
 1.179.2.10  18-Jan-2019  pgoyette Don't restrict hooks to having only int or void types. Pass the hook's
type to the various macros, as needed.

Allows us to reduce diffs to original in at least one or two places (we
no longer have to provide an additional parameter to the hook routine
for returning a non-int return value).
 1.179.2.9  14-Jan-2019  pgoyette Create a variant of the HOOK macros that handles hook routines of
type void, and use them where appropriate.
 1.179.2.8  13-Jan-2019  pgoyette Remove the HOOK2 versions of the MODULE_HOOK macros. There were
only a few uses, and using them led to some lack of clarity in the
code. Instead, we now use two separate hooks, with names that
make it clear(er) what we're doing.

This also positions us to start unraveling some of the rtsock_50
mess, which will need (at least) five hooks.
 1.179.2.7  29-Sep-2018  pgoyette In MODULE_HOOK_CALL_DECL we don't need to provide the actual argument
list for calling the hook function, nor do we need to provide the
default value (for when the hook has not been set).
 1.179.2.6  18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.179.2.5  18-Sep-2018  pgoyette Split the COMPAT_CALL_HOOK to separate the declaration from the
implementation. Some hooks are called from multiple source files,
and the old method resulted in duplicate implementations.

Implement MP-safe hooks for the usb_subr_30 code. Pass the helper
functions as arguments to the compat code so it does not have to
determine if the kernel contains usb code.
 1.179.2.4  17-Sep-2018  pgoyette Adapt (most of) the indirect function pointers to the new MP-safe
mechanism. Still remaining are the compat_netbsd32 stuff, and
some usb subroutines.
 1.179.2.3  07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.179.2.2  30-Mar-2018  pgoyette Import fixes from HEAD
 1.179.2.1  21-Mar-2018  pgoyette Move if_spppsubr compat code into the compat50 module.

More prep work for compat80 module (for raidframe)
 1.180.2.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.180.2.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.180.2.1  10-Jun-2019  christos Sync with HEAD
 1.184.2.1  29-Feb-2020  ad Sync with head.
 1.187.2.11  11-Apr-2020  is trying to ind the right place for MLPPP renegotiation.
 1.187.2.10  11-Apr-2020  is typo
 1.187.2.9  11-Apr-2020  is MLPPP mrru negotiation.
 1.187.2.8  11-Apr-2020  is macro error
 1.187.2.7  11-Apr-2020  is whitespace error
 1.187.2.6  11-Apr-2020  is compat code to make transplanting this to netbsd-8 easier
 1.187.2.5  10-Apr-2020  is syntax fixes.
 1.187.2.4  10-Apr-2020  is first part of defragmentation code. No dropping/sequence error statistics
yet, and no MRRU negotiation so not active.
 1.187.2.3  07-Apr-2020  is The specification calls this a class, not type.
 1.187.2.2  07-Apr-2020  is Multilink PPP: sanity check of option values, storage of remote MRRU.
 1.187.2.1  07-Apr-2020  is Define a few more LCP options. Recognize, sanity-check and report (but
still reject for the moment) multilink PPP configuration options received.
 1.190.2.1  14-Dec-2020  thorpej Sync w/ HEAD.
 1.215.2.1  17-Apr-2021  thorpej Sync with HEAD.
 1.220.2.2  17-Jun-2021  thorpej Sync w/ HEAD.
 1.220.2.1  13-May-2021  thorpej Sync with HEAD.
 1.230.2.1  31-May-2021  cjep sync with head
 1.266.4.1  01-Oct-2025  martin Pull up following revision(s) (requested by ozaki-r in ticket #1164):

sys/net/link_proto.c: revision 1.41
sys/netinet6/in6.c: revision 1.293
sys/net/if.h: revision 1.307
sys/netinet/ip_icmp.c: revision 1.180
sys/dev/vmt/vmt_subr.c: revision 1.11
sys/netinet6/in6_var.h: revision 1.105
sys/netinet6/in6_var.h: revision 1.106
sys/net/if.c: revision 1.532
sys/net/if.c: revision 1.533
sys/netinet6/mld6.c: revision 1.102
sys/netinet/in_var.h: revision 1.104
sys/net/if_spppsubr.c: revision 1.270
sys/net/if_spppsubr.c: revision 1.271
sys/netinet6/nd6.c: revision 1.284

if: introduce if_first_addr() (and psref variant)

It returns a first address (ifa) of a given family on a given interface.

It will replace a bunch of open codes and make their intent clear.
Apply if_first_addr() and if_first_addr_psref()

in6: introduce in6ifa_first_lladdr() (and psref variant)

It returns a first link-local address (ifa) on a given interface.
Apply in6ifa_first_lladdr() and in6ifa_first_lladdr_psref()
 1.267.4.3  16-Nov-2023  thorpej if_transmit_lock() and if_enqueue() are equivalent. if_enqueue() is
a better name, so collapse everything down to that and garbage-collect
if_transmit_lock().
 1.267.4.2  16-Nov-2023  thorpej IFQ_CLASSIFY() -> ifq_classify_packet().
 1.267.4.1  15-Nov-2023  thorpej Rename ifq_enqueue() -> if_enqueue(), ifq_enqueue2() -> if_enqueue2().
 1.268.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed