Received: from mx.pao1.isc.org (mx.pao1.isc.org [149.20.64.53]) by bugs.isc.org (Postfix) with ESMTP id 27AED20EE2CF; Sat, 23 Apr 2011 15:40:01 +0000 (UTC) Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by mx.pao1.isc.org (Postfix) with ESMTPS id EFF46C9423; Sat, 23 Apr 2011 15:39:57 +0000 (UTC) (envelope-from hal@dev.mellanox.co.il) Received: by mail-ww0-f45.google.com with SMTP id 36so1131616wwi.26 for ; Sat, 23 Apr 2011 08:39:57 -0700 (PDT) Received: by 10.227.166.11 with SMTP id k11mr2166373wby.68.1303573197649; Sat, 23 Apr 2011 08:39:57 -0700 (PDT) Received: from [192.168.1.100] (c-71-192-10-85.hsd1.ma.comcast.net [71.192.10.85]) by mx.google.com with ESMTPS id w25sm2312222wbd.56.2011.04.23.08.39.55 (version=SSLv3 cipher=OTHER); Sat, 23 Apr 2011 08:39:56 -0700 (PDT) Delivered-To: dhcp-bugs@bugs.isc.org Subject: [PATCH 1/2] Add dhclient option to broadcast always MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Return-Path: X-Original-To: dhcp-bugs@bugs.isc.org Date: Sat, 23 Apr 2011 11:39:53 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mx.pao1.isc.org content-type: text/plain; charset="utf-8" Message-ID: <4DB2F2C9.9080804@dev.mellanox.co.il> To: dhcp-bugs@isc.org, dhcp-suggest@isc.org Content-Transfer-Encoding: 7bit From: Hal Rosenstock X-RT-Original-Encoding: ISO-8859-1 Content-Length: 5168 DHCP over IPoIB requires the client to always set the BROADCAST flag of DHCPDISCOVER and DHCPREQUEST packets to ensure that server responses are broadcast back to the client so add this is as a supported option. Signed-off-by: Hal Rosenstock --- diff -up dhcp-4.2.1-P1/common/conflex.c.option dhcp-4.2.1-P1/common/conflex.c --- dhcp-4.2.1-P1/common/conflex.c.option 2010-12-15 00:07:46.000000000 +0200 +++ dhcp-4.2.1-P1/common/conflex.c 2011-04-23 18:06:57.189226000 +0300 @@ -808,6 +808,8 @@ intern(char *atom, enum dhcp_token dfv) return BALANCE; if (!strcasecmp (atom + 1, "ound")) return BOUND; + if (!strcasecmp (atom + 1, "ootp-broadcast-always")) + return BOOTP_BROADCAST_ALWAYS; break; case 'c': if (!strcasecmp(atom + 1, "ase")) diff -up dhcp-4.2.1-P1/includes/dhcpd.h.option dhcp-4.2.1-P1/includes/dhcpd.h --- dhcp-4.2.1-P1/includes/dhcpd.h.option 2010-12-03 22:32:14.000000000 +0200 +++ dhcp-4.2.1-P1/includes/dhcpd.h 2011-04-23 18:07:01.861768000 +0300 @@ -1119,6 +1119,9 @@ struct client_config { int do_forward_update; /* If nonzero, and if we have the information we need, update the A record for the address we get. */ + + int bootp_broadcast_always; /* If nonzero, always set the BOOTP_BROADCAST + flag in requests */ }; /* Per-interface state used in the dhcp client... */ diff -up dhcp-4.2.1-P1/client/dhclient.c.option dhcp-4.2.1-P1/client/dhclient.c --- dhcp-4.2.1-P1/client/dhclient.c.option 2011-03-24 23:17:07.000000000 +0200 +++ dhcp-4.2.1-P1/client/dhclient.c 2011-04-23 18:07:07.436204000 +0300 @@ -84,6 +84,7 @@ int wanted_ia_na = -1; /* the absolute int wanted_ia_ta = 0; int wanted_ia_pd = 0; char *mockup_relay = NULL; +int bootp_broadcast_always = 0; void run_stateless(int exit_mode); @@ -304,6 +305,8 @@ main(int argc, char **argv) { } else if (!strcmp(argv[i], "--version")) { log_info("isc-dhclient-%s", PACKAGE_VERSION); exit(0); + } else if (!strcmp(argv[i], "-B")) { + bootp_broadcast_always = 1; } else if (argv[i][0] == '-') { usage(); } else if (interfaces_requested < 0) { @@ -2344,7 +2347,8 @@ void make_discover (client, lease) client -> packet.xid = random (); client -> packet.secs = 0; /* filled in by send_discover. */ - if (can_receive_unicast_unconfigured (client -> interface)) + if ((!(bootp_broadcast_always || client->config->bootp_broadcast_always)) + && can_receive_unicast_unconfigured(client->interface)) client -> packet.flags = 0; else client -> packet.flags = htons (BOOTP_BROADCAST); @@ -2428,7 +2432,9 @@ void make_request (client, lease) } else { memset (&client -> packet.ciaddr, 0, sizeof client -> packet.ciaddr); - if (can_receive_unicast_unconfigured (client -> interface)) + if ((!(bootp_broadcast_always || + client ->config->bootp_broadcast_always)) && + can_receive_unicast_unconfigured (client -> interface)) client -> packet.flags = 0; else client -> packet.flags = htons (BOOTP_BROADCAST); @@ -2490,7 +2496,8 @@ void make_decline (client, lease) client -> packet.hops = 0; client -> packet.xid = client -> xid; client -> packet.secs = 0; /* Filled in by send_request. */ - if (can_receive_unicast_unconfigured (client -> interface)) + if ((!(bootp_broadcast_always || client->config-> bootp_broadcast_always)) + && can_receive_unicast_unconfigured (client->interface)) client -> packet.flags = 0; else client -> packet.flags = htons (BOOTP_BROADCAST); diff -up dhcp-4.2.1-P1/client/clparse.c.option dhcp-4.2.1-P1/client/clparse.c --- dhcp-4.2.1-P1/client/clparse.c.option 2010-09-14 00:15:19.000000000 +0200 +++ dhcp-4.2.1-P1/client/clparse.c 2011-04-23 18:07:11.930832000 +0300 @@ -136,6 +136,7 @@ isc_result_t read_client_conf () /* Requested lease time, used by DHCPv6 (DHCPv4 uses the option cache) */ top_level_config.requested_lease = 7200; + top_level_config.bootp_broadcast_always = 0; group_allocate (&top_level_config.on_receipt, MDL); if (!top_level_config.on_receipt) @@ -303,7 +304,8 @@ void read_client_leases () interface-declaration | LEASE client-lease-statement | ALIAS client-lease-statement | - KEY key-definition */ + KEY key-definition | + BOOTP_BROADCAST_ALWAYS */ void parse_client_statement (cfile, ip, config) struct parse *cfile; @@ -717,6 +719,12 @@ void parse_client_statement (cfile, ip, parse_reject_statement (cfile, config); return; + case BOOTP_BROADCAST_ALWAYS: + token = next_token(&val, (unsigned*)0, cfile); + config -> bootp_broadcast_always = 1; + parse_semi (cfile); + return; + default: lose = 0; stmt = (struct executable_statement *)0; diff -up dhcp-4.2.1-P1/includes/dhctoken.c.option dhcp-4.2.1-P1/includes/dhctoken.h --- dhcp-4.2.1-P1/includes/dhctoken.h.option 2010-02-17 22:33:55.000000000 +0200 +++ dhcp-4.2.1-P1/includes/dhctoken.h 2011-04-23 18:07:17.252304000 +0300 @@ -357,7 +357,8 @@ enum dhcp_token { CONFLICT_DONE = 660, AUTO_PARTNER_DOWN = 661, GETHOSTNAME = 662, - REWIND = 663 + REWIND = 663, + BOOTP_BROADCAST_ALWAYS = 664 }; #define is_identifier(x) ((x) >= FIRST_TOKEN && \