net: Check error when pushing packet into stack
Make tcpip_input() to return 0 if there is an error when processing the packet. Value != 0 indicates a successfull packet processing and in this case the application will free the packet. Change-Id: I4aaeb5f0039cfbe25f7238a144964e31a8204148 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
fa87944a08
commit
6fe17bb7a5
4 changed files with 17 additions and 9 deletions
|
@ -540,14 +540,23 @@ eventhandler(process_event_t ev, process_data_t data, struct net_buf *buf)
|
|||
};
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
uint8_t
|
||||
tcpip_input(struct net_buf *buf)
|
||||
{
|
||||
process_post_synch(&tcpip_process, PACKET_INPUT, NULL, buf);
|
||||
if (uip_len(buf) == 0) {
|
||||
/* This indicates that there was a parsing/other error
|
||||
* in packet.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
uip_len(buf) = 0;
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
uip_ext_len(buf) = 0;
|
||||
#endif /*NETSTACK_CONF_WITH_IPV6*/
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
|
|
|
@ -333,9 +333,11 @@ CCIF extern process_event_t tcpip_event;
|
|||
* deliver an incoming packet to the TCP/IP stack. The
|
||||
* incoming packet must be present in the uip_buf buffer,
|
||||
* and the length of the packet must be in the global
|
||||
* uip_len variable.
|
||||
* uip_len variable. If 0 is returned, then there was
|
||||
* an error in the packet and it is discarded. The caller
|
||||
* can then release the net_buf
|
||||
*/
|
||||
CCIF void tcpip_input(struct net_buf *buf);
|
||||
CCIF uint8_t tcpip_input(struct net_buf *buf);
|
||||
|
||||
/**
|
||||
* \brief Output packet to layer 2
|
||||
|
|
|
@ -2325,11 +2325,6 @@ uip_process(struct net_buf *buf, uint8_t flag)
|
|||
return 1;
|
||||
|
||||
drop:
|
||||
/* If there is an error, then just return the buffer to pool */
|
||||
if (uip_len(buf) == 0) {
|
||||
net_buf_put(buf);
|
||||
}
|
||||
|
||||
uip_len(buf) = 0;
|
||||
uip_ext_len(buf) = 0;
|
||||
uip_ext_bitmap(buf) = 0;
|
||||
|
|
|
@ -352,7 +352,9 @@ static void net_rx_fiber(void)
|
|||
/* Check stack usage (no-op if not enabled) */
|
||||
analyze_stacks(buf, &buf);
|
||||
|
||||
tcpip_input(buf);
|
||||
if (!tcpip_input(buf)) {
|
||||
net_buf_put(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue