net/ipfrag: fix ip fragment assert when iob not enough

insufficient IOB during IP fragment is a normal scenario and should
not crash directly. The assert needs to be removed and corresponding
error handling needs to be added.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu
2024-04-26 15:14:18 +08:00
committed by Alan C. Assis
parent 908596dde3
commit c2a4899941
2 changed files with 16 additions and 4 deletions
+8 -2
View File
@@ -361,7 +361,7 @@ int32_t ipv4_fragout(FAR struct net_driver_s *dev, uint16_t mtu)
uint32_t nfrags; uint32_t nfrags;
uint16_t offset = 0; uint16_t offset = 0;
uint16_t hdrlen; uint16_t hdrlen;
FAR struct iob_s *frag; FAR struct iob_s *frag = NULL;
FAR struct ipv4_hdr_s *ref = NULL; FAR struct ipv4_hdr_s *ref = NULL;
struct iob_queue_s fragq = struct iob_queue_s fragq =
{ {
@@ -379,9 +379,15 @@ int32_t ipv4_fragout(FAR struct net_driver_s *dev, uint16_t mtu)
*/ */
nfrags = ip_fragout_slice(dev->d_iob, PF_INET, mtu, hdrlen, &fragq); nfrags = ip_fragout_slice(dev->d_iob, PF_INET, mtu, hdrlen, &fragq);
ASSERT(nfrags > 1);
netdev_iob_clear(dev); netdev_iob_clear(dev);
/* No I/O Buffer is the only cause of failure */
if (nfrags == 0)
{
goto fail;
}
/* Fill the L3 header into the reserved space */ /* Fill the L3 header into the reserved space */
for (iter = 0; iter < nfrags; iter++) for (iter = 0; iter < nfrags; iter++)
+8 -2
View File
@@ -570,7 +570,7 @@ int32_t ipv6_fragout(FAR struct net_driver_s *dev, uint16_t mtu)
uint32_t nfrags; uint32_t nfrags;
uint16_t hdroff; uint16_t hdroff;
uint16_t hdrtype; uint16_t hdrtype;
FAR struct iob_s *frag; FAR struct iob_s *frag = NULL;
FAR struct ipv6_hdr_s *ref = NULL; FAR struct ipv6_hdr_s *ref = NULL;
FAR struct ipv6_fragment_extension_s *fraghdr; FAR struct ipv6_fragment_extension_s *fraghdr;
struct iob_queue_s fragq = struct iob_queue_s fragq =
@@ -590,9 +590,15 @@ int32_t ipv6_fragout(FAR struct net_driver_s *dev, uint16_t mtu)
*/ */
nfrags = ip_fragout_slice(dev->d_iob, PF_INET6, mtu, unfraglen, &fragq); nfrags = ip_fragout_slice(dev->d_iob, PF_INET6, mtu, unfraglen, &fragq);
ASSERT(nfrags > 1);
netdev_iob_clear(dev); netdev_iob_clear(dev);
/* No I/O Buffer is the only cause of failure */
if (nfrags == 0)
{
goto fail;
}
ipid = ++g_ipv6id; ipid = ++g_ipv6id;
/* Fill the L3 header into the reserved space */ /* Fill the L3 header into the reserved space */