Another IP forwarding design simplification: Remove an unnecessary field from state structure.
This commit is contained in:
parent
b5d7187df6
commit
db69e4b09c
@ -80,7 +80,6 @@ void devif_forward(FAR struct forward_s *fwd)
|
|||||||
|
|
||||||
/* Copy the IOB chain that contains the L3L3 headers and any data payload */
|
/* Copy the IOB chain that contains the L3L3 headers and any data payload */
|
||||||
|
|
||||||
DEBUGASSERT(fwd->f_iob->io_pktlen >= fwd->f_hdrsize);
|
|
||||||
DEBUGASSERT(offset + fwd->f_iob->io_pktlen <= NET_DEV_MTU(fwd->f_dev));
|
DEBUGASSERT(offset + fwd->f_iob->io_pktlen <= NET_DEV_MTU(fwd->f_dev));
|
||||||
ret = iob_copyout(&fwd->f_dev->d_buf[offset], fwd->f_iob,
|
ret = iob_copyout(&fwd->f_dev->d_buf[offset], fwd->f_iob,
|
||||||
fwd->f_iob->io_pktlen, 0);
|
fwd->f_iob->io_pktlen, 0);
|
||||||
|
@ -163,7 +163,6 @@ struct forward_s
|
|||||||
FAR struct iob_s *f_iob; /* IOB chain containing the packet */
|
FAR struct iob_s *f_iob; /* IOB chain containing the packet */
|
||||||
FAR struct devif_callback_s *f_cb; /* Reference to callback instance */
|
FAR struct devif_callback_s *f_cb; /* Reference to callback instance */
|
||||||
union fwd_conn_u f_conn; /* Protocol-specific connection struct */
|
union fwd_conn_u f_conn; /* Protocol-specific connection struct */
|
||||||
uint8_t f_hdrsize; /* The size of the L2+L3 headers */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -80,7 +80,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
#if defined(CONFIG_NETDEV_MULTINIC) && defined(CONFIG_DEBUG_NET_WARN)
|
||||||
static int ipv4_hdrsize(FAR struct ipv4_hdr_s *ipv4)
|
static int ipv4_hdrsize(FAR struct ipv4_hdr_s *ipv4)
|
||||||
{
|
{
|
||||||
/* Size is determined by the following protocol header, */
|
/* Size is determined by the following protocol header, */
|
||||||
@ -267,7 +267,9 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev,
|
|||||||
FAR struct ipv4_hdr_s *ipv4)
|
FAR struct ipv4_hdr_s *ipv4)
|
||||||
{
|
{
|
||||||
FAR struct forward_s *fwd = NULL;
|
FAR struct forward_s *fwd = NULL;
|
||||||
|
#ifdef CONFIG_DEBUG_NET_WARN
|
||||||
int hdrsize;
|
int hdrsize;
|
||||||
|
#endif
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Verify that the full packet will fit within the forwarding devices MTU.
|
/* Verify that the full packet will fit within the forwarding devices MTU.
|
||||||
@ -297,16 +299,8 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev,
|
|||||||
|
|
||||||
fwd->f_dev = fwddev; /* Forwarding device */
|
fwd->f_dev = fwddev; /* Forwarding device */
|
||||||
|
|
||||||
/* Get the size of the IPv4 + L3 header. Use this to determine start of
|
#ifdef CONFIG_DEBUG_NET_WARN
|
||||||
* the data payload.
|
/* Get the size of the IPv4 + L3 header. */
|
||||||
*
|
|
||||||
* Remember that the size of the L1 header has already been subtracted
|
|
||||||
* from dev->d_len.
|
|
||||||
*
|
|
||||||
* REVISIT: Consider an alternative design that does not require data
|
|
||||||
* copying. This would require a pool of d_buf's that are managed by
|
|
||||||
* the network rather than the network device.
|
|
||||||
*/
|
|
||||||
|
|
||||||
hdrsize = ipv4_hdrsize(ipv4);
|
hdrsize = ipv4_hdrsize(ipv4);
|
||||||
if (hdrsize < IPv4_HDRLEN)
|
if (hdrsize < IPv4_HDRLEN)
|
||||||
@ -324,8 +318,7 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev,
|
|||||||
ret = -E2BIG;
|
ret = -E2BIG;
|
||||||
goto errout_with_fwd;
|
goto errout_with_fwd;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
fwd->f_hdrsize = hdrsize;
|
|
||||||
|
|
||||||
/* Try to allocate the head of an IOB chain. If this fails, the
|
/* Try to allocate the head of an IOB chain. If this fails, the
|
||||||
* packet will be dropped; we are not operating in a context
|
* packet will be dropped; we are not operating in a context
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
#if defined(CONFIG_NETDEV_MULTINIC) && defined(CONFIG_DEBUG_NET_WARN)
|
||||||
static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6)
|
static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6)
|
||||||
{
|
{
|
||||||
/* Size is determined by the following protocol header, */
|
/* Size is determined by the following protocol header, */
|
||||||
@ -368,7 +368,9 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev,
|
|||||||
FAR struct ipv6_hdr_s *ipv6)
|
FAR struct ipv6_hdr_s *ipv6)
|
||||||
{
|
{
|
||||||
FAR struct forward_s *fwd = NULL;
|
FAR struct forward_s *fwd = NULL;
|
||||||
|
#ifdef CONFIG_DEBUG_NET_WARN
|
||||||
int hdrsize;
|
int hdrsize;
|
||||||
|
#endif
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Perform any necessary packet conversions. */
|
/* Perform any necessary packet conversions. */
|
||||||
@ -408,16 +410,8 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev,
|
|||||||
|
|
||||||
fwd->f_dev = fwddev; /* Forwarding device */
|
fwd->f_dev = fwddev; /* Forwarding device */
|
||||||
|
|
||||||
/* Get the size of the IPv6 + L3 header. Use this to determine start
|
#ifdef CONFIG_DEBUG_NET_WARN
|
||||||
* of the data payload.
|
/* Get the size of the IPv6 + L3 header. */
|
||||||
*
|
|
||||||
* Remember that the size of the L1 header has already been subtracted
|
|
||||||
* from dev->d_len.
|
|
||||||
*
|
|
||||||
* REVISIT: Consider an alternative design that does not require data
|
|
||||||
* copying. This would require a pool of d_buf's that are managed by
|
|
||||||
* the network rather than the network device.
|
|
||||||
*/
|
|
||||||
|
|
||||||
hdrsize = ipv6_hdrsize(ipv6);
|
hdrsize = ipv6_hdrsize(ipv6);
|
||||||
if (hdrsize < IPv6_HDRLEN)
|
if (hdrsize < IPv6_HDRLEN)
|
||||||
@ -435,8 +429,7 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev,
|
|||||||
ret = -E2BIG;
|
ret = -E2BIG;
|
||||||
goto errout_with_fwd;
|
goto errout_with_fwd;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
fwd->f_hdrsize = hdrsize;
|
|
||||||
|
|
||||||
/* Try to allocate the head of an IOB chain. If this fails, the
|
/* Try to allocate the head of an IOB chain. If this fails, the
|
||||||
* packet will be dropped; we are not operating in a context where
|
* packet will be dropped; we are not operating in a context where
|
||||||
|
Loading…
x
Reference in New Issue
Block a user