Commit Graph

6184 Commits

Author SHA1 Message Date
Simon Goldschmidt
3eeda139bc minor coding style/spelling fixes 2023-09-22 09:54:36 +02:00
Simon Goldschmidt
b92faffaaa LWIP_VLAN_PCP==1: initialize tci correctly (disabled); add pcb_tci_*() functions to access the tci 2023-09-22 09:53:13 +02:00
Simon Goldschmidt
84fde1ebbf release: mark 2.2.0 RC1
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2023-06-29 22:22:19 +02:00
Simon Goldschmidt
657c9735a7 doxygen: dhcp: fix doxygen stumbling over nonexisting define 2023-06-29 21:59:05 +02:00
Shawn Silverman
e29870c15e Fix a printf conversion specifier in mdns.c
Use U32_F to print a u32_t.
2023-05-11 22:16:49 +02:00
Shawn Silverman
f84076b112 Add missing terminating newlines to LWIP_DEBUGF statements 2023-05-11 22:13:51 +02:00
Mingjie Shen
2e3dcf06d1 api,sockets: Fix signed overflow check
Signed overflow is undefined behaviour in C/C++.
2023-05-11 21:28:22 +02:00
Mingjie Shen
e3a20b3bc2 mdns: Add null check for pbuf_skip 2023-05-11 21:26:22 +02:00
Jan Breuer
1c5cc7bc02 snmp_v3: fix reported usmUserAuthProtocol for SHA 2023-05-11 21:05:16 +02:00
David Cermak
3aa82745c1 dhcp: Add macro for appending extra client's request options
Co-Authored-By: Liu Han <liuhan@espressif.com>
Co-Authored-By: Simon Goldschmidt <goldsimon@gmx.de>
2023-05-11 21:03:11 +02:00
Logan Gunthorpe
90b2a6b4c4 dhcp: Set hostname for DISCOVER packets
If the hostname is not set in the DISCOVER packet, then some servers might
issue an OFFER with hostname configured and consequently reject the REQUEST
with any other hostname.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Co-Authored-By: Simon Goldschmidt <goldsimon@gmx.de>
2023-05-11 20:59:15 +02:00
xueyunfei
5231c8da23 dhcp: Enable custom config for timeouts, thresholds, backoff time
Enables to configure:
* DHCP_COARSE_TIMER_SECS
* if DHCP_DEFINE_CUSTOM_TIMEOUTS defined these addtional options are
available:
  - DHCP_CALC_TIMEOUT_FROM_OFFERED_T0_LEASE to adjust the t0 lease timeout from the offered value
  - DHCP_CALC_TIMEOUT_FROM_OFFERED_T1_RENEW same for t1 renew
  - DHCP_CALC_TIMEOUT_FROM_OFFERED_T2_REBIND same for t2 rebind
  - DHCP_NEXT_TIMEOUT_THRESHOLD to adjust the period of the next timeout
  - DHCP_REQUEST_BACKOFF_SEQUENCE to adjust back-off times based on DHCP
request attempts
Also updates timeout type from u16 to u32 - eps useful when DHCP_COARSE_TIMER_SECS is a smaller number
2023-05-11 20:49:14 +02:00
David Cermak
00f5e179b5 dhcp: Move in-place timeout/threshold calculations to macros 2023-05-11 20:44:21 +02:00
Simon Goldschmidt
3a9c1e48dd altcp_tls_mbedtls: note which version of mbedtls we are compatible to
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2023-05-10 21:00:23 +02:00
Peter Putz
a9664395b0 pppos: fix in_tail null
happens during quick reconnect of LTE ppp session
2023-05-10 20:57:12 +02:00
David Cermak
6b734bbb2c PPP: Add test exhibiting empty packet null-deref
Also updates lcp.c to compile with PPP_AUTH_SUPPORT=0 in clang
2023-05-10 20:42:27 +02:00
Jonathan Neuschäfer
d8d1e4a015 altcp: Fix NULL pointer dereference found by fuzzing
Reproducer (in bash):

base64 -d <<< "H4sIAP/9L2QCA+3WoQ2AMBSE4QoCTFHBBJfgSRF4RDfpRmgmYBpGQRBCk4ZiSfk/+fJMK+5dZRVpzSQzSs6oPierDV4y87WxLQLwE42SfNCdDyHJB9/xZwAARPbMJbUq4JJmu4JVT1cAAACfbGIqoqcMzy90eu+aBw2+N28WFgAA" | gunzip | test/fuzz/lwip_fuzz2

Crash log:

../../src/core/altcp_tcp.c:178:13: runtime error: member access within null pointer of type 'struct tcp_pcb'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../src/core/altcp_tcp.c:178:13 in
AddressSanitizer:DEADLYSIGNAL
=================================================================
==192415==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000048 (pc 0x557065081703 bp 0x0aae0cb71204 sp 0x7ffd034dabc0 T0)
==192415==The signal is caused by a READ memory access.
==192415==Hint: address points to the zero page.
    #0 0x557065081703 in altcp_tcp_setup_callbacks /.../lwip/test/fuzz/../../src/core/altcp_tcp.c:178:19
    #1 0x55706508206f in altcp_tcp_setup /.../lwip/test/fuzz/../../src/core/altcp_tcp.c:189:3
    #2 0x55706508206f in altcp_tcp_accept /.../lwip/test/fuzz/../../src/core/altcp_tcp.c:84:5
    #3 0x557065095592 in tcp_input /.../lwip/test/fuzz/../../src/core/tcp_in.c:380:9
    #4 0x5570650e752f in ip4_input /.../lwip/test/fuzz/../../src/core/ipv4/ip4.c:743:9
    #5 0x55706513d4de in ethernet_input /.../lwip/test/fuzz/../../src/netif/ethernet.c:186:9
    #6 0x557064fe0959 in input_pkt /.../lwip/test/fuzz/fuzz_common.c:209:9
    #7 0x557064fdeb6a in input_pkts /.../lwip/test/fuzz/fuzz_common.c:257:9
    #8 0x557064fdeb6a in lwip_fuzztest /.../lwip/test/fuzz/fuzz_common.c:669:3
    #9 0x7ff4f578e189 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #10 0x7ff4f578e244 in __libc_start_main csu/../csu/libc-start.c:381:3
    #11 0x557064f20420 in _start (/.../lwip/test/fuzz/lwip_fuzz2+0x81420) (BuildId: 8680a96430d5749c90111fe9c3a3d4f881a5dbcd)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /.../lwip/test/fuzz/../../src/core/altcp_tcp.c:178:19 in altcp_tcp_setup_callbacks
==192415==ABORTING
Aborted
2023-04-07 22:32:18 +02:00
Renzo Davoli
6a350a0278 contrib/port/unix/lib: exclude slipif.c source 2023-04-07 22:07:17 +02:00
Simon Goldschmidt
790b914fea pbuf_copy_partial_pbuf: fix warning about assigning to smaller type when using '-=' operator
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2022-12-22 20:43:18 +01:00
yuanjm
239918ccc1 tcp: Make retransmission timeout (RTO) configurable 2022-05-09 21:24:57 +02:00
Jonathan Demeyer
234d282936 mqtt: Fix typos on 'incomming' 2022-05-09 21:10:34 +02:00
Simon Goldschmidt
a55679224f fs: move prototypes required to implement custom files as fs addon to header 2022-02-12 09:40:32 +01:00
Florian La Roche
62ac0faad8 redefine many vars as "static"
See patch #10156
2021-12-30 22:13:01 +01:00
weycen
9f7d9170c1 netif: fix the netif's index error
When using multiple netifs on one hardware interface (e.g. when mapping multiple IP addresses to one hardware interface), if the netif's low-level receive routine cannot decide for the correct netif, here the `netif` parameter may be a default netif, in this case, `p-> if_idx` will get a wrong netif index value. It should be placed after `netif = LWIP_ARP_FILTER_NETIF_FN(p, netif, lwip_htons(type));`.  Filter function can returns the correct netif before assigning `p-> if_idx`.
2021-12-07 00:57:48 +01:00
0x1abin
63d21c53e5 altcp mbedtls: Compile error fix. 2021-12-07 00:47:05 +01:00
Erik Ekman
17413c28b4 httpd: Add documentation for http_set_cgi_handlers 2021-11-27 20:36:27 +01:00
Erik Ekman
5b9159ce0d api: Adapt doc comment to varying parameters 2021-11-27 20:32:59 +01:00
Erik Ekman
754d628f2d ip_addr: Add description for IP_ANY_TYPE 2021-11-27 20:32:59 +01:00
Erik Ekman
b0361f14c1 netif: Add documentation for mac filter macros 2021-11-27 20:17:30 +01:00
Erik Ekman
2711dbcac0 lwiperf: Complete documentation of lwiperf_report_fn
Doxygen did not like only annotating one parameter.
2021-11-27 20:17:30 +01:00
Erik Ekman
e594742801 altcp: Add doxygen comment for altcp_allocator_t 2021-11-27 20:17:30 +01:00
Erik Ekman
759c38b956 ip_addr: Add text descriptions for ip addr macros
Doxygen seems to ignore them otherwise.
2021-11-27 20:17:30 +01:00
Florian La Roche
089697bb1c Use NULL instead of 0 as a pointer
Recommended by 'sparse' tool
2021-11-27 15:49:20 +01:00
Florian La Roche
53c09fe921 tcp_out: move debug output to after checking pcb 2021-11-24 23:17:16 +01:00
Bas Prins
a44fcb2e2e http_client: reset timeout when receiving data
This fixes downloads longer than 15 seconds.
See bug #60787 (http_client does not reset timeout counter)

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-11-12 23:11:22 +01:00
Simon Goldschmidt
a72fc743ef update tinydir.h to newest version
Update to cxong/tinydir commit 97a6032ddb ("Fix tinydir_file_open for root or subfolder of root in Linux.")

This should fix bug #61106 (compiling newest source fails with "-O3" optims)
2021-11-12 22:56:56 +01:00
Tom Collins
601e1bb326 altcp mbedtls: fix error in preprocessor logic setting ALTCP_MBEDTLS_PLATFORM_ALLOC
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-11-12 22:31:04 +01:00
Simon Goldschmidt
39a9c5a3c5 netif: fix removing ext-callback while callback is called
When a registered netif ext-callback unregisters itself when being
called (e.g. because some state is reached by this event), the invoke
iteration might access uninitialized memory or at least stop the
iteration (because next is set to null).

Fix his by caching the next pointer during iteration before calling
callbacks.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-10-01 19:44:07 +02:00
Jannis Achstetter
7ec4e9be30 makefsdata: Support using the system's zlib instead of only minizip for deflate compression and note so in the readme
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-05-21 22:32:37 +02:00
Simon Goldschmidt
a8e8ce4108 dhcp: don't set a default gateway if dhcp server doesn't give one
see bug #60578
2021-05-14 10:32:57 +02:00
Axel Lin
919dc2019a acd: Fix updating prev pointer in acd_remove
Fixes: 3a788b6e8b ("dhcp: remove acd handle when stopping dhcp")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2021-05-14 13:48:43 +08:00
Eric Koldeweij
b538bff383 ip6: Fix crash in ip6_output with debug enabled
It turns out the crash only occurs if LWIP_DEBUG is enabled. If the
parameter dest is NULL the function tries to find a route using the
destination address of the packet instead. If this fails as well a
debug message is printed but it is still using dest causing a NULL
pointer dereference and crash at src/core/ipv6/ip6.c line 1312.

[erik@kryo.se: Apply fix to ip6_output_hinted as well]
2021-05-13 13:40:33 +02:00
Erik Ekman
b9056e148e acd: Fix LWIP_ASSERT argument order 2021-05-13 13:28:02 +02:00
Simon Goldschmidt
3a788b6e8b dhcp: remove acd handle when stopping dhcp
see bug #57706
2021-05-12 21:05:17 +02:00
Simon Goldschmidt
fa5ca55c9d pbuf_realloc: check that mem_trim does not move the memory
Our own implementation does not do this, but overridden implementations
calling 'realloc()' might invalidly do this
2021-05-12 21:05:17 +02:00
Erik Ekman
b0e347158d dhcp: Add missing newline to debug message 2021-03-25 20:56:21 +01:00
Simon Goldschmidt
0056522cc9 netdb: improve documentation of LWIP_DNS_API_HOSTENT_STORAGE 2021-03-05 13:04:59 +01:00
Simon Goldschmidt
8a900aa81f netdb: fix alignment warning in debug output
see bug #58650
2021-03-05 13:04:18 +01:00
Simon Goldschmidt
3ff267fbed dhcp: prevent dhcp_cleanup passing external data to heap 2021-03-04 22:20:17 +01:00
Simon Goldschmidt
c7e1b35899 dhcp: convert 'subnet_mask_given' to 'flags'
Don't waste 7 bits (in preparation for more flags)
2021-03-04 22:16:19 +01:00
Simon Goldschmidt
18b1178e0c makefsdata: add version info
This is required to make it possible to see you're using an old version if something doesn't work...
See task #15331
2021-03-04 21:51:06 +01:00
Harrold Spier
79c8a04152 SNMP netconn API should not check for core locked
See patch #9907
2021-03-04 21:29:20 +01:00
Jeremy HU
4a169109a7 makefsdata: Fix flags missing
Fix the Perl script from which the generated fsdata.c cause runtime assertion: "HTTP headers not included in file system".
2021-03-04 21:16:48 +01:00
Oliver Hitz
b5176936c7 tcp: make tcp_listen() inherit the netbuf_idx of the original pcb
This simple patch causes tcp_listen() to inherit the netbuf_idx setting
of the original pcb. Without this, it is not possible to restrict a
socket to a specific interface using SO_BINDTODEVICE before listening.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-03-04 21:15:25 +01:00
Simon Goldschmidt
3666dcc66c tcp: send RST to input netif when no pcb is available
If we know there's no matchin pcb (e.g. for routing), don't even
try to pass NULL but instead send the RST to the input netif.

See also patch #9988.
2021-03-04 21:10:28 +01:00
Simon Goldschmidt
1f4a029d10 mqtt: check data_cb != NULL 2021-03-04 20:18:04 +01:00
Simon Goldschmidt
d7a0757764 mqtt: allow calling mqtt_set_inpub_callback before mqtt_client_connect
See also patch #10037
2021-03-04 20:14:46 +01:00
Christoffer Lind
600e248f06 dhcp: generate new xid for DHCP release 2021-03-02 22:49:57 +01:00
Erik Ekman
e02d126b07 lowpan6: Use arch-independent printf formatters 2021-02-13 21:14:29 +01:00
Thomas Mueller
7a2923020f Fix typo in definition of netif_is_flag_set() macro 2021-02-08 19:17:20 +01:00
Simon Goldschmidt
9aae444f49 pbuf_free: remove outdated comment about packet queues
See bug #59875
2021-01-30 22:08:36 +01:00
Simon Goldschmidt
3e098f90df pbuf: fix allocating large PBUF_RAM
See bug #59974
2021-01-30 22:06:46 +01:00
Mike Kleshov
6fee08daab httpd: revert part of previous change
pextension needs to be zeroed in case fs_file structure
is reused in a persistent HTTP connection
2021-01-29 08:02:56 +03:00
yuanjm
b00a05d086 lwip_selscan: lwip_selscan return -1 without setting errno number
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-01-28 21:00:37 +01:00
Simon Goldschmidt
fc5b6f7b0e lwiperf: fix double-free of pcb on error
See bug #59841 (PCB double-free happened at lwiperf TCP error)

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-01-28 20:00:11 +01:00
Mike Kleshov
9b040624c0 httpd: follow-up to previous commit
see bug #59876
2021-01-28 19:53:57 +03:00
Mike Kleshov
69725292a0 httpd: wrap fs_file::pextension in a config macro
see bug #59876
2021-01-28 08:29:25 +03:00
Mike Kleshov
89dca4588f httpd: follow-up to previous commit, replace strstr() with memcmp() 2021-01-27 19:28:19 +03:00
Mike Kleshov
fdd702e61b httpd: fix bug #58223 2021-01-26 19:19:32 +03:00
Mike Kleshov
1678b21a94 httpd: remove fs_file::is_custom_file, use fs_file::flags instead 2021-01-25 21:49:17 +03:00
Erik Ekman
651d0af0b6 netdb: Accept '0' as service in lwip_getaddrinfo
Fixes bug #59925
2021-01-22 20:20:51 +01:00
Erik Ekman
b5618c51ca altcp: Fix memory leak in altcp_tls_free_config
Reported in bug #59032 by Ondrej Lufinka,
fix suggested by David GIRAULT.
2021-01-13 22:19:47 +01:00
Erik Ekman
35550eeab3 icmp: Fix copied length in response packets
Fixes bug #59364, reported by Yi Guai
2021-01-13 20:31:55 +01:00
Mike Kleshov
c6777547f6 Make sure tag insertion is complete when tag is followed by EOF.
See bug #59728.

Signed-off-by: Mike Kleshov <m.kleshov@gmail.com>
2021-01-01 11:26:30 +03:00
Erik Ekman
c748395bda PPP: Change data argument in sio_write to const
To fix the build after ppp_output_cb started taking it as const in
commit b2d1fc119d.

Fixes this failure:
../contrib/examples/ppp/pppos_example.c: In function ‘ppp_output_cb’:
../contrib/examples/ppp/pppos_example.c:163:29: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
   return sio_write(ppp_sio, (u8_t*)data, len);
                             ^
2020-12-03 09:47:00 +01:00
Sylvain Rochet
d1fc5c2ec4 PPP: add one more timer to PPP_NUM_TIMEOUTS_PER_PCB for late authentication
Authentication timer might still be running when entering network phase
for any necessary rechallenge, mostly for PPP server support.

Update the detailed analysis of simultaneously running PPP timers
taking into account the authentication timer that might still be
running and chose to increase the base number to 2 instead of
adding more unnecessary complexity.
2020-11-17 01:19:21 +01:00
Sylvain Rochet
9a9d92a59e PPP, PAP: cancel PAP timeout when authentication succeed or fail
upap_timeout is not currently stopped on authentication success or
fail events. This may have strange results if session is restarted
in a high pace because even if the timeout callback have a sanity
check against the PAP state the session can be restarted and be
back in the valid state before the timeout callback is actually
called.
2020-11-17 00:50:50 +01:00
Sylvain Rochet
3013e1fc19 PPP: remove unused ppp_pcb CHAP fields if server mode is disabled
pcb->settings.chap_timeout_time and pcb->settings.chap_max_transmits
are only used if server mode is enabled.
2020-11-17 00:26:32 +01:00
Sylvain Rochet
a4514cf416 PPP: fix unused parameter warning on prot_flavor if CHAP support is disabled
prot_flavor parameter is only used if CHAP support is enabled.
2020-11-16 22:26:00 +01:00
Sylvain Rochet
332119d7e0 PPP, magic: dot not assume LWIP_RAND will return 32 bits of randomness
Do not assume LWIP_RAND will return 32 bits of randomness because it is
probably going to be defined to directly return the rand() value. For
example, LCP magic numbers are 32-bit random values.
2020-10-27 21:52:18 +01:00
Sylvain Rochet
e239222775 PPP, magic: cleanup code and documentation
Documentation and simple code cleanup, no behavior change.
2020-10-27 21:47:26 +01:00
Sylvain Rochet
72d9132ecf PPP, PPPoL2TP: skip address & flags for PPP control packets
This is already what we inherently have always done for IPv4/IPv6
packets, so it works. Receivers must handle both cases anyway because
both behaviors are seen in the wild.
2020-10-23 17:34:25 +02:00
Sylvain Rochet
a494b990da PPP, PPPoS: drop in flight packets from the tcpip mailbox if PPP session is down
A previous call to ppp_input might have disconnected the session while
there were still packets in flight in the tcpip mailbox. Drop incoming
packets because ppp_input must never be called if the upper layer is
down.
2020-10-22 23:03:56 +02:00
Sylvain Rochet
a9f19cd7f1 PPP, PPPoS: only check open flag after events that may have changed it
Speed-up a little bit the PPPoS input parser by only checking the open
flag after calling the ppp_input function, the only one that can induce
a state change here.
2020-10-22 20:56:23 +02:00
Sylvain Rochet
22f13c24aa PPP: assert if ppp_set_* functions are called when session is not dead
ppp_set_* functions that set the PPP session parameters must only be
called when the session is in a dead state (i.e. disconnected),
otherwise not fatal but surprising results may happen.
2020-10-21 02:11:59 +02:00
Sylvain Rochet
dbb7c00aa5 PPP: add LWIP_ASSERT_CORE_LOCKED to ppp_set_notify_phase_callback
This function call the notify phase callback that should be called from
the lwIP core thread. This is especially true if the user callback
is not designed to be reentrant.
2020-10-21 01:43:57 +02:00
Freddie Chopin
c18a8dc9cc PPP, PPPoS: Remove useless cast from pppos_output_append() and pppos_output_last()
pppos_output_cb_fn() now takes `const void*`, so there is no need to
cast the payload (`void*`) to anything else.
2020-10-20 05:38:05 +02:00
Freddie Chopin
b2d1fc119d PPP, PPPoS: Use const void* instead of u8_t* in pppos_output_cb_fn()
There is no good reason why this function should take a non-const
pointer, as the output callback should never modify what lwIP gives it.
While changing that also switch to a more generic `void*` instead of
"byte".
2020-10-20 05:38:03 +02:00
Freddie Chopin
34156e0594 PPP, PPPoS: Remove useless cast from pppos_input_sys()
pppos_input() now takes `const void*`, so there is no need to cast the
payload (`void*`) to anything else.
2020-10-20 05:30:21 +02:00
Freddie Chopin
5ad2f06333 PPP, PPPoS: Use const void* instead of u8_t* in pppos_input()
There is no good reason why this function should take a non-const
pointer. While changing that also switch to a more generic `void*`
instead of "byte".
2020-10-20 05:30:17 +02:00
Freddie Chopin
c5021bdc4d PPP, PPPoS: Use const void* instead of u8_t* in pppos_input_tcpip()
There is no good reason why this function should take a non-const
pointer. While changing that also switch to a more generic `void*`
instead of "byte".
2020-10-20 05:30:12 +02:00
Sylvain Rochet
3b57750715 PPP: remove LWIP_ASSERT_CORE_LOCKED on ppp_set_auth function
We do not have equivalents in PPPAPI for ppp_set_* functions because
calling them only makes sense while session is disconnected, furthermore
they are only setting structure members of the session configuration.
2020-10-20 04:15:25 +02:00
Sylvain Rochet
9b7cba9643 PPP: don't define PPP_IP if PPP_IPV4_SUPPORT is disabled
Doing so helps a lot at finding places where we have leftovers of IPv4
support when the support is disabled.
2020-10-20 03:59:34 +02:00
Sylvain Rochet
6584002826 PPP, PPPoS: only reserve header space for IPv4 and IPv6 packets if IP forwarding is enabled
We only have to reserve header space for forwarding for IPv4 and IPv6
packets, all other packets are PPP control packets. Doing so reduce
the need of having to coalesce the PBUF chain before PPP processes
control packets.
2020-10-20 03:53:07 +02:00
Sylvain Rochet
e801307738 PPP: set mtu6 too when setting PPP netif MTU
PPP peer can negotiate its MRU, therefore we don't know the MTU we are
going to use before starting PPP. This is an issue because netif_add
function assume that the netif init callback function will set the MTU,
netif_add will then copy mtu to mtu6. We have then to update mtu6 each
time we update mtu to keep them in sync. Doing so is fine because PPP
netif MTU is only updated when the netif is in link down state.
2020-10-20 02:53:46 +02:00
Sylvain Rochet
a39ce0f53b PPP, PPPoS: drop input packets much bigger than our MRU
Our current HDLC decoder does not protect against starving the Rx
PBUF POOL for one packet, most likely due to received garbage on
the serial port.

Prevent starving the Rx pool by checking incoming packets length
against PPP_MRU with a 10% margin because we only want to avoid
filling all PBUFs with garbage, we don't have to be pedantic.

Fixes bug #58441: Invalid PPP data accumulates forever.
2020-10-20 02:18:48 +02:00
Sylvain Rochet
51c6548631 PPP: allow negotiating MRU with PPP_MRU config option
PPP_MRU is now free to be used for what it should have been. Now using
it at PPP init stage to set the wanted MRU value, triggering a MRU
negotiation at the LCP phase.

I doubt anyone needs it anyway, but, well, at least it is fixed and the
MRU/MTU config mess is cleaned.

And while we are at it, better document PPP MRU config values.
2020-10-19 00:53:11 +02:00
Sylvain Rochet
90874392e3 PPP: force default MRU to 1500
RFC1661 mandates that default MRU value, that must be used prior
negotiation of MRU value and if MRU value is not negotiated later, must
be 1500.

That is, any PPP host must accept control frames of at least 1500 when
the PPP session start (there are no way to split them in multiples
frames anyway) and must use a value of 1500 if MRU is no negotiated
during LCP exchanges.

Therefore, having it configurable in ppp_opts is a mistake. It was wrong
and never worked because changing the value never triggered a MRU value
negotiation because it changed both the wanted MRU value and the RFC
default value to which the wanted value is compared to trigger a MRU
negotiation if values are not equal.
2020-10-18 23:54:48 +02:00
Sylvain Rochet
b8640678d6 PPP, LCP: merge PPP_MRU into PPP_DEFMRU
This is actually the same thing, both values are used interchangeably in
various places but their value must be the same.
2020-10-18 22:36:53 +02:00
Sylvain Rochet
331fe2dea2 PPP: rename netif_set/get_mtu to ppp_netif_set/get_mtu
Those are private functions, using the netif_ prefix here is not really
nice, especially with functions named netif_set_mtu and netif_get_mtu
for obvious reasons.
2020-10-18 22:11:18 +02:00