Author Topic: DHCP with Relay Agent bug  (Read 6093 times)

Offline johnr

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
DHCP with Relay Agent bug
« on: October 11, 2012, 04:28:42 PM »
Mark, we've run into a problem using DHCP with a relay agent. The DHCP server is located on another subnet, so the broadcast request must go through a relay agent. When using this setup, our customer said all the parameters would get set except the IP. He gave us a Wireshark log of the problem,  and we were able to fix it by commenting out the check  (uMemcmp(ucDHCP_SERVER_IP, ucIP, IPV4_LENGTH)) in fnDHCPListner() . Being the incoming IP from the relay agent will be different than the DHCP server IP. it would fail.

 John


 
Code: [Select]
// The UDP listner function for DHCP port
//
static int fnDHCPListner(USOCKET SocketNr, unsigned char ucEvent, unsigned char *ucIP, unsigned short usPortNr, unsigned char *data, unsigned short usLength)
{
           |
           |
            /* check magic cookie */
            if (uMemcmp(data, ucMagicCookie_and_message, MAGIC_COOKIE_LENGTH)) return BAD_MAGIC_COOKIE;  // magic cookie is bad - quit
            data += MAGIC_COOKIE_LENGTH;

FIX            if (ucDHCP_state == DHCP_STATE_REQUESTING) {                 // we do this check here simply to avoid having to pass parameters
---->>>>                if (  /*** (uMemcmp(ucDHCP_SERVER_IP, ucIP, IPV4_LENGTH)) || ***/       (uMemcmp(usOfferedIP, ucDHCP_IP, IPV4_LENGTH))) {
                    return FOREIGN_DHCP_PACKET;                          // server or requested IP not same
                }
            }
            // the initial checks were successful - now we do state specific stuff
            return (fnDoRxDHCP(data, usOfferedIP, (unsigned short)(usLength + UDP_HLEN - (3 + 8 + XID_LENGTH + IPV4_LENGTH + 216))));
    }
    return 0;
}

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: DHCP with Relay Agent bug
« Reply #1 on: October 11, 2012, 08:01:47 PM »
Hi John

Could you check the version that you are using since Relay Agent support was added to DHCP on 24.10.2010? The following is the change log for dhcp.c:
    10.06.2007   Quieten GNU compiler by initialising a variable          {1}
    22.06.2008   Allow operation without random number generator support  {2}
    14.10.2009   Allow overload options to be tolerated, but not handled  {3}
    22.03.2010   Verify the MAC address in offers to ensure accepting only own values {4}
    03.06.2010   Correct MAX_TIMER_DELAY value                            {5}
    04.06.2010   Check for invalid renewal and rebind timers from server and force realistic values {6}
    24.10.2010   Add relay agent support                                  {7}


At the location that you changed there is a check of either the DHCP server's address or the relay agent's address, which was reported by the DHCP server:

                if ((uMemcmp(usOfferedIP, ucDHCP_IP, IPV4_LENGTH) != 0) || ((uMemcmp(ucDHCP_SERVER_IP, ucIP, IPV4_LENGTH) != 0) && (uMemcmp(usRelayAgentIP, ucIP, IPV4_LENGTH) != 0))) {
                    return FOREIGN_DHCP_PACKET;                          // server or requested IP not same
                }


You may find that there are a couple of other changes that you may like to include.

Regards

Mark


Offline johnr

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
Re: DHCP with Relay Agent bug
« Reply #2 on: October 12, 2012, 04:35:45 PM »
Mark, I figured someone would have run into this problem by now. We're running version 1.3.9 for the Coldfire, which we modified the network stack to work with our web software. We bought a support license 5 years ago. Do we need a new license to open the 1.4x zip projects?

 Thanks, John

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: DHCP with Relay Agent bug
« Reply #3 on: October 17, 2012, 01:21:34 PM »
Hi John

Sorry for (somehow) missing your post for a few days.

V1.4 has a new password. A support extension will extend any licensing to cover new versions as well as for additional technical support.

Regards

Mark