History log of /netbsd-current/sys/net/if_pppoe.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.183 15-Aug-2022 knakahara

Fix stall on PPPOE_STATE_PADR_SENT, suggested by martin@n.o, thanks.

Just drop such large PADO frames, ok'ed by yamaguchi@n.o.

I left if_pppoe.c:r1.182 code because that fixes other issues such as
pppoe(4) stall in PPPOE_STATE_PADR_SENT when the PADO sender never
replys.


# 1.182 12-Aug-2022 knakahara

Fix stall on PPPOE_STATE_PADR_SENT when received specific PADO, ok'ed by yamaguchi@n.o.

When pppoe receives a PADO frame larger than mbuf cluster size,
pppoe_send_padr() fails forever. So, the pppoe interface stall
on PPPOE_STATE_PADR_SENT until ifconfig down/up.
It should retry from PADI in such case.


# 1.181 23-May-2022 andvar

s/controll/control/ in comments.


# 1.180 10-May-2022 knakahara

Zeroize the length explicitly when malloc failed. Pointed out by yamaguchi@n.o.


# 1.179 04-May-2022 martin

Do not allocate mbuf clusters when the caller (eroneously) asks
for more than MCLBYTES size, instead fail the allocation.

When we have received multiple PADO offer packets in the discovery
phase, do not combine tags from different packets. We are supposed
to pick one PADO packet and continue session establishment with that.

The second bug could cause code to trigger the first and create
invalid response packets and also overwrite data outside of
the allocated mbuf cluster.

Fixes CVE-2022-29867.


# 1.178 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.177 16-Jun-2021 riastradh

if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.176 19-May-2021 yamaguchi

Added a kernel option to change the number of processing packets
at one pppoeintr()


# 1.175 19-May-2021 yamaguchi

Added a limitation of the number of processing packets
because a enqueuing process can not add packets over IFQ_MAXLEN

and removed reschedule at pppoeintr()
because it also scheduled at enqueuing process.


# 1.174 18-May-2021 yamaguchi

Added missing PPPOE_UNLOCK() on dropping PADS and PADT


# 1.173 13-May-2021 yamaguchi

Drop PADS and PADT from unknown host for safety


# 1.172 13-May-2021 yamaguchi

Change reconnect delay after PADT received (15 sec -> 5 sec)

5 sec is the same as minimum PADI resending interval


# 1.171 13-May-2021 yamaguchi

Accept a frame like a PADT just containing PPPoE header


Revision tags: cjep_staticlib_x-base
# 1.170 22-Apr-2021 yamaguchi

branches: 1.170.2; 1.170.4;
Added missing free of sc_hunique to prevent memory leak
when using PPPoE server


Revision tags: thorpej-cfargs-base
# 1.169 16-Apr-2021 yamaguchi

Stop and destroy timeout after sppp_detach and if_detach
for safety

The functions may use resources of pppoe(4) while detaching,
so the release should move after it.


# 1.168 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.167 16-Apr-2021 yamaguchi

Stop ppp layer at first of destroying pppoe interface


# 1.166 16-Apr-2021 yamaguchi

Sort initialization sequence in pppoe_clone_create() out
for refactoring

It has no functionality impact


# 1.165 16-Apr-2021 yamaguchi

Use kmem_zalloc to allocate pppoe_softc


# 1.164 16-Apr-2021 yamaguchi

Move initialization of sc_lock in pppoe_softc to first

The lock may be held in callbacks for ppp layer or other
components so that it should be initialized early.


# 1.163 16-Apr-2021 yamaguchi

commonize error handling in pppoe_clone_create()


# 1.162 13-Apr-2021 yamaguchi

Reschedule softint to process packets enqueued to ppoediscinq
while doing pppoe_data_input

And added a empty check for ppoeinq, for safety


# 1.161 13-Apr-2021 yamaguchi

Added missing counter clear when a pppoe state changes to PADI_SENT


# 1.160 13-Apr-2021 yamaguchi

Added a NULL check for parent interface of pppoe


# 1.159 13-Apr-2021 yamaguchi

Hold the lock for pppoe while referencing sc_id
that is an item of struct pppoe_softc


Revision tags: thorpej-futex-base
# 1.158 25-Nov-2020 yamaguchi

branches: 1.158.2;
Fix to reconnect after PADT received


# 1.157 25-Nov-2020 yamaguchi

add a logging function used at debugging pppoe(4)


# 1.156 25-Nov-2020 yamaguchi

fix to remove trailing garbage


# 1.155 25-Nov-2020 yamaguchi

stop callout even when the state is in PPPOE_STATE_INITIAL


# 1.154 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.153 25-Sep-2020 yamaguchi

branches: 1.153.2;
Add a function to copy AC-Name and Service-Name


# 1.152 25-Sep-2020 yamaguchi

Clear AC-Name and Service-Name if params are not specified


# 1.151 18-Sep-2020 yamaguchi

Do pppoe_timeout() in thread context

OKed by knakahara@n.o
fix port-amd64/55661


# 1.150 18-Sep-2020 yamaguchi

Use callout_setfunc and callout_schedule


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.149 10-Feb-2020 mlelstv

safely extract character sequences from packet for printing.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

branches: 1.147.4; 1.147.6;
s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.182 12-Aug-2022 knakahara

Fix stall on PPPOE_STATE_PADR_SENT when received specific PADO, ok'ed by yamaguchi@n.o.

When pppoe receives a PADO frame larger than mbuf cluster size,
pppoe_send_padr() fails forever. So, the pppoe interface stall
on PPPOE_STATE_PADR_SENT until ifconfig down/up.
It should retry from PADI in such case.


# 1.181 23-May-2022 andvar

s/controll/control/ in comments.


# 1.180 10-May-2022 knakahara

Zeroize the length explicitly when malloc failed. Pointed out by yamaguchi@n.o.


# 1.179 04-May-2022 martin

Do not allocate mbuf clusters when the caller (eroneously) asks
for more than MCLBYTES size, instead fail the allocation.

When we have received multiple PADO offer packets in the discovery
phase, do not combine tags from different packets. We are supposed
to pick one PADO packet and continue session establishment with that.

The second bug could cause code to trigger the first and create
invalid response packets and also overwrite data outside of
the allocated mbuf cluster.

Fixes CVE-2022-29867.


# 1.178 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.177 16-Jun-2021 riastradh

if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.176 19-May-2021 yamaguchi

Added a kernel option to change the number of processing packets
at one pppoeintr()


# 1.175 19-May-2021 yamaguchi

Added a limitation of the number of processing packets
because a enqueuing process can not add packets over IFQ_MAXLEN

and removed reschedule at pppoeintr()
because it also scheduled at enqueuing process.


# 1.174 18-May-2021 yamaguchi

Added missing PPPOE_UNLOCK() on dropping PADS and PADT


# 1.173 13-May-2021 yamaguchi

Drop PADS and PADT from unknown host for safety


# 1.172 13-May-2021 yamaguchi

Change reconnect delay after PADT received (15 sec -> 5 sec)

5 sec is the same as minimum PADI resending interval


# 1.171 13-May-2021 yamaguchi

Accept a frame like a PADT just containing PPPoE header


Revision tags: cjep_staticlib_x-base
# 1.170 22-Apr-2021 yamaguchi

branches: 1.170.2; 1.170.4;
Added missing free of sc_hunique to prevent memory leak
when using PPPoE server


Revision tags: thorpej-cfargs-base
# 1.169 16-Apr-2021 yamaguchi

Stop and destroy timeout after sppp_detach and if_detach
for safety

The functions may use resources of pppoe(4) while detaching,
so the release should move after it.


# 1.168 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.167 16-Apr-2021 yamaguchi

Stop ppp layer at first of destroying pppoe interface


# 1.166 16-Apr-2021 yamaguchi

Sort initialization sequence in pppoe_clone_create() out
for refactoring

It has no functionality impact


# 1.165 16-Apr-2021 yamaguchi

Use kmem_zalloc to allocate pppoe_softc


# 1.164 16-Apr-2021 yamaguchi

Move initialization of sc_lock in pppoe_softc to first

The lock may be held in callbacks for ppp layer or other
components so that it should be initialized early.


# 1.163 16-Apr-2021 yamaguchi

commonize error handling in pppoe_clone_create()


# 1.162 13-Apr-2021 yamaguchi

Reschedule softint to process packets enqueued to ppoediscinq
while doing pppoe_data_input

And added a empty check for ppoeinq, for safety


# 1.161 13-Apr-2021 yamaguchi

Added missing counter clear when a pppoe state changes to PADI_SENT


# 1.160 13-Apr-2021 yamaguchi

Added a NULL check for parent interface of pppoe


# 1.159 13-Apr-2021 yamaguchi

Hold the lock for pppoe while referencing sc_id
that is an item of struct pppoe_softc


Revision tags: thorpej-futex-base
# 1.158 25-Nov-2020 yamaguchi

branches: 1.158.2;
Fix to reconnect after PADT received


# 1.157 25-Nov-2020 yamaguchi

add a logging function used at debugging pppoe(4)


# 1.156 25-Nov-2020 yamaguchi

fix to remove trailing garbage


# 1.155 25-Nov-2020 yamaguchi

stop callout even when the state is in PPPOE_STATE_INITIAL


# 1.154 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.153 25-Sep-2020 yamaguchi

branches: 1.153.2;
Add a function to copy AC-Name and Service-Name


# 1.152 25-Sep-2020 yamaguchi

Clear AC-Name and Service-Name if params are not specified


# 1.151 18-Sep-2020 yamaguchi

Do pppoe_timeout() in thread context

OKed by knakahara@n.o
fix port-amd64/55661


# 1.150 18-Sep-2020 yamaguchi

Use callout_setfunc and callout_schedule


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.149 10-Feb-2020 mlelstv

safely extract character sequences from packet for printing.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

branches: 1.147.4; 1.147.6;
s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.181 23-May-2022 andvar

s/controll/control/ in comments.


# 1.180 10-May-2022 knakahara

Zeroize the length explicitly when malloc failed. Pointed out by yamaguchi@n.o.


# 1.179 04-May-2022 martin

Do not allocate mbuf clusters when the caller (eroneously) asks
for more than MCLBYTES size, instead fail the allocation.

When we have received multiple PADO offer packets in the discovery
phase, do not combine tags from different packets. We are supposed
to pick one PADO packet and continue session establishment with that.

The second bug could cause code to trigger the first and create
invalid response packets and also overwrite data outside of
the allocated mbuf cluster.

Fixes CVE-2022-29867.


# 1.178 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.177 16-Jun-2021 riastradh

if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.176 19-May-2021 yamaguchi

Added a kernel option to change the number of processing packets
at one pppoeintr()


# 1.175 19-May-2021 yamaguchi

Added a limitation of the number of processing packets
because a enqueuing process can not add packets over IFQ_MAXLEN

and removed reschedule at pppoeintr()
because it also scheduled at enqueuing process.


# 1.174 18-May-2021 yamaguchi

Added missing PPPOE_UNLOCK() on dropping PADS and PADT


# 1.173 13-May-2021 yamaguchi

Drop PADS and PADT from unknown host for safety


# 1.172 13-May-2021 yamaguchi

Change reconnect delay after PADT received (15 sec -> 5 sec)

5 sec is the same as minimum PADI resending interval


# 1.171 13-May-2021 yamaguchi

Accept a frame like a PADT just containing PPPoE header


Revision tags: cjep_staticlib_x-base
# 1.170 22-Apr-2021 yamaguchi

branches: 1.170.2; 1.170.4;
Added missing free of sc_hunique to prevent memory leak
when using PPPoE server


Revision tags: thorpej-cfargs-base
# 1.169 16-Apr-2021 yamaguchi

Stop and destroy timeout after sppp_detach and if_detach
for safety

The functions may use resources of pppoe(4) while detaching,
so the release should move after it.


# 1.168 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.167 16-Apr-2021 yamaguchi

Stop ppp layer at first of destroying pppoe interface


# 1.166 16-Apr-2021 yamaguchi

Sort initialization sequence in pppoe_clone_create() out
for refactoring

It has no functionality impact


# 1.165 16-Apr-2021 yamaguchi

Use kmem_zalloc to allocate pppoe_softc


# 1.164 16-Apr-2021 yamaguchi

Move initialization of sc_lock in pppoe_softc to first

The lock may be held in callbacks for ppp layer or other
components so that it should be initialized early.


# 1.163 16-Apr-2021 yamaguchi

commonize error handling in pppoe_clone_create()


# 1.162 13-Apr-2021 yamaguchi

Reschedule softint to process packets enqueued to ppoediscinq
while doing pppoe_data_input

And added a empty check for ppoeinq, for safety


# 1.161 13-Apr-2021 yamaguchi

Added missing counter clear when a pppoe state changes to PADI_SENT


# 1.160 13-Apr-2021 yamaguchi

Added a NULL check for parent interface of pppoe


# 1.159 13-Apr-2021 yamaguchi

Hold the lock for pppoe while referencing sc_id
that is an item of struct pppoe_softc


Revision tags: thorpej-futex-base
# 1.158 25-Nov-2020 yamaguchi

branches: 1.158.2;
Fix to reconnect after PADT received


# 1.157 25-Nov-2020 yamaguchi

add a logging function used at debugging pppoe(4)


# 1.156 25-Nov-2020 yamaguchi

fix to remove trailing garbage


# 1.155 25-Nov-2020 yamaguchi

stop callout even when the state is in PPPOE_STATE_INITIAL


# 1.154 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.153 25-Sep-2020 yamaguchi

branches: 1.153.2;
Add a function to copy AC-Name and Service-Name


# 1.152 25-Sep-2020 yamaguchi

Clear AC-Name and Service-Name if params are not specified


# 1.151 18-Sep-2020 yamaguchi

Do pppoe_timeout() in thread context

OKed by knakahara@n.o
fix port-amd64/55661


# 1.150 18-Sep-2020 yamaguchi

Use callout_setfunc and callout_schedule


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.149 10-Feb-2020 mlelstv

safely extract character sequences from packet for printing.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

branches: 1.147.4; 1.147.6;
s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.180 10-May-2022 knakahara

Zeroize the length explicitly when malloc failed. Pointed out by yamaguchi@n.o.


# 1.179 04-May-2022 martin

Do not allocate mbuf clusters when the caller (eroneously) asks
for more than MCLBYTES size, instead fail the allocation.

When we have received multiple PADO offer packets in the discovery
phase, do not combine tags from different packets. We are supposed
to pick one PADO packet and continue session establishment with that.

The second bug could cause code to trigger the first and create
invalid response packets and also overwrite data outside of
the allocated mbuf cluster.

Fixes CVE-2022-29867.


# 1.178 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.177 16-Jun-2021 riastradh

if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.176 19-May-2021 yamaguchi

Added a kernel option to change the number of processing packets
at one pppoeintr()


# 1.175 19-May-2021 yamaguchi

Added a limitation of the number of processing packets
because a enqueuing process can not add packets over IFQ_MAXLEN

and removed reschedule at pppoeintr()
because it also scheduled at enqueuing process.


# 1.174 18-May-2021 yamaguchi

Added missing PPPOE_UNLOCK() on dropping PADS and PADT


# 1.173 13-May-2021 yamaguchi

Drop PADS and PADT from unknown host for safety


# 1.172 13-May-2021 yamaguchi

Change reconnect delay after PADT received (15 sec -> 5 sec)

5 sec is the same as minimum PADI resending interval


# 1.171 13-May-2021 yamaguchi

Accept a frame like a PADT just containing PPPoE header


Revision tags: cjep_staticlib_x-base
# 1.170 22-Apr-2021 yamaguchi

branches: 1.170.2; 1.170.4;
Added missing free of sc_hunique to prevent memory leak
when using PPPoE server


Revision tags: thorpej-cfargs-base
# 1.169 16-Apr-2021 yamaguchi

Stop and destroy timeout after sppp_detach and if_detach
for safety

The functions may use resources of pppoe(4) while detaching,
so the release should move after it.


# 1.168 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.167 16-Apr-2021 yamaguchi

Stop ppp layer at first of destroying pppoe interface


# 1.166 16-Apr-2021 yamaguchi

Sort initialization sequence in pppoe_clone_create() out
for refactoring

It has no functionality impact


# 1.165 16-Apr-2021 yamaguchi

Use kmem_zalloc to allocate pppoe_softc


# 1.164 16-Apr-2021 yamaguchi

Move initialization of sc_lock in pppoe_softc to first

The lock may be held in callbacks for ppp layer or other
components so that it should be initialized early.


# 1.163 16-Apr-2021 yamaguchi

commonize error handling in pppoe_clone_create()


# 1.162 13-Apr-2021 yamaguchi

Reschedule softint to process packets enqueued to ppoediscinq
while doing pppoe_data_input

And added a empty check for ppoeinq, for safety


# 1.161 13-Apr-2021 yamaguchi

Added missing counter clear when a pppoe state changes to PADI_SENT


# 1.160 13-Apr-2021 yamaguchi

Added a NULL check for parent interface of pppoe


# 1.159 13-Apr-2021 yamaguchi

Hold the lock for pppoe while referencing sc_id
that is an item of struct pppoe_softc


Revision tags: thorpej-futex-base
# 1.158 25-Nov-2020 yamaguchi

branches: 1.158.2;
Fix to reconnect after PADT received


# 1.157 25-Nov-2020 yamaguchi

add a logging function used at debugging pppoe(4)


# 1.156 25-Nov-2020 yamaguchi

fix to remove trailing garbage


# 1.155 25-Nov-2020 yamaguchi

stop callout even when the state is in PPPOE_STATE_INITIAL


# 1.154 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.153 25-Sep-2020 yamaguchi

branches: 1.153.2;
Add a function to copy AC-Name and Service-Name


# 1.152 25-Sep-2020 yamaguchi

Clear AC-Name and Service-Name if params are not specified


# 1.151 18-Sep-2020 yamaguchi

Do pppoe_timeout() in thread context

OKed by knakahara@n.o
fix port-amd64/55661


# 1.150 18-Sep-2020 yamaguchi

Use callout_setfunc and callout_schedule


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.149 10-Feb-2020 mlelstv

safely extract character sequences from packet for printing.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

branches: 1.147.4; 1.147.6;
s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.179 04-May-2022 martin

Do not allocate mbuf clusters when the caller (eroneously) asks
for more than MCLBYTES size, instead fail the allocation.

When we have received multiple PADO offer packets in the discovery
phase, do not combine tags from different packets. We are supposed
to pick one PADO packet and continue session establishment with that.

The second bug could cause code to trigger the first and create
invalid response packets and also overwrite data outside of
the allocated mbuf cluster.

Fixes CVE-2022-29867.


# 1.178 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.177 16-Jun-2021 riastradh

if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.176 19-May-2021 yamaguchi

Added a kernel option to change the number of processing packets
at one pppoeintr()


# 1.175 19-May-2021 yamaguchi

Added a limitation of the number of processing packets
because a enqueuing process can not add packets over IFQ_MAXLEN

and removed reschedule at pppoeintr()
because it also scheduled at enqueuing process.


# 1.174 18-May-2021 yamaguchi

Added missing PPPOE_UNLOCK() on dropping PADS and PADT


# 1.173 13-May-2021 yamaguchi

Drop PADS and PADT from unknown host for safety


# 1.172 13-May-2021 yamaguchi

Change reconnect delay after PADT received (15 sec -> 5 sec)

5 sec is the same as minimum PADI resending interval


# 1.171 13-May-2021 yamaguchi

Accept a frame like a PADT just containing PPPoE header


Revision tags: cjep_staticlib_x-base
# 1.170 22-Apr-2021 yamaguchi

branches: 1.170.2; 1.170.4;
Added missing free of sc_hunique to prevent memory leak
when using PPPoE server


Revision tags: thorpej-cfargs-base
# 1.169 16-Apr-2021 yamaguchi

Stop and destroy timeout after sppp_detach and if_detach
for safety

The functions may use resources of pppoe(4) while detaching,
so the release should move after it.


# 1.168 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.167 16-Apr-2021 yamaguchi

Stop ppp layer at first of destroying pppoe interface


# 1.166 16-Apr-2021 yamaguchi

Sort initialization sequence in pppoe_clone_create() out
for refactoring

It has no functionality impact


# 1.165 16-Apr-2021 yamaguchi

Use kmem_zalloc to allocate pppoe_softc


# 1.164 16-Apr-2021 yamaguchi

Move initialization of sc_lock in pppoe_softc to first

The lock may be held in callbacks for ppp layer or other
components so that it should be initialized early.


# 1.163 16-Apr-2021 yamaguchi

commonize error handling in pppoe_clone_create()


# 1.162 13-Apr-2021 yamaguchi

Reschedule softint to process packets enqueued to ppoediscinq
while doing pppoe_data_input

And added a empty check for ppoeinq, for safety


# 1.161 13-Apr-2021 yamaguchi

Added missing counter clear when a pppoe state changes to PADI_SENT


# 1.160 13-Apr-2021 yamaguchi

Added a NULL check for parent interface of pppoe


# 1.159 13-Apr-2021 yamaguchi

Hold the lock for pppoe while referencing sc_id
that is an item of struct pppoe_softc


Revision tags: thorpej-futex-base
# 1.158 25-Nov-2020 yamaguchi

branches: 1.158.2;
Fix to reconnect after PADT received


# 1.157 25-Nov-2020 yamaguchi

add a logging function used at debugging pppoe(4)


# 1.156 25-Nov-2020 yamaguchi

fix to remove trailing garbage


# 1.155 25-Nov-2020 yamaguchi

stop callout even when the state is in PPPOE_STATE_INITIAL


# 1.154 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.153 25-Sep-2020 yamaguchi

branches: 1.153.2;
Add a function to copy AC-Name and Service-Name


# 1.152 25-Sep-2020 yamaguchi

Clear AC-Name and Service-Name if params are not specified


# 1.151 18-Sep-2020 yamaguchi

Do pppoe_timeout() in thread context

OKed by knakahara@n.o
fix port-amd64/55661


# 1.150 18-Sep-2020 yamaguchi

Use callout_setfunc and callout_schedule


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.149 10-Feb-2020 mlelstv

safely extract character sequences from packet for printing.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

branches: 1.147.4; 1.147.6;
s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.178 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.177 16-Jun-2021 riastradh

if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.176 19-May-2021 yamaguchi

Added a kernel option to change the number of processing packets
at one pppoeintr()


# 1.175 19-May-2021 yamaguchi

Added a limitation of the number of processing packets
because a enqueuing process can not add packets over IFQ_MAXLEN

and removed reschedule at pppoeintr()
because it also scheduled at enqueuing process.


# 1.174 18-May-2021 yamaguchi

Added missing PPPOE_UNLOCK() on dropping PADS and PADT


# 1.173 13-May-2021 yamaguchi

Drop PADS and PADT from unknown host for safety


# 1.172 13-May-2021 yamaguchi

Change reconnect delay after PADT received (15 sec -> 5 sec)

5 sec is the same as minimum PADI resending interval


# 1.171 13-May-2021 yamaguchi

Accept a frame like a PADT just containing PPPoE header


Revision tags: cjep_staticlib_x-base
# 1.170 22-Apr-2021 yamaguchi

branches: 1.170.2; 1.170.4;
Added missing free of sc_hunique to prevent memory leak
when using PPPoE server


Revision tags: thorpej-cfargs-base
# 1.169 16-Apr-2021 yamaguchi

Stop and destroy timeout after sppp_detach and if_detach
for safety

The functions may use resources of pppoe(4) while detaching,
so the release should move after it.


# 1.168 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.167 16-Apr-2021 yamaguchi

Stop ppp layer at first of destroying pppoe interface


# 1.166 16-Apr-2021 yamaguchi

Sort initialization sequence in pppoe_clone_create() out
for refactoring

It has no functionality impact


# 1.165 16-Apr-2021 yamaguchi

Use kmem_zalloc to allocate pppoe_softc


# 1.164 16-Apr-2021 yamaguchi

Move initialization of sc_lock in pppoe_softc to first

The lock may be held in callbacks for ppp layer or other
components so that it should be initialized early.


# 1.163 16-Apr-2021 yamaguchi

commonize error handling in pppoe_clone_create()


# 1.162 13-Apr-2021 yamaguchi

Reschedule softint to process packets enqueued to ppoediscinq
while doing pppoe_data_input

And added a empty check for ppoeinq, for safety


# 1.161 13-Apr-2021 yamaguchi

Added missing counter clear when a pppoe state changes to PADI_SENT


# 1.160 13-Apr-2021 yamaguchi

Added a NULL check for parent interface of pppoe


# 1.159 13-Apr-2021 yamaguchi

Hold the lock for pppoe while referencing sc_id
that is an item of struct pppoe_softc


Revision tags: thorpej-futex-base
# 1.158 25-Nov-2020 yamaguchi

branches: 1.158.2;
Fix to reconnect after PADT received


# 1.157 25-Nov-2020 yamaguchi

add a logging function used at debugging pppoe(4)


# 1.156 25-Nov-2020 yamaguchi

fix to remove trailing garbage


# 1.155 25-Nov-2020 yamaguchi

stop callout even when the state is in PPPOE_STATE_INITIAL


# 1.154 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.153 25-Sep-2020 yamaguchi

branches: 1.153.2;
Add a function to copy AC-Name and Service-Name


# 1.152 25-Sep-2020 yamaguchi

Clear AC-Name and Service-Name if params are not specified


# 1.151 18-Sep-2020 yamaguchi

Do pppoe_timeout() in thread context

OKed by knakahara@n.o
fix port-amd64/55661


# 1.150 18-Sep-2020 yamaguchi

Use callout_setfunc and callout_schedule


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.149 10-Feb-2020 mlelstv

safely extract character sequences from packet for printing.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

branches: 1.147.4; 1.147.6;
s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.177 16-Jun-2021 riastradh

if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.176 19-May-2021 yamaguchi

Added a kernel option to change the number of processing packets
at one pppoeintr()


# 1.175 19-May-2021 yamaguchi

Added a limitation of the number of processing packets
because a enqueuing process can not add packets over IFQ_MAXLEN

and removed reschedule at pppoeintr()
because it also scheduled at enqueuing process.


# 1.174 18-May-2021 yamaguchi

Added missing PPPOE_UNLOCK() on dropping PADS and PADT


# 1.173 13-May-2021 yamaguchi

Drop PADS and PADT from unknown host for safety


# 1.172 13-May-2021 yamaguchi

Change reconnect delay after PADT received (15 sec -> 5 sec)

5 sec is the same as minimum PADI resending interval


# 1.171 13-May-2021 yamaguchi

Accept a frame like a PADT just containing PPPoE header


Revision tags: cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.170 22-Apr-2021 yamaguchi

branches: 1.170.4;
Added missing free of sc_hunique to prevent memory leak
when using PPPoE server


Revision tags: thorpej-cfargs-base
# 1.169 16-Apr-2021 yamaguchi

Stop and destroy timeout after sppp_detach and if_detach
for safety

The functions may use resources of pppoe(4) while detaching,
so the release should move after it.


# 1.168 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.167 16-Apr-2021 yamaguchi

Stop ppp layer at first of destroying pppoe interface


# 1.166 16-Apr-2021 yamaguchi

Sort initialization sequence in pppoe_clone_create() out
for refactoring

It has no functionality impact


# 1.165 16-Apr-2021 yamaguchi

Use kmem_zalloc to allocate pppoe_softc


# 1.164 16-Apr-2021 yamaguchi

Move initialization of sc_lock in pppoe_softc to first

The lock may be held in callbacks for ppp layer or other
components so that it should be initialized early.


# 1.163 16-Apr-2021 yamaguchi

commonize error handling in pppoe_clone_create()


# 1.162 13-Apr-2021 yamaguchi

Reschedule softint to process packets enqueued to ppoediscinq
while doing pppoe_data_input

And added a empty check for ppoeinq, for safety


# 1.161 13-Apr-2021 yamaguchi

Added missing counter clear when a pppoe state changes to PADI_SENT


# 1.160 13-Apr-2021 yamaguchi

Added a NULL check for parent interface of pppoe


# 1.159 13-Apr-2021 yamaguchi

Hold the lock for pppoe while referencing sc_id
that is an item of struct pppoe_softc


Revision tags: thorpej-futex-base
# 1.158 25-Nov-2020 yamaguchi

branches: 1.158.2;
Fix to reconnect after PADT received


# 1.157 25-Nov-2020 yamaguchi

add a logging function used at debugging pppoe(4)


# 1.156 25-Nov-2020 yamaguchi

fix to remove trailing garbage


# 1.155 25-Nov-2020 yamaguchi

stop callout even when the state is in PPPOE_STATE_INITIAL


# 1.154 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.153 25-Sep-2020 yamaguchi

branches: 1.153.2;
Add a function to copy AC-Name and Service-Name


# 1.152 25-Sep-2020 yamaguchi

Clear AC-Name and Service-Name if params are not specified


# 1.151 18-Sep-2020 yamaguchi

Do pppoe_timeout() in thread context

OKed by knakahara@n.o
fix port-amd64/55661


# 1.150 18-Sep-2020 yamaguchi

Use callout_setfunc and callout_schedule


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.149 10-Feb-2020 mlelstv

safely extract character sequences from packet for printing.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

branches: 1.147.4; 1.147.6;
s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.176 19-May-2021 yamaguchi

Added a kernel option to change the number of processing packets
at one pppoeintr()


# 1.175 19-May-2021 yamaguchi

Added a limitation of the number of processing packets
because a enqueuing process can not add packets over IFQ_MAXLEN

and removed reschedule at pppoeintr()
because it also scheduled at enqueuing process.


# 1.174 18-May-2021 yamaguchi

Added missing PPPOE_UNLOCK() on dropping PADS and PADT


# 1.173 13-May-2021 yamaguchi

Drop PADS and PADT from unknown host for safety


# 1.172 13-May-2021 yamaguchi

Change reconnect delay after PADT received (15 sec -> 5 sec)

5 sec is the same as minimum PADI resending interval


# 1.171 13-May-2021 yamaguchi

Accept a frame like a PADT just containing PPPoE header


Revision tags: cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.170 22-Apr-2021 yamaguchi

Added missing free of sc_hunique to prevent memory leak
when using PPPoE server


Revision tags: thorpej-cfargs-base
# 1.169 16-Apr-2021 yamaguchi

Stop and destroy timeout after sppp_detach and if_detach
for safety

The functions may use resources of pppoe(4) while detaching,
so the release should move after it.


# 1.168 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.167 16-Apr-2021 yamaguchi

Stop ppp layer at first of destroying pppoe interface


# 1.166 16-Apr-2021 yamaguchi

Sort initialization sequence in pppoe_clone_create() out
for refactoring

It has no functionality impact


# 1.165 16-Apr-2021 yamaguchi

Use kmem_zalloc to allocate pppoe_softc


# 1.164 16-Apr-2021 yamaguchi

Move initialization of sc_lock in pppoe_softc to first

The lock may be held in callbacks for ppp layer or other
components so that it should be initialized early.


# 1.163 16-Apr-2021 yamaguchi

commonize error handling in pppoe_clone_create()


# 1.162 13-Apr-2021 yamaguchi

Reschedule softint to process packets enqueued to ppoediscinq
while doing pppoe_data_input

And added a empty check for ppoeinq, for safety


# 1.161 13-Apr-2021 yamaguchi

Added missing counter clear when a pppoe state changes to PADI_SENT


# 1.160 13-Apr-2021 yamaguchi

Added a NULL check for parent interface of pppoe


# 1.159 13-Apr-2021 yamaguchi

Hold the lock for pppoe while referencing sc_id
that is an item of struct pppoe_softc


Revision tags: thorpej-futex-base
# 1.158 25-Nov-2020 yamaguchi

branches: 1.158.2;
Fix to reconnect after PADT received


# 1.157 25-Nov-2020 yamaguchi

add a logging function used at debugging pppoe(4)


# 1.156 25-Nov-2020 yamaguchi

fix to remove trailing garbage


# 1.155 25-Nov-2020 yamaguchi

stop callout even when the state is in PPPOE_STATE_INITIAL


# 1.154 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.153 25-Sep-2020 yamaguchi

branches: 1.153.2;
Add a function to copy AC-Name and Service-Name


# 1.152 25-Sep-2020 yamaguchi

Clear AC-Name and Service-Name if params are not specified


# 1.151 18-Sep-2020 yamaguchi

Do pppoe_timeout() in thread context

OKed by knakahara@n.o
fix port-amd64/55661


# 1.150 18-Sep-2020 yamaguchi

Use callout_setfunc and callout_schedule


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.149 10-Feb-2020 mlelstv

safely extract character sequences from packet for printing.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

branches: 1.147.4; 1.147.6;
s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.174 18-May-2021 yamaguchi

Added missing PPPOE_UNLOCK() on dropping PADS and PADT


# 1.173 13-May-2021 yamaguchi

Drop PADS and PADT from unknown host for safety


# 1.172 13-May-2021 yamaguchi

Change reconnect delay after PADT received (15 sec -> 5 sec)

5 sec is the same as minimum PADI resending interval


# 1.171 13-May-2021 yamaguchi

Accept a frame like a PADT just containing PPPoE header


Revision tags: cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.170 22-Apr-2021 yamaguchi

Added missing free of sc_hunique to prevent memory leak
when using PPPoE server


Revision tags: thorpej-cfargs-base
# 1.169 16-Apr-2021 yamaguchi

Stop and destroy timeout after sppp_detach and if_detach
for safety

The functions may use resources of pppoe(4) while detaching,
so the release should move after it.


# 1.168 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.167 16-Apr-2021 yamaguchi

Stop ppp layer at first of destroying pppoe interface


# 1.166 16-Apr-2021 yamaguchi

Sort initialization sequence in pppoe_clone_create() out
for refactoring

It has no functionality impact


# 1.165 16-Apr-2021 yamaguchi

Use kmem_zalloc to allocate pppoe_softc


# 1.164 16-Apr-2021 yamaguchi

Move initialization of sc_lock in pppoe_softc to first

The lock may be held in callbacks for ppp layer or other
components so that it should be initialized early.


# 1.163 16-Apr-2021 yamaguchi

commonize error handling in pppoe_clone_create()


# 1.162 13-Apr-2021 yamaguchi

Reschedule softint to process packets enqueued to ppoediscinq
while doing pppoe_data_input

And added a empty check for ppoeinq, for safety


# 1.161 13-Apr-2021 yamaguchi

Added missing counter clear when a pppoe state changes to PADI_SENT


# 1.160 13-Apr-2021 yamaguchi

Added a NULL check for parent interface of pppoe


# 1.159 13-Apr-2021 yamaguchi

Hold the lock for pppoe while referencing sc_id
that is an item of struct pppoe_softc


Revision tags: thorpej-futex-base
# 1.158 25-Nov-2020 yamaguchi

branches: 1.158.2;
Fix to reconnect after PADT received


# 1.157 25-Nov-2020 yamaguchi

add a logging function used at debugging pppoe(4)


# 1.156 25-Nov-2020 yamaguchi

fix to remove trailing garbage


# 1.155 25-Nov-2020 yamaguchi

stop callout even when the state is in PPPOE_STATE_INITIAL


# 1.154 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.153 25-Sep-2020 yamaguchi

branches: 1.153.2;
Add a function to copy AC-Name and Service-Name


# 1.152 25-Sep-2020 yamaguchi

Clear AC-Name and Service-Name if params are not specified


# 1.151 18-Sep-2020 yamaguchi

Do pppoe_timeout() in thread context

OKed by knakahara@n.o
fix port-amd64/55661


# 1.150 18-Sep-2020 yamaguchi

Use callout_setfunc and callout_schedule


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.149 10-Feb-2020 mlelstv

safely extract character sequences from packet for printing.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

branches: 1.147.4; 1.147.6;
s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.173 13-May-2021 yamaguchi

Drop PADS and PADT from unknown host for safety


# 1.172 13-May-2021 yamaguchi

Change reconnect delay after PADT received (15 sec -> 5 sec)

5 sec is the same as minimum PADI resending interval


# 1.171 13-May-2021 yamaguchi

Accept a frame like a PADT just containing PPPoE header


Revision tags: cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.170 22-Apr-2021 yamaguchi

Added missing free of sc_hunique to prevent memory leak
when using PPPoE server


Revision tags: thorpej-cfargs-base
# 1.169 16-Apr-2021 yamaguchi

Stop and destroy timeout after sppp_detach and if_detach
for safety

The functions may use resources of pppoe(4) while detaching,
so the release should move after it.


# 1.168 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.167 16-Apr-2021 yamaguchi

Stop ppp layer at first of destroying pppoe interface


# 1.166 16-Apr-2021 yamaguchi

Sort initialization sequence in pppoe_clone_create() out
for refactoring

It has no functionality impact


# 1.165 16-Apr-2021 yamaguchi

Use kmem_zalloc to allocate pppoe_softc


# 1.164 16-Apr-2021 yamaguchi

Move initialization of sc_lock in pppoe_softc to first

The lock may be held in callbacks for ppp layer or other
components so that it should be initialized early.


# 1.163 16-Apr-2021 yamaguchi

commonize error handling in pppoe_clone_create()


# 1.162 13-Apr-2021 yamaguchi

Reschedule softint to process packets enqueued to ppoediscinq
while doing pppoe_data_input

And added a empty check for ppoeinq, for safety


# 1.161 13-Apr-2021 yamaguchi

Added missing counter clear when a pppoe state changes to PADI_SENT


# 1.160 13-Apr-2021 yamaguchi

Added a NULL check for parent interface of pppoe


# 1.159 13-Apr-2021 yamaguchi

Hold the lock for pppoe while referencing sc_id
that is an item of struct pppoe_softc


Revision tags: thorpej-futex-base
# 1.158 25-Nov-2020 yamaguchi

branches: 1.158.2;
Fix to reconnect after PADT received


# 1.157 25-Nov-2020 yamaguchi

add a logging function used at debugging pppoe(4)


# 1.156 25-Nov-2020 yamaguchi

fix to remove trailing garbage


# 1.155 25-Nov-2020 yamaguchi

stop callout even when the state is in PPPOE_STATE_INITIAL


# 1.154 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.153 25-Sep-2020 yamaguchi

branches: 1.153.2;
Add a function to copy AC-Name and Service-Name


# 1.152 25-Sep-2020 yamaguchi

Clear AC-Name and Service-Name if params are not specified


# 1.151 18-Sep-2020 yamaguchi

Do pppoe_timeout() in thread context

OKed by knakahara@n.o
fix port-amd64/55661


# 1.150 18-Sep-2020 yamaguchi

Use callout_setfunc and callout_schedule


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.149 10-Feb-2020 mlelstv

safely extract character sequences from packet for printing.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

branches: 1.147.4; 1.147.6;
s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.170 22-Apr-2021 yamaguchi

Added missing free of sc_hunique to prevent memory leak
when using PPPoE server


Revision tags: thorpej-cfargs-base
# 1.169 16-Apr-2021 yamaguchi

Stop and destroy timeout after sppp_detach and if_detach
for safety

The functions may use resources of pppoe(4) while detaching,
so the release should move after it.


# 1.168 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.167 16-Apr-2021 yamaguchi

Stop ppp layer at first of destroying pppoe interface


# 1.166 16-Apr-2021 yamaguchi

Sort initialization sequence in pppoe_clone_create() out
for refactoring

It has no functionality impact


# 1.165 16-Apr-2021 yamaguchi

Use kmem_zalloc to allocate pppoe_softc


# 1.164 16-Apr-2021 yamaguchi

Move initialization of sc_lock in pppoe_softc to first

The lock may be held in callbacks for ppp layer or other
components so that it should be initialized early.


# 1.163 16-Apr-2021 yamaguchi

commonize error handling in pppoe_clone_create()


# 1.162 13-Apr-2021 yamaguchi

Reschedule softint to process packets enqueued to ppoediscinq
while doing pppoe_data_input

And added a empty check for ppoeinq, for safety


# 1.161 13-Apr-2021 yamaguchi

Added missing counter clear when a pppoe state changes to PADI_SENT


# 1.160 13-Apr-2021 yamaguchi

Added a NULL check for parent interface of pppoe


# 1.159 13-Apr-2021 yamaguchi

Hold the lock for pppoe while referencing sc_id
that is an item of struct pppoe_softc


Revision tags: thorpej-futex-base
# 1.158 25-Nov-2020 yamaguchi

branches: 1.158.2;
Fix to reconnect after PADT received


# 1.157 25-Nov-2020 yamaguchi

add a logging function used at debugging pppoe(4)


# 1.156 25-Nov-2020 yamaguchi

fix to remove trailing garbage


# 1.155 25-Nov-2020 yamaguchi

stop callout even when the state is in PPPOE_STATE_INITIAL


# 1.154 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.153 25-Sep-2020 yamaguchi

branches: 1.153.2;
Add a function to copy AC-Name and Service-Name


# 1.152 25-Sep-2020 yamaguchi

Clear AC-Name and Service-Name if params are not specified


# 1.151 18-Sep-2020 yamaguchi

Do pppoe_timeout() in thread context

OKed by knakahara@n.o
fix port-amd64/55661


# 1.150 18-Sep-2020 yamaguchi

Use callout_setfunc and callout_schedule


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.149 10-Feb-2020 mlelstv

safely extract character sequences from packet for printing.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

branches: 1.147.4; 1.147.6;
s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.169 16-Apr-2021 yamaguchi

Stop and destroy timeout after sppp_detach and if_detach
for safety

The functions may use resources of pppoe(4) while detaching,
so the release should move after it.


# 1.168 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.167 16-Apr-2021 yamaguchi

Stop ppp layer at first of destroying pppoe interface


# 1.166 16-Apr-2021 yamaguchi

Sort initialization sequence in pppoe_clone_create() out
for refactoring

It has no functionality impact


# 1.165 16-Apr-2021 yamaguchi

Use kmem_zalloc to allocate pppoe_softc


# 1.164 16-Apr-2021 yamaguchi

Move initialization of sc_lock in pppoe_softc to first

The lock may be held in callbacks for ppp layer or other
components so that it should be initialized early.


# 1.163 16-Apr-2021 yamaguchi

commonize error handling in pppoe_clone_create()


# 1.162 13-Apr-2021 yamaguchi

Reschedule softint to process packets enqueued to ppoediscinq
while doing pppoe_data_input

And added a empty check for ppoeinq, for safety


# 1.161 13-Apr-2021 yamaguchi

Added missing counter clear when a pppoe state changes to PADI_SENT


# 1.160 13-Apr-2021 yamaguchi

Added a NULL check for parent interface of pppoe


# 1.159 13-Apr-2021 yamaguchi

Hold the lock for pppoe while referencing sc_id
that is an item of struct pppoe_softc


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.158 25-Nov-2020 yamaguchi

Fix to reconnect after PADT received


# 1.157 25-Nov-2020 yamaguchi

add a logging function used at debugging pppoe(4)


# 1.156 25-Nov-2020 yamaguchi

fix to remove trailing garbage


# 1.155 25-Nov-2020 yamaguchi

stop callout even when the state is in PPPOE_STATE_INITIAL


# 1.154 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.153 25-Sep-2020 yamaguchi

branches: 1.153.2;
Add a function to copy AC-Name and Service-Name


# 1.152 25-Sep-2020 yamaguchi

Clear AC-Name and Service-Name if params are not specified


# 1.151 18-Sep-2020 yamaguchi

Do pppoe_timeout() in thread context

OKed by knakahara@n.o
fix port-amd64/55661


# 1.150 18-Sep-2020 yamaguchi

Use callout_setfunc and callout_schedule


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.149 10-Feb-2020 mlelstv

safely extract character sequences from packet for printing.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

branches: 1.147.4; 1.147.6;
s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.162 13-Apr-2021 yamaguchi

Reschedule softint to process packets enqueued to ppoediscinq
while doing pppoe_data_input

And added a empty check for ppoeinq, for safety


# 1.161 13-Apr-2021 yamaguchi

Added missing counter clear when a pppoe state changes to PADI_SENT


# 1.160 13-Apr-2021 yamaguchi

Added a NULL check for parent interface of pppoe


# 1.159 13-Apr-2021 yamaguchi

Hold the lock for pppoe while referencing sc_id
that is an item of struct pppoe_softc


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.158 25-Nov-2020 yamaguchi

Fix to reconnect after PADT received


# 1.157 25-Nov-2020 yamaguchi

add a logging function used at debugging pppoe(4)


# 1.156 25-Nov-2020 yamaguchi

fix to remove trailing garbage


# 1.155 25-Nov-2020 yamaguchi

stop callout even when the state is in PPPOE_STATE_INITIAL


# 1.154 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.153 25-Sep-2020 yamaguchi

branches: 1.153.2;
Add a function to copy AC-Name and Service-Name


# 1.152 25-Sep-2020 yamaguchi

Clear AC-Name and Service-Name if params are not specified


# 1.151 18-Sep-2020 yamaguchi

Do pppoe_timeout() in thread context

OKed by knakahara@n.o
fix port-amd64/55661


# 1.150 18-Sep-2020 yamaguchi

Use callout_setfunc and callout_schedule


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.149 10-Feb-2020 mlelstv

safely extract character sequences from packet for printing.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

branches: 1.147.4; 1.147.6;
s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.158 25-Nov-2020 yamaguchi

Fix to reconnect after PADT received


# 1.157 25-Nov-2020 yamaguchi

add a logging function used at debugging pppoe(4)


# 1.156 25-Nov-2020 yamaguchi

fix to remove trailing garbage


# 1.155 25-Nov-2020 yamaguchi

stop callout even when the state is in PPPOE_STATE_INITIAL


# 1.154 25-Nov-2020 yamaguchi

Close lcp when the lower layer down if the interface is passive or on-demand

reivewed by knakahara@n.o.


Revision tags: thorpej-futex-base
# 1.153 25-Sep-2020 yamaguchi

Add a function to copy AC-Name and Service-Name


# 1.152 25-Sep-2020 yamaguchi

Clear AC-Name and Service-Name if params are not specified


# 1.151 18-Sep-2020 yamaguchi

Do pppoe_timeout() in thread context

OKed by knakahara@n.o
fix port-amd64/55661


# 1.150 18-Sep-2020 yamaguchi

Use callout_setfunc and callout_schedule


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.149 10-Feb-2020 mlelstv

safely extract character sequences from packet for printing.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

branches: 1.147.4; 1.147.6;
s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.153 25-Sep-2020 yamaguchi

Add a function to copy AC-Name and Service-Name


# 1.152 25-Sep-2020 yamaguchi

Clear AC-Name and Service-Name if params are not specified


# 1.151 18-Sep-2020 yamaguchi

Do pppoe_timeout() in thread context

OKed by knakahara@n.o
fix port-amd64/55661


# 1.150 18-Sep-2020 yamaguchi

Use callout_setfunc and callout_schedule


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.149 10-Feb-2020 mlelstv

safely extract character sequences from packet for printing.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

branches: 1.147.4; 1.147.6;
s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.149 10-Feb-2020 mlelstv

safely extract character sequences from packet for printing.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.148 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

branches: 1.141.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


Revision tags: isaki-audio2-base
# 1.147 18-Mar-2019 msaitoh

s/pakcet/packet/ in comment.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.146 27-Oct-2018 maxv

Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.


# 1.145 27-Oct-2018 maxv

style


Revision tags: pgoyette-compat-1020
# 1.144 30-Sep-2018 maxv

remove hardcoded bullshit, probably fixes PR/53644


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906
# 1.143 24-Aug-2018 maxv

Use a random hunique, instead of sending the pointer of the interface.
Tested via ATF.


# 1.142 13-Aug-2018 maxv

Clarify two functions.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.141 26-Jun-2018 msaitoh

Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.140 18-Jun-2018 yamaguchi

Fix to aquire pppoe_softc_list_lock before read and write the list

ok by knakahara@n.o


# 1.139 18-Jun-2018 yamaguchi

Fix not to use PPPOE_UNLOCK before acccess to pppoe_softc
to avoid a race condition

According to the locking order of pppoe(4), the access to
pppoe_softc has to follow 5 steps as below.

1. aquire pppoe_softc_list_lock
2. aquire pppoe_softc lock
3. release pppoe_softc_list_lock
4. access to pppoe_softc
5. release pppoe_softc lock

However, pppoe_dispatch_disc_pkt() releases the lock of pppoe_softc
temporarily, and then re-aquires it before step 4 of the adove. So,
it is possible for other contexts to destroy a pppoe_softc in the
interim.
To fix this condition, avoid PPPOE_UNLOCK with the problem.

ok by knakahara@n.o


# 1.138 25-May-2018 ozaki-r

Ensure to call if_register after interface initializations finish


Revision tags: pgoyette-compat-0521
# 1.137 03-May-2018 maxv

Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422
# 1.136 18-Apr-2018 knakahara

Fix sending PADT to unexpected hosts when net.pppoe.term_unknown is enabled.


# 1.135 18-Apr-2018 knakahara

net.pppoe.term_unknown can be written safely now.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.134 12-Feb-2018 maxv

branches: 1.134.2;
Use m_freem instead of m_free. Otherwise we're leaking the next mbufs in
the chain.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.133 07-Dec-2017 ozaki-r

Remove wrong assertions

rw_lock_held() returns true when any context holds the lock. However, in
if_pppoe.c, the function was used wrongly as it returns true only if the lock is
held in the same context.

From s-yamaguchi@IIJ


Revision tags: tls-maxphys-base-20171202
# 1.132 17-Nov-2017 ozaki-r

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


# 1.131 16-Nov-2017 ozaki-r

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@


# 1.130 15-Nov-2017 knakahara

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


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.129 23-Oct-2017 msaitoh

- If if_initialize() failed in the attach function, free resources and return.
- KNF


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.128 12-Oct-2017 knakahara

sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.

Add locking notes later.


# 1.127 12-Oct-2017 knakahara

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.


Revision tags: nick-nhusb-base-20170825
# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

branches: 1.125.6;
Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.126 20-Jul-2017 knakahara

fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.

XXX need pullup to -8 branch


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.125 07-Feb-2017 ozaki-r

Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

branches: 1.123.2;
fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.125 07-Feb-2017 ozaki-r

Use m_get_rcvif_psref instead of m_get_rcvif

Because the critical sections are now sleepable.

Reviewed by knakahara@


Revision tags: nick-nhusb-base-20170204
# 1.124 01-Feb-2017 maxv

Not sure what we are trying to achieve here, but there are two issues;
error can be printed while it is not initialized, and if m_pulldown fails
m is freed and reused.

Quickly reviewed by christos and martin


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.123 27-Dec-2016 christos

fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.


# 1.123 27-Dec-2016 christos

fix merge conflict.


# 1.122 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.121 16-Dec-2016 knakahara

fix unlock and splx inversion. Currently, this doesn't cause problem because either one is used.


# 1.120 13-Dec-2016 knakahara

MP-safe pppoe(4).

Nearly all parts is implemented by Shoichi YAMAGUCHI<s-yamaguchi@IIJ>, thanks.


Revision tags: nick-nhusb-base-20161204
# 1.119 18-Nov-2016 knakahara

if_register() must be called after ifp->if_dl initialized.

There may be similar problems. I will fix step by step...


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.118 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@


Revision tags: localcount-20160914
# 1.117 11-Aug-2016 christos

kill unknown sessions ifdef, link set for sysctl.


# 1.116 08-Aug-2016 roy

Fix compile without modules.


# 1.115 08-Aug-2016 pgoyette

Don't try to set-up our sysctl sub-tree if we're built-in - this will
happen automatically (via "registration" of the setup function in a
link-set), and if we're not a module, the SYSCTL_SETUP_PROTO() will
not have declared a function prototype!


# 1.114 07-Aug-2016 christos

modularize some more drivers and merge the module glue


# 1.113 07-Aug-2016 pgoyette

For modular configurations, always build with PPPOE_TERM_UNKNOWN_SESSIONS
defined, and provide a sysctl variable for enabling/disabling the option.

Update man page accordingly.


# 1.112 06-Aug-2016 pgoyette

Modularize the pppoe driver


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.111 07-Jul-2016 msaitoh

branches: 1.111.2;
KNF. Remove extra spaces. No functional change.


# 1.110 28-Jun-2016 ozaki-r

Add missing NULL checks for m_get_rcvif_psref


# 1.109 20-Jun-2016 knakahara

apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).


# 1.108 10-Jun-2016 ozaki-r

Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.


# 1.107 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.


Revision tags: nick-nhusb-base-20160529
# 1.106 24-Apr-2016 christos

CID 980057, 980058, use strlcpy()


Revision tags: nick-nhusb-base-20160422
# 1.105 15-Apr-2016 ozaki-r

Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

From s-yamaguchi@IIJ


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.104 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


# 1.103 20-Aug-2015 christos

include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.102 18-Oct-2014 snj

branches: 1.102.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.101 13-Sep-2013 martin

Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.100 17-Jul-2013 oki

if received PADT, get correct sc related with session id.
RFC2516 5.5 says, no tags required in PADT packet.


# 1.99 29-Jun-2013 rmind

- 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.98 05-Sep-2011 rjs

branches: 1.98.2; 1.98.12; 1.98.16;
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.97 30-Aug-2011 rjs

Typo in comment.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 rmind-uvmplock-base
# 1.96 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.95 19-Jan-2010 pooka

branches: 1.95.2; 1.95.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base
# 1.94 19-Feb-2009 christos

PR/40690: Jordan Gordeev: pppoe(4) doesn't work when PPPoE relays are present
Add support for sending the session id tag back.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 haad-dm-base mjf-devfs2-base
# 1.93 15-Oct-2008 scw

branches: 1.93.2; 1.93.4; 1.93.8;
Reduce the scope of PPPoE session IDs from globally unique to per-interface
unique. Some brands of ADSL modems pick a hard-coded session ID which
would otherwise make it impossible to use two of them in the same system
simultaneously.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.92 19-Aug-2008 martin

Simplify auth failure reconnect a bit and make it more similar to the
session establishment timeout handling.


# 1.91 19-Aug-2008 simonb

Fix a tyop in a comment and a few #define<tab> nits while here.


# 1.90 18-Aug-2008 martin

When upper layer asks us to re-establish a connection, don't do so
synchronously, but insert a (varying) delay. Before we have only been
decoupled from the peer via network latency - now we introduce some
explicit delay. This, at least, creates batter serialized debug output.

However, if we have to reconnect because of an authentication failure,
the peer may have just been unable to access it's radius server. (I have
a setup where this seems to happen every now and then, depending on time
of day.) Backoff reconnect in this cases seriously longer - this is better
than hitting the max-auth-failure limit within a few seconds.


# 1.89 18-Aug-2008 martin

Test and handle memory allocation failure for the access concentrator
cookie.


# 1.88 08-Aug-2008 martin

Apply patch from Yasuoka Masahiko in PR kern/39321: fix length check
when parsing pppoe discovery phase packets.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.87 15-Jun-2008 christos

branches: 1.87.2;
- add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.86 28-Apr-2008 martin

branches: 1.86.2; 1.86.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.85 24-Apr-2008 ad

branches: 1.85.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.84 20-Feb-2008 matt

branches: 1.84.6; 1.84.8;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)


Revision tags: mjf-devfs-base
# 1.83 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.


Revision tags: vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-base
# 1.82 25-Dec-2007 perry

Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.81 08-Oct-2007 ad

branches: 1.81.4; 1.81.6; 1.81.10;
Use the softint API.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base2 yamt-x86pmap-base
# 1.80 09-Sep-2007 martin

branches: 1.80.2;
Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.79 09-Jul-2007 ad

branches: 1.79.2; 1.79.6; 1.79.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.78 31-Mar-2007 martin

caddr_t fallout (only visible with options PPPOE_SERVER)


# 1.77 04-Mar-2007 christos

branches: 1.77.2; 1.77.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-RC1 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.76 16-Nov-2006 christos

branches: 1.76.2; 1.76.4; 1.76.8;
__unused removal on arguments; approved by core.


# 1.75 01-Nov-2006 martin

Do not truncate the last char from a remote error message


# 1.74 25-Oct-2006 elad

Kill some KAUTH_GENERIC_ISSUSER uses.


Revision tags: yamt-splraiseipl-base2
# 1.73 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.72 30-Aug-2006 christos

branches: 1.72.2; 1.72.4;
Fix initializers.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.71 05-Aug-2006 pavel

defflag PPPOE_SERVER and PPPOE_TERM_UNKNOWN_SESSIONS.


# 1.70 23-Jul-2006 ad

Use the LWP cached credentials where sane.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base chap-midi-base
# 1.69 07-Jun-2006 kardel

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


Revision tags: yamt-pdpolicy-base5 simonb-timecounters-base
# 1.68 14-May-2006 elad

branches: 1.68.2;
integrate kauth.


Revision tags: elad-kernelauth-base
# 1.67 27-Apr-2006 tron

Adapt maximum MTU permitted on pppoe(4) interfaces to the MTU of the
connected ethernet interface.


# 1.66 27-Apr-2006 tron

Don't allow to connect a non ethernet interface to a PPPoE interface.


# 1.65 15-Apr-2006 christos

Don't try to free a NULL mbuf.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.64 31-Jan-2006 martin

branches: 1.64.2; 1.64.4; 1.64.6; 1.64.8; 1.64.10;
Make sure error messages (received from the access concentrator) are
zero terminated.


# 1.63 11-Dec-2005 thorpej

branches: 1.63.2;
ANSI function decls and application of static.


# 1.62 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.61 31-Aug-2005 martin

Fix bogus uninitialized variable warning ifdef PPPOE_SERVER.
Noticed by Marcin Jessa on current-users.


# 1.60 29-May-2005 christos

branches: 1.60.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.


Revision tags: netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.59 26-Feb-2005 perry

branches: 1.59.2; 1.59.4;
nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base
# 1.58 19-Jan-2005 martin

branches: 1.58.2;
Remove deleted interfaces from the instance list (inspired by an OpenBSD
change). While there, fix a comment.


Revision tags: kent-audio1-beforemerge
# 1.57 08-Dec-2004 martin

branches: 1.57.2;
Factor out softc cleanup after loss of session into pppoe_clear_softc.
Use this when loosing the ethernet interface (when it deataches).
Fixes PR kern/28375.


Revision tags: kent-audio1-base
# 1.56 04-Dec-2004 peter

Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.


# 1.55 28-Nov-2004 skrll

Re-order the inclusion of opt_pfil_hooks so PFIL_HOOKS gets set properly.


# 1.54 28-Nov-2004 martin

Add a pfil(9) hook to get notified when interfaces detach.
When the ethernet interface of a pppoe pseudo-interface detaches, remove
the association and mark the pppoe interface down.
This should fix PR kern/28375.


# 1.53 21-Apr-2004 itojun

kill sprintf, use snprintf


# 1.52 30-Mar-2004 oki

fixed mbuf leak if up pppoe but not connected an ether i/f.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 28-Nov-2003 keihan

branches: 1.51.4;
s/netbsd.org/NetBSD.org/g


# 1.50 30-Oct-2003 simonb

Remove some assigned-to but otherwise unused variables.


# 1.49 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.48 26-Sep-2003 wiz

Process has only one c. From miod@openbsd.


# 1.47 16-Sep-2003 martin

Tell copyinstr about the real buffer size (not one byte to few). Add more
error checking. Noticed by Quentin Garnier.


# 1.46 03-Sep-2003 martin

If the peer cares to send us error messages, actually display them.


# 1.45 23-Aug-2003 martin

When trying to (re-)establish a session cope with intermediate output
failures of the underlying ethernet interface - just keep trying.


# 1.44 27-Jun-2003 oki

branches: 1.44.2;
Put correct dest ether address on PPPoE server mode.


# 1.43 18-Jun-2003 oki

Add support in-kernel PPPoE server.
This may work with one PPPoE session.
If you want to use it, #define PPPOE_SERVER in somewhere,
or add options PPPOE_SERVER in kernel config file.

This is experimental code, and good start point for future development.


# 1.42 01-Mar-2003 martin

Backout previous, I'm on crack obviously.


# 1.41 01-Mar-2003 martin

Initialize sc to NULL, it could be used uninitialized otherwise when
searching for our sc by host unique tag.


# 1.40 01-Mar-2003 aymeric

when looking up a Host-Uniq tag, do not consider NULL as a valid
(struct pppoe_softc *). Although we do not generate such tags, other hosts
could and some actually do.


# 1.39 04-Feb-2003 martin

PADT is always send with ethertype PPPOE_DISCOVERY, no matter if we
have reached session state or not.

Fixes PR kern/20203 by Shoichi Miyake.


# 1.38 03-Feb-2003 thorpej

Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.37 07-Jan-2003 martin

Fix broken error handling in case M_PREPEND fails.
Noticed by Matthias Scheeler.


Revision tags: fvdl_fs64_base
# 1.36 25-Dec-2002 martin

In do not call pppoe_abort_connect if we fail to send the initial PADI
packet - there is nothing to abort.
In pppoe_abort_connect rearange state handling slightly to avoid calls
to the PPP LCP state machine get into an infinite recursion.

This should fix the symptoms of PR kern/19500, but does not touch the
real cause for the lossage described there.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.35 01-Sep-2002 martin

Apply patch from Todd Vierling in PR kern/17665:

remove a test that has been obsoleted by the authentication failure
counter - enter slow retry mode always, not only if we already transfered
data successfully (the test was designed to disable retries when the
initial authentication setting was not correct, the auth failure counter
does this job better).


# 1.34 01-Sep-2002 martin

Add an option PPPOE_TERM_UNKNOWN_SESSIONS to forcefully disconnect sessions
we don't know anything about with a PADT packet.

Use with care, this is pretty dangerous and will kill all userland PPPoE
implementations. Therefore it is not enabled by default nor added as
a commented out option to GENERIC kernels.

But it is highly usefull if you have a fixed IP, an ISP that does not use
LCP echo requests for link monitoring and you want to recover quickly after
a crash or otherwise ungracefull disconnect.


Revision tags: gehenna-devsw-base
# 1.33 25-Aug-2002 tron

Fix typo in a comment.


# 1.32 22-Jun-2002 yamt

- free buf when unneeded.
- pass a consistent type to free(9).


# 1.31 22-Jun-2002 yamt

fix loop condition.
(don't skip last tag)


# 1.30 22-Jun-2002 itojun

avoid unneeded call to m_pullup


# 1.29 22-Jun-2002 itojun

do not require PPPoE control packet to be put into a single mbuf.
reviewed/tested by ymmt


# 1.28 22-Jun-2002 itojun

more style


# 1.27 22-Jun-2002 itojun

style


# 1.26 22-Jun-2002 itojun

more KNF. warn about mbuf misuse (passing pointer outside of mbuf is dangerous)


# 1.25 22-Jun-2002 itojun

tabify. minor KNF


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.24 14-Apr-2002 martin

branches: 1.24.2; 1.24.4;
Fix copyright notice.


Revision tags: eeh-devprop-base newlock-base
# 1.23 04-Mar-2002 martin

Avoid noise from the kernel if we have pseudo-device pppoe configured
but not used and a userland PPPoE pkg sends/receives PPPoE packets.


Revision tags: ifpoll-base
# 1.22 24-Feb-2002 martin

Clear M_BCAST and M_MCAST flags on mbufs before passing them down to the
ethernet driver - just in case it would look at them and do the wrong
thing.


# 1.21 10-Feb-2002 martin

Fix typo in comment.


# 1.20 01-Feb-2002 martin

Avoid any non-error output for normal operations, only print those
messages if the interface is set to debug.


# 1.19 01-Feb-2002 martin

Tweak the slow-but-persistent connection reestablishment timeout, retrying
is not realy expensive - do it once every minute.

Prevent the MTU from being set bigger than what we can handle.


# 1.18 14-Jan-2002 kleink

As discussed with Aymeric, <machine/intr.h> is always required, so don't
make its inclusion conditional.


# 1.17 14-Jan-2002 aymeric

Don't include machine/types.h (my fault in previous commit)
Reported by Klaus Klein.


# 1.16 13-Jan-2002 aymeric

include machine/types.h
include machine/intr.h if defined(__HAVE_GENERIC_SOFT_INTERRUPTS)
It makes this file compile for the amiga.


# 1.15 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.14 16-Dec-2001 martin

Cleanup softc more completely on "ifconfig down", but only if we are
currently in a connection reestablishement state.

The previouse (incomplete/unconditional) cleanup confused the state machine.


# 1.13 16-Dec-2001 martin

Fix packet accounting (now netstat -i and netstat -ib show reasonable
values).

Implement a secondary connection-reestablishement mode, which is only
entered after (1) we have successfully transfered payload data over this
connection and (2) if initial retries did not reestablish a session.
In this mode we retry (infrequently) forever, until adminstrator stops
us (by "ifconfig ppppoe0 down"). XXX - need to display this mode in
pppoectl.

It is now possible to pull the DSL modems plug for say 15 minutes, plug
it back in again and just wait. The connection will be reestablished within
three minutes.


# 1.12 15-Dec-2001 martin

Enable additional error messages for the discovery phase, clarify some
others. Change one timeout slightly - we need to make all others user
settable.


# 1.11 10-Dec-2001 martin

Enable active LCP keepalive handling in the PPP layer, the PPPoE layer
itself has no means to detect broken connections.


# 1.10 10-Dec-2001 martin

Now that everything works without LINK1 set, do not set it by default.
While here, remove an unnecessary splnet()/splx() pair.


# 1.9 01-Dec-2001 martin

Fail early when trying to identify a pppoe interface softc (from a
HOST UNIQUE token) and our list of interfaces is empty. Without this
test an unitinalized pointer may be dereferenced.


# 1.8 13-Nov-2001 lukem

remove unnecessary #if NFOO > 0 .... #endif wrappers


# 1.7 12-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.6 28-Oct-2001 martin

Don't call if_alloc_sadl when creating the pppoe interface, it's called
from sppp_attach.
When destroying the interface, call sppp_detach for proper cleanup.
This avoids a crash from the slow timeout handler for no longer existing
interfaces (spotted by R�mi Zara).


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.5 04-Sep-2001 martin

branches: 1.5.4;
Make this interface cloning.


# 1.4 24-Jun-2001 martin

branches: 1.4.2;
Take into account the two byte PPP protocol discrimator following the PPPoE
header when calculating the MTU. Ooops...

Thanks to Mario Kemper for noting this.


# 1.3 18-Jun-2001 martin

branches: 1.3.2;
Protect interface queue manipulations by splnet(). Splsoftnet() is not
enough.


# 1.2 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


# 1.1 29-Apr-2001 martin

Add an in-kernel PPPoE (ppp over ethernet, RFC 2516) implementation,
based on the existing net/if_spppsubr.c stuff.

While there are completely userland (bpf based) implementations available,
those have a vastly larger per packet overhead thus causing major CPU
overhead and higher latency. On an i386 base router, running a 486DX at 50MHz
my line (768kBit/s downstream) was limited to something (varying) between 10
and 20 kByte/s effective download rate. With this implementation I get full
bandwidth (~85kByte/s).

This is client side only. Arguably the right way to add full PPPoE support
(including server side) would be a variation of the ppp line discipline and
appropriate modifications to pppd. I promise every help I can give to anyone
doing that - but I needed this realy fast. Besids, on low memory NAT boxes
with typically a single PPPoE connection, this implementation is more
lightweight than a pppd based one, which nicely fits my needs.