xiaoxiang781216 commented on code in PR #18245:
URL: https://github.com/apache/nuttx/pull/18245#discussion_r2736806863


##########
net/ipforward/ipv4_forward.c:
##########
@@ -471,7 +471,8 @@ int ipv4_forward(FAR struct net_driver_s *dev, FAR struct 
ipv4_hdr_s *ipv4)
   srcipaddr  = net_ip4addr_conv32(ipv4->srcipaddr);
 
   fwddev     = netdev_findby_ripv4addr(srcipaddr, destipaddr);
-  if (fwddev == NULL)
+  if ((fwddev == NULL) ||

Review Comment:
   remove () and merge with the next line



##########
net/ipforward/ipfwd_forward.c:
##########
@@ -49,6 +49,70 @@
  * Public Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: ipforward_enable
+ *
+ * Description:
+ *   Enable forward function on a network device.
+ *
+ * Input Parameters:
+ *   dev   - The device on which will be enabled forward function.
+ *
+ * Returned Value:
+ *   Zero is returned if forward function is successfully enabled;
+ *   A negated errno value is returned if failed.
+ *
+ ****************************************************************************/
+
+int ipforward_enable(FAR struct net_driver_s *dev)
+{
+  net_lock();
+
+  if (IFF_IS_FORWARD(dev->d_flags))
+    {
+      nwarn("WARNING: FORWARD was already enabled for %s!\n", dev->d_ifname);
+      net_unlock();
+      return -EEXIST;
+    }
+
+  IFF_SET_FORWARD(dev->d_flags);
+
+  net_unlock();
+  return OK;
+}
+
+/****************************************************************************
+ * Name: ipforward_disable
+ *
+ * Description:
+ *   Disable forward function on a network device.
+ *
+ * Input Parameters:
+ *   dev   - The device on which the ipforward function will be disabled.
+ *
+ * Returned Value:
+ *   Zero is returned if ipforward function is successfully disabled;
+ *   A negated errno value is returned if failed.
+ *
+ ****************************************************************************/
+
+int ipforward_disable(FAR struct net_driver_s *dev)
+{
+  net_lock();

Review Comment:
   ditto



##########
net/ipforward/ipfwd_forward.c:
##########
@@ -49,6 +49,70 @@
  * Public Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: ipforward_enable
+ *
+ * Description:
+ *   Enable forward function on a network device.
+ *
+ * Input Parameters:
+ *   dev   - The device on which will be enabled forward function.
+ *
+ * Returned Value:
+ *   Zero is returned if forward function is successfully enabled;
+ *   A negated errno value is returned if failed.
+ *
+ ****************************************************************************/
+
+int ipforward_enable(FAR struct net_driver_s *dev)

Review Comment:
   where you call this function, please follow how IFUP get changed from 
userspace



##########
net/ipforward/ipfwd_forward.c:
##########
@@ -49,6 +49,70 @@
  * Public Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: ipforward_enable
+ *
+ * Description:
+ *   Enable forward function on a network device.
+ *
+ * Input Parameters:
+ *   dev   - The device on which will be enabled forward function.
+ *
+ * Returned Value:
+ *   Zero is returned if forward function is successfully enabled;
+ *   A negated errno value is returned if failed.
+ *
+ ****************************************************************************/
+
+int ipforward_enable(FAR struct net_driver_s *dev)
+{
+  net_lock();

Review Comment:
   use netdev_lock



##########
net/ipforward/ipv6_forward.c:
##########
@@ -606,7 +606,8 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct 
ipv6_hdr_s *ipv6)
   /* Search for a device that can forward this packet. */
 
   fwddev = netdev_findby_ripv6addr(ipv6->srcipaddr, ipv6->destipaddr);
-  if (fwddev == NULL)
+  if ((fwddev == NULL) ||

Review Comment:
   remove () and merge with the next line



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to