Skip to content

Commit

Permalink
odhcp6c: fix empty ORO and unblock DHCPV6_OPT_SOL_MAX_RT for request/…
Browse files Browse the repository at this point in the history
…renew/rebind
  • Loading branch information
themiron committed Dec 16, 2019
1 parent e6ebf11 commit 1bdbc8e
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions release/src/router/odhcp6c/src/dhcpv6.c
Expand Up @@ -239,6 +239,7 @@ int init_dhcpv6(const char *ifname, unsigned int options, int sol_timeout)

enum {
IOV_HDR=0,
IOV_HDR_ORO,
IOV_ORO,
IOV_CL_ID,
IOV_SRV_ID,
Expand Down Expand Up @@ -456,8 +457,21 @@ static void dhcpv6_send(enum dhcpv6_msg type, uint8_t trid[3], uint32_t ecs)
if (!(opt->flags & OPT_ORO))
continue;

/* TODO: warn upstream about DHCPV6_OPT_SOL_MAX_RT for request/renew/rebind */
#if 0
if ((opt->flags & OPT_ORO_SOLICIT) && type != DHCPV6_MSG_SOLICIT)
continue;
#else
if (opt->flags & OPT_ORO_SOLICIT) switch (type) {
case DHCPV6_MSG_SOLICIT:
case DHCPV6_MSG_REQUEST:
case DHCPV6_MSG_RENEW:
case DHCPV6_MSG_REBIND:
break;
default:
continue;
}
#endif

if ((opt->flags & OPT_ORO_STATELESS) && type != DHCPV6_MSG_INFO_REQ)
continue;
Expand All @@ -477,17 +491,22 @@ static void dhcpv6_send(enum dhcpv6_msg type, uint8_t trid[3], uint32_t ecs)
uint16_t elapsed_type;
uint16_t elapsed_len;
uint16_t elapsed_value;
uint16_t oro_type;
uint16_t oro_len;
} hdr = {
type, {trid[0], trid[1], trid[2]},
htons(DHCPV6_OPT_ELAPSED), htons(2),
htons((ecs > 0xffff) ? 0xffff : ecs),
};

struct {
uint16_t oro_type;
uint16_t oro_len;
} hdr_oro = {
htons(DHCPV6_OPT_ORO), htons(oro_len),
};

struct iovec iov[IOV_TOTAL] = {
[IOV_HDR] = {&hdr, sizeof(hdr)},
[IOV_HDR_ORO] = {&hdr_oro, oro_len ? sizeof(hdr_oro) : 0},
[IOV_ORO] = {oro, oro_len},
[IOV_CL_ID] = {cl_id, cl_id_len},
[IOV_SRV_ID] = {srv_id, srv_id_len},
Expand Down

0 comments on commit 1bdbc8e

Please sign in to comment.