[En-Nut-Discussion] SVN r4206 broke DHCP with some DHCP servers

Ole Reinhardt ole.reinhardt at embedded-it.de
Mon Jul 2 23:09:57 CEST 2012


Hi Harald (and all others),

the patch, introduced in r4206 which should fix the bug #3511170
introduced a new bug with some DHCP servers (like e.g. dhcpd3).

The new ip header check introduced in r4206 discards all incomming
unicast ip packets, as long as the interface is not yet configured.

But when using DHCP the interface might not yet be configured. 

When the DHCP client now sends a DHCP_DISCOVER, the server _should_
answer with a broadcast packet, but according to RFC1542, chapter 3.1.1
(http://www.ietf.org/rfc/rfc1542.txt) it can also answer with a unicast
packet.

The old implementation allowed such packets to be received, but with
r4206 this was changed.


So my question:

Is there any real need to discard unicast packets as long as our own
interface is not yet configured?

I would suggest to allow all packets to pass, as long as the interface
is not yet configured.

See the patch below.

Any suggestions?



--- /home/ole/work/NutOS/ethernut/trunk/nut/net/ipin.c	2012-06-08
22:29:09.465480702 +0200
+++ ipin.c	2012-07-02 23:05:06.304629612 +0200
@@ -105,7 +105,7 @@
     IPHDR *ip;
     uint_fast8_t hdrlen;
     uint32_t dst;
-    uint_fast8_t bcast;
+    uint_fast8_t bcast = 0;
     IFNET *nif;
 
     ip = nb->nb_nw.vp;
@@ -168,33 +168,29 @@
     /*
      * Check device's local IP address.
      */
-    else if (nif->if_local_ip == 0) {
-        /* Not yet configured, discard net-directed datagrams. */
-        NutNetBufFree(nb);
-        return;
-    }
-
-    /*
-     * Check for unicast.
-     */
-    else if (dst == nif->if_local_ip) {
-        bcast = 0;
-        nb->nb_flags |= NBAF_UNICAST;
-    }
+    else if (nif->if_local_ip != 0) {
+        /*
+         * Check for unicast.
+         */
+        if (dst == nif->if_local_ip) {
+            bcast = 0;
+            nb->nb_flags |= NBAF_UNICAST;
+        }
 
-    /*
-     * Check for net-directed broadcast.
-     */
-    else if ((dst & ~nif->if_mask) == ~nif->if_mask) {
-        bcast = 1;
-    }
+        /*
+         * Check for net-directed broadcast.
+         */
+        else if ((dst & ~nif->if_mask) == ~nif->if_mask) {
+            bcast = 1;
+        }
 
-    /*
-     * Not for us, discard silently.
-     */
-    else {
-        NutNetBufFree(nb);
-        return;
+        /*
+         * Not for us, discard silently.
+         */
+        else {
+            NutNetBufFree(nb);
+            return;
+        }
     }
 
     /*





-- 

Thermotemp GmbH, Embedded-IT

Embedded Hard-/ Software and Open Source Development, 
Integration and Consulting

http://www.embedded-it.de

Geschäftsstelle Siegen - Steinstraße 67 - D-57072 Siegen - 
tel +49 (0)271 5513597, +49 (0)271-73681 - fax +49 (0)271 736 97

Hauptsitz - Hademarscher Weg 7 - 13503 Berlin
Tel +49 (0)30 4315205 - Fax +49 (0)30 43665002
Geschäftsführer: Jörg Friedrichs, Ole Reinhardt
Handelsregister Berlin Charlottenburg HRB 45978 UstID DE 156329280 




More information about the En-Nut-Discussion mailing list