Commit Graph

102 Commits

Author SHA1 Message Date
Pedro F. Giffuni
053359b7f4 sys/netgraph: spelling fixes in comments.
No functional change.
2016-04-29 21:25:05 +00:00
Alexander Motin
5b363c09dc Add support for PPP-Max-Payload PPPoE tag (RFC4638).
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	2 weeks
2015-09-11 09:15:27 +00:00
Gleb Smirnoff
5c6d5d5598 Add constant for PPP-Max-PayLoad tag.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov gmail.com>
2013-07-23 10:25:34 +00:00
Gleb Smirnoff
eb1b1807af Mechanically substitute flags from historic mbuf allocator with
malloc(9) flags within sys.

Exceptions:

- sys/contrib not touched
- sys/mbuf.h edited manually
2012-12-05 08:04:20 +00:00
Ed Schouten
d745c852be Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.
This means that their use is restricted to a single C file.
2011-11-07 06:44:47 +00:00
Gleb Smirnoff
674d86bf91 Node constructor methods are supposed to be called in syscall
context always. Convert nodes to consistently use M_WAITOK flag
for memory allocation.

Reviewed by:	julian
2011-04-18 09:12:27 +00:00
Alexander Motin
5a73d193c4 Remove some dead and incorrect code.
Found with:   Coverity Prevent(tm)
CID:          4562
2010-06-05 10:16:23 +00:00
Ed Schouten
60d234c583 Make Netgraph compile with Clang.
Clang disallows structs with variable length arrays to be nested inside
other structs, because this is in violation with ISO C99. Even though we
can keep bugging the LLVM folks about this issue, we'd better just fix
our code to not do this. This code seems to be the only code in the
entire source tree that does this.

I haven't tested this patch by using the kernel modules in question, but
Diane Bruce and I have compared disassembled versions of these kernel
modules. We would have expected them to be exactly the same, but due to
randomness in the register allocator and reordering of instructions,
there were some minor differences.

Approved by:	julian
2009-03-03 18:47:33 +00:00
Alexander Motin
dda30f129e Use more compact LIST instead of TAILQ for session hash.
Add all listening hooks into LIST to simplify searches.
Use ng_findhook() instead of own equal implementation.
2008-03-03 19:36:03 +00:00
Alexander Motin
bd500dab7f Make session ID generator to use session ID hash.
Make session ID generator thread-safe.
2008-03-02 23:26:35 +00:00
Alexander Motin
b4d0be220a Do not use bcmp() to compare two bytes with constants. 2008-02-06 20:37:34 +00:00
Alexander Motin
b1a3358ba3 Tune the message for better informativity.
Print the hook pointer as other functions do.
2008-02-01 07:25:06 +00:00
Benno Rice
db2dabf87c Band-aid recent commit by mav by replacing a variable in a CTR statement with
the variable that appears as if it should've been there.

Pointy hat to:		mav
Not tested either by:	benno
2008-02-01 07:17:26 +00:00
Alexander Motin
b2b5279b25 Implement Session-ID hashing to improve receive performance scalability
for big number of concurrent sessions.
2008-01-31 22:42:37 +00:00
Alexander Motin
098ff746f8 Add support for optional "AC-Name\Service-Name" syntax at NGM_PPPOE_CONNECT
argument. It allows ppp, mpd or any other node consumer to request
connection to specified access concentrator.

Proposed by:	Alexander A. Burylov <burylov@mail.ru>
2007-12-29 19:44:41 +00:00
Alexander Motin
97b4f83bb3 Fix incorrectly placed bracket in pppoe_find_svc(). 2007-12-26 19:33:53 +00:00
Alexander Motin
98e7b7536b Split ng_pppoe_rcvdata() function into three hook-specific ones
to simplify code and reduce stack usage.
2007-10-14 09:58:22 +00:00
Alexander Motin
8cfaad5f6a Remove ng_pppoe_sendpacket() function to simplify code as it is called
as much times as it has cases inside of it.
2007-10-14 09:51:19 +00:00
Alexander Motin
661e502900 Dead code removal.
Approved by:	re (kensmith), glebius (mentor)
2007-09-21 08:25:55 +00:00
Alexander Motin
99f4de905c This is optimization of ether and debug hooks determination. It
simplifies code and should speedup pppoe_findsession() function which is
called for every incoming packet.

Approved by:	re (kensmith), glebius (mentor)
2007-09-21 08:24:08 +00:00
Alexander Motin
1e7d84b055 This patch fixes thread unsafe usage of global pkt_hdr
variable. Second part is not so important, but IMO is also good.

Approved by:	re (kensmith), glebius (mentor)
2007-09-21 08:16:33 +00:00
Gleb Smirnoff
f366efa96f Some perfectionizm against last revision.
Submitted by:	ru
2006-08-10 11:07:11 +00:00
Gleb Smirnoff
b1ba28df1d Fix ng_pppoe(4) after turning off "autosrc feature" on ng_ether(4).
- Store the Ethernet header in node softc.
- Initialize header with dst addr and ethertype in node
  constructor method.
- In node connect method send NGM_ETHER_GET_ENADDR message
  downwards.
- If received reply from ng_ether(4) store the src addr
  in softc.
- Add NGM_PPPOE_SETENDADDR message that allows user to
  override the address with whatever he/she wants.
2006-08-09 09:56:58 +00:00
Gleb Smirnoff
2e87c3cc4d - Use log(9) instead of printf(9).
- Print node ID, where possible.
- Prepend log messages with function name, or at least with "ng_pppoe".

Reviewed by:	julian
Tested by:	Joao Barros <joao.barros gmail.com>
2006-08-07 08:05:10 +00:00
Gleb Smirnoff
1c8aa594a8 o Introduce D-Link compat mode, that is default to off and can be set
by NGM_PPPOE_SETMODE message. When D-Link compat mode is on, we will
  broadcast PADI with empty Service-Name to all listening hooks.
o Rewrite the compatibility options. Before we had two modes - standard
  and non-standard (aka 3Com). Now we have standard mode and two compat
  flags, that can be combined.
o Be consistent and do s/STUPID/3COM/g. I don't say that 3Com mode isn't
  stupid, just want to make code easier to read.
2006-01-27 10:56:22 +00:00
Gleb Smirnoff
68b789b23f From the RFC2516 it is not clear, what is the correct behavior for a
PPPoE AC, servicing a specific Service-Name, when client sends a PADI
with an empty Service-Name. Should it reply with all available service
names or should it be silent? Our implementation had chosen the latter,
while some other had chosen the former (they say Linux and Cisco). Now
some PPPoE clients appear, that rely on the assumption that AC will
send all names in a PADO reply to a PADI with wildcard Service-Name.
These clients can't connect to FreeBSD AC.

I have requested comments from authors of RFC2516 via email, but
received no reply.

This change makes FreeBSD AC compatible with D-Link DI-614+ and
D-Link DI-624+ SOHO routers, and probably others.

Big thanks to D-Link's Russian office, namely Victor Platov, for
assistance and support in investigation and testing of this change.

Details:
  o Split pppoe_match_svc() into three different functions serving
    different purposes:
    - pppoe_match_svc() - match non-empty Service-Name tag from PADI
      against all available hooks in listening state.
    - pppoe_find_svc() - check that given Service-Name is not yet
      registered.
    - pppoe_broadcast_padi() - send a copy of PADI packet with empty
      Service-Name tag to all listening hooks.
  o For NGM_PPPOE_LISTEN message use pppoe_find_svc().
  o In ng_pppoe_rcvdata() in a PADI case use pppoe_match_svc() for
    a non-empty Service-Name tag, and pppoe_broadcast_padi() in
    either case.

A side effect from the above changes is that now pppoed(8) and mpd
will reply to a empty Service-Name PADI sending a PADO with two
Service-Name tags - an empty one and correct one. This is not fatal,
and will be corrected in pppoed(8) and mpd later. No need to update
node interface version.

Supported by:	D-Link
2006-01-26 13:06:49 +00:00
Gleb Smirnoff
7762e8c630 - Remove debugging printfs.
- Add some ktr(4) debugging.
- Whitespaces at eols.
- Tidy up comments.
- u_intXX -> uintXX
2006-01-21 08:13:19 +00:00
Gleb Smirnoff
f795fd004d Dej'a vu of revision 1.35
PR:		kern/86258
Submitted by:	Hiroshi Oota <ghelp excite.co.jp>
2005-09-19 11:49:54 +00:00
Gleb Smirnoff
ae1ff8e34f Remove obsoleted sysctl interface for switching between standard and 3Com
PPPoE modes. The interface was declared obsoleted before 5.3-RELEASE.

When running as access concentrator ng_pppoe(4) supports both modes
simultanously. When running as client mode can be swicthed in ppp(8)
configuration.

Approved by:	re (scottl)
2005-07-05 17:51:02 +00:00
Gleb Smirnoff
30afbe338b Remove ng_connect_t where it is unused. Probably it remained from ng_source.c. 2005-03-14 20:49:48 +00:00
Ruslan Ermilov
48f4d9918c Drop mythical module dependency on ng_ether. 2005-02-13 00:50:18 +00:00
Warner Losh
c398230b64 /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
Gleb Smirnoff
ef237c7faf - Use ng_callout() instead of timeout()
- remove spl(9) calls

Tested by:	Ilya Pizik
Approved by:	julian (mentor)
2004-12-08 13:27:54 +00:00
Gleb Smirnoff
ec774932ba Since last change moved ';' from macro to code, we need to embrace
macros with 'do {} while (0)' to avoid error in case macro is
not defined.

Prodded by:	julian, archie
Pointy hat to:	glebius
2004-10-31 17:32:51 +00:00
Gleb Smirnoff
f2b9562c53 Rename debug macro to DBG and indent it properly.
Requested by:	maxim
Approved by:	julian (mentor)
2004-10-28 18:23:44 +00:00
Gleb Smirnoff
c0451ac3d9 Another stupid error from my side. PPPOE_NONSTANDARD was first defined
in enum {}, and then redefined with #define.
No warnings from compiler, though.

Submitted by:	bz
Pointy hat to:	glebius
2004-08-01 20:39:33 +00:00
Gleb Smirnoff
fdc755d162 When node is server serve both standard RFC2516 and non-standard 3Com
clients simultaneously. When node is client its mode is configured
with a control message.

sysctl net.graph.nonstandard_pppoe is deprecated but kept for
backward compatibility for some time.

Approved by:	julian
2004-07-27 19:47:13 +00:00
Robert Watson
6f7d64c44a Add a note indicating that the eh_prototype field used to construct
ethernet headers is unsynchronized.
2004-07-14 20:31:37 +00:00
Julian Elischer
3ca24c284d Having moved metadata usage to mbuf tags, remove code that supports
the old way of doing it.

Submitted by:	Gleb Smirnoff <glebius@cell.sick.ru>
2004-06-26 22:24:16 +00:00
Julian Elischer
f8aae7776f Switch to using C99 sparse initialisers for the type methods array.
Should make no binary difference.

Submitted by:	Gleb Smirnoff <glebius@cell.sick.ru>
Reviewed by:	Harti Brandt <harti@freebsd.org>
MFC after:	1 week
2004-05-29 00:51:19 +00:00
Hartmut Brandt
87e2c66a6a Get rid of the deprecated *LEN constants in favour of the new
*SIZ constants that include the trailing \0 byte.
2004-01-26 14:05:31 +00:00
Yaroslav Tykhiy
e883537ce7 The default value of net.graph.nonstandard_pppoe is changed to -1,
which means "always stay in the standard mode of PPPoE operation
regardless of any junk floating around."

As the referenced PR stated clearly, the old default setting of 0
was extremely dangerous because it opened a possibility for a
spurious frame not only to put down a single PPPoE node running
FreeBSD, but to plague *every* FreeBSD node in a PPPoE network in
such a way that those nodes would keep poisoning each other until
rebooted simultaneously.

PR:		kern/47920
Reviewed by:	Gleb Smirnoff <glebius <at> cell.sick.ru>
MFC after:	1 week
2003-12-19 16:03:28 +00:00
Ruslan Ermilov
9ab65054a7 Fixed compilation on 64-bit platforms. 2003-12-19 09:34:37 +00:00
Yaroslav Tykhiy
875467fafa There are two modes of ng_pppoe operation, standard and
nonstandard.  They differ in the values of certain fields in
the PPPoE frame.  Previously, ng_pppoe would start in standard
mode, yet switch to nonstandard one upon reception of a single
nonstandard frame.  After having done so, ng_pppoe would be unable
to interact with standard PPPoE peers.  Thus, a DoS condition
existed that could be triggered by a buggy peer or malicious party.

Since few people have expressed their displeasure WRT this problem,
the default operation of ng_pppoe is left untouched for now.  However,
a new value for the sysctl net.graph.nonstandard_pppoe is introduced,
-1, which will force ng_pppoe stay in standard mode regardless of any
bogus frames floating around.

PR:		kern/47920
Submitted by:	Gleb Smirnoff <glebius <at> cell.sick.ru>
MFC after:	1 week
2003-12-18 16:38:35 +00:00
Warner Losh
a163d034fa Back out M_* changes, per decision of the TRB.
Approved by: trb
2003-02-19 05:47:46 +00:00
Alfred Perlstein
44956c9863 Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
2003-01-21 08:56:16 +00:00
John Baldwin
a2a6abd546 Use %z to print a size_t value. 2002-11-08 14:50:44 +00:00
Alfred Perlstein
4f492bfab5 use __packed. 2002-09-23 18:54:32 +00:00
Archie Cobbs
facfd88935 Don't use "NULL" when "0" is really meant. 2002-08-22 00:30:03 +00:00
Brian Somers
9e6798e7c0 NUL terminate the ACNAME passed to userland. 2002-06-22 21:00:53 +00:00