On Mon, Jun 26, 2017 at 11:20 PM, tiggersWelt.net (Support)
<supp...@tiggerswelt.net> wrote:
> Good evening Denys,
>
> thank you for your effort!
>
> Am 26.06.2017 um 20:08 schrieb Denys Vlasenko:
>> On Wed, Jun 21, 2017 at 4:29 PM, tiggersWelt.net (Support)
>> <supp...@tiggerswelt.net> wrote:
>>>  static const char opt_req[] = {
>>>         (D6_OPT_ORO >> 8), (D6_OPT_ORO & 0xff),
>>> -       0, 6,
>>> +       0, 10,
>>>         (D6_OPT_DNS_SERVERS >> 8), (D6_OPT_DNS_SERVERS & 0xff),
>>>         (D6_OPT_DOMAIN_LIST >> 8), (D6_OPT_DOMAIN_LIST & 0xff),
>>> -       (D6_OPT_CLIENT_FQDN >> 8), (D6_OPT_CLIENT_FQDN & 0xff)
>>> +       (D6_OPT_CLIENT_FQDN >> 8), (D6_OPT_CLIENT_FQDN & 0xff),
>>> +       (D6_OPT_TZ_POSIX >> 8), (D6_OPT_TZ_POSIX & 0xff),
>>> +       (D6_OPT_TZ_NAME >> 8), (D6_OPT_TZ_NAME & 0xff)
>>>  };
>>
>> Please explain what does this do, and why.
>
> It's the content of the DHCP6 Option Request Option (ORO) as of RFC 3315, 
> 22.7. It actually tells the
> server what options are supported and wanted on client-side.
>
> I introduced this option in my last patch (see commit 
> ed898ed2ddc1e3627555488671155420a32d0167) as some
> servers required this to deliver the listed options. Now it was only enhanced 
> by the new options -
> haven't tested without it, but I'll give it a try tomorrow.

Let's unbreak -O OPT instead? IPv4 client adds list of -O options
to outgoing packets using add_client_options(), like this:

static void add_client_options(struct dhcp_packet *packet)
{
...
        end = udhcp_end_option(packet->options);
        len = 0;
        for (i = 1; i < DHCP_END; i++) {
                if (client_config.opt_mask[i >> 3] & (1 << (i & 7))) {
                        packet->options[end + OPT_DATA + len] = i;
                        len++;
                }
        }
...
}

static NOINLINE int send_discover(uint32_t xid, uint32_t requested)
{
        struct dhcp_packet packet;

        /* Fill in: op, htype, hlen, cookie, chaddr fields,
         * random xid field (we override it below),
         * client-id option (unless -C), message type option:
         */
        init_packet(&packet, DHCPDISCOVER);

        packet.xid = xid;
        if (requested)
                udhcp_add_simple_option(&packet, DHCP_REQUESTED_IP, requested);

        /* Add options: maxsize,
         * optionally: hostname, fqdn, vendorclass,
         * "param req" option according to -O, options specified with -x
         */
        add_client_options(&packet);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        bb_error_msg("sending %s", "discover");
        return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY);
}

IPv6 client does not do it:

static NOINLINE int send_d6_discover(uint32_t xid, struct in6_addr
*requested_ipv6)
{
        struct d6_packet packet;
        uint8_t *opt_ptr;
        unsigned len;

        /* Fill in: msg type, client id */
        opt_ptr = init_d6_packet(&packet, D6_MSG_SOLICIT, xid);

        /* Create new IA_NA, optionally with included IAADDR with
requested IP */
        free(client6_data.ia_na);
        len = requested_ipv6 ? 2+2+4+4+4 + 2+2+16+4+4 : 2+2+4+4+4;
        client6_data.ia_na = xzalloc(len);
        client6_data.ia_na->code = D6_OPT_IA_NA;
        client6_data.ia_na->len = len - 4;
        *(uint32_t*)client6_data.ia_na->data = rand(); /* IAID */
        if (requested_ipv6) {
                struct d6_option *iaaddr =
(void*)(client6_data.ia_na->data + 4+4+4);
                iaaddr->code = D6_OPT_IAADDR;
                iaaddr->len = 16+4+4;
                memcpy(iaaddr->data, requested_ipv6, 16);
        }
        opt_ptr = mempcpy(opt_ptr, client6_data.ia_na, len);

        /* Request additional options */
        opt_ptr = mempcpy(opt_ptr, &opt_req, sizeof(opt_req));
        opt_ptr = mempcpy(opt_ptr, &opt_fqdn_req, sizeof(opt_fqdn_req));

        /* Add options:
         * "param req" option according to -O, options specified with -x
         */
        opt_ptr = add_d6_client_options(opt_ptr);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

        bb_error_msg("sending %s", "discover");
        return d6_mcast_from_client_config_ifindex(&packet, opt_ptr);
}

but add_d6_client_options() is a dummy function: currently it simply
returns opt_ptr.

What it needs to do is look at client_config.opt_mask, and if
there are requested opts, append OPTION_ORO at opt_ptr:

      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |           OPTION_ORO          |           option-len          |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |    requested-option-code-1    |    requested-option-code-2    |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |                              ...                              |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

(And opt_req[] needs to die then).

Can you try making a patch?
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to