TCP's snd_nxt represents the next sequence number after sent data, and
as such does not cover any unsent data queued on the connection. The
current implementation does not take the latter point into account
when processing FIN acknowledgments, mistakenly assuming that an
outgoing FIN is ACK'ed when the acknowledgment covers up to snd_nxt
while there is still unsent data. This patch adds a check for unsent
data to correct this, effectively preventing that TCP connections are
closed prematurely.
It is possible that the byte sent as a zero window probe is accepted
and acknowledged by the receiver side without the window being opened.
In that case, the stream has effectively advanced by one byte, and
since lwIP did not take this into account on the sender side, the
result was a desynchronization between the sender and the receiver.
That situation could occur even on a lwIP loopback device, after
filling up the receiver side's receive buffer, and resulted in an ACK
storm. This patch corrects the problem by advancing the sender's next
sequence number by one as needed when sending a zero window probe.
delay_time and stale_time are ticks now.
reachable_time and invalidation_timer are untouched since they may originate from telegram values -> not converting them to ticks avoids an integer division
commit 8c52afb6ca ("igmp: Optimize code by always skipping the first entry in the linked groups list - it is always the "allsystems" entry")
accidently changes the code logic. it should check groupref rather than group.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reasoning:
- Makes code in single-netif case perform better and smaller
- IGMP / MLD6 code is a little bit easier to read and understand
- Easier to get multicast groups per netif when implementing drivers
Downside: In multi-netif mode, there are two more pointers on each netif, even if IGMP/MLD6 is not used on it. But these systems should not be so memory-constrained that this will matter.
In a dual stack configuration it is not really feasible to wait
until the IPv4 address is valid before starting the mDNS responder.
If there is no DHCPv4 server in the network, the IPv4 address may
never become valid, which should however not preclude IPv6 mDNS
from working.
When leaving a multicast group, remove the group from the list
before invoking the MAC filter callback. This avoids the need
for the callee to skip over the group that is about to be deleted.
This commit adds support to the sanity checks in init.c to ensure that
PBUF_POOL is in use
In ports with drivers/netifs that use PBUF_REF for the RX pathway, there
is no need for the PBUF_POOL memory pool. This allows the port to define
PBUF_POOL_SIZE to 0
This corrects documentation on TCP_OOSEQ_MAX_BYTES and _PBUFS to list
their dependency on TCP_QUEUE_OOSEQ==1 (out of order sequence queueing
enabled) rather than ==0 (disabled)
Change macro signature to be universal: netif, pbuf, src, dst, eth_type - whatever the user needs to decide about VLAN header.
Return value <0 means "no VLAN header", 0 <= return_value <= 0xFFFF -> value is prio_vid of header.
Clean up ethernet_output function to be more readable.
commit 44e1a2d8e2 accidently includes below changes in tcp_listen_with_backlog
- tcp_backlog_set(lpcb, backlog);
+ lpcb->backlog = backlog;
Thus pass 0 to the backlog parameter of netconn_listen_with_backlog() fails.
Fixes: 44e1a2d8e2 ("define tcp_backlog_set() as dummy-define when backlog feature is disable")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
Use memset to zero the allocated memory rather than explicitly init each field.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
MEMP_SANITY_REGION_BEFORE and MEMP_SANITY_REGION_AFTER can be overridden in
lwipopts.h, if one of it is set to 0 we got build error due to unused variable.
Fix unused variable build error when MEMP_OVERFLOW_CHECK >= 1 &&
(MEMP_SANITY_REGION_BEFORE == 0 || MEMP_SANITY_REGION_AFTER == 0).
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
There is only one caller using memp_overflow_init(), and at that context
calling memp_overflow_init_element() actually simplifes the code.
Thus remove memp_overflow_init() function.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
Fix below build errors:
In file included from ../../../../../lwip/src/include/netif/ppp/ppp_opts.h:31:0,
from ../../../../../lwip/src/netif/ppp/pppoe.c:71:
../../../../../lwip/src/netif/ppp/pppoe.c: In function ‘pppoe_timeout’:
../../../../../lwip/src/netif/ppp/pppoe.c:861:30: error: ‘ethbroadcast’ undeclared (first use in this function)
MEMCPY(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest));
^
../../../../../lwip/src/include/lwip/opt.h:137:52: note: in definition of macro ‘MEMCPY’
#define MEMCPY(dst,src,len) memcpy(dst,src,len)
^
../../../../../lwip/src/netif/ppp/pppoe.c:861:30: note: each undeclared identifier is reported only once for each function it appears in
MEMCPY(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest));
^
../../../../../lwip/src/include/lwip/opt.h:137:52: note: in definition of macro ‘MEMCPY’
#define MEMCPY(dst,src,len) memcpy(dst,src,len)
^
../../../../../lwip/src/netif/ppp/pppoe.c: In function ‘pppoe_connect’:
../../../../../lwip/src/netif/ppp/pppoe.c:899:24: error: ‘ethbroadcast’ undeclared (first use in this function)
MEMCPY(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest));
^
../../../../../lwip/src/include/lwip/opt.h:137:52: note: in definition of macro ‘MEMCPY’
#define MEMCPY(dst,src,len) memcpy(dst,src,len)
^
../../Common.mk:94: recipe for target 'pppoe.o' failed
make: *** [pppoe.o] Error 1
Fixes: 8eb9db18a2 ("Reduce usage of netif/ethernet.h header, mostly lwip/prot/ethernet.h is sufficient")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
Use LWIP_MEM_ALIGN() in memp_overflow_init() to get alignment address for memp.
This fixes assertion in memp_overflow_check_element_overflow when
MEMP_OVERFLOW_CHECK is set.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Fix below build error.
../../../../../lwip/src/core/memp.c: In function ‘memp_free’:
../../../../../lwip/src/core/memp.c:490:31: error: request for member ‘tab’ in something not a structure or union
old_first = memp_pools[type].tab;
^
../../Common.mk:94: recipe for target 'memp.o' failed
make: *** [memp.o] Error 1
Fixes: de9054cb7a ("memp: cleaned up MEMP_MEM_MALLOC")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
The check for link up was missing, meaning valid LCP echo request/reply
packets are filtered whatever the PPP state is, despite what the comment
says.
Fix it by checking the PPP state as we would like to have done when it
was written.
During documentation updated LWIP_MEMPOOL_PROTOTYPE was moved inside
"#if MEMP_MEM_MALLOC" which cause ppp build to break. This patch fix that
issue.
ref commit-id: 2f950a7dcc
Signed-off-by: Ajay Bhargav <contact@rickeyworld.info>
VJ packets, Compressed packets, IPv4 and IPv6 packets are useless in
the PPP packet dump. We properly filtered IPv4 and IPv6 packets but
we forgot filtering VJ and Compressed packets.
Improve the filtering rule to filter packets which are not auth
protocol (< 0xC000) and which are not control protocol (0x8000 bit
not set).
I have below code in my cc.h:
#ifdef MYSDK_LWIP_DEBUG
#define LWIP_PLATFORM_ASSERT(x) MYSDK_ASSERTION_FAIL_ACTION()
#else
#define LWIP_PLATFORM_ASSERT(x)
#endif /* ifdef MYSDK_LWIP_DEBUG */
I got below error when in non-debug build:
src/include/lwip/debug.h:76:32: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
LWIP_PLATFORM_ASSERT(message); } while(0)
^
Fix the build error by adding braces around empty body in an 'if' statement.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: sg <goldsimon@gmx.de>
If LCP is not started yet, we are only closing the link protocol, in
this case we have to set the disconnect state ourself because PPP
is not actually started yet.
Include stdlib.h to fix below build warnings when MEM_LIBC_MALLOC is set:
src/core/mem.c:119:3: warning: implicit declaration of function 'malloc' [-Wimplicit-function-declaration]
void* ret = mem_clib_malloc(size + MEM_LIBC_STATSHELPER_SIZE);
^
src/core/mem.c:96:25: warning: incompatible implicit declaration of built-in function 'malloc'
#define mem_clib_malloc malloc
^
src/core/mem.c:119:15: note: in expansion of macro 'mem_clib_malloc'
void* ret = mem_clib_malloc(size + MEM_LIBC_STATSHELPER_SIZE);
^
src/core/mem.c: In function 'mem_free':
src/core/mem.c:146:3: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
mem_clib_free(rmem);
^
src/core/mem.c:93:23: warning: incompatible implicit declaration of built-in function 'free'
#define mem_clib_free free
^
src/core/mem.c:146:3: note: in expansion of macro 'mem_clib_free'
mem_clib_free(rmem);
^
Signed-off-by: Axel Lin <axel.lin@ingics.com>
pppoe_softc_list is always not null when pppoe_find_softc_by_session is
called, furthermore pppoe_softc_list being null here does not hurt.
session is still checked whatsoever in pppoe_find_softc_by_session,
prechecking the session value for a value which can't really happen
except for forged frames does not add any value.
Remove unnecessary cleanup at the end of session, cleanup as much as
possible in the connect callback instead. It follows what PPPoE is
currently doing and it makes everything simpler to read.
Instead of relying on cleanup at the end of session, cleanup as much as
possible in the connect callback. It removes duplicated code and make
everything simpler to read.
While we are at it, remove useless initialization code from create
and connect functions.
ppp_close might try to close LCP even if LCP is not started, it happens
because because the PPP session might be waiting for the link protocol
to come up and we do not check that.
We say in the PPP documentation that ppp_close() can be called anytime,
so, if link protocol is currently trying to connect, we must cancel
the link connection.
Fix it by calling the link protocol disconnect callback if LCP is not
started yet.
Disconnect callback does not currently support a disconnect event while
initiation is in progress. Retry timer is not stopped and PADT frame is
sent whatever the current state is. PADT frame can only be sent if we
received a PADS frame, otherwise sc_session is 0 and sending a PADT
frame is meaningless.
Fix both issues to allow calling the disconnect callback whatever the
PPPoE state is.
We say in the PPP documentation that ppp_close() can be called anytime,
as of today, this is not entirely true, there are still conditions that
are not handled properly.
If PPP is already disconnecting, ppp_close() must do nothing and returns
ERR_INPROGRESS instead of messing up the PPP disconnection state.
Master state is almost exactly the same thing as dead state, move it
next to dead state. Holdoff state is actually the state just before
initialize, move it before initialize.
The goal is to be able to use > running or => terminate condition to
check a currently running disconnection phase, which is not possible
today without excluding master and holdoff states.
PPP_PHASE_MASTER state is only used if multilink mode is enabled. Since
we don't support multilink mode checking for this state only add some
code for no value added at all.
Build-out PPP_PHASE_MASTER state check if multilink mode is disabled.
Van Jacobson TCP header compression only apply if TCP is enabled,
therefore we need to disable VJ compression if TCP is disabled.
We already have conditions to enforce VJ disabling if IPv4 is disabled
or if PPPoS is disabled, add TCP to those conditions and remove
unecessary VJ_SUPPORT && LWIP_TCP conditions.
This function only set PPP to initialize phase, and it is only called at
the very beginning of functions where it is called. It means we could
as well set the initialize phase before calling those functions in the
PPP core.
PPP is currently in initialize phase until authentication is started
or until we start IPCP negotiation.
It works, because PPP states are mostly used for user information, most
state are actually useless for PPP itself. Being in initialize state
while PPP is started is not very consistent, switch to establish phase
before starting LCP.
sc->sc_ethif can't be NULL, it is set definitively in pppoe_create.
PPPoE can't by anything else than PADI sent in pppoe_send_padi, it
is only called when this is true.
PPPoE state can't be anything else than initial state in
pppoe_connect, this function is called from PPP core only when PPP
is in the dead phase, if PPP is in the dead phase it means the link
protocol is dead as well.
PPPoE can't be anything else than data phase in pppoe_disconnect
this function is only called by PPP core only when PPP session is up,
if PPP session is UP it means the link protocol is UP as well.
PPPoE can't by anything else than PADR sent in pppoe_send_padr, it
is only called when this is true.
PPPoE can't by anything else than PADO sent in pppoe_send_pado, it
is only called when this is true.
PPPoE can't by anything else than PADO sent in pppoe_send_pads, it
is only called when this is true.
PPPoE can't be anything else than session phase in pppoe_xmit,
function is only called by pppoe_write and pppoe_netif_output
which are both called by PPP core only when PPP session is up, if
PPP session is UP it means the link protocol is UP as well.
L2TP state can't be anything else than initial state in
pppol2tp_connect, this function is called from PPP core only when PPP
is in the dead phase, if PPP is in the dead phase it means the link
protocol is dead as well.
L2TP can't be anything else than data phase in pppol2tp_xmit, this
function is only called by pppol2tp_write and pppol2tp_netif_output
which are both called by PPP core only when PPP session is up, if
PPP session is UP it means the link protocol is UP as well.
L2TP can't be anything else than data phase in pppol2tp_disconnect,
this function is only called by PPP core only when PPP session is up,
if PPP session is UP it means the link protocol is UP as well.
When we are disconnecting, we should switch to PPP dead phase at the
very end, because this is our final disconnection phase allowing
reconnect, therefore we should switch to dead phase after the link
protocol finished disconnecting.
We are currently switching to dead phase when LCP detected that the link
is down, this is obviously wrong. Fix this flaw by continuing in
disconnect phase until ppp_link_end is called from link protocol.
In the BSD socket API world, IP_HDRINCL is a socket option for "raw"
sockets that indicates whether sent packets already include an IP
header. Within lwIP, "IP_HDRINCL" is redefined as a special value
that indicates to lwIP-internal functions that an IP header is already
included. While somewhat related, the two meanings are different and,
on platforms that define the IP_HDRINCL socket option, this results in
a conflict. This patch renames the lwIP one to "LWIP_IP_HDRINCL",
thus resolving the conflict.
Doxygen does not handle #ifndef foo #define foo #endif properly. It does not see the #define foo inside.
If someone has objections or a fix for it, please tell me.